- private final YangStoreService yangStoreService;
- private final ConfigRegistryJMXClient jmxClient;
-
- private static final Logger LOG = LoggerFactory.getLogger(NetconfOperationServiceFactoryImpl.class);
-
- public NetconfOperationServiceFactoryImpl(YangStoreService yangStoreService) {
- this(yangStoreService, ManagementFactory.getPlatformMBeanServer());
- }
-
- 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) {
-
- try {
- configRegistryJMXClient = new ConfigRegistryJMXClient(mBeanServer);
- break;
- } catch (IllegalStateException e) {
- ++i;
- if (i > SILENT_ATTEMPTS) {
- LOG.info("JMX client not created after {} attempts, still trying", i, e);
- } else {
- LOG.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 IllegalStateException("Interrupted while reattempting connection", e1);
- }
- }
- }
-
- jmxClient = configRegistryJMXClient;
- if (i > SILENT_ATTEMPTS) {
- LOG.info("Created JMX client after {} attempts", i);
- } else {
- LOG.debug("Created JMX client after {} attempts", i);
- }