Search in sources :

Example 1 with CombinedTimeLockServerConfiguration

use of com.palantir.atlasdb.timelock.config.CombinedTimeLockServerConfiguration in project atlasdb by palantir.

the class TimeLockServerLauncher method run.

@Override
public void run(TimeLockServerConfiguration configuration, Environment environment) {
    environment.getObjectMapper().registerModule(new Jdk8Module());
    environment.jersey().register(HttpRemotingJerseyFeature.INSTANCE);
    CombinedTimeLockServerConfiguration combined = TimeLockConfigMigrator.convert(configuration, environment);
    Consumer<Object> registrar = component -> environment.jersey().register(component);
    TimeLockAgent.create(combined.install(), // this won't actually live reload
    combined::runtime, combined.deprecated(), registrar);
}
Also used : Environment(io.dropwizard.setup.Environment) Application(io.dropwizard.Application) MetricRegistry(com.codahale.metrics.MetricRegistry) Bootstrap(io.dropwizard.setup.Bootstrap) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) SharedMetricRegistries(com.codahale.metrics.SharedMetricRegistries) UUID(java.util.UUID) TimeLockAgent(com.palantir.timelock.paxos.TimeLockAgent) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) Consumer(java.util.function.Consumer) TimeLockServerConfiguration(com.palantir.atlasdb.timelock.config.TimeLockServerConfiguration) CombinedTimeLockServerConfiguration(com.palantir.atlasdb.timelock.config.CombinedTimeLockServerConfiguration) NonBlockingFileAppenderFactory(com.palantir.atlasdb.timelock.logging.NonBlockingFileAppenderFactory) HttpRemotingJerseyFeature(com.palantir.remoting3.servers.jersey.HttpRemotingJerseyFeature) TimeLockConfigMigrator(com.palantir.atlasdb.timelock.config.TimeLockConfigMigrator) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) CombinedTimeLockServerConfiguration(com.palantir.atlasdb.timelock.config.CombinedTimeLockServerConfiguration)

Example 2 with CombinedTimeLockServerConfiguration

use of com.palantir.atlasdb.timelock.config.CombinedTimeLockServerConfiguration in project atlasdb by palantir.

the class TimeLockServerLauncher method run.

@Override
public void run(CombinedTimeLockServerConfiguration configuration, Environment environment) throws JsonProcessingException {
    environment.getObjectMapper().registerModule(new Jdk8Module()).registerModule(new JavaTimeModule());
    environment.jersey().register(ConjureJerseyFeature.INSTANCE);
    environment.jersey().register(new EmptyOptionalTo204ExceptionMapper());
    MetricsManager metricsManager = MetricsManagers.of(environment.metrics(), taggedMetricRegistry);
    Consumer<Object> registrar = component -> environment.jersey().register(component);
    log.info("Paxos configuration\n{}", UnsafeArg.of("paxosConfig", environment.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(configuration.install().paxos())));
    TimeLockRuntimeConfiguration runtime = configuration.runtime();
    TimeLockAgent timeLockAgent = TimeLockAgent.create(metricsManager, configuration.install(), // this won't actually live reload
    Refreshable.only(runtime), runtime.clusterSnapshot(), USER_AGENT, CombinedTimeLockServerConfiguration.threadPoolSize(), CombinedTimeLockServerConfiguration.blockingTimeoutMs(), registrar, Optional.empty(), OrderableSlsVersion.valueOf("0.0.0"), environment.getObjectMapper(), () -> System.exit(0));
    environment.lifecycle().manage(new Managed() {

        @Override
        public void start() {
        }

        @Override
        public void stop() {
        }
    });
    environment.lifecycle().addLifeCycleListener(new LifeCycle.Listener() {

        @Override
        public void lifeCycleStarting(LifeCycle event) {
        }

        @Override
        public void lifeCycleStarted(LifeCycle event) {
        }

        @Override
        public void lifeCycleFailure(LifeCycle event, Throwable cause) {
            shutdownFuture.setException(cause);
        }

        @Override
        public void lifeCycleStopping(LifeCycle event) {
        }

        @Override
        public void lifeCycleStopped(LifeCycle event) {
            timeLockAgent.shutdown();
            shutdownFuture.set(null);
        }
    });
}
Also used : SafeLoggerFactory(com.palantir.logsafe.logger.SafeLoggerFactory) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Provider(javax.ws.rs.ext.Provider) LifeCycle(org.eclipse.jetty.util.component.LifeCycle) Bootstrap(io.dropwizard.setup.Bootstrap) ObjectMappers(com.palantir.conjure.java.serialization.ObjectMappers) ExceptionMapper(javax.ws.rs.ext.ExceptionMapper) TimeLockAgent(com.palantir.timelock.paxos.TimeLockAgent) SettableFuture(com.google.common.util.concurrent.SettableFuture) SafeLogger(com.palantir.logsafe.logger.SafeLogger) TimeLockRuntimeConfiguration(com.palantir.timelock.config.TimeLockRuntimeConfiguration) MetricsManager(com.palantir.atlasdb.util.MetricsManager) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) Refreshable(com.palantir.refreshable.Refreshable) Environment(io.dropwizard.setup.Environment) Application(io.dropwizard.Application) MetricRegistry(com.codahale.metrics.MetricRegistry) OrderableSlsVersion(com.palantir.sls.versions.OrderableSlsVersion) DiscoverableSubtypeResolver(io.dropwizard.jackson.DiscoverableSubtypeResolver) SharedMetricRegistries(com.codahale.metrics.SharedMetricRegistries) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) UUID(java.util.UUID) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) MetricsManagers(com.palantir.atlasdb.util.MetricsManagers) Consumer(java.util.function.Consumer) EmptyOptionalException(io.dropwizard.jersey.optional.EmptyOptionalException) Response(javax.ws.rs.core.Response) CombinedTimeLockServerConfiguration(com.palantir.atlasdb.timelock.config.CombinedTimeLockServerConfiguration) UnsafeArg(com.palantir.logsafe.UnsafeArg) NonBlockingFileAppenderFactory(com.palantir.atlasdb.timelock.logging.NonBlockingFileAppenderFactory) ConjureJerseyFeature(com.palantir.conjure.java.server.jersey.ConjureJerseyFeature) Managed(io.dropwizard.lifecycle.Managed) Optional(java.util.Optional) LifeCycle(org.eclipse.jetty.util.component.LifeCycle) TimeLockAgent(com.palantir.timelock.paxos.TimeLockAgent) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) TimeLockRuntimeConfiguration(com.palantir.timelock.config.TimeLockRuntimeConfiguration) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) MetricsManager(com.palantir.atlasdb.util.MetricsManager) Managed(io.dropwizard.lifecycle.Managed)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)2 SharedMetricRegistries (com.codahale.metrics.SharedMetricRegistries)2 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)2 CombinedTimeLockServerConfiguration (com.palantir.atlasdb.timelock.config.CombinedTimeLockServerConfiguration)2 NonBlockingFileAppenderFactory (com.palantir.atlasdb.timelock.logging.NonBlockingFileAppenderFactory)2 TimeLockAgent (com.palantir.timelock.paxos.TimeLockAgent)2 DefaultTaggedMetricRegistry (com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)2 TaggedMetricRegistry (com.palantir.tritium.metrics.registry.TaggedMetricRegistry)2 Application (io.dropwizard.Application)2 Bootstrap (io.dropwizard.setup.Bootstrap)2 Environment (io.dropwizard.setup.Environment)2 UUID (java.util.UUID)2 Consumer (java.util.function.Consumer)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 SettableFuture (com.google.common.util.concurrent.SettableFuture)1 TimeLockConfigMigrator (com.palantir.atlasdb.timelock.config.TimeLockConfigMigrator)1 TimeLockServerConfiguration (com.palantir.atlasdb.timelock.config.TimeLockServerConfiguration)1 AtlasDbMetrics (com.palantir.atlasdb.util.AtlasDbMetrics)1