Skip to content

Commit

Permalink
IGNITE-18348 Replaced deprecated Ignite.active() by Ignite.cluster().…
Browse files Browse the repository at this point in the history
…state() (apache#10440)
  • Loading branch information
J-Bakuli authored Dec 27, 2022
1 parent 8cfa8b0 commit 098e091
Show file tree
Hide file tree
Showing 355 changed files with 1,683 additions and 1,366 deletions.
2 changes: 1 addition & 1 deletion docs/_docs/persistence/native-persistence.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ If the memory-mapped file approach is disabled then the changes stay in node's i
Otherwise, recent data updates may get lost in case of a process crash or other outages.

| `NONE` | WAL is disabled. The changes are persisted only if you shut down the node gracefully.
Use `Ignite.active(false)` to deactivate the cluster and shut down the node.
Use `Ignite.cluster().state(ClusterState.INACTIVE)` to deactivate the cluster and shut down the node.

| Data loss might occur.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.examples.datagrid.CacheQueryExample;
import org.apache.ignite.examples.model.Organization;
Expand Down Expand Up @@ -63,7 +64,7 @@ public static void main(String[] args) throws Exception {
try (Ignite ignite = Ignition.start("examples/config/persistentstore/example-persistent-store.xml")) {
// Activate the cluster. Required to do if the persistent store is enabled because you might need
// to wait while all the nodes, that store a subset of data on disk, join the cluster.
ignite.active(true);
ignite.cluster().state(ClusterState.ACTIVE);

CacheConfiguration<Long, Organization> cacheCfg = new CacheConfiguration<>(ORG_CACHE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
Expand Down Expand Up @@ -114,7 +115,7 @@ private Map<TestResultParameterInfo, Comparable> testGrid() {

Ignite ignite = Ignition.start(getConfiguration(name));

ignite.cluster().active(true);
ignite.cluster().state(ClusterState.ACTIVE);

long start = System.currentTimeMillis();

Expand All @@ -133,7 +134,7 @@ private Map<TestResultParameterInfo, Comparable> testGrid() {

GraphLayout layout = GraphLayout.parseInstance(ignite);

ignite.cluster().active(false);
ignite.cluster().state(ClusterState.INACTIVE);

Ignition.stop(name, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlFunction;
import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.ClientConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
Expand Down Expand Up @@ -78,7 +79,7 @@ public class RunningQueryInfoCheckInitiatorTest extends JdbcThinAbstractSelfTest
startGrid(0);
startClientGrid(1);

grid(0).cluster().active(true);
grid(0).cluster().state(ClusterState.ACTIVE);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ public void testActivateDeActivate() throws GridClientException {
IgniteEx ig1 = grid(0);
IgniteEx ig2 = grid(1);

assertFalse(ig1.active());
assertFalse(ig2.active());
assertFalse(ig1.cluster().state().active());
assertFalse(ig2.cluster().state().active());
assertEquals(INACTIVE, state.state());

state.state(ACTIVE, false);

assertTrue(ig1.active());
assertTrue(ig2.active());
assertTrue(ig1.cluster().state().active());
assertTrue(ig2.cluster().state().active());
assertEquals(ACTIVE, state.state());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ protected void restartGrid() throws Exception {

startGrids(gridCount());

grid(0).cluster().active(true);
grid(0).cluster().state(ClusterState.ACTIVE);

initCache();
}
Expand Down Expand Up @@ -3575,7 +3575,7 @@ private void assertClusterState(boolean exp) throws Exception {
JsonNode res = validateJsonResponse(ret);

assertEquals(ret, exp, res.asBoolean());
assertEquals(ret, exp, grid(0).cluster().active());
assertEquals(ret, exp, grid(0).cluster().state().active());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.concurrent.Callable;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
Expand Down Expand Up @@ -55,7 +56,7 @@ public abstract class JettyRestProcessorAuthenticationAbstractTest extends Jetty
/** {@inheritDoc} */
@Override protected void initCache() {
// We need to activate cluster.
grid(0).cluster().active(true);
grid(0).cluster().state(ClusterState.ACTIVE);

super.initCache();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Collections;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.ignite.cluster.BaselineNode;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
Expand All @@ -48,7 +49,7 @@ public class JettyRestProcessorBaselineSelfTest extends JettyRestProcessorCommon

grid(0).cluster().baselineAutoAdjustEnabled(false);
// We need to activate cluster.
grid(0).cluster().active(true);
grid(0).cluster().state(ClusterState.ACTIVE);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.concurrent.Callable;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
Expand Down Expand Up @@ -67,7 +68,7 @@ public class JdbcThinAuthenticateConnectionSelfTest extends JdbcThinAbstractSelf

startGrids(2);

grid(0).cluster().active(true);
grid(0).cluster().state(ClusterState.ACTIVE);

try (AutoCloseable ignored = withSecurityContextOnAllNodes(authenticate(grid(0), "ignite", "ignite"))) {
grid(0).context().security().createUser("another_user", "passwd".toCharArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -147,7 +148,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name) throws Excep
}
streamer.flush();
}
ignite.active(true);
ignite.cluster().state(ClusterState.ACTIVE);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.sql.Statement;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.ConnectorConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
Expand Down Expand Up @@ -80,15 +81,15 @@ public void testTxRollbackAfterDeactivation() throws Exception {
public void checkTxFinishAfterDeactivation(boolean commit) throws Exception {
IgniteEx node0 = startGrid(0);

node0.cluster().active(true);
node0.cluster().state(ClusterState.ACTIVE);

try (Connection conn = connect()) {
execute(conn, "CREATE TABLE t1(a INT, b VARCHAR, PRIMARY KEY(a)) WITH \"atomicity=TRANSACTIONAL_SNAPSHOT,backups=1\"");
}

final CountDownLatch enlistedLatch = new CountDownLatch(1);

assert node0.cluster().active();
assert node0.cluster().state().active();

IgniteInternalFuture txFinishedFut = GridTestUtils.runAsync(() -> {
executeTransaction(commit, enlistedLatch, () -> !node0.context().state().publicApiActiveState(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.List;
import org.apache.ignite.Ignite;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
Expand Down Expand Up @@ -87,7 +88,7 @@ public class DiskPageCompressionConfigValidationTest extends GridCommonAbstractT
public void testIncorrectDynamicCacheStartRequest() throws Exception {
Ignite ig = startGrid();

ig.cluster().active(true);
ig.cluster().state(ClusterState.ACTIVE);

boolean expEThrown = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
Expand Down Expand Up @@ -90,7 +91,7 @@ protected FileIOFactory getFileIOFactory() {
@Override protected void doTestPageCompression() throws Exception {
IgniteEx ignite = startGrid(0);

ignite.cluster().active(true);
ignite.cluster().state(ClusterState.ACTIVE);

String cacheName = "test";

Expand Down Expand Up @@ -187,7 +188,7 @@ protected FileIOFactory getFileIOFactory() {
public void _testCompressionRatio() throws Exception {
IgniteEx ignite = startGrid(0);

ignite.cluster().active(true);
ignite.cluster().state(ClusterState.ACTIVE);

String cacheName = "test";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public class WalPageCompressionIntegrationTest extends AbstractPageCompressionIn
// Reference ignite instance with uncompressed WAL page records.
IgniteEx ignite1 = startGrid(1);

ignite0.cluster().active(true);
ignite1.cluster().active(true);
ignite0.cluster().state(ClusterState.ACTIVE);
ignite1.cluster().state(ClusterState.ACTIVE);

String cacheName = "test";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.ConnectorConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
Expand Down Expand Up @@ -77,7 +78,7 @@ public abstract class BaselineEventsTest extends GridCommonAbstractTest {
/** */
@Test
public void testChangeBltWithControlUtility() throws Exception {
startGrid(0).cluster().active(true);
startGrid(0).cluster().state(ClusterState.ACTIVE);

AtomicBoolean baselineChanged = new AtomicBoolean();

Expand Down Expand Up @@ -110,7 +111,7 @@ public void testChangeBltWithControlUtility() throws Exception {
/** */
@Test
public void testChangeBltWithPublicApi() throws Exception {
startGrid(0).cluster().active(true);
startGrid(0).cluster().state(ClusterState.ACTIVE);

AtomicBoolean baselineChanged = new AtomicBoolean();

Expand Down Expand Up @@ -150,13 +151,13 @@ public void testDeactivateActivate() throws Exception {
EventType.EVT_BASELINE_CHANGED
);

ignite.cluster().active(true);
ignite.cluster().state(ClusterState.ACTIVE);

assertTrue(GridTestUtils.waitForCondition(baselineChanged::get, 3_000));
baselineChanged.set(false);

ignite.cluster().active(false);
ignite.cluster().active(true);
ignite.cluster().state(ClusterState.INACTIVE);
ignite.cluster().state(ClusterState.ACTIVE);

assertFalse(GridTestUtils.waitForCondition(baselineChanged::get, 3_000));
}
Expand All @@ -166,7 +167,7 @@ public void testDeactivateActivate() throws Exception {
public void testChangeAutoAdjustEnabled() throws Exception {
IgniteClusterEx cluster = startGrids(2).cluster();

cluster.active(true);
cluster.state(ClusterState.ACTIVE);

assertFalse(cluster.isBaselineAutoAdjustEnabled());

Expand Down Expand Up @@ -208,7 +209,7 @@ public void testChangeAutoAdjustEnabled() throws Exception {
public void testChangeAutoAdjustTimeout() throws Exception {
IgniteClusterEx cluster = startGrids(2).cluster();

cluster.active(true);
cluster.state(ClusterState.ACTIVE);

AtomicLong autoAdjustTimeout = new AtomicLong();

Expand Down Expand Up @@ -241,7 +242,7 @@ public void testEventsDisabledByDefault() throws Exception {
includedEvtTypes = new int[0];

IgniteClusterEx cluster = startGrid(0).cluster();
cluster.active(true);
cluster.state(ClusterState.ACTIVE);

AtomicInteger evtsTriggered = new AtomicInteger();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.ignite.cache.QueryIndex;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
Expand Down Expand Up @@ -237,8 +238,8 @@ protected void populateData(IgniteEx node, @Nullable Boolean insert) throws Exce

IgniteClusterEx cluster = node.cluster();

if (!cluster.active())
cluster.active(true);
if (!cluster.state().active())
cluster.state(ClusterState.ACTIVE);

IgniteCache<Integer, Object> qryCache = node.cache(QUERY_CACHE_NAME);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.regex.Pattern;
import org.apache.ignite.Ignite;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.cache.query.index.Index;
Expand Down Expand Up @@ -124,7 +125,7 @@ public void testIndexFindFail() throws Exception {
private void prepareGridForTest() throws Exception {
Ignite ignite = startGrids(2);

ignite.cluster().active(true);
ignite.cluster().state(ClusterState.ACTIVE);

Ignite client = startGrid(CLIENT_NODE_NAME_PREFIX);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.UUID;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.testframework.junits.WithSystemProperty;
Expand Down Expand Up @@ -74,7 +75,7 @@ public class GridCommandHandlerCheckIndexesInlineSizeTest extends GridCommandHan

assertEquals(INITIAL_PAYLOAD_SIZE, Integer.parseInt(System.getProperty(IGNITE_MAX_INDEX_PAYLOAD_SIZE)));

startGrids(NODES_CNT).cluster().active(true);
startGrids(NODES_CNT).cluster().state(ClusterState.ACTIVE);

for (Map.Entry<String, Object[]> entry : getSqlStatements().entrySet())
executeSql(grid(0), entry.getKey(), entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.HashSet;
import java.util.Set;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.IgniteEx;

Expand Down Expand Up @@ -51,7 +52,7 @@ public abstract class GridCommandHandlerClusterByClassAbstractTest extends GridC

client = startGrid(CLIENT_NODE_NAME_PREFIX);

crd.cluster().active(true);
crd.cluster().state(ClusterState.ACTIVE);
}

/** {@inheritDoc} */
Expand Down
Loading

0 comments on commit 098e091

Please sign in to comment.