ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ag...@apache.org
Subject ignite git commit: Compilation fixed
Date Tue, 09 Jan 2018 10:10:35 GMT
Repository: ignite
Updated Branches:
  refs/heads/master daf70d24a -> dd2fe1bce


Compilation fixed


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

Branch: refs/heads/master
Commit: dd2fe1bcefcabc05ab5a09139d6be5ff5f7348d3
Parents: daf70d2
Author: Andrey Gura <agura@apache.org>
Authored: Tue Jan 9 13:10:18 2018 +0300
Committer: Andrey Gura <agura@apache.org>
Committed: Tue Jan 9 13:10:18 2018 +0300

----------------------------------------------------------------------
 .../ipfinder/elb/TcpDiscoveryElbIpFinder.java   | 78 ++++++++++----------
 .../elb/TcpDiscoveryElbIpFinderSelfTest.java    |  9 +--
 .../ignite/testsuites/IgniteElbTestSuite.java   | 17 +++++
 3 files changed, 60 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dd2fe1bc/modules/aws/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/aws/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinder.java
b/modules/aws/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinder.java
index cfce92a..5fcf792 100644
--- a/modules/aws/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinder.java
+++ b/modules/aws/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinder.java
@@ -20,11 +20,13 @@ import com.amazonaws.auth.AWSCredentialsProvider;
 import com.amazonaws.services.ec2.AmazonEC2;
 import com.amazonaws.services.ec2.AmazonEC2ClientBuilder;
 import com.amazonaws.services.ec2.model.DescribeInstancesRequest;
+import com.amazonaws.services.ec2.model.Reservation;
 import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancing;
 import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClientBuilder;
 import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest;
 import com.amazonaws.services.elasticloadbalancing.model.Instance;
 import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription;
+import java.util.ArrayList;
 import org.apache.ignite.spi.IgniteSpiConfiguration;
 import org.apache.ignite.spi.IgniteSpiException;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAdapter;
@@ -34,7 +36,6 @@ import java.util.Collection;
 import java.util.List;
 
 import static com.amazonaws.util.StringUtils.isNullOrEmpty;
-import static java.util.stream.Collectors.toList;
 
 /**
  * AWS ELB-based IP finder.
@@ -67,7 +68,7 @@ public class TcpDiscoveryElbIpFinder extends TcpDiscoveryIpFinderAdapter
{
     private AmazonEC2 amazonEC2Client;
 
     /** */
-    private AWSCredentialsProvider credentialsProvider;
+    private AWSCredentialsProvider credsProvider;
 
     /** */
     private String region;
@@ -82,47 +83,53 @@ public class TcpDiscoveryElbIpFinder extends TcpDiscoveryIpFinderAdapter
{
         setShared(true);
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException
{
+    /** {@inheritDoc} */
+    @Override public Collection<InetSocketAddress> getRegisteredAddresses() throws
IgniteSpiException {
         initClients();
 
+        List<String> instanceIds = new ArrayList<>();
+
         DescribeLoadBalancersRequest req = new DescribeLoadBalancersRequest().withLoadBalancerNames(loadBalancerName);
 
-        List<String> instanceIds = amazonELBClient.describeLoadBalancers(req)
-            .getLoadBalancerDescriptions()
-            .stream()
-            .map(LoadBalancerDescription::getInstances)
-            .flatMap(instances -> instances.stream())
-            .map(Instance::getInstanceId)
-            .collect(toList());
-
-        return amazonEC2Client.describeInstances(new DescribeInstancesRequest().withInstanceIds(instanceIds))
-            .getReservations()
-            .stream()
-            .flatMap(reservation -> reservation.getInstances().stream())
-            .map(instance -> new InetSocketAddress(instance.getPrivateIpAddress(), 0))
-            .collect(toList());
+        List<LoadBalancerDescription> descs = amazonELBClient.describeLoadBalancers(req).getLoadBalancerDescriptions();
+
+        for (LoadBalancerDescription desc : descs) {
+            for (Instance instance : desc.getInstances())
+                instanceIds.add(instance.getInstanceId());
+        }
+
+        DescribeInstancesRequest instReq = new DescribeInstancesRequest().withInstanceIds(instanceIds);
+
+        List<Reservation> reservations = amazonEC2Client.describeInstances(instReq).getReservations();
+
+        List<InetSocketAddress> addrs = new ArrayList<>();
+
+        for (Reservation reservation : reservations) {
+            List<com.amazonaws.services.ec2.model.Instance> instances = reservation.getInstances();
+
+            for (com.amazonaws.services.ec2.model.Instance instance : instances)
+                addrs.add(new InetSocketAddress(instance.getPrivateIpAddress(), 0));
+        }
+
+        return addrs;
     }
 
     /**
      * Initializing the IP finder.
      */
     private void initClients() {
-        if (credentialsProvider == null || isNullOrEmpty(loadBalancerName) || isNullOrEmpty(region))
+        if (credsProvider == null || isNullOrEmpty(loadBalancerName) || isNullOrEmpty(region))
             throw new IgniteSpiException("One or more configuration parameters are invalid
[setCredentialsProvider=" +
-                credentialsProvider + ", setRegion=" + region + ", setLoadBalancerName="
+
+                credsProvider + ", setRegion=" + region + ", setLoadBalancerName=" +
                 loadBalancerName + "]");
 
         if (amazonEC2Client == null)
-            amazonEC2Client = AmazonEC2ClientBuilder.standard().withRegion(region).withCredentials(credentialsProvider)
+            amazonEC2Client = AmazonEC2ClientBuilder.standard().withRegion(region).withCredentials(credsProvider)
                 .build();
 
         if (amazonELBClient == null)
             amazonELBClient = AmazonElasticLoadBalancingClientBuilder.standard().withRegion(region)
-                .withCredentials(credentialsProvider).build();
+                .withCredentials(credsProvider).build();
     }
 
     /**
@@ -153,27 +160,20 @@ public class TcpDiscoveryElbIpFinder extends TcpDiscoveryIpFinderAdapter
{
      *
      * For details refer to Amazon API reference.
      *
-     * @param credentialsProvider AWS credentials provider.
-     * @return {@code this} for chaining.
+     * @param credsProvider AWS credentials provider.
      */
     @IgniteSpiConfiguration(optional = false)
-    public void setCredentialsProvider(AWSCredentialsProvider credentialsProvider) {
-        this.credentialsProvider = credentialsProvider;
+    public void setCredentialsProvider(AWSCredentialsProvider credsProvider) {
+        this.credsProvider = credsProvider;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void registerAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException
{
+    /** {@inheritDoc} */
+    @Override public void registerAddresses(Collection<InetSocketAddress> addrs) throws
IgniteSpiException {
         //No-op, ELB will take care of registration.
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void unregisterAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException
{
+    /** {@inheritDoc} */
+    @Override public void unregisterAddresses(Collection<InetSocketAddress> addrs)
throws IgniteSpiException {
         // No-op, ELB will take care of this process.
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/dd2fe1bc/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinderSelfTest.java
b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinderSelfTest.java
index a58d8d0..1217d8b 100644
--- a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinderSelfTest.java
+++ b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinderSelfTest.java
@@ -23,8 +23,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAbstract
 /**
  * TcpDiscoveryElbIpFinderSelfTest test.
  */
-public class TcpDiscoveryElbIpFinderSelfTest extends
-    TcpDiscoveryIpFinderAbstractSelfTest<TcpDiscoveryElbIpFinder> {
+public class TcpDiscoveryElbIpFinderSelfTest extends TcpDiscoveryIpFinderAbstractSelfTest<TcpDiscoveryElbIpFinder>
{
     /**
      * Constructor.
      *
@@ -34,17 +33,17 @@ public class TcpDiscoveryElbIpFinderSelfTest extends
         // No-op.
     }
 
+    /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
         // No-op.
     }
 
-    /* {@inheritDoc} */
+    /** {@inheritDoc} */
     @Override protected TcpDiscoveryElbIpFinder ipFinder() throws Exception {
-        // No-op.
         return null;
     }
 
-    /* {@inheritDoc} */
+    /** {@inheritDoc} */
     @Override public void testIpFinder() throws Exception {
         TcpDiscoveryElbIpFinder ipFinder = new TcpDiscoveryElbIpFinder();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/dd2fe1bc/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteElbTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteElbTestSuite.java
b/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteElbTestSuite.java
index af6e213..28f7e0e 100644
--- a/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteElbTestSuite.java
+++ b/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteElbTestSuite.java
@@ -1,3 +1,20 @@
+/*
+ * 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.ignite.testsuites;
 
 import junit.framework.TestSuite;


Mime
View raw message