fluo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] kamaci closed pull request #996: Loggers are used instead to printing Throwable.
Date Thu, 01 Jan 1970 00:00:00 GMT
kamaci closed pull request #996: Loggers are used instead to printing Throwable.
URL: https://github.com/apache/fluo/pull/996
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/modules/cluster/src/main/java/org/apache/fluo/cluster/runnable/OracleRunnable.java
b/modules/cluster/src/main/java/org/apache/fluo/cluster/runnable/OracleRunnable.java
index 99d09a0e..2e15211e 100644
--- a/modules/cluster/src/main/java/org/apache/fluo/cluster/runnable/OracleRunnable.java
+++ b/modules/cluster/src/main/java/org/apache/fluo/cluster/runnable/OracleRunnable.java
@@ -64,7 +64,7 @@ public void run() {
       }
     } catch (Exception e) {
       System.err.println("Exception while starting FluoOracle: " + e.getMessage());
-      e.printStackTrace();
+      log.error("Exception while starting FluoOracle: {}", e.getMessage(), e);
       System.exit(-1);
     }
 
diff --git a/modules/cluster/src/main/java/org/apache/fluo/cluster/runnable/WorkerRunnable.java
b/modules/cluster/src/main/java/org/apache/fluo/cluster/runnable/WorkerRunnable.java
index dbfd191b..1c0b7ee2 100644
--- a/modules/cluster/src/main/java/org/apache/fluo/cluster/runnable/WorkerRunnable.java
+++ b/modules/cluster/src/main/java/org/apache/fluo/cluster/runnable/WorkerRunnable.java
@@ -64,7 +64,7 @@ public void run() {
       }
     } catch (Exception e) {
       System.err.println("Exception while starting FluoWorker: " + e.getMessage());
-      e.printStackTrace();
+      log.error("Exception while starting FluoWorker: {}", e.getMessage(), e);
       System.exit(-1);
     }
 
@@ -81,7 +81,7 @@ public void run() {
         config.validate();
       } catch (Exception e) {
         System.err.println("Error - Invalid fluo.properties due to " + e.getMessage());
-        e.printStackTrace();
+        log.error("Error - Invalid fluo.properties due to {}", e.getMessage(), e);
         System.exit(-1);
       }
 
diff --git a/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java b/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
index e7117057..8d717f32 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
@@ -324,9 +324,7 @@ public static String copyDirToDfs(String dfsRoot, String appName, String
srcDir,
     String dfsAppRoot = dfsRoot + "/" + appName;
     String dfsDestDir = dfsAppRoot + "/" + destDir;
 
-    FileSystem fs;
-    try {
-      fs = FileSystem.get(new URI(dfsRoot), new Configuration());
+    try (FileSystem fs = FileSystem.get(new URI(dfsRoot), new Configuration())) {
       fs.delete(new Path(dfsDestDir), true);
       fs.mkdirs(new Path(dfsAppRoot));
       fs.copyFromLocalFile(new Path(srcDir), new Path(dfsDestDir));
@@ -340,11 +338,19 @@ private String copyJarsToDfs(String jars, String destDir) {
     String dfsAppRoot = config.getDfsRoot() + "/" + config.getApplicationName();
     String dfsDestDir = dfsAppRoot + "/" + destDir;
 
-    FileSystem fs;
+    FileSystem fs = null;
     try {
       fs = FileSystem.get(new URI(config.getDfsRoot()), new Configuration());
       fs.mkdirs(new Path(dfsDestDir));
     } catch (Exception e) {
+      logger.error("Failed to create DFS directory {}", dfsDestDir);
+      if (fs != null) {
+        try {
+          fs.close();
+        } catch (IOException ioe) {
+          throw new IllegalStateException(ioe);
+        }
+      }
       throw new IllegalStateException(e);
     }
 
@@ -356,12 +362,23 @@ private String copyJarsToDfs(String jars, String destDir) {
         fs.copyFromLocalFile(new Path(jarPath), new Path(dfsDestDir));
       } catch (IOException e) {
         logger.error("Failed to copy file {} to DFS directory {}", jarPath, dfsDestDir);
+        try {
+          fs.close();
+        } catch (IOException ioe) {
+          throw new IllegalStateException(ioe);
+        }
         throw new IllegalStateException(e);
       }
       if (classpath.length() != 0) {
         classpath.append(",");
       }
-      classpath.append(dfsDestDir + "/" + jarName);
+      classpath.append(dfsDestDir).append("/").append(jarName);
+    }
+
+    try {
+      fs.close();
+    } catch (IOException e) {
+      throw new IllegalStateException(e);
     }
     return classpath.toString();
   }
diff --git a/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleClient.java b/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleClient.java
index 9c112397..150a055b 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleClient.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleClient.java
@@ -368,7 +368,8 @@ public Stamp getStamp() {
           if (waitPeriod < MAX_ORACLE_WAIT_PERIOD) {
             waitPeriod *= 2;
           }
-          log.warn("Waiting for timestamp from Oracle. Is it running? waitTotal={}s waitPeriod={}s",
+          log.warn(
+              "Waiting for timestamp from Oracle. Is it running? Client has waited a total
of {}s and will retry in {}s",
               waitTotal, waitPeriod);
         }
       } else if (!tr.cdl.await(timeout, TimeUnit.MILLISECONDS)) {
diff --git a/modules/core/src/main/java/org/apache/fluo/core/util/ScanUtil.java b/modules/core/src/main/java/org/apache/fluo/core/util/ScanUtil.java
index d5451956..46aacca8 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/util/ScanUtil.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/util/ScanUtil.java
@@ -4,9 +4,9 @@
  * 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
@@ -90,10 +90,7 @@ public static Span getSpan(ScanOpts options) {
   }
 
   public static void scanFluo(ScanOpts options, FluoConfiguration sConfig) {
-    System.out.println(
-        "Scanning snapshot of data in Fluo '" + sConfig.getApplicationName() + "' application.");
 
-    long entriesFound = 0;
     try (FluoClient client = FluoFactory.newClient(sConfig)) {
       try (Snapshot s = client.newSnapshot()) {
 
@@ -128,24 +125,20 @@ public static void scanFluo(ScanOpts options, FluoConfiguration sConfig)
{
             sb.append(rcv.getsValue());
             System.out.println(sb.toString());
           }
-          entriesFound++;
+
           if (System.out.checkError()) {
             break;
           }
         }
 
-        if (entriesFound == 0) {
-          System.out.println("\nNo data found\n");
-        }
       } catch (FluoException e) {
-        System.out.println("Scan failed - " + e.getMessage());
+        System.err.println("Scan failed - " + e.getMessage());
+        System.exit(-1);
       }
     }
   }
 
   public static void scanAccumulo(ScanOpts options, FluoConfiguration sConfig) {
-    System.out.println("Scanning data in Accumulo directly for '" + sConfig.getApplicationName()
-        + "' application.");
 
     Connector conn = AccumuloUtil.getConnector(sConfig);
 
@@ -175,7 +168,8 @@ public static void scanAccumulo(ScanOpts options, FluoConfiguration sConfig)
{
         System.out.println(entry);
       }
     } catch (Exception e) {
-      System.out.println("Scan failed - " + e.getMessage());
+      System.err.println("Scan failed - " + e.getMessage());
+      System.exit(-1);
     }
   }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message