kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 4625fd285b2c72e237513776f6f1251a0c04a1a02a8d01f86831419de2274341 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-09-01 18:41 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-09-01 18:43 +02:00 |
| Parents | 26add0c6583f |
2 files changed
modified driver-core/CHANGELOG.rst +1 −0
| @@ -11,6 +11,7 @@ | ||
| 11 | 11 | - [bug] Do not use a host when no rpc_address found for it (JAVA-428) |
| 12 | 12 | - [improvement] Add ResultSet.wasApplied() for conditional queries (JAVA-358) |
| 13 | 13 | - [bug] Fix negative HostConnectionPool open count (JAVA-349) |
| 14 | +- [improvement] Log more connection details at trace and debug levels (JAVA-436) | |
| 14 | 15 | |
| 15 | 16 | 2.0.5: |
| 16 | 17 | ------ |
modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +16 −16
| @@ -102,16 +102,16 @@ | ||
| 102 | 102 | if (!future.isSuccess()) |
| 103 | 103 | { |
| 104 | 104 | if (logger.isDebugEnabled()) |
| 105 | - logger.debug(String.format("[%s] Error connecting to %s%s", name, address, extractMessage(future.getCause()))); | |
| 105 | + logger.debug(String.format("%s Error connecting to %s%s", this, address, extractMessage(future.getCause()))); | |
| 106 | 106 | throw defunct(new TransportException(address, "Cannot connect", future.getCause())); |
| 107 | 107 | } |
| 108 | 108 | } finally { |
| 109 | 109 | writer.decrementAndGet(); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - logger.trace("[{}] Connection opened successfully", name); | |
| 112 | + logger.trace("{} Connection opened successfully", this); | |
| 113 | 113 | initializeTransport(protocolVersion, factory.manager.metadata.clusterName); |
| 114 | - logger.debug("[{}] Transport initialized and ready", name); | |
| 114 | + logger.debug("{} Transport initialized and ready", this); | |
| 115 | 115 | isInitialized = true; |
| 116 | 116 | } |
| 117 | 117 | |
| @@ -194,7 +194,7 @@ | ||
| 194 | 194 | private void waitForAuthCompletion(Message.Response authResponse, Authenticator authenticator) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException { |
| 195 | 195 | switch (authResponse.type) { |
| 196 | 196 | case AUTH_SUCCESS: |
| 197 | - logger.trace("Authentication complete"); | |
| 197 | + logger.trace("{} Authentication complete", this); | |
| 198 | 198 | authenticator.onAuthenticationSuccess(((Responses.AuthSuccess)authResponse).token); |
| 199 | 199 | break; |
| 200 | 200 | case AUTH_CHALLENGE: |
| @@ -202,11 +202,11 @@ | ||
| 202 | 202 | if (responseToServer == null) { |
| 203 | 203 | // If we generate a null response, then authentication has completed, return without |
| 204 | 204 | // sending a further response back to the server. |
| 205 | - logger.trace("Authentication complete (No response to server)"); | |
| 205 | + logger.trace("{} Authentication complete (No response to server)", this); | |
| 206 | 206 | return; |
| 207 | 207 | } else { |
| 208 | 208 | // Otherwise, send the challenge response back to the server |
| 209 | - logger.trace("Sending Auth response to challenge"); | |
| 209 | + logger.trace("{} Sending Auth response to challenge", this); | |
| 210 | 210 | waitForAuthCompletion(write(new Requests.AuthResponse(responseToServer)).get(), authenticator); |
| 211 | 211 | } |
| 212 | 212 | break; |
| @@ -289,7 +289,7 @@ | ||
| 289 | 289 | return; |
| 290 | 290 | |
| 291 | 291 | try { |
| 292 | - logger.trace("[{}] Setting keyspace {}", name, keyspace); | |
| 292 | + logger.trace("{} Setting keyspace {}", this, keyspace); | |
| 293 | 293 | long timeout = factory.getConnectTimeoutMillis(); |
| 294 | 294 | // Note: we quote the keyspace below, because the name is the one coming from Cassandra, so it's in the right case already |
| 295 | 295 | Future future = write(new Requests.Query("USE \"" + keyspace + '"')); |
| @@ -357,7 +357,7 @@ | ||
| 357 | 357 | throw new ConnectionException(address, "Connection has been closed"); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - logger.trace("[{}] writing request {}", name, request); | |
| 360 | + logger.trace("{} writing request {}", this, request); | |
| 361 | 361 | writer.incrementAndGet(); |
| 362 | 362 | channel.write(request).addListener(writeHandler(request, handler)); |
| 363 | 363 | return handler; |
| @@ -371,7 +371,7 @@ | ||
| 371 | 371 | writer.decrementAndGet(); |
| 372 | 372 | |
| 373 | 373 | if (!writeFuture.isSuccess()) { |
| 374 | - logger.debug("[{}] Error writing request {}", name, request); | |
| 374 | + logger.debug("{} Error writing request {}", Connection.this, request); | |
| 375 | 375 | // Remove this handler from the dispatcher so it don't get notified of the error |
| 376 | 376 | // twice (we will fail that method already) |
| 377 | 377 | dispatcher.removeHandler(handler.streamId, true); |
| @@ -384,7 +384,7 @@ | ||
| 384 | 384 | } |
| 385 | 385 | handler.callback.onException(Connection.this, defunct(ce), System.nanoTime() - handler.startTime); |
| 386 | 386 | } else { |
| 387 | - logger.trace("[{}] request sent successfully", name); | |
| 387 | + logger.trace("{} request sent successfully", Connection.this); | |
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | }; |
| @@ -413,7 +413,7 @@ | ||
| 413 | 413 | return closeFuture.get(); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - logger.debug("[{}] closing connection", name); | |
| 416 | + logger.debug("{} closing connection", this); | |
| 417 | 417 | |
| 418 | 418 | boolean terminated = terminate(false, false); |
| 419 | 419 | if (!terminated) |
| @@ -610,13 +610,13 @@ | ||
| 610 | 610 | public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) { |
| 611 | 611 | if (!(e.getMessage() instanceof Message.Response)) { |
| 612 | 612 | String msg = asDebugString(e.getMessage()); |
| 613 | - logger.error("[{}] Received unexpected message: {}", name, msg); | |
| 613 | + logger.error("{} Received unexpected message: {}", Connection.this, msg); | |
| 614 | 614 | defunct(new TransportException(address, "Unexpected message received: " + msg)); |
| 615 | 615 | } else { |
| 616 | 616 | Message.Response response = (Message.Response)e.getMessage(); |
| 617 | 617 | int streamId = response.getStreamId(); |
| 618 | 618 | |
| 619 | - logger.trace("[{}] received: {}", name, e.getMessage()); | |
| 619 | + logger.trace("{} received: {}", Connection.this, e.getMessage()); | |
| 620 | 620 | |
| 621 | 621 | if (streamId < 0) { |
| 622 | 622 | factory.defaultHandler.handle(response); |
| @@ -637,8 +637,8 @@ | ||
| 637 | 637 | */ |
| 638 | 638 | streamIdHandler.unmark(streamId); |
| 639 | 639 | if (logger.isDebugEnabled()) |
| 640 | - logger.debug("[{}] Response received on stream {} but no handler set anymore (either the request has " | |
| 641 | - + "timed out or it was closed due to another error). Received message is {}", name, streamId, asDebugString(response)); | |
| 640 | + logger.debug("{} Response received on stream {} but no handler set anymore (either the request has " | |
| 641 | + + "timed out or it was closed due to another error). Received message is {}", Connection.this, streamId, asDebugString(response)); | |
| 642 | 642 | return; |
| 643 | 643 | } |
| 644 | 644 | handler.cancelTimeout(); |
| @@ -666,7 +666,7 @@ | ||
| 666 | 666 | @Override |
| 667 | 667 | public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) { |
| 668 | 668 | if (logger.isDebugEnabled()) |
| 669 | - logger.debug(String.format("[%s] connection error", name), e.getCause()); | |
| 669 | + logger.debug(String.format("%s connection error", Connection.this), e.getCause()); | |
| 670 | 670 | |
| 671 | 671 | // Ignore exception while writing, this will be handled by write() directly |
| 672 | 672 | if (writer.get() > 0) |