You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streams.apache.org by mf...@apache.org on 2014/05/30 05:05:25 UTC
[2/4] git commit: Replaced e.printStackTrace() with log statements
Replaced e.printStackTrace() with log statements
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/cb0c8797
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/cb0c8797
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/cb0c8797
Branch: refs/heads/STREAMS-104
Commit: cb0c879779ebf6140b81780ca9ef298298e9144e
Parents: e67d9ad
Author: mfranklin <mf...@apache.org>
Authored: Thu May 29 21:09:04 2014 -0400
Committer: mfranklin <mf...@apache.org>
Committed: Thu May 29 21:09:04 2014 -0400
----------------------------------------------------------------------
.../streams/hdfs/WebHdfsPersistWriter.java | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/cb0c8797/streams-contrib/streams-persist-hdfs/src/main/java/org/apache/streams/hdfs/WebHdfsPersistWriter.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-hdfs/src/main/java/org/apache/streams/hdfs/WebHdfsPersistWriter.java b/streams-contrib/streams-persist-hdfs/src/main/java/org/apache/streams/hdfs/WebHdfsPersistWriter.java
index 4c083fc..8fae4a6 100644
--- a/streams-contrib/streams-persist-hdfs/src/main/java/org/apache/streams/hdfs/WebHdfsPersistWriter.java
+++ b/streams-contrib/streams-persist-hdfs/src/main/java/org/apache/streams/hdfs/WebHdfsPersistWriter.java
@@ -110,8 +110,7 @@ public class WebHdfsPersistWriter implements StreamsPersistWriter, Flushable, Cl
}
});
} catch (Exception e) {
- LOGGER.error("There was an error connecting to WebHDFS, please check your settings and try again");
- e.printStackTrace();
+ LOGGER.error("There was an error connecting to WebHDFS, please check your settings and try again",e);
}
}
@@ -124,14 +123,16 @@ public class WebHdfsPersistWriter implements StreamsPersistWriter, Flushable, Cl
try {
resetFile();
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Unable to reset file. Shutting down and propagating error", e);
+ this.cleanUp();
+ throw new RuntimeException(e);
}
String line = convertResultToString(streamsDatum);
try {
this.currentWriter.write(line);
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.warn("Error writing to HDFS. Attempting to try a new file", e);
}
int bytesInLine = line.getBytes().length;
@@ -143,7 +144,7 @@ public class WebHdfsPersistWriter implements StreamsPersistWriter, Flushable, Cl
try {
flush();
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Error flushing to HDFS", e);
}
this.fileLineCounter++;
@@ -205,14 +206,14 @@ public class WebHdfsPersistWriter implements StreamsPersistWriter, Flushable, Cl
try {
metadata = mapper.writeValueAsString(entry.getMetadata());
} catch (JsonProcessingException e) {
- e.printStackTrace();
+ LOGGER.warn("Error converting metadata to a string", e);
}
String documentJson = null;
try {
documentJson = mapper.writeValueAsString(entry.getDocument());
} catch (JsonProcessingException e) {
- e.printStackTrace();
+ LOGGER.warn("Error converting document to string", e);
}
if (Strings.isNullOrEmpty(documentJson))
@@ -241,12 +242,12 @@ public class WebHdfsPersistWriter implements StreamsPersistWriter, Flushable, Cl
try {
flush();
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Error flushing on cleanup", e);
}
try {
close();
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Error closing on cleanup", e);
}
}