From 5da295a34e39b507e8291073782e0576cd06896a Mon Sep 17 00:00:00 2001 From: Robert Kanter Date: Mon, 23 Oct 2017 17:56:56 -0700 Subject: [PATCH] YARN-7320. Duplicate LiteralByteStrings in SystemCredentialsForAppsProto.credentialsForApp_ (misha@cloudera.com via rkanter) --- .../impl/pb/NodeHeartbeatResponsePBImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/NodeHeartbeatResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/NodeHeartbeatResponsePBImpl.java index bbd1294219..ccc4191d1e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/NodeHeartbeatResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/NodeHeartbeatResponsePBImpl.java @@ -26,6 +26,10 @@ 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 containersToDecrease = null; private List containersToSignal = null; + private static final Interner BYTE_STRING_INTERNER = + Interners.newWeakInterner(); + public NodeHeartbeatResponsePBImpl() { builder = NodeHeartbeatResponseProto.newBuilder(); } @@ -148,8 +155,8 @@ private void addSystemCredentialsToProto() { for (Map.Entry 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())))); } }