Search in sources :

Example 1 with TitusValidatorConfiguration

use of com.netflix.titus.common.model.admission.TitusValidatorConfiguration in project titus-control-plane by Netflix.

the class EmbeddedTitusGateway method boot.

public EmbeddedTitusGateway boot() {
    Stopwatch timer = Stopwatch.createStarted();
    logger.info("Starting Titus Gateway");
    injector = InjectorBuilder.fromModules(newJettyModule(), new ArchaiusModule() {

        @Override
        protected void configureArchaius() {
            config.setProperty("titus.masterClient.masterIp", masterGrpcHost);
            if (embeddedTitusMaster == null) {
                config.setProperty("titus.masterClient.masterGrpcPort", masterGrpcPort);
                config.setProperty("titus.masterClient.masterHttpPort", masterHttpPort);
            } else {
                // In the embedded mode, master cannot run jetty, so we set only GRPC port.
                config.setProperty("titus.masterClient.masterGrpcPort", embeddedTitusMaster.getGrpcPort());
                config.setProperty("titus.masterClient.masterHttpPort", "0");
            }
            bindApplicationConfigurationOverride().toInstance(config);
        }
    }, Modules.override(new TitusGatewayModule(enableREST)).with(new AbstractModule() {

        @Override
        protected void configure() {
            if (store != null) {
                bind(JobStore.class).toInstance(store);
            }
            bind(new TypeLiteral<AdmissionValidator<JobDescriptor>>() {
            }).toInstance(validator);
        }

        @Provides
        @Singleton
        public AdmissionSanitizer<JobDescriptor> getJobSanitizer(TitusValidatorConfiguration configuration) {
            return new AggregatingSanitizer(configuration, Collections.singletonList(jobSanitizer));
        }
    })).createInjector();
    logger.info("Embedded TitusGateway started in {}ms", timer.elapsed(TimeUnit.MILLISECONDS));
    return this;
}
Also used : TitusGatewayModule(com.netflix.titus.gateway.startup.TitusGatewayModule) TitusValidatorConfiguration(com.netflix.titus.common.model.admission.TitusValidatorConfiguration) TypeLiteral(com.google.inject.TypeLiteral) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) Stopwatch(com.google.common.base.Stopwatch) ArchaiusModule(com.netflix.archaius.guice.ArchaiusModule) JobStore(com.netflix.titus.api.jobmanager.store.JobStore) AggregatingSanitizer(com.netflix.titus.runtime.endpoint.admission.AggregatingSanitizer) AbstractModule(com.google.inject.AbstractModule)

Aggregations

Stopwatch (com.google.common.base.Stopwatch)1 AbstractModule (com.google.inject.AbstractModule)1 TypeLiteral (com.google.inject.TypeLiteral)1 ArchaiusModule (com.netflix.archaius.guice.ArchaiusModule)1 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)1 JobStore (com.netflix.titus.api.jobmanager.store.JobStore)1 TitusValidatorConfiguration (com.netflix.titus.common.model.admission.TitusValidatorConfiguration)1 TitusGatewayModule (com.netflix.titus.gateway.startup.TitusGatewayModule)1 AggregatingSanitizer (com.netflix.titus.runtime.endpoint.admission.AggregatingSanitizer)1