You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2018/11/07 14:56:33 UTC

[GitHub] ascrutae commented on a change in pull request #1887: Support for overriding config with agent options

ascrutae commented on a change in pull request #1887: Support for overriding config with agent options
URL: https://github.com/apache/incubator-skywalking/pull/1887#discussion_r231537742
 
 

 ##########
 File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
 ##########
 @@ -84,6 +97,46 @@ public static void initialize() throws ConfigNotFoundException, AgentPackageNotF
         IS_INIT_COMPLETED = true;
     }
 
+    private static void overrideConfigByAgentOptions(String agentOptions) throws IllegalAccessException {
+        Properties properties = new Properties();
+        for (List<String> terms : parseAgentOptions(agentOptions)) {
+            if (terms.size() != 2) {
+                throw new IllegalArgumentException("[" + terms + "] is not a key-value pair.");
+            }
+            properties.put(terms.get(0), terms.get(1));
+        }
+        if (!properties.isEmpty()) {
+            ConfigInitializer.initialize(properties, Config.class);
+        }
+    }
+
+    private static List<List<String>> parseAgentOptions(String agentOptions) {
+        List<List<String>> options = new ArrayList<List<String>>();
+        List<String> terms = new ArrayList<String>();
+        boolean isInQuotes = false;
+        StringBuilder currentTerm = new StringBuilder();
+        for (char c : agentOptions.toCharArray()) {
 
 Review comment:
   Why don't you spilt agent Options by ','

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services