@Override public GridClient call() throws Exception { return GridClientFactory.start(cfg); } });
/** * @return Client. * @throws GridClientException In case of error. */ protected GridClient client() throws GridClientException { return GridClientFactory.start(clientConfiguration()); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { client = GridClientFactory.start(clientConfiguration()); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { client = GridClientFactory.start(clientConfiguration()); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { client = GridClientFactory.start(clientConfiguration()); }
/** * @return Client. * @throws GridClientException In case of error. */ protected GridClient client() throws GridClientException { return GridClientFactory.start(new GridClientConfiguration() .setConnectTimeout(300) .setServers(Collections .singleton(HOST + ":" + BINARY_PORT))); } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { GridClientConfiguration cfg = new GridClientConfiguration(); cfg.setProtocol(TCP); cfg.setServers(Collections.singletonList("localhost:" + BINARY_PORT)); client = GridClientFactory.start(cfg); }
/** * @param host - server host * @return Client for test. * @throws GridClientException In case of error. */ private GridClient client(String host) throws GridClientException { GridClientConfiguration cfg = new GridClientConfiguration(); cfg.setProtocol(GridClientProtocol.TCP); Collection<String> addrs = new ArrayList<>(); for (int port = ClientTestRestServer.FIRST_SERVER_PORT; port < ClientTestRestServer.FIRST_SERVER_PORT + ClientTestRestServer.SERVERS_CNT; port++) addrs.add(host + ":" + port); cfg.setServers(addrs); cfg.setTopologyRefreshFrequency(60 * 60 * 1000); return GridClientFactory.start(cfg); }
/** * @param b Balancer. * @return Client. * @throws Exception If failed. */ private GridClient client(GridClientLoadBalancer b) throws Exception { GridClientConfiguration cfg = new GridClientConfiguration(); cfg.setBalancer(b); cfg.setTopologyRefreshFrequency(TOP_REFRESH_FREQ); Collection<String> rtrs = new ArrayList<>(3); for (int i = 0; i < NODES_CNT / 2; i++) rtrs.add(HOST + ':' + (REST_TCP_PORT_BASE + i)); cfg.setRouters(rtrs); return GridClientFactory.start(cfg); }
@Override public Object call() throws Exception { GridClient client = GridClientFactory.start(getClientConfiguration()); client.compute().refreshTopology(false, false); return null; } },
/** * */ @Test public void testEmptyAddresses() { try { GridClientFactory.start(new GridClientConfiguration()); assert false; } catch (GridClientException e) { info("Caught expected exception: " + e); } }
/** * Starts a REST client. * * @param addr REST server address. * @param port REST server port. * @return A successfully started REST client. * @throws GridClientException If failed to start REST client. */ protected GridClient startClient(String addr, int port) throws GridClientException { GridClientConfiguration cliCfg = new GridClientConfiguration(); cliCfg.setServers(Collections.singleton(addr + ":" + port)); cliCfg.setProtocol(protocol()); return GridClientFactory.start(cliCfg); }
/** * @param p Protocol. * @param useRouter Use router flag. * @return Client instance. * @throws GridClientException If failed. */ private GridClient client(GridClientProtocol p, boolean useRouter) throws GridClientException { GridClientConfiguration cfg = new GridClientConfiguration(); int port = p == TCP ? (useRouter ? ROUTER_BINARY_PORT : BINARY_PORT) : (useRouter ? ROUTER_JETTY_PORT : JETTY_PORT); cfg.setProtocol(p); cfg.setServers(Arrays.asList(HOST + ":" + port)); cfg.setTopologyRefreshFrequency(TOP_REFRESH_PERIOD); return GridClientFactory.start(cfg); }
/** * */ @Test public void testRoutersAndServersAddressesProvided() { try { GridClientConfiguration c = new GridClientConfiguration(); c.setRouters(Collections.singleton("127.0.0.1:10000")); c.setServers(Collections.singleton("127.0.0.1:10000")); GridClientFactory.start(c); assert false; } catch (GridClientException e) { info("Caught expected exception: " + e); } }
/** */ private void deactivateThroughClient() throws Exception { GridClientConfiguration clientCfg = new GridClientConfiguration(); clientCfg.setServers(Collections.singletonList("127.0.0.1:11211")); try (GridClient client = GridClientFactory.start(clientCfg)) { GridClientClusterState state = client.state(); log.info(">>> Try to deactivate ..."); state.active(false); } } }
/** * @throws Exception If failed. */ @Test public void testTaskAfterRestart() throws Exception { startGrids(1); GridClientConfiguration cfg = new GridClientConfiguration(); cfg.setProtocol(GridClientProtocol.TCP); cfg.setServers(Collections.singleton("127.0.0.1:" + PORT)); GridClient cli = GridClientFactory.start(cfg); cli.compute().execute(ClientTcpTask.class.getName(), Collections.singletonList("arg")); stopAllGrids(); startGrid(); cli.compute().execute(ClientTcpTask.class.getName(), Collections.singletonList("arg")); } }
/** * @param cipherSuites list of cipher suites * @param protocols list of protocols * @throws Exception If failed. */ private void checkSuccessfulClientStart(String[] cipherSuites, String[] protocols) throws Exception { this.cipherSuites = F.isEmpty(cipherSuites) ? null : cipherSuites; this.protocols = F.isEmpty(protocols) ? null : protocols; try (GridClient client = GridClientFactory.start(getClientConfiguration())) { List<GridClientNode> top = client.compute().refreshTopology(false, false); assertEquals(1, top.size()); } }
/** * Creates client that will try to connect to only first node in grid. * * @return Client. * @throws Exception If failed to create client. */ private GridClientImpl createClient() throws Exception { GridClientConfiguration cfg = new GridClientConfiguration(); cfg.setServers(Arrays.asList(U.getLocalHost().getHostAddress() + ":" + REST_TCP_PORT)); cfg.setBalancer(new GridClientRoundRobinBalancer()); GridSslBasicContextFactory factory = (GridSslBasicContextFactory)GridTestUtils.sslContextFactory(); factory.setTrustManagers(clientTrustMgr); cfg.setSslContextFactory(factory); return (GridClientImpl)GridClientFactory.start(cfg); }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { Ignite g = startGrid(); g.events().localListen(new IgnitePredicate<Event>() { @Override public boolean apply(Event evt) { assert evt instanceof TaskEvent; evts.add((TaskEvent)evt); latch.countDown(); return true; } }, EVTS_TASK_EXECUTION); nodeId = g.cluster().localNode().id(); GridClientConfiguration cfg = new GridClientConfiguration(); cfg.setServers(Collections.singleton("127.0.0.1:11211")); client = GridClientFactory.start(cfg); }
/** * 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); }