|
@@ -17,6 +17,8 @@
|
|
|
|
|
|
package org.apache.hadoop.yarn.server.federation.store.records;
|
|
|
|
|
|
+import org.apache.commons.lang3.builder.EqualsBuilder;
|
|
|
+import org.apache.commons.lang3.builder.HashCodeBuilder;
|
|
|
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
|
|
import org.apache.hadoop.classification.InterfaceAudience.Public;
|
|
|
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
|
@@ -43,6 +45,7 @@ public abstract class SubClusterInfo {
|
|
|
|
|
|
@Private
|
|
|
@Unstable
|
|
|
+ @SuppressWarnings("checkstyle:ParameterNumber")
|
|
|
public static SubClusterInfo newInstance(SubClusterId subClusterId,
|
|
|
String amRMServiceAddress, String clientRMServiceAddress,
|
|
|
String rmAdminServiceAddress, String rmWebServiceAddress,
|
|
@@ -54,6 +57,7 @@ public abstract class SubClusterInfo {
|
|
|
|
|
|
@Private
|
|
|
@Unstable
|
|
|
+ @SuppressWarnings("checkstyle:ParameterNumber")
|
|
|
public static SubClusterInfo newInstance(SubClusterId subClusterId,
|
|
|
String amRMServiceAddress, String clientRMServiceAddress,
|
|
|
String rmAdminServiceAddress, String rmWebServiceAddress,
|
|
@@ -252,48 +256,49 @@ public abstract class SubClusterInfo {
|
|
|
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
- return "SubClusterInfo [getSubClusterId() = " + getSubClusterId()
|
|
|
- + ", getAMRMServiceAddress() = " + getAMRMServiceAddress()
|
|
|
- + ", getClientRMServiceAddress() = " + getClientRMServiceAddress()
|
|
|
- + ", getRMAdminServiceAddress() = " + getRMAdminServiceAddress()
|
|
|
- + ", getRMWebServiceAddress() = " + getRMWebServiceAddress()
|
|
|
- + ", getState() = " + getState() + ", getLastStartTime() = "
|
|
|
- + getLastStartTime() + ", getCapability() = " + getCapability() + "]";
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append("SubClusterInfo: [")
|
|
|
+ .append("SubClusterId: ").append(getSubClusterId()).append(", ")
|
|
|
+ .append("AMRMServiceAddress: ").append(getAMRMServiceAddress()).append(", ")
|
|
|
+ .append("ClientRMServiceAddress: ").append(getClientRMServiceAddress()).append(", ")
|
|
|
+ .append("RMAdminServiceAddress: ").append(getRMAdminServiceAddress()).append(", ")
|
|
|
+ .append("RMWebServiceAddress: ").append(getRMWebServiceAddress()).append(", ")
|
|
|
+ .append("State: ").append(getState()).append(", ")
|
|
|
+ .append("LastStartTime: ").append(getLastStartTime()).append(", ")
|
|
|
+ .append("Capability: ").append(getCapability())
|
|
|
+ .append("]");
|
|
|
+ return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean equals(Object obj) {
|
|
|
+
|
|
|
if (this == obj) {
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
if (obj == null) {
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
if (getClass() != obj.getClass()) {
|
|
|
return false;
|
|
|
}
|
|
|
- SubClusterInfo other = (SubClusterInfo) obj;
|
|
|
- if (!this.getSubClusterId().equals(other.getSubClusterId())) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!this.getAMRMServiceAddress().equals(other.getAMRMServiceAddress())) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!this.getClientRMServiceAddress()
|
|
|
- .equals(other.getClientRMServiceAddress())) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!this.getRMAdminServiceAddress()
|
|
|
- .equals(other.getRMAdminServiceAddress())) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!this.getRMWebServiceAddress().equals(other.getRMWebServiceAddress())) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!this.getState().equals(other.getState())) {
|
|
|
- return false;
|
|
|
+
|
|
|
+ if (obj instanceof SubClusterInfo) {
|
|
|
+ SubClusterInfo other = (SubClusterInfo) obj;
|
|
|
+ return new EqualsBuilder()
|
|
|
+ .append(this.getSubClusterId(), other.getSubClusterId())
|
|
|
+ .append(this.getAMRMServiceAddress(), other.getAMRMServiceAddress())
|
|
|
+ .append(this.getClientRMServiceAddress(), other.getClientRMServiceAddress())
|
|
|
+ .append(this.getRMAdminServiceAddress(), other.getRMAdminServiceAddress())
|
|
|
+ .append(this.getRMWebServiceAddress(), other.getRMWebServiceAddress())
|
|
|
+ .append(this.getState(), other.getState())
|
|
|
+ .append(this.getLastStartTime(), other.getLastStartTime())
|
|
|
+ .isEquals();
|
|
|
}
|
|
|
- return this.getLastStartTime() == other.getLastStartTime();
|
|
|
+
|
|
|
+ return false;
|
|
|
// Capability and HeartBeat fields are not included as they are temporal
|
|
|
// (i.e. timestamps), so they change during the lifetime of the same
|
|
|
// sub-cluster
|
|
@@ -301,23 +306,16 @@ public abstract class SubClusterInfo {
|
|
|
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
|
- final int prime = 31;
|
|
|
- int result = 1;
|
|
|
- result = prime * result
|
|
|
- + ((getSubClusterId() == null) ? 0 : getSubClusterId().hashCode());
|
|
|
- result = prime * result + ((getAMRMServiceAddress() == null) ? 0
|
|
|
- : getAMRMServiceAddress().hashCode());
|
|
|
- result = prime * result + ((getClientRMServiceAddress() == null) ? 0
|
|
|
- : getClientRMServiceAddress().hashCode());
|
|
|
- result = prime * result + ((getRMAdminServiceAddress() == null) ? 0
|
|
|
- : getRMAdminServiceAddress().hashCode());
|
|
|
- result = prime * result + ((getRMWebServiceAddress() == null) ? 0
|
|
|
- : getRMWebServiceAddress().hashCode());
|
|
|
- result =
|
|
|
- prime * result + ((getState() == null) ? 0 : getState().hashCode());
|
|
|
- result = prime * result
|
|
|
- + (int) (getLastStartTime() ^ (getLastStartTime() >>> 32));
|
|
|
- return result;
|
|
|
+
|
|
|
+ return new HashCodeBuilder()
|
|
|
+ .append(this.getSubClusterId())
|
|
|
+ .append(this.getAMRMServiceAddress())
|
|
|
+ .append(this.getClientRMServiceAddress())
|
|
|
+ .append(this.getRMAdminServiceAddress())
|
|
|
+ .append(this.getRMWebServiceAddress())
|
|
|
+ .append(this.getState())
|
|
|
+ .append(this.getLastStartTime())
|
|
|
+ .toHashCode();
|
|
|
// Capability and HeartBeat fields are not included as they are temporal
|
|
|
// (i.e. timestamps), so they change during the lifetime of the same
|
|
|
// sub-cluster
|