use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class MockJoiner method lookupJoinAddress.
private Address lookupJoinAddress() {
Node foundNode = findAliveNode();
if (foundNode == null) {
logger.fine("Picking this node as master, no other running node has been detected.");
return node.getThisAddress();
}
logger.fine("Found alive node. Will try to connect to " + foundNode.getThisAddress());
return foundNode.getThisAddress();
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class MockJoiner method findAliveNode.
private Node findAliveNode() {
Collection<Address> joinAddresses = registry.getJoinAddresses();
logger.fine("Searching possible addresses for master " + joinAddresses);
for (Address address : joinAddresses) {
Node foundNode = registry.getNode(address);
if (foundNode == null) {
logger.fine("Node for " + address + " is null.");
continue;
}
verifyInvariant(address.equals(foundNode.getThisAddress()), "The address should be equal to the one in the found node");
if (foundNode.getThisAddress().equals(node.getThisAddress())) {
continue;
}
if (!foundNode.isRunning()) {
logger.fine("Node for " + address + " is not running. -> " + foundNode.getState());
continue;
}
if (!foundNode.joined()) {
logger.fine("Node for " + address + " is not joined yet.");
continue;
}
if (isBlacklisted(address)) {
logger.fine("Node for " + address + " is blacklisted and should not be joined.");
continue;
}
logger.fine("Found an alive node. Will ask master of " + address);
return foundNode;
}
return null;
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class SplitBrainTestSupport method unblockCommunicationBetween.
public static void unblockCommunicationBetween(HazelcastInstance h1, HazelcastInstance h2) {
FirewallingMockConnectionManager h1CM = getFireWalledConnectionManager(h1);
FirewallingMockConnectionManager h2CM = getFireWalledConnectionManager(h2);
Node h1Node = getNode(h1);
Node h2Node = getNode(h2);
h1CM.unblock(h2Node.getThisAddress());
h2CM.unblock(h1Node.getThisAddress());
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class HazelcastTestSupport method closeConnectionBetween.
// ################################################
// ########## cluster and instance state ##########
// ################################################
public static void closeConnectionBetween(HazelcastInstance h1, HazelcastInstance h2) {
if (h1 == null || h2 == null) {
return;
}
Node n1 = TestUtil.getNode(h1);
Node n2 = TestUtil.getNode(h2);
if (n1 != null && n2 != null) {
n1.clusterService.removeAddress(n2.address, null);
n2.clusterService.removeAddress(n1.address, null);
}
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class ServiceManagerImpl method readServiceDescriptors.
private void readServiceDescriptors() {
Node node = nodeEngine.getNode();
try {
ClassLoader classLoader = node.getConfigClassLoader();
Iterator<Class<RemoteServiceDescriptorProvider>> iter = com.hazelcast.util.ServiceLoader.classIterator(PROVIDER_ID, classLoader);
while (iter.hasNext()) {
Class<RemoteServiceDescriptorProvider> clazz = iter.next();
Constructor<RemoteServiceDescriptorProvider> constructor = clazz.getDeclaredConstructor();
RemoteServiceDescriptorProvider provider = constructor.newInstance();
RemoteServiceDescriptor[] services = provider.createRemoteServiceDescriptors();
for (RemoteServiceDescriptor serviceDescriptor : services) {
registerService(serviceDescriptor.getServiceName(), serviceDescriptor.getService(nodeEngine));
}
}
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
}
Aggregations