Search in sources :

Example 1 with SingularityRunnerBaseModule

use of com.hubspot.singularity.runner.base.config.SingularityRunnerBaseModule in project Singularity by HubSpot.

the class SingularityExecutorCleanupRunner method main.

public static void main(String... args) {
    final long start = System.currentTimeMillis();
    try {
        final Injector injector = Guice.createInjector(Stage.PRODUCTION, new SingularityRunnerBaseModule(SingularityExecutorCleanupConfiguration.class, ImmutableSet.of(SingularityS3Configuration.class, SingularityExecutorConfiguration.class)), new SingularityExecutorModule(), new SingularityExecutorCleanupModule(), new SingularityClientModule(), new SingularityMesosClientModule());
        final SingularityExecutorCleanupRunner runner = injector.getInstance(SingularityExecutorCleanupRunner.class);
        LOG.info("Starting cleanup");
        final SingularityExecutorCleanupStatistics statistics = runner.cleanup();
        LOG.info("Finished with {} after {}", statistics, JavaUtils.duration(start));
        System.exit(0);
    } catch (Throwable t) {
        LOG.error("Finished after {} with error", JavaUtils.duration(start), t);
        System.exit(1);
    }
}
Also used : SingularityExecutorCleanupConfiguration(com.hubspot.singularity.executor.cleanup.config.SingularityExecutorCleanupConfiguration) SingularityClientModule(com.hubspot.singularity.client.SingularityClientModule) Injector(com.google.inject.Injector) SingularityRunnerBaseModule(com.hubspot.singularity.runner.base.config.SingularityRunnerBaseModule) SingularityExecutorCleanupModule(com.hubspot.singularity.executor.cleanup.config.SingularityExecutorCleanupModule) SingularityExecutorCleanupStatistics(com.hubspot.singularity.executor.SingularityExecutorCleanupStatistics) SingularityExecutorModule(com.hubspot.singularity.executor.config.SingularityExecutorModule) SingularityMesosClientModule(com.hubspot.mesos.client.SingularityMesosClientModule)

Example 2 with SingularityRunnerBaseModule

use of com.hubspot.singularity.runner.base.config.SingularityRunnerBaseModule in project Singularity by HubSpot.

the class SingularityExecutorRunner method main.

public static void main(String... args) {
    final long start = System.currentTimeMillis();
    try {
        final Injector injector = Guice.createInjector(Stage.PRODUCTION, new SingularityRunnerBaseModule(SingularityExecutorConfiguration.class, ImmutableSet.<Class<? extends BaseRunnerConfiguration>>of(SingularityS3Configuration.class)), new SingularityExecutorModule());
        final SingularityExecutorRunner executorRunner = injector.getInstance(SingularityExecutorRunner.class);
        final Protos.Status driverStatus = executorRunner.run();
        LOG.info("Executor finished after {} with status: {}", JavaUtils.duration(start), driverStatus);
        stopLog();
        System.exit(driverStatus == Protos.Status.DRIVER_STOPPED ? 0 : 1);
    } catch (Throwable t) {
        LOG.error("Finished after {} with error", JavaUtils.duration(start), t);
        stopLog();
        System.exit(1);
    }
}
Also used : SingularityExecutorConfiguration(com.hubspot.singularity.executor.config.SingularityExecutorConfiguration) BaseRunnerConfiguration(com.hubspot.singularity.runner.base.configuration.BaseRunnerConfiguration) Protos(org.apache.mesos.Protos) Injector(com.google.inject.Injector) SingularityRunnerBaseModule(com.hubspot.singularity.runner.base.config.SingularityRunnerBaseModule) SingularityExecutorModule(com.hubspot.singularity.executor.config.SingularityExecutorModule)

Example 3 with SingularityRunnerBaseModule

use of com.hubspot.singularity.runner.base.config.SingularityRunnerBaseModule in project Singularity by HubSpot.

the class SingularityExecutorConfigurationTest method loadConfig.

private SingularityExecutorConfiguration loadConfig(String file) {
    try {
        ObjectMapper mapper = new SingularityRunnerBaseModule(null).providesYamlMapper();
        Validator validator = mock(Validator.class);
        Field mapperField = SingularityRunnerConfigurationProvider.class.getDeclaredField("objectMapper");
        mapperField.setAccessible(true);
        Field validatorField = SingularityRunnerConfigurationProvider.class.getDeclaredField("validator");
        validatorField.setAccessible(true);
        SingularityRunnerConfigurationProvider<SingularityExecutorConfiguration> configProvider = new SingularityRunnerConfigurationProvider<>(SingularityExecutorConfiguration.class, Optional.of(new File(getClass().getClassLoader().getResource(file).toURI()).getAbsolutePath()));
        mapperField.set(configProvider, mapper);
        validatorField.set(configProvider, validator);
        return configProvider.get();
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : SingularityRunnerConfigurationProvider(com.hubspot.singularity.runner.base.config.SingularityRunnerConfigurationProvider) Field(java.lang.reflect.Field) SingularityRunnerBaseModule(com.hubspot.singularity.runner.base.config.SingularityRunnerBaseModule) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Validator(javax.validation.Validator)

Aggregations

SingularityRunnerBaseModule (com.hubspot.singularity.runner.base.config.SingularityRunnerBaseModule)3 Injector (com.google.inject.Injector)2 SingularityExecutorModule (com.hubspot.singularity.executor.config.SingularityExecutorModule)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SingularityMesosClientModule (com.hubspot.mesos.client.SingularityMesosClientModule)1 SingularityClientModule (com.hubspot.singularity.client.SingularityClientModule)1 SingularityExecutorCleanupStatistics (com.hubspot.singularity.executor.SingularityExecutorCleanupStatistics)1 SingularityExecutorCleanupConfiguration (com.hubspot.singularity.executor.cleanup.config.SingularityExecutorCleanupConfiguration)1 SingularityExecutorCleanupModule (com.hubspot.singularity.executor.cleanup.config.SingularityExecutorCleanupModule)1 SingularityExecutorConfiguration (com.hubspot.singularity.executor.config.SingularityExecutorConfiguration)1 SingularityRunnerConfigurationProvider (com.hubspot.singularity.runner.base.config.SingularityRunnerConfigurationProvider)1 BaseRunnerConfiguration (com.hubspot.singularity.runner.base.configuration.BaseRunnerConfiguration)1 File (java.io.File)1 Field (java.lang.reflect.Field)1 Validator (javax.validation.Validator)1 Protos (org.apache.mesos.Protos)1