Skip to content

Commit

Permalink
ClientAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint authored and lutovich committed Jul 21, 2016
1 parent 2703374 commit 185ae53
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 40 deletions.
Expand Up @@ -94,7 +94,7 @@ public int compareTo( Resource o )
} }
} }


// TODO the state in this class is quite unoptimized, please do so // TODO the state keeping in this class is quite unoptimized, please do so
private static class DeferringLockClient implements Client private static class DeferringLockClient implements Client
{ {
private final Client clientDelegate; private final Client clientDelegate;
Expand Down
Expand Up @@ -135,4 +135,19 @@ interface Client extends AutoCloseable


/** Visit all held locks. */ /** Visit all held locks. */
void accept(Visitor visitor); void accept(Visitor visitor);

public abstract class ClientAdapter implements Client
{
@Override
public void prepare()
{
// Nothing to prepare
}

@Override
public Client delegate()
{
return this;
}
}
} }
Expand Up @@ -19,7 +19,7 @@
*/ */
package org.neo4j.kernel.impl.locking; package org.neo4j.kernel.impl.locking;


public class NoOpClient implements Locks.Client public class NoOpClient extends Locks.ClientAdapter
{ {
public static final Locks.Client NO_LOCKS = new NoOpClient(); public static final Locks.Client NO_LOCKS = new NoOpClient();


Expand Down Expand Up @@ -60,11 +60,6 @@ public void releaseAll()
{ {
} }


@Override
public void prepare()
{
}

@Override @Override
public void stop() public void stop()
{ {
Expand All @@ -80,10 +75,4 @@ public int getLockSessionId()
{ {
return -1; return -1;
} }

@Override
public Locks.Client delegate()
{
return this;
}
} }
Expand Up @@ -38,7 +38,7 @@
// Please note. Except separate test cases for particular classes related to community locking // Please note. Except separate test cases for particular classes related to community locking
// see also org.neo4j.kernel.impl.locking.community.CommunityLocksCompatibility test suite // see also org.neo4j.kernel.impl.locking.community.CommunityLocksCompatibility test suite


public class CommunityLockClient implements Locks.Client public class CommunityLockClient extends Locks.ClientAdapter
{ {
private final LockManagerImpl manager; private final LockManagerImpl manager;
private final LockTransaction lockTransaction = new LockTransaction(); private final LockTransaction lockTransaction = new LockTransaction();
Expand Down Expand Up @@ -254,12 +254,6 @@ public void releaseAll()
} }
} }


@Override
public void prepare()
{
// Do nothing
}

@Override @Override
public void stop() public void stop()
{ {
Expand Down Expand Up @@ -312,12 +306,6 @@ public int getLockSessionId()
return lockTransaction.getId(); return lockTransaction.getId();
} }


@Override
public Locks.Client delegate()
{
return this;
}

private PrimitiveLongObjectMap<LockResource> localShared( Locks.ResourceType resourceType ) private PrimitiveLongObjectMap<LockResource> localShared( Locks.ResourceType resourceType )
{ {
PrimitiveLongObjectMap<LockResource> map = sharedLocks.get( resourceType.typeId() ); PrimitiveLongObjectMap<LockResource> map = sharedLocks.get( resourceType.typeId() );
Expand Down
Expand Up @@ -50,7 +50,7 @@
* with the master for certain types of locks. If you grab a lock on a node, for instance, this class will grab a * with the master for certain types of locks. If you grab a lock on a node, for instance, this class will grab a
* cluster-global lock by talking to the master machine, and then grab that same lock locally before returning. * cluster-global lock by talking to the master machine, and then grab that same lock locally before returning.
*/ */
class SlaveLocksClient implements Locks.Client class SlaveLocksClient extends Locks.ClientAdapter
{ {
private final Master master; private final Master master;
private final Locks.Client client; private final Locks.Client client;
Expand Down
Expand Up @@ -47,7 +47,7 @@
* local fields how many times the lock has been grabbed, such that it will only grab and release the lock once from the * local fields how many times the lock has been grabbed, such that it will only grab and release the lock once from the
* global lock manager. * global lock manager.
*/ */
public class ForsetiClient implements Locks.Client public class ForsetiClient extends Locks.ClientAdapter
{ {
/** Id for this client */ /** Id for this client */
private final int clientId; private final int clientId;
Expand Down Expand Up @@ -484,12 +484,6 @@ public void releaseAll()
} }
} }


@Override
public void prepare()
{
// Do nothing
}

private void releaseAllClientLocks() private void releaseAllClientLocks()
{ {
// Force the release of all locks held. // Force the release of all locks held.
Expand Down Expand Up @@ -572,12 +566,6 @@ public int getLockSessionId()
return clientId; return clientId;
} }


@Override
public Locks.Client delegate()
{
return this;
}

public int waitListSize() public int waitListSize()
{ {
return waitList.size(); return waitList.size();
Expand Down

0 comments on commit 185ae53

Please sign in to comment.