* 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.dsbenchmark.simpletx;
-
-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.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+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.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
public class SimpletxBaDelete extends DatastoreAbstractWriter {
private static final Logger LOG = LoggerFactory.getLogger(SimpletxBaDelete.class);
- private DataBroker dataBroker;
+ private final DataBroker dataBroker;
- public SimpletxBaDelete(DataBroker dataBroker, int outerListElem, int innerListElem,
- long writesPerTx, DataStore dataStore) {
+ public SimpletxBaDelete(final DataBroker dataBroker, final int outerListElem, final int innerListElem,
+ final long writesPerTx, final DataStore dataStore) {
super(StartTestInput.Operation.DELETE, outerListElem, innerListElem, writesPerTx, dataStore);
this.dataBroker = dataBroker;
- LOG.info("Created SimpletxBaDelete");
+ LOG.debug("Created SimpletxBaDelete");
}
@Override
public void createList() {
- LOG.info("DatastoreDelete: creating data in the data store");
+ LOG.debug("DatastoreDelete: creating data in the data store");
// Dump the whole list into the data store in a single transaction
// with <outerListElem> PUTs on the transaction
SimpletxBaWrite dd = new SimpletxBaWrite(dataBroker,
@Override
public void executeList() {
+ final LogicalDatastoreType dsType = getDataStoreType();
+
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
long putCnt = 0;
for (long l = 0; l < outerListElem; l++) {
InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
.child(OuterList.class, new OuterListKey((int)l));
- tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
+ tx.delete(dsType, iid);
putCnt++;
if (putCnt == writesPerTx) {
try {
- tx.submit().checkedGet();
+ tx.commit().get();
txOk++;
- } catch (TransactionCommitFailedException e) {
- LOG.error("Transaction failed: {}", e);
+ } catch (final InterruptedException | ExecutionException e) {
+ LOG.error("Transaction failed", e);
txError++;
}
tx = dataBroker.newWriteOnlyTransaction();
}
if (putCnt != 0) {
try {
- tx.submit().checkedGet();
- } catch (TransactionCommitFailedException e) {
- LOG.error("Transaction failed: {}", e);
+ tx.commit().get();
+ } catch (final InterruptedException | ExecutionException e) {
+ LOG.error("Transaction failed", e);
}
}
}