Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SlaveLockClient cope better with ComExceptions #6102

Merged
merged 7 commits into from Dec 18, 2015

This file was deleted.

Expand Up @@ -19,29 +19,10 @@
*/
package org.neo4j.kernel.impl.locking;

import org.neo4j.kernel.api.KernelTransaction;

/**
* Enum defining the <CODE>READ</CODE> lock and the <CODE>WRITE</CODE> lock.
*/
public enum LockType
{
READ
{
@Override
public void release( LockManager lockManager, Object resource, KernelTransaction tx )
{
lockManager.releaseReadLock( resource, tx );
}
},
WRITE
{
@Override
public void release( LockManager lockManager, Object resource, KernelTransaction tx )
{
lockManager.releaseWriteLock( resource, tx );
}
};

public abstract void release( LockManager lockManager, Object resource, KernelTransaction tx );
READ, WRITE
}
Expand Up @@ -98,12 +98,6 @@ interface Client extends AutoCloseable
/** Release a set of exclusive locks */
void releaseExclusive( ResourceType resourceType, long... resourceIds );

/** Release all shared locks. */
void releaseAllShared();

/** Release all exclusive locks. */
void releaseAllExclusive();

/** Release all locks. */
void releaseAll();

Expand Down
Expand Up @@ -53,16 +53,6 @@ public void releaseExclusive( Locks.ResourceType resourceType, long... resourceI
{
}

@Override
public void releaseAllShared()
{
}

@Override
public void releaseAllExclusive()
{
}

@Override
public void releaseAll()
{
Expand Down
Expand Up @@ -165,15 +165,13 @@ public void releaseExclusive( Locks.ResourceType resourceType, long... resourceI
}
}

@Override
public void releaseAllShared()
private void releaseAllShared()
{
sharedLocks.visitEntries( typeReadReleaser );
sharedLocks.clear();
}

@Override
public void releaseAllExclusive()
private void releaseAllExclusive()
{
exclusiveLocks.visitEntries( typeWriteReleaser );
exclusiveLocks.clear();
Expand Down
Expand Up @@ -24,12 +24,11 @@

import org.neo4j.helpers.collection.Visitor;
import org.neo4j.kernel.DeadlockDetectedException;
import org.neo4j.kernel.impl.locking.LockManager;
import org.neo4j.kernel.impl.transaction.IllegalResourceException;
import org.neo4j.kernel.impl.util.StringLogger;
import org.neo4j.kernel.logging.Logging;

public class LockManagerImpl implements LockManager
public class LockManagerImpl
{
private final Map<Object,RWLock> resourceLockMap = new HashMap<>();
private final RagManager ragManager;
Expand All @@ -39,58 +38,50 @@ public LockManagerImpl( RagManager ragManager )
this.ragManager = ragManager;
}

@Override
public long getDetectedDeadlockCount()
{
return ragManager.getDeadlockCount();
}

@Override
public void getReadLock( Object resource, Object tx )
throws DeadlockDetectedException, IllegalResourceException
{
getRWLockForAcquiring( resource, tx ).acquireReadLock( tx );
}

@Override
public boolean tryReadLock( Object resource, Object tx )
throws IllegalResourceException
{
return getRWLockForAcquiring( resource, tx ).tryAcquireReadLock( tx );
}

@Override
public void getWriteLock( Object resource, Object tx )
throws DeadlockDetectedException, IllegalResourceException
{
getRWLockForAcquiring( resource, tx ).acquireWriteLock( tx );
}

@Override
public boolean tryWriteLock( Object resource, Object tx )
throws IllegalResourceException
{
return getRWLockForAcquiring( resource, tx ).tryAcquireWriteLock( tx );
}

@Override
public void releaseReadLock( Object resource, Object tx )
throws LockNotFoundException, IllegalResourceException
{
getRWLockForReleasing( resource, tx, 1, 0 ).releaseReadLock( tx );
}

@Override
public void releaseWriteLock( Object resource, Object tx )
throws LockNotFoundException, IllegalResourceException
{
getRWLockForReleasing( resource, tx, 0, 1 ).releaseWriteLock( tx );
}

@Override
public void dumpLocksOnResource( Object resource, Logging logging )
{
StringLogger logger = logging.getMessagesLog( LockManager.class );
StringLogger logger = logging.getMessagesLog( LockManagerImpl.class );
RWLock lock;
synchronized ( resourceLockMap )
{
Expand Down