Search in sources :

Example 1 with DistributionGroupMetadata

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());
}
Also used : DistributionGroupMetadata(org.bboxdb.storage.entity.DistributionGroupMetadata) Test(org.junit.Test)

Example 2 with DistributionGroupMetadata

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);
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) DistributionGroupMetadata(org.bboxdb.storage.entity.DistributionGroupMetadata)

Example 3 with 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);
}
Also used : DistributionGroupMetadata(org.bboxdb.storage.entity.DistributionGroupMetadata) Test(org.junit.Test)

Example 4 with DistributionGroupMetadata

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");
    }
}
Also used : DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) DistributionGroupMetadata(org.bboxdb.storage.entity.DistributionGroupMetadata)

Aggregations

DistributionGroupMetadata (org.bboxdb.storage.entity.DistributionGroupMetadata)4 DistributionGroupAdapter (org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)2 Test (org.junit.Test)2 ZookeeperClient (org.bboxdb.distribution.zookeeper.ZookeeperClient)1 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)1 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)1