X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-persister-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fpersist%2Fimpl%2FConfigPusherImpl.java;h=22b061a1285c88d0ea372a5c104a2baf69fcb58c;hp=b06219c978558cb69c92bb353d279cb0f8c480cb;hb=4e59b3bd93bc8d7bf1880e98b75c87faab8f61c9;hpb=c6b87f96d930b1873cc4a5091b7413e7ad26f6dc diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusherImpl.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusherImpl.java index b06219c978..22b061a128 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusherImpl.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusherImpl.java @@ -33,10 +33,10 @@ import org.opendaylight.controller.config.api.ConflictingVersionException; import org.opendaylight.controller.config.persist.api.ConfigPusher; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.config.persist.api.Persister; +import org.opendaylight.controller.netconf.api.Capability; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants; -import org.opendaylight.controller.netconf.mapping.api.Capability; import org.opendaylight.controller.netconf.mapping.api.HandlingPriority; import org.opendaylight.controller.netconf.mapping.api.NetconfOperation; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution; @@ -78,17 +78,9 @@ public class ConfigPusherImpl implements ConfigPusher { synchronized (autoCloseables) { autoCloseables.add(jmxNotificationHandler); } - /* - * We have completed initial configuration. At this point - * it is good idea to perform garbage collection to prune - * any garbage we have accumulated during startup. - */ - LOG.debug("Running post-initialization garbage collection..."); - System.gc(); - LOG.debug("Post-initialization garbage collection completed."); - LOG.debug("ConfigPusher has pushed configs {}, gc completed", configs); - } - catch (NetconfDocumentedException e) { + + LOG.debug("ConfigPusher has pushed configs {}", configs); + } catch (NetconfDocumentedException e) { LOG.error("Error pushing configs {}",configs); throw new IllegalStateException(e); } @@ -123,17 +115,20 @@ public class ConfigPusherImpl implements ConfigPusher { */ private synchronized EditAndCommitResponse pushConfigWithConflictingVersionRetries(ConfigSnapshotHolder configSnapshotHolder) throws NetconfDocumentedException { ConflictingVersionException lastException; - Stopwatch stopwatch = new Stopwatch().start(); + Stopwatch stopwatch = Stopwatch.createUnstarted(); do { String idForReporting = configSnapshotHolder.toString(); SortedSet expectedCapabilities = checkNotNull(configSnapshotHolder.getCapabilities(), "Expected capabilities must not be null - %s, check %s", idForReporting, configSnapshotHolder.getClass().getName()); try (NetconfOperationService operationService = getOperationServiceWithRetries(expectedCapabilities, idForReporting)) { + if(!stopwatch.isRunning()) { + stopwatch.start(); + } return pushConfig(configSnapshotHolder, operationService); } catch (ConflictingVersionException e) { lastException = e; - LOG.debug("Conflicting version detected, will retry after timeout"); + LOG.info("Conflicting version detected, will retry after timeout"); sleep(); } } while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < conflictingVersionTimeoutMillis); @@ -142,7 +137,7 @@ public class ConfigPusherImpl implements ConfigPusher { } private NetconfOperationService getOperationServiceWithRetries(Set expectedCapabilities, String idForReporting) { - Stopwatch stopwatch = new Stopwatch().start(); + Stopwatch stopwatch = Stopwatch.createStarted(); NotEnoughCapabilitiesException lastException; do { try { @@ -182,20 +177,20 @@ public class ConfigPusherImpl implements ConfigPusher { } catch(RuntimeException e) { throw new NotEnoughCapabilitiesException("Netconf service not stable for " + idForReporting, e); } - Set notFoundDiff = computeNotFoundCapabilities(expectedCapabilities, serviceCandidate); + Set notFoundDiff = computeNotFoundCapabilities(expectedCapabilities, configNetconfConnector); if (notFoundDiff.isEmpty()) { return serviceCandidate; } else { serviceCandidate.close(); LOG.trace("Netconf server did not provide required capabilities for {} ", idForReporting, "Expected but not found: {}, all expected {}, current {}", - notFoundDiff, expectedCapabilities, serviceCandidate.getCapabilities() + notFoundDiff, expectedCapabilities, configNetconfConnector.getCapabilities() ); throw new NotEnoughCapabilitiesException("Not enough capabilities for " + idForReporting + ". Expected but not found: " + notFoundDiff); } } - private static Set computeNotFoundCapabilities(Set expectedCapabilities, NetconfOperationService serviceCandidate) { + private static Set computeNotFoundCapabilities(Set expectedCapabilities, NetconfOperationServiceFactory serviceCandidate) { Collection actual = Collections2.transform(serviceCandidate.getCapabilities(), new Function() { @Override public String apply(@Nonnull final Capability input) { @@ -235,7 +230,7 @@ public class ConfigPusherImpl implements ConfigPusher { throw new IllegalStateException("Cannot parse " + configSnapshotHolder); } LOG.trace("Pushing last configuration to netconf: {}", configSnapshotHolder); - Stopwatch stopwatch = new Stopwatch().start(); + Stopwatch stopwatch = Stopwatch.createStarted(); NetconfMessage editConfigMessage = createEditConfigMessage(xmlToBePersisted); Document editResponseMessage = sendRequestGetResponseCheckIsOK(editConfigMessage, operationService,