/** * Print cluster state. * * @param client Client. * @throws Throwable If failed to print state. */ private void state(GridClient client) throws Throwable { try { GridClientClusterState state = client.state(); log("Cluster is " + (state.active() ? "active" : "inactive")); } catch (Throwable e) { log("Failed to get cluster state."); throw e; } }
/** * Activate cluster. * * @param client Client. * @throws GridClientException If failed to activate. */ private void activate(GridClient client) throws Throwable { try { GridClientClusterState state = client.state(); state.active(true); log("Cluster activated"); } catch (Throwable e) { log("Failed to activate cluster."); throw e; } }
/** * Deactivate cluster. * * @param client Client. * @throws Throwable If failed to deactivate. */ private void deactivate(GridClient client) throws Throwable { try { GridClientClusterState state = client.state(); state.active(false); log("Cluster deactivated"); } catch (Throwable e) { log("Failed to deactivate cluster."); throw e; } }
/** */ private void deactivateThroughClient() throws Exception { GridClientConfiguration clientCfg = new GridClientConfiguration(); clientCfg.setServers(Collections.singletonList("127.0.0.1:11211")); try (GridClient client = GridClientFactory.start(clientCfg)) { GridClientClusterState state = client.state(); log.info(">>> Try to deactivate ..."); state.active(false); } } }
/** * */ @Test public void testActivateDeActivate() throws GridClientException { GridClientClusterState state = client.state(); boolean active = state.active(); assertTrue(active); state.active(false); IgniteEx ig1 = grid(0); IgniteEx ig2 = grid(1); assertFalse(ig1.active()); assertFalse(ig2.active()); assertFalse(state.active()); state.active(true); assertTrue(ig1.active()); assertTrue(ig2.active()); assertTrue(state.active()); } }
/** * Activate cluster. * * @param client Client. * @throws GridClientException If failed to activate. */ private void activate(GridClient client) throws Throwable { try { GridClientClusterState state = client.state(); state.active(true); log("Cluster activated"); } catch (Throwable e) { log("Failed to activate cluster."); throw e; } }
/** * Print cluster state. * * @param client Client. * @throws Throwable If failed to print state. */ private void state(GridClient client) throws Throwable { try { GridClientClusterState state = client.state(); log("Cluster is " + (state.active() ? "active" : "inactive")); } catch (Throwable e) { log("Failed to get cluster state."); throw e; } }
/** * Deactivate cluster. * * @param client Client. * @throws Throwable If failed to deactivate. */ private void deactivate(GridClient client) throws Throwable { try { GridClientClusterState state = client.state(); state.active(false); log("Cluster deactivated"); } catch (Throwable e) { log("Failed to deactivate cluster."); throw e; } }