Search in sources :

Example 6 with GridClientConfiguration

use of org.apache.ignite.internal.client.GridClientConfiguration in project ignite by apache.

the class ClientAbstractSelfTest method clientConfiguration.

/**
     * @return Test client configuration.
     */
protected GridClientConfiguration clientConfiguration() throws GridClientException {
    GridClientConfiguration cfg = new GridClientConfiguration();
    GridClientDataConfiguration nullCache = new GridClientDataConfiguration();
    GridClientDataConfiguration cache = new GridClientDataConfiguration();
    cache.setName(CACHE_NAME);
    cfg.setDataConfigurations(Arrays.asList(nullCache, cache));
    cfg.setProtocol(protocol());
    cfg.setServers(Collections.singleton(serverAddress()));
    // Setting custom executor, to avoid failures on client shutdown.
    // And applying custom naming scheme to ease debugging.
    cfg.setExecutorService(Executors.newCachedThreadPool(new ThreadFactory() {

        private AtomicInteger cntr = new AtomicInteger();

        @SuppressWarnings("NullableProblems")
        @Override
        public Thread newThread(Runnable r) {
            return new Thread(r, "client-worker-thread-" + cntr.getAndIncrement());
        }
    }));
    if (useSsl())
        cfg.setSslContextFactory(sslContextFactory());
    return cfg;
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) GridClientDataConfiguration(org.apache.ignite.internal.client.GridClientDataConfiguration)

Example 7 with GridClientConfiguration

use of org.apache.ignite.internal.client.GridClientConfiguration in project ignite by apache.

the class TcpRouterAbstractSelfTest method clientConfiguration.

/** {@inheritDoc} */
@Override
protected GridClientConfiguration clientConfiguration() throws GridClientException {
    GridClientConfiguration cfg = super.clientConfiguration();
    cfg.setServers(Collections.<String>emptySet());
    cfg.setRouters(Collections.singleton(HOST + ":" + ROUTER_PORT));
    return cfg;
}
Also used : GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration)

Example 8 with GridClientConfiguration

use of org.apache.ignite.internal.client.GridClientConfiguration in project ignite by apache.

the class TcpRouterMultiNodeSelfTest method clientConfiguration.

/** {@inheritDoc} */
@Override
protected GridClientConfiguration clientConfiguration() throws GridClientException {
    GridClientConfiguration cfg = super.clientConfiguration();
    cfg.setServers(Collections.<String>emptySet());
    Collection<String> rtrs = new ArrayList<>(ROUTERS_CNT);
    for (int i = 0; i < ROUTERS_CNT; i++) rtrs.add(HOST + ':' + (ROUTER_TCP_PORT_BASE + i));
    cfg.setRouters(rtrs);
    return cfg;
}
Also used : ArrayList(java.util.ArrayList) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration)

Example 9 with GridClientConfiguration

use of org.apache.ignite.internal.client.GridClientConfiguration in project ignite by apache.

the class ClientTcpUnreachableMultiNodeSelfTest method clientConfiguration.

/** {@inheritDoc} */
@Override
protected GridClientConfiguration clientConfiguration() throws GridClientException {
    GridClientConfiguration cfg = super.clientConfiguration();
    // Setting low connection timeout to allow multiple threads
    // pass the unavailable address quickly.
    cfg.setConnectTimeout(100);
    return cfg;
}
Also used : GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration)

Example 10 with GridClientConfiguration

use of org.apache.ignite.internal.client.GridClientConfiguration in project ignite by apache.

the class ClientFailedInitSelfTest method client.

/**
     * @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);
}
Also used : GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration)

Aggregations

GridClientConfiguration (org.apache.ignite.internal.client.GridClientConfiguration)23 GridClientDataConfiguration (org.apache.ignite.internal.client.GridClientDataConfiguration)5 ArrayList (java.util.ArrayList)4 GridClient (org.apache.ignite.internal.client.GridClient)3 GridClientException (org.apache.ignite.internal.client.GridClientException)3 GridClientPartitionAffinity (org.apache.ignite.internal.client.GridClientPartitionAffinity)2 File (java.io.File)1 IOException (java.io.IOException)1 Map (java.util.Map)1 Properties (java.util.Properties)1 UUID (java.util.UUID)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Ignite (org.apache.ignite.Ignite)1 Event (org.apache.ignite.events.Event)1 TaskEvent (org.apache.ignite.events.TaskEvent)1 GridClientClusterState (org.apache.ignite.internal.client.GridClientClusterState)1 GridClientRoundRobinBalancer (org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer)1 GridClientJdkMarshaller (org.apache.ignite.internal.client.marshaller.jdk.GridClientJdkMarshaller)1 VisorNodePingTask (org.apache.ignite.internal.visor.node.VisorNodePingTask)1