You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/12/02 09:25:13 UTC
[07/19] ignite git commit: IGNITE-3958 Fixed "Client node should not
start rest processor".
IGNITE-3958 Fixed "Client node should not start rest processor".
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9c6824b4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9c6824b4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9c6824b4
Branch: refs/heads/master
Commit: 9c6824b4f33fbdead64299d9e0c34365d5d4a570
Parents: 7d88c5b
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Thu Nov 24 16:27:05 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Thu Nov 24 16:28:26 2016 +0300
----------------------------------------------------------------------
.../rest/RestProcessorMultiStartSelfTest.java | 48 +++++++++++++++++++-
.../apache/ignite/IgniteSystemProperties.java | 6 +++
.../apache/ignite/internal/IgniteKernal.java | 12 ++++-
.../processors/rest/GridRestProcessor.java | 15 ++++++
4 files changed, 79 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c6824b4/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java
index 7714dbf..5b88079 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java
@@ -17,8 +17,10 @@
package org.apache.ignite.internal.processors.rest;
+import java.util.Map;
import org.apache.ignite.configuration.ConnectorConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
/**
@@ -28,15 +30,26 @@ public class RestProcessorMultiStartSelfTest extends GridCommonAbstractTest {
/** */
private static final int GRID_CNT = 3;
+ /** */
+ private static boolean client = false;
+
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setConnectorConfiguration(new ConnectorConfiguration());
+ cfg.setClientMode(client);
return cfg;
}
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ client = false;
+ }
+
/**
* Test that multiple nodes can start with JETTY enabled.
*
@@ -53,4 +66,37 @@ public class RestProcessorMultiStartSelfTest extends GridCommonAbstractTest {
stopAllGrids();
}
}
-}
\ No newline at end of file
+
+ /**
+ * Test that multiple nodes can start with JETTY enabled.
+ *
+ * @throws Exception If failed.
+ */
+ public void testMultiStartWithClient() throws Exception {
+ try {
+ int clnIdx = GRID_CNT - 1;
+
+ for (int i = 0; i < clnIdx; i++) {
+ startGrid(i);
+
+ GridRestProcessor rest = grid(i).context().rest();
+
+ assertNotNull(rest);
+ assertFalse(((Map)GridTestUtils.getFieldValue(rest, "handlers")).isEmpty());
+ }
+
+ client = true;
+
+ startGrid(clnIdx);
+
+ GridRestProcessor rest = grid(GRID_CNT - 1).context().rest();
+
+ // Check that rest processor doesn't start.
+ assertNotNull(rest);
+ assertTrue(((Map)GridTestUtils.getFieldValue(rest, "handlers")).isEmpty());
+ }
+ finally {
+ stopAllGrids();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c6824b4/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 043c95a..de6cbed 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -110,6 +110,12 @@ public final class IgniteSystemProperties {
public static final String IGNITE_REST_MAX_TASK_RESULTS = "IGNITE_REST_MAX_TASK_RESULTS";
/**
+ * This property allows to override default behavior that rest processor
+ * doesn't start on client node. If set {@code true} than rest processor will be started on client node.
+ */
+ public static final String IGNITE_REST_START_ON_CLIENT = "IGNITE_REST_START_ON_CLIENT";
+
+ /**
* This property defines the maximum number of attempts to remap near get to the same
* primary node. Remapping may be needed when topology is changed concurrently with
* get operation.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c6824b4/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 1963509..ef9c651 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -179,6 +179,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_CONFIG_URL;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_DAEMON;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_NO_ASCII;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_REST_START_ON_CLIENT;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_STARVATION_CHECK_INTERVAL;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SUCCESS_FILE;
@@ -1632,7 +1633,16 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
private boolean isRestEnabled() {
assert cfg != null;
- return cfg.getConnectorConfiguration() != null;
+ return cfg.getConnectorConfiguration() != null &&
+ // By default rest processor doesn't start on client nodes.
+ (!isClientNode() || (isClientNode() && IgniteSystemProperties.getBoolean(IGNITE_REST_START_ON_CLIENT)));
+ }
+
+ /**
+ * @return {@code True} if node client or daemon otherwise {@code false}.
+ */
+ private boolean isClientNode() {
+ return cfg.isClientMode() || cfg.isDaemon();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c6824b4/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index 6d20547..3f04785 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -75,6 +75,7 @@ import org.apache.ignite.plugin.security.SecurityPermission;
import org.apache.ignite.thread.IgniteThread;
import org.jsr166.LongAdder8;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_REST_START_ON_CLIENT;
import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_AUTH_FAILED;
import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_FAILED;
import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_SECURITY_CHECK_FAILED;
@@ -436,6 +437,13 @@ public class GridRestProcessor extends GridProcessorAdapter {
/** {@inheritDoc} */
@Override public void start() throws IgniteCheckedException {
if (isRestEnabled()) {
+ if (notStartOnClient()) {
+ U.quietAndInfo(log, "REST protocols do not start on client node. " +
+ "To start the protocols on client node set '-DIGNITE_REST_START_ON_CLIENT=true' system property.");
+
+ return;
+ }
+
// Register handlers.
addHandler(new GridCacheCommandHandler(ctx));
addHandler(new GridTaskCommandHandler(ctx));
@@ -471,6 +479,13 @@ public class GridRestProcessor extends GridProcessorAdapter {
}
}
+ /**
+ * @return {@code True} if rest processor should not start on client node.
+ */
+ private boolean notStartOnClient() {
+ return ctx.clientNode() && !IgniteSystemProperties.getBoolean(IGNITE_REST_START_ON_CLIENT);
+ }
+
/** {@inheritDoc} */
@Override public void onKernalStart() throws IgniteCheckedException {
if (isRestEnabled()) {