Skip to content

Commit

Permalink
Fix log message claiming connected to Cottontail even when not connec…
Browse files Browse the repository at this point in the history
…ted (#367)
  • Loading branch information
Spiess committed Mar 15, 2023
1 parent b571a18 commit d132b19
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public CottontailWrapper(String host, int port) {
this.client = new SimpleClient(sharedChannel(host, port));
boolean pingSuccessful = this.client.ping();
watch.stop();
if (!pingSuccessful) {
if (pingSuccessful) {
LOGGER.info("Connected to Cottontail DB in {} ms at {}:{}", watch.getTime(TimeUnit.MILLISECONDS), host, port);
} else {
LOGGER.warn("Could not ping Cottontail DB instance at {}:{}", host, port);
}
}
Expand Down Expand Up @@ -72,16 +74,13 @@ private static ManagedChannel sharedChannel(String host, int port) {
* @return {@link ManagedChannel}
*/
private static ManagedChannel createChannel(String host, int port) {
final StopWatch watch = StopWatch.createStarted();
LOGGER.debug("Starting to connect to Cottontail DB at {}:{}", host, port);
final NettyChannelBuilder builder = NettyChannelBuilder.forAddress(host, port).usePlaintext();
final ManagedChannel channel = builder.build();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
LOGGER.info("Closing connection to Cottontail DB.");
channel.shutdownNow();
}));
watch.stop();
LOGGER.info("Connected to Cottontail DB in {} ms at {}:{}", watch.getTime(TimeUnit.MILLISECONDS), host, port);
return channel;
}

Expand Down

0 comments on commit d132b19

Please sign in to comment.