use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class ReplicatedMapTest method testDestroy.
@Test
public void testDestroy() throws Exception {
HazelcastInstance instance = createHazelcastInstance();
ReplicatedMap<Object, Object> replicatedMap = instance.getReplicatedMap(randomName());
replicatedMap.put(1, 1);
replicatedMap.destroy();
Collection<DistributedObject> objects = instance.getDistributedObjects();
assertEquals(0, objects.size());
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class HazelcastOSGiInstanceTest method getDistributedObjectCalledSuccessfullyOverOSGiInstance.
@Test
public void getDistributedObjectCalledSuccessfullyOverOSGiInstance() {
DistributedObject mockDistributedObject = mock(DistributedObject.class);
HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
HazelcastOSGiInstance hazelcastOSGiInstance = HazelcastOSGiTestUtil.createHazelcastOSGiInstance(mockHazelcastInstance);
when(mockHazelcastInstance.getDistributedObject("my-service", "my-name")).thenReturn(mockDistributedObject);
assertEquals(mockDistributedObject, hazelcastOSGiInstance.getDistributedObject("my-service", "my-name"));
verify(mockHazelcastInstance).getDistributedObject("my-service", "my-name");
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class MapPartitionAwareService method onPartitionLost.
@Override
public void onPartitionLost(IPartitionLostEvent partitionLostEvent) {
final Address thisAddress = nodeEngine.getThisAddress();
final int partitionId = partitionLostEvent.getPartitionId();
Collection<DistributedObject> result = proxyService.getDistributedObjects(MapService.SERVICE_NAME);
for (DistributedObject object : result) {
final MapProxyImpl mapProxy = (MapProxyImpl) object;
final String mapName = mapProxy.getName();
if (mapProxy.getTotalBackupCount() <= partitionLostEvent.getLostReplicaIndex()) {
mapServiceContext.getMapEventPublisher().publishMapPartitionLostEvent(thisAddress, mapName, partitionId);
}
}
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class ClientMapPartitionLostListenerTest method assertProxyExistsEventually.
private void assertProxyExistsEventually(HazelcastInstance instance, final String proxyName) {
final InternalProxyService proxyService = getNodeEngineImpl(instance).getProxyService();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
Collection<DistributedObject> allDistributedObjects = proxyService.getAllDistributedObjects();
for (DistributedObject distributedObject : allDistributedObjects) {
if (distributedObject.getName().equals(proxyName)) {
return;
}
}
fail("There is no proxy with name " + proxyName + " created (yet)");
}
});
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class ProxyRegistry method destroyProxy.
/**
* Destroys a proxy.
*
* @param name The name of the proxy to destroy.
* @param publishEvent true if this destroy should be published.
*/
void destroyProxy(String name, boolean publishEvent) {
final DistributedObjectFuture proxyFuture = proxies.remove(name);
if (proxyFuture == null) {
return;
}
DistributedObject proxy;
try {
proxy = proxyFuture.get();
} catch (Throwable t) {
proxyService.logger.warning("Cannot destroy proxy [" + serviceName + ":" + name + "], since its creation is failed with " + t.getClass().getName() + ": " + t.getMessage());
return;
}
InternalEventService eventService = proxyService.nodeEngine.getEventService();
ProxyEventProcessor callback = new ProxyEventProcessor(proxyService.listeners.values(), DESTROYED, serviceName, name, proxy);
eventService.executeEventCallback(callback);
if (publishEvent) {
publish(new DistributedObjectEventPacket(DESTROYED, serviceName, name));
}
}
Aggregations