Search in sources :

Example 1 with DistributedObjectInfo

use of com.hazelcast.client.impl.client.DistributedObjectInfo 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;
}
Also used : DistributedObject(com.hazelcast.core.DistributedObject) ArrayList(java.util.ArrayList) DistributedObjectInfo(com.hazelcast.client.impl.client.DistributedObjectInfo)

Example 2 with DistributedObjectInfo

use of com.hazelcast.client.impl.client.DistributedObjectInfo 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);
    }
}
Also used : DistributedObject(com.hazelcast.core.DistributedObject) ClientInvocation(com.hazelcast.client.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) TransactionException(com.hazelcast.transaction.TransactionException) DistributedObjectInfo(com.hazelcast.client.impl.client.DistributedObjectInfo) Collection(java.util.Collection) ClientGetDistributedObjectsCodec(com.hazelcast.client.impl.protocol.codec.ClientGetDistributedObjectsCodec) HashSet(java.util.HashSet)

Aggregations

DistributedObjectInfo (com.hazelcast.client.impl.client.DistributedObjectInfo)2 DistributedObject (com.hazelcast.core.DistributedObject)2 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 ClientGetDistributedObjectsCodec (com.hazelcast.client.impl.protocol.codec.ClientGetDistributedObjectsCodec)1 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)1 TransactionException (com.hazelcast.transaction.TransactionException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1