From: Robert Varga Date: Mon, 2 Jul 2018 18:43:55 +0000 (+0200) Subject: Cache topology path X-Git-Tag: release/fluorine~44 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=b9cc350e02936d5edb0bb71cbf4adeb98bf97baa;p=netconf.git Cache topology path Instead of creating base InstanceIdentifier over and over, cache it in a field. Change-Id: I54d1bb7555a94fc20c5cf406f6f6f6dd69d7fc5d Signed-off-by: Robert Varga --- diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/NetconfTopologyRPCProvider.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/NetconfTopologyRPCProvider.java index 1683a35f2d..44e4ff99ac 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/NetconfTopologyRPCProvider.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/NetconfTopologyRPCProvider.java @@ -48,16 +48,17 @@ import org.slf4j.LoggerFactory; public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService { private static final Logger LOG = LoggerFactory.getLogger(NetconfTopologyRPCProvider.class); + private final InstanceIdentifier topologyPath; private final AAAEncryptionService encryptionService; private final DataBroker dataBroker; - private final String topologyId; public NetconfTopologyRPCProvider(final DataBroker dataBroker, final AAAEncryptionService encryptionService, final String topologyId) { this.dataBroker = dataBroker; this.encryptionService = Preconditions.checkNotNull(encryptionService); - this.topologyId = Preconditions.checkNotNull(topologyId); + this.topologyPath = InstanceIdentifier.builder(NetworkTopology.class) + .child(Topology.class, new TopologyKey(new TopologyId(Preconditions.checkNotNull(topologyId)))).build(); } @Override @@ -99,10 +100,7 @@ public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService { final SettableFuture> futureResult) { final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); - final InstanceIdentifier networkTopologyId = - InstanceIdentifier.builder(NetworkTopology.class).build(); - final InstanceIdentifier niid = networkTopologyId.child(Topology.class, - new TopologyKey(new TopologyId(topologyId))).child(Node.class, + final InstanceIdentifier niid = topologyPath.child(Node.class, new NodeKey(nodeId)).augmentation(NetconfNode.class); writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, niid, node, true); final ListenableFuture future = writeTransaction.submit(); @@ -127,11 +125,7 @@ public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService { public ListenableFuture> deleteDevice(final DeleteDeviceInput input) { final NodeId nodeId = new NodeId(input.getNodeId()); - final InstanceIdentifier networkTopologyId = - InstanceIdentifier.builder(NetworkTopology.class).build(); - final InstanceIdentifier niid = networkTopologyId.child(Topology.class, - new TopologyKey(new TopologyId(topologyId))).child(Node.class, - new NodeKey(nodeId)); + final InstanceIdentifier niid = topologyPath.child(Node.class, new NodeKey(nodeId)); final WriteTransaction wtx = dataBroker.newWriteOnlyTransaction(); wtx.delete(LogicalDatastoreType.CONFIGURATION, niid);