From 18e08a8f511652ed9f4ba386bb4f0cf8339e2729 Mon Sep 17 00:00:00 2001 From: Siddharth Seth Date: Mon, 25 Mar 2013 18:28:50 +0000 Subject: [PATCH] YARN-439. Flatten NodeHeartbeatResponse. Contributed by Xuan Gong. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1460811 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 2 + .../NodeHeartbeatResponse.java | 24 +- .../impl/pb/NodeHeartbeatResponsePBImpl.java | 247 ++++++++++-- .../server/api/records/HeartbeatResponse.java | 52 --- .../impl/pb/HeartbeatResponsePBImpl.java | 350 ------------------ .../proto/yarn_server_common_protos.proto | 7 - .../yarn_server_common_service_protos.proto | 7 +- .../apache/hadoop/yarn/TestRecordFactory.java | 11 - .../nodemanager/NodeStatusUpdaterImpl.java | 10 +- .../nodemanager/MockNodeStatusUpdater.java | 7 +- .../nodemanager/TestNodeStatusUpdater.java | 26 +- .../ResourceTrackerService.java | 37 +- .../server/resourcemanager/rmnode/RMNode.java | 11 +- .../resourcemanager/rmnode/RMNodeImpl.java | 20 +- .../rmnode/RMNodeStatusEvent.java | 8 +- .../yarn/server/resourcemanager/MockNM.java | 14 +- .../server/resourcemanager/MockNodes.java | 6 +- .../server/resourcemanager/NodeManager.java | 6 +- .../TestApplicationCleanup.java | 22 +- .../TestRMNodeTransitions.java | 16 +- .../server/resourcemanager/TestRMRestart.java | 4 +- .../TestResourceTrackerService.java | 14 +- .../resourcetracker/TestNMExpiry.java | 2 +- .../TestRMNMRPCResponseId.java | 15 +- .../hadoop/yarn/server/MiniYARNCluster.java | 3 +- .../yarn/server/TestRMNMSecretKeys.java | 4 +- 26 files changed, 348 insertions(+), 577 deletions(-) delete mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/HeartbeatResponse.java delete mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/impl/pb/HeartbeatResponsePBImpl.java diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index c3c13eea3ac..490b5e98ef0 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -62,6 +62,8 @@ Release 2.0.5-beta - UNRELEASED YARN-396. Rationalize AllocateResponse in RM Scheduler API. (Zhijie Shen via hitesh) + YARN-439. Flatten NodeHeartbeatResponse. (Xuan Gong via sseth) + NEW FEATURES IMPROVEMENTS 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/NodeHeartbeatResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/NodeHeartbeatResponse.java index 665f1f164c0..6aff34ae284 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/NodeHeartbeatResponse.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/NodeHeartbeatResponse.java @@ -18,10 +18,28 @@ package org.apache.hadoop.yarn.server.api.protocolrecords; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; +import java.util.List; + +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.server.api.records.MasterKey; +import org.apache.hadoop.yarn.server.api.records.NodeAction; public interface NodeHeartbeatResponse { - public abstract HeartbeatResponse getHeartbeatResponse(); + int getResponseId(); + NodeAction getNodeAction(); + + List getContainersToCleanup(); + + List getApplicationsToCleanup(); + + void setResponseId(int responseId); + void setNodeAction(NodeAction action); + + MasterKey getMasterKey(); + void setMasterKey(MasterKey secretKey); + + void addAllContainersToCleanup(List containers); - public abstract void setHeartbeatResponse(HeartbeatResponse heartbeatResponse); + void addAllApplicationsToCleanup(List applications); } 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 49352a2afa6..bc51b241f3c 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 @@ -18,14 +18,25 @@ package org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb; +import java.util.ArrayList; +import java.util.List; +import java.util.Iterator; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ProtoBase; -import org.apache.hadoop.yarn.proto.YarnServerCommonProtos.HeartbeatResponseProto; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; +import org.apache.hadoop.yarn.proto.YarnServerCommonProtos.MasterKeyProto; +import org.apache.hadoop.yarn.proto.YarnServerCommonProtos.NodeActionProto; import org.apache.hadoop.yarn.proto.YarnServerCommonServiceProtos.NodeHeartbeatResponseProto; import org.apache.hadoop.yarn.proto.YarnServerCommonServiceProtos.NodeHeartbeatResponseProtoOrBuilder; import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; -import org.apache.hadoop.yarn.server.api.records.impl.pb.HeartbeatResponsePBImpl; +import org.apache.hadoop.yarn.server.api.records.MasterKey; +import org.apache.hadoop.yarn.server.api.records.NodeAction; +import org.apache.hadoop.yarn.server.api.records.impl.pb.MasterKeyPBImpl; @@ -34,8 +45,9 @@ public class NodeHeartbeatResponsePBImpl extends ProtoBase containersToCleanup = null; + private List applicationsToCleanup = null; + private MasterKey masterKey = null; public NodeHeartbeatResponsePBImpl() { builder = NodeHeartbeatResponseProto.newBuilder(); @@ -54,8 +66,14 @@ public class NodeHeartbeatResponsePBImpl extends ProtoBase getContainersToCleanup() { + initContainersToCleanup(); + return this.containersToCleanup; + } + + private void initContainersToCleanup() { + if (this.containersToCleanup != null) { + return; + } + NodeHeartbeatResponseProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getContainersToCleanupList(); + this.containersToCleanup = new ArrayList(); + + for (ContainerIdProto c : list) { + this.containersToCleanup.add(convertFromProtoFormat(c)); + } + } + + @Override + public void addAllContainersToCleanup( + final List containersToCleanup) { + if (containersToCleanup == null) + return; + initContainersToCleanup(); + this.containersToCleanup.addAll(containersToCleanup); + } + + private void addContainersToCleanupToProto() { + maybeInitBuilder(); + builder.clearContainersToCleanup(); + if (containersToCleanup == null) + return; + Iterable iterable = new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = containersToCleanup.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public ContainerIdProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllContainersToCleanup(iterable); + } + + @Override + public List getApplicationsToCleanup() { + initApplicationsToCleanup(); + return this.applicationsToCleanup; + } + + private void initApplicationsToCleanup() { + if (this.applicationsToCleanup != null) { + return; + } + NodeHeartbeatResponseProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getApplicationsToCleanupList(); + this.applicationsToCleanup = new ArrayList(); + + for (ApplicationIdProto c : list) { + this.applicationsToCleanup.add(convertFromProtoFormat(c)); + } + } + + @Override + public void addAllApplicationsToCleanup( + final List applicationsToCleanup) { + if (applicationsToCleanup == null) + return; + initApplicationsToCleanup(); + this.applicationsToCleanup.addAll(applicationsToCleanup); + } + + private void addApplicationsToCleanupToProto() { + maybeInitBuilder(); + builder.clearApplicationsToCleanup(); + if (applicationsToCleanup == null) + return; + Iterable iterable = new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = applicationsToCleanup.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public ApplicationIdProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllApplicationsToCleanup(iterable); + } + + private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { + return new ContainerIdPBImpl(p); + } + + private ContainerIdProto convertToProtoFormat(ContainerId t) { + return ((ContainerIdPBImpl) t).getProto(); + } + + private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { + return new ApplicationIdPBImpl(p); + } + + private ApplicationIdProto convertToProtoFormat(ApplicationId t) { + return ((ApplicationIdPBImpl) t).getProto(); + } + + private NodeAction convertFromProtoFormat(NodeActionProto p) { + return NodeAction.valueOf(p.name()); + } + + private NodeActionProto convertToProtoFormat(NodeAction t) { + return NodeActionProto.valueOf(t.name()); + } + + private MasterKeyPBImpl convertFromProtoFormat(MasterKeyProto p) { + return new MasterKeyPBImpl(p); + } + + private MasterKeyProto convertToProtoFormat(MasterKey t) { + return ((MasterKeyPBImpl) t).getProto(); + } +} -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/HeartbeatResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/HeartbeatResponse.java deleted file mode 100644 index 4536934054f..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/HeartbeatResponse.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.api.records; - -import java.util.List; - -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ContainerId; - -public interface HeartbeatResponse { - int getResponseId(); - NodeAction getNodeAction(); - - List getContainersToCleanupList(); - ContainerId getContainerToCleanup(int index); - int getContainersToCleanupCount(); - - List getApplicationsToCleanupList(); - ApplicationId getApplicationsToCleanup(int index); - int getApplicationsToCleanupCount(); - - void setResponseId(int responseId); - void setNodeAction(NodeAction action); - - MasterKey getMasterKey(); - void setMasterKey(MasterKey secretKey); - - void addAllContainersToCleanup(List containers); - void addContainerToCleanup(ContainerId container); - void removeContainerToCleanup(int index); - void clearContainersToCleanup(); - - void addAllApplicationsToCleanup(List applications); - void addApplicationToCleanup(ApplicationId applicationId); - void removeApplicationToCleanup(int index); - void clearApplicationsToCleanup(); -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/impl/pb/HeartbeatResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/impl/pb/HeartbeatResponsePBImpl.java deleted file mode 100644 index 8a7d890aebd..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/impl/pb/HeartbeatResponsePBImpl.java +++ /dev/null @@ -1,350 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.api.records.impl.pb; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ProtoBase; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnServerCommonProtos.HeartbeatResponseProto; -import org.apache.hadoop.yarn.proto.YarnServerCommonProtos.HeartbeatResponseProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnServerCommonProtos.MasterKeyProto; -import org.apache.hadoop.yarn.proto.YarnServerCommonProtos.NodeActionProto; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; -import org.apache.hadoop.yarn.server.api.records.MasterKey; -import org.apache.hadoop.yarn.server.api.records.NodeAction; - -public class HeartbeatResponsePBImpl extends - ProtoBase implements HeartbeatResponse { - HeartbeatResponseProto proto = HeartbeatResponseProto.getDefaultInstance(); - HeartbeatResponseProto.Builder builder = null; - boolean viaProto = false; - - private List containersToCleanup = null; - private List applicationsToCleanup = null; - private MasterKey masterKey = null; - - public HeartbeatResponsePBImpl() { - builder = HeartbeatResponseProto.newBuilder(); - } - - public HeartbeatResponsePBImpl(HeartbeatResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public HeartbeatResponseProto getProto() { - - mergeLocalToProto(); - proto = viaProto ? proto : builder.build(); - viaProto = true; - return proto; - } - - private void mergeLocalToBuilder() { - if (this.containersToCleanup != null) { - addContainersToCleanupToProto(); - } - if (this.applicationsToCleanup != null) { - addApplicationsToCleanupToProto(); - } - if (this.masterKey != null) { - builder.setMasterKey(convertToProtoFormat(this.masterKey)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = HeartbeatResponseProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public int getResponseId() { - HeartbeatResponseProtoOrBuilder p = viaProto ? proto : builder; - return (p.getResponseId()); - } - - @Override - public void setResponseId(int responseId) { - maybeInitBuilder(); - builder.setResponseId((responseId)); - } - - @Override - public MasterKey getMasterKey() { - HeartbeatResponseProtoOrBuilder p = viaProto ? proto : builder; - if (this.masterKey != null) { - return this.masterKey; - } - if (!p.hasMasterKey()) { - return null; - } - this.masterKey = convertFromProtoFormat(p.getMasterKey()); - return this.masterKey; - } - - @Override - public void setMasterKey(MasterKey masterKey) { - maybeInitBuilder(); - if (masterKey == null) - builder.clearMasterKey(); - this.masterKey = masterKey; - } - - @Override - public NodeAction getNodeAction() { - HeartbeatResponseProtoOrBuilder p = viaProto ? proto : builder; - if(!p.hasNodeAction()) { - return null; - } - return (convertFromProtoFormat(p.getNodeAction())); - } - - @Override - public void setNodeAction(NodeAction nodeAction) { - maybeInitBuilder(); - if (nodeAction == null) { - builder.clearNodeAction(); - return; - } - builder.setNodeAction(convertToProtoFormat(nodeAction)); - } - - @Override - public List getContainersToCleanupList() { - initContainersToCleanup(); - return this.containersToCleanup; - } - @Override - public ContainerId getContainerToCleanup(int index) { - initContainersToCleanup(); - return this.containersToCleanup.get(index); - } - @Override - public int getContainersToCleanupCount() { - initContainersToCleanup(); - return this.containersToCleanup.size(); - } - - private void initContainersToCleanup() { - if (this.containersToCleanup != null) { - return; - } - HeartbeatResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getContainersToCleanupList(); - this.containersToCleanup = new ArrayList(); - - for (ContainerIdProto c : list) { - this.containersToCleanup.add(convertFromProtoFormat(c)); - } - } - - @Override - public void addAllContainersToCleanup(final List containersToCleanup) { - if (containersToCleanup == null) - return; - initContainersToCleanup(); - this.containersToCleanup.addAll(containersToCleanup); - } - - private void addContainersToCleanupToProto() { - maybeInitBuilder(); - builder.clearContainersToCleanup(); - if (containersToCleanup == null) - return; - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = containersToCleanup.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public ContainerIdProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllContainersToCleanup(iterable); - } - @Override - public void addContainerToCleanup(ContainerId containersToCleanup) { - initContainersToCleanup(); - this.containersToCleanup.add(containersToCleanup); - } - @Override - public void removeContainerToCleanup(int index) { - initContainersToCleanup(); - this.containersToCleanup.remove(index); - } - @Override - public void clearContainersToCleanup() { - initContainersToCleanup(); - this.containersToCleanup.clear(); - } - @Override - public List getApplicationsToCleanupList() { - initApplicationsToCleanup(); - return this.applicationsToCleanup; - } - @Override - public ApplicationId getApplicationsToCleanup(int index) { - initApplicationsToCleanup(); - return this.applicationsToCleanup.get(index); - } - @Override - public int getApplicationsToCleanupCount() { - initApplicationsToCleanup(); - return this.applicationsToCleanup.size(); - } - - private void initApplicationsToCleanup() { - if (this.applicationsToCleanup != null) { - return; - } - HeartbeatResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getApplicationsToCleanupList(); - this.applicationsToCleanup = new ArrayList(); - - for (ApplicationIdProto c : list) { - this.applicationsToCleanup.add(convertFromProtoFormat(c)); - } - } - - @Override - public void addAllApplicationsToCleanup(final List applicationsToCleanup) { - if (applicationsToCleanup == null) - return; - initApplicationsToCleanup(); - this.applicationsToCleanup.addAll(applicationsToCleanup); - } - - private void addApplicationsToCleanupToProto() { - maybeInitBuilder(); - builder.clearApplicationsToCleanup(); - if (applicationsToCleanup == null) - return; - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = applicationsToCleanup.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public ApplicationIdProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllApplicationsToCleanup(iterable); - } - @Override - public void addApplicationToCleanup(ApplicationId applicationsToCleanup) { - initApplicationsToCleanup(); - this.applicationsToCleanup.add(applicationsToCleanup); - } - @Override - public void removeApplicationToCleanup(int index) { - initApplicationsToCleanup(); - this.applicationsToCleanup.remove(index); - } - @Override - public void clearApplicationsToCleanup() { - initApplicationsToCleanup(); - this.applicationsToCleanup.clear(); - } - - private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { - return new ContainerIdPBImpl(p); - } - - private ContainerIdProto convertToProtoFormat(ContainerId t) { - return ((ContainerIdPBImpl)t).getProto(); - } - - private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { - return new ApplicationIdPBImpl(p); - } - - private ApplicationIdProto convertToProtoFormat(ApplicationId t) { - return ((ApplicationIdPBImpl)t).getProto(); - } - - private NodeAction convertFromProtoFormat(NodeActionProto p) { - return NodeAction.valueOf(p.name()); - } - - private NodeActionProto convertToProtoFormat(NodeAction t) { - return NodeActionProto.valueOf(t.name()); - } - - private MasterKeyPBImpl convertFromProtoFormat(MasterKeyProto p) { - return new MasterKeyPBImpl(p); - } - - private MasterKeyProto convertToProtoFormat(MasterKey t) { - return ((MasterKeyPBImpl)t).getProto(); - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_protos.proto index 71f5b1bc88f..4d1ce15fca8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_protos.proto @@ -47,11 +47,4 @@ message RegistrationResponseProto { optional NodeActionProto nodeAction = 2; } -message HeartbeatResponseProto { - optional int32 response_id = 1; - optional MasterKeyProto master_key = 2; - optional NodeActionProto nodeAction = 3; - repeated ContainerIdProto containers_to_cleanup = 4; - repeated ApplicationIdProto applications_to_cleanup = 5; -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_service_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_service_protos.proto index e4d82c75d61..30d0cfeff33 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_service_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_common_service_protos.proto @@ -38,6 +38,11 @@ message NodeHeartbeatRequestProto { optional MasterKeyProto last_known_master_key = 2; } + message NodeHeartbeatResponseProto { - optional HeartbeatResponseProto heartbeat_response = 1; + optional int32 response_id = 1; + optional MasterKeyProto master_key = 2; + optional NodeActionProto nodeAction = 3; + repeated ContainerIdProto containers_to_cleanup = 4; + repeated ApplicationIdProto applications_to_cleanup = 5; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestRecordFactory.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestRecordFactory.java index c77d21071ec..b833e6104bd 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestRecordFactory.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestRecordFactory.java @@ -25,8 +25,6 @@ import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factories.impl.pb.RecordFactoryPBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; -import org.apache.hadoop.yarn.server.api.records.impl.pb.HeartbeatResponsePBImpl; import org.junit.Test; public class TestRecordFactory { @@ -34,15 +32,6 @@ public class TestRecordFactory { @Test public void testPbRecordFactory() { RecordFactory pbRecordFactory = RecordFactoryPBImpl.get(); - - try { - HeartbeatResponse response = pbRecordFactory.newRecordInstance(HeartbeatResponse.class); - Assert.assertEquals(HeartbeatResponsePBImpl.class, response.getClass()); - } catch (YarnException e) { - e.printStackTrace(); - Assert.fail("Failed to crete record"); - } - try { NodeHeartbeatRequest request = pbRecordFactory.newRecordInstance(NodeHeartbeatRequest.class); Assert.assertEquals(NodeHeartbeatRequestPBImpl.class, request.getClass()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java index e3dae41603a..3df4311b600 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java @@ -50,8 +50,8 @@ import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.ipc.YarnRPC; import org.apache.hadoop.yarn.server.api.ResourceTracker; import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.MasterKey; import org.apache.hadoop.yarn.server.api.records.NodeAction; import org.apache.hadoop.yarn.server.api.records.NodeStatus; @@ -408,8 +408,8 @@ public class NodeStatusUpdaterImpl extends AbstractService implements request.setLastKnownMasterKey(NodeStatusUpdaterImpl.this.context .getContainerTokenSecretManager().getCurrentKey()); } - HeartbeatResponse response = - resourceTracker.nodeHeartbeat(request).getHeartbeatResponse(); + NodeHeartbeatResponse response = + resourceTracker.nodeHeartbeat(request); // See if the master-key has rolled over if (isSecurityEnabled()) { @@ -439,14 +439,14 @@ public class NodeStatusUpdaterImpl extends AbstractService implements lastHeartBeatID = response.getResponseId(); List containersToCleanup = response - .getContainersToCleanupList(); + .getContainersToCleanup(); if (containersToCleanup.size() != 0) { dispatcher.getEventHandler().handle( new CMgrCompletedContainersEvent(containersToCleanup, CMgrCompletedContainersEvent.Reason.BY_RESOURCEMANAGER)); } List appsToCleanup = - response.getApplicationsToCleanupList(); + response.getApplicationsToCleanup(); //Only start tracking for keepAlive on FINISH_APP trackAppsForKeepAlive(appsToCleanup); if (appsToCleanup.size() != 0) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/MockNodeStatusUpdater.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/MockNodeStatusUpdater.java index e2ea8212d88..bf46cde02f2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/MockNodeStatusUpdater.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/MockNodeStatusUpdater.java @@ -29,7 +29,6 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerResponse; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.NodeStatus; import org.apache.hadoop.yarn.server.api.records.RegistrationResponse; import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics; @@ -79,13 +78,9 @@ public class MockNodeStatusUpdater extends NodeStatusUpdaterImpl { LOG.info("Got heartbeat number " + heartBeatID); nodeStatus.setResponseId(heartBeatID++); - HeartbeatResponse response = recordFactory - .newRecordInstance(HeartbeatResponse.class); - response.setResponseId(heartBeatID); - NodeHeartbeatResponse nhResponse = recordFactory .newRecordInstance(NodeHeartbeatResponse.class); - nhResponse.setHeartbeatResponse(response); + nhResponse.setResponseId(heartBeatID); return nhResponse; } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java index ff9e0824efc..afeb0302422 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java @@ -56,7 +56,6 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerResponse; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.NodeAction; import org.apache.hadoop.yarn.server.api.records.NodeStatus; import org.apache.hadoop.yarn.server.api.records.RegistrationResponse; @@ -218,13 +217,10 @@ public class TestNodeStatusUpdater { this.context.getContainers(); Assert.assertEquals(2, activeContainers.size()); } - HeartbeatResponse response = recordFactory - .newRecordInstance(HeartbeatResponse.class); - response.setResponseId(heartBeatID); NodeHeartbeatResponse nhResponse = recordFactory .newRecordInstance(NodeHeartbeatResponse.class); - nhResponse.setHeartbeatResponse(response); + nhResponse.setResponseId(heartBeatID); return nhResponse; } } @@ -335,14 +331,11 @@ public class TestNodeStatusUpdater { throws YarnRemoteException { NodeStatus nodeStatus = request.getNodeStatus(); nodeStatus.setResponseId(heartBeatID++); - HeartbeatResponse response = recordFactory - .newRecordInstance(HeartbeatResponse.class); - response.setResponseId(heartBeatID); - response.setNodeAction(heartBeatNodeAction); NodeHeartbeatResponse nhResponse = recordFactory .newRecordInstance(NodeHeartbeatResponse.class); - nhResponse.setHeartbeatResponse(response); + nhResponse.setResponseId(heartBeatID); + nhResponse.setNodeAction(heartBeatNodeAction); return nhResponse; } } @@ -378,10 +371,10 @@ public class TestNodeStatusUpdater { LOG.info("Got heartBeatId: [" + heartBeatID +"]"); NodeStatus nodeStatus = request.getNodeStatus(); nodeStatus.setResponseId(heartBeatID++); - HeartbeatResponse response = - recordFactory.newRecordInstance(HeartbeatResponse.class); - response.setResponseId(heartBeatID); - response.setNodeAction(heartBeatNodeAction); + NodeHeartbeatResponse nhResponse = + recordFactory.newRecordInstance(NodeHeartbeatResponse.class); + nhResponse.setResponseId(heartBeatID); + nhResponse.setNodeAction(heartBeatNodeAction); if (nodeStatus.getKeepAliveApplications() != null && nodeStatus.getKeepAliveApplications().size() > 0) { @@ -397,11 +390,8 @@ public class TestNodeStatusUpdater { if (heartBeatID == 2) { LOG.info("Sending FINISH_APP for application: [" + appId + "]"); this.context.getApplications().put(appId, mock(Application.class)); - response.addAllApplicationsToCleanup(Collections.singletonList(appId)); + nhResponse.addAllApplicationsToCleanup(Collections.singletonList(appId)); } - NodeHeartbeatResponse nhResponse = - recordFactory.newRecordInstance(NodeHeartbeatResponse.class); - nhResponse.setHeartbeatResponse(response); return nhResponse; } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java index 7aaa0668452..2ca1360eb9d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceTrackerService.java @@ -39,7 +39,6 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerResponse; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.MasterKey; import org.apache.hadoop.yarn.server.api.records.NodeAction; import org.apache.hadoop.yarn.server.api.records.NodeStatus; @@ -78,15 +77,9 @@ public class ResourceTrackerService extends AbstractService implements .newRecordInstance(NodeHeartbeatResponse.class); static { - HeartbeatResponse rebootResp = recordFactory - .newRecordInstance(HeartbeatResponse.class); - rebootResp.setNodeAction(NodeAction.REBOOT); - reboot.setHeartbeatResponse(rebootResp); - - HeartbeatResponse decommissionedResp = recordFactory - .newRecordInstance(HeartbeatResponse.class); - decommissionedResp.setNodeAction(NodeAction.SHUTDOWN); - shutDown.setHeartbeatResponse(decommissionedResp); + reboot.setNodeAction(NodeAction.REBOOT); + + shutDown.setNodeAction(NodeAction.SHUTDOWN); } public ResourceTrackerService(RMContext rmContext, @@ -240,17 +233,16 @@ public class ResourceTrackerService extends AbstractService implements .newRecordInstance(NodeHeartbeatResponse.class); // 3. Check if it's a 'fresh' heartbeat i.e. not duplicate heartbeat - HeartbeatResponse lastHeartbeatResponse = rmNode.getLastHeartBeatResponse(); - if (remoteNodeStatus.getResponseId() + 1 == lastHeartbeatResponse + NodeHeartbeatResponse lastNodeHeartbeatResponse = rmNode.getLastNodeHeartBeatResponse(); + if (remoteNodeStatus.getResponseId() + 1 == lastNodeHeartbeatResponse .getResponseId()) { LOG.info("Received duplicate heartbeat from node " + rmNode.getNodeAddress()); - nodeHeartBeatResponse.setHeartbeatResponse(lastHeartbeatResponse); - return nodeHeartBeatResponse; - } else if (remoteNodeStatus.getResponseId() + 1 < lastHeartbeatResponse + return lastNodeHeartbeatResponse; + } else if (remoteNodeStatus.getResponseId() + 1 < lastNodeHeartbeatResponse .getResponseId()) { LOG.info("Too far behind rm response id:" - + lastHeartbeatResponse.getResponseId() + " nm response id:" + + lastNodeHeartbeatResponse.getResponseId() + " nm response id:" + remoteNodeStatus.getResponseId()); // TODO: Just sending reboot is not enough. Think more. this.rmContext.getDispatcher().getEventHandler().handle( @@ -259,11 +251,9 @@ public class ResourceTrackerService extends AbstractService implements } // Heartbeat response - HeartbeatResponse latestResponse = recordFactory - .newRecordInstance(HeartbeatResponse.class); - latestResponse.setResponseId(lastHeartbeatResponse.getResponseId() + 1); - rmNode.updateHeartbeatResponseForCleanup(latestResponse); - latestResponse.setNodeAction(NodeAction.NORMAL); + nodeHeartBeatResponse.setResponseId(lastNodeHeartbeatResponse.getResponseId() + 1); + rmNode.updateNodeHeartbeatResponseForCleanup(nodeHeartBeatResponse); + nodeHeartBeatResponse.setNodeAction(NodeAction.NORMAL); // Check if node's masterKey needs to be updated and if the currentKey has // roller over, send it across @@ -282,7 +272,7 @@ public class ResourceTrackerService extends AbstractService implements } } if (shouldSendMasterKey) { - latestResponse.setMasterKey(nextMasterKeyForNode); + nodeHeartBeatResponse.setMasterKey(nextMasterKeyForNode); } } @@ -290,9 +280,8 @@ public class ResourceTrackerService extends AbstractService implements this.rmContext.getDispatcher().getEventHandler().handle( new RMNodeStatusEvent(nodeId, remoteNodeStatus.getNodeHealthStatus(), remoteNodeStatus.getContainersStatuses(), - remoteNodeStatus.getKeepAliveApplications(), latestResponse)); + remoteNodeStatus.getKeepAliveApplications(), nodeHeartBeatResponse)); - nodeHeartBeatResponse.setHeartbeatResponse(latestResponse); return nodeHeartBeatResponse; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java index dc7295af085..9d1103d4fc0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java @@ -27,7 +27,7 @@ import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.NodeHealthStatus; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeState; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; /** * Node managers information on available resources @@ -106,13 +106,13 @@ public interface RMNode { public List getAppsToCleanup(); /** - * Update a {@link HeartbeatResponse} with the list of containers and + * Update a {@link NodeHeartbeatResponse} with the list of containers and * applications to clean up for this node. - * @param response the {@link HeartbeatResponse} to update + * @param response the {@link NodeHeartbeatResponse} to update */ - public void updateHeartbeatResponseForCleanup(HeartbeatResponse response); + public void updateNodeHeartbeatResponseForCleanup(NodeHeartbeatResponse response); - public HeartbeatResponse getLastHeartBeatResponse(); + public NodeHeartbeatResponse getLastNodeHeartBeatResponse(); /** * Get and clear the list of containerUpdates accumulated across NM @@ -121,5 +121,4 @@ public interface RMNode { * @return containerUpdates accumulated across NM heartbeats. */ public List pullContainerUpdates(); - } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java index 23a45991390..255b4951396 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java @@ -46,7 +46,7 @@ import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.event.EventHandler; import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.resourcemanager.ClusterMetrics; import org.apache.hadoop.yarn.server.resourcemanager.NodesListManagerEvent; import org.apache.hadoop.yarn.server.resourcemanager.NodesListManagerEventType; @@ -107,8 +107,8 @@ public class RMNodeImpl implements RMNode, EventHandler { /* the list of applications that have finished and need to be purged */ private final List finishedApplications = new ArrayList(); - private HeartbeatResponse latestHeartBeatResponse = recordFactory - .newRecordInstance(HeartbeatResponse.class); + private NodeHeartbeatResponse latestNodeHeartBeatResponse = recordFactory + .newRecordInstance(NodeHeartbeatResponse.class); private static final StateMachineFactory { this.nodeHealthStatus.setHealthReport("Healthy"); this.nodeHealthStatus.setLastHealthReportTime(System.currentTimeMillis()); - this.latestHeartBeatResponse.setResponseId(0); + this.latestNodeHeartBeatResponse.setResponseId(0); ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); this.readLock = lock.readLock(); @@ -304,7 +304,7 @@ public class RMNodeImpl implements RMNode, EventHandler { }; @Override - public void updateHeartbeatResponseForCleanup(HeartbeatResponse response) { + public void updateNodeHeartbeatResponseForCleanup(NodeHeartbeatResponse response) { this.writeLock.lock(); try { @@ -319,12 +319,12 @@ public class RMNodeImpl implements RMNode, EventHandler { }; @Override - public HeartbeatResponse getLastHeartBeatResponse() { + public NodeHeartbeatResponse getLastNodeHeartBeatResponse() { this.readLock.lock(); try { - return this.latestHeartBeatResponse; + return this.latestNodeHeartBeatResponse; } finally { this.readLock.unlock(); } @@ -430,7 +430,7 @@ public class RMNodeImpl implements RMNode, EventHandler { if (rmNode.getTotalCapability().equals(newNode.getTotalCapability()) && rmNode.getHttpPort() == newNode.getHttpPort()) { // Reset heartbeat ID since node just restarted. - rmNode.getLastHeartBeatResponse().setResponseId(0); + rmNode.getLastNodeHeartBeatResponse().setResponseId(0); rmNode.context.getDispatcher().getEventHandler().handle( new NodeAddedSchedulerEvent(rmNode)); } else { @@ -507,7 +507,7 @@ public class RMNodeImpl implements RMNode, EventHandler { RMNodeStatusEvent statusEvent = (RMNodeStatusEvent) event; // Switch the last heartbeatresponse. - rmNode.latestHeartBeatResponse = statusEvent.getLatestResponse(); + rmNode.latestNodeHeartBeatResponse = statusEvent.getLatestResponse(); NodeHealthStatus remoteNodeHealthStatus = statusEvent.getNodeHealthStatus(); @@ -591,7 +591,7 @@ public class RMNodeImpl implements RMNode, EventHandler { RMNodeStatusEvent statusEvent = (RMNodeStatusEvent) event; // Switch the last heartbeatresponse. - rmNode.latestHeartBeatResponse = statusEvent.getLatestResponse(); + rmNode.latestNodeHeartBeatResponse = statusEvent.getLatestResponse(); NodeHealthStatus remoteNodeHealthStatus = statusEvent.getNodeHealthStatus(); rmNode.setNodeHealthStatus(remoteNodeHealthStatus); if (remoteNodeHealthStatus.getIsNodeHealthy()) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeStatusEvent.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeStatusEvent.java index 1285c2bed99..3f356817658 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeStatusEvent.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeStatusEvent.java @@ -24,18 +24,18 @@ import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.NodeHealthStatus; import org.apache.hadoop.yarn.api.records.NodeId; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; public class RMNodeStatusEvent extends RMNodeEvent { private final NodeHealthStatus nodeHealthStatus; private final List containersCollection; - private final HeartbeatResponse latestResponse; + private final NodeHeartbeatResponse latestResponse; private final List keepAliveAppIds; public RMNodeStatusEvent(NodeId nodeId, NodeHealthStatus nodeHealthStatus, List collection, List keepAliveAppIds, - HeartbeatResponse latestResponse) { + NodeHeartbeatResponse latestResponse) { super(nodeId, RMNodeEventType.STATUS_UPDATE); this.nodeHealthStatus = nodeHealthStatus; this.containersCollection = collection; @@ -51,7 +51,7 @@ public class RMNodeStatusEvent extends RMNodeEvent { return this.containersCollection; } - public HeartbeatResponse getLatestResponse() { + public NodeHeartbeatResponse getLatestResponse() { return this.latestResponse; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNM.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNM.java index 8f66bdba485..e22aa6ca7e0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNM.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNM.java @@ -33,8 +33,8 @@ import org.apache.hadoop.yarn.api.records.NodeHealthStatus; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.MasterKey; import org.apache.hadoop.yarn.server.api.records.NodeStatus; import org.apache.hadoop.yarn.server.api.records.RegistrationResponse; @@ -93,12 +93,12 @@ public class MockNM { return registrationResponse; } - public HeartbeatResponse nodeHeartbeat(boolean isHealthy) throws Exception { + public NodeHeartbeatResponse nodeHeartbeat(boolean isHealthy) throws Exception { return nodeHeartbeat(new HashMap>(), isHealthy, ++responseId); } - public HeartbeatResponse nodeHeartbeat(ApplicationAttemptId attemptId, + public NodeHeartbeatResponse nodeHeartbeat(ApplicationAttemptId attemptId, int containerId, ContainerState containerState) throws Exception { HashMap> nodeUpdate = new HashMap>(1); @@ -112,12 +112,12 @@ public class MockNM { return nodeHeartbeat(nodeUpdate, true); } - public HeartbeatResponse nodeHeartbeat(Map> conts, boolean isHealthy) throws Exception { return nodeHeartbeat(conts, isHealthy, ++responseId); } - public HeartbeatResponse nodeHeartbeat(Map> conts, boolean isHealthy, int resId) throws Exception { NodeHeartbeatRequest req = Records.newRecord(NodeHeartbeatRequest.class); NodeStatus status = Records.newRecord(NodeStatus.class); @@ -133,8 +133,8 @@ public class MockNM { status.setNodeHealthStatus(healthStatus); req.setNodeStatus(status); req.setLastKnownMasterKey(this.currentMasterKey); - HeartbeatResponse heartbeatResponse = - resourceTracker.nodeHeartbeat(req).getHeartbeatResponse(); + NodeHeartbeatResponse heartbeatResponse = + resourceTracker.nodeHeartbeat(req); MasterKey masterKeyFromRM = heartbeatResponse.getMasterKey(); this.currentMasterKey = (masterKeyFromRM != null diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java index 2c0fb6cf1d3..c3fe72d99cb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockNodes.java @@ -31,7 +31,7 @@ import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode; import org.apache.hadoop.yarn.server.resourcemanager.rmnode.UpdatedContainerInfo; @@ -187,11 +187,11 @@ public class MockNodes { } @Override - public void updateHeartbeatResponseForCleanup(HeartbeatResponse response) { + public void updateNodeHeartbeatResponseForCleanup(NodeHeartbeatResponse response) { } @Override - public HeartbeatResponse getLastHeartBeatResponse() { + public NodeHeartbeatResponse getLastNodeHeartBeatResponse() { return null; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/NodeManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/NodeManager.java index e7ad0314e8f..610ec0b3f7a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/NodeManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/NodeManager.java @@ -51,8 +51,8 @@ import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.ipc.RPCUtil; import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.NodeStatus; import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode; @@ -151,8 +151,8 @@ public class NodeManager implements ContainerManager { NodeHeartbeatRequest request = recordFactory .newRecordInstance(NodeHeartbeatRequest.class); request.setNodeStatus(nodeStatus); - HeartbeatResponse response = resourceTrackerService - .nodeHeartbeat(request).getHeartbeatResponse(); + NodeHeartbeatResponse response = resourceTrackerService + .nodeHeartbeat(request); responseID = response.getResponseId(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java index ca640b39e59..6705171de3c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java @@ -36,7 +36,7 @@ import org.apache.hadoop.yarn.api.records.ResourceRequest; import org.apache.hadoop.yarn.event.Dispatcher; import org.apache.hadoop.yarn.event.DrainDispatcher; import org.apache.hadoop.yarn.event.EventHandler; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState; @@ -92,15 +92,15 @@ public class TestApplicationCleanup { Assert.assertEquals(request, contReceived); am.unregisterAppAttempt(); - HeartbeatResponse resp = nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, + NodeHeartbeatResponse resp = nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, ContainerState.COMPLETE); am.waitForState(RMAppAttemptState.FINISHED); //currently only containers are cleaned via this //AM container is cleaned via container launcher resp = nm1.nodeHeartbeat(true); - List contsToClean = resp.getContainersToCleanupList(); - List apps = resp.getApplicationsToCleanupList(); + List contsToClean = resp.getContainersToCleanup(); + List apps = resp.getApplicationsToCleanup(); int cleanedConts = contsToClean.size(); int cleanedApps = apps.size(); waitCount = 0; @@ -109,8 +109,8 @@ public class TestApplicationCleanup { + cleanedConts + " cleanedApps: " + cleanedApps); Thread.sleep(100); resp = nm1.nodeHeartbeat(true); - contsToClean = resp.getContainersToCleanupList(); - apps = resp.getApplicationsToCleanupList(); + contsToClean = resp.getContainersToCleanup(); + apps = resp.getApplicationsToCleanup(); cleanedConts += contsToClean.size(); cleanedApps += apps.size(); } @@ -198,9 +198,9 @@ public class TestApplicationCleanup { .getId(), ContainerState.RUNNING, "nothing", 0)); containerStatuses.put(app.getApplicationId(), containerStatusList); - HeartbeatResponse resp = nm1.nodeHeartbeat(containerStatuses, true); + NodeHeartbeatResponse resp = nm1.nodeHeartbeat(containerStatuses, true); dispatcher.await(); - List contsToClean = resp.getContainersToCleanupList(); + List contsToClean = resp.getContainersToCleanup(); int cleanedConts = contsToClean.size(); waitCount = 0; while (cleanedConts < 1 && waitCount++ < 200) { @@ -208,7 +208,7 @@ public class TestApplicationCleanup { Thread.sleep(100); resp = nm1.nodeHeartbeat(true); dispatcher.await(); - contsToClean = resp.getContainersToCleanupList(); + contsToClean = resp.getContainersToCleanup(); cleanedConts += contsToClean.size(); } LOG.info("Got cleanup for " + contsToClean.get(0)); @@ -226,7 +226,7 @@ public class TestApplicationCleanup { resp = nm1.nodeHeartbeat(containerStatuses, true); dispatcher.await(); - contsToClean = resp.getContainersToCleanupList(); + contsToClean = resp.getContainersToCleanup(); cleanedConts = contsToClean.size(); // The cleanup list won't be instantaneous as it is given out by scheduler // and not RMNodeImpl. @@ -236,7 +236,7 @@ public class TestApplicationCleanup { Thread.sleep(100); resp = nm1.nodeHeartbeat(true); dispatcher.await(); - contsToClean = resp.getContainersToCleanupList(); + contsToClean = resp.getContainersToCleanup(); cleanedConts += contsToClean.size(); } LOG.info("Got cleanup for " + contsToClean.get(0)); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java index e165e417cd9..cd5d2a23cbc 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java @@ -38,7 +38,7 @@ import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.event.EventHandler; import org.apache.hadoop.yarn.event.InlineDispatcher; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeCleanAppEvent; import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeCleanContainerEvent; import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeEvent; @@ -118,7 +118,7 @@ public class TestRMNodeTransitions { } private RMNodeStatusEvent getMockRMNodeStatusEvent() { - HeartbeatResponse response = mock(HeartbeatResponse.class); + NodeHeartbeatResponse response = mock(NodeHeartbeatResponse.class); NodeHealthStatus healthStatus = mock(NodeHealthStatus.class); Boolean yes = new Boolean(true); @@ -325,14 +325,14 @@ public class TestRMNodeTransitions { node.handle(statusEvent); Assert.assertEquals(1, node.getContainersToCleanUp().size()); Assert.assertEquals(1, node.getAppsToCleanup().size()); - HeartbeatResponse hbrsp = Records.newRecord(HeartbeatResponse.class); - node.updateHeartbeatResponseForCleanup(hbrsp); + NodeHeartbeatResponse hbrsp = Records.newRecord(NodeHeartbeatResponse.class); + node.updateNodeHeartbeatResponseForCleanup(hbrsp); Assert.assertEquals(0, node.getContainersToCleanUp().size()); Assert.assertEquals(0, node.getAppsToCleanup().size()); - Assert.assertEquals(1, hbrsp.getContainersToCleanupCount()); - Assert.assertEquals(completedContainerId, hbrsp.getContainerToCleanup(0)); - Assert.assertEquals(1, hbrsp.getApplicationsToCleanupCount()); - Assert.assertEquals(finishedAppId, hbrsp.getApplicationsToCleanup(0)); + Assert.assertEquals(1, hbrsp.getContainersToCleanup().size()); + Assert.assertEquals(completedContainerId, hbrsp.getContainersToCleanup().get(0)); + Assert.assertEquals(1, hbrsp.getApplicationsToCleanup().size()); + Assert.assertEquals(finishedAppId, hbrsp.getApplicationsToCleanup().get(0)); } private RMNodeImpl getRunningNode() { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java index 63868b0c490..2057d8ab419 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java @@ -31,7 +31,7 @@ import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerState; import org.apache.hadoop.yarn.api.records.ResourceRequest; import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.NodeAction; import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore; import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationAttemptState; @@ -219,7 +219,7 @@ public class TestRMRestart { Assert.assertTrue(allocResponse.getReboot()); // NM should be rebooted on heartbeat, even first heartbeat for nm2 - HeartbeatResponse hbResponse = nm1.nodeHeartbeat(true); + NodeHeartbeatResponse hbResponse = nm1.nodeHeartbeat(true); Assert.assertEquals(NodeAction.REBOOT, hbResponse.getNodeAction()); hbResponse = nm2.nodeHeartbeat(true); Assert.assertEquals(NodeAction.REBOOT, hbResponse.getNodeAction()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java index 7e5b5da9356..cf679137f35 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java @@ -36,9 +36,9 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.event.Dispatcher; import org.apache.hadoop.yarn.event.DrainDispatcher; import org.apache.hadoop.yarn.event.EventHandler; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerResponse; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.NodeAction; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEvent; @@ -75,7 +75,7 @@ public class TestResourceTrackerService { assert(metrics != null); int metricCount = metrics.getNumDecommisionedNMs(); - HeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); + NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertTrue(NodeAction.NORMAL.equals(nodeHeartbeat.getNodeAction())); nodeHeartbeat = nm2.nodeHeartbeat(true); Assert.assertTrue(NodeAction.NORMAL.equals(nodeHeartbeat.getNodeAction())); @@ -124,7 +124,7 @@ public class TestResourceTrackerService { int metricCount = ClusterMetrics.getMetrics().getNumDecommisionedNMs(); - HeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); + NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertTrue(NodeAction.NORMAL.equals(nodeHeartbeat.getNodeAction())); nodeHeartbeat = nm2.nodeHeartbeat(true); Assert.assertTrue(NodeAction.NORMAL.equals(nodeHeartbeat.getNodeAction())); @@ -161,7 +161,7 @@ public class TestResourceTrackerService { ClusterMetrics metrics = ClusterMetrics.getMetrics(); assert(metrics != null); int initialMetricCount = metrics.getNumDecommisionedNMs(); - HeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); + NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals( NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); @@ -198,7 +198,7 @@ public class TestResourceTrackerService { ClusterMetrics metrics = ClusterMetrics.getMetrics(); assert(metrics != null); int initialMetricCount = metrics.getNumDecommisionedNMs(); - HeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); + NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertEquals( NodeAction.NORMAL, nodeHeartbeat.getNodeAction()); @@ -254,7 +254,7 @@ public class TestResourceTrackerService { MockNM nm2 = rm.registerNode("host2:1234", 2048); int initialMetricCount = ClusterMetrics.getMetrics().getNumRebootedNMs(); - HeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); + NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true); Assert.assertTrue(NodeAction.NORMAL.equals(nodeHeartbeat.getNodeAction())); nodeHeartbeat = nm2.nodeHeartbeat( @@ -351,7 +351,7 @@ public class TestResourceTrackerService { // reconnect of healthy node nm1 = rm.registerNode("host1:1234", 5120); - HeartbeatResponse response = nm1.nodeHeartbeat(true); + NodeHeartbeatResponse response = nm1.nodeHeartbeat(true); Assert.assertTrue(NodeAction.NORMAL.equals(response.getNodeAction())); dispatcher.await(); Assert.assertEquals(expectedNMs, ClusterMetrics.getMetrics().getNumActiveNMs()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java index 6ec3f5403b9..8ca0b43c35f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java @@ -109,7 +109,7 @@ public class TestNMExpiry { .newRecordInstance(NodeHeartbeatRequest.class); request.setNodeStatus(nodeStatus); lastResponseID = resourceTrackerService.nodeHeartbeat(request) - .getHeartbeatResponse().getResponseId(); + .getResponseId(); Thread.sleep(1000); } catch(Exception e) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java index 7d7f99d054e..984d7cdfcf5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java @@ -31,8 +31,8 @@ import org.apache.hadoop.yarn.event.InlineDispatcher; import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.NodeAction; import org.apache.hadoop.yarn.server.resourcemanager.NMLivelinessMonitor; import org.apache.hadoop.yarn.server.resourcemanager.NodesListManager; @@ -116,23 +116,20 @@ public class TestRMNMRPCResponseId { nodeHeartBeatRequest.setNodeStatus(nodeStatus); nodeStatus.setResponseId(0); - HeartbeatResponse response = resourceTrackerService.nodeHeartbeat( - nodeHeartBeatRequest).getHeartbeatResponse(); + NodeHeartbeatResponse response = resourceTrackerService.nodeHeartbeat( + nodeHeartBeatRequest); Assert.assertTrue(response.getResponseId() == 1); nodeStatus.setResponseId(response.getResponseId()); - response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest) - .getHeartbeatResponse(); + response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest); Assert.assertTrue(response.getResponseId() == 2); /* try calling with less response id */ - response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest) - .getHeartbeatResponse(); + response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest); Assert.assertTrue(response.getResponseId() == 2); nodeStatus.setResponseId(0); - response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest) - .getHeartbeatResponse(); + response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest); Assert.assertTrue(NodeAction.REBOOT.equals(response.getNodeAction())); } } \ No newline at end of file diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java index 452508ff4af..68a00362d3f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java @@ -361,8 +361,7 @@ public class MiniYARNCluster extends CompositeService { NodeHeartbeatResponse response = recordFactory.newRecordInstance( NodeHeartbeatResponse.class); try { - response.setHeartbeatResponse(rt.nodeHeartbeat(request) - .getHeartbeatResponse()); + response = rt.nodeHeartbeat(request); } catch (IOException ioe) { LOG.info("Exception in heartbeat from node " + request.getNodeStatus().getNodeId(), ioe); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestRMNMSecretKeys.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestRMNMSecretKeys.java index 7bd1ff2032d..5bc2f7ad0c9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestRMNMSecretKeys.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestRMNMSecretKeys.java @@ -27,7 +27,7 @@ import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.event.Dispatcher; import org.apache.hadoop.yarn.event.DrainDispatcher; -import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse; +import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.MasterKey; import org.apache.hadoop.yarn.server.api.records.RegistrationResponse; import org.apache.hadoop.yarn.server.resourcemanager.MockNM; @@ -67,7 +67,7 @@ public class TestRMNMSecretKeys { Assert.assertNotNull("Registration should cause a key-update!", masterKey); dispatcher.await(); - HeartbeatResponse response = nm.nodeHeartbeat(true); + NodeHeartbeatResponse response = nm.nodeHeartbeat(true); Assert.assertNull( "First heartbeat after registration shouldn't get any key updates!", response.getMasterKey());