use of voldemort.client.scheduler.AsyncMetadataVersionManager in project voldemort by voldemort.
the class AsyncMetadataVersionManagerTest method testStoreDefinitionChangeTracker.
/*
* Validates that the AsyncMetadataVersionManager correctly identifies the
* store specific version update. This is done by initializing the base
* metadata version (for a particular store), starting the
* AsyncMetadataVersionManager and then updating the version to a new value.
* For the test to succeed the callback has to be invoked correctly by the
* asynchronous manager.
*/
@Test(timeout = 60000)
public void testStoreDefinitionChangeTracker() {
String storeVersionKey = "users";
Callable<Void> rebootstrapCallback = new Callable<Void>() {
public Void call() throws Exception {
callbackForStoreChange();
return null;
}
};
try {
// Write a base version of 100
Properties versionProps = MetadataVersionStoreUtils.getProperties(this.sysVersionStore);
versionProps.setProperty(storeVersionKey, Long.toString(100));
MetadataVersionStoreUtils.setProperties(this.sysVersionStore, versionProps);
// Giving enough time to complete the above put.
Thread.sleep(500);
// Starting the Version Metadata Manager
this.asyncCheckMetadata = new AsyncMetadataVersionManager(this.repository, rebootstrapCallback, storeVersionKey);
scheduler.schedule(asyncCheckMetadata.getClass().getName(), asyncCheckMetadata, new Date(), 500);
// Wait until the Version Manager is active
while (!asyncCheckMetadata.isActive) {
Thread.sleep(500);
}
// Updating the version metadata here for the Version Metadata
// Manager to detect
this.newVersion = 101;
System.err.println("Incrementing the version for : " + storeVersionKey);
versionProps.setProperty(storeVersionKey, Long.toString(this.newVersion));
MetadataVersionStoreUtils.setProperties(this.sysVersionStore, versionProps);
while (!callbackDone) {
Thread.sleep(2000);
}
assertEquals(false, (this.updatedStoreVersion == 0));
assertEquals(this.updatedStoreVersion, this.newVersion);
} catch (Exception e) {
e.printStackTrace();
fail("Failed to start the Metadata Version Manager : " + e.getMessage());
}
}
Aggregations