X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fclient%2FNetconfClient.java;h=2ce779a1f54e9ce4f68b9c7f1db478d9de4e0201;hb=213aae87ecaccb43f3d909e0455db43511ace381;hp=d95977492a9206fb0ff05d4e6229810b08dcda9a;hpb=549b3260a884bf1801d6ea1a0f4ffb7bb5ed2bf5;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 d95977492a..2ce779a1f5 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 @@ -67,6 +67,10 @@ public class NetconfClient implements Closeable { } } + public static NetconfClient clientFor(String clientLabelForLogging, InetSocketAddress address, ReconnectStrategy strat, NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException { + return new NetconfClient(clientLabelForLogging,address,strat,netconfClientDispatcher); + } + public NetconfClient(String clientLabelForLogging, InetSocketAddress address, int connectTimeoutMs, NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException { this(clientLabelForLogging, address, @@ -84,6 +88,7 @@ public class NetconfClient implements Closeable { } public NetconfMessage sendMessage(NetconfMessage message, int attempts, int attemptMsDelay) { + long startTime = System.currentTimeMillis(); Preconditions.checkState(clientSession.isUp(), "Session was not up yet"); clientSession.sendMessage(message); try { @@ -92,6 +97,9 @@ public class NetconfClient implements Closeable { 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); } } @@ -100,6 +108,10 @@ public class NetconfClient implements Closeable { clientSession.close(); } + public NetconfClientDispatcher getNetconfClientDispatcher() { + return dispatch; + } + private static ReconnectStrategy getReconnectStrategy(int connectionAttempts, int attemptMsTimeout) { return new TimedReconnectStrategy(GlobalEventExecutor.INSTANCE, attemptMsTimeout, 1000, 1.0, null, Long.valueOf(connectionAttempts), null);