@Override public void close() throws IOException { zkClient.stopAndWait(); }
public void start() { zkClient.startAndWait(); }
@Override public PhoenixTransactionService getTransactionService(Configuration config, ConnectionInfo connInfo, int port) { config.setInt(TxConstants.Service.CFG_DATA_TX_BIND_PORT, port); int retryTimeOut = config.getInt(TxConstants.Service.CFG_DATA_TX_CLIENT_DISCOVERY_TIMEOUT_SEC, TxConstants.Service.DEFAULT_DATA_TX_CLIENT_DISCOVERY_TIMEOUT_SEC); ZKClientService zkClient = ZKClientServices.delegate( ZKClients.reWatchOnExpire( ZKClients.retryOnFailure( ZKClientService.Builder.of(connInfo.getZookeeperConnectionString()) .setSessionTimeout(config.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT)) .build(), RetryStrategies.exponentialDelay(500, retryTimeOut, TimeUnit.MILLISECONDS) ) ) ); DiscoveryService discovery = new ZKDiscoveryService(zkClient); TransactionManager txManager = new TransactionManager(config, new HDFSTransactionStateStorage(config, new SnapshotCodecProvider(config), new TxMetricsCollector()), new TxMetricsCollector()); TransactionService txService = new TransactionService(config, zkClient, discovery, Providers.of(txManager)); TephraTransactionService service = new TephraTransactionService(zkClient, txService); service.start(); return service; }
TxConstants.Service.DEFAULT_DATA_TX_CLIENT_DISCOVERY_TIMEOUT_SEC); ZKClientService zkClientService = ZKClientServices.delegate( ZKClients.reWatchOnExpire( ZKClients.retryOnFailure( new TephraZKClientService(zkQuorumServersString, timeOut, null, ArrayListMultimap.<String, byte[]>create()), RetryStrategies.exponentialDelay(500, retryTimeOut, TimeUnit.MILLISECONDS))
@Override protected void startUp() throws Exception { LOG.info("Creating container ZK path: {}{}", zkClient.getConnectString(), path); ZKOperations.ignoreError(zkClient.create(path, null, CreateMode.PERSISTENT), KeeperException.NodeExistsException.class, null).get(TIMEOUT_SECONDS, TimeUnit.SECONDS); }
@Override protected void shutDown() throws Exception { LOG.info("Removing container ZK path: {}{}", zkClient.getConnectString(), path); ZKOperations.recursiveDelete(zkClient, path).get(TIMEOUT_SECONDS, TimeUnit.SECONDS); } }
@Override public void run() { logIfFailed(zkClient.delete(path, version)); } };
@Override protected void startUp() throws Exception { cancellable = ZKOperations.watchChildren(zkClient, leaderElectionPath, new ZKOperations.ChildrenCallback() { @Override public void updated(NodeChildren nodeChildren) { childrenUpdated(nodeChildren, participants, readyFuture); } }); }
@Override public void destroy() { if (zkClientService != null) { zkClientService.stop(); } }
/** * Creates a {@link Builder} with the given ZooKeeper connection string. * @param connectStr The connection string. * @return A new instance of Builder. */ public static Builder of(String connectStr) { return new Builder(connectStr); }
private ZKClientService getZKClientService(String zkConnect) { return ZKClientServices.delegate( ZKClients.reWatchOnExpire( ZKClients.retryOnFailure(ZKClientService.Builder.of(zkConnect) .setSessionTimeout(ZK_TIMEOUT) .build(), RetryStrategies.exponentialDelay(100, 2000, TimeUnit.MILLISECONDS)))); }
@Override protected void startUp() throws Exception { LOG.info("Creating container ZK path: {}{}", zkClient.getConnectString(), path); ZKOperations.ignoreError(zkClient.create(path, null, CreateMode.PERSISTENT), KeeperException.NodeExistsException.class, null).get(TIMEOUT_SECONDS, TimeUnit.SECONDS); }
@Override public void close() throws IOException { try { if (txService != null) txService.stopAndWait(); } finally { if (zkClient != null) zkClient.stopAndWait(); } }
public void start() { zkClient.startAndWait(); txService.startAndWait(); }
@Override protected void shutDown() throws Exception { LOG.info("Removing container ZK path: {}{}", zkClient.getConnectString(), path); ZKOperations.recursiveDelete(zkClient, path).get(TIMEOUT_SECONDS, TimeUnit.SECONDS); } }
@Override protected void startUp() throws Exception { cancellable = ZKOperations.watchChildren(zkClient, leaderElectionPath, new ZKOperations.ChildrenCallback() { @Override public void updated(NodeChildren nodeChildren) { childrenUpdated(nodeChildren, participants, readyFuture); } }); }
private ZKClientService getZKClientService(String zkConnect) { return ZKClientServices.delegate( ZKClients.reWatchOnExpire( ZKClients.retryOnFailure(ZKClientService.Builder.of(zkConnect) .setSessionTimeout(ZK_TIMEOUT) .build(), RetryStrategies.exponentialDelay(100, 2000, TimeUnit.MILLISECONDS)))); }
@Override public void close() { // zkClientService is null if used by the Explore service, // since Explore manages the lifecycle of the zk service. it is not null if used by a MR job launched by Hive. if (zkClientService != null) { zkClientService.stopAndWait(); } } }