use of org.apache.ignite.internal.client.impl.GridClientImpl in project ignite by apache.
the class ClientTcpSslAuthenticationSelfTest method checkClientAuthenticatedByServer.
/**
* @param fail Should server trust manager fail.
* @throws Exception If failed.
*/
private void checkClientAuthenticatedByServer(boolean fail) throws Exception {
checkClient = true;
srvTrustMgr.shouldFail(fail);
clientTrustMgr.shouldFail(false);
startGrid();
try {
try (GridClientImpl c = createClient()) {
c.compute().refreshTopology(false, false);
}
} finally {
G.stopAll(false);
}
assertEquals(1, srvTrustMgr.clientCheckCallCount());
assertEquals(1, clientTrustMgr.serverCheckCallCount());
}
use of org.apache.ignite.internal.client.impl.GridClientImpl in project ignite by apache.
the class ClientTcpSslAuthenticationSelfTest method checkServerAuthenticatedByClient.
/**
* @param fail Should client trust manager fail.
* @throws Exception If failed.
*/
private void checkServerAuthenticatedByClient(boolean fail) throws Exception {
checkClient = false;
srvTrustMgr.shouldFail(false);
clientTrustMgr.shouldFail(fail);
startGrid();
try {
try (GridClientImpl c = createClient()) {
c.compute().refreshTopology(false, false);
}
} finally {
G.stopAll(false);
}
assertEquals(0, srvTrustMgr.clientCheckCallCount());
assertEquals(1, clientTrustMgr.serverCheckCallCount());
}
use of org.apache.ignite.internal.client.impl.GridClientImpl in project ignite by apache.
the class GridClientFactory method stopAll.
/**
* Stops all currently open clients.
*
* @param wait If {@code true} then each client will wait to finish all ongoing requests before
* closing (however, no new requests will be accepted). If {@code false}, clients will be
* closed immediately and all ongoing requests will be failed.
*/
@SuppressWarnings("TooBroadScope")
public static void stopAll(boolean wait) {
ConcurrentMap<UUID, GridClientImpl> old;
busyLock.writeLock().lock();
try {
old = openClients;
openClients = new ConcurrentHashMap<>();
} finally {
busyLock.writeLock().unlock();
}
for (GridClientImpl client : old.values()) client.stop(wait);
}
use of org.apache.ignite.internal.client.impl.GridClientImpl 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);
}
use of org.apache.ignite.internal.client.impl.GridClientImpl in project ignite by apache.
the class GridClientFactory method start.
/**
* Starts a client with given configuration. Starting client will be assigned a randomly generated
* UUID which can be obtained by {@link GridClient#id()} method.
*
* @param cfg Client configuration.
* @return Started client.
* @throws GridClientException If client could not be created.
*/
public static GridClient start(GridClientConfiguration cfg) throws GridClientException {
busyLock.readLock().lock();
try {
UUID clientId = UUID.randomUUID();
GridClientImpl client = new GridClientImpl(clientId, cfg, false);
GridClientImpl old = openClients.putIfAbsent(clientId, client);
assert old == null : "Random unique UUID generation failed.";
return client;
} finally {
busyLock.readLock().unlock();
}
}
Aggregations