use of org.apache.ignite.internal.client.GridClientNode in project gridgain by gridgain.
the class ClientAbstractMultiNodeSelfTest method testProjectionRun.
/**
* @throws Exception If failed.
*/
@Test
public void testProjectionRun() throws Exception {
GridClientCompute dflt = client.compute();
Collection<? extends GridClientNode> nodes = dflt.nodes();
assertEquals(NODES_CNT, nodes.size());
for (int i = 0; i < NODES_CNT; i++) {
Ignite g = grid(i);
assert g != null;
GridClientNode clientNode = dflt.node(g.cluster().localNode().id());
assertNotNull("Client node for " + g.cluster().localNode().id() + " was not found", clientNode);
GridClientCompute prj = dflt.projection(clientNode);
String res = prj.execute(TestTask.class.getName(), null);
assertNotNull(res);
assertEquals(g.cluster().localNode().id().toString(), res);
}
}
use of org.apache.ignite.internal.client.GridClientNode in project gridgain by gridgain.
the class ClientAbstractSelfTest method testConnectable.
/**
* @throws Exception If failed.
*/
@Test
public void testConnectable() throws Exception {
GridClient client = client();
List<GridClientNode> nodes = client.compute().refreshTopology(false, false);
assertTrue(F.first(nodes).connectable());
}
use of org.apache.ignite.internal.client.GridClientNode in project gridgain by gridgain.
the class ClientAbstractSelfTest method testTopology.
/**
* @throws Exception If failed.
*/
@Test
public void testTopology() throws Exception {
GridClientCompute compute = client.compute();
List<GridClientNode> top = compute.refreshTopology(true, true);
assertNotNull(top);
assertEquals(1, top.size());
GridClientNode node = F.first(top);
assertNotNull(node);
assertFalse(node.attributes().isEmpty());
assertNotNull(node.tcpAddresses());
assertEquals(grid().localNode().id(), node.nodeId());
assertNotNull(node.metrics());
top = compute.refreshTopology(false, false);
node = F.first(top);
assertNotNull(top);
assertEquals(1, top.size());
assertNull(node.metrics());
assertTrue(node.attributes().isEmpty());
node = F.first(top);
assertNotNull(node);
assertTrue(node.attributes().isEmpty());
assertNull(node.metrics());
assertNotNull(node.tcpAddresses());
assertEquals(grid().localNode().id(), node.nodeId());
top = compute.refreshTopologyAsync(true, true).get();
assertNotNull(top);
assertEquals(1, top.size());
node = F.first(top);
assertNotNull(node);
assertFalse(node.attributes().isEmpty());
assertNotNull(node.metrics());
assertNotNull(node.tcpAddresses());
assertEquals(grid().localNode().id(), node.nodeId());
top = compute.refreshTopologyAsync(false, false).get();
assertNotNull(top);
assertEquals(1, top.size());
node = F.first(top);
assertNotNull(node);
assertTrue(node.attributes().isEmpty());
assertNull(node.metrics());
assertNotNull(node.tcpAddresses());
assertEquals(grid().localNode().id(), node.nodeId());
}
use of org.apache.ignite.internal.client.GridClientNode in project gridgain by gridgain.
the class GridRouterClientImpl method forwardMessage.
/**
* Send a raw packet "as is" directly to the given node.
* The exact types of acceptable arguments and return values depends on underlying connections.
*
* @param msg Raw message to send.
* @param destId Id of node to send message to. If {@code null} than node will be chosen
* from the topology randomly.
* @return Future, representing forwarded message.
* @throws GridServerUnreachableException If destination node can't be reached.
* @throws GridClientClosedException If client is closed.
* @throws GridClientException If any other client-related error occurs.
* @throws InterruptedException If router was interrupted while trying.
* to establish connection with destination node.
*/
GridClientFutureAdapter<?> forwardMessage(Object msg, @Nullable UUID destId, byte marshId) throws GridClientException, InterruptedException {
GridClientTopology top = clientImpl.topology();
GridClientNode dest = destId != null ? top.node(destId) : cliCfg.getBalancer().balancedNode(applyFilter(top.nodes(), new GridClientPredicate<GridClientNodeImpl>() {
@Override
public boolean apply(GridClientNodeImpl e) {
return restAvailable(e, cliCfg.getProtocol());
}
}));
if (dest == null)
throw new GridServerUnreachableException("Failed to resolve node for specified destination ID: " + destId);
GridClientConnectionManager connMgr = connectionManager(marshId);
GridClientConnection conn = null;
// No reconnection handling there. Let client to do it if needed.
GridClientException cause;
try {
conn = connMgr.connection(dest);
return conn.forwardMessage(msg);
} catch (GridClientConnectionResetException e) {
if (destId != null)
connMgr.terminateConnection(conn, top.node(destId), e);
else
connMgr.terminateConnection(conn, null, e);
cause = e;
} catch (GridClientException e) {
cause = e;
}
GridClientFutureAdapter<Object> fail = new GridClientFutureAdapter<>();
fail.onDone(cause);
return fail;
}
use of org.apache.ignite.internal.client.GridClientNode in project gridgain by gridgain.
the class GridClientTopology method fail.
/**
* Marks topology as failed. After this method called all accessors will throw exception
* until a next successful update.
*
* @param cause Exception caused the failure.
*/
public void fail(GridClientException cause) {
lock.writeLock().lock();
try {
lastError = cause;
for (GridClientNode n : nodes.values()) notifyEvents(Collections.singletonList(new TopologyEvent(false, n)));
nodes = Collections.emptyMap();
} finally {
lock.writeLock().unlock();
}
}
Aggregations