use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class MapFlushMessageTask method call.
@Override
protected Object call() throws Exception {
MapService mapService = getService(SERVICE_NAME);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
ProxyService proxyService = nodeEngine.getProxyService();
DistributedObject distributedObject = proxyService.getDistributedObject(SERVICE_NAME, parameters.name);
MapProxyImpl mapProxy = (MapProxyImpl) distributedObject;
mapProxy.flush();
return null;
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class MapLoadAllMessageTask method call.
@Override
protected Object call() {
final MapService mapService = getService(MapService.SERVICE_NAME);
final DistributedObject distributedObject = mapService.getMapServiceContext().getNodeEngine().getProxyService().getDistributedObject(MapService.SERVICE_NAME, parameters.name);
final MapProxyImpl mapProxy = (MapProxyImpl) distributedObject;
mapProxy.loadAll(parameters.replaceExistingValues);
return null;
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class HazelcastClientInstanceImpl method getDistributedObjects.
@Override
public Collection<DistributedObject> getDistributedObjects() {
try {
ClientMessage request = ClientGetDistributedObjectsCodec.encodeRequest();
final Future<ClientMessage> future = new ClientInvocation(this, request).invoke();
ClientMessage response = future.get();
ClientGetDistributedObjectsCodec.ResponseParameters resultParameters = ClientGetDistributedObjectsCodec.decodeResponse(response);
Collection<? extends DistributedObject> distributedObjects = proxyManager.getDistributedObjects();
Set<DistributedObjectInfo> localDistributedObjects = new HashSet<DistributedObjectInfo>();
for (DistributedObject localInfo : distributedObjects) {
localDistributedObjects.add(new DistributedObjectInfo(localInfo.getServiceName(), localInfo.getName()));
}
Collection<DistributedObjectInfo> newDistributedObjectInfo = resultParameters.response;
for (DistributedObjectInfo distributedObjectInfo : newDistributedObjectInfo) {
localDistributedObjects.remove(distributedObjectInfo);
getDistributedObject(distributedObjectInfo.getServiceName(), distributedObjectInfo.getName());
}
for (DistributedObjectInfo distributedObjectInfo : localDistributedObjects) {
proxyManager.removeProxy(distributedObjectInfo.getServiceName(), distributedObjectInfo.getName());
}
return (Collection<DistributedObject>) proxyManager.getDistributedObjects();
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class ProxyRegistry method getDistributedObjects.
/**
* Gets the DistributedObjects in this registry. The result is written into 'result'.
*
* @param result The DistributedObjects in this registry.
*/
public void getDistributedObjects(Collection<DistributedObject> result) {
Collection<DistributedObjectFuture> futures = proxies.values();
for (DistributedObjectFuture future : futures) {
try {
DistributedObject object = future.get();
result.add(object);
} catch (Throwable ignored) {
// ignore if proxy creation failed
EmptyStatement.ignore(ignored);
}
}
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class ProxyRegistry method doCreateProxy.
private DistributedObjectFuture doCreateProxy(String name, boolean publishEvent, boolean initialize, DistributedObjectFuture proxyFuture) {
DistributedObject proxy;
try {
proxy = service.createDistributedObject(name);
if (initialize && proxy instanceof InitializingObject) {
try {
((InitializingObject) proxy).initialize();
} catch (Exception e) {
// log and throw exception to be handled in outer catch block
proxyService.logger.warning("Error while initializing proxy: " + proxy, e);
throw e;
}
}
proxyFuture.set(proxy);
} catch (Throwable e) {
// proxy creation or initialization failed
// deregister future to avoid infinite hang on future.get()
proxyFuture.setError(e);
proxies.remove(name);
throw ExceptionUtil.rethrow(e);
}
InternalEventService eventService = proxyService.nodeEngine.getEventService();
ProxyEventProcessor callback = new ProxyEventProcessor(proxyService.listeners.values(), CREATED, serviceName, name, proxy);
eventService.executeEventCallback(callback);
if (publishEvent) {
publish(new DistributedObjectEventPacket(CREATED, serviceName, name));
}
return proxyFuture;
}
Aggregations