use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class TupleStoreUtil method getSizeOfDistributionGroupAndRegionId.
/**
* Get the size of all sstables in the distribution group and region id
* @param distributionGroupName
* @param regionId
* @return
* @throws StorageManagerException
*/
public static long getSizeOfDistributionGroupAndRegionId(final TupleStoreManagerRegistry registry, final String distributionGroupName, final long regionId) throws StorageManagerException {
final List<TupleStoreName> tables = getAllTablesForDistributionGroupAndRegionId(registry, distributionGroupName, regionId);
long totalSize = 0;
for (TupleStoreName ssTableName : tables) {
totalSize = totalSize + registry.getTupleStoreManager(ssTableName).getSize();
}
return totalSize;
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class TupleStoreZookeeperObserver method registerTable.
/**
* Register a new table, a callback is registered on the space partitioner
* to delete the table when it is split or merged
*
* @param tupleStoreName
*/
public void registerTable(final TupleStoreName tupleStoreName) {
if (!tupleStoreName.isDistributedTable()) {
return;
}
final String distributionGroup = tupleStoreName.getDistributionGroup();
final DistributionRegionEntity tableEntity = new DistributionRegionEntity(distributionGroup, tupleStoreName.getRegionId().getAsLong());
synchronized (knownRegions) {
if (knownRegions.contains(tableEntity)) {
return;
}
// Register callback
final DistributionRegionCallback callback = (e, r) -> {
handleCallback(tableEntity, e, r);
};
try {
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
spacePartitioner.registerCallback(callback);
knownRegions.add(tableEntity);
} catch (BBoxDBException e) {
logger.error("Unable to register callback", e);
}
}
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class TupleStoreZookeeperObserver method deleteAllDeletedTables.
/**
* Delete all deleted tables
*
* @param distributionGroup
* @param allZookeeperTables
* @throws BBoxDBException
* @throws StorageManagerException
*/
private void deleteAllDeletedTables(final String distributionGroup, final List<String> allZookeeperTables) throws BBoxDBException, StorageManagerException {
final List<TupleStoreName> allLocalTables = registry.getAllTablesForDistributionGroup(distributionGroup);
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
final DistributionRegionIdMapper regionIdMapper = spacePartitioner.getDistributionRegionIdMapper();
for (final TupleStoreName localTable : allLocalTables) {
final String localTableName = localTable.getFullnameWithoutPrefix();
if (!allZookeeperTables.contains(localTableName)) {
logger.info("Table {} is not known in zookeeper, deleting local", localTableName);
final Collection<TupleStoreName> localTables = regionIdMapper.getAllLocalTables(localTable);
for (final TupleStoreName ssTableName : localTables) {
registry.deleteTable(ssTableName, false);
}
}
}
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method testDecodePackage.
/**
* Decode an encoded package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void testDecodePackage() throws IOException, PackageEncodeException {
final Tuple tuple = new Tuple("key", BoundingBox.FULL_SPACE, "abc".getBytes(), 12);
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final InsertTupleRequest insertPackage = new InsertTupleRequest(sequenceNumber, ROUTING_HEADER_UNROUTED, new TupleStoreName("test"), tuple);
byte[] encodedPackage = networkPackageToByte(insertPackage);
Assert.assertNotNull(encodedPackage);
final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedPackage);
boolean result = NetworkPackageDecoder.validateRequestPackageHeader(bb, NetworkConst.REQUEST_TYPE_INSERT_TUPLE);
Assert.assertTrue(result);
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method testGetSequenceNumber.
/**
* Get the sequence number from a package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void testGetSequenceNumber() throws IOException, PackageEncodeException {
final Tuple tuple = new Tuple("key", BoundingBox.FULL_SPACE, "abc".getBytes(), 12);
// Increment to avoid sequenceNumber = 0
sequenceNumberGenerator.getNextSequenceNummber();
sequenceNumberGenerator.getNextSequenceNummber();
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final InsertTupleRequest insertPackage = new InsertTupleRequest(sequenceNumber, ROUTING_HEADER_UNROUTED, new TupleStoreName("test"), tuple);
final byte[] encodedPackage = networkPackageToByte(insertPackage);
final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedPackage);
final short packageSequencenNumber = NetworkPackageDecoder.getRequestIDFromRequestPackage(bb);
Assert.assertEquals(sequenceNumber, packageSequencenNumber);
}
Aggregations