Creating Empty Tables in datastore only when statistics polling is
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / device / initialization / OF10DeviceInitializer.java
index a7290f4cfe6f43400a9dc7ded629165eaac84d28..69b88f24a9bbcd55ffa40618f9e7032f4085a261 100644 (file)
@@ -5,19 +5,17 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.openflowplugin.impl.device.initialization;
 
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.Future;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
@@ -54,7 +52,7 @@ public class OF10DeviceInitializer extends AbstractDeviceInitializer {
     private static final Logger LOG = LoggerFactory.getLogger(OF10DeviceInitializer.class);
 
     @Override
-    protected Future<Void> initializeNodeInformation(@Nonnull final DeviceContext deviceContext,
+    protected ListenableFuture<Void> initializeNodeInformation(@Nonnull final DeviceContext deviceContext,
                                                      final boolean switchFeaturesMandatory,
                                                      final boolean skipTableFeatures,
                                                      @Nullable final MultipartWriterProvider multipartWriterProvider,
@@ -72,7 +70,7 @@ public class OF10DeviceInitializer extends AbstractDeviceInitializer {
 
         Futures.addCallback(future, new FutureCallback<Boolean>() {
             @Override
-            public void onSuccess(@Nullable final Boolean result) {
+            public void onSuccess(final Boolean result) {
                 if (Boolean.TRUE.equals(result)) {
                     LOG.debug("Creating empty flow capable node: {}", deviceInfo);
                     makeEmptyFlowCapableNode(deviceContext, deviceInfo);
@@ -81,25 +79,21 @@ public class OF10DeviceInitializer extends AbstractDeviceInitializer {
                     DeviceInitializationUtil.makeEmptyTables(
                         deviceContext,
                         deviceInfo,
-                        deviceContext.getPrimaryConnectionContext().getFeatures().getTables());
+                        deviceContext.getPrimaryConnectionContext().getFeatures().getTables().toJava());
                 }
             }
 
             @Override
-            public void onFailure(@Nonnull final Throwable throwable) {
+            public void onFailure(final Throwable throwable) {
                 LOG.warn("Error occurred in preparation node {} for protocol 1.0", deviceInfo);
                 LOG.trace("Error for node {} : ", deviceInfo, throwable);
             }
         }, MoreExecutors.directExecutor());
 
-        return Futures.transform(future, new Function<Boolean, Void>() {
-            @Nullable
-            @Override
-            public Void apply(@Nullable final Boolean input) {
-                LOG.debug("Writing physical port information for {}", deviceInfo);
-                writePhyPortInformation(deviceContext);
-                return null;
-            }
+        return Futures.transform(future, input -> {
+            LOG.debug("Writing physical port information for {}", deviceInfo);
+            writePhyPortInformation(deviceContext);
+            return null;
         }, MoreExecutors.directExecutor());
     }
 
@@ -138,6 +132,8 @@ public class OF10DeviceInitializer extends AbstractDeviceInitializer {
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+            justification = "https://github.com/spotbugs/spotbugs/issues/811")
     private static void makeEmptyFlowCapableNode(final TxFacade txFacade, final DeviceInfo deviceInfo) {
         try {
             txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL,