use of com.hazelcast.core.Cluster in project neo4j by neo4j.
the class HazelcastClientTest method shouldNotReconnectWhileHazelcastRemainsAvailable.
@Test
public void shouldNotReconnectWhileHazelcastRemainsAvailable() throws Throwable {
// given
HazelcastConnector connector = mock(HazelcastConnector.class);
OnDemandJobScheduler jobScheduler = new OnDemandJobScheduler();
HazelcastClient client = new HazelcastClient(connector, jobScheduler, NullLogProvider.getInstance(), config(), myself);
HazelcastInstance hazelcastInstance = mock(HazelcastInstance.class);
when(connector.connectToHazelcast()).thenReturn(hazelcastInstance);
when(hazelcastInstance.getAtomicReference(anyString())).thenReturn(mock(IAtomicReference.class));
when(hazelcastInstance.getSet(anyString())).thenReturn(new HazelcastSet());
when(hazelcastInstance.getMultiMap(anyString())).thenReturn(new HazelcastMultiMap());
when(hazelcastInstance.getExecutorService(anyString())).thenReturn(new StubExecutorService());
com.hazelcast.core.Cluster cluster = mock(Cluster.class);
when(hazelcastInstance.getCluster()).thenReturn(cluster);
Set<Member> members = asSet(makeMember(1), makeMember(2));
when(cluster.getMembers()).thenReturn(members);
// when
client.start();
jobScheduler.runJob();
CoreTopology topology;
for (int i = 0; i < 5; i++) {
topology = client.coreServers();
assertEquals(members.size(), topology.members().size());
}
// then
verify(connector, times(1)).connectToHazelcast();
}
use of com.hazelcast.core.Cluster in project hazelcast by hazelcast.
the class ChangeClusterStateRequest method writeResponse.
@Override
public void writeResponse(ManagementCenterService mcs, JsonObject out) throws Exception {
String resultString = "SUCCESS";
try {
Cluster cluster = mcs.getHazelcastInstance().getCluster();
cluster.changeClusterState(getClusterState(state));
} catch (Exception e) {
ILogger logger = mcs.getHazelcastInstance().node.nodeEngine.getLogger(getClass());
logger.warning("Cluster state can not be changed: ", e);
resultString = FAILURE + e.getMessage();
}
JsonObject result = new JsonObject().add("result", resultString);
out.add("result", result);
}
use of com.hazelcast.core.Cluster in project hazelcast by hazelcast.
the class ClusterMembershipTest method testRemoveMembershipListener.
@Test
public void testRemoveMembershipListener() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance hz1 = factory.newHazelcastInstance();
Cluster cluster = hz1.getCluster();
MembershipListener membershipListener = mock(MembershipListener.class);
String id = cluster.addMembershipListener(membershipListener);
boolean removed = cluster.removeMembershipListener(id);
assertTrue(removed);
// now we add a member
HazelcastInstance hz2 = factory.newHazelcastInstance();
// and verify that the listener isn't called.
verify(membershipListener, never()).memberAdded(any(MembershipEvent.class));
}
use of com.hazelcast.core.Cluster in project hazelcast by hazelcast.
the class ClusterMembershipTest method testRemoveMembershipListener_whenNonExistingRegistrationId.
@Test
public void testRemoveMembershipListener_whenNonExistingRegistrationId() {
HazelcastInstance hz = createHazelcastInstance();
Cluster cluster = hz.getCluster();
boolean result = cluster.removeMembershipListener("notexist");
assertFalse(result);
}
use of com.hazelcast.core.Cluster in project hazelcast by hazelcast.
the class ClientClusterProxyTest method removeMembershipListener.
@Test
public void removeMembershipListener() throws Exception {
Cluster cluster = client().getCluster();
String regId = cluster.addMembershipListener(new MembershipAdapter());
assertTrue(cluster.removeMembershipListener(regId));
}
Aggregations