Search in sources :

Example 1 with SamzaRestConfig

use of org.apache.samza.rest.SamzaRestConfig 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 SamzaRestConfig

use of org.apache.samza.rest.SamzaRestConfig 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 SamzaRestConfig

use of org.apache.samza.rest.SamzaRestConfig 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)

Example 4 with SamzaRestConfig

use of org.apache.samza.rest.SamzaRestConfig in project samza by apache.

the class TestTasksResource method configure.

@Override
protected Application configure() {
    Map<String, String> configMap = ImmutableMap.of(TaskResourceConfig.CONFIG_TASK_PROXY_FACTORY, MockTaskProxyFactory.class.getName(), SamzaRestConfig.CONFIG_REST_RESOURCE_FACTORIES, MockResourceFactory.class.getName());
    SamzaRestConfig config = new SamzaRestConfig(new MapConfig(configMap));
    return new SamzaRestApplication(config);
}
Also used : SamzaRestConfig(org.apache.samza.rest.SamzaRestConfig) SamzaRestApplication(org.apache.samza.rest.SamzaRestApplication) MapConfig(org.apache.samza.config.MapConfig) MockTaskProxyFactory(org.apache.samza.rest.resources.mock.MockTaskProxyFactory) MockResourceFactory(org.apache.samza.rest.resources.mock.MockResourceFactory)

Example 5 with SamzaRestConfig

use of org.apache.samza.rest.SamzaRestConfig in project samza by apache.

the class TestJobsResource method configure.

@Override
protected Application configure() {
    Map<String, String> configMap = ImmutableMap.of(JobsResourceConfig.CONFIG_JOB_PROXY_FACTORY, MockJobProxyFactory.class.getName(), SamzaRestConfig.CONFIG_REST_RESOURCE_FACTORIES, MockResourceFactory.class.getName());
    SamzaRestConfig config = new SamzaRestConfig(new MapConfig(configMap));
    return new SamzaRestApplication(config);
}
Also used : SamzaRestConfig(org.apache.samza.rest.SamzaRestConfig) SamzaRestApplication(org.apache.samza.rest.SamzaRestApplication) MapConfig(org.apache.samza.config.MapConfig) MockJobProxyFactory(org.apache.samza.rest.resources.mock.MockJobProxyFactory) MockResourceFactory(org.apache.samza.rest.resources.mock.MockResourceFactory)

Aggregations

MapConfig (org.apache.samza.config.MapConfig)5 SamzaRestConfig (org.apache.samza.rest.SamzaRestConfig)5 InstantSchedulingProvider (org.apache.samza.monitor.mock.InstantSchedulingProvider)3 Test (org.junit.Test)3 SamzaRestApplication (org.apache.samza.rest.SamzaRestApplication)2 MockResourceFactory (org.apache.samza.rest.resources.mock.MockResourceFactory)2 SamzaException (org.apache.samza.SamzaException)1 ExceptionThrowingMonitorFactory (org.apache.samza.monitor.mock.ExceptionThrowingMonitorFactory)1 MockMonitorFactory (org.apache.samza.monitor.mock.MockMonitorFactory)1 MockJobProxyFactory (org.apache.samza.rest.resources.mock.MockJobProxyFactory)1 MockTaskProxyFactory (org.apache.samza.rest.resources.mock.MockTaskProxyFactory)1