hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject [35/35] hadoop git commit: YARN-4647. Make RegisterNodeManagerRequestPBImpl thread-safe. (kasha)
Date Fri, 29 Jan 2016 16:29:38 GMT
YARN-4647. Make RegisterNodeManagerRequestPBImpl thread-safe. (kasha)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c9a09d69
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c9a09d69
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c9a09d69

Branch: refs/heads/YARN-1011
Commit: c9a09d6926b258e205a4ff7998ce5a86bf5dbe3b
Parents: a277bdc
Author: Karthik Kambatla <kasha@apache.org>
Authored: Fri Jan 29 08:12:54 2016 -0800
Committer: Karthik Kambatla <kasha@apache.org>
Committed: Fri Jan 29 08:12:54 2016 -0800

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  2 +
 .../pb/RegisterNodeManagerRequestPBImpl.java    | 75 +++++++++++---------
 2 files changed, 42 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/c9a09d69/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index 138e581..76cad7f 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -113,6 +113,8 @@ Release 2.9.0 - UNRELEASED
     integrated ResourceHandler mechanism, and also deprecated the old
     LCEResourceHandler inteface hierarchy. (Varun Vasudev via vinodkv)
 
+    YARN-4647. Make RegisterNodeManagerRequestPBImpl thread-safe. (kasha)
+
   OPTIMIZATIONS
 
   BUG FIXES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c9a09d69/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/RegisterNodeManagerRequestPBImpl.java
----------------------------------------------------------------------
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/RegisterNodeManagerRequestPBImpl.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/RegisterNodeManagerRequestPBImpl.java
index 5b0e0a1..2a1a268 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/RegisterNodeManagerRequestPBImpl.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/RegisterNodeManagerRequestPBImpl.java
@@ -65,14 +65,14 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
     viaProto = true;
   }
   
-  public RegisterNodeManagerRequestProto getProto() {
-      mergeLocalToProto();
+  public synchronized RegisterNodeManagerRequestProto getProto() {
+    mergeLocalToProto();
     proto = viaProto ? proto : builder.build();
     viaProto = true;
     return proto;
   }
 
-  private void mergeLocalToBuilder() {
+  private synchronized void mergeLocalToBuilder() {
     if (this.containerStatuses != null) {
       addNMContainerStatusesToProto();
     }
@@ -107,15 +107,16 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
   }
 
     
-  private void mergeLocalToProto() {
-    if (viaProto) 
+  private synchronized void mergeLocalToProto() {
+    if (viaProto) {
       maybeInitBuilder();
+    }
     mergeLocalToBuilder();
     proto = builder.build();
     viaProto = true;
   }
 
-  private void maybeInitBuilder() {
+  private synchronized void maybeInitBuilder() {
     if (viaProto || builder == null) {
       builder = RegisterNodeManagerRequestProto.newBuilder(proto);
     }
@@ -124,7 +125,7 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
     
   
   @Override
-  public Resource getResource() {
+  public synchronized Resource getResource() {
     RegisterNodeManagerRequestProtoOrBuilder p = viaProto ? proto : builder;
     if (this.resource != null) {
       return this.resource;
@@ -137,7 +138,7 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
   }
 
   @Override
-  public void setResource(Resource resource) {
+  public synchronized void setResource(Resource resource) {
     maybeInitBuilder();
     if (resource == null) 
       builder.clearResource();
@@ -145,7 +146,7 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
   }
 
   @Override
-  public NodeId getNodeId() {
+  public synchronized NodeId getNodeId() {
     RegisterNodeManagerRequestProtoOrBuilder p = viaProto ? proto : builder;
     if (this.nodeId != null) {
       return this.nodeId;
@@ -158,15 +159,16 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
   }
 
   @Override
-  public void setNodeId(NodeId nodeId) {
+  public synchronized void setNodeId(NodeId nodeId) {
     maybeInitBuilder();
-    if (nodeId == null) 
+    if (nodeId == null) {
       builder.clearNodeId();
+    }
     this.nodeId = nodeId;
   }
 
   @Override
-  public int getHttpPort() {
+  public synchronized int getHttpPort() {
     RegisterNodeManagerRequestProtoOrBuilder p = viaProto ? proto : builder;
     if (!p.hasHttpPort()) {
       return 0;
@@ -175,18 +177,18 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
   }
 
   @Override
-  public void setHttpPort(int httpPort) {
+  public synchronized void setHttpPort(int httpPort) {
     maybeInitBuilder();
     builder.setHttpPort(httpPort);
   }
   
   @Override
-  public List<ApplicationId> getRunningApplications() {
+  public synchronized List<ApplicationId> getRunningApplications() {
     initRunningApplications();
     return runningApplications;
   }
   
-  private void initRunningApplications() {
+  private synchronized void initRunningApplications() {
     if (this.runningApplications != null) {
       return;
     }
@@ -199,7 +201,7 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
   }
 
   @Override
-  public void setRunningApplications(List<ApplicationId> apps) {
+  public synchronized void setRunningApplications(List<ApplicationId> apps) {
     if (apps == null) {
       return;
     }
@@ -207,7 +209,7 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
     this.runningApplications.addAll(apps);
   }
   
-  private void addRunningApplicationsToProto() {
+  private synchronized void addRunningApplicationsToProto() {
     maybeInitBuilder();
     builder.clearRunningApplications();
     if (runningApplications == null) {
@@ -241,12 +243,12 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
   }
 
   @Override
-  public List<NMContainerStatus> getNMContainerStatuses() {
+  public synchronized List<NMContainerStatus> getNMContainerStatuses() {
     initContainerRecoveryReports();
     return containerStatuses;
   }
   
-  private void initContainerRecoveryReports() {
+  private synchronized void initContainerRecoveryReports() {
     if (this.containerStatuses != null) {
       return;
     }
@@ -259,7 +261,7 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
   }
 
   @Override
-  public void setContainerStatuses(
+  public synchronized void setContainerStatuses(
       List<NMContainerStatus> containerReports) {
     if (containerReports == null) {
       return;
@@ -284,7 +286,7 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
   }
   
   @Override
-  public String getNMVersion() {
+  public synchronized String getNMVersion() {
     RegisterNodeManagerRequestProtoOrBuilder p = viaProto ? proto : builder;
     if (!p.hasNmVersion()) {
       return "";
@@ -293,25 +295,25 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
   }
 
   @Override
-  public void setNMVersion(String version) {
+  public synchronized void setNMVersion(String version) {
     maybeInitBuilder();
     builder.setNmVersion(version);
   }
   
   @Override
-  public Set<NodeLabel> getNodeLabels() {
+  public synchronized Set<NodeLabel> getNodeLabels() {
     initNodeLabels();
     return this.labels;
   }
 
   @Override
-  public void setNodeLabels(Set<NodeLabel> nodeLabels) {
+  public synchronized void setNodeLabels(Set<NodeLabel> nodeLabels) {
     maybeInitBuilder();
     builder.clearNodeLabels();
     this.labels = nodeLabels;
   }
   
-  private void initNodeLabels() {
+  private synchronized void initNodeLabels() {
     if (this.labels != null) {
       return;
     }
@@ -327,43 +329,46 @@ public class RegisterNodeManagerRequestPBImpl extends RegisterNodeManagerRequest
     }
   }
 
-  private NodeLabelPBImpl convertFromProtoFormat(NodeLabelProto p) {
+  private static NodeLabelPBImpl convertFromProtoFormat(NodeLabelProto p) {
     return new NodeLabelPBImpl(p);
   }
 
-  private NodeLabelProto convertToProtoFormat(NodeLabel t) {
+  private static NodeLabelProto convertToProtoFormat(NodeLabel t) {
     return ((NodeLabelPBImpl)t).getProto();
   }
 
-  private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) {
+  private static ApplicationIdPBImpl convertFromProtoFormat(
+      ApplicationIdProto p) {
     return new ApplicationIdPBImpl(p);
   }
 
-  private ApplicationIdProto convertToProtoFormat(ApplicationId t) {
+  private static ApplicationIdProto convertToProtoFormat(ApplicationId t) {
     return ((ApplicationIdPBImpl)t).getProto();
   }
 
-  private NodeIdPBImpl convertFromProtoFormat(NodeIdProto p) {
+  private static NodeIdPBImpl convertFromProtoFormat(NodeIdProto p) {
     return new NodeIdPBImpl(p);
   }
 
-  private NodeIdProto convertToProtoFormat(NodeId t) {
+  private static NodeIdProto convertToProtoFormat(NodeId t) {
     return ((NodeIdPBImpl)t).getProto();
   }
 
-  private ResourcePBImpl convertFromProtoFormat(ResourceProto p) {
+  private static ResourcePBImpl convertFromProtoFormat(ResourceProto p) {
     return new ResourcePBImpl(p);
   }
 
-  private ResourceProto convertToProtoFormat(Resource t) {
+  private static ResourceProto convertToProtoFormat(Resource t) {
     return ((ResourcePBImpl)t).getProto();
   }
 
-  private NMContainerStatusPBImpl convertFromProtoFormat(NMContainerStatusProto c) {
+  private static NMContainerStatusPBImpl convertFromProtoFormat(
+      NMContainerStatusProto c) {
     return new NMContainerStatusPBImpl(c);
   }
   
-  private NMContainerStatusProto convertToProtoFormat(NMContainerStatus c) {
+  private static NMContainerStatusProto convertToProtoFormat(
+      NMContainerStatus c) {
     return ((NMContainerStatusPBImpl)c).getProto();
   }
 }
\ No newline at end of file


Mime
View raw message