ObjectNamespace objectNamespace = new DistributedObjectNamespace(proxy.getServiceName(), proxy.getDistributedObjectName()); ClientProxyFuture registeredProxyFuture = proxies.remove(objectNamespace); ClientProxy registeredProxy = registeredProxyFuture == null ? null : registeredProxyFuture.get(); if (registeredProxy != null) { try { registeredProxy.destroyLocally(); } finally { registeredProxy.destroyRemotely(); proxy.destroyLocally();
protected final HazelcastClientInstanceImpl getClient() { return (HazelcastClientInstanceImpl) getContext().getHazelcastInstance(); }
@Override public int hashCode() { int result = getInstanceName().hashCode(); result = 31 * result + serviceName.hashCode(); result = 31 * result + getDistributedObjectName().hashCode(); return result; }
protected <T> T invoke(ClientMessage clientMessage, Object key) { final int partitionId = getContext().getPartitionService().getPartitionId(key); return invokeOnPartition(clientMessage, partitionId); }
/** * Destroys the remote distributed object counterpart of this proxy by * issuing the destruction request to the cluster. */ public final void destroyRemotely() { ClientMessage clientMessage = ClientDestroyProxyCodec.encodeRequest(getDistributedObjectName(), getServiceName()); try { new ClientInvocation(getClient(), clientMessage, getName()).invoke().get(); } catch (Exception e) { throw rethrow(e); } }
private void initialize(ClientProxy clientProxy) throws Exception { Address initializationTarget = findNextAddressToSendCreateRequest(); if (initializationTarget == null) { throw new IOException("Not able to find a member to create proxy on!"); } ClientMessage clientMessage = ClientCreateProxyCodec.encodeRequest(clientProxy.getDistributedObjectName(), clientProxy.getServiceName(), initializationTarget); new ClientInvocation(client, clientMessage, clientProxy.getServiceName(), initializationTarget).invoke().get(); clientProxy.onInitialize(); }
private void initializeWithRetry(ClientProxy clientProxy) throws Exception { long startMillis = System.currentTimeMillis(); while (System.currentTimeMillis() < startMillis + invocationTimeoutMillis) { try { initialize(clientProxy); return; } catch (Exception e) { boolean retryable = isRetryable(e); if (!retryable && e instanceof ExecutionException) { retryable = isRetryable(e.getCause()); } if (retryable) { try { Thread.sleep(invocationRetryPauseMillis); } catch (InterruptedException ignored) { currentThread().interrupt(); } } else { throw e; } } } long elapsedTime = System.currentTimeMillis() - startMillis; throw new OperationTimeoutException("Initializing " + clientProxy.getServiceName() + ":" + clientProxy.getName() + " is timed out after " + elapsedTime + " ms. Configured invocation timeout is " + invocationTimeoutMillis + " ms"); }
protected Data toData(Object o) { return getSerializationService().toData(o); }
protected final int getConnectedServerVersion() { HazelcastClientInstanceImpl client = getClient(); ClientConnectionManager connectionManager = client.getConnectionManager(); Collection<ClientConnection> activeConnections = connectionManager.getActiveConnections(); for (ClientConnection connection : activeConnections) { return connection.getConnectedServerVersion(); } return UNKNOWN_HAZELCAST_VERSION; }
@Override public String getPartitionKey() { return StringPartitioningStrategy.getPartitionKey(getDistributedObjectName()); }
/** * Locally destroys the proxy identified by the given service and object ID. * <p> * Upon successful completion the proxy is unregistered in this proxy * manager and all local resources associated with the proxy are released. * * @param service the service associated with the proxy. * @param id the ID of the object to destroy the proxy of. */ public void destroyProxyLocally(String service, String id) { ObjectNamespace objectNamespace = new DistributedObjectNamespace(service, id); ClientProxyFuture clientProxyFuture = proxies.remove(objectNamespace); if (clientProxyFuture != null) { ClientProxy clientProxy = clientProxyFuture.get(); clientProxy.destroyLocally(); } }
/** * Destroys the remote distributed object counterpart of this proxy by * issuing the destruction request to the cluster. */ public final void destroyRemotely() { ClientMessage clientMessage = ClientDestroyProxyCodec.encodeRequest(getDistributedObjectName(), getServiceName()); try { new ClientInvocation(getClient(), clientMessage, getName()).invoke().get(); } catch (Exception e) { throw rethrow(e); } }
private void initialize(ClientProxy clientProxy) throws Exception { Address initializationTarget = findNextAddressToSendCreateRequest(); if (initializationTarget == null) { throw new IOException("Not able to find a member to create proxy on!"); } ClientMessage clientMessage = ClientCreateProxyCodec.encodeRequest(clientProxy.getDistributedObjectName(), clientProxy.getServiceName(), initializationTarget); new ClientInvocation(client, clientMessage, clientProxy.getServiceName(), initializationTarget).invoke().get(); clientProxy.onInitialize(); }
@Override public int hashCode() { int result = getInstanceName().hashCode(); result = 31 * result + serviceName.hashCode(); result = 31 * result + getDistributedObjectName().hashCode(); return result; }
protected <T> T invoke(ClientMessage clientMessage, Object key) { final int partitionId = getContext().getPartitionService().getPartitionId(key); return invokeOnPartition(clientMessage, partitionId); }
private void initializeWithRetry(ClientProxy clientProxy) throws Exception { long startMillis = System.currentTimeMillis(); while (System.currentTimeMillis() < startMillis + invocationTimeoutMillis) { try { initialize(clientProxy); return; } catch (Exception e) { boolean retryable = isRetryable(e); if (!retryable && e instanceof ExecutionException) { retryable = isRetryable(e.getCause()); } if (retryable) { try { Thread.sleep(invocationRetryPauseMillis); } catch (InterruptedException ignored) { currentThread().interrupt(); } } else { throw e; } } } long elapsedTime = System.currentTimeMillis() - startMillis; throw new OperationTimeoutException("Initializing " + clientProxy.getServiceName() + ":" + clientProxy.getName() + " is timed out after " + elapsedTime + " ms. Configured invocation timeout is " + invocationTimeoutMillis + " ms"); }
protected <T> T toObject(Object data) { return getSerializationService().toObject(data); }
protected final int getConnectedServerVersion() { HazelcastClientInstanceImpl client = getClient(); ClientConnectionManager connectionManager = client.getConnectionManager(); Collection<ClientConnection> activeConnections = connectionManager.getActiveConnections(); for (ClientConnection connection : activeConnections) { return connection.getConnectedServerVersion(); } return UNKNOWN_HAZELCAST_VERSION; }
@Override public String getPartitionKey() { return StringPartitioningStrategy.getPartitionKey(getDistributedObjectName()); }