@Override public EventBus load(String key) throws Exception { return new EventBus(key); } });
@Override protected void setUp() throws Exception { bus = new EventBus(); methodCalled = false; methodArgument = null; }
@Override protected void setUp() throws Exception { super.setUp(); bus = new EventBus(BUS_IDENTIFIER); }
protected InternalEventBus() { this.eventBus = new EventBus(this.getClass().getName()); logger.log(Level.INFO, "Event bus: Created event bus " + this.getClass().getName()); }
@Override protected void setUp() throws Exception { subscriber = createSubscriber(); EventBus bus = new EventBus(); bus.register(subscriber); bus.post(EVENT); }
public static <T> AsyncDataWriter<T> asyncDataWriter(Executor executorService, ManifestComparator<T> comparator) { return asyncDataWriter(executorService, comparator, new EventBus()); }
public void testSubscriberThrowsExceptionHandlerThrowsException() throws Exception { final EventBus eventBus = new EventBus( new SubscriberExceptionHandler() { @Override public void handleException(Throwable exception, SubscriberExceptionContext context) { throw new RuntimeException(); } }); final Object subscriber = new Object() { @Subscribe public void throwExceptionOn(String message) { throw new RuntimeException(); } }; eventBus.register(subscriber); try { eventBus.post(EVENT); } catch (RuntimeException e) { fail("Exception should not be thrown."); } }
public void testAnonymous() { final AtomicReference<String> holder = new AtomicReference<>(); final AtomicInteger deliveries = new AtomicInteger(); EventBus bus = new EventBus(); bus.register( new Object() { @Subscribe public void accept(String str) { holder.set(str); deliveries.incrementAndGet(); } }); String EVENT = "Hello!"; bus.post(EVENT); assertEquals("Only one event should be delivered.", 1, deliveries.get()); assertEquals("Correct string should be delivered.", EVENT, holder.get()); } }
public void testToString() throws Exception { EventBus eventBus = new EventBus("a b ; - \" < > / \\ €"); assertEquals("EventBus{a b ; - \" < > / \\ €}", eventBus.toString()); }
EventBus eventBus = new EventBus(agentName + "-event-bus"); List<LifecycleAware> components = Lists.newArrayList(); PollingZooKeeperConfigurationProvider zookeeperConfigurationProvider = EventBus eventBus = new EventBus(agentName + "-event-bus"); PollingPropertiesFileConfigurationProvider configurationProvider = new PollingPropertiesFileConfigurationProvider(
@Before public void setup() { eventRecieved = new AtomicInteger( 0); bus = new EventBus(); bus.register(this); dummyMc = new DummyManifestComparator<>(); writer = new AsyncDataWriter<>( ex, dummyMc, bus); }
/** * Test the throughput of the writer used on {@link #testGobblinThroughput()} to prove it is not a bottleneck. */ public static void testWriterThroughput() throws Exception { EventBus eventBus = new EventBus(); EventHandler eventHandler = new EventHandler(); eventBus.register(eventHandler); GobblinTestEventBusWriter writer = new GobblinTestEventBusWriter(eventBus, GobblinTestEventBusWriter.Mode.COUNTING); long records = 0; long endAt = System.currentTimeMillis() + 10000; long startTime = System.nanoTime(); for (records = 0; records < 10000000 && System.currentTimeMillis() < endAt; records++) { writer.write(records); } long elapsedMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime); writer.commit(); Assert.assertEquals(eventHandler.runSummaries.get(0).getRecordsWritten(), records); System.out.println(String.format("Writer consumed %d records in %d millis, qps: %f", records, elapsedMillis, (double) records * 1000 / elapsedMillis)); }
public void testSubscriberThrowsException() throws Exception { final RecordingSubscriberExceptionHandler handler = new RecordingSubscriberExceptionHandler(); final EventBus eventBus = new EventBus(handler); final RuntimeException exception = new RuntimeException("but culottes have a tendancy to ride up!"); final Object subscriber = new Object() { @Subscribe public void throwExceptionOn(String message) { throw exception; } }; eventBus.register(subscriber); eventBus.post(EVENT); assertEquals("Cause should be available.", exception, handler.exception); assertEquals("EventBus should be available.", eventBus, handler.context.getEventBus()); assertEquals("Event should be available.", EVENT, handler.context.getEvent()); assertEquals("Subscriber should be available.", subscriber, handler.context.getSubscriber()); assertEquals( "Method should be available.", subscriber.getClass().getMethod("throwExceptionOn", String.class), handler.context.getSubscriberMethod()); }
@Before public void setup() { bus = new ErrorBus(); EventBus ebus = new EventBus(); ebus.register(this); ErrorBus.setErrorBus(ebus); }
@Before public void setup() { registry = new MetricRegistry(); bus = new EventBus(); config = new Configuration( true, true, true, true, 5, 6, 7, 8, 10,"bob"); catcher = new MetricsCatcher<>( registry, bus, config); }
@Before public void setup() { registry = new MetricRegistry(); bus = new EventBus(); config = new Configuration( false, false, false, false, 5, 6, 7, 8, 10, "bob"); catcher = new MetricsCatcher<>( registry, bus, config); }
@Before public void setup() { bus = new EventBus(); requests = new RequestsBeingExecuted( bus); types = new RequestTypes( bus, true); types.getMap() .put("default", requests); }
@Before public void setUp() throws Exception { bus = new EventBus(); queries1 = new RequestsBeingExecuted( bus); queries2 = new RequestsBeingExecuted( bus, "partition"); jobs = new JobsBeingExecuted( new EventBus(), 10, JobName.Types.SIMPLE); RequestTypes types = new RequestTypes( bus, true); types.getMap() .put(queries1.getType(), queries1); types.getMap() .put(queries2.getType(), queries2); active = new ActiveResource( types, jobs); }
@Before public void setUp() throws Exception { data = SystemData.builder() .dataMap(Maps.newHashMap()) .errors(1) .processed(100) .build(); bus = new EventBus(); bus.register(this); jobs = new JobsBeingExecuted( bus, 10, JobName.Types.SIMPLE); pjp = Mockito.mock(ProceedingJoinPoint.class); }
this.yarnAppSecurityManager = new YarnAppSecurityManager(config, this.helixManager, this.localFs, this.tokenFilePath); this.yarnContainerSecurityManager = new YarnContainerSecurityManager(config, this.localFs, new EventBus());