ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntikho...@apache.org
Subject [05/13] ignite git commit: IGNITE-2101: Hadoop: Improved error messages when Hadoop module is not loaded. This closes #609.
Date Wed, 13 Apr 2016 12:24:20 GMT
IGNITE-2101: Hadoop: Improved error messages when Hadoop module is not loaded. This closes
#609.


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

Branch: refs/heads/ignite-2004
Commit: cc0dbd1617c905fc96058bdf43b90f52b04d5b0b
Parents: 8eed48b
Author: iveselovskiy <iveselovskiy@gridgain.com>
Authored: Tue Apr 12 15:39:00 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Apr 12 15:39:00 2016 +0300

----------------------------------------------------------------------
 .../processors/hadoop/HadoopNoopProcessor.java  | 24 ++++++----
 .../hadoop/HadoopNoHadoopMapReduceTest.java     | 47 ++++++++++++++++++++
 .../testsuites/IgniteHadoopTestSuite.java       |  2 +
 3 files changed, 65 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cc0dbd16/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopProcessor.java
index 72b5050..e772787 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopProcessor.java
@@ -37,41 +37,49 @@ public class HadoopNoopProcessor extends HadoopProcessorAdapter {
 
     /** {@inheritDoc} */
     @Override public Hadoop hadoop() {
-        throw new IllegalStateException("Hadoop module is not found in class path.");
+        throw createException();
     }
 
     /** {@inheritDoc} */
     @Override public HadoopConfiguration config() {
-        return null;
+        throw createException();
     }
 
     /** {@inheritDoc} */
     @Override public HadoopJobId nextJobId() {
-        return null;
+        throw createException();
     }
 
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<?> submit(HadoopJobId jobId, HadoopJobInfo
jobInfo) {
-        return new GridFinishedFuture<>(new IgniteCheckedException("Hadoop is not available."));
+        return new GridFinishedFuture<>(createException());
     }
 
     /** {@inheritDoc} */
     @Override public HadoopJobStatus status(HadoopJobId jobId) throws IgniteCheckedException
{
-        return null;
+        throw createException();
     }
 
     /** {@inheritDoc} */
     @Override public HadoopCounters counters(HadoopJobId jobId) {
-        return null;
+        throw createException();
     }
 
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<?> finishFuture(HadoopJobId jobId) throws
IgniteCheckedException {
-        return null;
+        throw createException();
     }
 
     /** {@inheritDoc} */
     @Override public boolean kill(HadoopJobId jobId) throws IgniteCheckedException {
-        return false;
+        throw createException();
+    }
+
+    /**
+     * Creates an exception to be uniformly thrown from all the methods.
+     */
+    private IllegalStateException createException() {
+        return new IllegalStateException("Hadoop module is not loaded (please ensure that
ignite-hadoop.jar is in " +
+            "classpath and IgniteConfiguration.peerClassLoadingEnabled is set to false).");
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/cc0dbd16/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopNoHadoopMapReduceTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopNoHadoopMapReduceTest.java
b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopNoHadoopMapReduceTest.java
new file mode 100644
index 0000000..0c172c3
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopNoHadoopMapReduceTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.internal.processors.hadoop;
+
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+/**
+ * Test attempt to execute a map-reduce task while no Hadoop processor available.
+ */
+public class HadoopNoHadoopMapReduceTest extends HadoopMapReduceTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration c = super.getConfiguration(gridName);
+
+        c.setHadoopConfiguration(null);
+        c.setPeerClassLoadingEnabled(true);
+
+        return c;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void testWholeMapReduceExecution() throws Exception {
+        try {
+            super.testWholeMapReduceExecution();
+
+            fail("IllegalStateException expected.");
+        }
+        catch (IllegalStateException ignore) {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cc0dbd16/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
index 9b1d7a2..3358e18 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
@@ -56,6 +56,7 @@ import org.apache.ignite.internal.processors.hadoop.HadoopGroupingTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopJobTrackerSelfTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopMapReduceEmbeddedSelfTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopMapReduceTest;
+import org.apache.ignite.internal.processors.hadoop.HadoopNoHadoopMapReduceTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopSerializationWrapperSelfTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopSnappyFullMapReduceTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopSnappyTest;
@@ -166,6 +167,7 @@ public class IgniteHadoopTestSuite extends TestSuite {
         suite.addTest(new TestSuite(ldr.loadClass(HadoopTasksV2Test.class.getName())));
 
         suite.addTest(new TestSuite(ldr.loadClass(HadoopMapReduceTest.class.getName())));
+        suite.addTest(new TestSuite(ldr.loadClass(HadoopNoHadoopMapReduceTest.class.getName())));
 
         suite.addTest(new TestSuite(ldr.loadClass(HadoopMapReduceEmbeddedSelfTest.class.getName())));
 


Mime
View raw message