Search in sources :

Example 1 with GridClientRoundRobinBalancer

use of org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer in project ignite by apache.

the class BinaryConfigurationCustomSerializerSelfTest method testThinClientConnected.

/**
 * 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);
}
Also used : GridClientRoundRobinBalancer(org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer) VisorNodePingTaskArg(org.apache.ignite.internal.visor.node.VisorNodePingTaskArg) GridClient(org.apache.ignite.internal.client.GridClient) VisorNodePingTask(org.apache.ignite.internal.visor.node.VisorNodePingTask) UUID(java.util.UUID) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with GridClientRoundRobinBalancer

use of org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer in project ignite by apache.

the class ClientPreferDirectSelfTest method testRoundRobinBalancer.

/**
 * @throws Exception If failed.
 */
@Test
public void testRoundRobinBalancer() throws Exception {
    GridClientRoundRobinBalancer b = new GridClientRoundRobinBalancer();
    b.setPreferDirectNodes(true);
    executeTest(b);
}
Also used : GridClientRoundRobinBalancer(org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with GridClientRoundRobinBalancer

use of org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer in project ignite by apache.

the class ClientTcpSslAuthenticationSelfTest method createClient.

/**
 * 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);
}
Also used : GridClientImpl(org.apache.ignite.internal.client.impl.GridClientImpl) GridClientRoundRobinBalancer(org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer) GridSslBasicContextFactory(org.apache.ignite.internal.client.ssl.GridSslBasicContextFactory)

Example 4 with GridClientRoundRobinBalancer

use of org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer in project ignite by apache.

the class ClientAbstractMultiThreadedSelfTest method clientConfiguration.

/**
 * Creates client that will try to connect to only first node in grid.
 *
 * @return Client.
 */
private GridClientConfiguration clientConfiguration() {
    GridClientConfiguration cfg = new GridClientConfiguration();
    cfg.setTopologyRefreshFrequency(topologyRefreshFrequency());
    cfg.setMaxConnectionIdleTime(maxConnectionIdleTime());
    cfg.setProtocol(protocol());
    cfg.setServers(Arrays.asList(serverAddress()));
    cfg.setBalancer(new GridClientRoundRobinBalancer());
    if (useSsl())
        cfg.setSslContextFactory(sslContextFactory());
    GridClientDataConfiguration loc = new GridClientDataConfiguration();
    GridClientDataConfiguration partitioned = new GridClientDataConfiguration();
    partitioned.setName(PARTITIONED_CACHE_NAME);
    partitioned.setAffinity(new GridClientPartitionAffinity());
    GridClientDataConfiguration partitionedAsyncBackup = new GridClientDataConfiguration();
    partitionedAsyncBackup.setName(PARTITIONED_ASYNC_BACKUP_CACHE_NAME);
    partitionedAsyncBackup.setAffinity(new GridClientPartitionAffinity());
    GridClientDataConfiguration replicated = new GridClientDataConfiguration();
    replicated.setName(REPLICATED_CACHE_NAME);
    GridClientDataConfiguration replicatedAsync = new GridClientDataConfiguration();
    replicatedAsync.setName(REPLICATED_ASYNC_CACHE_NAME);
    cfg.setDataConfigurations(Arrays.asList(loc, partitioned, replicated, replicatedAsync, partitionedAsyncBackup));
    return cfg;
}
Also used : GridClientRoundRobinBalancer(org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer)

Aggregations

GridClientRoundRobinBalancer (org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)2 Test (org.junit.Test)2 UUID (java.util.UUID)1 GridClient (org.apache.ignite.internal.client.GridClient)1 GridClientConfiguration (org.apache.ignite.internal.client.GridClientConfiguration)1 GridClientImpl (org.apache.ignite.internal.client.impl.GridClientImpl)1 GridSslBasicContextFactory (org.apache.ignite.internal.client.ssl.GridSslBasicContextFactory)1 VisorNodePingTask (org.apache.ignite.internal.visor.node.VisorNodePingTask)1 VisorNodePingTaskArg (org.apache.ignite.internal.visor.node.VisorNodePingTaskArg)1