protected void closeSession(final T session) { try { session.close(); } catch (final Exception ex) { errorHandler.onError(ex); } }
private void recordError(final Exception ex) { errors.increment(); errorHandler.onError(ex); } }
void handleError(final Throwable ex) { ctx.errorHandler().onError(ex); }
private void handleError(final Throwable throwable) { if (isRunning) { if (null != errorCounter) { errorCounter.increment(); } errorHandler.onError(throwable); } } }
private void handleError(final Throwable throwable) { if (null != errorCounter) { errorCounter.increment(); } errorHandler.onError(throwable); } }
public void onError(final Throwable throwable) { errorCounter.increment(); errorHandler.onError(throwable); } }
public void close() { if (!free()) { errorHandler.onError(new AeronException("unable to delete " + logFile)); } }
/** * Mark the invoker as closed and call the {@link Agent#onClose()} logic for clean up. * <p> * The clean up logic will only be performed once. */ public final void close() { try { if (!isClosed) { isRunning = false; isClosed = true; agent.onClose(); } } catch (final Throwable throwable) { errorHandler.onError(throwable); } }
protected void closeSessionWorkers() { try { CloseHelper.close(recorderAgentRunner); } catch (final Exception ex) { errorHandler.onError(ex); } try { CloseHelper.close(replayerAgentRunner); } catch (final Exception ex) { errorHandler.onError(ex); } while (processCloseQueue() > 0 || !closeQueue.isEmpty()) { Thread.yield(); } }
/** * Mark the invoker as started and call the {@link Agent#onStart()} method. * <p> * Startup logic will only be performed once. */ public void start() { try { if (!isStarted) { isStarted = true; agent.onStart(); isRunning = true; } } catch (final Throwable throwable) { errorHandler.onError(throwable); close(); } }
private void assertExceptionNotReported() throws Exception { new Thread(runner).start(); Thread.sleep(100); runner.close(); verify(mockAgent, times(1)).onStart(); verify(mockAgent, atLeastOnce()).doWork(); verify(mockErrorHandler, never()).onError(any()); verify(mockAtomicCounter, never()).increment(); } }
@Test public void shouldErrorOnRemoveSubscriptionOnUnknownRegistrationId() { final long id1 = driverProxy.addSubscription(CHANNEL_4000, STREAM_ID_1); driverProxy.removeSubscription(id1 + 100); driverConductor.doWork(); final InOrder inOrder = inOrder(receiverProxy, mockClientProxy); inOrder.verify(receiverProxy).addSubscription(any(), anyInt()); inOrder.verify(mockClientProxy).onSubscriptionReady(eq(id1), anyInt()); inOrder.verify(mockClientProxy).onError(anyLong(), eq(UNKNOWN_SUBSCRIPTION), anyString()); inOrder.verifyNoMoreInteractions(); verify(mockErrorHandler).onError(any(Throwable.class)); }
@Test public void shouldErrorOnAddSubscriptionWithInvalidChannel() { driverProxy.addSubscription(INVALID_URI, STREAM_ID_1); driverConductor.doWork(); driverConductor.doWork(); verify(senderProxy, never()).newNetworkPublication(any()); verify(mockClientProxy).onError(anyLong(), eq(INVALID_CHANNEL), anyString()); verify(mockClientProxy, never()).operationSucceeded(anyLong()); verify(mockErrorCounter).increment(); verify(mockErrorHandler).onError(any(Throwable.class)); }
@Test public void shouldErrorOnRemovePublicationOnUnknownRegistrationId() { final long id = driverProxy.addPublication(CHANNEL_4000, STREAM_ID_1); driverProxy.removePublication(id + 1); driverConductor.doWork(); final InOrder inOrder = inOrder(senderProxy, mockClientProxy); inOrder.verify(senderProxy).newNetworkPublication(any()); inOrder.verify(mockClientProxy).onPublicationReady( anyLong(), eq(id), eq(STREAM_ID_1), anyInt(), any(), anyInt(), anyInt(), eq(false)); inOrder.verify(mockClientProxy).onError(anyLong(), eq(UNKNOWN_PUBLICATION), anyString()); inOrder.verifyNoMoreInteractions(); verify(mockErrorCounter).increment(); verify(mockErrorHandler).onError(any(Throwable.class)); }
private void assertExceptionNotReported() { invoker.start(); invoker.invoke(); invoker.close(); verify(mockErrorHandler, never()).onError(any()); verify(mockAtomicCounter, never()).increment(); } }
@Test public void shouldNotDoWorkOnClosedRunnerButCallOnClose() throws Exception { invoker.close(); invoker.invoke(); verify(mockAgent, never()).onStart(); verify(mockAgent, never()).doWork(); verify(mockErrorHandler, never()).onError(any()); verify(mockAtomicCounter, never()).increment(); verify(mockAgent).onClose(); }
@Test public void shouldErrorOnAddPublicationWithClashingSessionId() { driverProxy.addPublication(CHANNEL_4000, STREAM_ID_1); driverConductor.doWork(); final ArgumentCaptor<NetworkPublication> argumentCaptor = ArgumentCaptor.forClass(NetworkPublication.class); verify(senderProxy).newNetworkPublication(argumentCaptor.capture()); final String sessionIdParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + argumentCaptor.getValue().sessionId(); final long correlationId = driverProxy.addExclusivePublication(CHANNEL_4000 + sessionIdParam, STREAM_ID_1); driverConductor.doWork(); verify(mockClientProxy).onError(eq(correlationId), eq(GENERIC_ERROR), anyString()); verify(mockErrorCounter).increment(); verify(mockErrorHandler).onError(any(Throwable.class)); }
@Test public void shouldTimeoutInterServiceIfTooLongBetweenDoWorkCalls() { suppressPrintError = true; conductor.doWork(); timeNs += (TimeUnit.MILLISECONDS.toNanos(INTER_SERVICE_TIMEOUT_MS) + 1); conductor.doWork(); verify(mockClientErrorHandler).onError(any(ConductorServiceTimeoutException.class)); assertTrue(conductor.isTerminating()); }
@Test public void shouldUseUniqueChannelEndpointOnAddSubscriptionWithNoDistinguishingCharacteristics() { final long id1 = driverProxy.addSubscription(CHANNEL_SUB_CONTROL_MODE_MANUAL, STREAM_ID_1); final long id2 = driverProxy.addSubscription(CHANNEL_SUB_CONTROL_MODE_MANUAL, STREAM_ID_1); driverConductor.doWork(); verify(receiverProxy, times(2)).registerReceiveChannelEndpoint(any()); driverProxy.removeSubscription(id1); driverProxy.removeSubscription(id2); driverConductor.doWork(); verify(receiverProxy, times(2)).closeReceiveChannelEndpoint(any()); verify(mockErrorHandler, never()).onError(any()); }
@Test public void shouldErrorOnAddPublicationWithNonEqualSessionId() { driverProxy.addPublication(CHANNEL_4000, STREAM_ID_1); driverConductor.doWork(); final ArgumentCaptor<NetworkPublication> argumentCaptor = ArgumentCaptor.forClass(NetworkPublication.class); verify(senderProxy).newNetworkPublication(argumentCaptor.capture()); final String sessionIdParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + (argumentCaptor.getValue().sessionId() + 1); final long correlationId = driverProxy.addPublication(CHANNEL_4000 + sessionIdParam, STREAM_ID_1); driverConductor.doWork(); verify(mockClientProxy).onError(eq(correlationId), eq(GENERIC_ERROR), anyString()); verify(mockErrorCounter).increment(); verify(mockErrorHandler).onError(any(Throwable.class)); }