private void resetConnection() { try { destroyConnection(); createConnection(); } catch (Throwable throwable) { // Don't rethrow, else this runnable won't get scheduled again. logger.error("Error while trying to expire connection", throwable); } }
@Override public void stop() { logger.info("Rpc sink {} stopping...", getName()); destroyConnection(); cxnResetExecutor.shutdown(); try { if (cxnResetExecutor.awaitTermination(5, TimeUnit.SECONDS)) { cxnResetExecutor.shutdownNow(); } } catch (Exception ex) { logger.error("Interrupted while waiting for connection reset executor to shut down"); } sinkCounter.stop(); super.stop(); logger.info("Rpc sink {} stopped. Metrics: {}", getName(), sinkCounter); }
/** * The start() of RpcSink is more of an optimization that allows connection * to be created before the process() loop is started. In case it so happens * that the start failed, the process() loop will itself attempt to reconnect * as necessary. This is the expected behavior since it is possible that the * downstream source becomes unavailable in the middle of the process loop * and the sink will have to retry the connection again. */ @Override public void start() { logger.info("Starting {}...", this); sinkCounter.start(); try { createConnection(); } catch (FlumeException e) { logger.warn("Unable to create Rpc client using hostname: " + hostname + ", port: " + port, e); /* Try to prevent leaking resources. */ destroyConnection(); } super.start(); logger.info("Rpc sink {} started.", getName()); }
/** * Ensure the connection exists and is active. * If the connection is not active, destroy it and recreate it. * * @throws org.apache.flume.FlumeException If there are errors closing or opening the RPC * connection. */ private void verifyConnection() throws FlumeException { if (client == null) { createConnection(); } else if (!client.isActive()) { destroyConnection(); createConnection(); } }
} else { sinkCounter.incrementEventWriteFail(); destroyConnection(); throw new EventDeliveryException("Failed to send events", t);
private void resetConnection() { try { destroyConnection(); createConnection(); } catch (Throwable throwable) { // Don't rethrow, else this runnable won't get scheduled again. logger.error("Error while trying to expire connection", throwable); } }
@Override public void stop() { logger.info("Rpc sink {} stopping...", getName()); destroyConnection(); cxnResetExecutor.shutdown(); try { if (cxnResetExecutor.awaitTermination(5, TimeUnit.SECONDS)) { cxnResetExecutor.shutdownNow(); } } catch (Exception ex) { logger.error("Interrupted while waiting for connection reset executor to shut down"); } sinkCounter.stop(); super.stop(); logger.info("Rpc sink {} stopped. Metrics: {}", getName(), sinkCounter); }
/** * The start() of RpcSink is more of an optimization that allows connection * to be created before the process() loop is started. In case it so happens * that the start failed, the process() loop will itself attempt to reconnect * as necessary. This is the expected behavior since it is possible that the * downstream source becomes unavailable in the middle of the process loop * and the sink will have to retry the connection again. */ @Override public void start() { logger.info("Starting {}...", this); sinkCounter.start(); try { createConnection(); } catch (FlumeException e) { logger.warn("Unable to create Rpc client using hostname: " + hostname + ", port: " + port, e); /* Try to prevent leaking resources. */ destroyConnection(); } super.start(); logger.info("Rpc sink {} started.", getName()); }
/** * Ensure the connection exists and is active. * If the connection is not active, destroy it and recreate it. * * @throws org.apache.flume.FlumeException If there are errors closing or opening the RPC * connection. */ private void verifyConnection() throws FlumeException { if (client == null) { createConnection(); } else if (!client.isActive()) { destroyConnection(); createConnection(); } }
} else { sinkCounter.incrementEventWriteFail(); destroyConnection(); throw new EventDeliveryException("Failed to send events", t);