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

This commit is contained in:
Robert Kanter 2017-10-23 17:56:56 -07:00
parent c904d60c38
commit 5da295a34e

View File

@ -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<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 @@ private void addSystemCredentialsToProto() {
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()))));
}
}