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;
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);
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());
}
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<Object> {
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;
}
@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,
}
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());
}