use of com.palantir.atlasdb.timelock.paxos.ManagedTimestampService in project atlasdb by palantir.
the class TimeLockAgent method createInvalidatingTimeLockServices.
/**
* Creates timestamp and lock services for the given client. It is expected that for each client there should
* only be (up to) one active timestamp service, and one active lock service at any time.
* @param client Client namespace to create the services for
* @return Invalidating timestamp and lock services
*/
private TimeLockServices createInvalidatingTimeLockServices(String client) {
List<String> uris = install.cluster().clusterMembers();
ImmutableLeaderConfig leaderConfig = ImmutableLeaderConfig.builder().addLeaders(uris.toArray(new String[uris.size()])).localServer(install.cluster().localServer()).sslConfiguration(PaxosRemotingUtils.getSslConfigurationOptional(install)).quorumSize(PaxosRemotingUtils.getQuorumSize(uris)).build();
Supplier<ManagedTimestampService> rawTimestampServiceSupplier = timestampCreator.createTimestampService(client, leaderConfig);
Supplier<LockService> rawLockServiceSupplier = lockCreator::createThreadPoolingLockService;
LockLog.setSlowLockThresholdMillis(JavaSuppliers.compose(TimeLockRuntimeConfiguration::slowLockLogTriggerMillis, runtime));
return timelockCreator.createTimeLockServices(client, rawTimestampServiceSupplier, rawLockServiceSupplier);
}
use of com.palantir.atlasdb.timelock.paxos.ManagedTimestampService in project atlasdb by palantir.
the class DbBoundTimestampCreator method createTimestampService.
@Override
public Supplier<ManagedTimestampService> createTimestampService(String client, LeaderConfig leaderConfig) {
ServiceDiscoveringAtlasSupplier atlasFactory = new ServiceDiscoveringAtlasSupplier(kvsConfig, Optional.of(leaderConfig), Optional.empty(), Optional.of(AtlasDbConstants.TIMELOCK_TIMESTAMP_TABLE));
TimestampService timestampService = atlasFactory.getTimestampService();
Preconditions.checkArgument(TimestampManagementService.class.isInstance(timestampService), "The timestamp service is not a managed timestamp service.");
return () -> new DelegatingManagedTimestampService(timestampService, (TimestampManagementService) timestampService);
}
use of com.palantir.atlasdb.timelock.paxos.ManagedTimestampService in project atlasdb by palantir.
the class LegacyTimeLockServicesCreator method createTimeLockServices.
@Override
public TimeLockServices createTimeLockServices(String client, Supplier<ManagedTimestampService> rawTimestampServiceSupplier, Supplier<LockService> rawLockServiceSupplier) {
log.info("Creating legacy timelock service for client {}", client);
ManagedTimestampService timestampService = instrumentInLeadershipProxy(ManagedTimestampService.class, rawTimestampServiceSupplier, client);
LockService lockService = instrumentInLeadershipProxy(LockService.class, rawLockServiceSupplier, client);
// The underlying primitives are already wrapped in a leadership proxy (and must be).
// Wrapping this means that we will make 2 paxos checks per request, which is silly.
TimelockService legacyTimelockService = instrument(TimelockService.class, createRawLegacyTimelockService(timestampService, lockService), client);
return TimeLockServices.create(timestampService, lockService, AsyncOrLegacyTimelockService.createFromLegacyTimelock(legacyTimelockService), timestampService);
}
use of com.palantir.atlasdb.timelock.paxos.ManagedTimestampService in project atlasdb by palantir.
the class AsyncTimelockServiceImplTest method delegatesInitializationCheck.
@Test
public void delegatesInitializationCheck() {
ManagedTimestampService mockMts = mock(ManagedTimestampService.class);
AsyncTimelockServiceImpl service = new AsyncTimelockServiceImpl(mock(AsyncLockService.class), mockMts);
when(mockMts.isInitialized()).thenReturn(false).thenReturn(true);
assertFalse(service.isInitialized());
assertTrue(service.isInitialized());
}
Aggregations