六、OpenDaylight应用基础开发(DataStore)

本文档详细介绍了OpenDaylight中的DataStore概念,包括DataTree、OperationalDataTree和ConfigurationDataTree等。文章重点阐述了基于事务的读写操作,如ReadOnlyTransaction和WriteTransaction的使用,并讨论了DataStore的数据变更通知机制。此外,还探讨了事务链的设计初衷、实现原理及其实现接口。最后,提供了实践练习,涉及监听网络设备状态和通过写库方式下发流表规则。

1 DataStore相关概念

  1. ODL社区实现的内存数据库,其存储的数据结构是由YANG定义的树状的结构
  2. 基于事务的访问与操作
  3. 支持数据变更通知
  4. 支持事务链
  5. DataStore is an intelligent in-memory cache with tree-like structures that would be able to track dependencies, calculate change sets and maintain the relationships between commit handlers, notification listeners and the actual data.)

几个基本概念

  • Data Tree-All state-related data are modeled and represented as data tree, with possibility to address any element / subtree
    1. Operational Data Tree - Reported state of the system, published by the providers using MD-SAL. Represents a feedback loop for applications to observe state of the network / system.
    2. Configuration Data Tree - Intended state of the system or network, populated by consumers, which expresses their intention.
  • Instance Identifier
    1. Unique identifier of node / subtree in data tree, which provides unambiguous information, how to reference and retrieve node / subtree from conceptual data trees.
    2. Transaction - MD-SAL Data Broker provides transactional access to conceptual data trees representing configuration and operational state.

2 DataStore基于简单事务的读写操作

2.1 访问DataStore

 <reference id="dataBroker"
    interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
    odl:type="default" />

获取到OSGI的DataBroker服务接口

2.2 DataBroker服务接口

public interface DataBroker extends DataTreeChangeService {
   
   
    ReadOnlyTransaction newReadOnlyTransaction(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值