Exemplo n.º 1
0
 @Override
 protected void initFromConfiguration(LogAppenderDto appender, FlumeConfig configuration) {
   LOG.debug("Initializing new instance of Flume log appender");
   try {
     this.configuration = configuration;
     flumeEventBuilder = new FlumeAvroEventBuilder();
     flumeEventBuilder.init(configuration);
     int executorPoolSize =
         Math.min(configuration.getExecutorThreadPoolSize(), MAX_CALLBACK_THREAD_POOL_SIZE);
     int callbackPoolSize =
         Math.min(configuration.getCallbackThreadPoolSize(), MAX_CALLBACK_THREAD_POOL_SIZE);
     executor = Executors.newFixedThreadPool(executorPoolSize);
     callbackExecutor = Executors.newFixedThreadPool(callbackPoolSize);
     flumeClientManager = FlumeClientManager.getInstance(configuration);
   } catch (Exception e) {
     LOG.error("Failed to init Flume log appender: ", e);
   }
 }
Exemplo n.º 2
0
 @Override
 public void close() {
   if (!closed) {
     closed = true;
     if (flumeClientManager != null) {
       flumeClientManager.cleanUp();
     }
     if (executor != null) {
       executor.shutdownNow();
     }
     if (callbackExecutor != null) {
       callbackExecutor.shutdownNow();
     }
     if (scheduler != null) {
       scheduler.shutdownNow();
     }
     flumeClientManager = null;
   }
   LOG.debug("Stoped Flume log appender.");
 }
Exemplo n.º 3
0
 public void reinit() {
   if (configuration == null) {
     LOG.warn(
         "Flume configuration wasn't initialized. Invoke method init with configuration before.");
     return;
   }
   if (flumeEventBuilder == null) {
     flumeEventBuilder = new FlumeAvroEventBuilder();
     flumeEventBuilder.init(configuration);
   }
   if (executor == null) {
     int executorPoolSize =
         Math.min(configuration.getExecutorThreadPoolSize(), MAX_CALLBACK_THREAD_POOL_SIZE);
     executor = Executors.newFixedThreadPool(executorPoolSize);
   }
   if (callbackExecutor == null) {
     int callbackPoolSize =
         Math.min(configuration.getCallbackThreadPoolSize(), MAX_CALLBACK_THREAD_POOL_SIZE);
     callbackExecutor = Executors.newFixedThreadPool(callbackPoolSize);
   }
   if (flumeClientManager == null) {
     flumeClientManager = FlumeClientManager.getInstance(configuration);
   }
 }