use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class DistributedObjectTest method testInitialization_whenEachNodeExecutesPostJoinOperations.
@Test
public void testInitialization_whenEachNodeExecutesPostJoinOperations() {
int nodeCount = 4;
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
Config config = new Config();
config.getServicesConfig().addServiceConfig(new ServiceConfig().setImplementation(new TestInitializingObjectService()).setEnabled(true).setName(TestInitializingObjectService.NAME));
String serviceName = TestInitializingObjectService.NAME;
String objectName = "test-object";
HazelcastInstance[] instances = new HazelcastInstance[nodeCount];
for (int i = 0; i < instances.length; i++) {
instances[i] = factory.newHazelcastInstance(config);
instances[i].getDistributedObject(serviceName, objectName);
}
for (int i = 0; i < nodeCount; i++) {
Node node = TestUtil.getNode(instances[i]);
ProxyServiceImpl proxyService = (ProxyServiceImpl) node.nodeEngine.getProxyService();
Operation postJoinOperation = proxyService.getPostJoinOperation();
for (int j = 0; j < nodeCount; j++) {
if (i == j)
continue;
Node node2 = TestUtil.getNode(instances[j]);
node.nodeEngine.getOperationService().send(postJoinOperation, node2.address);
}
}
for (HazelcastInstance instance : instances) {
TestInitializingObject obj = instance.getDistributedObject(serviceName, objectName);
assertTrue(obj.init.get());
assertFalse(obj.error);
}
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class ClientListenersTest method testEntryMergeListener_withPortableNotRegisteredInNode.
@Test
public void testEntryMergeListener_withPortableNotRegisteredInNode() throws Exception {
final IMap<Object, Object> map = client.getMap(randomMapName());
final CountDownLatch latch = new CountDownLatch(1);
map.addEntryListener(new EntryMergedListener<Object, Object>() {
@Override
public void entryMerged(EntryEvent<Object, Object> event) {
latch.countDown();
}
}, true);
Node node = getNode(server);
NodeEngineImpl nodeEngine = node.nodeEngine;
OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();
SerializationService serializationService = getSerializationService(server);
Data key = serializationService.toData(1);
Data value = serializationService.toData(new ClientRegressionWithMockNetworkTest.SamplePortable(1));
EntryView entryView = EntryViews.createSimpleEntryView(key, value, Mockito.mock(Record.class));
MergeOperation op = new MergeOperation(map.getName(), key, entryView, new PassThroughMergePolicy());
int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
operationService.invokeOnPartition(MapService.SERVICE_NAME, op, partitionId);
assertOpenEventually(latch);
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class MasterClaimOperation method run.
@Override
public void run() {
final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
Node node = nodeEngine.getNode();
Joiner joiner = node.getJoiner();
final ILogger logger = node.getLogger(getClass().getName());
if (joiner instanceof TcpIpJoiner) {
TcpIpJoiner tcpIpJoiner = (TcpIpJoiner) joiner;
final Address endpoint = getCallerAddress();
final Address masterAddress = node.getMasterAddress();
approvedAsMaster = !tcpIpJoiner.isClaimingMaster() && !node.isMaster() && (masterAddress == null || masterAddress.equals(endpoint));
} else {
approvedAsMaster = false;
logger.warning("This node requires MulticastJoin strategy!");
}
if (logger.isFineEnabled()) {
logger.fine("Sending '" + approvedAsMaster + "' for master claim of node: " + getCallerAddress());
}
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class MemberInfoUpdateOperation method processPartitionState.
final void processPartitionState() {
if (partitionRuntimeState == null) {
return;
}
partitionRuntimeState.setEndpoint(getCallerAddress());
ClusterServiceImpl clusterService = getService();
Node node = clusterService.getNodeEngine().getNode();
node.partitionService.processPartitionRuntimeState(partitionRuntimeState);
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class MemberInfoUpdateOperation method checkLocalMemberUuid.
final void checkLocalMemberUuid() {
ClusterServiceImpl clusterService = getService();
NodeEngineImpl nodeEngine = clusterService.getNodeEngine();
Node node = nodeEngine.getNode();
if (!node.getThisUuid().equals(targetUuid)) {
String msg = "targetUuid: " + targetUuid + " is different than this node's uuid: " + node.getThisUuid();
throw new IllegalStateException(msg);
}
}
Aggregations