List of usage examples for com.google.common.eventbus AsyncEventBus AsyncEventBus
public AsyncEventBus(Executor executor, SubscriberExceptionHandler subscriberExceptionHandler)
From source file:com.p2p.peercds.cli.ClientMain.java
/** * Main client entry point for stand-alone operation. *///from w w w .j a va 2 s . c o m public static void main(String[] args) { BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%d [%-25t] %-5p: %m%n"))); CmdLineParser parser = new CmdLineParser(); CmdLineParser.Option help = parser.addBooleanOption('h', "help"); CmdLineParser.Option output = parser.addStringOption('o', "output"); CmdLineParser.Option iface = parser.addStringOption('i', "iface"); CmdLineParser.Option seedTime = parser.addIntegerOption('s', "seed"); CmdLineParser.Option maxUpload = parser.addDoubleOption('u', "max-upload"); CmdLineParser.Option maxDownload = parser.addDoubleOption('d', "max-download"); try { parser.parse(args); } catch (CmdLineParser.OptionException oe) { System.err.println(oe.getMessage()); usage(System.err); System.exit(1); } // Display help and exit if requested if (Boolean.TRUE.equals((Boolean) parser.getOptionValue(help))) { usage(System.out); System.exit(0); } String outputValue = (String) parser.getOptionValue(output, DEFAULT_OUTPUT_DIRECTORY); String ifaceValue = (String) parser.getOptionValue(iface); int seedTimeValue = (Integer) parser.getOptionValue(seedTime, -1); double maxDownloadRate = (Double) parser.getOptionValue(maxDownload, 0.0); double maxUploadRate = (Double) parser.getOptionValue(maxUpload, 0.0); String[] otherArgs = parser.getRemainingArgs(); if (otherArgs.length != 1) { usage(System.err); System.exit(1); } try { Lock lock = new ReentrantLock(); CloudEventHandler handler = new CloudEventHandler(lock); AsyncEventBus eventBus = new AsyncEventBus(Executors.newFixedThreadPool(5), handler); eventBus.register(handler); Client c = new Client(getIPv4Address(ifaceValue), SharedTorrent.fromFile(new File(otherArgs[0]), new File(outputValue)), lock, eventBus, handler); c.setMaxDownloadRate(maxDownloadRate); c.setMaxUploadRate(maxUploadRate); // Set a shutdown hook that will stop the sharing/seeding and send // a STOPPED announce request. Runtime.getRuntime().addShutdownHook(new Thread(new Client.ClientShutdown(c, null))); c.share(seedTimeValue); if (Client.ClientState.ERROR.equals(c.getState())) { System.exit(1); } } catch (Exception e) { logger.error("Fatal error: {}", e.getMessage(), e); System.exit(2); } }
From source file:org.excalibur.core.events.EventBusFactory.java
public static AsyncEventBus createAsyncEventBus(String name, ListeningExecutorService executor, DeadEventLoggingHandler deadEventLoggingHandler) { AsyncEventBus asyncEventBus = new AsyncEventBus(name, executor); asyncEventBus.register(deadEventLoggingHandler); return asyncEventBus; }
From source file:org.muhia.app.psi.portal.eventbus.AsyncEventbusService.java
public AsyncEventbusService() { eventBus = new AsyncEventBus("orchestrate-events", Executors.newCachedThreadPool()); }
From source file:com.webbfontaine.valuewebb.irms.eventbus.VWEventBus.java
protected VWEventBus(String name, ExecutorService executorService) { eventBus = new EventBus(); registerDeadEventHandler(eventBus);/* www . ja va 2 s . c om*/ asyncEventBus = new AsyncEventBus(name, executorService); registerDeadEventHandler(asyncEventBus); this.executorService = executorService; }
From source file:com.guestful.bus.GuavaEventBus.java
public GuavaEventBus(Executor executor, SubscriberExceptionHandler subscriberExceptionHandler) { this.eventBus = new AsyncEventBus(executor, subscriberExceptionHandler); }
From source file:com.esofthead.mycollab.spring.AppEventBus.java
@Bean public AsyncEventBus asyncEventBus() { return new AsyncEventBus(Executors.newCachedThreadPool(), new SubscriberExceptionHandler() { @Override//from w w w.java2 s .co m public void handleException(Throwable throwable, SubscriberExceptionContext subscriberExceptionContext) { LOG.error("Error in event bus execution", throwable); } }); }
From source file:com.mpush.tools.event.EventBus.java
public EventBus() { Executor executor = ThreadPoolManager.I.getEventBusExecutor(); eventBus = new AsyncEventBus(executor, (exception, context) -> LOGGER.error("event bus subscriber ex", exception)); }
From source file:com.netflix.metacat.common.server.events.MetacatEventBus.java
/** * Constructor./*w w w. j a va2 s . c o m*/ * @param config config */ @Inject public MetacatEventBus(final Config config) { final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("metacat-event-pool-%d") .build(); final int threadCount = config.getEventBusThreadCount(); this.asyncEventBus = new AsyncEventBus("metacat-async-event-bus", Executors.newFixedThreadPool(threadCount, threadFactory)); this.syncEventBus = new EventBus("metacat-sync-event-bus"); }
From source file:org.zalando.stups.boot.eventbus.EventBusAutoConfiguration.java
@Bean public AsyncEventBus asyncEventBus() { AsyncEventBus asyncEventBus = new AsyncEventBus("asyncDefault", Executors.newFixedThreadPool(2)); return asyncEventBus; }
From source file:org.graylog2.shared.bindings.providers.EventBusProvider.java
@Override public EventBus get() { final EventBus eventBus = new AsyncEventBus("graylog-eventbus", executorService(configuration.getAsyncEventbusProcessors())); eventBus.register(new DeadEventLoggingListener()); return eventBus; }