use of org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction in project bgpcep by opendaylight.
the class MatchOriginatorIdSetHandler method loadSets.
private OriginatorIdSet loadSets(final String key) throws ExecutionException, InterruptedException {
final ReadOnlyTransaction tr = this.dataBroker.newReadOnlyTransaction();
final Optional<OriginatorIdSet> result = tr.read(LogicalDatastoreType.CONFIGURATION, ORIGINATOR_ID_SETS_IID.child(OriginatorIdSet.class, new OriginatorIdSetKey(key))).get();
return result.orNull();
}
use of org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction in project bgpcep by opendaylight.
the class MatchRoleSetHandler method loadRoleSets.
private List<PeerRole> loadRoleSets(final String key) throws ExecutionException, InterruptedException {
final ReadOnlyTransaction tr = this.dataBroker.newReadOnlyTransaction();
final Optional<RoleSet> result = tr.read(LogicalDatastoreType.CONFIGURATION, ROLE_SET_IID.child(RoleSet.class, new RoleSetKey(key))).get();
if (!result.isPresent()) {
return Collections.emptyList();
}
return result.get().getRole();
}
use of org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction in project bgpcep by opendaylight.
the class BGPRibPolicyImpl method loadStatements.
private List<Statement> loadStatements(final String key) throws ExecutionException, InterruptedException {
final ReadOnlyTransaction tr = this.databroker.newReadOnlyTransaction();
final com.google.common.base.Optional<Statements> result = tr.read(LogicalDatastoreType.CONFIGURATION, ROUTING_POLICY_IID.child(PolicyDefinitions.class).child(PolicyDefinition.class, new PolicyDefinitionKey(key)).child(Statements.class)).get();
if (!result.isPresent()) {
return Collections.emptyList();
}
return result.get().getStatement();
}
use of org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction in project bgpcep by opendaylight.
the class CheckUtil method checkNotPresent.
private static <T extends DataObject> void checkNotPresent(final DataBroker dataBroker, final LogicalDatastoreType ldt, final InstanceIdentifier<T> iid) throws ReadFailedException {
AssertionError lastError = null;
final Stopwatch sw = Stopwatch.createStarted();
while (sw.elapsed(TimeUnit.SECONDS) <= 10) {
try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) {
final com.google.common.base.Optional<T> data = tx.read(ldt, iid).checkedGet();
try {
assert !data.isPresent();
return;
} catch (final AssertionError e) {
lastError = e;
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.MILLISECONDS);
}
}
}
throw lastError;
}
use of org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction in project openflowplugin by opendaylight.
the class OpenflowpluginStatsTestCommandProvider method _flowStats.
public void _flowStats(CommandInterpreter ci) {
int flowCount = 0;
int flowStatsCount = 0;
List<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.getKey();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
List<Table> tables = node.getTable();
for (Table table2 : tables) {
TableKey tableKey = table2.getKey();
InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
if (table != null) {
if (table.getFlow() != null) {
List<Flow> flows = table.getFlow();
for (Flow flow2 : flows) {
flowCount++;
FlowKey flowKey = flow2.getKey();
InstanceIdentifier<Flow> flowRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
Flow flow = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, flowRef);
if (flow != null) {
FlowStatisticsData data = flow.getAugmentation(FlowStatisticsData.class);
if (null != data) {
flowStatsCount++;
LOG.debug("--------------------------------------------");
ci.print(data);
}
}
}
}
}
}
}
}
if (flowCount == flowStatsCount) {
LOG.debug("flowStats - Success");
} else {
LOG.debug("flowStats - Failed");
LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
Aggregations