use of com.hazelcast.cluster.MemberSelector in project sonarqube by SonarSource.
the class HazelcastMemberSelectorsTest method selecting_web_and_app_nodes.
@Test
public void selecting_web_and_app_nodes() {
Member member = mock(Member.class);
MemberSelector underTest = HazelcastMemberSelectors.selectorForProcessIds(WEB_SERVER, APP);
when(member.getAttribute(PROCESS_KEY.getKey())).thenReturn(COMPUTE_ENGINE.getKey());
assertThat(underTest.select(member)).isFalse();
when(member.getAttribute(PROCESS_KEY.getKey())).thenReturn(WEB_SERVER.getKey());
assertThat(underTest.select(member)).isTrue();
when(member.getAttribute(PROCESS_KEY.getKey())).thenReturn(APP.getKey());
assertThat(underTest.select(member)).isTrue();
}
use of com.hazelcast.cluster.MemberSelector in project sonarqube by SonarSource.
the class HazelcastMemberSelectorsTest method selecting_ce_nodes.
@Test
public void selecting_ce_nodes() {
Member member = mock(Member.class);
MemberSelector underTest = HazelcastMemberSelectors.selectorForProcessIds(COMPUTE_ENGINE);
when(member.getAttribute(PROCESS_KEY.getKey())).thenReturn(COMPUTE_ENGINE.getKey());
assertThat(underTest.select(member)).isTrue();
when(member.getAttribute(PROCESS_KEY.getKey())).thenReturn(WEB_SERVER.getKey());
assertThat(underTest.select(member)).isFalse();
when(member.getAttribute(PROCESS_KEY.getKey())).thenReturn(APP.getKey());
assertThat(underTest.select(member)).isFalse();
}
use of com.hazelcast.cluster.MemberSelector in project sonarqube by SonarSource.
the class AppNodesInfoLoaderImpl method load.
public Collection<NodeInfo> load() throws InterruptedException {
Map<String, NodeInfo> nodesByName = new HashMap<>();
MemberSelector memberSelector = HazelcastMemberSelectors.selectorForProcessIds(ProcessId.WEB_SERVER, ProcessId.COMPUTE_ENGINE);
DistributedAnswer<ProtobufSystemInfo.SystemInfo> distributedAnswer = hzMember.call(ProcessInfoProvider::provide, memberSelector, DISTRIBUTED_TIMEOUT_MS);
for (Member member : distributedAnswer.getMembers()) {
String nodeName = member.getAttribute(NODE_NAME.getKey());
NodeInfo nodeInfo = nodesByName.computeIfAbsent(nodeName, name -> {
NodeInfo info = new NodeInfo(name);
info.setHost(member.getAddress().getHost());
return info;
});
completeNodeInfo(distributedAnswer, member, nodeInfo);
}
return nodesByName.values();
}
use of com.hazelcast.cluster.MemberSelector in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnableToMembers_withExecutionCallback.
@Test
public void submitRunnableToMembers_withExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
final CountDownLatch completeLatch = new CountDownLatch(1);
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
MemberSelector selector = new SelectAllMembers();
service.submitToMembers(runnable, selector, new MultiExecutionCallback() {
public void onResponse(Member member, Object value) {
responseLatch.countDown();
}
public void onComplete(Map<Member, Object> values) {
completeLatch.countDown();
}
});
IMap map = client.getMap(mapName);
assertOpenEventually("responseLatch", responseLatch);
assertOpenEventually("completeLatch", completeLatch);
assertEquals(CLUSTER_SIZE, map.size());
}
use of com.hazelcast.cluster.MemberSelector in project hazelcast by hazelcast.
the class ClientExecutorServiceExecuteTest method testExecuteOnMembers_whenSelectorNull.
@Test(expected = NullPointerException.class)
public void testExecuteOnMembers_whenSelectorNull() {
IExecutorService service = client.getExecutorService(randomString());
MemberSelector selector = null;
service.executeOnMembers(new MapPutRunnable("task"), selector);
}
Aggregations