@Override public void onDone(GridClientFuture<GridClientDataMetrics> fut) { try { metrics = fut.get(); } catch (GridClientException ignored) { // It's just a cache, so ignore failures. } } });
/** {@inheritDoc} */ @Override public <R> R affinityExecute(String taskName, String cacheName, Object affKey, Object taskArg) throws GridClientException { return this.<R>affinityExecuteAsync(taskName, cacheName, affKey, taskArg).get(); }
@Override public R onComplete(GridClientFuture<GridClientTaskResultBean> fut) throws GridClientException { return fut.get().getResult(); } });
/** {@inheritDoc} */ @Override public boolean active() throws GridClientException { return withReconnectHandling(new ClientProjectionClosure<Boolean>() { @Override public GridClientFuture<Boolean> apply( GridClientConnection conn, UUID nodeId ) throws GridClientConnectionResetException, GridClientClosedException { return conn.currentState(nodeId); } }).get(); } }
/** {@inheritDoc} */ @Nullable @Override public GridClientNode refreshNode(String ip, boolean includeAttrs, boolean inclMetrics) throws GridClientException { return refreshNodeAsync(ip, includeAttrs, inclMetrics).get(); }
/** {@inheritDoc} */ @Override public void active(final boolean active) throws GridClientException { withReconnectHandling(new ClientProjectionClosure<Void>() { @Override public GridClientFuture apply( GridClientConnection conn, UUID nodeId ) throws GridClientConnectionResetException, GridClientClosedException { return conn.changeState(active, nodeId); } }).get(); }
@Override public V onComplete(GridClientFuture<Map<K, V>> fut) throws GridClientException { Map<K, V> map = fut.get(); return F.firstValue(map); } });
/** {@inheritDoc} */ @Override public <K, V> Map<K, V> getAll(Collection<K> keys) throws GridClientException { return this.<K, V>getAllAsync(keys).get(); }
/** {@inheritDoc} */ @Override public GridClientNode refreshNode(UUID id, boolean includeAttrs, boolean includeMetrics) throws GridClientException { return refreshNodeAsync(id, includeAttrs, includeMetrics).get(); }
/** {@inheritDoc} */ @Override public List<GridClientNode> refreshTopology(boolean includeAttrs, boolean includeMetrics) throws GridClientException { return refreshTopologyAsync(includeAttrs, includeMetrics).get(); }
/** {@inheritDoc} */ @Override public <K, V> V get(K key) throws GridClientException { return this.<K, V>getAsync(key).get(); }
/** {@inheritDoc} */ @Override public <K, V> void putAll(Map<K, V> entries) throws GridClientException { putAllAsync(entries).get(); }
/** {@inheritDoc} */ @Override public <K, V> boolean replace(K key, V val) throws GridClientException { return replaceAsync(key, val).get(); }
/** {@inheritDoc} */ @Override public <K, V> boolean cas(K key, V val1, V val2) throws GridClientException { return casAsync(key, val1, val2).get(); }
/** {@inheritDoc} */ @Override public <K> void removeAll(Collection<K> keys) throws GridClientException { removeAllAsync(keys).get(); }
/** {@inheritDoc} */ @Override public <K, V> boolean prepend(K key, V val) throws GridClientException { return prependAsync(key, val).get(); }
/** {@inheritDoc} */ @Override public <R> R execute(String taskName, Object taskArg) throws GridClientException { return this.<R>executeAsync(taskName, taskArg).get(); }
@Override public Integer onComplete(GridClientFuture<Integer> f) throws GridClientException { assertTrue("Expects callback future is finished.", f.isDone()); return f.get() + 1; } });
@Override public void onDone(GridClientFuture fut) { try { GridRouterResponse res = (GridRouterResponse)fut.get(); // Restoring original request id, because it was overwritten by the client. res.requestId(reqId); ses.send(res); } catch (GridClientException e) { ses.send(makeFailureResponse(e, clientId, reqId)); } } });
/** * @throws Exception If failed. */ @Test public void testExecute() throws Exception { String taskName = getTaskName(); Object taskArg = getTaskArgument(); GridClientCompute compute = client.compute(); assertEquals(Integer.valueOf(17), compute.execute(taskName, taskArg)); assertEquals(Integer.valueOf(17), compute.executeAsync(taskName, taskArg).get()); }