Skip to content

Commit

Permalink
Improve some log (apache#2807)
Browse files Browse the repository at this point in the history
  • Loading branch information
binlijin authored and fjy committed Apr 15, 2016
1 parent 632b214 commit c1e6902
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 4 additions & 3 deletions server/src/main/java/io/druid/client/DirectDruidClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public Sequence<T> run(final Query<T> query, final Map<String, Object> context)
final String cancelUrl = String.format("http://%s/druid/v2/%s", host, query.getId());

try {
log.debug("Querying url[%s]", url);
log.debug("Querying queryId[%s] url[%s]", query.getId(), url);

final long requestStartTime = System.currentTimeMillis();

Expand All @@ -179,7 +179,7 @@ public Sequence<T> run(final Query<T> query, final Map<String, Object> context)
@Override
public ClientResponse<InputStream> handleResponse(HttpResponse response)
{
log.debug("Initial response from url[%s]", url);
log.debug("Initial response from url[%s] for queryId[%s]", url, query.getId());
responseStartTime = System.currentTimeMillis();
emitter.emit(builder.build("query/node/ttfb", responseStartTime - requestStartTime));

Expand Down Expand Up @@ -272,7 +272,8 @@ public ClientResponse<InputStream> done(ClientResponse<InputStream> clientRespon
{
long stopTime = System.currentTimeMillis();
log.debug(
"Completed request to url[%s] with %,d bytes returned in %,d millis [%,f b/s].",
"Completed queryId[%s] request to url[%s] with %,d bytes returned in %,d millis [%,f b/s].",
query.getId(),
url,
byteCount.get(),
stopTime - responseStartTime,
Expand Down
10 changes: 9 additions & 1 deletion server/src/main/java/io/druid/server/QueryResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ public QueryResource(
@Produces(MediaType.APPLICATION_JSON)
public Response getServer(@PathParam("id") String queryId)
{
if (log.isDebugEnabled()) {
log.debug("Received cancel request for query [%s]", queryId);
}
queryManager.cancelQuery(queryId);
return Response.status(Response.Status.ACCEPTED).build();

}

@POST
Expand All @@ -135,6 +137,7 @@ public Response doPost(
? objectMapper.writerWithDefaultPrettyPrinter()
: objectMapper.writer();

final String currThreadName = Thread.currentThread().getName();
try {
query = objectMapper.readValue(in, Query.class);
queryId = query.getId();
Expand All @@ -151,6 +154,8 @@ public Response doPost(
);
}

Thread.currentThread()
.setName(String.format("%s[%s_%s_%s]", currThreadName, query.getType(), query.getDataSource(), queryId));
if (log.isDebugEnabled()) {
log.debug("Got query [%s]", query);
}
Expand Down Expand Up @@ -337,5 +342,8 @@ public void write(OutputStream outputStream) throws IOException, WebApplicationE
)
).build();
}
finally {
Thread.currentThread().setName(currThreadName);
}
}
}

0 comments on commit c1e6902

Please sign in to comment.