MD-SAL API integration
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / reconciliation / ReconciliationManager.java
index 397dd630e40b66884e1ecf4fb95fe1cdfdf50284..8beaac578822e67142b1d3a98776e4a2c13ee65a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ * Copyright © 2016, 2017 Brocade Communications Systems, Inc. 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,
@@ -8,16 +8,20 @@
 package org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation;
 
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.concurrent.*;
-
 /**
- * Copied from org.opendaylight.ovsdb.southbound.reconciliation.ReconciliationManager
+ * Copied from org.opendaylight.ovsdb.southbound.reconciliation.ReconciliationManager.
  *
+ * <p>
  * This class provides the implementation of ovsdb southbound plugins
  * configuration reconciliation engine. This engine provide interfaces
  * to enqueue (one time retry)/ enqueueForRetry(periodic retry)/ dequeue
@@ -31,6 +35,7 @@ import java.util.concurrent.*;
  * Ideally, addition of any type of reconciliation task should not require
  * any change in this reconciliation manager execution engine.
  *
+ * <p>
  * 3-Node Cluster:
  * Reconciliation manager is agnostic of whether it's running in single
  * node cluster or 3-node cluster. It's a responsibility of the task
@@ -40,6 +45,7 @@ import java.util.concurrent.*;
  * the 3-nodes in the cluster, because connection to individual controller
  * can be interrupted for various reason.
  *
+ * <p>
  * Created by Anil Vishnoi (avishnoi@Brocade.com) on 3/9/16.
  */
 public class ReconciliationManager implements AutoCloseable {
@@ -56,7 +62,9 @@ public class ReconciliationManager implements AutoCloseable {
 
     public ReconciliationManager(final DataBroker db) {
         this.db = db;
-        reconcilers = SpecialExecutors.newBoundedCachedThreadPool(NO_OF_RECONCILER, RECON_TASK_QUEUE_SIZE, "ovsdb-reconciler");
+        reconcilers =
+                SpecialExecutors.newBoundedCachedThreadPool(NO_OF_RECONCILER, RECON_TASK_QUEUE_SIZE, "ovsdb-reconciler",
+                        getClass());
 
         ThreadFactory threadFact = new ThreadFactoryBuilder()
                 .setNameFormat("ovsdb-recon-task-triager-%d").build();
@@ -75,12 +83,7 @@ public class ReconciliationManager implements AutoCloseable {
     public void enqueueForRetry(final ReconciliationTask task) {
         LOG.trace("Reconciliation task re-queued for re-execution {}",task);
         reconTaskManager.cacheTask(task, taskTriager.schedule(
-                new Runnable() {
-                    @Override
-                    public void run() {
-                        task.checkReadinessAndProcess();
-                    }
-                }, task.retryDelayInMills(), TimeUnit.MILLISECONDS
+                task::checkReadinessAndProcess, task.retryDelayInMills(), TimeUnit.MILLISECONDS
             )
         );
     }