use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project openflowplugin by opendaylight.
the class TransactionChainManagerTest method setUp.
@Before
public void setUp() throws Exception {
final ReadOnlyTransaction readOnlyTx = Mockito.mock(ReadOnlyTransaction.class);
final CheckedFuture<Optional<Node>, ReadFailedException> noExistNodeFuture = Futures.immediateCheckedFuture(Optional.<Node>absent());
Mockito.when(readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, nodeKeyIdent)).thenReturn(noExistNodeFuture);
Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTx);
Mockito.when(dataBroker.createTransactionChain(Matchers.any(TransactionChainListener.class))).thenReturn(txChain);
nodeId = new NodeId("h2g2:42");
nodeKeyIdent = DeviceStateUtil.createNodeInstanceIdentifier(nodeId);
Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
txChainManager = new TransactionChainManager(dataBroker, nodeId.getValue());
Mockito.when(txChain.newReadWriteTransaction()).thenReturn(writeTx);
path = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
Mockito.when(writeTx.submit()).thenReturn(Futures.<Void, TransactionCommitFailedException>immediateCheckedFuture(null));
txChainManager.activateTransactionManager();
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException 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;
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project lispflowmapping by opendaylight.
the class DataStoreBackEnd method readTransaction.
private <U extends org.opendaylight.yangtools.yang.binding.DataObject> U readTransaction(InstanceIdentifier<U> readIID, LogicalDatastoreType logicalDatastoreType) {
ReadOnlyTransaction readTx = txChain.newReadOnlyTransaction();
CheckedFuture<Optional<U>, ReadFailedException> readFuture = readTx.read(logicalDatastoreType, readIID);
readTx.close();
try {
Optional<U> optionalDataObject = readFuture.checkedGet();
if (optionalDataObject != null && optionalDataObject.isPresent()) {
return optionalDataObject.get();
} else {
LOG.debug("{}: Failed to read", Thread.currentThread().getStackTrace()[1]);
}
} catch (ReadFailedException e) {
LOG.warn("Failed to ....", e);
}
return null;
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project genius by opendaylight.
the class DirectTunnelUtils method getEgressActionInfosForInterface.
private List<ActionInfo> getEgressActionInfosForInterface(String interfaceName, long tunnelKey, int actionKeyStart) {
DpnTepInterfaceInfo interfaceInfo = dpnTepStateCache.getTunnelFromCache(interfaceName);
if (interfaceInfo == null) {
LOG.error("Interface information not present in config DS for {}", interfaceName);
return Collections.singletonList(new ActionDrop());
}
Optional<StateTunnelList> ifState;
try {
ifState = tunnelStateCache.get(tunnelStateCache.getStateTunnelListIdentifier(interfaceName));
} catch (ReadFailedException e) {
LOG.error("Interface information not present in oper DS for {} ", interfaceName, e);
return Collections.singletonList(new ActionDrop());
}
if (ifState.isPresent()) {
String tunnelType = ItmUtils.convertTunnelTypetoString(interfaceInfo.getTunnelType());
return getEgressActionInfosForInterface(tunnelType, ifState.get().getPortNumber(), tunnelKey, actionKeyStart);
}
LOG.error("Interface information not present in oper DS for {}", interfaceName);
return Collections.singletonList(new ActionDrop());
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project genius by opendaylight.
the class DpnTepStateCache method getDpnTepInterface.
public DpnTepInterfaceInfo getDpnTepInterface(BigInteger srcDpnId, BigInteger dstDpnId) {
DpnTepInterfaceInfo dpnTepInterfaceInfo = dpnTepInterfaceMap.get(getDpnId(srcDpnId, dstDpnId));
if (dpnTepInterfaceInfo == null) {
try {
Optional<DpnsTeps> dpnsTeps = super.get(srcDpnId);
if (dpnsTeps.isPresent()) {
DpnsTeps teps = dpnsTeps.get();
teps.getRemoteDpns().forEach(remoteDpns -> {
DpnTepInterfaceInfo value = new DpnTepInterfaceInfoBuilder().setTunnelName(remoteDpns.getTunnelName()).setGroupId(teps.getGroupId()).setIsMonitoringEnabled(remoteDpns.isMonitoringEnabled()).setIsMonitoringEnabled(remoteDpns.isInternal()).setTunnelType(teps.getTunnelType()).build();
dpnTepInterfaceMap.putIfAbsent(getDpnId(srcDpnId, remoteDpns.getDestinationDpnId()), value);
addTunnelEndPointInfoToCache(remoteDpns.getTunnelName(), teps.getSourceDpnId().toString(), remoteDpns.getDestinationDpnId().toString());
});
}
} catch (ReadFailedException e) {
LOG.error("cache read for dpnID {} in DpnTepStateCache failed ", srcDpnId, e);
}
}
return dpnTepInterfaceMap.get(getDpnId(srcDpnId, dstDpnId));
}
Aggregations