X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Fosgi%2FNetconfOperationServiceFactoryImpl.java;h=034b39a8066b0fbf631c4159558efdd15a362a2a;hb=702ba6faa3f7f2f6bd8ae02b3bc1abc06aea1c26;hp=2db3c9d4f1d538893da1b9de420c696ef555e242;hpb=0ae12c54560ef14cb8c08beef4553f7523d41578;p=controller.git diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java index 2db3c9d4f1..034b39a806 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java @@ -21,6 +21,7 @@ import java.lang.management.ManagementFactory; public class NetconfOperationServiceFactoryImpl implements NetconfOperationServiceFactory { public static final int ATTEMPT_TIMEOUT_MS = 1000; + private static final int SILENT_ATTEMPTS = 30; private final YangStoreService yangStoreService; private final ConfigRegistryJMXClient jmxClient; @@ -34,25 +35,35 @@ public class NetconfOperationServiceFactoryImpl implements NetconfOperationServi public NetconfOperationServiceFactoryImpl(YangStoreService yangStoreService, MBeanServer mBeanServer) { this.yangStoreService = yangStoreService; + ConfigRegistryJMXClient configRegistryJMXClient; + int i = 0; // Config registry might not be present yet, but will be eventually while(true) { - final ConfigRegistryJMXClient configRegistryJMXClient; try { configRegistryJMXClient = new ConfigRegistryJMXClient(mBeanServer); + break; } catch (IllegalStateException e) { - logger.debug("Jmx client could not be created, reattempting"); + ++i; + if (i > SILENT_ATTEMPTS) { + logger.info("JMX client not created after {} attempts, still trying", i, e); + } else { + logger.debug("JMX client could not be created, reattempting, try {}", i, e); + } try { Thread.sleep(ATTEMPT_TIMEOUT_MS); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); - throw new RuntimeException(e1); + throw new RuntimeException("Interrupted while reattempting connection", e1); } - continue; } + } - jmxClient = configRegistryJMXClient; - break; + jmxClient = configRegistryJMXClient; + if (i > SILENT_ATTEMPTS) { + logger.info("Created JMX client after {} attempts", i); + } else { + logger.debug("Created JMX client after {} attempts", i); } }