use of com.hubspot.singularity.config.SingularityConfiguration in project Singularity by HubSpot.
the class SingularityService method initialize.
@Override
public void initialize(final Bootstrap<T> bootstrap) {
if (!Strings.isNullOrEmpty(System.getProperty(SINGULARITY_DEFAULT_CONFIGURATION_PROPERTY))) {
bootstrap.setConfigurationSourceProvider(new MergingSourceProvider(bootstrap.getConfigurationSourceProvider(), System.getProperty(SINGULARITY_DEFAULT_CONFIGURATION_PROPERTY), bootstrap.getObjectMapper(), new YAMLFactory()));
}
final Iterable<? extends Module> additionalModules = checkNotNull(getGuiceModules(bootstrap), "getGuiceModules() returned null");
final Iterable<? extends Bundle> additionalBundles = checkNotNull(getDropwizardBundles(bootstrap), "getDropwizardBundles() returned null");
final Iterable<? extends ConfiguredBundle<T>> additionalConfiguredBundles = checkNotNull(getDropwizardConfiguredBundles(bootstrap), "getDropwizardConfiguredBundles() returned null");
guiceBundle = GuiceBundle.defaultBuilder(SingularityConfiguration.class).modules(new SingularityServiceModule()).modules(new SingularityAuthModule()).modules(additionalModules).build();
bootstrap.addBundle(guiceBundle);
bootstrap.addBundle(new CorsBundle());
bootstrap.addBundle(new ViewBundle<>());
bootstrap.addBundle(new AssetsBundle("/assets/static/", "/static/"));
bootstrap.addBundle(new AssetsBundle("/assets/api-docs/", "/api-docs/", "index.html", "api-docs"));
bootstrap.addBundle(new MigrationsBundle<SingularityConfiguration>() {
@Override
public DataSourceFactory getDataSourceFactory(final SingularityConfiguration configuration) {
return configuration.getDatabaseConfiguration().get();
}
});
for (Bundle bundle : additionalBundles) {
bootstrap.addBundle(bundle);
}
for (ConfiguredBundle<T> configuredBundle : additionalConfiguredBundles) {
bootstrap.addBundle(configuredBundle);
}
bootstrap.getObjectMapper().registerModule(new ProtobufModule());
bootstrap.getObjectMapper().registerModule(new GuavaModule());
bootstrap.getObjectMapper().setSerializationInclusion(Include.NON_NULL);
bootstrap.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
use of com.hubspot.singularity.config.SingularityConfiguration in project Singularity by HubSpot.
the class SingularityTestModule method configure.
@Override
public void configure(Binder mainBinder) {
mainBinder.install(new GuiceBundle.GuiceEnforcerModule());
TestingMesosClient tmc = new TestingMesosClient();
mainBinder.bind(MesosClient.class).toInstance(tmc);
mainBinder.bind(TestingMesosClient.class).toInstance(tmc);
mainBinder.bind(TestingServer.class).toInstance(ts);
final SingularityConfiguration configuration = getSingularityConfigurationForTestingServer(ts);
configuration.getMesosConfiguration().setMaster("");
if (useDBTests) {
configuration.setDatabaseConfiguration(getDataSourceFactory());
}
if (customConfigSetup != null) {
customConfigSetup.apply(configuration);
}
mainBinder.bind(SingularityConfiguration.class).toInstance(configuration);
mainBinder.install(Modules.override(new SingularityMainModule(configuration)).with(new Module() {
@Override
public void configure(Binder binder) {
binder.bind(SingularityExceptionNotifier.class).toInstance(mock(SingularityExceptionNotifier.class));
SingularityAbort abort = mock(SingularityAbort.class);
SingularityMailer mailer = mock(SingularityMailer.class);
binder.bind(SingularityMailer.class).toInstance(mailer);
binder.bind(SingularityAbort.class).toInstance(abort);
TestingLoadBalancerClient tlbc = new TestingLoadBalancerClient();
binder.bind(LoadBalancerClient.class).toInstance(tlbc);
binder.bind(TestingLoadBalancerClient.class).toInstance(tlbc);
if (configuration.isCacheOffers()) {
binder.bind(OfferCache.class).to(SingularityOfferCache.class);
} else {
binder.bind(OfferCache.class).to(SingularityNoOfferCache.class);
}
binder.bind(ObjectMapper.class).toInstance(om);
binder.bind(Environment.class).toInstance(environment);
binder.bind(HostAndPort.class).annotatedWith(named(HTTP_HOST_AND_PORT)).toInstance(HostAndPort.fromString("localhost:8080"));
binder.bind(new TypeLiteral<Optional<Raven>>() {
}).toInstance(Optional.<Raven>absent());
binder.bind(new TypeLiteral<Optional<SentryConfiguration>>() {
}).toInstance(Optional.<SentryConfiguration>absent());
binder.bind(HttpServletRequest.class).toProvider(new Provider<HttpServletRequest>() {
@Override
public HttpServletRequest get() {
throw new OutOfScopeException("testing");
}
});
}
}));
mainBinder.install(Modules.override(new SingularityMesosModule()).with(new Module() {
@Override
public void configure(Binder binder) {
SingularityMesosExecutorInfoSupport logSupport = mock(SingularityMesosExecutorInfoSupport.class);
binder.bind(SingularityMesosExecutorInfoSupport.class).toInstance(logSupport);
SingularityMesosSchedulerClient mockClient = mock(SingularityMesosSchedulerClient.class);
when(mockClient.isRunning()).thenReturn(true);
binder.bind(SingularityMesosSchedulerClient.class).toInstance(mockClient);
}
}));
mainBinder.install(new SingularityDataModule());
mainBinder.install(new SingularitySchedulerModule());
mainBinder.install(new SingularityTranscoderModule());
mainBinder.install(new SingularityHistoryModule(configuration));
mainBinder.install(new SingularityZkMigrationsModule());
mainBinder.install(new SingularityEventModule(configuration));
// Auth module bits
mainBinder.bind(SingularityAuthenticator.class).to(SingularityTestAuthenticator.class);
mainBinder.bind(SingularityAuthDatastore.class).to(SingularityDisabledAuthDatastore.class);
mainBinder.bind(SingularityAuthorizationHelper.class).in(Scopes.SINGLETON);
mainBinder.bind(SingularityTestAuthenticator.class).in(Scopes.SINGLETON);
mainBinder.bind(DeployResource.class);
mainBinder.bind(RequestResource.class);
mainBinder.bind(TaskResource.class);
mainBinder.bind(SlaveResource.class);
mainBinder.bind(RackResource.class);
mainBinder.bind(PriorityResource.class);
}
use of com.hubspot.singularity.config.SingularityConfiguration in project Singularity by HubSpot.
the class SingularityAuthorizationHelperTest method buildAuthDisabledConfig.
public static SingularityConfiguration buildAuthDisabledConfig() {
AuthConfiguration authConfiguration = new AuthConfiguration();
authConfiguration.setEnabled(false);
SingularityConfiguration configuration = new SingularityConfiguration();
configuration.setAuthConfiguration(authConfiguration);
configuration.setMesosConfiguration(new MesosConfiguration());
return configuration;
}
use of com.hubspot.singularity.config.SingularityConfiguration in project Singularity by HubSpot.
the class SingularityAuthorizationHelperTest method buildAuthEnabledConfig.
public static SingularityConfiguration buildAuthEnabledConfig(Set<String> requiredGroups, Set<String> adminGroups, Set<String> jitaGroups) {
AuthConfiguration authConfiguration = new AuthConfiguration();
authConfiguration.setEnabled(true);
authConfiguration.setRequiredGroups(requiredGroups);
authConfiguration.setAdminGroups(adminGroups);
authConfiguration.setJitaGroups(jitaGroups);
SingularityConfiguration configuration = new SingularityConfiguration();
configuration.setAuthConfiguration(authConfiguration);
configuration.setMesosConfiguration(new MesosConfiguration());
return configuration;
}
use of com.hubspot.singularity.config.SingularityConfiguration in project Singularity by HubSpot.
the class SingularityTestModule method getSingularityConfigurationForTestingServer.
private static SingularityConfiguration getSingularityConfigurationForTestingServer(final TestingServer ts) {
SingularityConfiguration config = new SingularityConfiguration();
config.setLoadBalancerUri("test");
MesosConfiguration mc = new MesosConfiguration();
mc.setDefaultCpus(1);
mc.setDefaultMemory(128);
mc.setDefaultDisk(1024);
config.setMesosConfiguration(mc);
config.setSmtpConfiguration(new SMTPConfiguration());
ZooKeeperConfiguration zookeeperConfiguration = new ZooKeeperConfiguration();
zookeeperConfiguration.setQuorum(ts.getConnectString());
config.setZooKeeperConfiguration(zookeeperConfiguration);
config.setConsiderTaskHealthyAfterRunningForSeconds(0);
return config;
}
Aggregations