From 6fb3e61a98a694d3d3a2d5cba4c746c1eb524ab6 Mon Sep 17 00:00:00 2001 From: Hagen Rother Date: Thu, 27 Mar 2014 19:38:53 +0100 Subject: [PATCH 1/2] add url logging to DirectDruidClient for debugging purposes --- .../java/io/druid/client/DirectDruidClient.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/io/druid/client/DirectDruidClient.java b/server/src/main/java/io/druid/client/DirectDruidClient.java index 6c376ed479e..a5247f5cb53 100644 --- a/server/src/main/java/io/druid/client/DirectDruidClient.java +++ b/server/src/main/java/io/druid/client/DirectDruidClient.java @@ -34,6 +34,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.metamx.common.IAE; import com.metamx.common.Pair; +import com.metamx.common.RE; import com.metamx.common.guava.BaseSequence; import com.metamx.common.guava.Sequence; import com.metamx.common.guava.Sequences; @@ -203,7 +204,7 @@ public class DirectDruidClient implements QueryRunner @Override public JsonParserIterator make() { - return new JsonParserIterator(typeRef, future); + return new JsonParserIterator(typeRef, future, url); } @Override @@ -239,11 +240,13 @@ public class DirectDruidClient implements QueryRunner private ObjectCodec objectCodec; private final JavaType typeRef; private final Future future; + private final String url; - public JsonParserIterator(JavaType typeRef, Future future) + public JsonParserIterator(JavaType typeRef, Future future, String url) { this.typeRef = typeRef; this.future = future; + this.url = url; jp = null; } @@ -289,20 +292,20 @@ public class DirectDruidClient implements QueryRunner try { jp = objectMapper.getFactory().createParser(future.get()); if (jp.nextToken() != JsonToken.START_ARRAY) { - throw new IAE("Next token wasn't a START_ARRAY, was[%s]", jp.getCurrentToken()); + throw new IAE("Next token wasn't a START_ARRAY, was[%s] in url [%s]", jp.getCurrentToken(), url); } else { jp.nextToken(); objectCodec = jp.getCodec(); } } catch (IOException e) { - throw Throwables.propagate(e); + throw Throwables.propagate(new RE(e, "Failure getting results from[%s]", url)); } catch (InterruptedException e) { - throw Throwables.propagate(e); + throw Throwables.propagate(new RE(e, "Failure getting results from[%s]", url)); } catch (ExecutionException e) { - throw Throwables.propagate(e); + throw Throwables.propagate(new RE(e, "Failure getting results from[%s]", url)); } } } From d6f4cf37332e07cd2fff0d4819699920fcffb88a Mon Sep 17 00:00:00 2001 From: Hagen Rother Date: Thu, 27 Mar 2014 19:46:53 +0100 Subject: [PATCH 2/2] add changes as suggested by cheddar --- .../src/main/java/io/druid/client/DirectDruidClient.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/io/druid/client/DirectDruidClient.java b/server/src/main/java/io/druid/client/DirectDruidClient.java index a5247f5cb53..fa95ba97f11 100644 --- a/server/src/main/java/io/druid/client/DirectDruidClient.java +++ b/server/src/main/java/io/druid/client/DirectDruidClient.java @@ -292,20 +292,20 @@ public class DirectDruidClient implements QueryRunner try { jp = objectMapper.getFactory().createParser(future.get()); if (jp.nextToken() != JsonToken.START_ARRAY) { - throw new IAE("Next token wasn't a START_ARRAY, was[%s] in url [%s]", jp.getCurrentToken(), url); + throw new IAE("Next token wasn't a START_ARRAY, was[%s] from url [%s]", jp.getCurrentToken(), url); } else { jp.nextToken(); objectCodec = jp.getCodec(); } } catch (IOException e) { - throw Throwables.propagate(new RE(e, "Failure getting results from[%s]", url)); + throw new RE(e, "Failure getting results from[%s]", url); } catch (InterruptedException e) { - throw Throwables.propagate(new RE(e, "Failure getting results from[%s]", url)); + throw new RE(e, "Failure getting results from[%s]", url); } catch (ExecutionException e) { - throw Throwables.propagate(new RE(e, "Failure getting results from[%s]", url)); + throw new RE(e, "Failure getting results from[%s]", url); } } }