public void start() { zkClient.startAndWait(); txService.startAndWait(); }
@Override public void close() throws IOException { try { if (txService != null) txService.stopAndWait(); } finally { if (zkClient != null) zkClient.stopAndWait(); } }
/** * Invoked by jsvc to stop the program. */ public void stop() { LOG.info("Stopping {}", getClass().getSimpleName()); if (txService == null) { return; } try { if (txService.isRunning()) { txService.stopAndWait(); } } catch (Throwable e) { LOG.error("Failed to shutdown transaction service.", e); // because shutdown hooks execute concurrently, the logger may be closed already: thus also print it. System.err.println("Failed to shutdown transaction service: " + e.getMessage()); e.printStackTrace(System.err); } }
@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; }
@Override protected void doStop() { internalStop(); notifyStopped(); }
protected void abort(Throwable cause) { // try to clear leader status and shutdown RPC internalStop(); notifyFailed(cause); }
@Override public void leader() { // if the txManager fails, we should stop the server txManager = txManagerProvider.get(); txManager.addListener(new ServiceListenerAdapter() { @Override public void failed(State from, Throwable failure) { LOG.error("Transaction manager aborted, stopping transaction service"); TransactionService.this.abort(failure); } }, MoreExecutors.sameThreadExecutor()); pruningService = createPruningService(conf, txManager); server = ThriftRPCServer.builder(TTransactionServer.class) .setHost(address) .setPort(port) .setWorkerThreads(threads) .setMaxReadBufferBytes(maxReadBufferBytes) .setIOThreads(ioThreads) .build(new TransactionServiceThriftHandler(txManager, pruningService)); try { server.startAndWait(); pruningService.startAndWait(); doRegister(); LOG.info("Transaction Thrift Service started successfully on " + getAddress()); } catch (Throwable t) { LOG.info("Transaction Thrift Service didn't start on " + server.getBindAddress()); leaderElection.stop(); notifyFailed(t); } }
@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; }
private void startUp() throws Exception { zkClientService.startAndWait(); txService.startAndWait(); }
@Override public void close() throws IOException { try { if (txService != null) txService.stopAndWait(); } finally { if (zkClient != null) zkClient.stopAndWait(); } }
@Override public PhoenixTransactionService getTransactionService(Configuration config, ConnectionInfo connInfo) { 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, 2000, TimeUnit.MILLISECONDS) ) ) ); //zkClient.startAndWait(); 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); //txService.startAndWait(); service.start(); return service; }
public void start() { zkClient.startAndWait(); txService.startAndWait(); }
@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(); }
/** * Stop services and */ private void stop() { try { txService.stopAndWait(); zkClientService.stopAndWait(); } catch (Throwable e) { LOG.error("Exception while trying to stop upgrade process", e); Runtime.getRuntime().halt(1); } }
/** * Do the start up work * Note: includeNewDatasets boolean is required because upgrade tool has two mode: 1. Normal CDAP upgrade and * 2. Upgrading co processor for tables after hbase upgrade. This parameter specifies whether new system dataset * which were added in the current release needs to be added in the dataset framework or not. * During Normal CDAP upgrade (1) we don't need these datasets to be added in the ds framework as they will get * created during upgrade rather than when cdap starts after upgrade which is what we want. * Whereas during Hbase upgrade (2) we want these new tables to be added so that the co processor of these tables * can be upgraded when the user runs CDAP's Hbase Upgrade after upgrading to a newer version of Hbase. * @param includeNewDatasets boolean which specifies whether to add new datasets in ds framework or not */ private void startUp(boolean includeNewDatasets) throws Exception { // Start all the services. LOG.info("Starting Zookeeper Client..."); Services.startAndWait(zkClientService, cConf.getLong(Constants.Zookeeper.CLIENT_STARTUP_TIMEOUT_MILLIS), TimeUnit.MILLISECONDS, String.format("Connection timed out while trying to start ZooKeeper client. Please " + "verify that the ZooKeeper quorum settings are correct in cdap-site.xml. " + "Currently configured as: %s", cConf.get(Constants.Zookeeper.QUORUM))); LOG.info("Starting Transaction Service..."); txService.startAndWait(); LOG.info("Initializing Dataset Framework..."); initializeDSFramework(cConf, dsFramework, includeNewDatasets); LOG.info("Building and uploading new HBase coprocessors..."); coprocessorManager.ensureCoprocessorExists(); }
/** * Invoked by jsvc to start the program. */ public void start() throws Exception { Injector injector = Guice.createInjector( new ConfigModule(conf), new ZKModule(), new DiscoveryModules().getDistributedModules(), new TransactionModules().getDistributedModules(), new TransactionClientModule() ); ZKClientService zkClientService = injector.getInstance(ZKClientService.class); zkClientService.startAndWait(); // start a tx server txService = injector.getInstance(TransactionService.class); try { LOG.info("Starting {}", getClass().getSimpleName()); txService.startAndWait(); } catch (Exception e) { System.err.println("Failed to start service: " + e.getMessage()); } }