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