use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method assertNoOfDistributedObject.
private void assertNoOfDistributedObject(String message, int expected, Collection<DistributedObject> distributedObjects) {
StringBuilder sb = new StringBuilder(message + "\n");
for (DistributedObject distributedObject : distributedObjects) {
sb.append("Name: ").append(distributedObject.getName()).append(", Service: ").append(distributedObject.getServiceName()).append(", PartitionKey: ").append(distributedObject.getPartitionKey()).append("\n");
}
assertEqualsStringFormat(sb.toString(), expected, distributedObjects.size());
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testGetDistributedObjectsIssue678.
@Test
public void testGetDistributedObjectsIssue678() {
final HazelcastInstance hz = hazelcastFactory.newHazelcastInstance();
hz.getQueue("queue");
hz.getMap("map");
hz.getSemaphore("s");
final HazelcastInstance instance = hazelcastFactory.newHazelcastClient();
final Collection<DistributedObject> distributedObjects = instance.getDistributedObjects();
assertEquals(3, distributedObjects.size());
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class HazelcastCacheManager method getCacheNames.
@Override
public Collection<String> getCacheNames() {
Set<String> cacheNames = new HashSet<String>();
final Collection<DistributedObject> distributedObjects = hazelcastInstance.getDistributedObjects();
for (DistributedObject distributedObject : distributedObjects) {
if (distributedObject instanceof IMap) {
final IMap<?, ?> map = (IMap) distributedObject;
cacheNames.add(map.getName());
}
}
return cacheNames;
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class TestCacheManager method testCacheNames.
@Test
public void testCacheNames() {
// create a test instance, to reproduce the behavior described in the GitHub issue
// https://github.com/hazelcast/hazelcast/issues/492
final String testMap = "test-map";
final CountDownLatch distributionSignal = new CountDownLatch(1);
instance.addDistributedObjectListener(new DistributedObjectListener() {
@Override
public void distributedObjectCreated(DistributedObjectEvent event) {
DistributedObject distributedObject = event.getDistributedObject();
if (distributedObject instanceof IMap) {
IMap<?, ?> map = (IMap) distributedObject;
if (testMap.equals(map.getName())) {
distributionSignal.countDown();
}
}
}
@Override
public void distributedObjectDestroyed(DistributedObjectEvent event) {
}
});
HazelcastInstance testInstance = Hazelcast.newHazelcastInstance();
testInstance.getMap(testMap);
// be sure that test-map is distributed
HazelcastTestSupport.assertOpenEventually(distributionSignal);
Collection<String> test = cacheManager.getCacheNames();
assertContains(test, testMap);
testInstance.shutdown();
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class GetDistributedObjectsMessageTask method call.
@Override
protected Object call() throws Exception {
Collection<DistributedObject> distributedObjects = clientEngine.getProxyService().getAllDistributedObjects();
List<DistributedObjectInfo> coll = new ArrayList<DistributedObjectInfo>(distributedObjects.size());
for (DistributedObject distributedObject : distributedObjects) {
String name = DistributedObjectUtil.getName(distributedObject);
coll.add(new DistributedObjectInfo(distributedObject.getServiceName(), name));
}
return coll;
}
Aggregations