Search in sources :

Example 1 with TimeLockAgent

use of com.palantir.timelock.paxos.TimeLockAgent in project atlasdb by palantir.

the class TimelockBenchmarkServerLauncher method run.

@Override
public void run(TimelockBenchmarkServerConfig configuration, Environment environment) throws Exception {
    FeignOkHttpClients.globalClientSettings = client -> client.hostnameVerifier((ig, nored) -> true);
    TimeLockAgent agent = TimeLockAgent.create(configuration.install(), // this won't actually live reload
    configuration::runtime, ImmutableTimeLockDeprecatedConfiguration.builder().build(), environment.jersey()::register);
}
Also used : Environment(io.dropwizard.setup.Environment) ImmutableTimeLockDeprecatedConfiguration(com.palantir.timelock.config.ImmutableTimeLockDeprecatedConfiguration) Application(io.dropwizard.Application) MetricRegistry(com.codahale.metrics.MetricRegistry) Bootstrap(io.dropwizard.setup.Bootstrap) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) TimeLockAgent(com.palantir.timelock.paxos.TimeLockAgent) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) FeignOkHttpClients(com.palantir.atlasdb.http.FeignOkHttpClients) MetricRegistries(com.palantir.tritium.metrics.MetricRegistries) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) TimelockBenchmarkServerConfig(com.palantir.atlasdb.timelock.benchmarks.server.config.TimelockBenchmarkServerConfig) NonBlockingFileAppenderFactory(com.palantir.atlasdb.timelock.logging.NonBlockingFileAppenderFactory) TimeLockAgent(com.palantir.timelock.paxos.TimeLockAgent)

Example 2 with TimeLockAgent

use of com.palantir.timelock.paxos.TimeLockAgent 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 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)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 SharedMetricRegistries (com.codahale.metrics.SharedMetricRegistries)1 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 FeignOkHttpClients (com.palantir.atlasdb.http.FeignOkHttpClients)1 TimelockBenchmarkServerConfig (com.palantir.atlasdb.timelock.benchmarks.server.config.TimelockBenchmarkServerConfig)1 CombinedTimeLockServerConfiguration (com.palantir.atlasdb.timelock.config.CombinedTimeLockServerConfiguration)1 AtlasDbMetrics (com.palantir.atlasdb.util.AtlasDbMetrics)1 MetricsManager (com.palantir.atlasdb.util.MetricsManager)1 MetricsManagers (com.palantir.atlasdb.util.MetricsManagers)1