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 2015/05/05 08:56:57 UTC
[11/50] incubator-ignite git commit: # ignite-776 WIP
# ignite-776 WIP
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/895d95bc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/895d95bc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/895d95bc
Branch: refs/heads/ignite-157-2
Commit: 895d95bc919858b18adb19155ab23c8cc1e7fcc1
Parents: 382ca01
Author: Andrey <an...@gridgain.com>
Authored: Wed Apr 29 10:23:36 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Wed Apr 29 10:23:36 2015 +0700
----------------------------------------------------------------------
.../ignite/internal/GridUpdateNotifier.java | 39 ++++++++++++--
.../apache/ignite/internal/IgniteKernal.java | 55 +++++++++-----------
2 files changed, 60 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/895d95bc/modules/core/src/main/java/org/apache/ignite/internal/GridUpdateNotifier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridUpdateNotifier.java b/modules/core/src/main/java/org/apache/ignite/internal/GridUpdateNotifier.java
index a43d30d..dc22128 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridUpdateNotifier.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridUpdateNotifier.java
@@ -59,6 +59,9 @@ class GridUpdateNotifier {
/** Latest version. */
private volatile String latestVer;
+ /** Download url for latest version. */
+ private volatile String downloadUrl;
+
/** HTML parsing helper. */
private final DocumentBuilder documentBuilder;
@@ -208,6 +211,9 @@ class GridUpdateNotifier {
U.cancel(checker);
String latestVer = this.latestVer;
+ String downloadUrl = this.downloadUrl;
+
+ downloadUrl = downloadUrl != null ? downloadUrl : IgniteKernal.SITE;
if (latestVer != null)
if (latestVer.equals(ver)) {
@@ -215,7 +221,7 @@ class GridUpdateNotifier {
throttle(log, false, "Your version is up to date.");
}
else
- throttle(log, true, "New version is available at " + IgniteKernal.SITE + ": " + latestVer);
+ throttle(log, true, "New version is available at " + downloadUrl + ": " + latestVer);
else
if (!reportOnlyNew)
throttle(log, false, "Update status is not available.");
@@ -328,8 +334,11 @@ class GridUpdateNotifier {
log.debug("Failed to connect to Ignite update server. " + e.getMessage());
}
- if (dom != null)
+ if (dom != null) {
latestVer = obtainVersionFrom(dom);
+
+ downloadUrl = obtainDownloadUrlFrom(dom);
+ }
}
}
catch (Exception e) {
@@ -344,7 +353,7 @@ class GridUpdateNotifier {
* @param node W3C DOM node.
* @return Version or {@code null} if one's not found.
*/
- @Nullable private String obtainVersionFrom(Node node) {
+ @Nullable private String obtainMeta(String metaName, Node node) {
assert node != null;
if (node instanceof Element && "meta".equals(node.getNodeName().toLowerCase())) {
@@ -352,7 +361,7 @@ class GridUpdateNotifier {
String name = meta.getAttribute("name");
- if (("version").equals(name)) {
+ if (metaName.equals(name)) {
String content = meta.getAttribute("content");
if (content != null && !content.isEmpty())
@@ -363,7 +372,7 @@ class GridUpdateNotifier {
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
- String ver = obtainVersionFrom(childNodes.item(i));
+ String ver = obtainMeta(metaName, childNodes.item(i));
if (ver != null)
return ver;
@@ -371,5 +380,25 @@ class GridUpdateNotifier {
return null;
}
+
+ /**
+ * Gets the version from the current {@code node}, if one exists.
+ *
+ * @param node W3C DOM node.
+ * @return Version or {@code null} if one's not found.
+ */
+ @Nullable private String obtainVersionFrom(Node node) {
+ return obtainMeta("version", node);
+ }
+
+ /**
+ * Gets the download url from the current {@code node}, if one exists.
+ *
+ * @param node W3C DOM node.
+ * @return download url or {@code null} if one's not found.
+ */
+ @Nullable private String obtainDownloadUrlFrom(Node node) {
+ return obtainMeta("downloadUrl", node);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/895d95bc/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 9347216..d98b023 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
@@ -686,7 +686,32 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
try {
verChecker = new GridUpdateNotifier(gridName, VER_STR, gw, ctx.plugins().allProviders(), false);
- verChecker.checkForNewVersion(execSvc, log);
+ updateNtfTimer = new Timer("ignite-update-notifier-timer");
+
+ // Setup periodic version check.
+ updateNtfTimer.scheduleAtFixedRate(new GridTimerTask() {
+ private boolean first = true;
+
+ @Override public void safeRun() throws InterruptedException {
+ if (!first)
+ verChecker.topologySize(cluster().nodes().size());
+
+ verChecker.checkForNewVersion(execSvc, log);
+
+ // Just wait for 10 secs.
+ Thread.sleep(PERIODIC_VER_CHECK_CONN_TIMEOUT);
+
+ // Report status if one is available.
+ // No-op if status is NOT available.
+ verChecker.reportStatus(log);
+
+ if (first) {
+ first = false;
+
+ verChecker.reportOnlyNew(true);
+ }
+ }
+ }, 0, PERIODIC_VER_CHECK_DELAY);
}
catch (IgniteCheckedException e) {
if (log.isDebugEnabled())
@@ -834,34 +859,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
// Mark start timestamp.
startTime = U.currentTimeMillis();
- // Ack latest version information.
- if (verChecker != null)
- verChecker.reportStatus(log);
-
- if (notifyEnabled) {
- assert verChecker != null;
-
- verChecker.reportOnlyNew(true);
-
- updateNtfTimer = new Timer("ignite-update-notifier-timer");
-
- // Setup periodic version check.
- updateNtfTimer.scheduleAtFixedRate(new GridTimerTask() {
- @Override public void safeRun() throws InterruptedException {
- verChecker.topologySize(cluster().nodes().size());
-
- verChecker.checkForNewVersion(execSvc, log);
-
- // Just wait for 10 secs.
- Thread.sleep(PERIODIC_VER_CHECK_CONN_TIMEOUT);
-
- // Report status if one is available.
- // No-op if status is NOT available.
- verChecker.reportStatus(log);
- }
- }, PERIODIC_VER_CHECK_DELAY, PERIODIC_VER_CHECK_DELAY);
- }
-
String intervalStr = IgniteSystemProperties.getString(IGNITE_STARVATION_CHECK_INTERVAL);
// Start starvation checker if enabled.