X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2Fosgi%2FNetconfOperationServiceSnapshotImpl.java;fp=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2Fosgi%2FNetconfOperationServiceSnapshot.java;h=ce312548b2858f7884596ea1f8d2b9f927f966a5;hp=5c08505091253282bdb638600b0ed656d3f2c319;hb=8f4996a3a1d486d83907c656a6c5390686c360a1;hpb=6932c15f119da55b17ce4ad39236566bfed96ab3 diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceSnapshot.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceSnapshotImpl.java similarity index 51% rename from opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceSnapshot.java rename to opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceSnapshotImpl.java index 5c08505091..ce312548b2 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceSnapshot.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceSnapshotImpl.java @@ -10,62 +10,46 @@ package org.opendaylight.controller.netconf.impl.osgi; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot; +import org.opendaylight.controller.netconf.util.CloseableUtil; import java.util.Collections; import java.util.HashSet; import java.util.Set; -public class NetconfOperationServiceSnapshot implements AutoCloseable { - private static final Logger logger = LoggerFactory.getLogger(NetconfOperationServiceSnapshot.class); +public class NetconfOperationServiceSnapshotImpl implements NetconfOperationServiceSnapshot { private final Set services; private final String netconfSessionIdForReporting; - public NetconfOperationServiceSnapshot(Set factories, long sessionId) { + public NetconfOperationServiceSnapshotImpl(Set factories, String sessionIdForReporting) { Set services = new HashSet<>(); - netconfSessionIdForReporting = getNetconfSessionIdForReporting(sessionId); + netconfSessionIdForReporting = sessionIdForReporting; for (NetconfOperationServiceFactory factory : factories) { services.add(factory.createService(netconfSessionIdForReporting)); } this.services = Collections.unmodifiableSet(services); } - private static String getNetconfSessionIdForReporting(long sessionId) { - return "netconf session id " + sessionId; - } + + @Override public String getNetconfSessionIdForReporting() { return netconfSessionIdForReporting; } + @Override public Set getServices() { return services; } @Override - public void close() { - RuntimeException firstException = null; - for (NetconfOperationService service : services) { - try { - service.close(); - } catch (RuntimeException e) { - logger.warn("Got exception while closing {}", service, e); - if (firstException == null) { - firstException = e; - } else { - firstException.addSuppressed(e); - } - } - } - if (firstException != null) { - throw firstException; - } + public void close() throws Exception { + CloseableUtil.closeAll(services); } @Override public String toString() { - return "NetconfOperationServiceSnapshot{" + netconfSessionIdForReporting + '}'; + return "NetconfOperationServiceSnapshotImpl{" + netconfSessionIdForReporting + '}'; } }