Search in sources :

Example 1 with InstantSchedulingProvider

use of org.apache.samza.monitor.mock.InstantSchedulingProvider in project samza by apache.

the class TestMonitorService method testMonitorExceptionIsolation.

@Test
public void testMonitorExceptionIsolation() {
    // Test that an exception from a monitor doesn't bubble up out of the scheduler.
    Map<String, String> configMap = ImmutableMap.of(String.format("monitor.name.%s", CONFIG_MONITOR_FACTORY_CLASS), ExceptionThrowingMonitorFactory.class.getCanonicalName());
    SamzaRestConfig config = new SamzaRestConfig(new MapConfig(configMap));
    SamzaMonitorService monitorService = new SamzaMonitorService(config, METRICS_REGISTRY, new InstantSchedulingProvider());
    // This will throw if the exception isn't caught within the provider.
    monitorService.start();
    monitorService.stop();
}
Also used : SamzaRestConfig(org.apache.samza.rest.SamzaRestConfig) InstantSchedulingProvider(org.apache.samza.monitor.mock.InstantSchedulingProvider) MapConfig(org.apache.samza.config.MapConfig) ExceptionThrowingMonitorFactory(org.apache.samza.monitor.mock.ExceptionThrowingMonitorFactory) Test(org.junit.Test)

Example 2 with InstantSchedulingProvider

use of org.apache.samza.monitor.mock.InstantSchedulingProvider in project samza by apache.

the class TestMonitorService method testShouldFailWhenTheMonitorFactoryClassIsInvalid.

@Test(expected = SamzaException.class)
public void testShouldFailWhenTheMonitorFactoryClassIsInvalid() {
    // Test that when MonitorFactoryClass is defined in the config and is invalid,
    // monitor service should fail. Should throw back SamzaException.
    Map<String, String> configMap = ImmutableMap.of(String.format("monitor.name.%s", CONFIG_MONITOR_FACTORY_CLASS), "RandomClassName");
    SamzaRestConfig config = new SamzaRestConfig(new MapConfig(configMap));
    SamzaMonitorService monitorService = new SamzaMonitorService(config, METRICS_REGISTRY, new InstantSchedulingProvider());
    monitorService.start();
}
Also used : SamzaRestConfig(org.apache.samza.rest.SamzaRestConfig) InstantSchedulingProvider(org.apache.samza.monitor.mock.InstantSchedulingProvider) MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test)

Example 3 with InstantSchedulingProvider

use of org.apache.samza.monitor.mock.InstantSchedulingProvider in project samza by apache.

the class TestMonitorService method testShouldNotFailWhenTheMonitorFactoryClassIsNotDefined.

@Test
public void testShouldNotFailWhenTheMonitorFactoryClassIsNotDefined() throws Exception {
    // Test that when MonitorFactoryClass is not defined in the config, monitor service
    // should not fail.
    Map<String, String> configMap = ImmutableMap.of("monitor.monitor1.config.key1", "configValue1", "monitor.monitor1.config.key2", "configValue2", String.format("monitor.MOCK_MONITOR.%s", CONFIG_MONITOR_FACTORY_CLASS), MockMonitorFactory.class.getCanonicalName());
    SamzaRestConfig config = new SamzaRestConfig(new MapConfig(configMap));
    SamzaMonitorService monitorService = new SamzaMonitorService(config, METRICS_REGISTRY, new InstantSchedulingProvider());
    try {
        monitorService.start();
    } catch (Exception e) {
        fail();
    }
    Mockito.verify(MockMonitorFactory.MOCK_MONITOR, Mockito.times(1)).monitor();
}
Also used : MockMonitorFactory(org.apache.samza.monitor.mock.MockMonitorFactory) SamzaRestConfig(org.apache.samza.rest.SamzaRestConfig) InstantSchedulingProvider(org.apache.samza.monitor.mock.InstantSchedulingProvider) MapConfig(org.apache.samza.config.MapConfig) SamzaException(org.apache.samza.SamzaException) Test(org.junit.Test)

Aggregations

MapConfig (org.apache.samza.config.MapConfig)3 InstantSchedulingProvider (org.apache.samza.monitor.mock.InstantSchedulingProvider)3 SamzaRestConfig (org.apache.samza.rest.SamzaRestConfig)3 Test (org.junit.Test)3 SamzaException (org.apache.samza.SamzaException)1 ExceptionThrowingMonitorFactory (org.apache.samza.monitor.mock.ExceptionThrowingMonitorFactory)1 MockMonitorFactory (org.apache.samza.monitor.mock.MockMonitorFactory)1