use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method execute.
/**
* Execute a new compaction
* @throws InterruptedException
*/
public synchronized void execute() throws InterruptedException {
final TupleStoreManagerRegistry storageRegistry = storage.getTupleStoreManagerRegistry();
final String location = storage.getBasedir().getAbsolutePath();
final List<TupleStoreName> tupleStores = storageRegistry.getTupleStoresForLocation(location);
processTupleStores(storageRegistry, tupleStores);
processRegionMerges();
processScheduldedDeletions();
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class TupleStoreLocator method scanDirectoryForExistingTables.
/**
* Scan the given directory for existing sstables
* @param storageDirectory
* @return
* @throws StorageManagerException
*/
public static Map<TupleStoreName, String> scanDirectoryForExistingTables(final String storageDirectory) throws StorageManagerException {
final String dataDirString = SSTableHelper.getDataDir(storageDirectory);
final File dataDir = new File(dataDirString);
if (!dataDir.exists()) {
throw new StorageManagerException("Root dir does not exist: " + dataDir);
}
final Map<TupleStoreName, String> sstableLocations = new HashMap<>();
// Distribution groups
for (final File fileEntry : dataDir.listFiles()) {
if (!fileEntry.isDirectory()) {
continue;
}
final String distributionGroup = fileEntry.getName();
assert (DistributionGroupHelper.validateDistributionGroupName(distributionGroup)) : "Invalid name: " + distributionGroup;
final Map<TupleStoreName, String> tablesInDir = handleDistributionGroupEntry(storageDirectory, fileEntry, distributionGroup);
sstableLocations.putAll(tablesInDir);
}
return sstableLocations;
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class DeleteTableHandler method handleRequest.
@Override
public /**
* Handle the delete table call
*/
boolean handleRequest(final ByteBuffer encodedPackage, final short packageSequence, final ClientConnectionHandler clientConnectionHandler) throws IOException, PackageEncodeException {
try {
final DeleteTableRequest deletePackage = DeleteTableRequest.decodeTuple(encodedPackage);
final TupleStoreName requestTable = deletePackage.getTable();
logger.info("Got delete call for table: {}", requestTable);
// Delete zookeeper configuration
final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
tupleStoreAdapter.deleteTable(requestTable);
// Clear cached data
TupleStoreConfigurationCache.getInstance().clear();
clientConnectionHandler.writeResultPackage(new SuccessResponse(packageSequence));
} catch (Exception e) {
logger.warn("Error while delete tuple", e);
final ErrorResponse responsePackage = new ErrorResponse(packageSequence, ErrorMessages.ERROR_EXCEPTION);
clientConnectionHandler.writeResultPackage(responsePackage);
}
return true;
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class KeepAliveHandler method checkLocalTuples.
/**
* @param tupleStoreManagerRegistry
* @param tupleStoreName
* @param tuple
* @throws BBoxDBException
* @throws StorageManagerException
*/
private boolean checkLocalTuples(final TupleStoreManagerRegistry tupleStoreManagerRegistry, final TupleStoreName tupleStoreName, final Tuple tuple) throws BBoxDBException {
final String fullname = tupleStoreName.getDistributionGroup();
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(fullname);
final DistributionRegionIdMapper regionIdMapper = spacePartitioner.getDistributionRegionIdMapper();
final Collection<TupleStoreName> localTables = regionIdMapper.getLocalTablesForRegion(tuple.getBoundingBox(), tupleStoreName);
for (final TupleStoreName localTupleStoreName : localTables) {
try {
final TupleStoreManager storageManager = tupleStoreManagerRegistry.getTupleStoreManager(localTupleStoreName);
final String key = tuple.getKey();
final List<Tuple> localTuples = storageManager.get(key);
if (localTables.isEmpty()) {
logger.error("Got empty tuple list during gossip");
return false;
}
final List<Long> localVersions = getSortedVersionList(localTuples);
final long gossipTupleVersion = tuple.getVersionTimestamp();
return checkLocalTupleVersions(localVersions, gossipTupleVersion, key);
} catch (StorageManagerException e) {
logger.error("Got exception while reading tuples", e);
}
}
return true;
}
use of org.bboxdb.storage.entity.TupleStoreName in project bboxdb by jnidzwetzki.
the class SSTableCheckpointRunnable method runThread.
/**
* Execute the checkpoint thread
*/
protected void runThread() {
final TupleStoreManagerRegistry storageRegistry = storage.getTupleStoreManagerRegistry();
try {
while (!Thread.currentThread().isInterrupted()) {
if (Const.LOG_MEMORY_STATISTICS) {
logger.info(SystemInfo.getMemoryStatisticsString());
}
final List<TupleStoreName> allTables = storageRegistry.getTupleStoresForLocation(storage.getBasedir().getAbsolutePath());
for (final TupleStoreName ssTableName : allTables) {
logger.info("Executing checkpoint check for: {}", ssTableName);
if (Thread.currentThread().isInterrupted()) {
return;
}
createCheckpointIfNeeded(storageRegistry, ssTableName);
}
waitForNextRun();
}
} catch (Exception e) {
if (!Thread.interrupted()) {
logger.error("Got exception while executing thread", e);
}
}
}
Aggregations