Skip to content

Commit

Permalink
First iteration of review comment fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvest committed Jul 19, 2018
1 parent 340909f commit e8f4148
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
Expand Up @@ -35,6 +35,8 @@
*/ */
public interface IndexReference extends IndexCapability public interface IndexReference extends IndexCapability
{ {
String UNNAMED_INDEX = "Unnamed index";

/** /**
* Returns true if this index only allows one value per key. * Returns true if this index only allows one value per key.
*/ */
Expand All @@ -60,6 +62,9 @@ public interface IndexReference extends IndexCapability
*/ */
String providerVersion(); String providerVersion();


/**
* The unique name for this index - either automatically generated or user supplied - or the {@link #UNNAMED_INDEX} constant.
*/
String name(); String name();


/** /**
Expand Down Expand Up @@ -135,7 +140,7 @@ public String providerVersion()
@Override @Override
public String name() public String name()
{ {
return null; return UNNAMED_INDEX;
} }
}; };
} }
Expand Up @@ -64,11 +64,11 @@ public interface SchemaRead
IndexReference indexReferenceUnchecked( int label, int... properties ); IndexReference indexReferenceUnchecked( int label, int... properties );


/** /**
* Acquire an index reference of the given {@code label} and {@code properties}. This method does not assert * Acquire an index reference of the given {@link SchemaDescriptor}. This method does not assert
* that the created reference points to a valid online index. * that the created reference points to a valid online index.
* *
* @param schema {@link SchemaDescriptor} for the index * @param schema {@link SchemaDescriptor} for the index.
* @return a IndexReference for the given label and properties * @return a IndexReference for the given schema.
*/ */
IndexReference indexReferenceUnchecked( SchemaDescriptor schema ); IndexReference indexReferenceUnchecked( SchemaDescriptor schema );


Expand Down
Expand Up @@ -26,5 +26,5 @@ public interface WaitStrategy<EXCEPTION extends Exception>
* Throws Exception to force users of this interface to handle any possible failure, since this is used in * Throws Exception to force users of this interface to handle any possible failure, since this is used in
* potentially very sensitive code. * potentially very sensitive code.
*/ */
void apply( long iteration, boolean exclusive ) throws EXCEPTION; void apply( long iteration ) throws EXCEPTION;
} }
Expand Up @@ -408,7 +408,7 @@ public IndexReference indexReferenceUnchecked( SchemaDescriptor schema )
@Override @Override
public Iterator<IndexReference> indexesGetForLabel( int labelId ) public Iterator<IndexReference> indexesGetForLabel( int labelId )
{ {
sharedOptimisticLock( ResourceTypes.LABEL, labelId ); acquireSharedLock( ResourceTypes.LABEL, labelId );
ktx.assertOpen(); ktx.assertOpen();


Iterator<? extends IndexDescriptor> iterator = storageReader.indexesGetForLabel( labelId ); Iterator<? extends IndexDescriptor> iterator = storageReader.indexesGetForLabel( labelId );
Expand Down Expand Up @@ -691,7 +691,7 @@ public boolean constraintExists( ConstraintDescriptor descriptor )
@Override @Override
public Iterator<ConstraintDescriptor> constraintsGetForLabel( int labelId ) public Iterator<ConstraintDescriptor> constraintsGetForLabel( int labelId )
{ {
sharedOptimisticLock( ResourceTypes.LABEL, labelId ); acquireSharedLock( ResourceTypes.LABEL, labelId );
ktx.assertOpen(); ktx.assertOpen();
Iterator<ConstraintDescriptor> constraints = storageReader.constraintsGetForLabel( labelId ); Iterator<ConstraintDescriptor> constraints = storageReader.constraintsGetForLabel( labelId );
if ( ktx.hasTxStateWithChanges() ) if ( ktx.hasTxStateWithChanges() )
Expand Down Expand Up @@ -721,7 +721,7 @@ public Iterator<ConstraintDescriptor> constraintsGetAll()
@Override @Override
public Iterator<ConstraintDescriptor> constraintsGetForRelationshipType( int typeId ) public Iterator<ConstraintDescriptor> constraintsGetForRelationshipType( int typeId )
{ {
sharedOptimisticLock( ResourceTypes.RELATIONSHIP_TYPE, typeId ); acquireSharedLock( ResourceTypes.RELATIONSHIP_TYPE, typeId );
ktx.assertOpen(); ktx.assertOpen();
Iterator<ConstraintDescriptor> constraints = storageReader.constraintsGetForRelationshipType( typeId ); Iterator<ConstraintDescriptor> constraints = storageReader.constraintsGetForRelationshipType( typeId );
if ( ktx.hasTxStateWithChanges() ) if ( ktx.hasTxStateWithChanges() )
Expand Down
Expand Up @@ -641,7 +641,7 @@ void acquireSharedSchemaLock( SchemaDescriptor schema )
ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), schema.keyType(), lockingIds ); ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), schema.keyType(), lockingIds );
} }


void sharedOptimisticLock( ResourceType resource, long resourceId ) void acquireSharedLock( ResourceType resource, long resourceId )
{ {
ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), resource, resourceId ); ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), resource, resourceId );
} }
Expand Down
Expand Up @@ -30,7 +30,7 @@ public enum LockWaitStrategies implements WaitStrategy<AcquireLockTimeoutExcepti
SPIN SPIN
{ {
@Override @Override
public void apply( long iteration, boolean exclusive ) throws AcquireLockTimeoutException public void apply( long iteration ) throws AcquireLockTimeoutException
{ {
// TODO We can experiment with introducing branch mispredictions here, to create // TODO We can experiment with introducing branch mispredictions here, to create
// TODO bubbles in the pipeline that'll allow hyper-threaded threads on the // TODO bubbles in the pipeline that'll allow hyper-threaded threads on the
Expand All @@ -43,7 +43,7 @@ public void apply( long iteration, boolean exclusive ) throws AcquireLockTimeout
YIELD YIELD
{ {
@Override @Override
public void apply( long iteration, boolean exclusive ) throws AcquireLockTimeoutException public void apply( long iteration ) throws AcquireLockTimeoutException
{ {
Thread.yield(); Thread.yield();
} }
Expand All @@ -54,11 +54,11 @@ public void apply( long iteration, boolean exclusive ) throws AcquireLockTimeout
private static final long multiplyUntilIteration = spinIterations + 2; private static final long multiplyUntilIteration = spinIterations + 2;


@Override @Override
public void apply( long iteration, boolean exclusive ) throws AcquireLockTimeoutException public void apply( long iteration ) throws AcquireLockTimeoutException
{ {
if ( iteration < spinIterations ) if ( iteration < spinIterations )
{ {
SPIN.apply( iteration, exclusive ); SPIN.apply( iteration );
return; return;
} }


Expand All @@ -83,7 +83,7 @@ public void apply( long iteration, boolean exclusive ) throws AcquireLockTimeout
NO_WAIT NO_WAIT
{ {
@Override @Override
public void apply( long iteration, boolean exclusive ) public void apply( long iteration )
throws AcquireLockTimeoutException throws AcquireLockTimeoutException
{ {
// The NO_WAIT bail-out is a mix of deadlock and lock acquire timeout. // The NO_WAIT bail-out is a mix of deadlock and lock acquire timeout.
Expand Down
Expand Up @@ -144,11 +144,6 @@ public boolean exists() throws IOException
return true; return true;
} }


public File getIndexFolder()
{
return indexStorage.getIndexFolder();
}

/** /**
* Verify state of the index. * Verify state of the index.
* If index is already open and in use method assume that index is valid since lucene already operating with it, * If index is already open and in use method assume that index is valid since lucene already operating with it,
Expand Down
Expand Up @@ -968,7 +968,7 @@ private void waitFor( ForsetiLockManager.Lock lock, ResourceType type, long reso
{ {
waitingForLock = lock; waitingForLock = lock;
clearAndCopyWaitList( lock ); clearAndCopyWaitList( lock );
waitStrategies[type.typeId()].apply( tries, exclusive ); waitStrategies[type.typeId()].apply( tries );


int b = lock.detectDeadlock( id() ); int b = lock.detectDeadlock( id() );
if ( b != -1 && deadlockResolutionStrategy.shouldAbort( this, clientById.apply( b ) ) ) if ( b != -1 && deadlockResolutionStrategy.shouldAbort( this, clientById.apply( b ) ) )
Expand Down

0 comments on commit e8f4148

Please sign in to comment.