ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [1/2] ignite git commit: IGNITE-2456 Added agent version check.
Date Thu, 28 Jan 2016 09:37:13 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 9ea0dbead -> 0f6b2d64a


IGNITE-2456 Added agent version check.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/43d8360d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/43d8360d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/43d8360d

Branch: refs/heads/ignite-843-rc2
Commit: 43d8360dbc273c6c750963ca593cdd5a532d035a
Parents: 66db273
Author: Andrey <anovikov@gridgain.com>
Authored: Thu Jan 28 16:37:45 2016 +0700
Committer: Andrey <anovikov@gridgain.com>
Committed: Thu Jan 28 16:37:45 2016 +0700

----------------------------------------------------------------------
 .../console/agent/AgentConfiguration.java       | 15 +++++++
 .../ignite/console/agent/AgentSocket.java       |  3 +-
 .../console/agent/remote/RemoteHandler.java     | 12 +++++-
 .../src/main/js/agents/agent-manager.js         | 40 ++++++++++++-------
 .../src/main/js/routes/agent.js                 | 42 ++++++++++++--------
 5 files changed, 79 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/43d8360d/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/AgentConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/AgentConfiguration.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/AgentConfiguration.java
index 6259cca..00af4a7 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/AgentConfiguration.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/AgentConfiguration.java
@@ -75,6 +75,9 @@ public class AgentConfiguration {
         "      Default value: ./jdbc-drivers")
     private String driversFolder;
 
+    /** Release date. */
+    private long relDate;
+
     /** */
     @Parameter(names = { "-h", "--help" }, help = true, description = "Print this help message")
     private Boolean help;
@@ -157,6 +160,13 @@ public class AgentConfiguration {
     }
 
     /**
+     * @return Release date.
+     */
+    public long relDate() {
+        return relDate;
+    }
+
+    /**
      * @return {@code true} If agent options usage should be printed.
      */
     public Boolean help() {
@@ -192,6 +202,11 @@ public class AgentConfiguration {
 
         if (val != null)
             driversFolder(val);
+
+        Long relDate = (Long)props.remove("rel-date");
+
+        if (relDate != null)
+            this.relDate = relDate;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/43d8360d/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/AgentSocket.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/AgentSocket.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/AgentSocket.java
index 80816fa..ae6da07 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/AgentSocket.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/AgentSocket.java
@@ -81,7 +81,7 @@ public class AgentSocket implements WebSocketSender {
      */
     @OnWebSocketClose
     public void onClose(int statusCode, String reason) {
-        log.warn(String.format("Connection closed: %d - %s.", statusCode, reason));
+        log.error(String.format("Connection closed: %d - %s.", statusCode, reason));
 
         if (remote != null)
             remote.close();
@@ -104,6 +104,7 @@ public class AgentSocket implements WebSocketSender {
 
         authMsg.addProperty("type", "AuthMessage");
         authMsg.addProperty("token", cfg.token());
+        authMsg.addProperty("relDate", cfg.relDate());
 
         send(authMsg);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/43d8360d/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/remote/RemoteHandler.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/remote/RemoteHandler.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/remote/RemoteHandler.java
index ac28a96..11e35e3 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/remote/RemoteHandler.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/console/agent/remote/RemoteHandler.java
@@ -30,6 +30,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.RejectedExecutionException;
+
 import org.apache.http.auth.AuthenticationException;
 import org.apache.log4j.Logger;
 
@@ -156,8 +158,14 @@ public class RemoteHandler implements AutoCloseable {
             }
         };
 
-        if (desc.async)
-            executorSrvc.submit(run);
+        if (desc.async) {
+            try {
+                executorSrvc.submit(run);
+            }
+            catch (RejectedExecutionException ignore) {
+                // No-op.
+            }
+        }
         else
             run.run();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/43d8360d/modules/control-center-web/src/main/js/agents/agent-manager.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/agents/agent-manager.js b/modules/control-center-web/src/main/js/agents/agent-manager.js
index eeb2cae..a6daab7 100644
--- a/modules/control-center-web/src/main/js/agents/agent-manager.js
+++ b/modules/control-center-web/src/main/js/agents/agent-manager.js
@@ -271,24 +271,36 @@ Client.prototype._invokeRmtMethod = function(method, args, callback)
{
 Client.prototype._rmtAuthMessage = function(msg) {
     var self = this;
 
-    db.Account.findOne({ token: msg.token }, function (err, account) {
-        if (err) {
-            self.authResult('Failed to authorize user');
-            // TODO IGNITE-1379 send error to web master.
-        }
-        else if (!account)
-            self.authResult('Invalid token, user not found');
-        else {
-            self.authResult(null);
+    var fs = require('fs');
 
-            self._user = account;
+    fs.stat('public/agent/ignite-web-agent-1.5.0.final.zip', function(err, stats) {
+        var relDate = 0;
 
-            self._manager._addClient(account._id, self);
+        if (!err)
+            relDate = stats.birthtime;
 
-            self._cluster = new apacheIgnite.Ignite(new AgentServer(self));
+        if (msg.relDate < relDate)
+            self.authResult('Used old version on agent. Please reload agent archive');
 
-            self._demo = new apacheIgnite.Ignite(new AgentServer(self, true));
-        }
+        db.Account.findOne({ token: msg.token }, function (err, account) {
+            if (err) {
+                self.authResult('Failed to authorize user');
+                // TODO IGNITE-1379 send error to web master.
+            }
+            else if (!account)
+                self.authResult('Invalid token, user not found');
+            else {
+                self.authResult(null);
+
+                self._user = account;
+
+                self._manager._addClient(account._id, self);
+
+                self._cluster = new apacheIgnite.Ignite(new AgentServer(self));
+
+                self._demo = new apacheIgnite.Ignite(new AgentServer(self, true));
+            }
+        });
     });
 };
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/43d8360d/modules/control-center-web/src/main/js/routes/agent.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/agent.js b/modules/control-center-web/src/main/js/routes/agent.js
index b3d94db..e6bf001 100644
--- a/modules/control-center-web/src/main/js/routes/agent.js
+++ b/modules/control-center-web/src/main/js/routes/agent.js
@@ -55,32 +55,42 @@ router.get('/download/zip', function (req, res) {
 
     var agentFld = 'ignite-web-agent-1.5.0.final';
     var agentZip = agentFld + '.zip';
+    var agentPathZip = 'public/agent/' + agentFld + '.zip';
 
-    // Read a zip file.
-    fs.readFile('public/agent/' + agentZip, function(err, data) {
+    fs.stat(agentPathZip, function(err, stats) {
         if (err)
-            return res.download('public/agent/' + agentZip, agentZip);
+            return res.download(agentPathZip, agentZip);
 
-        var zip = new JSZip(data);
+        // Read a zip file.
+        fs.readFile(agentPathZip, function(err, data) {
+            if (err)
+                return res.download(agentPathZip, agentZip);
 
-        var prop = [];
+            var zip = new JSZip(data);
 
-        var host = req.hostname.match(/:/g) ? req.hostname.slice(0, req.hostname.indexOf(':'))
: req.hostname;
+            var prop = [];
 
-        prop.push('token=' + req.user.token);
-        prop.push('server-uri=wss://' + host + ':' + config.get('agent-server:port'));
-        prop.push('#Uncomment following options if needed:');
-        prop.push('#node-uri=http://localhost:8080');
-        prop.push('#driver-folder=./jdbc-drivers');
+            var host = req.hostname.match(/:/g) ? req.hostname.slice(0, req.hostname.indexOf(':'))
: req.hostname;
 
-        zip.file(agentFld + '/default.properties', prop.join('\n'));
+            prop.push('token=' + req.user.token);
+            prop.push('server-uri=wss://' + host + ':' + config.get('agent-server:port'));
+            prop.push('#Uncomment following options if needed:');
+            prop.push('#node-uri=http://localhost:8080');
+            prop.push('#driver-folder=./jdbc-drivers');
+            prop.push('#driver-folder=./jdbc-drivers');
+            prop.push('');
+            prop.push("#Note: Don't change this auto generated line");
+            prop.push('rel-date=' + stats.birthtime.getTime());
 
-        var buffer = zip.generate({type: 'nodebuffer', platform: 'UNIX'});
+            zip.file(agentFld + '/default.properties', prop.join('\n'));
 
-        // Set the archive name.
-        res.attachment(agentZip);
+            var buffer = zip.generate({type: 'nodebuffer', platform: 'UNIX'});
 
-        res.send(buffer);
+            // Set the archive name.
+            res.attachment(agentZip);
+
+            res.send(buffer);
+        });
     });
 });
 


Mime
View raw message