HDFS-15094. RBF: Reuse ugi string in ConnectionPoolID. Contributed by Ayush Saxena.
This commit is contained in:
parent
fd30f4c52b
commit
8fe01db34a
|
@ -44,6 +44,12 @@ public class ConnectionPoolId implements Comparable<ConnectionPoolId> {
|
|||
private final UserGroupInformation ugi;
|
||||
/** Protocol for the connection. */
|
||||
private final Class<?> protocol;
|
||||
/**
|
||||
* Caching ugi.toString() to save the redundant calculation effort,
|
||||
* since it is a costly operation and is used as part of both hash calculation
|
||||
* and equals method.
|
||||
*/
|
||||
private final String ugiString;
|
||||
|
||||
/**
|
||||
* New connection pool identifier.
|
||||
|
@ -57,13 +63,14 @@ public class ConnectionPoolId implements Comparable<ConnectionPoolId> {
|
|||
this.nnId = nnId;
|
||||
this.ugi = ugi;
|
||||
this.protocol = proto;
|
||||
this.ugiString = ugi.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = new HashCodeBuilder(17, 31)
|
||||
.append(this.nnId)
|
||||
.append(this.ugi.toString())
|
||||
.append(this.ugiString)
|
||||
.append(this.getTokenIds())
|
||||
.append(this.protocol)
|
||||
.toHashCode();
|
||||
|
@ -77,7 +84,7 @@ public class ConnectionPoolId implements Comparable<ConnectionPoolId> {
|
|||
if (!this.nnId.equals(other.nnId)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.ugi.toString().equals(other.ugi.toString())) {
|
||||
if (!this.ugiString.equals(other.ugiString)) {
|
||||
return false;
|
||||
}
|
||||
String thisTokens = this.getTokenIds().toString();
|
||||
|
|
Loading…
Reference in New Issue