private synchronized CuratorFramework getAppCurator() { if (appCurator == null) { appCurator = CuratorUtil.newAppCurator(config); appCurator.start(); } return appCurator; }
private synchronized CuratorFramework getAppCurator(FluoConfiguration config) { if (!curators.containsKey(config.getApplicationName())) { CuratorFramework curator = CuratorUtil.newAppCurator(config); curator.start(); curators.put(config.getApplicationName(), curator); } return curators.get(config.getApplicationName()); }
try (CuratorFramework curator = CuratorUtil.newAppCurator(config)) { curator.start();
public synchronized void start() throws Exception { if (started) { throw new IllegalStateException(); } final InetSocketAddress addr = startServer(); curatorFramework = CuratorUtil.newAppCurator(env.getConfiguration()); curatorFramework.getConnectionStateListenable().addListener(cnxnListener); curatorFramework.start(); while (!cnxnListener.isConnected()) { Thread.sleep(200); } leaderSelector = new LeaderSelector(curatorFramework, ZookeeperPath.ORACLE_SERVER, this); String leaderId = HostUtil.getHostName() + ":" + addr.getPort(); leaderSelector.setId(leaderId); log.info("Leader ID = " + leaderId); leaderSelector.start(); pathChildrenCache = new PathChildrenCache(curatorFramework, oraclePath, true); pathChildrenCache.getListenable().addListener(this); pathChildrenCache.start(); while (!cnxnListener.isConnected()) { Thread.sleep(200); } log.info("Listening " + addr); started = true; }
curatorFramework = CuratorUtil.newAppCurator(env.getConfiguration()); CuratorCnxnListener cnxnListener = new CuratorCnxnListener(); curatorFramework.getConnectionStateListenable().addListener(cnxnListener);
public SharedResources(Environment env) throws TableNotFoundException { this.env = env; curator = CuratorUtil.newAppCurator(env.getConfiguration()); curator.start(); int numTservers = env.getConnector().instanceOperations().getTabletServers().size(); int numBWThreads = FluoConfigurationImpl.getNumBWThreads(env.getConfiguration(), numTservers); bw = env.getConnector().createBatchWriter(env.getTable(), new BatchWriterConfig().setMaxWriteThreads(numBWThreads)); sbw = new SharedBatchWriter(bw); int numCWThreads = FluoConfigurationImpl.getNumCWThreads(env.getConfiguration(), numTservers); cw = env.getConnector().createConditionalWriter( env.getTable(), new ConditionalWriterConfig().setAuthorizations(env.getAuthorizations()) .setMaxWriteThreads(numCWThreads)); bulkCw = env.getConnector().createConditionalWriter( env.getTable(), new ConditionalWriterConfig().setAuthorizations(env.getAuthorizations()) .setMaxWriteThreads(numCWThreads)); txInfoCache = new TxInfoCache(env); visCache = new VisibilityCache(); metricRegistry = new MetricRegistry(); }