hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jia...@apache.org
Subject svn commit: r1609584 - in /hadoop/common/trunk/hadoop-yarn-project: ./ hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/
Date Thu, 10 Jul 2014 22:36:13 GMT
Author: jianhe
Date: Thu Jul 10 22:36:13 2014
New Revision: 1609584

URL: http://svn.apache.org/r1609584
Log:
YARN-2088. Fixed a bug in GetApplicationsRequestPBImpl#mergeLocalToBuilder. Contributed by
Binglin Chang

Modified:
    hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
    hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsRequestPBImpl.java
    hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestGetApplicationsRequest.java

Modified: hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt?rev=1609584&r1=1609583&r2=1609584&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt Thu Jul 10 22:36:13 2014
@@ -83,6 +83,9 @@ Release 2.5.0 - UNRELEASED
     YARN-2181. Added preemption info to logs and RM web UI. (Wangda Tan via
     jianhe)
 
+    YARN-2088. Fixed a bug in GetApplicationsRequestPBImpl#mergeLocalToBuilder.
+    (Binglin Chang via jianhe)
+
   IMPROVEMENTS
 
     YARN-1479. Invalid NaN values in Hadoop REST API JSON response (Chen He via

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsRequestPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsRequestPBImpl.java?rev=1609584&r1=1609583&r2=1609584&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsRequestPBImpl.java
(original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsRequestPBImpl.java
Thu Jul 10 22:36:13 2014
@@ -20,7 +20,6 @@ package org.apache.hadoop.yarn.api.proto
 
 import java.util.EnumSet;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -35,6 +34,8 @@ import org.apache.hadoop.yarn.proto.Yarn
 import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationsRequestProto;
 import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationsRequestProtoOrBuilder;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
 import com.google.protobuf.TextFormat;
 
 @Private
@@ -49,7 +50,8 @@ public class GetApplicationsRequestPBImp
   Set<String> users = null;
   Set<String> queues = null;
   long limit = Long.MAX_VALUE;
-  LongRange start = null, finish = null;
+  LongRange start = null;
+  LongRange finish = null;
   private Set<String> applicationTags;
   private ApplicationsRequestScope scope;
 
@@ -78,76 +80,46 @@ public class GetApplicationsRequestPBImp
   }
 
   private void mergeLocalToBuilder() {
-    if (this.applicationTypes != null) {
-      addLocalApplicationTypesToProto();
+    if (applicationTypes != null && !applicationTypes.isEmpty()) {
+      builder.clearApplicationTypes();
+      builder.addAllApplicationTypes(applicationTypes);
     }
-    if (this.applicationStates != null) {
-      maybeInitBuilder();
+    if (applicationStates != null && !applicationStates.isEmpty()) {
       builder.clearApplicationStates();
-      Iterable<YarnApplicationStateProto> iterable =
-          new Iterable<YarnApplicationStateProto>() {
-
+      builder.addAllApplicationStates(Iterables.transform(applicationStates,
+          new Function<YarnApplicationState, YarnApplicationStateProto>() {
             @Override
-            public Iterator<YarnApplicationStateProto> iterator() {
-              return new Iterator<YarnApplicationStateProto>() {
-
-                Iterator<YarnApplicationState> iter = applicationStates
-                    .iterator();
-
-                @Override
-                public boolean hasNext() {
-                  return iter.hasNext();
-                }
-
-                @Override
-                public YarnApplicationStateProto next() {
-                  return ProtoUtils.convertToProtoFormat(iter.next());
-                }
-
-                @Override
-                public void remove() {
-                  throw new UnsupportedOperationException();
-
-                }
-              };
-
+            public YarnApplicationStateProto apply(YarnApplicationState input) {
+              return ProtoUtils.convertToProtoFormat(input);
             }
-          };
-      builder.addAllApplicationStates(iterable);
+          }));
     }
-    if (this.applicationTags != null && !this.applicationTags.isEmpty()) {
+    if (applicationTags != null && !applicationTags.isEmpty()) {
+      builder.clearApplicationTags();
       builder.addAllApplicationTags(this.applicationTags);
     }
-    if (this.scope != null) {
+    if (scope != null) {
       builder.setScope(ProtoUtils.convertToProtoFormat(scope));
     }
-    if (this.start != null) {
+    if (start != null) {
       builder.setStartBegin(start.getMinimumLong());
       builder.setStartEnd(start.getMaximumLong());
     }
-    
-    if (this.finish != null) {
+    if (finish != null) {
       builder.setFinishBegin(finish.getMinimumLong());
       builder.setFinishEnd(finish.getMaximumLong());
     }
-    
-    builder.setLimit(limit);
-    
-    if (this.users != null && !this.users.isEmpty()) {
-      builder.addAllUsers(this.users);
+    if (limit != Long.MAX_VALUE) {
+      builder.setLimit(limit);
     }
-    
-    if (this.queues != null && !this.queues.isEmpty()) {
-      builder.addAllQueues(this.queues);
+    if (users != null && !users.isEmpty()) {
+      builder.clearUsers();
+      builder.addAllUsers(users);
+    }
+    if (queues != null && !queues.isEmpty()) {
+      builder.clearQueues();
+      builder.addAllQueues(queues);
     }
-  }
-
-  private void addLocalApplicationTypesToProto() {
-    maybeInitBuilder();
-    builder.clearApplicationTypes();
-    if (this.applicationTypes == null)
-      return;
-    builder.addAllApplicationTypes(applicationTypes);
   }
 
   private void maybeInitBuilder() {

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestGetApplicationsRequest.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestGetApplicationsRequest.java?rev=1609584&r1=1609583&r2=1609584&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestGetApplicationsRequest.java
(original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestGetApplicationsRequest.java
Thu Jul 10 22:36:13 2014
@@ -72,6 +72,9 @@ public class TestGetApplicationsRequest 
     GetApplicationsRequest requestFromProto = new GetApplicationsRequestPBImpl(
         ((GetApplicationsRequestPBImpl)request).getProto());
     
+    // verify the whole record equals with original record
+    Assert.assertEquals(requestFromProto, request);
+
     // verify all properties are the same as original request
     Assert.assertEquals(
         "ApplicationStates from proto is not the same with original request",



Mime
View raw message