use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class ClusterServiceMemberListTest method verifyMembersFromDataMember.
private void verifyMembersFromDataMember(final HazelcastInstance instance) {
final Member localMember = getLocalMember(instance);
final ClusterService clusterService = getClusterService(instance);
final Collection<Member> liteMembers = clusterService.getMembers(LITE_MEMBER_SELECTOR);
final Collection<Member> dataMembers = clusterService.getMembers(DATA_MEMBER_SELECTOR);
assertContains(dataMembers, localMember);
assertNotContains(liteMembers, localMember);
final Collection<Member> dataMembersWithoutThis = clusterService.getMembers(MemberSelectors.and(DATA_MEMBER_SELECTOR, NON_LOCAL_MEMBER_SELECTOR));
assertNotContains(dataMembersWithoutThis, localMember);
final Collection<Member> liteMembersWithThis = clusterService.getMembers(MemberSelectors.or(LITE_MEMBER_SELECTOR, LOCAL_MEMBER_SELECTOR));
assertContains(liteMembersWithThis, localMember);
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class SplitBrainTest method when_minorityMasterBecomesMajorityMaster_then_jobKeepsRunning.
@Test
public void when_minorityMasterBecomesMajorityMaster_then_jobKeepsRunning() {
int firstSubClusterSize = 2;
int secondSubClusterSize = 1;
int clusterSize = firstSubClusterSize + secondSubClusterSize;
NoOutputSourceP.executionStarted = new CountDownLatch(secondSubClusterSize * PARALLELISM);
Job[] jobRef = new Job[1];
Consumer<HazelcastInstance[]> beforeSplit = instances -> {
MockPS processorSupplier = new MockPS(NoOutputSourceP::new, clusterSize);
DAG dag = new DAG().vertex(new Vertex("test", processorSupplier));
jobRef[0] = instances[2].getJet().newJob(dag);
assertOpenEventually(NoOutputSourceP.executionStarted);
};
Consumer<HazelcastInstance[]> afterMerge = instances -> {
assertEquals(clusterSize, instances.length);
logger.info("Shutting down 1st instance");
instances[0].shutdown();
logger.info("1st instance down, starting another instance");
createHazelcastInstance(createConfig());
logger.info("Shutting down 2nd instance");
instances[1].shutdown();
assertTrue(((ClusterService) instances[2].getCluster()).isMaster());
assertJobStatusEventually(jobRef[0], RUNNING, 10);
assertTrueAllTheTime(() -> assertEquals(RUNNING, jobRef[0].getStatus()), 5);
};
testSplitBrain(firstSubClusterSize, secondSubClusterSize, beforeSplit, null, afterMerge);
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class FlakeIdGeneratorProxyTest method initialize.
public void initialize(FlakeIdGeneratorConfig config) {
ILogger logger = mock(ILogger.class);
clusterService = mock(ClusterService.class);
NodeEngine nodeEngine = mock(NodeEngine.class);
FlakeIdGeneratorService service = mock(FlakeIdGeneratorService.class);
when(nodeEngine.getLogger(FlakeIdGeneratorProxy.class)).thenReturn(logger);
when(nodeEngine.isRunning()).thenReturn(true);
config.setName("foo");
when(nodeEngine.getConfig()).thenReturn(new Config().addFlakeIdGeneratorConfig(config));
when(nodeEngine.getClusterService()).thenReturn(clusterService);
Address address = null;
try {
address = new Address("127.0.0.1", 5701);
} catch (UnknownHostException e) {
// no-op
}
when(nodeEngine.getLocalMember()).thenReturn(new MemberImpl(address, MemberVersion.UNKNOWN, true, UUID.randomUUID()));
UUID source = nodeEngine.getLocalMember().getUuid();
gen = new FlakeIdGeneratorProxy("foo", nodeEngine, service, source);
}
Aggregations