Search in sources :

Example 1 with ReadTransaction

use of org.opendaylight.controller.md.sal.binding.api.ReadTransaction in project openflowplugin by opendaylight.

the class OFPluginFlowTest method readFlow.

// TODO move to separate test util class
private static final Flow readFlow(InstanceIdentifier<Flow> flow) {
    Flow searchedFlow = null;
    ReadTransaction rt = dataBroker.newReadOnlyTransaction();
    CheckedFuture<Optional<Flow>, ReadFailedException> flowFuture = rt.read(LogicalDatastoreType.CONFIGURATION, flow);
    try {
        Optional<Flow> maybeFlow = flowFuture.checkedGet(500, TimeUnit.SECONDS);
        if (maybeFlow.isPresent()) {
            searchedFlow = maybeFlow.get();
        }
    } catch (TimeoutException e) {
        LOG.error("Future timed out. Getting FLOW from DataStore failed.", e);
    } catch (ReadFailedException e) {
        LOG.error("Something wrong happened in DataStore. Getting FLOW for userId {} failed.", e);
    }
    return searchedFlow;
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Optional(com.google.common.base.Optional) ReadTransaction(org.opendaylight.controller.md.sal.binding.api.ReadTransaction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

Optional (com.google.common.base.Optional)1 TimeoutException (java.util.concurrent.TimeoutException)1 ReadTransaction (org.opendaylight.controller.md.sal.binding.api.ReadTransaction)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)1