Search in sources :

Example 1 with ManagedTimestampService

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);
}
Also used : LockService(com.palantir.lock.LockService) ManagedTimestampService(com.palantir.atlasdb.timelock.paxos.ManagedTimestampService) ImmutableLeaderConfig(com.palantir.atlasdb.config.ImmutableLeaderConfig)

Example 2 with ManagedTimestampService

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);
}
Also used : ServiceDiscoveringAtlasSupplier(com.palantir.atlasdb.factory.ServiceDiscoveringAtlasSupplier) TimestampManagementService(com.palantir.timestamp.TimestampManagementService) DelegatingManagedTimestampService(com.palantir.atlasdb.timelock.paxos.DelegatingManagedTimestampService) ManagedTimestampService(com.palantir.atlasdb.timelock.paxos.ManagedTimestampService) TimestampService(com.palantir.timestamp.TimestampService) DelegatingManagedTimestampService(com.palantir.atlasdb.timelock.paxos.DelegatingManagedTimestampService)

Example 3 with ManagedTimestampService

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);
}
Also used : LockService(com.palantir.lock.LockService) LegacyTimelockService(com.palantir.lock.impl.LegacyTimelockService) TimelockService(com.palantir.lock.v2.TimelockService) AsyncOrLegacyTimelockService(com.palantir.atlasdb.timelock.util.AsyncOrLegacyTimelockService) ManagedTimestampService(com.palantir.atlasdb.timelock.paxos.ManagedTimestampService)

Example 4 with ManagedTimestampService

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());
}
Also used : AsyncLockService(com.palantir.atlasdb.timelock.lock.AsyncLockService) ManagedTimestampService(com.palantir.atlasdb.timelock.paxos.ManagedTimestampService) Test(org.junit.Test)

Aggregations

ManagedTimestampService (com.palantir.atlasdb.timelock.paxos.ManagedTimestampService)4 LockService (com.palantir.lock.LockService)2 ImmutableLeaderConfig (com.palantir.atlasdb.config.ImmutableLeaderConfig)1 ServiceDiscoveringAtlasSupplier (com.palantir.atlasdb.factory.ServiceDiscoveringAtlasSupplier)1 AsyncLockService (com.palantir.atlasdb.timelock.lock.AsyncLockService)1 DelegatingManagedTimestampService (com.palantir.atlasdb.timelock.paxos.DelegatingManagedTimestampService)1 AsyncOrLegacyTimelockService (com.palantir.atlasdb.timelock.util.AsyncOrLegacyTimelockService)1 LegacyTimelockService (com.palantir.lock.impl.LegacyTimelockService)1 TimelockService (com.palantir.lock.v2.TimelockService)1 TimestampManagementService (com.palantir.timestamp.TimestampManagementService)1 TimestampService (com.palantir.timestamp.TimestampService)1 Test (org.junit.Test)1