This closes #1167
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractApplication.java b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractApplication.java
index b05837c..f291367 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractApplication.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractApplication.java
@@ -198,7 +198,11 @@
@Override
public void logApplicationLifecycle(String message) {
- log.info(message+" application " + this);
+ if (getParent()==null) {
+ log.info(message + " application " + this);
+ } else {
+ log.debug(message + " nested application " + this);
+ }
}
protected void doStart(Collection<? extends Location> locations) {
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
index ab32910..dac5a4e 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
@@ -288,7 +288,7 @@
private AttributeMap attributesInternal = new AttributeMap(this);
protected transient volatile SubscriptionTracker _subscriptionTracker;
-
+
public AbstractEntity() {
this(Maps.newLinkedHashMap(), null);
}
@@ -388,7 +388,7 @@
displayName.set((String) flags.remove("name"));
displayNameAutoGenerated = false;
} else if (isLegacyConstruction()) {
- displayName.set(getClass().getSimpleName()+":"+Strings.maxlen(getId(), 4));
+ displayName.set(getAutogeneratedDefaultDisplayName());
displayNameAutoGenerated = true;
}
@@ -430,6 +430,16 @@
return this;
}
+ private String getAutogeneratedDefaultDisplayName() {
+ String simpleName;
+ if (getEntityType()!=null && Strings.isNonBlank(getEntityType().getSimpleName())) {
+ simpleName = getEntityType().getSimpleName();
+ } else {
+ simpleName = getClass().getSimpleName();
+ }
+ return simpleName + ":" + Strings.maxlen(getId(), 4);
+ }
+
/**
* Adds the config keys to the entity dynamic type
* @since 0.9.0
@@ -480,7 +490,7 @@
super.setManagementContext(managementContext);
getManagementSupport().setManagementContext(managementContext);
entityType.setName(getEntityTypeName());
- if (displayNameAutoGenerated) displayName.set(getEntityType().getSimpleName()+":"+Strings.maxlen(getId(), 4));
+ if (displayNameAutoGenerated) displayName.set(getAutogeneratedDefaultDisplayName());
}
/**
@@ -1298,7 +1308,11 @@
* Cannot be used in combination with overriding the deprecated toStringFieldsToInclude.
*/
protected ToStringHelper toStringHelper() {
- return Objects.toStringHelper(this).omitNullValues().add("id", getId());
+ ToStringHelper result = Objects.toStringHelper(this).omitNullValues().add("id", getId());
+ if (!displayNameAutoGenerated && !Objects.equal(getDisplayName(), getAutogeneratedDefaultDisplayName())) {
+ result.add("name", getDisplayName());
+ }
+ return result;
}
// -------- INITIALIZATION --------------
@@ -1728,7 +1742,7 @@
public void onManagementStarting() {
if (isLegacyConstruction()) {
entityType.setName(getEntityTypeName());
- if (displayNameAutoGenerated) displayName.set(getEntityType().getSimpleName()+":"+Strings.maxlen(getId(), 4));
+ if (displayNameAutoGenerated) displayName.set(getAutogeneratedDefaultDisplayName());
}
}
diff --git a/core/src/main/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocation.java b/core/src/main/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocation.java
index 30cd02e..8656f5d 100644
--- a/core/src/main/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocation.java
+++ b/core/src/main/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocation.java
@@ -78,6 +78,8 @@
public static final ConfigKey<Boolean> SKIP_ON_BOX_BASE_DIR_RESOLUTION = ConfigKeys.newConfigKeyWithDefault(
BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION,
true);
+
+ public static final ConfigKey<Boolean> KEEP_MACHINES = ConfigKeys.newBooleanConfigKey("keep_machines", "Whether by default to keep localhost machine instances available for re-use or to unmanage them", false);
@SetFromFlag("count")
int initialCount;
@@ -256,6 +258,12 @@
for (int p: portsObtained)
releasePort(null, p);
+
+ // prior to 2021-04 we kept the released machines in the queue
+ // this is now governed by a flag; tests that care should set this flag!
+ if (!config().get(KEEP_MACHINES)) {
+ this.removeChild(machine);
+ }
}
public static class LocalhostMachine extends SshMachineLocation implements HasSubnetHostname {