/** @deprecated since 0.6.0 use {@link #toJmxUrl(EntityLocal)} */ public static String toConnectorUrl(EntityLocal entity) { LOG.warn("Using legacy method toConnectorUrl("+entity+") which will only return JMX URLs"); String url = entity.getAttribute(Attributes.JMX_SERVICE_URL); if (url != null) { return url; } else { String host = checkNotNull(entity.getAttribute(Attributes.HOSTNAME)); Integer jmxEntryPort = entity.getAttribute(Attributes.JMX_PORT); if (GroovyJavaMethods.truth(entity.getConfig(UsesJmx.JMX_SSL_ENABLED))) { url = String.format(JMXMP_URL_FORMAT, host, jmxEntryPort); } else { Integer rmiServerPort = entity.getAttribute(Attributes.RMI_REGISTRY_PORT); String context = entity.getAttribute(Attributes.JMX_CONTEXT); url = toConnectorUrl(host, jmxEntryPort, rmiServerPort, context); } if (entity.getEntityType().getSensors().contains(Attributes.JMX_SERVICE_URL)) entity.setAttribute(Attributes.JMX_SERVICE_URL, url); return url; } }
public String getRunDir() { if (runDir == null) { String runBasedir = ((EntityInternal)entity).getManagementContext().getConfig().getFirst("brooklyn.dirs.run"); if (runBasedir == null) runBasedir = DEFAULT_RUN_BASEDIR; if (runBasedir.endsWith(File.separator)) runBasedir.substring(0, runBasedir.length()-1); runDir = elvis(entity.getConfig(SoftwareProcess.SUGGESTED_RUN_DIR), runBasedir+"/"+entity.getApplication().getId()+"/"+"entities"+"/"+ getEntityVersionLabel()+"_"+entity.getId()); } return runDir; }
<T> void setConfig(ConfigKey<T> key, T value) { ((EntityLocal)getEntity()).setConfig(key, value); }
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); } }
@Override public void onException(Exception exception) { log.error("Detected exception while retrieving Windows Performance Counters from entity " + entity.getDisplayName(), exception); for (AttributeSensor attribute : sensorMap.values()) { entity.setAttribute(attribute, null); } } }
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; } }
@Override public List<String> getEnabledProtocols() { return entity.getAttribute(JavaWebAppSoftwareProcessImpl.ENABLED_PROTOCOLS); }
public String getDatadir() { String result = entity.getConfig(MariaDbNode.DATA_DIR); return (result == null) ? "." : result; }
protected void customizeUserCreationScript() { log.info("Copying creation script " + getEntity().toString()); String creationScriptUrl = entity.getConfig(PostgreSqlNode.CREATION_SCRIPT_URL); Reader creationScript; if (creationScriptUrl != null) creationScript = new InputStreamReader(resource.getResourceFromUrl(creationScriptUrl)); else creationScript = new StringReader(entity.getConfig(PostgreSqlNode.CREATION_SCRIPT_CONTENTS)); getMachine().copyTo(creationScript, getRunDir() + "/creation-script.sql"); newScript(CUSTOMIZING).body.append(callPgctl("start", true), sudoAsUser("postgres", getInstallDir() + "/bin/psql -p " + entity.getAttribute(PostgreSqlNode.POSTGRESQL_PORT) + " --file " + getRunDir() + "/creation-script.sql"), callPgctl("stop", true)). failOnNonZeroResultCode().execute(); }
@Override boolean matches(EntityDriver driver, String addon) { String actualType = driver.getEntity().getEntityType().getName(); String actualSimpleType = actualType.substring(actualType.lastIndexOf(".")+1); return addonName.equals(addon) && entityType.equalsIgnoreCase(actualSimpleType); } }
@Override public void postLaunch() { String rootUrl = inferRootUrl(); entity.setAttribute(WebAppService.ROOT_URL, rootUrl); }
public PolicyConfigSummary(EntityLocal entity, Policy policy, ConfigKey<?> config) { super(config); String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); String policyUri = entityUri + "/policies/" + policy.getId(); this.links = ImmutableMap.<String, URI>builder() .put("self", URI.create(policyUri + "/config/" + config.getName())) .put("application", URI.create(applicationUri)) .put("entity", URI.create(entityUri)) .put("policy", URI.create(policyUri)) .build(); }
if (Strings.isNullOrEmpty(managementPassword)) { LOG.debug(this+" has no password specified for "+JBoss7Server.MANAGEMENT_PASSWORD.getName()+"; using a random string"); entity.setConfig(JBoss7Server.MANAGEMENT_PASSWORD, UUID.randomUUID().toString()); String hostname = entity.getAttribute(SoftwareProcess.HOSTNAME); Preconditions.checkNotNull(hostname, "AS 7 entity must set hostname otherwise server will only be visible on localhost");
Networking.checkPortsValid(getPortMap()); if (entity.getConfig(CassandraNode.INITIAL_SEEDS)==null) { if (isClustered()) { entity.setConfig(CassandraNode.INITIAL_SEEDS, DependentConfiguration.attributeWhenReady(entity.getParent(), CassandraCluster.CURRENT_SEEDS)); } else { entity.setConfig(CassandraNode.INITIAL_SEEDS, MutableSet.<Entity>of(entity)); String customSnitchJarUrl = entity.getConfig(CassandraNode.CUSTOM_SNITCH_JAR_URL); if (Strings.isNonBlank(customSnitchJarUrl)) { int lastSlashIndex = customSnitchJarUrl.lastIndexOf("/");
protected void onRestartFailed(String msg) { LOG.warn("ServiceRestarter failed for "+entity+": "+msg); if (getConfig(SET_ON_FIRE_ON_FAILURE)) { entity.setAttribute(Attributes.SERVICE_STATE, Lifecycle.ON_FIRE); } entity.emit(ENTITY_RESTART_FAILED, new FailureDescriptor(entity, msg)); } }
protected String getLogFileLocation() { return getRunDir()+"/"+entity.getId()+".log"; }
final EntityLocal entity = brooklyn().getEntity(application, entityToken); final Effector<?> effector = EffectorUtils.findEffectorMatching(entity.getEntityType().getEffectors(), effectorName, parameters); if (effector == null) { throw WebResourceUtils.notFound("Entity '%s' has no effector with name '%s'", entityToken, effectorName); Task<?> t = entity.invoke(effector, parameters);
public PolicyConfigSummary(ApplicationSummary application, EntityLocal entity, Policy policy, ConfigKey<?> config) { this(entity, policy, config); if (!entity.getApplicationId().equals(application.getInstance().getId())) throw new IllegalStateException("Application "+application+" does not match app "+entity.getApplication()+" of "+entity); }
entity.setDisplayName(memento.getDisplayName()); value = MementoTransformer.transformIdsToLocations(rebindContext, value, type, true); entity.setConfig(key, value); } catch (ClassNotFoundException e) { throw Throwables.propagate(e);
public static void connectJavaAppServerPolicies(EntityLocal entity, Duration windowPeriod) { entity.addEnricher(new TimeFractionDeltaEnricher<Double>(entity, UsesJavaMXBeans.PROCESS_CPU_TIME, UsesJavaMXBeans.PROCESS_CPU_TIME_FRACTION_LAST, TimeUnit.MILLISECONDS)); entity.addEnricher(new RollingTimeWindowMeanEnricher<Double>(entity, UsesJavaMXBeans.PROCESS_CPU_TIME_FRACTION_LAST, UsesJavaMXBeans.PROCESS_CPU_TIME_FRACTION_IN_WINDOW, windowPeriod)); }