Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
6ecdbf8
IGNITE-12597 : first impl
Vladsz83 Feb 3, 2020
4d4aae0
IGNITE-12597 : + checking of reuse-data-region system property
Feb 4, 2020
f36c579
IGNITE-12597 : + fix in the JMX
Feb 4, 2020
1aac619
IGNITE-12597 : Think is ready except the JMX tests
Vladsz83 Feb 4, 2020
e0f6ac4
IGNITE-12597 : Think the ticket is done. Attempt #1.
Vladsz83 Feb 4, 2020
172c432
IGNITE-12597 : Small fix in messages.
Vladsz83 Feb 4, 2020
9149f0a
IGNITE-12597 : Fixed checking of erase-mem-on-deactivation-flag. Now …
Vladsz83 Feb 5, 2020
9a90f53
IGNITE-12597 : Fixed checking of erase-mem-on-deactivation-flag. Now …
Vladsz83 Feb 5, 2020
4dfd7f8
IGNITE-12597 : Lost fixws after review
Vladsz83 Feb 5, 2020
edd2a52
IGNITE-12597 : fix after review.
Vladsz83 Feb 5, 2020
5d2dc69
deleteme
Vladsz83 Feb 6, 2020
3fa51cc
IGNITE-12597 : fix after review #n.
Vladsz83 Feb 6, 2020
cd26b38
IGNITE-12597 : fix.
Vladsz83 Feb 6, 2020
fbb406f
IGNITE-12597 : Removed checking of reuse-mem-on-deactivate. Useless. …
Vladsz83 Feb 7, 2020
d80a310
IGNITE-12597 : Minor fixes.
Vladsz83 Feb 7, 2020
7f0920c
IGNITE-12597 : Redeem IgniteMXBean
Vladsz83 Feb 7, 2020
64a1f84
IGNITE-12597 : code style
Vladsz83 Feb 7, 2020
ea322f7
IGNITE-12597 : fix force-change-state.
Vladsz83 Feb 7, 2020
f06d4dd
IGNITE-12597 : fix.
Vladsz83 Feb 7, 2020
46635a3
IGNITE-12597 : spell fix.
Vladsz83 Feb 7, 2020
7ff1a3b
IGNITE-12597 : removed exception throwing for the internal calls satb…
Vladsz83 Feb 10, 2020
7b2512a
IGNITE-12646 : checking of deactivation returned
Vladsz83 Feb 10, 2020
7ab3818
IGNITE-12646 : Suggestion of fixing mbean interface IgniteMXBean.
Vladsz83 Feb 11, 2020
fbc2de5
IGNITE-12646 : + some javadoc
Vladsz83 Feb 11, 2020
5eef097
IGNITE-12646 : + enchanced javadoc
Vladsz83 Feb 11, 2020
508e35d
IGNITE-12646 : changed IgniteCluster, Ignite, IgniteMXBean
Vladsz83 Feb 12, 2020
b12428f
IGNITE-12646 : another exception
Vladsz83 Feb 13, 2020
4dea12d
IGNITE-12646 : fix of import
Vladsz83 Feb 13, 2020
5520fe8
IGNITE-12646 : first working version of
Vladsz83 Feb 13, 2020
622a9b5
IGNITE-12614 : fixed REST, java tests.
Vladsz83 Feb 14, 2020
8c6f226
IGNITE-12701 : fix after review
Vladsz83 Feb 19, 2020
7ee19a5
IGNITE-12701 : redeem.
Vladsz83 Feb 20, 2020
5dadef1
Merge branch 'master' into IGNITE-12701-2
Vladsz83 Feb 20, 2020
a7e940f
IGNITE-12701 : minor comment fit.
Vladsz83 Feb 20, 2020
6830ec8
IGNITE-12701 : minor fix.
Vladsz83 Feb 20, 2020
bf9ddc2
IGNITE-12701 : review fixes.
Vladsz83 Feb 20, 2020
29f0e62
IGNITE-12701 : back to checking of state change through the discovery.
Vladsz83 Feb 20, 2020
11ae88b
IGNITE-12701 : critical fix.
Vladsz83 Feb 20, 2020
8f9bf80
IGNITE-12701 : codestyle fix.
Vladsz83 Feb 20, 2020
b547ea6
IGNITE-12701 : removed API change.
Vladsz83 Feb 20, 2020
01e7437
IGNITE-12701 : minority.
Vladsz83 Feb 20, 2020
01c3315
IGNITE-12701 : minority review fix.
Vladsz83 Feb 21, 2020
348a657
IGNITE-12701 : last review.
Vladsz83 Feb 21, 2020
d545dec
Merge branch 'master' into IGNITE-12701-3
Vladsz83 Feb 25, 2020
856c9ff
IGNITE-12701 : fix resetting params in the commands.
Vladsz83 Feb 25, 2020
d613f41
Merge branch 'master' into IGNITE-12701-3
Vladsz83 Feb 26, 2020
d2e4c94
IGNITE-12701 : attempt to fix nodeJS thin client test
Vladsz83 Feb 26, 2020
7d9c80e
IGNITE-12701 : minority.
Vladsz83 Feb 26, 2020
9721954
IGNITE-12701 : critical fix : checking the feature before deactivation.
Vladsz83 Feb 27, 2020
74c887f
IGNITE-12701 : fixes after review.
Vladsz83 Mar 2, 2020
4c71889
IGNITE-12701 : fixes after review.
Vladsz83 Mar 2, 2020
e4bef99
IGNITE-12701 : fixes after review 2.
Vladsz83 Mar 2, 2020
dead070
IGNITE-12701 : fixes after review 3.
Vladsz83 Mar 2, 2020
af95055
Minor javadoc update.
nizhikov Mar 4, 2020
5b916b4
Update GridClientClusterState.java
nizhikov Mar 4, 2020
4cfa09c
Update GridClientClusterState.java
nizhikov Mar 4, 2020
71eaa94
Update IgniteCluster.java
nizhikov Mar 4, 2020
fe02d6f
Update GridClientConnection.java
nizhikov Mar 4, 2020
f273dd6
IGNITE-12701 : fixes after review 4.
Vladsz83 Mar 4, 2020
ef2ab3b
IGNITE-12701 : fixes after review 5
Vladsz83 Mar 4, 2020
ec3d67a
IGNITE-12701 : ChangeGlobalStateMessage is now forced by default.
Vladsz83 Mar 4, 2020
d982a8b
IGNITE-12701 : minor change of an error message.
Vladsz83 Mar 4, 2020
e476bd0
IGNITE-12701 : fixed after prereview 6
Vladsz83 Mar 4, 2020
280e9a7
IGNITE-12701 : reverted change global state methods.
Vladsz83 Mar 4, 2020
63bd6a9
IGNITE-12701 : reverted proj settings.
Vladsz83 Mar 4, 2020
2f751f5
IGNITE-12701 : reverted proj settings.
Vladsz83 Mar 4, 2020
1de9983
IGNITE-12701 : Fix of comments, spelling, @code True->true / false / …
Vladsz83 Mar 4, 2020
51671d4
IGNITE-12701 : Fix of comments, spelling, @code True->true / false / …
Vladsz83 Mar 4, 2020
285fc7e
IGNITE-12701 : aalse -> false
Vladsz83 Mar 4, 2020
ae802fc
IGNITE-12701 : better 'fails if' description.
Vladsz83 Mar 4, 2020
9ff6109
IGNITE-12701 : better 'fails if' description 2.
Vladsz83 Mar 4, 2020
d15d5db
IGNITE-12701 : breakline.
Vladsz83 Mar 4, 2020
9fc2258
IGNITE-12701 : better see.
Vladsz83 Mar 4, 2020
95d82ef
IGNITE-12701 : better see.
Vladsz83 Mar 4, 2020
415fe1c
IGNITE-12701 : minorities.
Vladsz83 Mar 4, 2020
e062959
IGNITE-12701 : fixed notes of data loss.
Vladsz83 Mar 6, 2020
bdcb997
IGNITE-12703 : fixes after review.
Vladsz83 Mar 9, 2020
d47374b
IGNITE-12703: Same comments.
Vladsz83 Mar 9, 2020
9d80612
IGNITE-12703 + comments
Vladsz83 Mar 10, 2020
27f77f1
IGNITE-12703 : renaming, refactoring.
Vladsz83 Mar 11, 2020
6aad202
IGNITE-12703 : reverted minority.
Vladsz83 Mar 11, 2020
b07817d
IGNITE-12703 : major fix.
Vladsz83 Mar 11, 2020
c9078ca
IGNITE-12703 : + comment.
Vladsz83 Mar 11, 2020
8eea0b3
IGNITE-12703 : + breakline.
Vladsz83 Mar 11, 2020
861b5ec
IGNITE-12703 : removed testInternalForcedDeactivation()
Vladsz83 Mar 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
import static org.apache.ignite.cluster.ClusterState.ACTIVE;
import static org.apache.ignite.cluster.ClusterState.INACTIVE;
import static org.apache.ignite.configuration.WALMode.NONE;
import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
import static org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor.DATA_LOST_ON_DEACTIVATION_WARNING;
import static org.apache.ignite.internal.processors.query.QueryUtils.TEMPLATE_PARTITIONED;
import static org.apache.ignite.internal.processors.query.QueryUtils.TEMPLATE_REPLICATED;
import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_FAILED;
Expand Down Expand Up @@ -254,18 +257,35 @@ private void assertCacheMetrics(String content) throws IOException {
* @throws IOException If parsing failed.
*/
protected JsonNode validateJsonResponse(String content) throws IOException {
return validateJsonResponse(content, false);
}

/**
* Validates JSON response.
*
* @param content Content to check.
* @param errorExpected is error expected.
* @return REST result if {@code errorExpected} is {@code false}. Error instead.
* @throws IOException If parsing failed.
*/
protected JsonNode validateJsonResponse(String content, boolean errorExpected) throws IOException {
assertNotNull(content);
assertFalse(content.isEmpty());

JsonNode node = JSON_MAPPER.readTree(content);

assertTrue("Unexpected error: " + node.get("error").asText(), node.get("error").isNull());
JsonNode errNode = node.get("error");

if (errorExpected)
assertTrue("Expected an error.", !errNode.isNull());
else
assertTrue("Unexpected error: " + errNode.asText(), errNode.isNull());

assertEquals(STATUS_SUCCESS, node.get("successStatus").asInt());

assertNotSame(securityEnabled(), node.get("sessionToken").isNull());

return node.get("response");
return node.get(errorExpected ? "error" : "response");
}

/**
Expand Down Expand Up @@ -887,11 +907,23 @@ public void testGetAndReplace() throws Exception {
public void testDeactivateActivate() throws Exception {
assertClusterState(true);

changeClusterState(GridRestCommand.CLUSTER_SET_STATE, "state", INACTIVE.name());

changeClusterState(GridRestCommand.CLUSTER_SET_STATE, "state", INACTIVE.name(), "force", "true");

changeClusterState(GridRestCommand.CLUSTER_SET_STATE, "state", ACTIVE.name());

changeClusterState(GridRestCommand.CLUSTER_DEACTIVATE);

changeClusterState(GridRestCommand.CLUSTER_DEACTIVATE, "force", "true");

changeClusterState(GridRestCommand.CLUSTER_ACTIVATE);

// same for deprecated.
changeClusterState(GridRestCommand.CLUSTER_INACTIVE);

changeClusterState(GridRestCommand.CLUSTER_INACTIVE, "force", "true");

changeClusterState(GridRestCommand.CLUSTER_ACTIVE);

initCache();
Expand Down Expand Up @@ -3181,16 +3213,37 @@ private void assertClusterState(boolean exp) throws Exception {
* Change cluster state and test new state.
*
* @param cmd Command.
* @param params Arguments for {@code cmd}.
* @throws Exception If failed.
*/
private void changeClusterState(GridRestCommand cmd) throws Exception {
String ret = content(null, cmd);
private void changeClusterState(GridRestCommand cmd, String... params) throws Exception {
String ret = content(null, cmd, params);

JsonNode res = validateJsonResponse(ret);
boolean force = false;

boolean deactivate = cmd == GridRestCommand.CLUSTER_INACTIVE || cmd == GridRestCommand.CLUSTER_DEACTIVATE;

for (int i = 0; i < params.length; ++i) {
String p = params[i];

if ("force".equals(p) && params[i + 1].equals("true"))
force = true;

if (cmd == GridRestCommand.CLUSTER_SET_STATE && p.equals("state"))
deactivate = params[i + 1].equals(INACTIVE.name());
}

boolean errorExpected = !force && deactivate;

JsonNode res = validateJsonResponse(ret, errorExpected);

assertFalse(res.isNull());
assertTrue(res.asText().startsWith(cmd.key()));

assertClusterState(cmd == GridRestCommand.CLUSTER_ACTIVATE || cmd == GridRestCommand.CLUSTER_ACTIVE);
if (errorExpected)
assertTrue(res.asText().contains(DATA_LOST_ON_DEACTIVATION_WARNING));
else
assertTrue(res.asText().startsWith(cmd.key()));

assertClusterState(!deactivate || !force);
}
}
3 changes: 3 additions & 0 deletions modules/core/src/main/java/org/apache/ignite/Ignite.java
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ public <T> IgniteQueue<T> queue(String name, int cap, @Nullable CollectionConfig

/**
* Changes Ignite grid state to active or inactive.
* <p>
* <b>NOTE:</b>
* Deactivation clears in-memory caches (without persistence) including the system caches.
*
* @param active If {@code True} start activation process. If {@code False} start deactivation process.
* @throws IgniteException If there is an already started transaction or lock in the same thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync(Collecti

/**
* Changes Ignite grid state to active or inactive.
* <p>
* <b>NOTE:</b>
* Deactivation clears in-memory caches (without persistence) including the system caches.
*
* @param active If {@code True} start activation process. If {@code False} start deactivation process.
* @throws IgniteException If there is an already started transaction or lock in the same thread.
Expand All @@ -472,6 +475,9 @@ public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync(Collecti

/**
* Changes current cluster state to given {@code newState} cluster state.
* <p>
* <b>NOTE:</b>
* Deactivation clears in-memory caches (without persistence) including the system caches.
*
* @param newState New cluster state.
* @throws IgniteException If there is an already started transaction or lock in the same thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
* Cluster states.
*/
public enum ClusterState {
/** Cluster deactivated. Cache operations aren't allowed. */
/**
* Cluster deactivated. Cache operations aren't allowed.
* <p>
* <b>NOTE:</b>
* Deactivation clears in-memory caches (without persistence) including the system caches.
*/
INACTIVE,

/** Cluster activated. All cache operations are allowed. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.BitSet;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.internal.managers.encryption.GridEncryptionManager;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.communication.tcp.messages.HandshakeWaitMessage;
Expand Down Expand Up @@ -87,6 +88,13 @@ public enum IgniteFeatures {
/** ContinuousQuery with security subject id support. */
CONT_QRY_SECURITY_AWARE(21),

/**
* Preventing loss of in-memory data when deactivating the cluster.
*
* @see ClusterState#INACTIVE
*/
SAFE_CLUSTER_DEACTIVATION(22),

/** Long operations dump timeout. */
LONG_OPERATIONS_DUMP_TIMEOUT(30);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
public interface GridClientClusterState {
/**
* @param active {@code True} activate, {@code False} deactivate.
* @deprecated Use {@link #state()} instead.
* @throws GridClientException If the request to change the cluster state failed.
* @deprecated Use {@link #state(ClusterState, boolean)} instead.
*/
@Deprecated
public void active(boolean active) throws GridClientException;

/**
* @return {@code Boolean} - Current cluster state. {@code True} active, {@code False} inactive.
* @deprecated Use {@link #state(ClusterState)} instead.
* @deprecated Use {@link #state()} instead.
*/
@Deprecated
public boolean active() throws GridClientException;
Expand All @@ -47,9 +48,11 @@ public interface GridClientClusterState {
* Changes cluster state to {@code newState}.
*
* @param newState New cluster state.
* @param forceDeactivation If {@code true}, cluster deactivation will be forced.
* @throws GridClientException If the request to change the cluster state failed.
* @see ClusterState#INACTIVE
*/
public void state(ClusterState newState) throws GridClientException;
public void state(ClusterState newState, boolean forceDeactivation) throws GridClientException;

/**
* Get the cluster name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@
package org.apache.ignite.internal.client.impl;

import java.util.Collection;
import java.util.UUID;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.internal.IgniteFeatures;
import org.apache.ignite.internal.client.GridClientClusterState;
import org.apache.ignite.internal.client.GridClientException;
import org.apache.ignite.internal.client.GridClientNode;
import org.apache.ignite.internal.client.GridClientPredicate;
import org.apache.ignite.internal.client.balancer.GridClientLoadBalancer;
import org.apache.ignite.internal.client.impl.connection.GridClientConnection;

import static org.apache.ignite.cluster.ClusterState.ACTIVE;
import static org.apache.ignite.cluster.ClusterState.INACTIVE;
import static org.apache.ignite.internal.client.util.GridClientUtils.checkFeatureSupportedByCluster;

/**
*
*/
Expand All @@ -50,7 +56,7 @@ public GridClientClusterStateImpl(

/** {@inheritDoc} */
@Override public void active(final boolean active) throws GridClientException {
withReconnectHandling((conn, nodeId) -> conn.changeState(active, nodeId)).get();
state(active ? ACTIVE : INACTIVE, true);
}

/** {@inheritDoc} */
Expand All @@ -64,8 +70,22 @@ public GridClientClusterStateImpl(
}

/** {@inheritDoc} */
@Override public void state(ClusterState newState) throws GridClientException {
withReconnectHandling((con, nodeId) -> con.changeState(newState, nodeId)).get();
@Override public void state(ClusterState newState, boolean forceDeactivation) throws GridClientException {
// Check compatibility of new forced deactivation on all nodes.
UUID oldVerNode = checkFeatureSupportedByCluster(client, IgniteFeatures.SAFE_CLUSTER_DEACTIVATION, false,
false);

if (oldVerNode == null)
withReconnectHandling((con, nodeId) -> con.changeState(newState, nodeId, forceDeactivation)).get();
else {
if (newState == INACTIVE && !forceDeactivation) {
throw new GridClientException("Deactivation stopped. Found a node not supporting checking of " +
"safety of this operation: " + oldVerNode + ". Deactivation clears in-memory caches (without " +
"persistence) including the system caches. To deactivate cluster pass flag 'force'.");
}

withReconnectHandling((con, nodeId) -> con.changeState(newState, nodeId)).get();
}
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.Set;
import java.util.UUID;
import javax.net.ssl.SSLContext;

import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.internal.client.GridClientCacheFlag;
import org.apache.ignite.internal.client.GridClientClosedException;
Expand Down Expand Up @@ -310,25 +309,26 @@ public abstract <R> GridClientFutureAdapter<R> execute(String taskName, Object a
boolean keepBinaries) throws GridClientConnectionResetException, GridClientClosedException;

/**
* Change grid global state.
* Changes grid global state.
*
* @param active Active.
* @param state New cluster state.
* @param destNodeId Destination node id.
* @deprecated Use {@link #changeState(ClusterState, UUID)} instead.
* @throws GridClientConnectionResetException In case of error.
* @throws GridClientClosedException If client was manually closed before request was sent over network.
*/
@Deprecated
public abstract GridClientFuture<?> changeState(boolean active, UUID destNodeId)
throws GridClientClosedException, GridClientConnectionResetException;
public abstract GridClientFuture<?> changeState(ClusterState state, UUID destNodeId)
throws GridClientClosedException, GridClientConnectionResetException;

/**
* Changes grid global state.
*
* @param state New cluster state.
* @param destNodeId Destination node id.
* @param forceDeactivation If {@code true}, cluster deactivation will be forced.
* @throws GridClientConnectionResetException In case of error.
* @throws GridClientClosedException If client was manually closed before request was sent over network.
*/
public abstract GridClientFuture<?> changeState(ClusterState state, UUID destNodeId)
public abstract GridClientFuture<?> changeState(ClusterState state, UUID destNodeId, boolean forceDeactivation)
throws GridClientClosedException, GridClientConnectionResetException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest;
import org.apache.ignite.internal.processors.rest.client.message.GridClientClusterNameRequest;
import org.apache.ignite.internal.processors.rest.client.message.GridClientClusterStateRequest;
import org.apache.ignite.internal.processors.rest.client.message.GridClientClusterStateRequestV2;
import org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeRequest;
import org.apache.ignite.internal.processors.rest.client.message.GridClientMessage;
import org.apache.ignite.internal.processors.rest.client.message.GridClientNodeBean;
Expand All @@ -84,8 +85,6 @@
import org.jetbrains.annotations.Nullable;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.ignite.cluster.ClusterState.ACTIVE;
import static org.apache.ignite.cluster.ClusterState.INACTIVE;
import static org.apache.ignite.internal.client.GridClientCacheFlag.KEEP_BINARIES;
import static org.apache.ignite.internal.client.GridClientCacheFlag.encodeCacheFlags;
import static org.apache.ignite.internal.client.impl.connection.GridClientConnectionCloseReason.CONN_IDLE;
Expand Down Expand Up @@ -817,11 +816,11 @@ private GridClientAuthenticationRequest buildAuthRequest() {
}

/** {@inheritDoc} */
@Override public GridClientFuture<?> changeState(
boolean active,
UUID destNodeId
) throws GridClientClosedException, GridClientConnectionResetException {
return changeState(active ? ACTIVE : INACTIVE, destNodeId);
@Override public GridClientFuture<?> changeState(ClusterState state, UUID destNodeId, boolean forceDeactivation)
throws GridClientClosedException, GridClientConnectionResetException {
assert state != null;

return makeRequest(GridClientClusterStateRequestV2.state(state, forceDeactivation), destNodeId);
}

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