X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=applications%2Fbulk-o-matic%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fapplications%2Fbulk%2Fo%2Fmatic%2FFlowWriterSequential.java;h=987d73de6e928513ba13fccbdc076cd8a1d1761b;hb=05f8db12159673d0e0a95642fe86e62c14b7dc7b;hp=7e8fe0009fab658b03f81e8f2ae3379d13100036;hpb=b7e8e4ab19857d92fbf22795406174cf453128e9;p=openflowplugin.git diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java index 7e8fe0009f..987d73de6e 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java @@ -8,15 +8,13 @@ package org.opendaylight.openflowplugin.applications.bulk.o.matic; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; - import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -108,11 +106,11 @@ public class FlowWriterSequential implements FlowCounterMBean { writeOpStatus.set(FlowCounter.OperationStatus.IN_PROGRESS.status()); Short tableId = startTableId; - Integer sourceIp = 1; WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); short calculatedTableId = tableId; + int sourceIp = 1; for (; sourceIp <= batchSize; sourceIp++) { String flowId = "Flow-" + dpId + "." + calculatedTableId + "." + sourceIp; LOG.debug("Adding flow with id: {}", flowId); @@ -134,7 +132,7 @@ public class FlowWriterSequential implements FlowCounterMBean { LOG.debug("Submitting Txn for dpId: {}, begin tableId: {}, end tableId: {}, sourceIp: {}", dpId, tableId, calculatedTableId, sourceIp); - Futures.addCallback(writeTransaction.submit(), new DsCallBack(dpId, sourceIp, calculatedTableId), + writeTransaction.commit().addCallback(new DsCallBack(dpId, sourceIp, calculatedTableId), MoreExecutors.directExecutor()); } @@ -142,19 +140,23 @@ public class FlowWriterSequential implements FlowCounterMBean { Flow flow) { if (add) { LOG.trace("Adding flow for flowId: {}, flowIid: {}", flowId, flowIid); - writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow, isCreateParents); + if (isCreateParents) { + writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowIid, flow); + } else { + writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow); + } } else { LOG.trace("Deleting flow for flowId: {}, flowIid: {}", flowId, flowIid); writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowIid); } } - private class DsCallBack implements FutureCallback { + private class DsCallBack implements FutureCallback { private final String dpId; - private Integer sourceIp; + private int sourceIp; private final Short tableId; - DsCallBack(String dpId, Integer sourceIp, Short tableId) { + DsCallBack(String dpId, int sourceIp, Short tableId) { this.dpId = dpId; this.sourceIp = sourceIp; short numberA = 1; @@ -163,7 +165,7 @@ public class FlowWriterSequential implements FlowCounterMBean { } @Override - public void onSuccess(Object object) { + public void onSuccess(Object notUsed) { if (sourceIp > flowsPerDpn) { long dur = System.nanoTime() - startTime; LOG.info("Completed all flows installation for: dpid: {}, tableId: {}, sourceIp: {} in {}ns", dpId, @@ -206,7 +208,7 @@ public class FlowWriterSequential implements FlowCounterMBean { } LOG.debug("OnSuccess: Submitting Txn for dpId: {}, begin tableId: {}, end tableId: {}, sourceIp: {}", dpId, tableId, calculatedTableId, sourceIp); - Futures.addCallback(writeTransaction.submit(), new DsCallBack(dpId, sourceIp, calculatedTableId), + writeTransaction.commit().addCallback(new DsCallBack(dpId, sourceIp, calculatedTableId), MoreExecutors.directExecutor()); }