Search in sources :

Example 1 with ClientCluster

use of org.apache.ignite.client.ClientCluster in project ignite by apache.

the class JavaThinClient method cientCluster.

@Test
void cientCluster() throws Exception {
    ClientConfiguration clientCfg = new ClientConfiguration().setAddresses("127.0.0.1:10800");
    // tag::client-cluster[]
    try (IgniteClient client = Ignition.startClient(clientCfg)) {
        ClientCluster clientCluster = client.cluster();
        clientCluster.state(ClusterState.ACTIVE);
    }
// end::client-cluster[]
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) ClientCluster(org.apache.ignite.client.ClientCluster) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) ThinClientConfiguration(org.apache.ignite.configuration.ThinClientConfiguration) Test(org.junit.jupiter.api.Test)

Example 2 with ClientCluster

use of org.apache.ignite.client.ClientCluster in project ignite by apache.

the class ClusterApiTest method testClusterState.

/**
 * Test change cluster state operation by thin client.
 */
@Test
public void testClusterState() throws Exception {
    try (IgniteClient client = startClient(0)) {
        ClientCluster clientCluster = client.cluster();
        IgniteCluster igniteCluster = grid(0).cluster();
        changeAndCheckState(clientCluster, igniteCluster, ClusterState.INACTIVE);
        changeAndCheckState(clientCluster, igniteCluster, ClusterState.ACTIVE_READ_ONLY);
        changeAndCheckState(clientCluster, igniteCluster, ClusterState.ACTIVE);
        changeAndCheckState(clientCluster, igniteCluster, ClusterState.INACTIVE);
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) IgniteCluster(org.apache.ignite.IgniteCluster) ClientCluster(org.apache.ignite.client.ClientCluster) Test(org.junit.Test)

Example 3 with ClientCluster

use of org.apache.ignite.client.ClientCluster in project ignite by apache.

the class ClusterApiTest method testWalState.

/**
 * Test change WAL state for cache operation by thin client.
 */
@Test
public void testWalState() throws Exception {
    try (IgniteClient client = startClient(0)) {
        ClientCluster clientCluster = client.cluster();
        IgniteCluster igniteCluster = grid(0).cluster();
        igniteCluster.state(ClusterState.ACTIVE);
        grid(0).getOrCreateCache(DEFAULT_CACHE_NAME);
        igniteCluster.disableWal(DEFAULT_CACHE_NAME);
        // Check enable WAL operation.
        assertTrue(clientCluster.enableWal(DEFAULT_CACHE_NAME));
        assertTrue(clientCluster.isWalEnabled(DEFAULT_CACHE_NAME));
        assertTrue(igniteCluster.isWalEnabled(DEFAULT_CACHE_NAME));
        // Check enable WAL operation on already enabled WAL.
        assertFalse(clientCluster.enableWal(DEFAULT_CACHE_NAME));
        assertTrue(clientCluster.isWalEnabled(DEFAULT_CACHE_NAME));
        assertTrue(igniteCluster.isWalEnabled(DEFAULT_CACHE_NAME));
        // Check disable WAL operation.
        assertTrue(clientCluster.disableWal(DEFAULT_CACHE_NAME));
        assertFalse(clientCluster.isWalEnabled(DEFAULT_CACHE_NAME));
        assertFalse(igniteCluster.isWalEnabled(DEFAULT_CACHE_NAME));
        // Check disable WAL operation on already disabled WAL.
        assertFalse(clientCluster.disableWal(DEFAULT_CACHE_NAME));
        assertFalse(clientCluster.isWalEnabled(DEFAULT_CACHE_NAME));
        assertFalse(igniteCluster.isWalEnabled(DEFAULT_CACHE_NAME));
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) IgniteCluster(org.apache.ignite.IgniteCluster) ClientCluster(org.apache.ignite.client.ClientCluster) Test(org.junit.Test)

Aggregations

ClientCluster (org.apache.ignite.client.ClientCluster)3 IgniteClient (org.apache.ignite.client.IgniteClient)3 IgniteCluster (org.apache.ignite.IgniteCluster)2 Test (org.junit.Test)2 ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)1 ThinClientConfiguration (org.apache.ignite.configuration.ThinClientConfiguration)1 Test (org.junit.jupiter.api.Test)1