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/01/13 08:30:57 UTC
ignite git commit: ignite-2350
Repository: ignite
Updated Branches:
refs/heads/ignite-2350 [created] 3db0ec54a
ignite-2350
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3db0ec54
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3db0ec54
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3db0ec54
Branch: refs/heads/ignite-2350
Commit: 3db0ec54a830d36b3080faf890faeef142b13fc7
Parents: 457a9ae
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jan 13 10:30:41 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jan 13 10:30:41 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/GridComponent.java | 5 +-
.../apache/ignite/internal/IgniteKernal.java | 36 +++---
.../processors/cluster/ClusterProcessor.java | 48 ++++++-
...UpdateNotifierPerClusterSettingSelfTest.java | 127 +++++++++++++++++++
.../testsuites/IgniteKernalSelfTestSuite.java | 2 +
5 files changed, 199 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3db0ec54/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java b/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
index 0e234cd..9b02f2d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
@@ -40,7 +40,10 @@ public interface GridComponent {
CACHE_PROC,
/** */
- PLUGIN
+ PLUGIN,
+
+ /** */
+ CLUSTER
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/3db0ec54/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 3def718..fc32796 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
@@ -786,7 +786,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
cfg.getMarshaller().setContext(ctx.marshallerContext());
- startProcessor(new ClusterProcessor(ctx));
+ startProcessor(new ClusterProcessor(ctx, notifyEnabled));
fillNodeAttributes(notifyEnabled);
@@ -822,22 +822,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
verChecker = null;
- if (notifyEnabled) {
- try {
- verChecker = new GridUpdateNotifier(gridName, VER_STR, gw, ctx.plugins().allProviders(), false);
-
- updateNtfTimer = new Timer("ignite-update-notifier-timer", true);
-
- // Setup periodic version check.
- updateNtfTimer.scheduleAtFixedRate(new UpdateNotifierTimerTask(this, execSvc, verChecker),
- 0, PERIODIC_VER_CHECK_DELAY);
- }
- catch (IgniteCheckedException e) {
- if (log.isDebugEnabled())
- log.debug("Failed to create GridUpdateNotifier: " + e);
- }
- }
-
// Off-heap processor has no dependencies.
startProcessor(new GridOffHeapProcessor(ctx));
@@ -946,6 +930,24 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
comp.onKernalStart();
}
+ notifyEnabled = ctx.cluster().updateNotifierEnabled();
+
+ if (notifyEnabled) {
+ try {
+ verChecker = new GridUpdateNotifier(gridName, VER_STR, gw, ctx.plugins().allProviders(), false);
+
+ updateNtfTimer = new Timer("ignite-update-notifier-timer", true);
+
+ // Setup periodic version check.
+ updateNtfTimer.scheduleAtFixedRate(new UpdateNotifierTimerTask(this, execSvc, verChecker),
+ 0, PERIODIC_VER_CHECK_DELAY);
+ }
+ catch (IgniteCheckedException e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to create GridUpdateNotifier: " + e);
+ }
+ }
+
// Register MBeans.
registerKernalMBean();
registerLocalNodeMBean();
http://git-wip-us.apache.org/repos/asf/ignite/blob/3db0ec54/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
index a72615c..c6afcbe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
@@ -17,25 +17,39 @@
package org.apache.ignite.internal.processors.cluster;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.cluster.IgniteClusterImpl;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
import org.apache.ignite.lang.IgniteFuture;
+import org.jetbrains.annotations.Nullable;
/**
*
*/
public class ClusterProcessor extends GridProcessorAdapter {
/** */
+ private static final String UPDATE_NOTIFIER_STATUS = "UPDATE_NOTIFIER_STATUS";
+
+ /** */
private IgniteClusterImpl cluster;
+ /** */
+ private boolean notifyEnabled;
+
/**
* @param ctx Kernal context.
+ * @param notifyEnabled Update notifier flag.
*/
- public ClusterProcessor(GridKernalContext ctx) {
+ public ClusterProcessor(GridKernalContext ctx, boolean notifyEnabled) {
super(ctx);
+ this.notifyEnabled = notifyEnabled;
+
cluster = new IgniteClusterImpl(ctx);
}
@@ -54,4 +68,36 @@ public class ClusterProcessor extends GridProcessorAdapter {
return fut != null ? fut : new IgniteFinishedFutureImpl<>();
}
+
+ /** {@inheritDoc} */
+ @Nullable @Override public DiscoveryDataExchangeType discoveryDataType() {
+ return DiscoveryDataExchangeType.CLUSTER;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Serializable collectDiscoveryData(UUID nodeId) {
+ HashMap<String, Object> map = new HashMap<>();
+
+ map.put(UPDATE_NOTIFIER_STATUS, notifyEnabled);
+
+ return map;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void onDiscoveryDataReceived(UUID joiningNodeId, UUID rmtNodeId, Serializable data) {
+ if (joiningNodeId.equals(ctx.localNodeId())) {
+ Map<String, Object> map = (Map<String, Object>)data;
+
+ if (map != null && map.containsKey(UPDATE_NOTIFIER_STATUS))
+ notifyEnabled = (Boolean)map.get(UPDATE_NOTIFIER_STATUS);
+ }
+ }
+
+ /**
+ * @return Update notifier flag.
+ */
+ public boolean updateNotifierEnabled() {
+ return notifyEnabled;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/3db0ec54/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java
new file mode 100644
index 0000000..669d1db
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ */
+public class IgniteUpdateNotifierPerClusterSettingSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private String backup;
+
+ /** */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ backup = System.getProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, backup);
+
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ cfg.setClientMode(client);
+
+ return cfg;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNotifierEnabledForCluster() throws Exception {
+ checkNotifierStatusForCluster(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNotifierDisabledForCluster() throws Exception {
+ checkNotifierStatusForCluster(false);
+ }
+
+ /**
+ * @param enabled Notifier status.
+ * @throws Exception If failed.
+ */
+ private void checkNotifierStatusForCluster(boolean enabled) throws Exception {
+ System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, String.valueOf(enabled));
+
+ IgniteEx grid1 = startGrid(0);
+
+ checkNotifier(grid1, enabled);
+
+ System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, String.valueOf(!enabled));
+
+ IgniteEx grid2 = startGrid(1);
+
+ checkNotifier(grid2, enabled);
+
+ client = true;
+
+ IgniteEx grid3 = startGrid(2);
+
+ checkNotifier(grid3, enabled);
+
+ // Failover.
+ stopGrid(0); // Kill oldest.
+
+ client = false;
+
+ IgniteEx grid4 = startGrid(3);
+
+ checkNotifier(grid4, enabled);
+
+ client = true;
+
+ IgniteEx grid5 = startGrid(4);
+
+ checkNotifier(grid5, enabled);
+ }
+
+ /**
+ * @param ignite Node.
+ * @param expEnabled Expected notifier status.
+ */
+ private void checkNotifier(Ignite ignite, boolean expEnabled) {
+ if (expEnabled)
+ assertNotNull(GridTestUtils.getFieldValue(ignite, IgniteKernal.class, "updateNtfTimer"));
+ else
+ assertNull(GridTestUtils.getFieldValue(ignite, IgniteKernal.class, "updateNtfTimer"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3db0ec54/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
index deb49b7..1dd3be2 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.GridSameVmStartupSelfTest;
import org.apache.ignite.internal.GridSpiExceptionSelfTest;
import org.apache.ignite.internal.GridUpdateNotifierSelfTest;
import org.apache.ignite.internal.GridVersionSelfTest;
+import org.apache.ignite.internal.IgniteUpdateNotifierPerClusterSettingSelfTest;
import org.apache.ignite.internal.managers.GridManagerStopSelfTest;
import org.apache.ignite.internal.managers.communication.GridCommunicationSendMessageSelfTest;
import org.apache.ignite.internal.managers.deployment.GridDeploymentManagerStopSelfTest;
@@ -107,6 +108,7 @@ public class IgniteKernalSelfTestSuite extends TestSuite {
suite.addTestSuite(GridNodeLocalSelfTest.class);
suite.addTestSuite(GridKernalConcurrentAccessStopSelfTest.class);
suite.addTestSuite(GridUpdateNotifierSelfTest.class);
+ suite.addTestSuite(IgniteUpdateNotifierPerClusterSettingSelfTest.class);
suite.addTestSuite(GridLocalEventListenerSelfTest.class);
suite.addTestSuite(IgniteTopologyPrintFormatSelfTest.class);