use of org.bboxdb.distribution.membership.MembershipConnectionService in project bboxdb by jnidzwetzki.
the class BBoxDBMain method init.
public void init() throws Exception {
logger.info("Init the BBoxDB");
services.clear();
// The storage registry
final TupleStoreManagerRegistry storageRegistry = new TupleStoreManagerRegistry();
services.add(storageRegistry);
// The zookeeper registerer
final ZookeeperInstanceRegisterer zookeeperClient = new ZookeeperInstanceRegisterer();
services.add(zookeeperClient);
// The membership connection service
final MembershipConnectionService membershipService = createMembershipService(storageRegistry);
services.add(membershipService);
// The network connection handler
final NetworkConnectionService connectionHandler = createConnectionHandler(storageRegistry);
services.add(connectionHandler);
// The recovery service
final DistributedRecoveryService recoveryService = new DistributedRecoveryService(storageRegistry);
services.add(recoveryService);
// The statistics update service
final StatisticsUpdateService statisticsService = new StatisticsUpdateService(storageRegistry);
services.add(statisticsService);
// The JMX service
final JMXService jmxService = new JMXService(this);
services.add(jmxService);
// The performance counter service
final PerformanceCounterService performanceCounterService = new PerformanceCounterService();
services.add(performanceCounterService);
// Send flush events to zookeeper
storageRegistry.registerSSTableFlushCallback(new TupleStoreFlushZookeeperAdapter());
}
use of org.bboxdb.distribution.membership.MembershipConnectionService 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.distribution.membership.MembershipConnectionService in project bboxdb by jnidzwetzki.
the class BBoxDBMain method createMembershipService.
/**
* Returns a new instance of the membership service
* @param storageRegistry
* @return
*/
public MembershipConnectionService createMembershipService(final TupleStoreManagerRegistry storageRegistry) {
final MembershipConnectionService membershipService = MembershipConnectionService.getInstance();
// Prevent network connections to ourself
final BBoxDBInstance localhost = ZookeeperClientFactory.getLocalInstanceName();
membershipService.addSystemToBlacklist(localhost);
// The storage registry for gossip
membershipService.setTupleStoreManagerRegistry(storageRegistry);
return membershipService;
}
Aggregations