Search in sources :

Example 1 with GridClientImpl

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());
}
Also used : GridClientImpl(org.apache.ignite.internal.client.impl.GridClientImpl)

Example 2 with GridClientImpl

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());
}
Also used : GridClientImpl(org.apache.ignite.internal.client.impl.GridClientImpl)

Example 3 with GridClientImpl

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);
}
Also used : GridClientImpl(org.apache.ignite.internal.client.impl.GridClientImpl) UUID(java.util.UUID)

Example 4 with GridClientImpl

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);
}
Also used : GridClientImpl(org.apache.ignite.internal.client.impl.GridClientImpl) GridClientRoundRobinBalancer(org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer) GridSslBasicContextFactory(org.apache.ignite.internal.client.ssl.GridSslBasicContextFactory)

Example 5 with GridClientImpl

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();
    }
}
Also used : GridClientImpl(org.apache.ignite.internal.client.impl.GridClientImpl) UUID(java.util.UUID)

Aggregations

GridClientImpl (org.apache.ignite.internal.client.impl.GridClientImpl)5 UUID (java.util.UUID)2 GridClientRoundRobinBalancer (org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer)1 GridSslBasicContextFactory (org.apache.ignite.internal.client.ssl.GridSslBasicContextFactory)1