public void onStart() { super.onStart(); replayerAgentInvoker = new AgentInvoker(errorHandler, ctx.errorCounter(), replayer); recorderAgentInvoker = new AgentInvoker(errorHandler, ctx.errorCounter(), recorder); replayerAgentInvoker.start(); recorderAgentInvoker.start(); }
@Test(expected = IllegalStateException.class) public void shouldNotAllowRemoveAfterClose() { final DynamicCompositeAgent compositeAgent = new DynamicCompositeAgent(ROLE_NAME); final AgentInvoker invoker = new AgentInvoker(Throwable::printStackTrace, null, compositeAgent); invoker.close(); compositeAgent.tryRemove(mock(Agent.class)); }
@Test(expected = IllegalStateException.class) public void shouldNotAllowAddAfterClose() { final DynamicCompositeAgent compositeAgent = new DynamicCompositeAgent(ROLE_NAME); final AgentInvoker invoker = new AgentInvoker(Throwable::printStackTrace, null, compositeAgent); invoker.close(); compositeAgent.tryAdd(mock(Agent.class)); }
@Test public void shouldRemoveAgent() throws Exception { final Agent mockAgentOne = mock(Agent.class); final Agent mockAgentTwo = mock(Agent.class); final DynamicCompositeAgent compositeAgent = new DynamicCompositeAgent(ROLE_NAME, mockAgentOne, mockAgentTwo); final AgentInvoker invoker = new AgentInvoker(Throwable::printStackTrace, null, compositeAgent); invoker.start(); verify(mockAgentOne, times(1)).onStart(); verify(mockAgentTwo, times(1)).onStart(); invoker.invoke(); verify(mockAgentOne, times(1)).doWork(); verify(mockAgentTwo, times(1)).doWork(); assertTrue(compositeAgent.tryRemove(mockAgentTwo)); assertFalse(compositeAgent.hasRemoveAgentCompleted()); invoker.invoke(); assertTrue(compositeAgent.hasRemoveAgentCompleted()); verify(mockAgentOne, times(2)).doWork(); verify(mockAgentTwo, times(1)).doWork(); verify(mockAgentOne, times(1)).onStart(); verify(mockAgentTwo, times(1)).onStart(); verify(mockAgentTwo, times(1)).onClose(); }
Aeron(final Context ctx) { ctx.conclude(); this.ctx = ctx; clientId = ctx.clientId(); commandBuffer = ctx.toDriverBuffer(); conductor = new ClientConductor(ctx); if (ctx.useConductorAgentInvoker()) { conductorInvoker = new AgentInvoker(ctx.errorHandler(), null, conductor); conductorRunner = null; } else { conductorInvoker = null; conductorRunner = new AgentRunner(ctx.idleStrategy(), ctx.errorHandler(), null, conductor); } }
@Test public void shouldAddAgent() throws Exception { final Agent mockAgentOne = mock(Agent.class); final DynamicCompositeAgent compositeAgent = new DynamicCompositeAgent(ROLE_NAME, mockAgentOne); final AgentInvoker invoker = new AgentInvoker(Throwable::printStackTrace, null, compositeAgent); assertThat(compositeAgent.roleName(), is(ROLE_NAME)); invoker.start(); verify(mockAgentOne, times(1)).onStart(); invoker.invoke(); verify(mockAgentOne, times(1)).onStart(); verify(mockAgentOne, times(1)).doWork(); final Agent mockAgentTwo = mock(Agent.class); assertTrue(compositeAgent.tryAdd(mockAgentTwo)); assertFalse(compositeAgent.hasAddAgentCompleted()); invoker.invoke(); assertTrue(compositeAgent.hasAddAgentCompleted()); verify(mockAgentOne, times(1)).onStart(); verify(mockAgentOne, times(2)).doWork(); verify(mockAgentTwo, times(1)).onStart(); verify(mockAgentTwo, times(1)).doWork(); }
Archive(final Context ctx) { this.ctx = ctx; ctx.conclude(); final ArchiveConductor conductor = ArchiveThreadingMode.DEDICATED == ctx.threadingMode() ? new DedicatedModeArchiveConductor(ctx) : new SharedModeArchiveConductor(ctx); if (ArchiveThreadingMode.INVOKER == ctx.threadingMode()) { conductorInvoker = new AgentInvoker(ctx.errorHandler(), ctx.errorCounter(), conductor); conductorRunner = null; } else { conductorInvoker = null; conductorRunner = new AgentRunner(ctx.idleStrategy(), ctx.errorHandler(), ctx.errorCounter(), conductor); } }
@Test public void shouldDetectConcurrentAdd() { final Agent mockAgentOne = mock(Agent.class); final Agent mockAgentTwo = mock(Agent.class); final DynamicCompositeAgent compositeAgent = new DynamicCompositeAgent(ROLE_NAME, mockAgentOne, mockAgentTwo); final AgentInvoker invoker = new AgentInvoker(Throwable::printStackTrace, null, compositeAgent); invoker.start(); assertTrue(compositeAgent.tryAdd(mockAgentOne)); assertFalse(compositeAgent.tryAdd(mockAgentTwo)); invoker.invoke(); assertTrue(compositeAgent.tryAdd(mockAgentTwo)); }
@Test public void shouldDetectConcurrentRemove() { final Agent mockAgentOne = mock(Agent.class); final Agent mockAgentTwo = mock(Agent.class); final DynamicCompositeAgent compositeAgent = new DynamicCompositeAgent(ROLE_NAME, mockAgentOne, mockAgentTwo); final AgentInvoker invoker = new AgentInvoker(Throwable::printStackTrace, null, compositeAgent); invoker.start(); assertTrue(compositeAgent.tryAdd(mockAgentOne)); invoker.invoke(); assertTrue(compositeAgent.tryAdd(mockAgentTwo)); invoker.invoke(); assertTrue(compositeAgent.tryRemove(mockAgentOne)); assertFalse(compositeAgent.tryRemove(mockAgentTwo)); invoker.invoke(); assertTrue(compositeAgent.tryRemove(mockAgentTwo)); } }
sharedInvoker = new AgentInvoker( errorHandler, errorCounter, new CompositeAgent(sender, receiver, conductor)); sharedRunner = null;
public void onStart() { super.onStart(); replayerAgentInvoker = new AgentInvoker(errorHandler, ctx.errorCounter(), replayer); recorderAgentInvoker = new AgentInvoker(errorHandler, ctx.errorCounter(), recorder); replayerAgentInvoker.start(); recorderAgentInvoker.start(); }
Aeron(final Context ctx) { ctx.conclude(); this.ctx = ctx; clientId = ctx.clientId(); commandBuffer = ctx.toDriverBuffer(); conductor = new ClientConductor(ctx); if (ctx.useConductorAgentInvoker()) { conductorInvoker = new AgentInvoker(ctx.errorHandler(), null, conductor); conductorRunner = null; } else { conductorInvoker = null; conductorRunner = new AgentRunner(ctx.idleStrategy(), ctx.errorHandler(), null, conductor); } }
Aeron(final Context ctx) { ctx.conclude(); this.ctx = ctx; clientId = ctx.clientId(); commandBuffer = ctx.toDriverBuffer(); conductor = new ClientConductor(ctx); if (ctx.useConductorAgentInvoker()) { conductorInvoker = new AgentInvoker(ctx.errorHandler(), null, conductor); conductorRunner = null; } else { conductorInvoker = null; conductorRunner = new AgentRunner(ctx.idleStrategy(), ctx.errorHandler(), null, conductor); } }
public void launch( final EngineConfiguration configuration, final ErrorHandler errorHandler, final Agent framer, final Agent indexingAgent, final Agent monitoringAgent, final Agent conductorAgent, final RecordingCoordinator recordingCoordinator) { this.recordingCoordinator = recordingCoordinator; framerInvoker = new AgentInvoker(errorHandler, null, framer); framerInvoker.start(); if (archivingRunner != null) { EngineScheduler.fail(); } archivingRunner = new AgentRunner( configuration.archiverIdleStrategy(), errorHandler, null, indexingAgent); startOnThread(archivingRunner); if (monitoringAgent != null) { monitoringRunner = new AgentRunner( backoffIdleStrategy(), errorHandler, null, monitoringAgent); startOnThread(monitoringRunner); } }
Archive(final Context ctx) { this.ctx = ctx; ctx.conclude(); final ArchiveConductor conductor = ArchiveThreadingMode.DEDICATED == ctx.threadingMode() ? new DedicatedModeArchiveConductor(ctx) : new SharedModeArchiveConductor(ctx); if (ArchiveThreadingMode.INVOKER == ctx.threadingMode()) { conductorInvoker = new AgentInvoker(ctx.errorHandler(), ctx.errorCounter(), conductor); conductorRunner = null; } else { conductorInvoker = null; conductorRunner = new AgentRunner(ctx.idleStrategy(), ctx.errorHandler(), ctx.errorCounter(), conductor); } }
sharedInvoker = new AgentInvoker( errorHandler, errorCounter, new CompositeAgent(sender, receiver, conductor)); sharedRunner = null;
sharedInvoker = new AgentInvoker( errorHandler, errorCounter, new CompositeAgent(sender, receiver, conductor)); sharedRunner = null;