use of org.apache.ignite.internal.client.GridClient in project ignite by apache.
the class ClientAbstractConnectivitySelfTest method checkConnectivityByIp.
/**
* @param connectIp IP to test.
* @param nodeIp Expected IP reported to client.
* @throws GridClientException If failed.
*/
private void checkConnectivityByIp(String connectIp, IgniteBiTuple<Collection<String>, Collection<String>> nodeIp) throws GridClientException {
GridClient cli = startClient(connectIp, defaultRestPort());
List<GridClientNode> nodes = cli.compute().refreshTopology(true, false);
assertEquals(1, nodes.size());
GridClientNode node = F.first(nodes);
assertNotNull(node);
assertTrue(eqAddresses(nodeIp, node));
}
use of org.apache.ignite.internal.client.GridClient in project ignite by apache.
the class ClientAbstractConnectivitySelfTest method testOneNodeZeroIpv4Address.
/**
* Tests correct behavior in case of 1 REST-enabled node
* with explicitly specified 0.0.0.0 address.
*
* @throws Exception If error occurs.
*/
public void testOneNodeZeroIpv4Address() throws Exception {
startRestNode("grid1", WILDCARD_IP, defaultRestPort());
Collection<String> addrs = new LinkedList<>();
addrs.add(LOOPBACK_IP);
Collection<String> nonLoopbackAddrs = U.allLocalIps();
assertNotNull(nonLoopbackAddrs);
addrs.addAll(F.view(nonLoopbackAddrs, new IpV4AddressPredicate()));
// The client should be able to connect through all IPv4 addresses.
for (String addr : addrs) {
log.info("Trying address: " + addr);
GridClient cli = startClient(addr, defaultRestPort());
List<GridClientNode> nodes = cli.compute().refreshTopology(true, false);
assertEquals(1, nodes.size());
GridClientNode node = F.first(nodes);
assertNotNull(node);
assertEquals(getAllIps().get1(), node.attribute(restAddressAttributeName()));
assertEquals(getAllIps().get2(), node.attribute(restHostNameAttributeName()));
List<String> nodeAddrs = node.tcpAddresses();
assertTrue(nodeAddrs.contains(LOOPBACK_IP));
assertTrue(F.containsAll(nodeAddrs, addrs));
}
}
use of org.apache.ignite.internal.client.GridClient in project ignite by apache.
the class ClientAbstractConnectivitySelfTest method testRefreshTopologyOnNodeLeft.
/**
* Tests correct behavior in case of shutdown node used to refresh topology state.
*
* @throws Exception If error occurs.
*/
public void testRefreshTopologyOnNodeLeft() throws Exception {
startRestNode("grid1", null, null);
startRestNode("grid2", null, null);
GridClient cli = startClient(LOOPBACK_IP, defaultRestPort());
List<GridClientNode> nodes = cli.compute().refreshTopology(true, false);
assertEquals(2, nodes.size());
stopGrid("grid1");
nodes = cli.compute().refreshTopology(true, false);
assertEquals(1, nodes.size());
startRestNode("grid3", null, null);
nodes = cli.compute().refreshTopology(true, false);
assertEquals(2, nodes.size());
stopGrid("grid2");
nodes = cli.compute().refreshTopology(true, false);
assertEquals(1, nodes.size());
}
use of org.apache.ignite.internal.client.GridClient in project ignite by apache.
the class ClientAbstractSelfTest method testShutdown.
/**
* @throws Exception If failed.
*/
public void testShutdown() throws Exception {
GridClient c = client();
GridClientCompute compute = c.compute();
String taskName = getTaskName();
Object taskArg = getTaskArgument();
Collection<GridClientFuture<Object>> futs = new ArrayList<>();
// Validate connection works.
compute.execute(taskName, taskArg);
info(">>> First task executed successfully, running batch.");
for (int i = 0; i < 10; i++) futs.add(compute.executeAsync(taskName, taskArg));
// Stop client.
GridClientFactory.stop(c.id(), true);
info(">>> Completed stop request.");
int failed = 0;
for (GridClientFuture<Object> fut : futs) {
try {
assertEquals(17, fut.get());
} catch (GridClientException e) {
failed++;
log.warning("Task execution failed.", e);
}
}
assertEquals(0, failed);
}
use of org.apache.ignite.internal.client.GridClient in project ignite by apache.
the class ClientAbstractSelfTest method testConnectable.
/**
* @throws Exception If failed.
*/
public void testConnectable() throws Exception {
GridClient client = client();
List<GridClientNode> nodes = client.compute().refreshTopology(false, false);
assertTrue(F.first(nodes).connectable());
}
Aggregations