Add initial support for the multiple LTTNG_UST_APP_PATHs
[lttng-ust.git] / src / lib / lttng-ust-java-agent / java / lttng-ust-agent-common / org / lttng / ust / agent / client / LttngTcpSessiondClient.java
index 95376044a0116e52a6eb9f26656d391ac30e9a62..ccffb9d360c691ed8b4fd96b5ebf19fb3002330b 100644 (file)
@@ -36,6 +36,7 @@ public class LttngTcpSessiondClient implements Runnable {
        private static final String SESSION_HOST = "127.0.0.1";
        private static final String ROOT_PORT_FILE = "/var/run/lttng/agent.port";
        private static final String USER_PORT_FILE = "/.lttng/agent.port";
+       private static final String APP_PATH_PORT_FILE = "/agent.port";
        private static final Charset PORT_FILE_ENCODING = Charset.forName("UTF-8");
 
        private static final int PROTOCOL_MAJOR_VERSION = 2;
@@ -179,7 +180,7 @@ public class LttngTcpSessiondClient implements Runnable {
                String lttngUstAppPath = getUstAppPath();
 
                if (lttngUstAppPath != null) {
-                       portToUse = getPortFromFile(lttngUstAppPath + USER_PORT_FILE);
+                       portToUse = getPortFromFile(lttngUstAppPath + APP_PATH_PORT_FILE);
                } else {
                        int rootPort = getPortFromFile(ROOT_PORT_FILE);
                        int userPort = getPortFromFile(getHomePath() + USER_PORT_FILE);
@@ -207,8 +208,16 @@ public class LttngTcpSessiondClient implements Runnable {
                this.outToSessiond = new DataOutputStream(sessiondSock.getOutputStream());
        }
 
-       private static String getUstAppPath() {
-               return System.getenv("LTTNG_UST_APP_PATH");
+       private String getUstAppPath() {
+               String ustAppPath = System.getenv("LTTNG_UST_APP_PATH");
+               if (ustAppPath != null) {
+                       String[] paths = ustAppPath.split(":");
+                       if (paths.length > 1) {
+                               log("':' separator in LTTNG_UST_APP_PATH, only the first path will be used");
+                       }
+                       return paths[0];
+               }
+               return ustAppPath;
        }
 
        private static String getHomePath() {
This page took 0.025685 seconds and 4 git commands to generate.