use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class TransactionProxy method invoke.
private ClientMessage invoke(ClientMessage request) {
try {
final ClientInvocation clientInvocation = new ClientInvocation(client, request, connection);
final Future<ClientMessage> future = clientInvocation.invoke();
return future.get();
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientSmartListenerService method deregisterListener.
@Override
public boolean deregisterListener(final String userRegistrationId) {
Future<Boolean> future = registrationExecutor.submit(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
ClientRegistrationKey key = new ClientRegistrationKey(userRegistrationId);
Map<Connection, ClientEventRegistration> registrationMap = registrations.get(key);
if (registrationMap == null) {
return false;
}
boolean successful = true;
for (ClientEventRegistration registration : registrationMap.values()) {
Connection subscriber = registration.getSubscriber();
try {
ListenerMessageCodec listenerMessageCodec = registration.getCodec();
String serverRegistrationId = registration.getServerRegistrationId();
ClientMessage request = listenerMessageCodec.encodeRemoveRequest(serverRegistrationId);
new ClientInvocation(client, request, subscriber).invoke().get();
removeEventHandler(registration.getCallId());
registrationMap.remove(subscriber);
} catch (Exception e) {
successful = false;
logger.warning("Deregistration of listener with id " + userRegistrationId + " has failed to address " + subscriber.getEndPoint(), e);
}
}
if (successful) {
registrations.remove(key);
}
return successful;
}
});
try {
return future.get();
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientAddressCancellableDelegatingFuture method invokeCancelRequest.
private boolean invokeCancelRequest(boolean mayInterruptIfRunning) throws InterruptedException {
waitForRequestToBeSend();
ClientInvocation clientInvocation;
final HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) context.getHazelcastInstance();
ClientMessage request = ExecutorServiceCancelOnAddressCodec.encodeRequest(uuid, target, mayInterruptIfRunning);
clientInvocation = new ClientInvocation(client, request, target);
try {
ClientInvocationFuture f = clientInvocation.invoke();
return ExecutorServiceCancelOnAddressCodec.decodeResponse(f.get()).response;
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.spi.impl.ClientInvocation 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.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientInvokerWrapper method invoke.
@Override
public Object invoke(Object request) {
checkNotNull(request, "request cannot be null");
ClientInvocation invocation = new ClientInvocation(getClient(), (ClientMessage) request);
ClientInvocationFuture future = invocation.invoke();
try {
Object result = future.get();
return context.toObject(result);
} catch (Exception e) {
throw rethrow(e);
}
}
Aggregations