ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [13/22] ignite git commit: IGNITE-2355 Fixed the test HadoopClientProtocolMultipleServersSelfTest. Clear connection poll after the test, cosmetic.
Date Mon, 31 Oct 2016 13:48:14 GMT
IGNITE-2355 Fixed the test HadoopClientProtocolMultipleServersSelfTest. Clear connection poll
after the test, cosmetic.


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

Branch: refs/heads/ignite-4154
Commit: 66c76d1f30f024b58db8cab07ba9e7d429f596f8
Parents: 7290d88
Author: tledkov-gridgain <tledkov@gridgain.com>
Authored: Tue Oct 18 20:45:06 2016 +0500
Committer: tledkov-gridgain <tledkov@gridgain.com>
Committed: Tue Oct 18 20:45:06 2016 +0500

----------------------------------------------------------------------
 ...opClientProtocolMultipleServersSelfTest.java | 99 +++++++++-----------
 1 file changed, 44 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/66c76d1f/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java
b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java
index 0e51938..51b6164 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java
@@ -23,8 +23,8 @@ import java.io.OutputStreamWriter;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.Text;
@@ -44,6 +44,8 @@ import org.apache.ignite.IgniteFileSystem;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.hadoop.mapreduce.IgniteHadoopClientProtocolProvider;
 import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.client.GridClient;
 import org.apache.ignite.internal.client.GridServerUnreachableException;
 import org.apache.ignite.internal.processors.hadoop.impl.HadoopAbstractSelfTest;
 import org.apache.ignite.internal.processors.hadoop.impl.HadoopUtils;
@@ -79,6 +81,14 @@ public class HadoopClientProtocolMultipleServersSelfTest extends HadoopAbstractS
     @Override protected void afterTest() throws Exception {
         stopAllGrids();
 
+        ConcurrentHashMap<String, IgniteInternalFuture<GridClient>> cliMap =
+            GridTestUtils.getFieldValue(IgniteHadoopClientProtocolProvider.class, "cliMap");
+
+        for(IgniteInternalFuture<GridClient> fut : cliMap.values())
+            fut.get().close();
+
+        cliMap.clear();
+
         super.afterTest();
     }
 
@@ -114,7 +124,7 @@ public class HadoopClientProtocolMultipleServersSelfTest extends HadoopAbstractS
      * @param conf Hadoop configuration.
      * @throws Exception If failed.
      */
-    public void checkJobSubmit(Configuration conf) throws Exception {
+    private void checkJobSubmit(Configuration conf) throws Exception {
         final Job job = Job.getInstance(conf);
 
         job.setJobName(JOB_NAME);
@@ -144,22 +154,15 @@ public class HadoopClientProtocolMultipleServersSelfTest extends HadoopAbstractS
      */
     @SuppressWarnings("ConstantConditions")
     public void testMultipleAddresses() throws Exception {
-        try {
-            restPort = REST_PORT;
+        restPort = REST_PORT;
 
-            startGrids(gridCount());
+        startGrids(gridCount());
 
-            beforeJob();
+        beforeJob();
 
-            U.sleep(5000);
+        U.sleep(5000);
 
-            checkJobSubmit(configMultipleAddrs(gridCount()));
-        }
-        finally {
-            FileSystem fs = FileSystem.get(configMultipleAddrs(gridCount()));
-
-            fs.close();
-        }
+        checkJobSubmit(configMultipleAddrs(gridCount()));
     }
 
     /**
@@ -167,25 +170,18 @@ public class HadoopClientProtocolMultipleServersSelfTest extends HadoopAbstractS
      */
     @SuppressWarnings({"ConstantConditions", "ThrowableResultOfMethodCallIgnored"})
     public void testSingleAddress() throws Exception {
-        try {
-            // Don't use REST_PORT to test connection fails if the only this port is configured
-            restPort = REST_PORT + 1;
-
-            startGrids(gridCount());
-
-            GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() {
-                    @Override public Object call() throws Exception {
-                        checkJobSubmit(configSingleAddress());
-                        return null;
-                    }
-                },
-                GridServerUnreachableException.class, "Failed to connect to any of the servers
in list");
-        }
-        finally {
-            FileSystem fs = FileSystem.get(configSingleAddress());
-
-            fs.close();
-        }
+        // Don't use REST_PORT to test connection fails if the only this port is configured
+        restPort = REST_PORT + 1;
+
+        startGrids(gridCount());
+
+        GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() {
+                @Override public Object call() throws Exception {
+                    checkJobSubmit(configSingleAddress());
+                    return null;
+                }
+            },
+            GridServerUnreachableException.class, "Failed to connect to any of the servers
in list");
     }
 
     /**
@@ -193,28 +189,21 @@ public class HadoopClientProtocolMultipleServersSelfTest extends HadoopAbstractS
      */
     @SuppressWarnings("ConstantConditions")
     public void testMixedAddrs() throws Exception {
-        try {
-            restPort = REST_PORT;
+        restPort = REST_PORT;
 
-            startGrids(gridCount());
+        startGrids(gridCount());
 
-            beforeJob();
+        beforeJob();
 
-            stopGrid(1);
+        stopGrid(1);
 
-            U.sleep(5000);
+        U.sleep(5000);
 
-            checkJobSubmit(configMixed());
+        checkJobSubmit(configMixed());
 
-            startGrid(1);
+        startGrid(1);
 
-            awaitPartitionMapExchange();
-        }
-        finally {
-            FileSystem fs = FileSystem.get(configMixed());
-
-            fs.close();
-        }
+        awaitPartitionMapExchange();
     }
 
     /**
@@ -234,19 +223,19 @@ public class HadoopClientProtocolMultipleServersSelfTest extends HadoopAbstractS
     }
 
     /**
-     * @param serversCnt Count ov servers.
+     * @param srvsCnt Count ov servers.
      * @return Configuration.
      */
-    private Configuration configMultipleAddrs(int serversCnt) {
+    private Configuration configMultipleAddrs(int srvsCnt) {
         Configuration conf = HadoopUtils.safeCreateConfiguration();
 
         setupFileSystems(conf);
 
         conf.set(MRConfig.FRAMEWORK_NAME, IgniteHadoopClientProtocolProvider.FRAMEWORK_NAME);
 
-        Collection<String> addrs = new ArrayList<>(serversCnt);
+        Collection<String> addrs = new ArrayList<>(srvsCnt);
 
-        for (int i = 0; i < serversCnt; ++i)
+        for (int i = 0; i < srvsCnt; ++i)
             addrs.add("127.0.0.1:" + Integer.toString(REST_PORT + i));
 
         conf.set(MRConfig.MASTER_ADDRESS, F.concat(addrs, ","));
@@ -305,18 +294,18 @@ public class HadoopClientProtocolMultipleServersSelfTest extends HadoopAbstractS
      */
     public static class OutFormat extends OutputFormat {
         /** {@inheritDoc} */
-        @Override public RecordWriter getRecordWriter(TaskAttemptContext context) throws
IOException,
+        @Override public RecordWriter getRecordWriter(TaskAttemptContext ctx) throws IOException,
             InterruptedException {
             return null;
         }
 
         /** {@inheritDoc} */
-        @Override public void checkOutputSpecs(JobContext context) throws IOException, InterruptedException
{
+        @Override public void checkOutputSpecs(JobContext ctx) throws IOException, InterruptedException
{
             // No-op.
         }
 
         /** {@inheritDoc} */
-        @Override public OutputCommitter getOutputCommitter(TaskAttemptContext context) throws
IOException,
+        @Override public OutputCommitter getOutputCommitter(TaskAttemptContext ctx) throws
IOException,
             InterruptedException {
             return null;
         }


Mime
View raw message