use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class InvocationFuture_GetNewInstanceTest method invocationToRemoteMember.
@Test
public void invocationToRemoteMember() throws ExecutionException, InterruptedException {
Node localNode = getNode(local);
Data response = localNode.nodeEngine.toData(new DummyObject());
Operation op = new OperationWithResponse(response);
Address remoteAddress = getAddress(remote);
OperationService operationService = getOperationService(local);
Future future = operationService.createInvocationBuilder(null, op, remoteAddress).invoke();
Object instance1 = future.get();
Object instance2 = future.get();
assertNotNull(instance1);
assertNotNull(instance2);
assertTrue(instance1 instanceof DummyObject);
assertTrue(instance2 instanceof DummyObject);
assertNotSame(instance1, instance2);
assertNotSame(instance1, response);
assertNotSame(instance2, response);
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class InvocationFuture_GetNewInstanceTest method invocationToLocalMember.
@Test
public void invocationToLocalMember() throws ExecutionException, InterruptedException {
Node localNode = getNode(local);
Data response = localNode.nodeEngine.toData(new DummyObject());
Operation op = new OperationWithResponse(response);
OperationService service = getOperationService(local);
Future future = service.createInvocationBuilder(null, op, localNode.address).invoke();
Object instance1 = future.get();
Object instance2 = future.get();
assertNotNull(instance1);
assertNotNull(instance2);
assertTrue(instance1 instanceof DummyObject);
assertTrue(instance2 instanceof DummyObject);
assertNotSame(instance1, instance2);
assertNotSame(instance1, response);
assertNotSame(instance2, response);
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class MapTransactionTest method testGetForUpdate_releasesBackupLock.
@Test
public void testGetForUpdate_releasesBackupLock() {
Config config = getConfig();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance(config);
HazelcastInstance instance2 = factory.newHazelcastInstance(config);
final String keyOwnedByInstance2 = generateKeyOwnedBy(instance2);
instance1.executeTransaction(new TransactionalTask<Object>() {
@Override
public Object execute(TransactionalTaskContext context) throws TransactionException {
TransactionalMap<Object, Object> map = context.getMap(randomString());
map.getForUpdate(keyOwnedByInstance2);
return null;
}
});
Node node = TestUtil.getNode(instance1);
Data keyData = node.nodeEngine.toData(keyOwnedByInstance2);
LockService lockService = node.nodeEngine.getService(LockService.SERVICE_NAME);
for (LockResource lockResource : lockService.getAllLocks()) {
if (keyData.equals(lockResource.getKey())) {
assertEquals(0, lockResource.getLockCount());
}
}
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class IndexIntegrationTest method getIndexOfAttributeForMap.
private static Index getIndexOfAttributeForMap(HazelcastInstance instance, String mapName, String attribute) {
Node node = getNode(instance);
MapService service = node.nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext mapServiceContext = service.getMapServiceContext();
MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
Indexes indexes = mapContainer.getIndexes();
return indexes.getIndex(attribute);
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class DiscoverySpiTest method testSPIAwareMemberGroupFactoryCreateMemberGroups.
@Test
public void testSPIAwareMemberGroupFactoryCreateMemberGroups() throws Exception {
String xmlFileName = "test-hazelcast-discovery-spi-metadata.xml";
Config config = getDiscoverySPIConfig(xmlFileName);
// we create this instance in order to fully create Node
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
Node node = TestUtil.getNode(hazelcastInstance);
assertNotNull(node);
MemberGroupFactory groupFactory = new SPIAwareMemberGroupFactory(node.getDiscoveryService());
Collection<Member> members = createMembers();
Collection<MemberGroup> memberGroups = groupFactory.createMemberGroups(members);
assertEquals("Member Groups: " + String.valueOf(memberGroups), 2, memberGroups.size());
for (MemberGroup memberGroup : memberGroups) {
assertEquals("Member Group: " + String.valueOf(memberGroup), 2, memberGroup.size());
}
hazelcastInstance.shutdown();
}
Aggregations