use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientNonSmartListenerService method invoke.
private ClientEventRegistration invoke(ClientRegistrationKey registrationKey) throws Exception {
EventHandler handler = registrationKey.getHandler();
handler.beforeListenerRegister();
ClientMessage request = registrationKey.getCodec().encodeAddRequest(false);
ClientInvocation invocation = new ClientInvocation(client, request);
invocation.setEventHandler(handler);
ClientInvocationFuture future = invocation.invoke();
String registrationId = registrationKey.getCodec().decodeAddResponse(future.get());
handler.onListenerRegister();
Connection connection = future.getInvocation().getSendConnection();
return new ClientEventRegistration(registrationId, request.getCorrelationId(), connection, registrationKey.getCodec());
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientSmartListenerService method invoke.
private void invoke(ClientRegistrationKey registrationKey, Connection connection) throws Exception {
//This method should only be called from registrationExecutor
assert (Thread.currentThread().getName().contains("eventRegistration"));
Map<Connection, ClientEventRegistration> registrationMap = registrations.get(registrationKey);
if (registrationMap.containsKey(connection)) {
return;
}
ListenerMessageCodec codec = registrationKey.getCodec();
ClientMessage request = codec.encodeAddRequest(true);
EventHandler handler = registrationKey.getHandler();
handler.beforeListenerRegister();
ClientInvocation invocation = new ClientInvocation(client, request, connection);
invocation.setEventHandler(handler);
ClientInvocationFuture future = invocation.invokeUrgent();
ClientMessage clientMessage;
try {
clientMessage = future.get();
} catch (Exception e) {
throw ExceptionUtil.rethrow(e, Exception.class);
}
String serverRegistrationId = codec.decodeAddResponse(clientMessage);
handler.onListenerRegister();
long correlationId = request.getCorrelationId();
ClientEventRegistration registration = new ClientEventRegistration(serverRegistrationId, correlationId, connection, codec);
registrationMap.put(connection, registration);
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class XATransactionProxy 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 ExceptionUtil.rethrow(e);
}
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientProxy method destroy.
@Override
public final void destroy() {
if (preDestroy()) {
onDestroy();
ClientMessage clientMessage = ClientDestroyProxyCodec.encodeRequest(getDistributedObjectName(), getServiceName());
context.removeProxy(this);
try {
new ClientInvocation(getClient(), clientMessage).invoke().get();
postDestroy();
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
}
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ProxyManager method initialize.
private void initialize(ClientProxy clientProxy) throws Exception {
final Address initializationTarget = findNextAddressToSendCreateRequest();
final Connection connection = getTargetOrOwnerConnection(initializationTarget);
final ClientMessage clientMessage = ClientCreateProxyCodec.encodeRequest(clientProxy.getDistributedObjectName(), clientProxy.getServiceName(), initializationTarget);
final ClientContext context = new ClientContext(client, this);
new ClientInvocation(client, clientMessage, connection).invoke().get();
clientProxy.setContext(context);
clientProxy.onInitialize();
}
Aggregations