@Override public void configure(final Binder binder) { final ExportBuilder builder = MBeanModule.newExporter(binder); binder.bind(PersistentWriterFactory.class).to(EventSpoolWriterFactory.class).asEagerSingleton(); Multibinder<EventSpoolProcessor> defaultSpoolProcessors = Multibinder.newSetBinder(binder, EventSpoolProcessor.class); MapBinder<String, EventSpoolProcessor> perEventSpoolDispatchers = MapBinder.newMapBinder(binder, String.class, EventSpoolProcessor.class).permitDuplicates(); String spoolWriterClasses = config.getSpoolWriterClassNames(); final Iterable<String> spoolDispatcherClasses; if (!Strings.isNullOrEmpty(spoolWriterClasses)) { spoolDispatcherClasses = Splitter.on(",").trimResults().omitEmptyStrings().split(spoolWriterClasses); } else { spoolDispatcherClasses = Lists.newArrayList(); } // Bind the classes for default spoolClasses for (String className : spoolDispatcherClasses) { try { defaultSpoolProcessors .addBinding() .to(Class.forName(className).asSubclass(EventSpoolProcessor.class)) .asEagerSingleton(); } catch (ClassNotFoundException e) { log.error("Could not bind " + className, e); } } // Find and bind the classes used for per event spool writers Map<String, Iterable<String>> perEventSpoolWriterClasses = getSpoolWriterClassesByEventType(); for (Map.Entry<String, Iterable<String>> eventToSpoolWriters : perEventSpoolWriterClasses.entrySet()) { for (String spoolWriterClass : eventToSpoolWriters.getValue()) { try { perEventSpoolDispatchers .addBinding(eventToSpoolWriters.getKey()) .to(Class.forName(spoolWriterClass).asSubclass(EventSpoolProcessor.class)); } catch (ClassNotFoundException ex) { log.error("Could not bind " + spoolWriterClass, ex); } } } builder .export(EventSpoolWriterFactory.class) .as("com.ning.metrics.collector:name=EventSpoolWriter"); }
public ActiveMQConnection(final CollectorConfig config) { this.config = config; if (config.getActiveMQUri() != null) { this.connectionFactory = new ActiveMQConnectionFactory(config.getActiveMQUri()); this.connectionFactory.setUseAsyncSend(true); } }
public LocalQueueAndWorkers( CollectorConfig config, String type, EventQueueSession processor, EventQueueStats stats) { this.queue = new LinkedBlockingQueue<Object>(config.getActiveMQBufferLength()); this.processor = processor; this.stats = stats; this.executor = new FailsafeScheduledExecutor( config.getActiveMQNumSendersPerCategory(), new NamedThreadFactory(type + "-workers")); for (int idx = 0; idx < config.getActiveMQNumSendersPerCategory(); idx++) { executor.submit(new LocalQueueWorker(queue, processor, stats)); } }