@Override public Integer getOpenWirePort() { return entity.getAttribute(ActiveMQBroker.OPEN_WIRE_PORT); }
@Override public List<String> getEnabledProtocols() { return entity.getAttribute(JavaWebAppSoftwareProcessImpl.ENABLED_PROTOCOLS); }
protected Number recompute() { if (sources.length==0) return null; Double result = 0d; for (Sensor source: sources) { Object value = entity.getAttribute((AttributeSensor) source); if (value==null) return null; result += ((Number)value).doubleValue(); } return result; }
public JmxHelper(EntityLocal entity) { this(toJmxUrl(entity), entity, entity.getAttribute(Attributes.JMX_USER), entity.getAttribute(Attributes.JMX_PASSWORD)); if (entity.getAttribute(UsesJmx.JMX_URL) == null) { entity.setAttribute(UsesJmx.JMX_URL, url); } }
/** constructs a JMX URL suitable for connecting to the given entity, being smart about JMX/RMI vs JMXMP */ public static String toJmxUrl(EntityLocal entity) { String url = entity.getAttribute(UsesJmx.JMX_URL); if (url != null) { return url; } else { new JmxSupport(entity, null).setJmxUrl(); url = entity.getAttribute(UsesJmx.JMX_URL); return Preconditions.checkNotNull(url, "Could not find URL for "+entity); } }
@Override public Integer getKafkaPort() { return getEntity().getAttribute(KafkaBroker.KAFKA_PORT); }
/** @deprecated since 0.6.0, the config key is always used instead of this */ @Deprecated public String getJmxContext() { return !isJmxEnabled() ? null : entity.getAttribute(UsesJmx.JMX_CONTEXT); }
@Override public Integer getZookeeperPort() { return getEntity().getAttribute(KafkaZookeeper.ZOOKEEPER_PORT); }
/** @deprecated since 0.4.0, see {@link #getRmiRegistryPort()} */ @Deprecated public Integer getRmiServerPort() { return !isJmxEnabled() ? -1 : entity.getAttribute(UsesJmx.RMI_SERVER_PORT); }
/** @deprecated since 0.6.0, the config key is always used instead of this */ @Deprecated public Integer getRmiRegistryPort() { return !isJmxEnabled() ? -1 : entity.getAttribute(UsesJmx.RMI_REGISTRY_PORT); }
private synchronized void onMemberAdded() { if (getConfig(USE_SERVICE_STATE_RUNNING)) { Lifecycle status = entity.getAttribute(Attributes.SERVICE_STATE); onServiceState(status); } Boolean isUp = entity.getAttribute(Startable.SERVICE_UP); onServiceUp(isUp); }
private boolean isEntityUp() { if (entity == null) { return false; } else if (entity.getEntityType().getSensors().contains(Startable.SERVICE_UP)) { return Boolean.TRUE.equals(entity.getAttribute(Startable.SERVICE_UP)); } else { return true; } }
public static <T> T apply(EntityLocal entity, AttributeSensorAndConfigKey<?,T> key) { T v = entity.getAttribute(key); if (v!=null) return v; v = key.getAsSensorValue(entity); if (v!=null) entity.setAttribute(key, v); return v; } }
@Override public String get( final String application, final String entityToken, String sensorName) { final EntityLocal entity = brooklyn().getEntity(application, entityToken); Object value = entity.getAttribute(findSensor(entity, sensorName)); return (value != null) ? value.toString() : ""; }
@Override public String apply(DownloadRequirement input) { if (input.getAddonName() == null) { return input.getEntityDriver().getEntity().getAttribute(Attributes.DOWNLOAD_URL); } else { String addon = input.getAddonName(); Map<String, String> addonUrls = input.getEntityDriver().getEntity().getAttribute(Attributes.DOWNLOAD_ADDON_URLS); return (addonUrls != null) ? addonUrls.get(addon) : null; } } },
@Override public boolean isRunning() { return newScript(MutableMap.of("usePidFile", false), CHECK_RUNNING) .body.append("./bin/redis-cli -p " + getEntity().getAttribute(RedisStore.REDIS_PORT) + " ping > /dev/null") .execute() == 0; }
/** * Restarts redis with the current configuration. */ @Override public void stop() { newScript(MutableMap.of("usePidFile", false), STOPPING) .failOnNonZeroResultCode() .body.append("./bin/redis-cli -p " + getEntity().getAttribute(RedisStore.REDIS_PORT) + " shutdown") .execute(); } }
public void setEntity(EntityLocal entity) { super.setEntity(entity); for (Sensor source: sources) { subscribe(entity, source, this); if (source instanceof AttributeSensor) { Object value = entity.getAttribute((AttributeSensor)source); if (value!=null) onEvent(new BasicSensorEvent(source, entity, value)); } } }
private void copyDatabaseConfigScript() { newScript(CUSTOMIZING). body.append("echo copying config script"). execute(); //create the directory String configScriptContents = processTemplate(entity.getAttribute(MySqlNode.TEMPLATE_CONFIGURATION_URL)); Reader configContents = new StringReader(configScriptContents); getMachine().copyTo(configContents, getRunDir() + "/mymysql.cnf"); }
private void copyDatabaseConfigScript() { newScript(CUSTOMIZING). body.append("echo copying server config script"). execute(); //create the directory String configScriptContents = processTemplate(entity.getAttribute(MariaDbNode.TEMPLATE_CONFIGURATION_URL)); Reader configContents = new StringReader(configScriptContents); getMachine().copyTo(configContents, getRunDir() + "/my.cnf"); }