|
@@ -37,7 +37,10 @@ public class ComponentInfo {
|
|
|
private String category;
|
|
|
private boolean deleted;
|
|
|
private String cardinality = "0+";
|
|
|
-
|
|
|
+
|
|
|
+ @XmlElement(name="versionAdvertised")
|
|
|
+ private Boolean versionAdvertisedField;
|
|
|
+
|
|
|
/**
|
|
|
* Technically, no component is required to advertise a version. In practice,
|
|
|
* Components should advertise a version through a mechanism like hdp-select.
|
|
@@ -46,9 +49,11 @@ public class ComponentInfo {
|
|
|
* Whereas clients will advertise the version when INSTALLED.
|
|
|
* Some components do not need to advertise a version because it is either redundant, or they don't have a mechanism
|
|
|
* at the moment. For instance, ZKFC has the same version as NameNode, while AMBARI_METRICS and KERBEROS do not have a mechanism.
|
|
|
+ *
|
|
|
+ * This is the translation of the xml element ["true", "false", null] (note that if a value is not specified,
|
|
|
+ * it will inherit from the parent) into a boolean after actually resolving it.
|
|
|
*/
|
|
|
- @XmlElements(@XmlElement(name = "versionAdvertised"))
|
|
|
- private boolean versionAdvertised = false;
|
|
|
+ private boolean versionAdvertisedInternal = false;
|
|
|
|
|
|
/**
|
|
|
* Used to determine if decommission is allowed
|
|
@@ -139,7 +144,8 @@ public class ComponentInfo {
|
|
|
category = prototype.category;
|
|
|
deleted = prototype.deleted;
|
|
|
cardinality = prototype.cardinality;
|
|
|
- versionAdvertised = prototype.versionAdvertised;
|
|
|
+ versionAdvertisedField = prototype.versionAdvertisedField;
|
|
|
+ versionAdvertisedInternal = prototype.versionAdvertisedInternal;
|
|
|
decommissionAllowed = prototype.decommissionAllowed;
|
|
|
clientsToUpdateConfigs = prototype.clientsToUpdateConfigs;
|
|
|
commandScript = prototype.commandScript;
|
|
@@ -309,12 +315,45 @@ public class ComponentInfo {
|
|
|
return cardinality;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * WARNING: only call this method from unit tests to set the Boolean that would have been read from the xml file.
|
|
|
+ * If you call this function, you must still call {@see org.apache.ambari.server.stack.ComponentModule#resolve()}.
|
|
|
+ * @param versionAdvertisedField
|
|
|
+ */
|
|
|
+ public void setVersionAdvertisedField(Boolean versionAdvertisedField) {
|
|
|
+ this.versionAdvertisedField = versionAdvertisedField;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * WARNING: only call this from ComponentModule to resolve the boolean (true|false).
|
|
|
+ * In all other classes, use {@seealso isVersionAdvertised}
|
|
|
+ * @return The Boolean for versionAdvertised from the xml file in order to resolve it into a boolean.
|
|
|
+ */
|
|
|
+ public Boolean getVersionAdvertisedField() {
|
|
|
+ return this.versionAdvertisedField;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * WARNING: only call this from ComponentModule to resolve the boolean (true|false).
|
|
|
+ * @param versionAdvertised Final resolution of whether version is advertised or not.
|
|
|
+ */
|
|
|
public void setVersionAdvertised(boolean versionAdvertised) {
|
|
|
- this.versionAdvertised = versionAdvertised;
|
|
|
+ this.versionAdvertisedInternal = versionAdvertised;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Determine if this component advertises a version. This Boolean has already resolved to true|false depending
|
|
|
+ * on explicitly overriding the value or inheriting from an ancestor.
|
|
|
+ * @return boolean of whether this component advertises a version.
|
|
|
+ */
|
|
|
public boolean isVersionAdvertised() {
|
|
|
- return versionAdvertised;
|
|
|
+ if (null != versionAdvertisedField) {
|
|
|
+ return versionAdvertisedField.booleanValue();
|
|
|
+ }
|
|
|
+ // If set to null and has a parent, then the value would have already been resolved and set.
|
|
|
+ // Otherwise, return the default value (false).
|
|
|
+ return this.versionAdvertisedInternal;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public String getDecommissionAllowed() {
|
|
@@ -367,7 +406,8 @@ public class ComponentInfo {
|
|
|
if (deleted != that.deleted) return false;
|
|
|
if (autoDeploy != null ? !autoDeploy.equals(that.autoDeploy) : that.autoDeploy != null) return false;
|
|
|
if (cardinality != null ? !cardinality.equals(that.cardinality) : that.cardinality != null) return false;
|
|
|
- if (versionAdvertised != that.versionAdvertised) return false;
|
|
|
+ if (versionAdvertisedField != null ? !versionAdvertisedField.equals(that.versionAdvertisedField) : that.versionAdvertisedField != null) return false;
|
|
|
+ if (versionAdvertisedInternal != that.versionAdvertisedInternal) return false;
|
|
|
if (decommissionAllowed != null ? !decommissionAllowed.equals(that.decommissionAllowed) : that.decommissionAllowed != null) return false;
|
|
|
if (reassignAllowed != null ? !reassignAllowed.equals(that.reassignAllowed) : that.reassignAllowed != null) return false;
|
|
|
if (category != null ? !category.equals(that.category) : that.category != null) return false;
|
|
@@ -397,7 +437,6 @@ public class ComponentInfo {
|
|
|
result = 31 * result + (category != null ? category.hashCode() : 0);
|
|
|
result = 31 * result + (deleted ? 1 : 0);
|
|
|
result = 31 * result + (cardinality != null ? cardinality.hashCode() : 0);
|
|
|
- result = 31 * result + (versionAdvertised ? 1 : 0);
|
|
|
result = 31 * result + (decommissionAllowed != null ? decommissionAllowed.hashCode() : 0);
|
|
|
result = 31 * result + (reassignAllowed != null ? reassignAllowed.hashCode() : 0);
|
|
|
result = 31 * result + (commandScript != null ? commandScript.hashCode() : 0);
|
|
@@ -409,6 +448,8 @@ public class ComponentInfo {
|
|
|
result = 31 * result + (autoDeploy != null ? autoDeploy.hashCode() : 0);
|
|
|
result = 31 * result + (configDependencies != null ? configDependencies.hashCode() : 0);
|
|
|
result = 31 * result + (clientConfigFiles != null ? clientConfigFiles.hashCode() : 0);
|
|
|
+ // NULL = 0, TRUE = 2, FALSE = 1
|
|
|
+ result = 31 * result + (versionAdvertisedField != null ? (versionAdvertisedField.booleanValue() ? 2 : 1) : 0);
|
|
|
return result;
|
|
|
}
|
|
|
|