Search in sources :

Example 1 with DisabledNamespacesUpdaterService

use of com.palantir.atlasdb.timelock.api.DisabledNamespacesUpdaterService in project atlasdb by palantir.

the class AllNodesDisabledNamespacesUpdaterTest method setUp.

@Before
public void setUp() {
    when(remote1.ping(AUTH_HEADER)).thenReturn(true);
    when(remote2.ping(AUTH_HEADER)).thenReturn(true);
    ImmutableList<DisabledNamespacesUpdaterService> remotes = ImmutableList.of(remote1, remote2);
    Map<DisabledNamespacesUpdaterService, CheckedRejectionExecutorService> executors = ImmutableMap.of(remote1, new CheckedRejectionExecutorService(Executors.newSingleThreadExecutor()), remote2, new CheckedRejectionExecutorService(Executors.newSingleThreadExecutor()));
    when(remote1.reenable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
    when(remote2.reenable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
    when(localUpdater.reEnable(any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
    updater = new AllNodesDisabledNamespacesUpdater(remotes, executors, localUpdater);
}
Also used : DisabledNamespacesUpdaterService(com.palantir.atlasdb.timelock.api.DisabledNamespacesUpdaterService) CheckedRejectionExecutorService(com.palantir.common.concurrent.CheckedRejectionExecutorService) Before(org.junit.Before)

Example 2 with DisabledNamespacesUpdaterService

use of com.palantir.atlasdb.timelock.api.DisabledNamespacesUpdaterService in project atlasdb by palantir.

the class AllNodesDisabledNamespacesUpdater method attemptOnAllNodes.

// Update and analysis
private AllNodesUpdateResponse attemptOnAllNodes(Set<Namespace> namespaces, String lockId, Function<DisabledNamespacesUpdaterService, SingleNodeUpdateResponse> update, Supplier<SingleNodeUpdateResponse> localUpdate, boolean alwaysAttemptOnLocalNode) {
    Map<DisabledNamespacesUpdaterService, SingleNodeUpdateResponse> remoteResponses = attemptOnAllRemoteNodes(update);
    SingleNodeUpdateResponse localResponse = updateLocallyOrCheckState(remoteResponses.values(), namespaces, lockId, localUpdate, alwaysAttemptOnLocalNode);
    return AllNodesUpdateResponse.builder().remoteResponses(remoteResponses).localResponse(localResponse).build();
}
Also used : DisabledNamespacesUpdaterService(com.palantir.atlasdb.timelock.api.DisabledNamespacesUpdaterService) SingleNodeUpdateResponse(com.palantir.atlasdb.timelock.api.SingleNodeUpdateResponse)

Example 3 with DisabledNamespacesUpdaterService

use of com.palantir.atlasdb.timelock.api.DisabledNamespacesUpdaterService in project atlasdb by palantir.

the class AllNodesDisabledNamespacesUpdaterFactory method create.

public AllNodesDisabledNamespacesUpdater create(TimelockNamespaces localNamespaces) {
    PaxosRemoteClients remoteClients = ImmutablePaxosRemoteClients.of(install, metricsManager);
    List<WithDedicatedExecutor<DisabledNamespacesUpdaterService>> remoteUpdaters = remoteClients.updaters();
    Map<DisabledNamespacesUpdaterService, CheckedRejectionExecutorService> remoteExecutors = ImmutableMap.<DisabledNamespacesUpdaterService, CheckedRejectionExecutorService>builder().putAll(KeyedStream.of(remoteUpdaters).mapKeys(WithDedicatedExecutor::service).map(WithDedicatedExecutor::executor).collectToMap()).build();
    ImmutableList<DisabledNamespacesUpdaterService> remoteServices = ImmutableList.copyOf(remoteUpdaters.stream().map(WithDedicatedExecutor::service).collect(Collectors.toList()));
    return AllNodesDisabledNamespacesUpdater.create(remoteServices, remoteExecutors, localNamespaces);
}
Also used : WithDedicatedExecutor(com.palantir.atlasdb.timelock.paxos.WithDedicatedExecutor) DisabledNamespacesUpdaterService(com.palantir.atlasdb.timelock.api.DisabledNamespacesUpdaterService) CheckedRejectionExecutorService(com.palantir.common.concurrent.CheckedRejectionExecutorService) PaxosRemoteClients(com.palantir.atlasdb.timelock.paxos.PaxosRemoteClients) ImmutablePaxosRemoteClients(com.palantir.atlasdb.timelock.paxos.ImmutablePaxosRemoteClients)

Aggregations

DisabledNamespacesUpdaterService (com.palantir.atlasdb.timelock.api.DisabledNamespacesUpdaterService)3 CheckedRejectionExecutorService (com.palantir.common.concurrent.CheckedRejectionExecutorService)2 SingleNodeUpdateResponse (com.palantir.atlasdb.timelock.api.SingleNodeUpdateResponse)1 ImmutablePaxosRemoteClients (com.palantir.atlasdb.timelock.paxos.ImmutablePaxosRemoteClients)1 PaxosRemoteClients (com.palantir.atlasdb.timelock.paxos.PaxosRemoteClients)1 WithDedicatedExecutor (com.palantir.atlasdb.timelock.paxos.WithDedicatedExecutor)1 Before (org.junit.Before)1