use of org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction in project netvirt by opendaylight.
the class StatisticsImpl method handleInterfaceRemoval.
@Override
public void handleInterfaceRemoval(String interfaceId) {
CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc;
CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc;
try (ReadOnlyTransaction tx = db.newReadOnlyTransaction()) {
iecrc = tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
eecrc = tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
}
try {
Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
if (!iecrcOpt.isPresent() || !eecrcOpt.isPresent()) {
LOG.warn("Couldn't read element counters config data from DB");
StatisticsPluginImplCounters.failed_reading_counter_data_from_config.inc();
return;
}
removeAllElementCounterRequestsOnPort(interfaceId, iecrcOpt.get().getCounterRequests());
removeAllElementCounterRequestsOnPort(interfaceId, eecrcOpt.get().getCounterRequests());
} catch (InterruptedException | ExecutionException e) {
LOG.warn("failed to get counter request data from DB");
StatisticsPluginImplCounters.failed_getting_counter_results_port_removal.inc();
return;
}
}
use of org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction in project netvirt by opendaylight.
the class NodeConnectedHandlerTest method readNodes.
public void readNodes() throws Exception {
ReadOnlyTransaction tx = this.dataBroker.newReadOnlyTransaction();
d1GlobalOpNode = TestUtil.readNode(OPERATIONAL, d1NodePath, tx);
d2GlobalOpNode = TestUtil.readNode(OPERATIONAL, d2NodePath, tx);
haGlobalOpNode = TestUtil.readNode(OPERATIONAL, haNodePath, tx);
d1PsOpNode = TestUtil.readNode(OPERATIONAL, d1PsNodePath, tx);
d2PsOpNode = TestUtil.readNode(OPERATIONAL, d2PsNodePath, tx);
haPsOpNode = TestUtil.readNode(OPERATIONAL, haPsNodePath, tx);
haGlobalConfigNode = TestUtil.readNode(CONFIGURATION, haNodePath, tx);
d1GlobalConfigNode = TestUtil.readNode(CONFIGURATION, d1NodePath, tx);
d2GlobalConfigNode = TestUtil.readNode(CONFIGURATION, d2NodePath, tx);
haPsConfigNode = TestUtil.readNode(CONFIGURATION, haPsNodePath, tx);
d1PsConfigNode = TestUtil.readNode(CONFIGURATION, d1PsNodePath, tx);
d2PsConfigNode = TestUtil.readNode(CONFIGURATION, d2PsNodePath, tx);
tx.close();
}
use of org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction in project netvirt by opendaylight.
the class DhcpSubnetListener method getSubnetMapBuilder.
private SubnetmapBuilder getSubnetMapBuilder(DataBroker broker, Uuid subnetId) {
SubnetmapBuilder builder = null;
InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
ReadOnlyTransaction tx = broker.newReadOnlyTransaction();
Optional<Subnetmap> sn;
try {
sn = tx.read(LogicalDatastoreType.CONFIGURATION, id).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
if (sn.isPresent()) {
builder = new SubnetmapBuilder(sn.get());
} else {
builder = new SubnetmapBuilder().setKey(new SubnetmapKey(subnetId)).setId(subnetId);
}
return builder;
}
use of org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction in project netvirt by opendaylight.
the class DhcpExternalTunnelManager method createRemoteMcastMac.
public RemoteMcastMacs createRemoteMcastMac(Node dstDevice, String logicalSwitchName, IpAddress internalTunnelIp) {
Set<LocatorSet> locators = new HashSet<>();
TerminationPointKey terminationPointKey = HwvtepSouthboundUtils.getTerminationPointKey(internalTunnelIp.getIpv4Address().getValue());
HwvtepPhysicalLocatorRef phyLocRef = new HwvtepPhysicalLocatorRef(HwvtepSouthboundUtils.createInstanceIdentifier(dstDevice.getNodeId()).child(TerminationPoint.class, terminationPointKey));
locators.add(new LocatorSetBuilder().setLocatorRef(phyLocRef).build());
HwvtepLogicalSwitchRef lsRef = new HwvtepLogicalSwitchRef(HwvtepSouthboundUtils.createLogicalSwitchesInstanceIdentifier(dstDevice.getNodeId(), new HwvtepNodeName(logicalSwitchName)));
RemoteMcastMacs remoteMcastMacs = new RemoteMcastMacsBuilder().setMacEntryKey(new MacAddress(UNKNOWN_DMAC)).setLogicalSwitchRef(lsRef).build();
InstanceIdentifier<RemoteMcastMacs> iid = HwvtepSouthboundUtils.createRemoteMcastMacsInstanceIdentifier(dstDevice.getNodeId(), remoteMcastMacs.getKey());
ReadOnlyTransaction transaction = broker.newReadOnlyTransaction();
try {
// TODO do async mdsal read
remoteMcastMacs = transaction.read(LogicalDatastoreType.CONFIGURATION, iid).checkedGet().get();
locators.addAll(remoteMcastMacs.getLocatorSet());
return new RemoteMcastMacsBuilder(remoteMcastMacs).setLocatorSet(new ArrayList<>(locators)).build();
} catch (ReadFailedException e) {
LOG.error("Failed to read the macs {}", iid);
}
return null;
}
use of org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction in project bgpcep by opendaylight.
the class BGPOperationalStateUtils method readGlobalFromDataStore.
private static Bgp readGlobalFromDataStore(final DataBroker dataBroker, final String ribId) {
final InstanceIdentifier<Bgp> bgpIID = PROTOCOLS_IID.child(Protocol.class, new ProtocolKey(BGP.class, ribId)).augmentation(NetworkInstanceProtocol.class).child(Bgp.class);
final ReadOnlyTransaction rot = dataBroker.newReadOnlyTransaction();
try {
return rot.read(LogicalDatastoreType.OPERATIONAL, bgpIID).get().orNull();
} catch (final InterruptedException | ExecutionException e) {
LOG.warn("Failed to read rib {}", ribId, e);
}
return null;
}
Aggregations