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-843 Fixed agent run under mac os.
Date Wed, 14 Oct 2015 08:05:27 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc1 7445a723b -> 173f565b5


IGNITE-843 Fixed agent run under mac os.


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

Branch: refs/heads/ignite-843-rc1
Commit: 3d0fc59d02a072ec37170ce14b6770ca98fc1ea6
Parents: 419f6cf
Author: Andrey <anovikov@gridgain.com>
Authored: Wed Oct 14 15:05:09 2015 +0700
Committer: Andrey <anovikov@gridgain.com>
Committed: Wed Oct 14 15:05:09 2015 +0700

----------------------------------------------------------------------
 .../bin/ignite-web-agent.sh                     |  2 ++
 .../org/apache/ignite/agent/AgentLauncher.java  |  8 ++++-
 .../org/apache/ignite/agent/AgentUtils.java     | 35 ++++++++++++++++++++
 .../agent/testdrive/AgentMetadataTestDrive.java | 13 +++++---
 4 files changed, 53 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3d0fc59d/modules/control-center-agent/bin/ignite-web-agent.sh
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/bin/ignite-web-agent.sh b/modules/control-center-agent/bin/ignite-web-agent.sh
index 9acdc5c..a7bae1f 100644
--- a/modules/control-center-agent/bin/ignite-web-agent.sh
+++ b/modules/control-center-agent/bin/ignite-web-agent.sh
@@ -31,4 +31,6 @@ while [ -h "$SOURCE" ]
 
 DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
 
+cd $DIR
+
 java -jar ignite-web-agent-${version}.jar "$@"

http://git-wip-us.apache.org/repos/asf/ignite/blob/3d0fc59d/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
index abfc206..00021de 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
@@ -31,6 +31,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.websocket.client.WebSocketClient;
 
 import static org.apache.ignite.agent.AgentConfiguration.DFLT_SERVER_PORT;
+import static org.apache.ignite.agent.AgentUtils.resolvePath;
 
 /**
  * Control Center Agent launcher.
@@ -67,7 +68,12 @@ public class AgentLauncher {
         AgentConfiguration propCfg = new AgentConfiguration();
 
         try {
-            propCfg.load(new File(prop).toURI().toURL());
+            File f = resolvePath(prop);
+
+            if (f == null)
+                log.log(Level.WARNING, "Failed to find agent property file: '" + prop + "'");
+            else
+                propCfg.load(f.toURI().toURL());
         }
         catch (IOException ignore) {
             if (!AgentConfiguration.DFLT_CFG_PATH.equals(prop))

http://git-wip-us.apache.org/repos/asf/ignite/blob/3d0fc59d/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentUtils.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentUtils.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentUtils.java
index 6ee5633..4efb9c4 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentUtils.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentUtils.java
@@ -69,4 +69,39 @@ public class AgentUtils {
             return null;
         }
     }
+
+    /**
+     * Gets file associated with path.
+     * <p>
+     * First check if path is relative to agent home.
+     * If not, check if path is absolute.
+     * If all checks fail, then {@code null} is returned.
+     * <p>
+     *
+     * @param path Path to resolve.
+     * @return Resolved path as file, or {@code null} if path cannot be resolved.
+     */
+    public static File resolvePath(String path) {
+        assert path != null;
+
+        File home = getAgentHome();
+
+        if (home != null) {
+            File file = new File(home, path);
+
+            if (file.exists())
+                return file;
+        }
+
+        /*
+         * 2. Check given path as absolute.
+         */
+
+        File file = new File(path);
+
+        if (file.exists())
+            return file;
+
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3d0fc59d/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
index 7e80250..3dfd539 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
@@ -26,10 +26,11 @@ import java.sql.SQLException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import org.apache.ignite.agent.AgentUtils;
 import org.h2.tools.RunScript;
 import org.h2.tools.Server;
 
+import static org.apache.ignite.agent.AgentUtils.resolvePath;
+
 /**
  * Test drive for metadata load from database.
  *
@@ -64,10 +65,14 @@ public class AgentMetadataTestDrive {
             try {
                 Connection conn = DriverManager.getConnection("jdbc:h2:mem:test-drive-db;DB_CLOSE_DELAY=-1",
"sa", "");
 
-                File agentHome = AgentUtils.getAgentHome();
+                File sqlScript = resolvePath("test-drive/test-drive.sql");
+
+                if (sqlScript == null) {
+                    log.log(Level.SEVERE, "TEST-DRIVE: Failed to find test drive script file:
test-drive/test-drive.sql");
+                    log.log(Level.SEVERE, "TEST-DRIVE: Test drive for metadata not started");
 
-                File sqlScript = new File(agentHome != null ? new File(agentHome, "test-drive")
: new File("test-drive"),
-                    "test-drive.sql");
+                    return;
+                }
 
                 RunScript.execute(conn, new FileReader(sqlScript));
 


Mime
View raw message