Search in sources :

Example 46 with ReadFailedException

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();
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Optional(com.google.common.base.Optional) TransactionChainListener(org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) TransactionChainManager(org.opendaylight.openflowplugin.common.txchain.TransactionChainManager) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Before(org.junit.Before)

Example 47 with ReadFailedException

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;
}
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)

Example 48 with ReadFailedException

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;
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Optional(com.google.common.base.Optional) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)

Example 49 with ReadFailedException

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());
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) DpnTepInterfaceInfo(org.opendaylight.genius.itm.utils.DpnTepInterfaceInfo) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop)

Example 50 with ReadFailedException

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));
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) DpnTepInterfaceInfoBuilder(org.opendaylight.genius.itm.utils.DpnTepInterfaceInfoBuilder) DpnTepInterfaceInfo(org.opendaylight.genius.itm.utils.DpnTepInterfaceInfo) DpnsTeps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.teps.state.DpnsTeps)

Aggregations

ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)129 Optional (com.google.common.base.Optional)44 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)30 ArrayList (java.util.ArrayList)25 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)25 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)23 ExecutionException (java.util.concurrent.ExecutionException)17 Test (org.junit.Test)16 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)10 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)10 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)9 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)9 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)8 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)8 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)7 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)7 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 SingleTransactionDataBroker (org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)6 VpnInstance (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance)6