Skip to content

Commit

Permalink
Merge pull request #145 from amcp/testRefactor
Browse files Browse the repository at this point in the history
Make optimisticLocking a StoreFeature. Silence noisy kcvslog test.
  • Loading branch information
Alexander Patrikalakis authored Mar 3, 2017
2 parents 8ab4627 + db95f25 commit 4e1b92c
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public BerkeleyJEStoreManager(Configuration configuration) throws BackendExcepti
.scanTxConfig(GraphDatabaseConfiguration.buildGraphConfiguration()
.set(ISOLATION_LEVEL, IsolationLevel.READ_UNCOMMITTED.toString()))
.supportsInterruption(false)
.optimisticLocking(false)
.build();

// features = new StoreFeatures();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public void testConsistencyEnforcement() {
super.testConsistencyEnforcement();
}

@Override
protected boolean isLockingOptimistic() {
return false;
}

@Override
public void testConcurrentConsistencyEnforcement() {
//Do nothing TODO: Figure out why this is failing in BerkeleyDB!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,4 @@ public WriteConfiguration getBaseConfiguration() {
return BerkeleyStorageSetup.getBerkeleyJEGraphConfiguration();
}

@Override
public boolean storeUsesConsistentKeyLocker() {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public StoreFeatures getFeatures() {
fb.batchMutation(true).distributed(true);
fb.timestamps(true).cellTTL(true);
fb.keyConsistent(global, local);
fb.optimisticLocking(true);

boolean keyOrdered;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public static void startCassandra() {
CassandraStorageSetup.startCleanEmbedded();
}

@Override
protected boolean isLockingOptimistic() {
return true;
}

@Test
public void testHasTTL() throws Exception {
assertTrue(features.hasCellTTL());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,4 @@ public WriteConfiguration getConfiguration() {
public static void beforeClass() {
CassandraStorageSetup.startCleanEmbedded();
}



@Override
protected boolean isLockingOptimistic() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,4 @@ public WriteConfiguration getBaseConfiguration() {
return CassandraStorageSetup.getCassandraThriftGraphConfiguration(getClass().getSimpleName());
}

@Override
public boolean storeUsesConsistentKeyLocker() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class StandardStoreFeatures implements StoreFeatures {
private final Configuration localKeyConsistentTxConfig;
private final Configuration scanTxConfig;
private final boolean supportsInterruption;
private final boolean optimisticLocking;

@Override
public boolean hasScan() {
Expand Down Expand Up @@ -147,6 +148,11 @@ public boolean supportsInterruption()
return supportsInterruption;
}

@Override
public boolean hasOptimisticLocking() {
return optimisticLocking;
}

/**
* The only way to instantiate {@link StandardStoreFeatures}.
*/
Expand All @@ -172,6 +178,7 @@ public static class Builder {
private Configuration localKeyConsistentTxConfig;
private Configuration scanTxConfig;
private boolean supportsInterruption = true;
private boolean optimisticLocking;

/**
* Construct a Builder with everything disabled/unsupported/false/null.
Expand Down Expand Up @@ -203,6 +210,12 @@ public Builder(StoreFeatures template) {
}
scanTxConfig(template.getScanTxConfig());
supportsInterruption(template.supportsInterruption());
optimisticLocking(template.hasOptimisticLocking());
}

public Builder optimisticLocking(boolean b) {
optimisticLocking = b;
return this;
}

public Builder unorderedScan(boolean b) {
Expand Down Expand Up @@ -317,7 +330,7 @@ public StandardStoreFeatures build() {
timestamps, preferredTimestamps, cellLevelTTL,
storeLevelTTL, visibility, supportsPersist,
keyConsistentTxConfig,
localKeyConsistentTxConfig, scanTxConfig, supportsInterruption);
localKeyConsistentTxConfig, scanTxConfig, supportsInterruption, optimisticLocking);
}
}

Expand All @@ -330,7 +343,7 @@ private StandardStoreFeatures(boolean unorderedScan, boolean orderedScan,
boolean visibility, boolean supportsPersist,
Configuration keyConsistentTxConfig,
Configuration localKeyConsistentTxConfig,
Configuration scanTxConfig, boolean supportsInterruption) {
Configuration scanTxConfig, boolean supportsInterruption, boolean optimisticLocking) {
this.unorderedScan = unorderedScan;
this.orderedScan = orderedScan;
this.multiQuery = multiQuery;
Expand All @@ -351,5 +364,6 @@ private StandardStoreFeatures(boolean unorderedScan, boolean orderedScan,
this.localKeyConsistentTxConfig = localKeyConsistentTxConfig;
this.scanTxConfig = scanTxConfig;
this.supportsInterruption = supportsInterruption;
this.optimisticLocking = optimisticLocking;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,58 +30,58 @@ public interface StoreFeatures {
* Equivalent to calling {@link #hasUnorderedScan()} {@code ||}
* {@link #hasOrderedScan()}.
*/
public boolean hasScan();
boolean hasScan();

/**
* Whether this storage backend supports global key scans via
* {@link KeyColumnValueStore#getKeys(SliceQuery, StoreTransaction)}.
*/
public boolean hasUnorderedScan();
boolean hasUnorderedScan();

/**
* Whether this storage backend supports global key scans via
* {@link KeyColumnValueStore#getKeys(KeyRangeQuery, StoreTransaction)}.
*/
public boolean hasOrderedScan();
boolean hasOrderedScan();

/**
* Whether this storage backend supports query operations on multiple keys
* via
* {@link KeyColumnValueStore#getSlice(java.util.List, SliceQuery, StoreTransaction)}
*/
public boolean hasMultiQuery();
boolean hasMultiQuery();

/**
* Whether this store supports locking via
* {@link KeyColumnValueStore#acquireLock(org.janusgraph.diskstorage.StaticBuffer, org.janusgraph.diskstorage.StaticBuffer, org.janusgraph.diskstorage.StaticBuffer, StoreTransaction)}
*
*/
public boolean hasLocking();
boolean hasLocking();

/**
* Whether this storage backend supports batch mutations via
* {@link KeyColumnValueStoreManager#mutateMany(java.util.Map, StoreTransaction)}.
*
*/
public boolean hasBatchMutation();
boolean hasBatchMutation();

/**
* Whether this storage backend preserves key locality. This affects JanusGraph's
* use of vertex ID partitioning.
*
*/
public boolean isKeyOrdered();
boolean isKeyOrdered();

/**
* Whether this storage backend writes and reads data from more than one
* machine.
*/
public boolean isDistributed();
boolean isDistributed();

/**
* Whether this storage backend's transactions support isolation.
*/
public boolean hasTxIsolation();
boolean hasTxIsolation();

/**
* Whether this storage backend has a (possibly improper) subset of the
Expand All @@ -92,7 +92,7 @@ public interface StoreFeatures {
* return a valid list as described in that method. If this is false, that
* method will not be invoked.
*/
public boolean hasLocalKeyPartition();
boolean hasLocalKeyPartition();

/**
* Whether this storage backend provides strong consistency within each
Expand All @@ -103,15 +103,15 @@ public interface StoreFeatures {
*
* @return true if the backend supports key-level strong consistency
*/
public boolean isKeyConsistent();
boolean isKeyConsistent();

/**
* Returns true if column-value entries in this storage backend are annotated with a timestamp,
* else false. It is assumed that the timestamp matches the one set during the committing transaction.
*
* @return
*/
public boolean hasTimestamps();
boolean hasTimestamps();

/**
* If this storage backend supports one particular type of data
Expand All @@ -125,7 +125,7 @@ public interface StoreFeatures {
*
* @return null or a Timestamps enum value
*/
public TimestampProviders getPreferredTimestamps();
TimestampProviders getPreferredTimestamps();

/**
* Returns true if this storage backend support time-to-live (TTL) settings for column-value entries. If such a value
Expand All @@ -136,7 +136,7 @@ public interface StoreFeatures {
*
* @return true if the storage backend supports cell-level TTL, else false
*/
public boolean hasCellTTL();
boolean hasCellTTL();

/**
* Returns true if this storage backend supports time-to-live (TTL) settings on a per-store basis. That means, that
Expand All @@ -146,21 +146,21 @@ public interface StoreFeatures {
*
* @return true if the storage backend supports store-level TTL, else false
*/
public boolean hasStoreTTL();
boolean hasStoreTTL();

/**
* Returns true if this storage backend supports entry-level visibility by attaching a visibility or authentication
* token to each column-value entry in the data store and limited retrievals to "visible" entries.
*
* @return
*/
public boolean hasVisibility();
boolean hasVisibility();

/**
* Whether the backend supports data persistence. Return false if the backend is in-memory only.
* @return
*/
public boolean supportsPersistence();
boolean supportsPersistence();

/**
* Get a transaction configuration that enforces key consistency. This
Expand All @@ -169,7 +169,7 @@ public interface StoreFeatures {
*
* @return a key-consistent tx config
*/
public Configuration getKeyConsistentTxConfig();
Configuration getKeyConsistentTxConfig();

/**
* Get a transaction configuration that enforces local key consistency.
Expand All @@ -185,7 +185,7 @@ public interface StoreFeatures {
*
* @return a locally (or globally) key-consistent tx config
*/
public Configuration getLocalKeyConsistentTxConfig();
Configuration getLocalKeyConsistentTxConfig();


/**
Expand All @@ -197,12 +197,20 @@ public interface StoreFeatures {
*
* @return a transaction configuration suitable for scanjob data reading
*/
public Configuration getScanTxConfig();
Configuration getScanTxConfig();


/**
* Whether calls to this manager and its stores may be safely interrupted
* without leaving the underlying system in an inconsistent state.
*/
public boolean supportsInterruption();
boolean supportsInterruption();

/**
* Whether the store will commit pending mutations optimistically and make other pending changes
* to the same cells fail on tx.commit() (true) or will fail pending mutations pessimistically on tx.commit()
* if other parallel transactions have already marked the relevant cells dirty.
* @return
*/
boolean hasOptimisticLocking();
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public InMemoryStoreManager(final Configuration configuration) {
.unorderedScan(true)
.keyOrdered(true)
.persists(false)
.optimisticLocking(true)
.keyConsistent(GraphDatabaseConfiguration.buildGraphConfiguration())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public StoreFeatures getFeatures() {
.orderedScan(true).unorderedScan(true).batchMutation(true)
.multiQuery(true).distributed(true).keyOrdered(true).storeTTL(true)
.timestamps(true).preferredTimestamps(PREFERRED_TIMESTAMPS)
.keyConsistent(c);
.optimisticLocking(true).keyConsistent(c);

try {
fb.localKeyPartition(getDeployment() == Deployment.LOCAL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,4 @@ public WriteConfiguration getConfiguration() {
return HBaseStorageSetup.getHBaseGraphConfiguration();
}

@Override
protected boolean isLockingOptimistic() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ public static void startHBase() throws IOException {
HBaseStorageSetup.startHBase();
}

@Override
public boolean storeUsesConsistentKeyLocker() {
return true;
}

@Override
public void testCacheConcurrency() throws InterruptedException {
//Don't run this test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public abstract class LockKeyColumnValueStoreTest extends AbstractKCVSTest {

private StaticBuffer k, c1, c2, v1, v2;

private final String concreteClassName;
protected final String concreteClassName;

public LockKeyColumnValueStoreTest() {
concreteClassName = getClass().getSimpleName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public void processMessage(Message message) {
StaticBuffer content = message.getContent();
assertEquals(8,content.length());
long value = content.getLong(0);
log.info("Read log value {} by senderid \"{}\"", value, message.getSenderId());
log.debug("Read log value {} by senderid \"{}\"", value, message.getSenderId());
if (expectIncreasingValues) {
assertTrue("Message out of order or duplicated: " + lastMessageValue + " preceded " + value, lastMessageValue<value);
lastMessageValue = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,11 @@ public void run() {
*/
@Test
public void testStandardIndexVertexPropertyReads() throws InterruptedException, ExecutionException {
final int propCount = THREAD_COUNT * 5;
testStandardIndexVertexPropertyReadsLogic(THREAD_COUNT);
}

protected void testStandardIndexVertexPropertyReadsLogic(int numThreads) throws InterruptedException, ExecutionException {
final int propCount = numThreads * 5;
final int vertexCount = 1 * 1000;
// Create props with standard indexes
log.info("Creating types");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public abstract class JanusGraphOperationCountingTest extends JanusGraphBaseTest

public abstract WriteConfiguration getBaseConfiguration();

public abstract boolean storeUsesConsistentKeyLocker();
public final boolean storeUsesConsistentKeyLocker() {
return !this.features.hasLocking();
}

@Override
public WriteConfiguration getConfiguration() {
Expand Down
Loading

0 comments on commit 4e1b92c

Please sign in to comment.