Search in sources :

Example 41 with GridClientConfiguration

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

the class CacheCreateDestroyEventSecurityContextTest method testGridClient.

/**
 * Tests cache create/destroy event security context in case operation is initiated from the {@link GridClient}.
 */
@Test
public void testGridClient() throws Exception {
    operationInitiatorLogin = "grid_client";
    GridClientConfiguration cfg = new GridClientConfiguration().setServers(singletonList("127.0.0.1:11211")).setSecurityCredentialsProvider(new SecurityCredentialsBasicProvider(new SecurityCredentials(operationInitiatorLogin, "")));
    grid("crd").createCache(cacheConfiguration());
    try (GridClient cli = GridClientFactory.start(cfg)) {
        checkCacheEvents(() -> cli.state().state(INACTIVE, true), EVT_CACHE_STOPPED);
        checkCacheEvents(() -> cli.state().state(ACTIVE, true), EVT_CACHE_STARTED);
    }
}
Also used : SecurityCredentials(org.apache.ignite.plugin.security.SecurityCredentials) GridClient(org.apache.ignite.internal.client.GridClient) SecurityCredentialsBasicProvider(org.apache.ignite.plugin.security.SecurityCredentialsBasicProvider) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) Test(org.junit.Test)

Example 42 with GridClientConfiguration

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

the class ChangeStateCommandHandlerTest method beforeTest.

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

Example 43 with GridClientConfiguration

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

the class ClusterStateThinClientAbstractTest method beforeTestsStarted.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTestsStarted() throws Exception {
    super.beforeTestsStarted();
    GridClientConfiguration cfg = new GridClientConfiguration();
    cfg.setProtocol(GridClientProtocol.TCP);
    cfg.setServers(Collections.singletonList(HOST + ":" + DFLT_TCP_PORT));
    gridClient = GridClientFactory.start(cfg);
}
Also used : GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration)

Example 44 with GridClientConfiguration

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

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 45 with GridClientConfiguration

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

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)

Aggregations

GridClientConfiguration (org.apache.ignite.internal.client.GridClientConfiguration)64 GridClient (org.apache.ignite.internal.client.GridClient)18 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 GridClientDataConfiguration (org.apache.ignite.internal.client.GridClientDataConfiguration)11 UUID (java.util.UUID)10 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)10 List (java.util.List)9 Logger (java.util.logging.Logger)9 Collectors (java.util.stream.Collectors)9 GridClientNode (org.apache.ignite.internal.client.GridClientNode)9 GridClientException (org.apache.ignite.internal.client.GridClientException)8 F (org.apache.ignite.internal.util.typedef.F)7 Map (java.util.Map)6 VisorTaskArgument (org.apache.ignite.internal.visor.VisorTaskArgument)6 GridClientDisconnectedException (org.apache.ignite.internal.client.GridClientDisconnectedException)5 CommandLogger.optional (org.apache.ignite.internal.commandline.CommandLogger.optional)5 SecurityCredentials (org.apache.ignite.plugin.security.SecurityCredentials)5 SecurityCredentialsBasicProvider (org.apache.ignite.plugin.security.SecurityCredentialsBasicProvider)5 File (java.io.File)4