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);
}
}
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);
}
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);
}
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;
}
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;
}
Aggregations