Search in sources :

Example 1 with LaunchStatisticsService

use of com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService in project abort-mission by nagyesta.

the class RmiBackedStageStatisticsCollectorTest method testDoLogTimeMeasurementShouldThrowStrongbackExceptionWhenCaughtException.

@Test
void testDoLogTimeMeasurementShouldThrowStrongbackExceptionWhenCaughtException() throws Exception {
    // given
    final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
    when(matcher.getName()).thenReturn(MATCHER);
    final LaunchStatisticsService service = mock(LaunchStatisticsService.class);
    doThrow(new RemoteException()).when(service).insertStageTimeMeasurement(anyString(), anyString(), anyBoolean(), any(RmiStageTimeMeasurement.class));
    final Registry registry = mock(Registry.class);
    when(registry.lookup(eq(RmiServerConstants.SERVICE_NAME))).thenReturn(service);
    final RmiBackedStageStatisticsCollector underTest = new RmiBackedStageStatisticsCollector(CONTEXT, matcher, registry, true);
    // when
    Assertions.assertThrows(StrongbackException.class, () -> underTest.doLogTimeMeasurement(CONTEXT, matcher, true, ABORTED));
    // then + exception
    final InOrder inOrder = inOrder(registry, service, matcher);
    inOrder.verify(registry).lookup(eq(RmiServerConstants.SERVICE_NAME));
    inOrder.verify(service).insertStageTimeMeasurement(eq(CONTEXT), eq(MATCHER), eq(true), any(RmiStageTimeMeasurement.class));
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) Registry(java.rmi.registry.Registry) LaunchStatisticsService(com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService) RemoteException(java.rmi.RemoteException) MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) Test(org.junit.jupiter.api.Test)

Example 2 with LaunchStatisticsService

use of com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService in project abort-mission by nagyesta.

the class RmiBackedLaunchTelemetryDataSourceIntegrationTest method fetchAllMeasurements.

private List<StageTimeMeasurement> fetchAllMeasurements() throws RemoteException {
    final List<StageTimeMeasurement> list = new ArrayList<>();
    final LaunchStatisticsService serviceOuter = service;
    for (final String s : service.fetchAllMatcherNames()) {
        final List<RmiStageTimeMeasurement> rmiStageTimeMeasurements = serviceOuter.fetchAllMeasurementsForMatcher(s);
        for (final RmiStageTimeMeasurement rmiStageTimeMeasurement : rmiStageTimeMeasurements) {
            final StageTimeMeasurement toStageTimeMeasurement = rmiStageTimeMeasurement.toStageTimeMeasurement();
            list.add(toStageTimeMeasurement);
        }
    }
    return list;
}
Also used : RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement) LaunchStatisticsService(com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService)

Example 3 with LaunchStatisticsService

use of com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService in project abort-mission by nagyesta.

the class RmiBackedStageStatisticsCollector method doLogTimeMeasurement.

@Override
protected void doLogTimeMeasurement(final String contextName, final MissionHealthCheckMatcher matcher, final boolean countdown, final StageTimeMeasurement measurement) {
    try {
        final LaunchStatisticsService service = RmiServiceProvider.service(registry);
        final RmiStageTimeMeasurement rmiMeasurement = new RmiStageTimeMeasurement(measurement);
        service.insertStageTimeMeasurement(contextName, matcher.getName(), countdown, rmiMeasurement);
    } catch (final RemoteException e) {
        LOGGER.error("Failed to log measurement.", e);
        throw new StrongbackException(e.getMessage(), e);
    }
}
Also used : LaunchStatisticsService(com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService) RemoteException(java.rmi.RemoteException) StrongbackException(com.github.nagyesta.abortmission.strongback.base.StrongbackException)

Example 4 with LaunchStatisticsService

use of com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService in project abort-mission by nagyesta.

the class RmiBackedStageStatisticsCollectorTest method testDoFetchAllShouldThrowStrongbackExceptionWhenCaughtException.

@Test
void testDoFetchAllShouldThrowStrongbackExceptionWhenCaughtException() throws Exception {
    // given
    final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
    when(matcher.getName()).thenReturn(MATCHER);
    final LaunchStatisticsService service = mock(LaunchStatisticsService.class);
    when(service.fetchMeasurementsFor(anyString(), anyString(), anyBoolean())).thenThrow(new RemoteException());
    final Registry registry = mock(Registry.class);
    when(registry.lookup(eq(RmiServerConstants.SERVICE_NAME))).thenReturn(service);
    final RmiBackedStageStatisticsCollector underTest = new RmiBackedStageStatisticsCollector(CONTEXT, matcher, registry, true);
    // when
    Assertions.assertThrows(StrongbackException.class, () -> underTest.doFetchAll(CONTEXT, matcher, true));
    // then + exception
    final InOrder inOrder = inOrder(registry, service, matcher);
    inOrder.verify(registry).lookup(eq(RmiServerConstants.SERVICE_NAME));
    inOrder.verify(service).fetchMeasurementsFor(eq(CONTEXT), eq(MATCHER), eq(true));
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) Registry(java.rmi.registry.Registry) LaunchStatisticsService(com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService) RemoteException(java.rmi.RemoteException) MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) Test(org.junit.jupiter.api.Test)

Example 5 with LaunchStatisticsService

use of com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService in project abort-mission by nagyesta.

the class RmiBackedStageStatisticsCollectorTest method testDoGetSnapshotShouldThrowStrongbackExceptionWhenCaughtException.

@Test
void testDoGetSnapshotShouldThrowStrongbackExceptionWhenCaughtException() throws Exception {
    // given
    final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
    when(matcher.getName()).thenReturn(MATCHER);
    final LaunchStatisticsService service = mock(LaunchStatisticsService.class);
    when(service.getSnapshot(anyString(), anyString(), anyBoolean())).thenThrow(new RemoteException());
    final Registry registry = mock(Registry.class);
    when(registry.lookup(eq(RmiServerConstants.SERVICE_NAME))).thenReturn(service);
    final RmiBackedStageStatisticsCollector underTest = new RmiBackedStageStatisticsCollector(CONTEXT, matcher, registry, true);
    // when
    Assertions.assertThrows(StrongbackException.class, () -> underTest.doGetSnapshot(CONTEXT, matcher, true));
    // then + exception
    final InOrder inOrder = inOrder(registry, service, matcher);
    inOrder.verify(registry).lookup(eq(RmiServerConstants.SERVICE_NAME));
    inOrder.verify(service).getSnapshot(eq(CONTEXT), eq(MATCHER), eq(true));
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) Registry(java.rmi.registry.Registry) LaunchStatisticsService(com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService) RemoteException(java.rmi.RemoteException) MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) Test(org.junit.jupiter.api.Test)

Aggregations

LaunchStatisticsService (com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService)6 RemoteException (java.rmi.RemoteException)5 Registry (java.rmi.registry.Registry)4 MissionHealthCheckMatcher (com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher)3 Test (org.junit.jupiter.api.Test)3 InOrder (org.mockito.InOrder)3 StageTimeMeasurement (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement)2 StrongbackException (com.github.nagyesta.abortmission.strongback.base.StrongbackException)2 RmiStageTimeMeasurement (com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement)2 CLASS_ONLY (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement.CLASS_ONLY)1 BaseLaunchTelemetryConverter (com.github.nagyesta.abortmission.core.telemetry.converter.BaseLaunchTelemetryConverter)1 ClassTelemetryConverter (com.github.nagyesta.abortmission.core.telemetry.converter.ClassTelemetryConverter)1 ClassTelemetry (com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry)1 LaunchTelemetryDataSource (com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource)1 RmiServiceProvider (com.github.nagyesta.abortmission.strongback.rmi.server.RmiServiceProvider)1 java.util (java.util)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1