Search in sources :

Example 1 with GridClientDataConfiguration

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

the class ClientPropertiesConfigurationSelfTest method testSpringConfig.

/**
     * Validate spring client configuration.
     *
     * @throws Exception In case of any exception.
     */
public void testSpringConfig() throws Exception {
    GridClientConfiguration cfg = new FileSystemXmlApplicationContext(GRID_CLIENT_SPRING_CONFIG.toString()).getBean(GridClientConfiguration.class);
    assertEquals(Arrays.asList("127.0.0.1:11211"), new ArrayList<>(cfg.getServers()));
    assertNull(cfg.getSecurityCredentialsProvider());
    Collection<GridClientDataConfiguration> dataCfgs = cfg.getDataConfigurations();
    assertEquals(1, dataCfgs.size());
    GridClientDataConfiguration dataCfg = dataCfgs.iterator().next();
    assertEquals("partitioned", dataCfg.getName());
    assertNotNull(dataCfg.getPinnedBalancer());
    assertEquals(GridClientRandomBalancer.class, dataCfg.getPinnedBalancer().getClass());
    assertNotNull(dataCfg.getAffinity());
    assertEquals(GridClientPartitionAffinity.class, dataCfg.getAffinity().getClass());
}
Also used : FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) GridClientDataConfiguration(org.apache.ignite.internal.client.GridClientDataConfiguration)

Example 2 with GridClientDataConfiguration

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

the class ClientAbstractMultiNodeSelfTest method clientConfiguration.

/**
     * @return Client configuration for the test.
     */
protected GridClientConfiguration clientConfiguration() throws GridClientException {
    GridClientConfiguration cfg = new GridClientConfiguration();
    cfg.setBalancer(getBalancer());
    cfg.setTopologyRefreshFrequency(TOP_REFRESH_FREQ);
    cfg.setProtocol(protocol());
    cfg.setServers(Arrays.asList(serverAddress()));
    cfg.setSslContextFactory(sslContextFactory());
    GridClientDataConfiguration loc = new GridClientDataConfiguration();
    GridClientDataConfiguration partitioned = new GridClientDataConfiguration();
    partitioned.setName(PARTITIONED_CACHE_NAME);
    partitioned.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));
    return cfg;
}
Also used : GridClientPartitionAffinity(org.apache.ignite.internal.client.GridClientPartitionAffinity) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) GridClientDataConfiguration(org.apache.ignite.internal.client.GridClientDataConfiguration)

Example 3 with GridClientDataConfiguration

use of org.apache.ignite.internal.client.GridClientDataConfiguration 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 4 with GridClientDataConfiguration

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

the class TaskCommandHandlerSelfTest method clientConfiguration.

/**
     * @return Client configuration.
     */
private GridClientConfiguration clientConfiguration() {
    GridClientConfiguration cfg = new GridClientConfiguration();
    GridClientDataConfiguration nullCache = new GridClientDataConfiguration();
    GridClientDataConfiguration cache = new GridClientDataConfiguration();
    cache.setName(CACHE_NAME);
    cfg.setDataConfigurations(Arrays.asList(nullCache, cache));
    cfg.setProtocol(TCP);
    cfg.setServers(Arrays.asList("localhost:" + BINARY_PORT));
    return cfg;
}
Also used : GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) GridClientDataConfiguration(org.apache.ignite.internal.client.GridClientDataConfiguration)

Example 5 with GridClientDataConfiguration

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

the class ClientCacheBenchmark method configuration.

/**
     * @return Test client configuration.
     */
private GridClientConfiguration configuration() {
    GridClientConfiguration cfg = new GridClientConfiguration();
    cfg.setServers(Collections.singleton("localhost:11211"));
    GridClientDataConfiguration cacheCfg = new GridClientDataConfiguration();
    cacheCfg.setName("partitioned");
    cacheCfg.setAffinity(new GridClientPartitionAffinity());
    cfg.setDataConfigurations(Collections.singletonList(cacheCfg));
    return cfg;
}
Also used : GridClientPartitionAffinity(org.apache.ignite.internal.client.GridClientPartitionAffinity) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) GridClientDataConfiguration(org.apache.ignite.internal.client.GridClientDataConfiguration)

Aggregations

GridClientDataConfiguration (org.apache.ignite.internal.client.GridClientDataConfiguration)7 GridClientConfiguration (org.apache.ignite.internal.client.GridClientConfiguration)5 GridClientPartitionAffinity (org.apache.ignite.internal.client.GridClientPartitionAffinity)2 ThreadFactory (java.util.concurrent.ThreadFactory)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 GridClientException (org.apache.ignite.internal.client.GridClientException)1 GridClientNode (org.apache.ignite.internal.client.GridClientNode)1 GridClientPredicate (org.apache.ignite.internal.client.GridClientPredicate)1 GridClientLoadBalancer (org.apache.ignite.internal.client.balancer.GridClientLoadBalancer)1 GridClientRandomBalancer (org.apache.ignite.internal.client.balancer.GridClientRandomBalancer)1 FileSystemXmlApplicationContext (org.springframework.context.support.FileSystemXmlApplicationContext)1