ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adorosz...@apache.org
Subject [11/46] ambari git commit: AMBARI-22325. Fix impossible equality: ComponentV2 vs ProvisionAction (adoroszlai)
Date Fri, 08 Dec 2017 19:26:11 GMT
AMBARI-22325. Fix impossible equality: ComponentV2 vs ProvisionAction (adoroszlai)


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

Branch: refs/heads/branch-feature-AMBARI-14714-blueprintv2
Commit: be519e0af34e36f4dcf85f996db5d8fc471bc598
Parents: c859a1b
Author: Attila Doroszlai <adoroszlai@hortonworks.com>
Authored: Mon Nov 13 10:32:43 2017 +0100
Committer: Doroszlai, Attila <adoroszlai@hortonworks.com>
Committed: Fri Dec 8 20:24:24 2017 +0100

----------------------------------------------------------------------
 .../ambari/server/topology/HostGroupV2Impl.java | 33 +++++++-------------
 1 file changed, 12 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/be519e0a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
index dd7a316..ff82ecf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
@@ -17,23 +17,18 @@
  */
 package org.apache.ambari.server.topology;
 
+import static java.util.stream.Collectors.toList;
+
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import javax.annotation.Nullable;
-
 import org.apache.ambari.server.controller.internal.ProvisionAction;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
 
 public class HostGroupV2Impl implements HostGroupV2, Configurable {
 
@@ -73,22 +68,18 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
   @Override
   @JsonIgnore
   public Collection<String> getComponentNames() {
-    return getComponentNames(components);
-  }
-
-  private Collection<String> getComponentNames(List<ComponentV2> components)
{
-    return Lists.transform(components,
-      new Function<ComponentV2, String>() {
-        @Override public String apply(@Nullable ComponentV2 input) { return input.getName();
}
-      });
+    return components.stream()
+      .map(ComponentV2::getName)
+      .collect(toList());
   }
 
   @Override
   @JsonIgnore
   public Collection<String> getComponentNames(ProvisionAction provisionAction) {
-    List<ComponentV2> filtered =
-      ImmutableList.copyOf(Collections2.filter(components, Predicates.equalTo(provisionAction)));
-    return getComponentNames(filtered);
+    return components.stream()
+      .filter(c -> c.getProvisionAction().equals(provisionAction))
+      .map(ComponentV2::getName)
+      .collect(toList());
   }
 
   @Override
@@ -98,7 +89,7 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
 
   @Override
   public Collection<ComponentV2> getComponentsByServiceId(ServiceId serviceId) {
-    return components.stream().filter(c -> c.getServiceId().equals(serviceId)).collect(Collectors.toList());
+    return components.stream().filter(c -> c.getServiceId().equals(serviceId)).collect(toList());
   }
 
   @Override
@@ -128,13 +119,13 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
   @Override
   @JsonIgnore
   public Collection<String> getServiceNames() {
-    return serviceMap.values().stream().map(Service::getName).collect(Collectors.toList());
+    return serviceMap.values().stream().map(Service::getName).collect(toList());
   }
 
   @JsonIgnore
   public void setServiceMap(Map<ServiceId, Service> serviceMap) {
     Preconditions.checkArgument(serviceMap.keySet().equals(this.serviceIds),
-      "Maitained list of service ids doesn't match with received service map: %s vs %s",
serviceIds, serviceMap.keySet());
+      "Maintained list of service ids doesn't match with received service map: %s vs %s",
serviceIds, serviceMap.keySet());
     this.serviceMap = serviceMap;
   }
 


Mime
View raw message