use of org.bboxdb.storage.entity.DistributionGroupMetadata in project bboxdb by jnidzwetzki.
the class TestDistributionGroupMedadata method testReadAndWriteDistributionGroupMetadata.
/**
* Test reading and writing distribution group meta data
* @throws IOException
*/
@Test(timeout = 60000)
public void testReadAndWriteDistributionGroupMetadata() throws IOException {
final DistributionGroupMetadata distributionGroupMetadata1 = new DistributionGroupMetadata();
final DistributionGroupMetadata distributionGroupMetadata2 = new DistributionGroupMetadata();
distributionGroupMetadata1.setVersion(10);
distributionGroupMetadata2.setVersion(20);
Assert.assertFalse(distributionGroupMetadata1.equals(distributionGroupMetadata2));
DistributionGroupMetadataHelper.writeMedatadataForGroup(STORAGE_DIRECTORY, DGROUP_NAME, distributionGroupMetadata1);
final DistributionGroupMetadata distributionGroupMetadata1read = DistributionGroupMetadataHelper.getMedatadaForGroup(STORAGE_DIRECTORY, DGROUP_NAME);
DistributionGroupMetadataHelper.writeMedatadataForGroup(STORAGE_DIRECTORY, DGROUP_NAME, distributionGroupMetadata2);
final DistributionGroupMetadata distributionGroupMetadata2read = DistributionGroupMetadataHelper.getMedatadaForGroup(STORAGE_DIRECTORY, DGROUP_NAME);
Assert.assertTrue(distributionGroupMetadata1read.equals(distributionGroupMetadata1));
Assert.assertTrue(distributionGroupMetadata2read.equals(distributionGroupMetadata2));
Assert.assertEquals(distributionGroupMetadata2read.hashCode(), distributionGroupMetadata2.hashCode());
}
use of org.bboxdb.storage.entity.DistributionGroupMetadata in project bboxdb by jnidzwetzki.
the class TupleStoreManager method writeDistributionGroupMetaData.
/**
* Write the meta data for the distribution group
* @throws ZookeeperException
* @throws ZookeeperNotFoundException
* @throws IOException
*/
protected void writeDistributionGroupMetaData() throws ZookeeperException, ZookeeperNotFoundException, IOException {
if (!tupleStoreName.isDistributedTable()) {
return;
}
final String groupName = tupleStoreName.getDistributionGroup();
logger.debug("Write meta data for distribution group: ", groupName);
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
final DistributionGroupAdapter dAdapter = new DistributionGroupAdapter(zookeeperClient);
final String path = dAdapter.getDistributionGroupPath(groupName);
final long version = NodeMutationHelper.getNodeMutationVersion(zookeeperClient, path, null);
DistributionGroupMetadata distributionGroupMetadata = new DistributionGroupMetadata();
distributionGroupMetadata.setVersion(version);
DistributionGroupMetadataHelper.writeMedatadataForGroup(storage.getBasedir().getAbsolutePath(), tupleStoreName.getDistributionGroup(), distributionGroupMetadata);
}
use of org.bboxdb.storage.entity.DistributionGroupMetadata in project bboxdb by jnidzwetzki.
the class TestDistributionGroupMedadata method testToString.
/**
* Test the to sting method
*/
@Test(timeout = 60000)
public void testToString() {
final DistributionGroupMetadata distributionGroupMetadata2 = new DistributionGroupMetadata();
Assert.assertTrue(distributionGroupMetadata2.toString().length() > 10);
}
use of org.bboxdb.storage.entity.DistributionGroupMetadata in project bboxdb by jnidzwetzki.
the class DistributedRecoveryService method checkGroupVersion.
/**
* Check the group version
* @param storage
* @param distributionGroupName
* @param zookeeperClient
*/
protected void checkGroupVersion(final DiskStorage storage, final String distributionGroupName, final ZookeeperClient zookeeperClient) {
try {
final DistributionGroupMetadata metaData = DistributionGroupMetadataHelper.getMedatadaForGroup(storage.getBasedir().getAbsolutePath(), distributionGroupName);
if (metaData == null) {
logger.debug("Metadata for storage {} and group {} is null, skipping check", storage.getBasedir(), distributionGroupName);
return;
}
final DistributionGroupAdapter distributionGroupZookeeperAdapter = new DistributionGroupAdapter(zookeeperClient);
final String path = distributionGroupZookeeperAdapter.getDistributionGroupPath(distributionGroupName);
final long remoteVersion = NodeMutationHelper.getNodeMutationVersion(zookeeperClient, path, null);
final long localVersion = metaData.getVersion();
if (remoteVersion != localVersion) {
logger.error("Local version {} of dgroup {} does not match remtote version {}", localVersion, distributionGroupName, remoteVersion);
System.exit(-1);
}
} catch (ZookeeperException | ZookeeperNotFoundException e) {
logger.error("Got an exception while checking group version");
}
}
Aggregations