Repository: ignite Updated Branches: refs/heads/ignite-G-10964 9f0297395 -> c9bff1b37
G-10964 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c9bff1b3 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c9bff1b3 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c9bff1b3 Branch: refs/heads/ignite-G-10964 Commit: c9bff1b37b38044ae892d9a640c1ef107037080f Parents: 9f02973 Author: Anton Vinogradov <[email protected]> Authored: Wed Jan 20 13:17:19 2016 +0300 Committer: Anton Vinogradov <[email protected]> Committed: Wed Jan 20 13:17:19 2016 +0300 ---------------------------------------------------------------------- .../processors/cluster/ClusterProcessor.java | 29 ++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/c9bff1b3/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 79c8590..5ccd680 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 @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Timer; import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteSystemProperties; @@ -57,7 +58,7 @@ public class ClusterProcessor extends GridProcessorAdapter { private IgniteClusterImpl cluster; /** */ - private static volatile boolean notifyEnabled; + private final AtomicBoolean notifyEnabled = new AtomicBoolean(); /** */ @GridToStringExclude @@ -73,8 +74,8 @@ public class ClusterProcessor extends GridProcessorAdapter { public ClusterProcessor(GridKernalContext ctx) { super(ctx); - notifyEnabled = IgniteSystemProperties.getBoolean(IGNITE_UPDATE_NOTIFIER, - Boolean.parseBoolean(IgniteProperties.get("ignite.update.notifier.enabled.by.default"))); + notifyEnabled.set(IgniteSystemProperties.getBoolean(IGNITE_UPDATE_NOTIFIER, + Boolean.parseBoolean(IgniteProperties.get("ignite.update.notifier.enabled.by.default")))); cluster = new IgniteClusterImpl(ctx); } @@ -104,7 +105,7 @@ public class ClusterProcessor extends GridProcessorAdapter { @Nullable @Override public Serializable collectDiscoveryData(UUID nodeId) { HashMap<String, Object> map = new HashMap<>(); - map.put(ATTR_UPDATE_NOTIFIER_STATUS, notifyEnabled); + map.put(ATTR_UPDATE_NOTIFIER_STATUS, notifyEnabled.get()); return map; } @@ -116,13 +117,13 @@ public class ClusterProcessor extends GridProcessorAdapter { Map<String, Object> map = (Map<String, Object>)data; if (map != null && map.containsKey(ATTR_UPDATE_NOTIFIER_STATUS)) - notifyEnabled = (Boolean)map.get(ATTR_UPDATE_NOTIFIER_STATUS); + notifyEnabled.set((Boolean)map.get(ATTR_UPDATE_NOTIFIER_STATUS)); } } /** {@inheritDoc} */ @Override public void onKernalStart() throws IgniteCheckedException { - if (notifyEnabled) { + if (notifyEnabled.get()) { try { verChecker = new GridUpdateNotifier(ctx.gridName(), VER_STR, @@ -133,7 +134,8 @@ public class ClusterProcessor extends GridProcessorAdapter { updateNtfTimer = new Timer("ignite-update-notifier-timer", true); // Setup periodic version check. - updateNtfTimer.scheduleAtFixedRate(new UpdateNotifierTimerTask((IgniteKernal)ctx.grid(), verChecker), + updateNtfTimer.scheduleAtFixedRate( + new UpdateNotifierTimerTask((IgniteKernal)ctx.grid(), verChecker, notifyEnabled), 0, PERIODIC_VER_CHECK_DELAY); } catch (IgniteCheckedException e) { @@ -158,14 +160,14 @@ public class ClusterProcessor extends GridProcessorAdapter { * Disables update notifier. */ public void disableUpdateNotifier() { - notifyEnabled = false; + notifyEnabled.set(false); } /** * @return Update notifier status. */ public boolean updateNotifierEnabled() { - return notifyEnabled; + return notifyEnabled.get(); } /** @@ -191,23 +193,28 @@ public class ClusterProcessor extends GridProcessorAdapter { /** Whether this is the first run. */ private boolean first = true; + /** */ + private final AtomicBoolean notifyEnabled; + /** * Constructor. * * @param kernal Kernal. * @param verChecker Version checker. */ - private UpdateNotifierTimerTask(IgniteKernal kernal, GridUpdateNotifier verChecker) { + private UpdateNotifierTimerTask(IgniteKernal kernal, GridUpdateNotifier verChecker, + AtomicBoolean notifyEnabled) { kernalRef = new WeakReference<>(kernal); log = kernal.context().log(UpdateNotifierTimerTask.class); this.verChecker = verChecker; + this.notifyEnabled = notifyEnabled; } /** {@inheritDoc} */ @Override public void safeRun() throws InterruptedException { - if (!notifyEnabled) + if (!notifyEnabled.get()) return; if (!first) {
