<T> void setConfig(ConfigKey<T> key, T value) { ((EntityLocal)getEntity()).setConfig(key, value); }
<T> T getConfig(ConfigKey<T> key) { return getEntity().getConfig(key); }
<T> T getConfig(HasConfigKey<T> key) { return getEntity().getConfig(key); }
/** mode NONE cannot set a JMX (RMI server) port; it needs an RMI registry port, * then gets redirected to an anonymous RMI server port; * both the hostname and the anonymous port must be accessible to use this mode * (hence the use of the other agents in most cases) */ protected int fixPortsForModeNone() { assert getJmxAgentMode()==JmxAgentModes.NONE; Integer jmxRemotePort = getEntity().getAttribute(JMX_PORT); Integer rmiRegistryPort = getEntity().getAttribute(RMI_REGISTRY_PORT); if (rmiRegistryPort!=null && rmiRegistryPort>0) { if (jmxRemotePort==null || jmxRemotePort!=rmiRegistryPort) { if (jmxRemotePort!=null && jmxRemotePort>0) { // ignore RMI registry port when mode 'none' is set -- set same as JMX port here // (bit irritating, but JMX_PORT will be ignored in this mode) log.warn("Ignoring JMX_PORT "+jmxRemotePort+" when configuring agentless JMX on "+getEntity()+"; will use RMI_REGISTRY_PORT "+rmiRegistryPort); } jmxRemotePort = rmiRegistryPort; ((EntityLocal)getEntity()).setAttribute(JMX_PORT, jmxRemotePort); } } else { if (jmxRemotePort==null || jmxRemotePort<=0) { throw new IllegalStateException("Invalid JMX_PORT "+jmxRemotePort+" and RMI_REGISTRY_PORT "+rmiRegistryPort+" when configuring JMX "+getJmxAgentMode()+" on "+getEntity()); } ((EntityLocal)getEntity()).setAttribute(RMI_REGISTRY_PORT, jmxRemotePort); } return jmxRemotePort; }
String hostName = getEntity().getAttribute(Attributes.HOSTNAME); if (hostName==null) hostName = checkNotNull(getMachine().get().getAddress().getHostName(), "hostname for entity " + entity); jmxRemotePort = getEntity().getAttribute(JMX_PORT); if (jmxRemotePort==null || jmxRemotePort<=0) throw new IllegalStateException("Unsupported JMX port "+jmxRemotePort+" - when applying system properties ("+getJmxAgentMode()+" / "+getEntity()+")"); result.put(JmxmpAgent.JMXMP_PORT_PROPERTY, jmxRemotePort); break; case JMX_RMI_CUSTOM_AGENT: jmxRemotePort = getEntity().getAttribute(JMX_PORT); if (jmxRemotePort==null || jmxRemotePort<=0) throw new IllegalStateException("Unsupported JMX port "+jmxRemotePort+" - when applying system properties ("+getJmxAgentMode()+" / "+getEntity()+")"); result.put(JmxRmiAgent.RMI_REGISTRY_PORT_PROPERTY, Preconditions.checkNotNull(entity.getAttribute(UsesJmx.RMI_REGISTRY_PORT), "registry port")); break; default: throw new IllegalStateException("Unsupported JMX mode - when applying system properties ("+getJmxAgentMode()+" / "+getEntity()+")");