X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fnetconf%2Fnetconf-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fclient%2FNetconfClient.java;h=4fcad2cbd6afef217f32d23f71383f13f277414c;hb=c5b0b028392646507133df0af5efcee547763b6d;hp=8b8c886a1c0328b558a4992c7d67b6b99b71800c;hpb=f0fb3be54c79ce64725b467acdbf99a45b3a2504;p=controller.git diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java index 8b8c886a1c..4fcad2cbd6 100644 --- a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java +++ b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java @@ -8,16 +8,11 @@ package org.opendaylight.controller.netconf.client; +import com.google.common.base.Preconditions; +import com.google.common.base.Stopwatch; +import com.google.common.collect.Sets; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GlobalEventExecutor; - -import java.io.Closeable; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.Set; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; - import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.protocol.framework.NeverReconnectStrategy; import org.opendaylight.protocol.framework.ReconnectStrategy; @@ -25,8 +20,13 @@ import org.opendaylight.protocol.framework.TimedReconnectStrategy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Preconditions; -import com.google.common.collect.Sets; +import java.io.Closeable; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.Set; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; public class NetconfClient implements Closeable { @@ -103,19 +103,20 @@ public class NetconfClient implements Closeable { } public NetconfMessage sendMessage(NetconfMessage message, int attempts, int attemptMsDelay) { - long startTime = System.currentTimeMillis(); + Stopwatch stopwatch = new Stopwatch().start(); Preconditions.checkState(clientSession.isUp(), "Session was not up yet"); //logger.debug("Sending message: {}",XmlUtil.toString(message.getDocument())); clientSession.sendMessage(message); try { return sessionListener.getLastMessage(attempts, attemptMsDelay); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); throw new RuntimeException(this + " Cannot read message from " + address, e); } catch (IllegalStateException e) { throw new IllegalStateException(this + " Cannot read message from " + address, e); } finally { - long diffMillis = System.currentTimeMillis() - startTime; - logger.debug("Total time spent waiting for response {}", diffMillis); + stopwatch.stop(); + logger.debug("Total time spent waiting for response {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS)); } }