protected String getLogFileLocation() { return getRunDir()+"/"+entity.getId()+".log"; }
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(); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public int execute(Map flags2, List<String> script, String summaryForLogging) { Map flags = new LinkedHashMap(); if (!flags2.containsKey(IGNORE_ENTITY_SSH_FLAGS)) flags.putAll(getSshFlags()); flags.putAll(flags2); Map<String, String> environment = (Map<String, String>) ((flags.get("env") != null) ? flags.get("env") : getShellEnvironment()); if (!flags.containsKey("logPrefix")) flags.put("logPrefix", ""+entity.getId()+"@"+getLocation().getDisplayName()); return getMachine().execScript(flags, summaryForLogging, script, environment); }
/** generates a representation for a given config key, * with label inferred from annoation in the entity class, * and links pointing to the entity and the applicaiton */ public static EntityConfigSummary fromEntity(EntityLocal entity, ConfigKey<?> config) { /* * following code nearly there to get the @CatalogConfig annotation * in the class and use that to populate a label */ // EntityDynamicType typeMap = // ((AbstractEntity)entity).getMutableEntityType(); // // above line works if we can cast; line below won't work, but there should some way // // to get back the handle to the spec from an entity local, which then *would* work // EntityTypes.getDefinedEntityType(entity.getClass()); // String label = typeMap.getConfigKeyField(config.getName()); String label = null; Double priority = null; String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); Map<String,URI> links = ImmutableMap.<String, URI>builder() .put("self", URI.create(entityUri + "/config/" + config.getName())) .put("application", URI.create(applicationUri)) .put("entity", URI.create(entityUri)) .build(); return new EntityConfigSummary(config, label, priority, links); }
/** generates a representation for a given config key, * with label inferred from annoation in the entity class, * and links pointing to the entity and the applicaiton */ public static EntityConfigSummary entityConfigSummary(EntityLocal entity, ConfigKey<?> config) { /* * following code nearly there to get the @CatalogConfig annotation * in the class and use that to populate a label */ // EntityDynamicType typeMap = // ((AbstractEntity)entity).getMutableEntityType(); // // above line works if we can cast; line below won't work, but there should some way // // to get back the handle to the spec from an entity local, which then *would* work // EntityTypes.getDefinedEntityType(entity.getClass()); // String label = typeMap.getConfigKeyField(config.getName()); String label = null; Double priority = null; String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); Map<String,URI> links = ImmutableMap.<String, URI>builder() .put("self", URI.create(entityUri + "/config/" + config.getName())) .put("application", URI.create(applicationUri)) .put("entity", URI.create(entityUri)) .build(); return entityConfigSummary(config, label, priority, links); }
public static PolicyConfigSummary policyConfigSummary(BrooklynRestResourceUtils utils, EntityLocal entity, Policy policy, ConfigKey<?> config) { String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); String policyUri = entityUri + "/policies/" + policy.getId(); Map<String, URI> 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(); return new PolicyConfigSummary(config.getName(), config.getTypeName(), config.getDescription(), PolicyConfigResource.getStringValueForDisplay(utils, policy, config.getDefaultValue()), config.isReconfigurable(), links); }
public static EffectorSummary effectorSummary(EntityLocal entity, Effector<?> effector) { String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); return new EffectorSummary(effector.getName(), effector.getReturnTypeName(), ImmutableSet.copyOf(Iterables.transform(effector.getParameters(), new Function<ParameterType<?>, EffectorSummary.ParameterSummary>() { @Override public EffectorSummary.ParameterSummary apply(@Nullable ParameterType<?> parameterType) { return parameterSummary(parameterType); } })), effector.getDescription(), ImmutableMap.of( "self", URI.create(entityUri + "/effectors/" + effector.getName()), "entity", URI.create(entityUri), "application", URI.create(applicationUri) )); }
protected EffectorSummary(EntityLocal entity, Effector<?> effector) { this.name = effector.getName(); this.description = effector.getDescription(); this.returnType = effector.getReturnTypeName(); this.parameters = ImmutableSet.copyOf(Iterables.transform(effector.getParameters(), new Function<ParameterType<?>, ParameterSummary>() { @Override public ParameterSummary apply(@Nullable ParameterType<?> parameterType) { return new ParameterSummary(parameterType); } })); String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); this.links = ImmutableMap.of( "self", URI.create(entityUri + "/effectors/" + effector.getName()), "entity", URI.create(entityUri), "application", URI.create(applicationUri) ); }
@Deprecated public EffectorSummary(ApplicationSummary application, EntityLocal entity, Effector<?> effector) { this.name = effector.getName(); this.description = effector.getDescription(); this.returnType = effector.getReturnTypeName(); this.parameters = ImmutableSet.copyOf(Iterables.transform(effector.getParameters(), new Function<ParameterType<?>, ParameterSummary>() { @Override public ParameterSummary apply(@Nullable ParameterType<?> parameterType) { return new ParameterSummary(parameterType); } })); String applicationUri = "/v1/applications/" + application.getSpec().getName(); String entityUri = applicationUri + "/entities/" + entity.getId(); this.links = ImmutableMap.of( "self", URI.create(entityUri + "/effectors/" + effector.getName()), "entity", URI.create(entityUri), "application", URI.create(applicationUri) ); }
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; }
public void checkJavaHostnameBug() { try { ProcessTaskWrapper<Integer> hostnameLen = DynamicTasks.queue(SshEffectorTasks.ssh("hostname -f | wc | awk '{print $3}'")).block(); if (hostnameLen.getExitCode()==0) { Integer len = Integer.parseInt(hostnameLen.getStdout().trim()); if (len > 63) { // likely to cause a java crash due to java bug 7089443 -- set a new short hostname // http://mail.openjdk.java.net/pipermail/net-dev/2012-July/004603.html String newHostname = "br-"+getEntity().getId(); log.info("Detected likelihood of Java hostname bug with hostname length "+len+" for "+getEntity()+"; renaming "+getMachine()+" to hostname "+newHostname); DynamicTasks.queue(SshEffectorTasks.ssh( "hostname "+newHostname, "echo 127.0.0.1 "+newHostname+" > /etc/hosts").runAsRoot()).block(); } } } catch (Exception e) { log.warn("Error checking/fixing Java hostname bug: "+e, e); } }
format("export JBOSS_PIDFILE=%s/%s", getRunDir(), PID_FILENAME), format("%s/bin/run.sh -Djboss.service.binding.set=%s -Djboss.server.base.dir=$RUN_DIR/server ",getExpandedInstallDir(),PORT_GROUP_NAME) + format("-Djboss.server.base.url=file://$RUN_DIR/server -Djboss.messaging.ServerPeerID=%s ",entity.getId())+ format("-Djboss.boot.server.log.dir=%s/server/%s/log ",getRunDir(),SERVER_TYPE) + format("-b %s %s -c %s ", getBindAddress(), clusterArg,SERVER_TYPE) +