X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Fnetconf%2Fsal%2FNetconfDeviceTopologyAdapter.java;h=5bc790363466de47a6b707715bb25efb5d79fb45;hb=ab3aca4b7ad97b9068a9366653da7de03405232c;hp=41609b89c4fdd52950b336440adc643a52ee786b;hpb=528bb2ddb15b06b081695f61022c0e4eedb68fcb;p=netconf.git diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapter.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapter.java index 41609b89c4..5bc7903634 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapter.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapter.java @@ -9,9 +9,7 @@ package org.opendaylight.netconf.sal.connect.netconf.sal; import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; import java.util.ArrayList; import java.util.List; @@ -21,7 +19,7 @@ import java.util.stream.Collectors; import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities; import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; @@ -52,7 +50,7 @@ import org.opendaylight.yangtools.yang.common.QName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public final class NetconfDeviceTopologyAdapter implements AutoCloseable { +public class NetconfDeviceTopologyAdapter implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceTopologyAdapter.class); @@ -132,6 +130,8 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable { String reason = throwable != null && throwable.getMessage() != null ? throwable.getMessage() : UNKNOWN_REASON; final NetconfNode data = new NetconfNodeBuilder() + .setHost(id.getHost()) + .setPort(new PortNumber(id.getAddress().getPort())) .setConnectionStatus(ConnectionStatus.UnableToConnect).setConnectedMessage(reason).build(); final WriteTransaction writeTx = txChain.newWriteOnlyTransaction(); @@ -203,7 +203,7 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable { id, writeTx.getIdentifier()); try { - writeTx.submit().get(); + writeTx.commit().get(); } catch (InterruptedException | ExecutionException e) { LOG.error("{}: Transaction(close) {} FAILED!", id, writeTx.getIdentifier(), e); throw new IllegalStateException(id + " Transaction(close) not committed correctly", e); @@ -227,11 +227,10 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable { private void commitTransaction(final WriteTransaction transaction, final String txType) { LOG.trace("{}: Committing Transaction {}:{}", id, txType, transaction.getIdentifier()); - final CheckedFuture result = transaction.submit(); - Futures.addCallback(result, new FutureCallback() { + transaction.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { LOG.trace("{}: Transaction({}) {} SUCCESSFUL", id, txType, transaction.getIdentifier()); } @@ -246,19 +245,14 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable { }, MoreExecutors.directExecutor()); } - private static Node getNodeWithId(final RemoteDeviceId id) { - final NodeBuilder builder = getNodeIdBuilder(id); - return builder.build(); - } - private static NodeBuilder getNodeIdBuilder(final RemoteDeviceId id) { final NodeBuilder nodeBuilder = new NodeBuilder(); - nodeBuilder.setKey(new NodeKey(new NodeId(id.getName()))); + nodeBuilder.withKey(new NodeKey(new NodeId(id.getName()))); return nodeBuilder; } @Override - public void close() throws Exception { + public void close() { removeDeviceConfiguration(); }