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); } }
@Override protected void configure() { ObjectMapper objectMapper = JavaUtils.newObjectMapper(); objectMapper.registerModule(new GuavaModule()); objectMapper.registerModule(new Jdk8Module()); HttpClient httpClient = new NingHttpClient(httpConfig.or(HttpConfig.newBuilder().setObjectMapper(objectMapper).build())); bind(HttpClient.class).annotatedWith(Names.named(HTTP_CLIENT_NAME)).toInstance(httpClient); bind(SingularityClient.class).toProvider(SingularityClientProvider.class).in(Scopes.SINGLETON); if (hosts != null) { bindHosts(binder()).toInstance(hosts); } }
@Override protected void configure() { final int singularityPort = Integer.parseInt(System.getProperty("singularity.port")); install(new SingularityClientModule(Arrays.asList(String.format("%s:%d", getDockerAddress().or("localhost"), singularityPort)))); } }
@Test public void testModuleWithHosts() { final Injector injector = Guice.createInjector(Stage.PRODUCTION, new GuiceDisableModule(), new SingularityClientModule(Collections.singletonList("http://example.com"))); injector.injectMembers(this); }
@Test public void testModuleWithHosts() { final Injector injector = Guice.createInjector(Stage.PRODUCTION, new GuiceDisableModule(), new SingularityClientModule(Collections.singletonList("http://example.com"))); injector.injectMembers(this); }