Bug 8055: use method references instead of lambdas
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / HwvtepConnectionInstance.java
index 43ca350f3bd238952abf9aab22b07070f9600c58..c8c859a80d4f226e95eb509fe07e92c1f3570ce5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2015, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -17,13 +17,13 @@ import java.util.concurrent.ExecutionException;
 
 import javax.annotation.Nonnull;
 
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transact.TransactCommand;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transact.TransactInvoker;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transact.TransactInvokerImpl;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvoker;
-import org.opendaylight.ovsdb.lib.EchoServiceCallbackFilters;
 import org.opendaylight.ovsdb.lib.LockAquisitionCallback;
 import org.opendaylight.ovsdb.lib.LockStolenCallback;
 import org.opendaylight.ovsdb.lib.MonitorCallBack;
@@ -67,17 +67,21 @@ public class HwvtepConnectionInstance {
     private EntityOwnershipCandidateRegistration deviceOwnershipCandidateRegistration;
     private HwvtepGlobalAugmentation initialCreatedData = null;
     private HwvtepDeviceInfo deviceInfo;
+    private DataBroker dataBroker;
+    private final HwvtepConnectionManager hwvtepConnectionManager;
 
-    HwvtepConnectionInstance (ConnectionInfo key, OvsdbClient client,
-                              InstanceIdentifier<Node> iid, TransactionInvoker txInvoker) {
+    HwvtepConnectionInstance (HwvtepConnectionManager hwvtepConnectionManager, ConnectionInfo key, OvsdbClient client,
+                              InstanceIdentifier<Node> iid, TransactionInvoker txInvoker, DataBroker dataBroker) {
+        this.hwvtepConnectionManager = hwvtepConnectionManager;
         this.connectionInfo = key;
         this.client = client;
         this.instanceIdentifier = iid;
         this.txInvoker = txInvoker;
-        this.deviceInfo = new HwvtepDeviceInfo();
+        this.deviceInfo = new HwvtepDeviceInfo(this);
+        this.dataBroker = dataBroker;
     }
 
-    public void transact(TransactCommand command) {
+    public synchronized void transact(TransactCommand command) {
         for (TransactInvoker transactInvoker: transactInvokers.values()) {
             transactInvoker.invoke(command);
         }
@@ -155,6 +159,10 @@ public class HwvtepConnectionInstance {
          */
     }
 
+    public DataBroker getDataBroker() {
+        return dataBroker;
+    }
+
     public ListenableFuture<List<String>> getDatabases() {
         return client.getDatabases();
     }
@@ -248,6 +256,7 @@ public class HwvtepConnectionInstance {
 
     public void setInstanceIdentifier(InstanceIdentifier<Node> iid) {
         this.instanceIdentifier = iid;
+        hwvtepConnectionManager.putConnectionInstance(instanceIdentifier, this);
     }
 
     public Entity getConnectedEntity() {