use of org.bboxdb.distribution.zookeeper.ZookeeperClient 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);
}
use of org.bboxdb.distribution.zookeeper.ZookeeperClient in project bboxdb by jnidzwetzki.
the class BBoxDBMain method start.
/**
* Start all services
*/
public void start() {
logger.info("Starting up BBoxDB - version: {}", Const.VERSION);
if (!runBaseChecks()) {
logger.error("Some of the base checks have failed, exiting");
System.exit(-1);
}
// Init all services
for (final BBoxDBService service : services) {
try {
logger.info("Starting service: {}", service.getServicename());
service.init();
} catch (Throwable e) {
logger.error("Got exception while init service:" + service.getServicename(), e);
stop();
System.exit(-1);
}
}
// Read membership
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
BBoxDBInstanceManager.getInstance().startMembershipObserver(zookeeperClient);
}
use of org.bboxdb.distribution.zookeeper.ZookeeperClient in project bboxdb by jnidzwetzki.
the class DistributedRecoveryService method init.
@Override
public void init() {
try {
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
final ZookeeperBBoxDBInstanceAdapter zookeeperBBoxDBInstanceAdapter = new ZookeeperBBoxDBInstanceAdapter(zookeeperClient);
final BBoxDBInstance distributedInstance = ZookeeperClientFactory.getLocalInstanceName();
zookeeperBBoxDBInstanceAdapter.updateStateData(distributedInstance, BBoxDBInstanceState.OUTDATED);
logger.info("Running recovery for local stored data");
runRecovery();
logger.info("Running recovery for local stored data DONE");
zookeeperBBoxDBInstanceAdapter.updateStateData(distributedInstance, BBoxDBInstanceState.READY);
} catch (ZookeeperException | ZookeeperNotFoundException e) {
logger.error("Got an exception during recovery: ", e);
}
}
use of org.bboxdb.distribution.zookeeper.ZookeeperClient in project bboxdb by jnidzwetzki.
the class DistributionGroupConfigurationCache method getDistributionGroupConfiguration.
/**
* Get the distribution group configuration
* @param distributionGroupName
* @return
* @throws ZookeeperNotFoundException
*/
public synchronized DistributionGroupConfiguration getDistributionGroupConfiguration(final String distributionGroupName) throws ZookeeperNotFoundException {
if (!cache.containsKey(distributionGroupName)) {
try {
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
final DistributionGroupAdapter distributionGroupZookeeperAdapter = new DistributionGroupAdapter(zookeeperClient);
final DistributionGroupConfiguration configuration = distributionGroupZookeeperAdapter.getDistributionGroupConfiguration(distributionGroupName);
addNewConfiguration(distributionGroupName, configuration);
} catch (InputParseException | ZookeeperException e) {
logger.error("Exception while reading zokeeper data", e);
return new DistributionGroupConfiguration();
}
}
return cache.get(distributionGroupName);
}
use of org.bboxdb.distribution.zookeeper.ZookeeperClient in project bboxdb by jnidzwetzki.
the class CreateInitialPartitioning method main.
public static void main(final String[] args) throws Exception {
if (args.length != 5) {
System.err.println("Usage: <File> <Format> <Distribution group> <Partitiones> " + "<ZookeeperEndpoint> <Clustername>");
System.exit(-1);
}
final String filename = args[0];
final String format = args[1];
final String distributionGroup = args[2];
final int partitions = MathUtil.tryParseInt(args[3], () -> "Unable to parse: " + args[3]);
final String zookeeperEndpoint = args[4];
final String clustername = args[5];
final ZookeeperClient zookeeperClient = new ZookeeperClient(Arrays.asList(zookeeperEndpoint), clustername);
zookeeperClient.init();
if (!zookeeperClient.isConnected()) {
System.err.println("Unable to connect to zookeeper at: " + zookeeperEndpoint);
System.exit(-1);
}
ZookeeperClientFactory.setDefaultZookeeperClient(zookeeperClient);
doesGroupExist(distributionGroup);
checkForExistingPartitioning(distributionGroup);
final CreateInitialPartitioning dataRedistributionLoader = new CreateInitialPartitioning(filename, format, distributionGroup, partitions);
dataRedistributionLoader.run();
}
Aggregations