use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class InsertTupleHandler method createMissingTables.
/**
* Create all missing tables
*/
protected void createMissingTables(final TupleStoreName requestTable, final TupleStoreManagerRegistry storageRegistry, final Collection<TupleStoreName> localTables) throws StorageManagerException {
try {
final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
if (!tupleStoreAdapter.isTableKnown(requestTable)) {
throw new StorageManagerException("Table: " + requestTable.getFullname() + " is unkown");
}
final TupleStoreConfiguration config = tupleStoreAdapter.readTuplestoreConfiguration(requestTable);
for (final TupleStoreName tupleStoreName : localTables) {
final boolean alreadyKnown = storageRegistry.isStorageManagerKnown(tupleStoreName);
if (!alreadyKnown) {
storageRegistry.createTableIfNotExist(tupleStoreName, config);
}
}
} catch (ZookeeperException e) {
throw new StorageManagerException(e);
}
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class DataRedistributionLoader method initBBoxDB.
/**
* Re-Create the distribution group and the table
*/
private void initBBoxDB() {
try {
// Delete old distribution group
System.out.println("Delete old distribution group");
final EmptyResultFuture dgroupDeleteResult = bboxDBCluster.deleteDistributionGroup(DGROUP);
dgroupDeleteResult.waitForAll();
if (dgroupDeleteResult.isFailed()) {
System.err.println(dgroupDeleteResult.getAllMessages());
System.exit(-1);
}
// Create new distribution group
System.out.println("Create new distribution group");
final DistributionGroupConfiguration dgroupConfig = DistributionGroupConfigurationBuilder.create(2).withReplicationFactor((short) 1).withMaximumRegionSize(16).withMinimumRegionSize(4).build();
final EmptyResultFuture dgroupCreateResult = bboxDBCluster.createDistributionGroup(DGROUP, dgroupConfig);
dgroupCreateResult.waitForAll();
if (dgroupCreateResult.isFailed()) {
System.err.println(dgroupCreateResult.getAllMessages());
System.exit(-1);
}
// Create new table
System.out.println("Create new table");
final TupleStoreConfiguration storeConfiguration = TupleStoreConfigurationBuilder.create().allowDuplicates(false).build();
final EmptyResultFuture tableCreateResult = bboxDBCluster.createTable(TABLE, storeConfiguration);
tableCreateResult.waitForAll();
if (tableCreateResult.isFailed()) {
System.err.println(tableCreateResult.getAllMessages());
System.exit(-1);
}
} catch (Exception e) {
System.err.println("Got an exception while prepating BBoxDB");
e.printStackTrace();
System.exit(-1);
}
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TupleStoreAdapter method readTuplestoreConfiguration.
/**
* Read the tuple store name
* @param tupleStoreName
* @throws ZookeeperException
*/
public TupleStoreConfiguration readTuplestoreConfiguration(final TupleStoreName tupleStoreName) throws ZookeeperException {
final TupleStoreConfiguration tupleStoreConfiguration = new TupleStoreConfiguration();
try {
final String spatialIndexReader = zookeeperClient.readPathAndReturnString(getIndexReaderPath(tupleStoreName));
tupleStoreConfiguration.setSpatialIndexReader(spatialIndexReader);
final String spatialIndexWriter = zookeeperClient.readPathAndReturnString(getIndexWriterPath(tupleStoreName));
tupleStoreConfiguration.setSpatialIndexWriter(spatialIndexWriter);
final String duplicatesAllowed = zookeeperClient.readPathAndReturnString(getDuplicatesAllowedPath(tupleStoreName));
final boolean duplicatesAllowedBoolean = Boolean.parseBoolean(duplicatesAllowed);
tupleStoreConfiguration.setAllowDuplicates(duplicatesAllowedBoolean);
final String duplicatesTTL = zookeeperClient.readPathAndReturnString(getDuplicatesTTLPath(tupleStoreName));
final Integer ttlInterger = Integer.parseInt(duplicatesTTL);
tupleStoreConfiguration.setTtl(ttlInterger);
final String duplicateVersions = zookeeperClient.readPathAndReturnString(getDuplicateVersionsPath(tupleStoreName));
final Integer duplicateVersionsInteger = Integer.parseInt(duplicateVersions);
tupleStoreConfiguration.setVersions(duplicateVersionsInteger);
} catch (ZookeeperNotFoundException | NumberFormatException e) {
throw new ZookeeperException(e);
}
return tupleStoreConfiguration;
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TupleStoreConfigurationCache method getDuplicateResolverForTupleStore.
public synchronized DuplicateResolver<Tuple> getDuplicateResolverForTupleStore(final String tupleStorename) {
if (!cache.containsKey(tupleStorename)) {
try {
final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
final TupleStoreName tupleStoreNameObject = new TupleStoreName(tupleStorename);
if (!tupleStoreAdapter.isTableKnown(tupleStoreNameObject)) {
logger.error("Table {} is not known, using do nothing duplicate resolver", tupleStorename);
return new DoNothingDuplicateResolver();
}
final TupleStoreConfiguration tupleStoreConfiguration = tupleStoreAdapter.readTuplestoreConfiguration(tupleStoreNameObject);
final DuplicateResolver<Tuple> resolver = TupleDuplicateResolverFactory.build(tupleStoreConfiguration);
cache.put(tupleStorename, resolver);
} catch (ZookeeperException e) {
logger.error("Exception while reading zookeeper data", e);
return new DoNothingDuplicateResolver();
}
}
final DuplicateResolver<Tuple> duplicateResolver = cache.get(tupleStorename);
return duplicateResolver;
}
Aggregations