YARN-7320. Duplicate LiteralByteStrings in SystemCredentialsForAppsProto.credentialsForApp_ (misha@cloudera.com via rkanter)

(cherry picked from commit 5da295a34e)
This commit is contained in:
Robert Kanter 2017-10-23 17:56:56 -07:00
parent b8a2fd37dc
commit 61aba4f0c1
1 changed files with 9 additions and 2 deletions

View File

@ -26,6 +26,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Interner;
import com.google.common.collect.Interners;
import com.google.protobuf.ByteString;
import org.apache.hadoop.security.proto.SecurityProtos.TokenProto;
import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SignalContainerRequestPBImpl;
@ -84,6 +88,9 @@ public class NodeHeartbeatResponsePBImpl extends NodeHeartbeatResponse {
private List<Container> containersToDecrease = null;
private List<SignalContainerRequest> containersToSignal = null;
private static final Interner<ByteString> BYTE_STRING_INTERNER =
Interners.newWeakInterner();
public NodeHeartbeatResponsePBImpl() {
builder = NodeHeartbeatResponseProto.newBuilder();
}
@ -148,8 +155,8 @@ public class NodeHeartbeatResponsePBImpl extends NodeHeartbeatResponse {
for (Map.Entry<ApplicationId, ByteBuffer> entry : systemCredentials.entrySet()) {
builder.addSystemCredentialsForApps(SystemCredentialsForAppsProto.newBuilder()
.setAppId(convertToProtoFormat(entry.getKey()))
.setCredentialsForApp(ProtoUtils.convertToProtoFormat(
entry.getValue().duplicate())));
.setCredentialsForApp(BYTE_STRING_INTERNER.intern(
ProtoUtils.convertToProtoFormat(entry.getValue()))));
}
}