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();
}
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);
}
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();
}
Aggregations