Index: modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java (revision 6e36a7950db84913ddfd0d98f5a0b50923d2a29c) +++ modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java (revision 21f5bf1c7ff9d701dfcba77183ec3b8836784d26) @@ -17,8 +17,11 @@ package org.apache.ignite.internal.processors.rest; +import java.util.Map; +import java.util.concurrent.TimeUnit; 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 +31,26 @@ /** */ 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. * @@ -48,6 +62,39 @@ startGrid(i); stopGrid(0); + } + finally { + stopAllGrids(); + } + } + + /** + * 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(0 == ((Map)GridTestUtils.getFieldValue(rest, "handlers")).size()); + } + + client = true; + + startGrid(clnIdx); + + GridRestProcessor rest = grid(GRID_CNT - 1).context().rest(); + + // Check that rest processer doesn't start. + assertNotNull(rest); + assertEquals(0, ((Map)GridTestUtils.getFieldValue(rest, "handlers")).size()); } finally { stopAllGrids(); \ No newline at end of file Index: modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java (revision 6e36a7950db84913ddfd0d98f5a0b50923d2a29c) +++ modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java (revision 8f34e2cd6346b6b90eebb53930edd5044585d8af) @@ -75,6 +75,7 @@ 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,14 @@ /** {@inheritDoc} */ @Override public void start() throws IgniteCheckedException { if (isRestEnabled()) { + if (notStartOnClient()) { + if (log.isInfoEnabled()) + log.info("REST protocols have not been started. For start the protocols on a client node add " + + "-DIGNITE_REST_START_ON_CLIENT=true"); + + return; + } + // Register handlers. addHandler(new GridCacheCommandHandler(ctx)); addHandler(new GridTaskCommandHandler(ctx)); @@ -469,6 +478,13 @@ } } } + } + + /** + * @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} */ Index: modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java (revision 6e36a7950db84913ddfd0d98f5a0b50923d2a29c) +++ modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java (revision 8f34e2cd6346b6b90eebb53930edd5044585d8af) @@ -179,6 +179,7 @@ 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; @@ -1629,7 +1630,16 @@ 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(); } /** Index: modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java (revision 6e36a7950db84913ddfd0d98f5a0b50923d2a29c) +++ modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java (revision 8f34e2cd6346b6b90eebb53930edd5044585d8af) @@ -110,6 +110,12 @@ 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.