blob: 9439bd4b69d2c471a004d0578866cffd52da2040 [file] [log] [blame]
Tommy Carpenter53786ca2020-02-28 09:17:46 -05001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. SPDX-License-Identifier: CC-BY-4.0
3.. Copyright (C) 2020 AT&T Intellectual Property
4
Lott, Christopher (cl778h)2e1c18a2020-04-08 12:41:07 -04005Framework Overview
6==================
Tommy Carpenter53786ca2020-02-28 09:17:46 -05007
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -04008This package is a framework for writing RAN Intelligent Controller
9(RIC) Xapps in python. The framework reduces the amount of code
10required in an Xapp by providing common features needed by all
11Python-based Xapps including communication with the RIC message router
12(RMR) and the Shared Data Layer (SDL).
Tommy Carpenter53786ca2020-02-28 09:17:46 -050013
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040014The framework was designed to suport many types of Xapps, including
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -040015applications that are purely reactive to RMR messages, and general
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040016applications that initiate actions according to other criteria.
Tommy Carpenter53786ca2020-02-28 09:17:46 -050017
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -040018For complete documentation see the ReadTheDocs site for
19`xapp-frame-py <https://docs.o-ran-sc.org/projects/o-ran-sc-ric-plt-xapp-frame-py>`_.
20
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040021Reactive Xapps
22--------------
23
24A reactive Xapp acts on messages that are delivered (pushed) via RMR.
25The Xapp only takes action upon receipt of an RMR message. The Xapp
26never takes action at another time.
27
28This type of application is constructed by creating callback functions
29and registering them with the framework by message type. When an RMR
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -040030message arrives, the appropriate callback is invoked based on the
31message type. An Xapp may define and register a separate callback for
32each expected message type. Every Xapp must define a default callback
33function, which is invoked when a message arrives for which no
34type-specific callback was registered. An analogy of this is AWS
35Lambda: "execute this code every time an event comes in" (the code to
36execute can depend on the type of event).
Tommy Carpenter53786ca2020-02-28 09:17:46 -050037
Tommy Carpenter99a0b482020-03-03 10:21:24 -050038General Xapps
39-------------
Tommy Carpenter53786ca2020-02-28 09:17:46 -050040
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040041A general Xapp acts according to its own criteria, which may include
42receipt of RMR messages.
Tommy Carpenter53786ca2020-02-28 09:17:46 -050043
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -040044This type of application is constructed by creating a single function
45that is invoked by the framework after initialization. Typically that
46function contains a `while (something)` event loop. When the function
47returns, the Xapp stops. In this usage, the Xapp must fetch its own
48data, either from RMR, SDL or other source. The framework does less
49work for a general application compared to a reactive application; the
50framework only sets up an RMR thread and an SDL connection before
51invoking the client-provided function.
Tommy Carpenter53786ca2020-02-28 09:17:46 -050052
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040053Threading in the Framework
54--------------------------
55
56RMR interactions are processed in a thread started by the framework.
57This implementation detail is documented here for transparency, but
58most users will not have to worry about this.
59
60In both types of Xapp, the framework launches a separate thread whose
61only job is to read from RMR and deposit all messages (and their
62summaries) into a thread-safe queue. When the client Xapp reads from
63RMR using the framework (this read is done by the framework itself in
64the RMR Xapp, but by the client in a general Xapp), the read is done
65from the framework-managed queue. The framework is implemented this
66way so that a long-running client function (e.g., consume) will not
67block RMR reads. This is important because RMR is *not* a persistent
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -040068message bus; if an RMR client does not read fast enough, messages can
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040069be lost. So in this framework the client code is not in the same
70thread as the RMR reads, to ensure that long-running client code will
71not cause message loss.
72
73In the case of RMR Xapps, there are currently 3 potential threads; the
74thread that reads from RMR directly, and the user can optionally have
75the RMR queue read run in a thread, returning execution back to the
76user thread. The default is only two threads however, where `.run`
77does not return back execution and the user code is finished at that
78point.
Tommy Carpenter1c9ce6b2020-03-13 09:36:36 -040079
Tommy Carpenter09894e32020-04-02 19:45:19 -040080Healthchecks
81------------
Tommy Carpenter09894e32020-04-02 19:45:19 -040082
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040083The framework provides a default RMR healthcheck probe handler for
84reactive Xapps. When an RMR healthcheck message arrives, this handler
85checks that the RMR thread is healthy (of course the Xapp cannot even
86reply if the thread is not healthy!), and that the SDL connection is
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -040087healthy. The handler responds accordingly via RMR. The Xapp can
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040088override this probe handler by registering a new callback for the
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -040089healthcheck message type.
Tommy Carpenter09894e32020-04-02 19:45:19 -040090
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040091The framework provides no healthcheck handler for general Xapps. Those
92applications must handle healthcheck probe messages appropriately when
93they read their RMR mailboxes.
94
95There is no http service in the framework, so there is no support for
96HTTP-based healthcheck probes, such as what a deployment manager like
97Kubernetes may use.
Tommy Carpenterf9cd5cc2020-03-09 13:46:37 -040098
Tommy Carpenter53786ca2020-02-28 09:17:46 -050099Examples
100--------
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -0400101
102Two sample Xapps using this framework are provided in the `examples`
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -0400103directory of the
104`git repository <https://gerrit.o-ran-sc.org/r/gitweb?p=ric-plt/xapp-frame.git;a=tree>`_.
105The first, `ping`, is a general Xapp
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -0400106that defines a main function that reads its RMR mailbox in addition to
107other work. The second, `pong`, is a reactive Xapp that only takes
108action when a message is received.
109
110To run a demonstration, build the Docker images for both examples
111using the supplied Dockerfiles. Then start the Pong container (the
112listener) followed by the Ping container (the sender). The Ping
113application sends a message, the pong application receives the message
114and use RMR's return-to-sender feature to reply. Ping then reads its
115own mailbox and demonstrates other functionality.