Skip to content

Commit

Permalink
pool: Simplify synchronization during repository setup
Browse files Browse the repository at this point in the history
Motivation:

Simplify the various synchronization logic of CacheRepositoryV5.

Modification:

Do not synchronize setters for parameters that must be called
before initializing the repository. This is often referred to
as threadsafe once configured.

Result:

Synchronization on the repository is limited to state that
actually changes during the operation of the repository.

Target: trunk
Require-notes: no
Require-book: no
Request: 2.14
Request: 2.13
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: https://rb.dcache.org/r/8928
  • Loading branch information
gbehrmann committed Jan 12, 2016
1 parent a8edc26 commit 0f18c8b
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
/**
* Implementation of Repository interface.
*
* The class is thread-safe.
* The class is thread-safe after initialization.
*
* Allows openEntry, getEntry, getState and setSticky to be called
* before the load method finishes. Other methods of the Repository
Expand Down Expand Up @@ -224,7 +224,7 @@ private void assertInitialized()
* The executor is used for periodic background checks and sticky
* flag expiration.
*/
public synchronized void setExecutor(ScheduledExecutorService executor)
public void setExecutor(ScheduledExecutorService executor)
{
assertUninitialized();
_executor = executor;
Expand All @@ -233,13 +233,13 @@ public synchronized void setExecutor(ScheduledExecutorService executor)
/**
* Sets the handler for talking to the PNFS manager.
*/
public synchronized void setPnfsHandler(PnfsHandler pnfs)
public void setPnfsHandler(PnfsHandler pnfs)
{
assertUninitialized();
_pnfs = pnfs;
}

public synchronized boolean getVolatile()
public boolean getVolatile()
{
return _volatile;
}
Expand All @@ -249,7 +249,7 @@ public synchronized boolean getVolatile()
* ClearCacheLocation messages are flagged to trigger deletion of
* the namespace entry when the last known replica is deleted.
*/
public synchronized void setVolatile(boolean value)
public void setVolatile(boolean value)
{
assertUninitialized();
_volatile = value;
Expand All @@ -258,7 +258,7 @@ public synchronized void setVolatile(boolean value)
/**
* The account keeps track of available space.
*/
public synchronized void setAccount(Account account)
public void setAccount(Account account)
{
assertUninitialized();
_account = account;
Expand All @@ -267,25 +267,25 @@ public synchronized void setAccount(Account account)
/**
* The allocator implements an allocation policy.
*/
public synchronized void setAllocator(Allocator allocator)
public void setAllocator(Allocator allocator)
{
assertUninitialized();
_allocator = allocator;
}

public synchronized void setMetaDataStore(MetaDataStore store)
public void setMetaDataStore(MetaDataStore store)
{
assertUninitialized();
_store = store;
}

public synchronized void setSpaceSweeperPolicy(SpaceSweeperPolicy sweeper)
public void setSpaceSweeperPolicy(SpaceSweeperPolicy sweeper)
{
assertUninitialized();
_sweeper = sweeper;
}

public synchronized void setMaxDiskSpaceString(String size)
public void setMaxDiskSpaceString(String size)
{
setMaxDiskSpace(UnitInteger.parseUnitLong(size));
}
Expand All @@ -301,7 +301,7 @@ public synchronized void setMaxDiskSpace(long size)
}
}

public synchronized State getState()
public State getState()
{
return _state;
}
Expand All @@ -310,11 +310,11 @@ public synchronized State getState()
public void init()
throws IllegalStateException, CacheException
{
synchronized (this) {
assert _pnfs != null : "Pnfs handler must be set";
assert _account != null : "Account must be set";
assert _allocator != null : "Account must be set";
assert _pnfs != null : "Pnfs handler must be set";
assert _account != null : "Account must be set";
assert _allocator != null : "Account must be set";

synchronized (this) {
if (_state != State.UNINITIALIZED) {
throw new IllegalStateException("Can only initialize repository once.");
}
Expand Down

0 comments on commit 0f18c8b

Please sign in to comment.