Search in sources :

Example 1 with TimeLockRuntimeConfiguration

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

the class TimeLockConfigMigrator method convert.

public static CombinedTimeLockServerConfiguration convert(TimeLockServerConfiguration config, Environment environment) {
    // taking advantage of the fact that there is only one algorithm impl at the moment
    Preconditions.checkArgument(PaxosConfiguration.class.isInstance(config.algorithm()), "Paxos is the only leader election algorithm currently supported. Not: %s", config.algorithm().getClass());
    PaxosConfiguration paxos = (PaxosConfiguration) config.algorithm();
    TimeLockInstallConfiguration install = ImmutableTimeLockInstallConfiguration.builder().timestampBoundPersistence(config.getTsBoundPersisterConfiguration()).paxos(ImmutablePaxosInstallConfiguration.builder().dataDirectory(paxos.paxosDataDir()).build()).cluster(ImmutableDefaultClusterConfiguration.builder().cluster(PartialServiceConfiguration.builder().security(paxos.sslConfiguration()).uris(config.cluster().servers()).build()).localServer(config.cluster().localServer()).build()).asyncLock(config.asyncLockConfiguration()).build();
    TimeLockRuntimeConfiguration runtime = ImmutableTimeLockRuntimeConfiguration.builder().paxos(ImmutablePaxosRuntimeConfiguration.builder().leaderPingResponseWaitMs(paxos.leaderPingResponseWaitMs()).maximumWaitBeforeProposalMs(paxos.maximumWaitBeforeProposalMs()).pingRateMs(paxos.pingRateMs()).build()).slowLockLogTriggerMillis(config.slowLockLogTriggerMillis()).build();
    TimeLockDeprecatedConfiguration deprecated = createDeprecatedConfiguration(config, environment);
    return ImmutableCombinedTimeLockServerConfiguration.builder().install(install).runtime(runtime).deprecated(deprecated).build();
}
Also used : TimeLockInstallConfiguration(com.palantir.timelock.config.TimeLockInstallConfiguration) ImmutableTimeLockInstallConfiguration(com.palantir.timelock.config.ImmutableTimeLockInstallConfiguration) ImmutableTimeLockDeprecatedConfiguration(com.palantir.timelock.config.ImmutableTimeLockDeprecatedConfiguration) TimeLockDeprecatedConfiguration(com.palantir.timelock.config.TimeLockDeprecatedConfiguration) TimeLockRuntimeConfiguration(com.palantir.timelock.config.TimeLockRuntimeConfiguration) ImmutableTimeLockRuntimeConfiguration(com.palantir.timelock.config.ImmutableTimeLockRuntimeConfiguration)

Example 2 with TimeLockRuntimeConfiguration

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

the class LockCreator method createThreadPoolingLockService.

public CloseableLockService createThreadPoolingLockService() {
    // TODO (jkong): Live reload slow lock timeout, plus clients (issue #2342)
    // TODO (?????): Rewrite ThreadPooled to cope with live reload, and/or remove ThreadPooled (if using Async)
    TimeLockRuntimeConfiguration timeLockRuntimeConfiguration = runtime.get();
    CloseableLockService lockServiceNotUsingThreadPooling = createTimeLimitedLockService(timeLockRuntimeConfiguration.slowLockLogTriggerMillis());
    if (!deprecated.useClientRequestLimit()) {
        return lockServiceNotUsingThreadPooling;
    }
    int availableThreads = deprecated.availableThreads();
    // TODO(nziebart): Since the number of clients can grow dynamically, we can't compute a correct and useful
    // value for the local threadpool size at this point. Given that async lock service exists, and doesn't need
    // a thread pool, it's likely we won't fix this and will eventually remove the thread pooled lock service.
    // However, for the time being, it's still useful to have global limiting for services that need to use the
    // legacy lock service.
    int localThreadPoolSize = -1;
    int sharedThreadPoolSize = availableThreads;
    synchronized (this) {
        if (sharedThreadPool.availablePermits() == -1) {
            sharedThreadPool.release(sharedThreadPoolSize + 1);
        }
    }
    return new ThreadPooledLockService(lockServiceNotUsingThreadPooling, localThreadPoolSize, sharedThreadPool);
}
Also used : CloseableLockService(com.palantir.lock.CloseableLockService) ThreadPooledLockService(com.palantir.lock.impl.ThreadPooledLockService) TimeLockRuntimeConfiguration(com.palantir.timelock.config.TimeLockRuntimeConfiguration)

Example 3 with TimeLockRuntimeConfiguration

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

the class TimeLockAgent method createAndRegisterResources.

private void createAndRegisterResources() {
    registerPaxosResource();
    registerExceptionMappers();
    leadershipCreator.registerLeaderElectionService();
    // Finally, register the health check, and endpoints associated with the clients.
    healthCheckSupplier = leadershipCreator.getHealthCheck();
    resource = new TimeLockResource(this::createInvalidatingTimeLockServices, JavaSuppliers.compose(TimeLockRuntimeConfiguration::maxNumberOfClients, runtime));
    registrar.accept(resource);
    ClockSkewMonitorCreator.create(install, registrar).registerClockServices();
}
Also used : TimeLockRuntimeConfiguration(com.palantir.timelock.config.TimeLockRuntimeConfiguration) TimeLockResource(com.palantir.atlasdb.timelock.TimeLockResource)

Aggregations

TimeLockRuntimeConfiguration (com.palantir.timelock.config.TimeLockRuntimeConfiguration)3 TimeLockResource (com.palantir.atlasdb.timelock.TimeLockResource)1 CloseableLockService (com.palantir.lock.CloseableLockService)1 ThreadPooledLockService (com.palantir.lock.impl.ThreadPooledLockService)1 ImmutableTimeLockDeprecatedConfiguration (com.palantir.timelock.config.ImmutableTimeLockDeprecatedConfiguration)1 ImmutableTimeLockInstallConfiguration (com.palantir.timelock.config.ImmutableTimeLockInstallConfiguration)1 ImmutableTimeLockRuntimeConfiguration (com.palantir.timelock.config.ImmutableTimeLockRuntimeConfiguration)1 TimeLockDeprecatedConfiguration (com.palantir.timelock.config.TimeLockDeprecatedConfiguration)1 TimeLockInstallConfiguration (com.palantir.timelock.config.TimeLockInstallConfiguration)1