use of com.palantir.common.concurrent.CheckedRejectionExecutorService 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.common.concurrent.CheckedRejectionExecutorService in project atlasdb by palantir.
the class GetSuspectedLeaderWithUuidTests method functionForRemotes.
private GetSuspectedLeaderWithUuid functionForRemotes(ClientAwareLeaderPinger... remotes) {
Set<ClientAwareLeaderPinger> clientAwareLeaders = ImmutableSet.copyOf(remotes);
Set<LeaderPingerContext<BatchPingableLeader>> rpcClients = clientAwareLeaders.stream().map(ClientAwareLeaderPinger::underlyingRpcClient).collect(Collectors.toSet());
Map<LeaderPingerContext<BatchPingableLeader>, CheckedRejectionExecutorService> executors = Maps.toMap(ImmutableList.copyOf(rpcClients), $ -> new CheckedRejectionExecutorService(executorService));
return new GetSuspectedLeaderWithUuid(executors, clientAwareLeaders, LOCAL_UUID, Duration.ofSeconds(1));
}
use of com.palantir.common.concurrent.CheckedRejectionExecutorService in project atlasdb by palantir.
the class TestableTimelockCluster method currentLeaders.
SetMultimap<String, TestableTimelockServer> currentLeaders(Iterable<String> namespaces) {
Set<String> namespacesIterable = ImmutableSet.copyOf(namespaces);
KeyedStream<TestableTimelockServer, PaxosContainer<Set<String>>> responses = PaxosQuorumChecker.collectUntil(ImmutableList.copyOf(servers), server -> PaxosContainer.of(server.pinger().ping(namespaces)), Maps.toMap(servers, unused -> new CheckedRejectionExecutorService(executorService)), Duration.ofSeconds(2), untilAllNamespacesAreSeen(namespacesIterable), true).stream();
return responses.filter(PaxosContainer::isSuccessful).map(PaxosContainer::get).flatMap(Collection::stream).mapEntries((server, namespace) -> Maps.immutableEntry(namespace, server)).collectToSetMultimap();
}
use of com.palantir.common.concurrent.CheckedRejectionExecutorService 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);
}
use of com.palantir.common.concurrent.CheckedRejectionExecutorService in project atlasdb by palantir.
the class TimeLockPaxosExecutors method createBoundedExecutors.
/**
* Creates a mapping of services to {@link ExecutorService}s indicating that tasks oriented towards the relevant
* node should be run on the associated executor.
*
* It is assumed that tasks run on the local node will return quickly (hence the use of the direct executor).
*/
static <T> Map<T, CheckedRejectionExecutorService> createBoundedExecutors(int poolSize, LocalAndRemotes<T> localAndRemotes, String useCase) {
int numRemotes = localAndRemotes.remotes().size();
ImmutableMap.Builder<T, CheckedRejectionExecutorService> remoteExecutors = ImmutableMap.builderWithExpectedSize(numRemotes);
for (int index = 0; index < numRemotes; index++) {
T remote = localAndRemotes.remotes().get(index);
remoteExecutors.put(remote, createBoundedExecutor(poolSize, useCase, index));
}
remoteExecutors.put(localAndRemotes.local(), new CheckedRejectionExecutorService(MoreExecutors.newDirectExecutorService()));
return remoteExecutors.build();
}
Aggregations