brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [2/7] incubator-brooklyn git commit: jmx agent path is set as a sensor to work across versions
Date Wed, 19 Nov 2014 13:52:34 GMT
jmx agent path is set as a sensor to work across versions

also deprecate a needless inner class (but keep it around for rebinding)


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/2331fbc8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/2331fbc8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/2331fbc8

Branch: refs/heads/master
Commit: 2331fbc89c2a9389afab85301b360d2db23eeba3
Parents: fbfd78f
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Nov 19 10:12:54 2014 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Nov 19 10:13:18 2014 +0000

----------------------------------------------------------------------
 .../src/main/java/brooklyn/entity/java/JmxSupport.java   | 10 ++++++++++
 .../base/src/main/java/brooklyn/entity/java/UsesJmx.java | 11 +++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2331fbc8/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java b/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java
index 0d93d02..bddd85f 100644
--- a/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java
+++ b/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java
@@ -46,6 +46,7 @@ import brooklyn.util.jmx.jmxrmi.JmxRmiAgent;
 import brooklyn.util.maven.MavenArtifact;
 import brooklyn.util.maven.MavenRetriever;
 import brooklyn.util.net.Urls;
+import brooklyn.util.text.Strings;
 
 import com.google.common.base.Preconditions;
 import com.google.common.net.HostAndPort;
@@ -206,6 +207,15 @@ public class JmxSupport implements UsesJmx {
     }
 
     public String getJmxAgentJarDestinationFilePath() {
+        // cache the local path so we continue to work post-rebind to a different version
+        String result = getEntity().getAttribute(JMX_AGENT_LOCAL_PATH);
+        if (Strings.isNonBlank(result)) return result;
+        result = getJmxAgentJarDestinationFilePathDefault();
+        ((EntityInternal)getEntity()).setAttribute(JMX_AGENT_LOCAL_PATH, result);
+        return result;
+    }
+    
+    public String getJmxAgentJarDestinationFilePathDefault() {
         return Urls.mergePaths(getRunDir(), getJmxAgentJarBasename());
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2331fbc8/software/base/src/main/java/brooklyn/entity/java/UsesJmx.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/java/UsesJmx.java b/software/base/src/main/java/brooklyn/entity/java/UsesJmx.java
index ff8164a..778fe1a 100644
--- a/software/base/src/main/java/brooklyn/entity/java/UsesJmx.java
+++ b/software/base/src/main/java/brooklyn/entity/java/UsesJmx.java
@@ -43,7 +43,12 @@ public interface UsesJmx extends UsesJava {
     /** Chosen by Java itself by default, setting this will only have any effect if using
an agent. */
     @SetFromFlag("jmxPort")
     PortAttributeSensorAndConfigKey JMX_PORT = new PortAttributeSensorAndConfigKey(
-            "jmx.direct.port", "JMX direct/private port (e.g. JMX RMI server port, or JMXMP
port, but not RMI registry port)", PortRanges.fromString("31001+")) {
+        "jmx.direct.port", "JMX direct/private port (e.g. JMX RMI server port, or JMXMP port,
but not RMI registry port)", PortRanges.fromString("31001+"));
+    
+    /** @deprecated since 0.7.0, kept for rebinding, use {@link #JMX_PORT} */ @Deprecated
+    PortAttributeSensorAndConfigKey JMX_PORT_LEGACY = new PortAttributeSensorAndConfigKey(
+            "jmx.direct.port.legacy.NOT_USED", "Legacy definition JMX direct/private port
(e.g. JMX RMI server port, or JMXMP port, but not RMI registry port)", PortRanges.fromString("31001+"))
{
+        private static final long serialVersionUID = 3846846080809179437L;
         @Override protected Integer convertConfigToSensor(PortRange value, Entity entity)
{
             // TODO when using JmxAgentModes.NONE we should *not* convert, but leave it null
             // (e.g. to prevent a warning in e.g. ActiveMQIntegrationTest)
@@ -53,7 +58,7 @@ public interface UsesJmx extends UsesJava {
             return super.convertConfigToSensor(value, entity);
         }
     };
-
+    
     /** Well-known port used by Java itself to start the RMI registry where JMX private port
can be discovered, ignored if using JMXMP agent. */
     @SetFromFlag("rmiRegistryPort")
     PortAttributeSensorAndConfigKey RMI_REGISTRY_PORT = ConfigKeys.newPortSensorAndConfigKey(
@@ -100,6 +105,8 @@ public interface UsesJmx extends UsesJava {
     /* Currently these are only used to connect, so only applies where systems set this up
themselves. */
     AttributeSensorAndConfigKey<String, String> JMX_USER = ConfigKeys.newStringSensorAndConfigKey("jmx.user",
"JMX username");
     AttributeSensorAndConfigKey<String, String> JMX_PASSWORD = ConfigKeys.newStringSensorAndConfigKey("jmx.password",
"JMX password");
+    
+    AttributeSensorAndConfigKey<String, String> JMX_AGENT_LOCAL_PATH = ConfigKeys.newStringSensorAndConfigKey("jmx.agent.local.path",
"Path to JMX driver on the local machine");
 
     /*
      * Synopsis of how the keys work for JMX_SSL:


Mime
View raw message