Permalink
Browse files

Timeout on Avro file decodes because some people have ridiculously lo…

…ng messages.
  • Loading branch information...
1 parent 465524d commit 2f9c838099f3050d35a92bc07f0499bd86289a2c @rbpark committed Mar 20, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 azkaban-common/src/java/azkaban/common/web/HdfsAvroFileViewer.java
@@ -27,7 +27,9 @@
public class HdfsAvroFileViewer implements HdfsFileViewer {
private static Logger logger = Logger.getLogger(HdfsAvroFileViewer.class);
-
+ // Will spend 5 seconds trying to pull data and then stop.
+ private static long STOP_TIME = 5000l;
+
@Override
public boolean canReadFile(FileSystem fs, Path path) {
@@ -79,8 +81,9 @@ public void displayFile(FileSystem fs,
g.useDefaultPrettyPrinter();
Encoder encoder = new JsonEncoder(schema, g);
+ long endTime = System.currentTimeMillis() + STOP_TIME;
int lineno = 1; // line number starts from 1
- while(avroDatastream.hasNext() && lineno <= endLine) {
+ while(avroDatastream.hasNext() && lineno <= endLine && System.currentTimeMillis() <= endTime) {
Object datum = avroDatastream.next();
if(lineno >= startLine) {
String record = "\n\n Record " + lineno + ":\n";

0 comments on commit 2f9c838

Please sign in to comment.