/** {@inheritDoc} */ @Override public void close() throws SQLException { if (closed) return; closed = true; GridClientFactory.stop(client.id(), false); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (client != null) { GridClientFactory.stop(client.id(), false); client = null; } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { GridClientFactory.stop(client.id(), false); client = null; }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { GridClientFactory.stop(client.id()); }
/** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { GridClientFactory.stop(client.id()); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { GridClientFactory.stop(client.id()); }
/** * Events for class tasks that was started from external clients should contain * client subject id instead of the node where it was started. This test checks it. * * @throws Exception If failed. */ @Test public void testClient() throws Exception { latch = new CountDownLatch(3); client.compute().execute(SimpleTask.class.getName(), null); assert latch.await(1000, MILLISECONDS); assertEquals(3, evts.size()); Iterator<TaskEvent> it = evts.iterator(); assert it.hasNext(); TaskEvent evt = it.next(); assert evt != null; assertEquals(EVT_TASK_STARTED, evt.type()); assertEquals(client.id(), evt.subjectId()); assert it.hasNext(); evt = it.next(); assert evt != null; assertEquals(EVT_TASK_REDUCED, evt.type()); assertEquals(client.id(), evt.subjectId()); assert it.hasNext(); evt = it.next(); assert evt != null; assertEquals(EVT_TASK_FINISHED, evt.type()); assertEquals(client.id(), evt.subjectId()); assert !it.hasNext(); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { U.shutdownNow(ClientAbstractSelfTest.class, exec, log); exec = null; if (client != null) GridClientFactory.stop(client.id(), true); client = null; synchronized (cacheStores) { for (HashMapStore cacheStore : cacheStores.values()) cacheStore.map.clear(); } grid().cache(DEFAULT_CACHE_NAME).clear(); grid().cache(CACHE_NAME).clear(); INTERCEPTED_OBJECTS.clear(); }
futs.put("refreshTop", compute.refreshTopologyAsync(true, true)); GridClientFactory.stop(client.id(), false);
/** * @throws Exception If failed. */ @Test public void testGracefulShutdown() throws Exception { GridClientCompute compute = client.compute(); Object taskArg = getTaskArgument(); String taskName = getSleepTaskName(); GridClientFuture<Object> fut = compute.executeAsync(taskName, taskArg); GridClientFuture<Object> fut2 = compute.executeAsync(taskName, taskArg); GridClientFactory.stop(client.id(), true); Assert.assertEquals(17, fut.get()); Assert.assertEquals(17, fut2.get()); }
/** * @throws Exception If failed. */ @Test public void testForceShutdown() throws Exception { GridClientCompute compute = client.compute(); Object taskArg = getTaskArgument(); String taskName = getSleepTaskName(); GridClientFuture<Object> fut = compute.executeAsync(taskName, taskArg); GridClientFactory.stop(client.id(), false); try { fut.get(); } catch (GridClientClosedException ignored) { return; } Assert.fail("Expected GridClientClosedException."); }
/** * @throws Exception If failed. */ @Test public void testManyTasksRun() throws Exception { GridClientCompute compute = client.compute(); for (int i = 0; i < 1000; i++) assertEquals(new Integer("executing".length()), compute.execute(TestTask.class.getName(), "executing")); GridClientFactory.stop(client.id(), true); IgniteKernal g = (IgniteKernal)grid(0); Map<GridRestCommand, GridRestCommandHandler> handlers = U.field(g.context().rest(), "handlers"); GridTaskCommandHandler taskHnd = (GridTaskCommandHandler)F.find(handlers.values(), null, new P1<GridRestCommandHandler>() { @Override public boolean apply(GridRestCommandHandler e) { return e instanceof GridTaskCommandHandler; } }); assertNotNull("GridTaskCommandHandler was not found", taskHnd); ConcurrentLinkedHashMap taskDesc = U.field(taskHnd, "taskDescs"); assertTrue("Task result map size exceeded max value [mapSize=" + taskDesc.sizex() + ", " + "maxSize=" + MAX_TASK_RESULTS + ']', taskDesc.sizex() <= MAX_TASK_RESULTS); }
GridClientFactory.stop(c.id(), true);
/** * Test that thin client will be able to connect to node with custom binary serializer and custom consistent ID. * * @throws Exception If failed. */ @Test public void testThinClientConnected() throws Exception { UUID nid = ignite(0).cluster().localNode().id(); GridClientConfiguration clnCfg = new GridClientConfiguration(); clnCfg.setProtocol(GridClientProtocol.TCP); clnCfg.setServers(Collections.singleton("127.0.0.1:11211")); clnCfg.setBalancer(new GridClientRoundRobinBalancer()); // Start client. GridClient client = GridClientFactory.start(clnCfg); // Execute some task. client.compute().execute(VisorNodePingTask.class.getName(), new VisorTaskArgument<>(nid, new VisorNodePingTaskArg(nid), false)); GridClientFactory.stop(client.id(), false); }
/** * TODO: IGNITE-590. * * @throws Exception If failed. */ @Ignore("https://issues.apache.org/jira/browse/IGNITE-590") @Test public void testIdleConnection() throws Exception { int srvsCnt = 4; // TODO: IGNITE-590 it may be wrong value. Need to investigate after IGNITE-590 will be fixed. for (int i = 0; i < srvsCnt; i++) runServer(i, false); GridClient client = client(); // Here client opens initial connection and fetches topology. try { // Only first server in list should be contacted. assertEquals(1, srvs[0].getConnectCount()); Thread.sleep(35000); // Timeout as idle. assertEquals(1, srvs[0].getDisconnectCount()); for (int i = 1; i < srvsCnt; i++) assertEquals(0, srvs[i].getConnectCount()); srvs[0].resetCounters(); // On new request connection should be re-opened. client.compute().refreshTopology(false, false); assertEquals(1, srvs[0].getConnectCount()); for (int i = 1; i < srvsCnt; i++) assertEquals(0, srvs[i].getConnectCount()); } finally { GridClientFactory.stop(client.id()); } }
/** {@inheritDoc} */ @Override public void close() throws SQLException { if (closed) return; closed = true; GridClientFactory.stop(client.id(), false); }