ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [11/27] ignite git commit: IGNITE-3184: Review.
Date Fri, 01 Jul 2016 12:10:54 GMT
IGNITE-3184: Review.


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

Branch: refs/heads/ignite-3185
Commit: 61b12c6048ff3566c76f4330c66ddb8c297ed820
Parents: 7bbaafc
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Thu Jun 23 14:56:30 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Thu Jun 23 14:56:30 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/IgniteUtils.java       |  2 +-
 .../processors/hadoop/HadoopClassLoader.java    |  2 +-
 .../processors/hadoop/HadoopClasspathMain.java  | 30 +++++++---
 .../processors/hadoop/HadoopClasspathUtils.java | 59 +++++++++++++-------
 4 files changed, 63 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/61b12c60/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 8431645..fa18923 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -4049,7 +4049,7 @@ public abstract class IgniteUtils {
     public static void quietAndWarn(IgniteLogger log, Object msg, Object shortMsg) {
         warn(log, msg);
 
-        if (log != null && log.isQuiet())
+        if (log.isQuiet())
             quiet(false, shortMsg);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/61b12c60/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
index e614586..c0251eb 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
@@ -501,7 +501,7 @@ public class HadoopClassLoader extends URLClassLoader implements ClassCache
{
                 hadoopUrls = HadoopClasspathUtils.getAsUrlList();
             }
             catch (IOException e) {
-                throw new IgniteCheckedException(e);
+                throw new IgniteCheckedException("Failed to resolve Hadoop JAR locations.",
e);
             }
 
             hadoopJars = hadoopUrls;

http://git-wip-us.apache.org/repos/asf/ignite/blob/61b12c60/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClasspathMain.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClasspathMain.java
b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClasspathMain.java
index 0a0b422..fb0de7c 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClasspathMain.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClasspathMain.java
@@ -1,10 +1,24 @@
+/*
+ * 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 java.util.List;
 
-import static java.lang.System.out;
-import static java.lang.System.err;
-
 /**
  * Main class to compose Hadoop classpath depending on the environment.
  * This class is designed to be independent on any Ignite classes as possible.
@@ -18,7 +32,8 @@ public class HadoopClasspathMain {
      */
     public static void main(String[] args) throws Exception {
         if (args.length < 1) {
-            err.println("Path separator must be passed as the 1st argument.");
+            // TODO: TO exception.
+            System.err.println("Path separator must be passed as the 1st argument.");
 
             System.exit(1);
         }
@@ -28,12 +43,13 @@ public class HadoopClasspathMain {
         List<String> cp = HadoopClasspathUtils.getAsProcessClasspath();
 
         for (String s: cp) {
+            // TODO: Move null-checks to getAsProcessClasspath().
             if (s != null && s.length() > 0) {
-                out.print(s);
-                out.print(sep);
+                System.out.print(s);
+                System.out.print(sep);
             }
         }
 
-        out.println();
+        System.out.println();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/61b12c60/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClasspathUtils.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClasspathUtils.java
b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClasspathUtils.java
index e122913..7ef2f60 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClasspathUtils.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClasspathUtils.java
@@ -1,7 +1,23 @@
+/*
+ * 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 java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -13,8 +29,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import static java.lang.System.err;
-
 /**
  * Hadoop classpath utilities.
  */
@@ -23,7 +37,7 @@ public class HadoopClasspathUtils {
      * Gets Hadoop class path as list of classpath elements for process.
      *
      * @return List of the class path elements.
-     * @throws IOException On error.
+     * @throws IOException If failed.
      */
     static List<String> getAsProcessClasspath() throws IOException {
         Collection<DirAndMask> dams = getClasspathBaseDirectories();
@@ -40,7 +54,7 @@ public class HadoopClasspathUtils {
      * Gets Hadoop class path as a list of URLs (for in-process class loader usage).
      *
      * @return List of class path URLs.
-     * @throws IOException On error.
+     * @throws IOException If failed.
      */
     public static List<URL> getAsUrlList() throws IOException {
         Collection<DirAndMask> dams = getClasspathBaseDirectories();
@@ -61,7 +75,7 @@ public class HadoopClasspathUtils {
      * @param res Result.
      * @param dir Directory.
      * @param startsWith Starts with prefix.
-     * @throws MalformedURLException If failed.
+     * @throws IOException If failed.
      */
     private static void addUrls(Collection<URL> res, File dir, final String startsWith)
throws IOException {
         File[] files = dir.listFiles(new FilenameFilter() {
@@ -73,20 +87,26 @@ public class HadoopClasspathUtils {
         if (files == null)
             throw new IOException("Path is not a directory. [dir=" + dir + ']');
 
-        for (File file : files)
-            res.add(file.toURI().toURL());
+        for (File file : files) {
+            try {
+                res.add(file.toURI().toURL());
+            }
+            catch (MalformedURLException e) {
+                throw new IOException("Failed to convert file path to URL: " + file.getPath());
+            }
+        }
     }
 
-
     /**
      * Discovers classpath entries in specified directory and adds them as URLs to the given
{@code res} collection.
      *
      * @param res Result.
      * @param dir Directory.
      * @param startsWith Starts with prefix.
-     * @throws MalformedURLException If failed.
+     * @throws IOException If failed.
      */
-    private static void addAsJavaProcessClasspathElement(Collection<String> res, File
dir, final String startsWith) throws IOException {
+    private static void addAsJavaProcessClasspathElement(Collection<String> res, File
dir, final String startsWith)
+        throws IOException {
         if (!dir.exists() || !dir.isDirectory() || !dir.canRead())
             throw new IOException("Path is not an existing readable directory. [dir=" + dir
+ ']');
 
@@ -120,9 +140,9 @@ public class HadoopClasspathUtils {
      * Gets base directories to discover classpath elements in.
      *
      * @return Collection of directory and mask pairs.
-     * @throws FileNotFoundException if a mandatory classpath location is not found.
+     * @throws IOException if a mandatory classpath location is not found.
      */
-    private static Collection<DirAndMask> getClasspathBaseDirectories() throws FileNotFoundException
{
+    private static Collection<DirAndMask> getClasspathBaseDirectories() throws IOException
{
         final String hadoopHome = hadoopHome();
 
         String commonHome = resolveLocation("HADOOP_COMMON_HOME", hadoopHome, "/share/hadoop/common");
@@ -174,26 +194,23 @@ public class HadoopClasspathUtils {
      * @param envVarName Environment variable name. The value denotes the location path.
      * @param hadoopHome Hadoop home location, may be null.
      * @param expHadoopHomeRelativePath The path relative to Hadoop home, expected to start
with path separator.
-     * @throws FileNotFoundException If the value cannot be resolved to an existing directory.
+     * @throws IOException If the value cannot be resolved to an existing directory.
      */
-    private static String resolveLocation(String envVarName, String hadoopHome,
-                                          String expHadoopHomeRelativePath) throws FileNotFoundException
{
+    private static String resolveLocation(String envVarName, String hadoopHome, String expHadoopHomeRelativePath)
+        throws IOException {
         String val = getEnv(envVarName, null);
 
         if (val == null) {
             // The env. variable is not set. Try to resolve the location relative HADOOP_HOME:
             if (!isExistingDirectory(hadoopHome))
-                throw new FileNotFoundException("Failed to resolve Hadoop installation location.
" +
+                throw new IOException("Failed to resolve Hadoop installation location. "
+
                         envVarName + " or HADOOP_HOME environment variable should be set.");
 
             val = hadoopHome + expHadoopHomeRelativePath;
         }
 
         if (!isExistingDirectory(val))
-            throw new FileNotFoundException("Failed to resolve Hadoop location. [path=" +
val + ']');
-
-        // Print diagnostic output:
-        err.println(envVarName + " resolved to " + val);
+            throw new IOException("Failed to resolve Hadoop location [path=" + val + ']');
 
         return val;
     }


Mime
View raw message