use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class TupleRedistributor method registerRegion.
/**
* Register a new region for distribution
* @param distributionRegion
* @throws StorageManagerException
* @throws ZookeeperException
*/
public void registerRegion(final DistributionRegion distributionRegion) throws StorageManagerException {
final ArrayList<AbstractTupleSink> sinks = new ArrayList<>();
final Collection<BBoxDBInstance> instances = distributionRegion.getSystems();
final MembershipConnectionService membershipConnectionService = MembershipConnectionService.getInstance();
final BBoxDBInstance localInstance = ZookeeperClientFactory.getLocalInstanceName();
for (final BBoxDBInstance instance : instances) {
if (instance.socketAddressEquals(localInstance)) {
final TupleStoreName localTableName = tupleStoreName.cloneWithDifferntRegionId(distributionRegion.getRegionId());
final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
final TupleStoreConfiguration config = readTuplestoreConfig(localTableName, tupleStoreAdapter);
final TupleStoreManager storageManager = tupleStoreManagerRegistry.createTableIfNotExist(localTableName, config);
final LocalTupleSink tupleSink = new LocalTupleSink(tupleStoreName, storageManager);
sinks.add(tupleSink);
logger.info("Redistributing data to local table {}", localTableName.getFullname());
} else {
final BBoxDBConnection connection = membershipConnectionService.getConnectionForInstance(instance);
final NetworkTupleSink tupleSink = new NetworkTupleSink(tupleStoreName, connection);
sinks.add(tupleSink);
logger.info("Redistributing data to remote system {}", instance.getInetSocketAddress());
}
}
registerRegion(distributionRegion, sinks);
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class TestCompressionRatio method handleCompressedData.
/**
* Handle compressed packages
* @param tableName
* @param buffer
* @return
* @throws PackageEncodeException
* @throws IOException
*/
protected long handleCompressedData(final TupleStoreName tableName, final List<Tuple> buffer) {
final RoutingHeader routingHeader = new RoutingHeader(false);
final List<NetworkRequestPackage> packages = buffer.stream().map(t -> new InsertTupleRequest((short) 4, routingHeader, tableName, t)).collect(Collectors.toList());
final CompressionEnvelopeRequest compressionEnvelopeRequest = new CompressionEnvelopeRequest(NetworkConst.COMPRESSION_TYPE_GZIP, packages);
buffer.clear();
return packageToBytes(compressionEnvelopeRequest);
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method processScheduldedDeletions.
/**
* Process the schedules table deletions
*/
private void processScheduldedDeletions() {
final LinkedTransferQueue<TupleStoreName> pendingTableDeletions = storage.getPendingTableDeletions();
while (!pendingTableDeletions.isEmpty()) {
final TupleStoreName tableName = pendingTableDeletions.poll();
if (tableName != null) {
logger.info("Deleting table {}", tableName.getFullname());
TupleStoreManager.deletePersistentTableData(storage.getBasedir().getAbsolutePath(), tableName);
}
}
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method processTupleStores.
/**
* Process the tuple stores
*
* @param storageRegistry
* @param tupleStores
* @throws InterruptedException
*/
private void processTupleStores(final TupleStoreManagerRegistry storageRegistry, final List<TupleStoreName> tupleStores) throws InterruptedException {
for (final TupleStoreName tupleStoreName : tupleStores) {
try {
logger.debug("Running compact for: {}", tupleStoreName);
final TupleStoreManager tupleStoreManager = storageRegistry.getTupleStoreManager(tupleStoreName);
if (tupleStoreManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
logger.debug("Skipping compact for read only sstable manager: {}", tupleStoreName);
continue;
}
if (!CompactorHelper.isRegionActive(tupleStoreName)) {
logger.info("Skipping compact run, because region is not active {}", tupleStoreName);
continue;
}
final List<SSTableFacade> facades = getAllTupleStores(tupleStoreManager);
final MergeTask mergeTask = mergeStrategy.getMergeTask(facades);
executeCompactTask(mergeTask, tupleStoreManager);
testForRegionOverflow(tupleStoreManager);
} catch (StorageManagerException | BBoxDBException e) {
logger.error("Error while merging tables", e);
}
}
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method testForRegionOverflow.
/**
* Does the region needs to be split?
* @param sstableManager
* @throws BBoxDBException
* @throws InterruptedException
*/
private void testForRegionOverflow(final TupleStoreManager sstableManager) throws BBoxDBException, InterruptedException {
// Don't try to split non-distributed tables
if (!sstableManager.getTupleStoreName().isDistributedTable()) {
return;
}
try {
final TupleStoreName ssTableName = sstableManager.getTupleStoreName();
final long regionId = ssTableName.getRegionId().getAsLong();
final SpacePartitioner spacePartitioner = getSpacePartitioner(ssTableName);
final DistributionRegion distributionRegion = spacePartitioner.getRootNode();
final DistributionRegion regionToSplit = DistributionRegionHelper.getDistributionRegionForNamePrefix(distributionRegion, regionId);
// Region does not exist
if (regionToSplit == null) {
return;
}
if (!RegionSplitHelper.isSplittingSupported(regionToSplit)) {
return;
}
if (!RegionSplitHelper.isRegionOverflow(regionToSplit)) {
return;
}
executeSplit(sstableManager, spacePartitioner, regionToSplit);
} catch (Exception e) {
throw new BBoxDBException(e);
}
}
Aggregations