blob: eed350ab52a2eea2e97c53bb573ed23ca05017bf [file] [log] [blame]
ramverma3b71c972019-07-10 11:25:37 +00001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3
4
5APEX User Manual
6****************
7
8.. contents::
9 :depth: 3
10
waynedunicane5430c12021-03-31 11:06:56 +010011Installation of Apex
12^^^^^^^^^^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +000013
14Requirements
15------------
16
17 .. container:: paragraph
18
19 APEX is 100% written in Java and runs on any platform
20 that supports a JVM, e.g. Windows, Unix, Cygwin. Some
21 APEX applications (such as the monitoring application)
22 come as web archives, they do require a war-capable web
23 server installed.
24
25Installation Requirements
26#########################
27
28 .. container:: ulist
29
30 - Downloaded distribution: JAVA runtime environment
liamfallon3e524ba2020-07-02 15:32:26 +010031 (JRE, Java 11 or later, APEX is tested with the
32 OpenJDK Java)
ramverma3b71c972019-07-10 11:25:37 +000033
34 - Building from source: JAVA development kit (JDK,
liamfallon3e524ba2020-07-02 15:32:26 +010035 Java 11 or later, APEX is tested with the OpenJDK
ramverma3b71c972019-07-10 11:25:37 +000036 Java)
37
38 - A web archive capable webserver, for instance for
39 the monitoring application
40
41 .. container:: ulist
42
43 - for instance `Apache
44 Tomcat <https://tomcat.apache.org/>`__
45
46 - Sufficient rights to install APEX on the system
47
48 - Installation tools depending on the installation
49 method used:
50
51 .. container:: ulist
52
53 - ZIP to extract from a ZIP distribution
54
55 .. container:: ulist
56
57 - Windows for instance
58 `7Zip <http://www.7-zip.org/>`__
59
60 - TAR and GZ to extract from that TAR.GZ
61 distribution
62
63 .. container:: ulist
64
65 - Windows for instance
66 `7Zip <http://www.7-zip.org/>`__
67
ramverma3b71c972019-07-10 11:25:37 +000068 - DPKG to install from the DEB distribution
69
70 .. container:: ulist
71
72 - Install: ``sudo apt-get install dpkg``
73
74Feature Requirements
75####################
76
77 .. container:: paragraph
78
79 APEX supports a number of features that require extra
80 software being installed.
81
82 .. container:: ulist
83
84 - `Apache Kafka <https://kafka.apache.org/>`__ to
85 connect APEX to a Kafka message bus
86
87 - `Hazelcast <https://hazelcast.com/>`__ to use
88 distributed hash maps for context
89
90 - `Infinispan <http://infinispan.org/>`__ for
91 distributed context and persistence
92
93 - `Docker <https://www.docker.com/>`__ to run APEX
94 inside a Docker container
95
96Build (Install from Source) Requirements
97########################################
98
99 .. container:: paragraph
100
101 Installation from source requires a few development
102 tools
103
104 .. container:: ulist
105
106 - GIT to retrieve the source code
107
108 - Java SDK, Java version 8 or later
109
110 - Apache Maven 3 (the APEX build environment)
111
112Get the APEX Source Code
113------------------------
114
115 .. container:: paragraph
116
117 The first APEX source code was hosted on Github in
118 January 2018. By the end of 2018, APEX was added as a
119 project in the ONAP Policy Framework, released later in
120 the ONAP Casablanca release.
121
122 .. container:: paragraph
123
124 The APEX source code is hosted in ONAP as project APEX.
125 The current stable version is in the master branch.
126 Simply clone the master branch from ONAP using HTTPS.
127
128 .. container:: listingblock
129
130 .. container:: content
131
ramverma760cce92019-07-11 12:57:49 +0000132 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000133 :number-lines:
134
135 git clone https://gerrit.onap.org/r/policy/apex-pdp
136
137Build APEX
138----------
139
140 .. container:: paragraph
141
142 The examples in this document assume that the APEX source
143 repositories are cloned to:
144
145 .. container:: ulist
146
147 - Unix, Cygwin: ``/usr/local/src/apex-pdp``
148
149 - Windows: ``C:\dev\apex-pdp``
150
151 - Cygwin: ``/cygdrive/c/dev/apex-pdp``
152
ramverma760cce92019-07-11 12:57:49 +0000153 .. important::
ramverma3b71c972019-07-10 11:25:37 +0000154 A Build requires ONAP Nexus
ramverma760cce92019-07-11 12:57:49 +0000155 APEX has a dependency to ONAP parent projects. You might need to adjust your Maven M2 settings. The most current
156 settings can be found in the ONAP oparent repo: `Settings <https://git.onap.org/oparent/plain/settings.xml>`__.
ramverma3b71c972019-07-10 11:25:37 +0000157
ramverma760cce92019-07-11 12:57:49 +0000158 .. important::
159 A Build needs Space
160 Building APEX requires approximately 2-3 GB of hard disc space, 1 GB for the actual build with full
161 distribution and 1-2 GB for the downloaded dependencies
ramverma3b71c972019-07-10 11:25:37 +0000162
ramverma760cce92019-07-11 12:57:49 +0000163 .. important::
ramverma3b71c972019-07-10 11:25:37 +0000164 A Build requires Internet (for first build)
ramverma760cce92019-07-11 12:57:49 +0000165 During the build, several (a lot) of Maven dependencies will be downloaded and stored in the configured local Maven
166 repository. The first standard build (and any first specific build) requires Internet access to download those
167 dependencies.
ramverma3b71c972019-07-10 11:25:37 +0000168
ramverma3b71c972019-07-10 11:25:37 +0000169 .. container:: paragraph
170
171 Use Maven to for a standard build without any tests.
172
173 +-------------------------------------------------------+--------------------------------------------------------+
174 | Unix, Cygwin | Windows |
175 +=======================================================+========================================================+
176 | .. container:: | .. container:: |
177 | | |
178 | .. container:: content | .. container:: content |
179 | | |
180 | .. code:: | .. code:: |
181 | :number-lines: | :number-lines: |
182 | | |
183 | # cd /usr/local/src/apex-pdp | >c: |
liamfallon1540e472019-11-28 15:14:07 +0000184 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
185 | | >mvn clean install -Pdocker -DskipTests |
ramverma3b71c972019-07-10 11:25:37 +0000186 +-------------------------------------------------------+--------------------------------------------------------+
187
188.. container:: paragraph
189
190 The build takes 2-3 minutes on a standard development laptop. It
191 should run through without errors, but with a lot of messages from
192 the build process.
193
194.. container:: paragraph
195
196 When Maven is finished with the build, the final screen should look
197 similar to this (omitting some ``success`` lines):
198
199.. container:: listingblock
200
201 .. container:: content
202
ramverma760cce92019-07-11 12:57:49 +0000203 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000204 :number-lines:
205
206 [INFO] tools .............................................. SUCCESS [ 0.248 s]
207 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
208 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
209 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
210 [INFO] packages ........................................... SUCCESS [ 0.336 s]
211 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
212 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
213 [INFO] ------------------------------------------------------------------------
214 [INFO] BUILD SUCCESS
215 [INFO] ------------------------------------------------------------------------
216 [INFO] Total time: 03:43 min
217 [INFO] Finished at: 2018-09-03T11:56:01+01:00
218 [INFO] ------------------------------------------------------------------------
219
220.. container:: paragraph
221
222 The build will have created all artifacts required for an APEX
223 installation. The following example show how to change to the target
224 directory and how it should look like.
225
liamfallon40f09542021-10-11 11:57:31 +0100226+---------------------------------------------------------------------------------------------------------------------+
227| Unix, Cygwin |
228+=====================================================================================================================+
229| .. container:: content |
230| |
231| .. container:: listingblock |
232| |
233| .. container:: content |
234| |
235| .. code:: |
236| :number-lines: |
237| |
238| -rwxrwx---+ 1 esvevan Domain Users 772 Sep 3 11:55 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes* |
239| -rwxrwx---+ 1 esvevan Domain Users 146328082 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT.deb* |
240| -rwxrwx---+ 1 esvevan Domain Users 15633 Sep 3 11:54 apex-pdp-package-full-2.0.0-SNAPSHOT.jar* |
241| -rwxrwx---+ 1 esvevan Domain Users 146296819 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz* |
242| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 archive-tmp/ |
243| -rwxrwx---+ 1 esvevan Domain Users 89 Sep 3 11:54 checkstyle-cachefile* |
244| -rwxrwx---+ 1 esvevan Domain Users 10621 Sep 3 11:54 checkstyle-checker.xml* |
245| -rwxrwx---+ 1 esvevan Domain Users 584 Sep 3 11:54 checkstyle-header.txt* |
246| -rwxrwx---+ 1 esvevan Domain Users 86 Sep 3 11:54 checkstyle-result.xml* |
247| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 classes/ |
248| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 dependency-maven-plugin-markers/ |
249| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 etc/ |
250| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 examples/ |
251| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:55 install_hierarchy/ |
252| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 maven-archiver/ |
253+---------------------------------------------------------------------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000254
liamfallon40f09542021-10-11 11:57:31 +0100255+----------------------------------------------------------------------------------------------+
256| Windows |
257+==============================================================================================+
258| .. container:: |
259| |
260| .. container:: listingblock |
261| |
262| .. container:: content |
263| |
264| .. code:: |
265| :number-lines: |
266| |
267| 03/09/2018 11:55 <DIR> . |
268| 03/09/2018 11:55 <DIR> .. |
269| 03/09/2018 11:55 146,296,819 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz |
270| 03/09/2018 11:55 146,328,082 apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
271| 03/09/2018 11:54 15,633 apex-pdp-package-full-2.0.0-SNAPSHOT.jar |
272| 03/09/2018 11:55 772 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes |
273| 03/09/2018 11:54 <DIR> archive-tmp |
274| 03/09/2018 11:54 89 checkstyle-cachefile |
275| 03/09/2018 11:54 10,621 checkstyle-checker.xml |
276| 03/09/2018 11:54 584 checkstyle-header.txt |
277| 03/09/2018 11:54 86 checkstyle-result.xml |
278| 03/09/2018 11:54 <DIR> classes |
279| 03/09/2018 11:54 <DIR> dependency-maven-plugin-markers |
280| 03/09/2018 11:54 <DIR> etc |
281| 03/09/2018 11:54 <DIR> examples |
282| 03/09/2018 11:55 <DIR> install_hierarchy |
283| 03/09/2018 11:54 <DIR> maven-archiver |
284| 8 File(s) 292,652,686 bytes |
285| 9 Dir(s) 14,138,720,256 bytes free |
286+----------------------------------------------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000287
288Install APEX
289------------
290
291 .. container:: paragraph
292
293 APEX can be installed in different ways:
294
295 .. container:: ulist
296
liamfallon3e524ba2020-07-02 15:32:26 +0100297 - Unix: automatically using ``dpkg`` from
ramverma3b71c972019-07-10 11:25:37 +0000298 ``.deb`` archive
299
300 - Windows, Unix, Cygwin: manually from a ``.tar.gz`` archive
301
302 - Windows, Unix, Cygwin: build from source using Maven, then
303 install manually
304
liamfallon3e524ba2020-07-02 15:32:26 +0100305Install with DPKG
306#################
ramverma3b71c972019-07-10 11:25:37 +0000307
308 .. container:: paragraph
309
liamfallon3e524ba2020-07-02 15:32:26 +0100310 You can get the APEX debian package from the
311 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
312
ramverma3b71c972019-07-10 11:25:37 +0000313 The install distributions of APEX automatically install the
314 system. The installation directory is
315 ``/opt/app/policy/apex-pdp``. Log files are located in
316 ``/var/log/onap/policy/apex-pdp``. The latest APEX version will
317 be available as ``/opt/app/policy/apex-pdp/apex-pdp``.
318
319 .. container:: paragraph
320
321 For the installation, a new user ``apexuser`` and a new group
322 ``apexuser`` will be created. This user owns the installation
323 directories and the log file location. The user is also used by
324 the standard APEX start scripts to run APEX with this user’s
325 permissions.
326
liamfallon40f09542021-10-11 11:57:31 +0100327+-------------------------------------------------------------------------------+
328| DPKG Installation |
329+===============================================================================+
330| .. container:: |
331| |
332| .. container:: listingblock |
333| |
334| .. container:: content |
335| |
336| .. code:: |
337| :number-lines: |
338| |
339| # sudo dpkg -i apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
340| Selecting previously unselected package apex-uservice. |
341| (Reading database ... 288458 files and directories currently installed.) |
342| Preparing to unpack apex-pdp-package-full-2.0.0-SNAPSHOT.deb ... |
343| ********************preinst******************* |
344| arguments install |
345| ********************************************** |
346| creating group apexuser . . . |
347| creating user apexuser . . . |
348| Unpacking apex-uservice (2.0.0-SNAPSHOT) ... |
349| Setting up apex-uservice (2.0.0-SNAPSHOT) ... |
350| ********************postinst**************** |
351| arguments configure |
352| *********************************************** |
353+-------------------------------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000354
355.. container:: paragraph
356
357 Once the installation is finished, APEX is fully installed and ready
358 to run.
359
360Install Manually from Archive (Unix, Cygwin)
361############################################
362
363 .. container:: paragraph
364
liamfallon3e524ba2020-07-02 15:32:26 +0100365 You can download a ``tar.gz`` archive from the
366 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
367
368 Create a directory where APEX
ramverma3b71c972019-07-10 11:25:37 +0000369 should be installed. Extract the ``tar`` archive. The following
370 example shows how to install APEX in ``/opt/apex`` and create a
371 link to ``/opt/apex/apex`` for the most recent installation.
372
373 .. container:: listingblock
374
375 .. container:: content
376
ramverma760cce92019-07-11 12:57:49 +0000377 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000378 :number-lines:
379
380 # cd /opt
381 # mkdir apex
382 # cd apex
383 # mkdir apex-full-2.0.0-SNAPSHOT
384 # tar xvfz ~/Downloads/apex-pdp-package-full-2.0.0-SNAPSHOT.tar.gz -C apex-full-2.0.0-SNAPSHOT
385 # ln -s apex apex-pdp-package-full-2.0.0-SNAPSHOT
386
387Install Manually from Archive (Windows, 7Zip, GUI)
388##################################################
389
390 .. container:: paragraph
391
liamfallon3e524ba2020-07-02 15:32:26 +0100392 You can download a ``tar.gz`` archive from the
393 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
394
395 Copy the ``tar.gz`` file into the install
ramverma3b71c972019-07-10 11:25:37 +0000396 folder (in this example ``C:\apex``). Assuming you are using 7Zip,
397 right click on the file and extract the ``tar`` archive. Note: the
398 screenshots might show an older version than you have.
399
liamfallon40f09542021-10-11 11:57:31 +0100400 Now, right-click on the new created TAR file and extract the actual
401 APEX distribution. Inside the new APEX folder you will see the main directories: ``bin``,
ramverma3b71c972019-07-10 11:25:37 +0000402 ``etc``, ``examples``, ``lib``, and ``war``
403
404 .. container:: paragraph
405
406 Once extracted, please rename the created folder to
407 ``apex-full-2.0.0-SNAPSHOT``. This will keep the directory name in
408 line with the rest of this documentation.
409
410Install Manually from Archive (Windows, 7Zip, CMD)
411##################################################
412
413 .. container:: paragraph
414
liamfallon3e524ba2020-07-02 15:32:26 +0100415 You can download a ``tar.gz`` archive from the
416 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
417
418 Copy the ``tar.gz`` file into the install
ramverma3b71c972019-07-10 11:25:37 +0000419 folder (in this example ``C:\apex``). Start ``cmd``, for instance
420 typing ``Windows+R`` and then ``cmd`` in the dialog. Assuming
421 ``7Zip`` is installed in the standard folder, simply run the
422 following commands (for APEX version 2.0.0-SNAPSHOT full
423 distribution)
424
425 .. container:: listingblock
426
427 .. container:: content
428
ramverma760cce92019-07-11 12:57:49 +0000429 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000430 :number-lines:
431
432 >c:
433 >cd \apex
434 >"\Program Files\7-Zip\7z.exe" x apex-pdp-package-full-2.0.0-SNAPSHOT.tar.gz -so | "\Program Files\7-Zip\7z.exe" x -aoa -si -ttar -o"apex-full-2.0.0-SNAPSHOT"
435
436.. container:: paragraph
437
438 APEX is now installed in the folder
439 ``C:\apex\apex-full-2.0.0-SNAPSHOT``.
440
441Build from Source
442-----------------
443
444Build and Install Manually (Unix, Windows, Cygwin)
445##################################################
446
447 .. container:: paragraph
448
449 Clone the APEX GIT repositories into a directory. Go to that
450 directory. Use Maven to build APEX (all details on building
451 APEX from source can be found in *APEX HowTo: Build*). Install
452 from the created artifacts (``rpm``, ``deb``, ``tar.gz``, or
453 copying manually).
454
ramverma3b71c972019-07-10 11:25:37 +0000455 .. container:: paragraph
456
457 The following example shows how to build the APEX system,
458 without tests (``-DskipTests``) to safe some time. It assumes
459 that the APX GIT repositories are cloned to:
460
461 .. container:: ulist
462
463 - Unix, Cygwin: ``/usr/local/src/apex``
464
465 - Windows: ``C:\dev\apex``
466
ramverma760cce92019-07-11 12:57:49 +0000467 +-------------------------------------------------------+--------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000468 | Unix, Cygwin | Windows |
469 +=======================================================+========================================================+
470 | .. container:: | .. container:: |
471 | | |
472 | .. container:: content | .. container:: content |
473 | | |
474 | .. code:: | .. code:: |
475 | :number-lines: | :number-lines: |
476 | | |
477 | # cd /usr/local/src/apex | >c: |
liamfallon1540e472019-11-28 15:14:07 +0000478 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
479 | | >mvn clean install -Pdocker -DskipTests |
ramverma3b71c972019-07-10 11:25:37 +0000480 +-------------------------------------------------------+--------------------------------------------------------+
481
482.. container:: paragraph
483
484 The build takes about 2 minutes without test and about 4-5 minutes
485 with tests on a standard development laptop. It should run through
486 without errors, but with a lot of messages from the build process. If
487 build with tests (i.e. without ``-DskipTests``), there will be error
488 messages and stack trace prints from some tests. This is normal, as
489 long as the build finishes successful.
490
491.. container:: paragraph
492
493 When Maven is finished with the build, the final screen should look
494 similar to this (omitting some ``success`` lines):
495
496.. container:: listingblock
497
498 .. container:: content
499
ramverma760cce92019-07-11 12:57:49 +0000500 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000501 :number-lines:
502
503 [INFO] tools .............................................. SUCCESS [ 0.248 s]
504 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
505 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
506 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
507 [INFO] packages ........................................... SUCCESS [ 0.336 s]
508 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
509 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
510 [INFO] ------------------------------------------------------------------------
511 [INFO] BUILD SUCCESS
512 [INFO] ------------------------------------------------------------------------
513 [INFO] Total time: 03:43 min
514 [INFO] Finished at: 2018-09-03T11:56:01+01:00
515 [INFO] ------------------------------------------------------------------------
516
517.. container:: paragraph
518
519 The build will have created all artifacts required for an APEX
520 installation. The following example show how to change to the target
521 directory and how it should look like.
522
liamfallon40f09542021-10-11 11:57:31 +0100523+--------------------------------------------------------------------------------------------------------------------+
524| Unix, Cygwin |
525+====================================================================================================================+
526| .. container:: |
527| |
528| .. container:: listingblock |
529| |
530| .. code:: |
531| :number-lines: |
532| |
533| # cd packages/apex-pdp-package-full/target |
534| # ls -l |
535| -rwxrwx---+ 1 esvevan Domain Users 772 Sep 3 11:55 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes* |
536| -rwxrwx---+ 1 esvevan Domain Users 146328082 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT.deb* |
537| -rwxrwx---+ 1 esvevan Domain Users 15633 Sep 3 11:54 apex-pdp-package-full-2.0.0-SNAPSHOT.jar* |
538| -rwxrwx---+ 1 esvevan Domain Users 146296819 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz* |
539| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 archive-tmp/ |
540| -rwxrwx---+ 1 esvevan Domain Users 89 Sep 3 11:54 checkstyle-cachefile* |
541| -rwxrwx---+ 1 esvevan Domain Users 10621 Sep 3 11:54 checkstyle-checker.xml* |
542| -rwxrwx---+ 1 esvevan Domain Users 584 Sep 3 11:54 checkstyle-header.txt* |
543| -rwxrwx---+ 1 esvevan Domain Users 86 Sep 3 11:54 checkstyle-result.xml* |
544| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 classes/ |
545| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 dependency-maven-plugin-markers/ |
546| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 etc/ |
547| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 examples/ |
548| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:55 install_hierarchy/ |
549| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 maven-archiver/ |
550+--------------------------------------------------------------------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000551
liamfallon40f09542021-10-11 11:57:31 +0100552+---------------------------------------------------------------------------------------------+
553| Windows |
554+=============================================================================================+
555| .. container:: |
556| |
557| .. container:: listingblock |
558| |
559| .. code:: |
560| :number-lines: |
561| |
562| >cd packages\apex-pdp-package-full\target |
563| >dir |
564| 03/09/2018 11:55 <DIR> . |
565| 03/09/2018 11:55 <DIR> .. |
566| 03/09/2018 11:55 146,296,819 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz |
567| 03/09/2018 11:55 146,328,082 apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
568| 03/09/2018 11:54 15,633 apex-pdp-package-full-2.0.0-SNAPSHOT.jar |
569| 03/09/2018 11:55 772 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes |
570| 03/09/2018 11:54 <DIR> archive-tmp |
571| 03/09/2018 11:54 89 checkstyle-cachefile |
572| 03/09/2018 11:54 10,621 checkstyle-checker.xml |
573| 03/09/2018 11:54 584 checkstyle-header.txt |
574| 03/09/2018 11:54 86 checkstyle-result.xml |
575| 03/09/2018 11:54 <DIR> classes |
576| 03/09/2018 11:54 <DIR> dependency-maven-plugin-markers |
577| 03/09/2018 11:54 <DIR> etc |
578| 03/09/2018 11:54 <DIR> examples |
579| 03/09/2018 11:55 <DIR> install_hierarchy |
580| 03/09/2018 11:54 <DIR> maven-archiver |
581| 8 File(s) 292,652,686 bytes |
582| 9 Dir(s) 14,138,720,256 bytes free |
583+---------------------------------------------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000584
585.. container:: paragraph
586
587 Now, take the ``.deb`` or the ``.tar.gz`` file and install APEX.
588 Alternatively, copy the content of the folder ``install_hierarchy``
589 to your APEX directory.
590
591Installation Layout
592-------------------
593
594 .. container:: paragraph
595
596 A full installation of APEX comes with the following layout.
597
598 .. container:: listingblock
599
600 .. container:: content
601
liamfallon40f09542021-10-11 11:57:31 +0100602 ::
ramverma3b71c972019-07-10 11:25:37 +0000603
604 $APEX_HOME
605 ├───bin (1)
606 ├───etc (2)
607 │ ├───editor
608 │ ├───hazelcast
609 │ ├───infinispan
610 │ └───META-INF
611 ├───examples (3)
612 │ ├───config (4)
613 │ ├───docker (5)
614 │ ├───events (6)
615 │ ├───html (7)
616 │ ├───models (8)
617 │ └───scripts (9)
618 ├───lib (10)
619 │ └───applications (11)
620 └───war (12)
621
622 .. container:: colist arabic
623
624 +-----------------------------------+-----------------------------------+
625 | **1** | binaries, mainly scripts (bash |
626 | | and bat) to start the APEX engine |
627 | | and applications |
628 +-----------------------------------+-----------------------------------+
629 | **2** | configuration files, such as |
630 | | logback (logging) and third party |
631 | | library configurations |
632 +-----------------------------------+-----------------------------------+
633 | **3** | example policy models to get |
634 | | started |
635 +-----------------------------------+-----------------------------------+
636 | **4** | configurations for the examples |
637 | | (with sub directories for |
638 | | individual examples) |
639 +-----------------------------------+-----------------------------------+
640 | **5** | Docker files and additional |
641 | | Docker instructions for the |
642 | | exampples |
643 +-----------------------------------+-----------------------------------+
644 | **6** | example events for the examples |
645 | | (with sub directories for |
646 | | individual examples) |
647 +-----------------------------------+-----------------------------------+
648 | **7** | HTML files for some examples, |
649 | | e.g. the Decisionmaker example |
650 +-----------------------------------+-----------------------------------+
651 | **8** | the policy models, generated for |
652 | | each example (with sub |
653 | | directories for individual |
654 | | examples) |
655 +-----------------------------------+-----------------------------------+
656 | **9** | additional scripts for the |
657 | | examples (with sub directories |
658 | | for individual examples) |
659 +-----------------------------------+-----------------------------------+
660 | **10** | the library folder with all Java |
661 | | JAR files |
662 +-----------------------------------+-----------------------------------+
663 | **11** | applications, also known as jar |
664 | | with dependencies (or fat jars), |
665 | | individually deployable |
666 +-----------------------------------+-----------------------------------+
667 | **12** | WAR files for web applications |
668 +-----------------------------------+-----------------------------------+
669
670System Configuration
671--------------------
672
673 .. container:: paragraph
674
675 Once APEX is installed, a few configurations need to be done:
676
677 .. container:: ulist
678
679 - Create an APEX user and an APEX group (optional, if not
680 installed using RPM and DPKG)
681
682 - Create environment settings for ``APEX_HOME`` and
683 ``APEX_USER``, required by the start scripts
684
685 - Change settings of the logging framework (optional)
686
687 - Create directories for logging, required (execution might fail
688 if directories do not exist or cannot be created)
689
690APEX User and Group
691###################
692
693 .. container:: paragraph
694
695 On smaller installations and test systems, APEX can run as any
696 user or group.
697
698 .. container:: paragraph
699
700 However, if APEX is installed in production, we strongly
701 recommend you set up a dedicated user for running APEX. This
702 will isolate the execution of APEX to that user. We recommend
703 you use the userid ``apexuser`` but you may use any user you
704 choose.
705
706 .. container:: paragraph
707
708 The following example, for UNIX, creates a group called
709 ``apexuser``, an APEX user called ``apexuser``, adds the group
710 to the user, and changes ownership of the APEX installation to
711 the user. Substitute ``<apex-dir>`` with the directory where
712 APEX is installed.
713
714 .. container:: listingblock
715
716 .. container:: content
717
ramverma760cce92019-07-11 12:57:49 +0000718 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000719 :number-lines:
720
721 # sudo groupadd apexuser
722 # sudo useradd -g apexuser apexuser
723 # sudo chown -R apexuser:apexuser <apex-dir>
724
725.. container:: paragraph
726
727 For other operating systems please consult your manual or system
728 administrator.
729
730Environment Settings: APEX_HOME and APEX_USER
731#############################################
732
733 .. container:: paragraph
734
735 The provided start scripts for APEX require two environment
736 variables being set:
737
738 .. container:: ulist
739
740 - ``APEX_USER`` with the user under whos name and permission APEX
741 should be started (Unix only)
742
743 - ``APEX_HOME`` with the directory where APEX is installed (Unix,
744 Windows, Cygwin)
745
746 .. container:: paragraph
747
748 The first row in the following table shows how to set these
749 environment variables temporary (assuming the user is
750 ``apexuser``). The second row shows how to verify the settings.
751 The last row explains how to set those variables permanently.
752
753 +------------------------------------------------+---------------------------------------------------------+
754 | Unix, Cygwin (bash/tcsh) | Windows |
755 +================================================+=========================================================+
756 | .. container:: | .. container:: |
757 | | |
758 | .. container:: content | .. container:: content |
759 | | |
760 | .. code:: | .. code:: |
761 | :number-lines: | :number-lines: |
762 | | |
763 | # export APEX_USER=apexuser | >set APEX_HOME=C:\apex\apex-full-2.0.0-SNAPSHOT |
764 | # cd /opt/app/policy/apex-pdp | |
ramverma760cce92019-07-11 12:57:49 +0000765 | # export APEX_HOME=`pwd` | |
ramverma3b71c972019-07-10 11:25:37 +0000766 | | |
767 +------------------------------------------------+ |
768 | .. container:: | |
769 | | |
770 | .. container:: content | |
771 | | |
ramverma760cce92019-07-11 12:57:49 +0000772 | .. code::tcsh | |
ramverma3b71c972019-07-10 11:25:37 +0000773 | :number-lines: | |
774 | | |
775 | # setenv APEX_USER apexuser | |
776 | # cd /opt/app/policy/apex-pdp | |
ramverma760cce92019-07-11 12:57:49 +0000777 | # setenv APEX_HOME `pwd` | |
ramverma3b71c972019-07-10 11:25:37 +0000778 | | |
779 +------------------------------------------------+---------------------------------------------------------+
780 | .. container:: | .. container:: |
781 | | |
782 | .. container:: content | .. container:: content |
783 | | |
784 | .. code:: | .. code:: |
785 | :number-lines: | :number-lines: |
786 | | |
787 | # env | grep APEX | >set APEX_HOME |
788 | # APEX_USER=apexuser | APEX_HOME=\apex\apex-full-2.0.0-SNAPSHOT |
ramverma760cce92019-07-11 12:57:49 +0000789 | # APEX_HOME=/opt/app/policy/apex-pdp | |
ramverma3b71c972019-07-10 11:25:37 +0000790 | | |
791 +------------------------------------------------+---------------------------------------------------------+
792
793Making Environment Settings Permanent (Unix, Cygwin)
794====================================================
795
796 .. container:: paragraph
797
798 For a per-user setting, edit the a user’s ``bash`` or ``tcsh``
799 settings in ``~/.bashrc`` or ``~/.tcshrc``. For system-wide
800 settings, edit ``/etc/profiles`` (requires permissions).
801
802Making Environment Settings Permanent (Windows)
803===============================================
804
805 .. container:: paragraph
806
807 On Windows 7 do
808
809 .. container:: ulist
810
811 - Click on the **Start** Menu
812
813 - Right click on **Computer**
814
815 - Select **Properties**
816
817 .. container:: paragraph
818
819 On Windows 8/10 do
820
821 .. container:: ulist
822
823 - Click on the **Start** Menu
824
825 - Select **System**
826
827 .. container:: paragraph
828
829 Then do the following
830
831 .. container:: ulist
832
833 - Select **Advanced System Settings**
834
835 - On the **Advanced** tab, click the **Environment Variables**
836 button
837
838 - Edit an existing variable, or create a new System variable:
839 'Variable name'="APEX_HOME", 'Variable
840 value'="C:\apex\apex-full-2.0.0-SNAPSHOT"
841
842 .. container:: paragraph
843
844 For the settings to take effect, an application needs to be
845 restarted (e.g. any open ``cmd`` window).
846
847Edit the APEX Logging Settings
848##############################
849
850 .. container:: paragraph
851
852 Configure the APEX logging settings to your requirements, for
853 instance:
854
855 .. container:: ulist
856
857 - change the directory where logs are written to, or
858
859 - change the log levels
860
861 .. container:: paragraph
862
863 Edit the file ``$APEX_HOME/etc/logback.xml`` for any required
864 changes. To change the log directory change the line
865
866 .. container:: paragraph
867
liamfallon1540e472019-11-28 15:14:07 +0000868 ``<property name="logDir" value="/var/log/onap/policy/apex-pdp/" />``
ramverma3b71c972019-07-10 11:25:37 +0000869
870 .. container:: paragraph
871
872 to
873
874 .. container:: paragraph
875
liamfallon1540e472019-11-28 15:14:07 +0000876 ``<property name="logDir" value="/PATH/TO/LOG/DIRECTORY/" />``
ramverma3b71c972019-07-10 11:25:37 +0000877
878 .. container:: paragraph
879
880 On Windows, it is recommended to change the log directory to:
881
882 .. container:: paragraph
883
liamfallon1540e472019-11-28 15:14:07 +0000884 ``<property name="logDir" value="C:/apex/apex-full-2.0.0-SNAPSHOT/logs" />``
ramverma3b71c972019-07-10 11:25:37 +0000885
886 .. container:: paragraph
887
888 Note: Be careful about when to use ``\`` vs. ``/`` as the path
889 separator!
890
891Create Directories for Logging
892##############################
893
894 .. container:: paragraph
895
896 Make sure that the log directory exists. This is important when
897 APEX was installed manually or when the log directory was changed
898 in the settings (see above).
899
liamfallon9c7bd672019-10-03 13:42:08 +0100900 +-----------------------------------------------------------------------+-------------------------------------------------------+
901 | Unix, Cygwin | Windows |
902 +=======================================================================+=======================================================+
903 | .. container:: | .. container:: |
904 | | |
905 | .. container:: content | .. container:: content |
906 | | |
907 | .. code:: | .. code:: |
908 | :number-lines: | :number-lines: |
909 | | |
910 | sudo mkdir -p /var/log/onap/policy/apex-pdp | >mkdir C:\apex\apex-full-2.0.0-SNAPSHOT\logs |
911 | sudo chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp | |
912 +-----------------------------------------------------------------------+-------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000913
914Verify the APEX Installation
915----------------------------
916
917 .. container:: paragraph
918
919 When APEX is installed and all settings are realized, the
920 installation can be verified.
921
922Verify Installation - run Engine
923################################
924
925 .. container:: paragraph
926
927 A simple verification of an APEX installation can be done by
a.sreekumarebd97932020-09-14 13:34:23 +0100928 simply starting the APEX engine without specifying a tosca policy. On
ramverma3b71c972019-07-10 11:25:37 +0000929 Unix (or Cygwin) start the engine using
liamfallonb621de42020-08-21 12:59:26 +0100930 ``$APEX_HOME/bin/apexApps.sh engine``. On Windows start the engine
931 using ``%APEX_HOME%\bin\apexApps.bat engine``. The engine will fail
ramverma3b71c972019-07-10 11:25:37 +0000932 to fully start. However, if the output looks similar to the
933 following line, the APEX installation is realized.
934
935 .. container:: listingblock
936
937 .. container:: content
938
ramverma760cce92019-07-11 12:57:49 +0000939 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000940 :number-lines:
941
942 Starting Apex service with parameters [] . . .
a.sreekumarebd97932020-09-14 13:34:23 +0100943 start of Apex service failed.
944 org.onap.policy.apex.model.basicmodel.concepts.ApexException: Arguments validation failed.
945 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:238)
946 at org.onap.policy.apex.service.engine.main.ApexMain.<init>(ApexMain.java:86)
947 at org.onap.policy.apex.service.engine.main.ApexMain.main(ApexMain.java:351)
948 Caused by: org.onap.policy.apex.model.basicmodel.concepts.ApexException: Tosca Policy file was not specified as an argument
949 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validateReadableFile(ApexCommandLineArguments.java:242)
950 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validate(ApexCommandLineArguments.java:172)
951 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:235)
952 ... 2 common frames omitted
ramverma3b71c972019-07-10 11:25:37 +0000953
954Verify Installation - run an Example
955####################################
956
957 .. container:: paragraph
958
959 A full APEX installation comes with several examples. Here, we can
960 fully verify the installation by running one of the examples.
961
962 .. container:: paragraph
963
964 We use the example called *SampleDomain* and configure the engine
965 to use standard in and standard out for events. Run the engine
966 with the provided configuration. Note: Cygwin executes scripts as
967 Unix scripts but runs Java as a Windows application, thus the
968 configuration file must be given as a Windows path.
969
liamfallon9c7bd672019-10-03 13:42:08 +0100970 .. container:: paragraph
971
972 On Unix/Linux flavoured platforms, give the commands below:
973
ramverma3b71c972019-07-10 11:25:37 +0000974 .. container:: listingblock
975
976 .. container:: content
977
aditya.puthuparambil9e67eb72020-04-30 15:59:43 +0100978 .. code::
liamfallon9c7bd672019-10-03 13:42:08 +0100979 :number-lines:
ramverma3b71c972019-07-10 11:25:37 +0000980
aditya.puthuparambil9e67eb72020-04-30 15:59:43 +0100981 sudo su - apexuser
982 export APEX_HOME <path to apex installation>
983 export APEX_USER apexuser
liamfallon9c7bd672019-10-03 13:42:08 +0100984
985 .. container:: paragraph
986
a.sreekumarebd97932020-09-14 13:34:23 +0100987 Create a Tosca Policy for the SampleDomain example using ApexCliToscaEditor
988 as explained in the section "The APEX CLI Tosca Editor". Assume the tosca policy name is SampleDomain_tosca.json.
989 You can then try to run apex using the ToscaPolicy.
liamfallon9c7bd672019-10-03 13:42:08 +0100990
991 .. container:: listingblock
992
993 .. container:: content
994
aditya.puthuparambil9e67eb72020-04-30 15:59:43 +0100995 .. code::
liamfallon9c7bd672019-10-03 13:42:08 +0100996 :number-lines:
997
a.sreekumarebd97932020-09-14 13:34:23 +0100998 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/examples/SampleDomain_tosca.json (1)
999 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\examples\SampleDomain_tosca.json(2)
ramverma3b71c972019-07-10 11:25:37 +00001000
1001.. container:: colist arabic
1002
1003 +-------+---------+
1004 | **1** | UNIX |
1005 +-------+---------+
liamfallonb621de42020-08-21 12:59:26 +01001006 | **2** | Windows |
ramverma3b71c972019-07-10 11:25:37 +00001007 +-------+---------+
1008
1009.. container:: paragraph
1010
liamfallon9c7bd672019-10-03 13:42:08 +01001011 The engine should start successfully. Assuming the logging levels are set to ``info`` in the built system, the output
1012 should look similar to this (last few lines)
ramverma3b71c972019-07-10 11:25:37 +00001013
1014.. container:: listingblock
1015
1016 .. container:: content
1017
ramverma760cce92019-07-11 12:57:49 +00001018 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001019 :number-lines:
1020
a.sreekumarebd97932020-09-14 13:34:23 +01001021 Starting Apex service with parameters [-p, /home/ubuntu/apex/SampleDomain_tosca.json] . . .
ramverma3b71c972019-07-10 11:25:37 +00001022 2018-09-05 15:16:42,800 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-0:0.0.1 .
1023 2018-09-05 15:16:42,804 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-1:0.0.1 .
1024 2018-09-05 15:16:42,804 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-2:0.0.1 .
1025 2018-09-05 15:16:42,805 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-3:0.0.1 .
1026 2018-09-05 15:16:42,805 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - APEX service created.
1027 2018-09-05 15:16:43,962 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging starting . . .
1028 2018-09-05 15:16:43,963 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging started
1029 2018-09-05 15:16:44,987 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-0:0.0.1
1030 2018-09-05 15:16:45,112 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-1:0.0.1
1031 2018-09-05 15:16:45,113 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-2:0.0.1
1032 2018-09-05 15:16:45,113 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-3:0.0.1
1033 2018-09-05 15:16:45,120 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Added the action listener to the engine
1034 Started Apex service
1035
1036.. container:: paragraph
1037
1038 Important are the last two line, stating that APEX has added the
1039 final action listener to the engine and that the engine is started.
1040
1041.. container:: paragraph
1042
1043 The engine is configured to read events from standard input and write
1044 produced events to standard output. The policy model is a very simple
1045 policy.
1046
1047.. container:: paragraph
1048
1049 The following table shows an input event in the left column and an
1050 output event in the right column. Past the input event into the
1051 console where APEX is running, and the output event should appear in
1052 the console. Pasting the input event multiple times will produce
1053 output events with different values.
1054
liamfallon40f09542021-10-11 11:57:31 +01001055+----------------------------------------------------------+----------------------------------------------------------+
1056| Input Event | Example Output Event |
1057+==========================================================+==========================================================+
1058| .. container:: | .. container:: |
1059| | |
1060| .. container:: content | .. container:: content |
1061| | |
1062| .. code:: | .. code:: |
1063| :number-lines: | :number-lines: |
1064| | |
1065| { | { |
1066| "nameSpace": "org.onap.policy.apex.sample.events", | "name": "Event0004", |
1067| "name": "Event0000", | "version": "0.0.1", |
1068| "version": "0.0.1", | "nameSpace": "org.onap.policy.apex.sample.events", |
1069| "source": "test", | "source": "Act", |
1070| "target": "apex", | "target": "Outside", |
1071| "TestSlogan": "Test slogan for External Event0", | "TestActCaseSelected": 2, |
1072| "TestMatchCase": 0, | "TestActStateTime": 1536157104627, |
1073| "TestTimestamp": 1469781869269, | "TestDecideCaseSelected": 0, |
1074| "TestTemperature": 9080.866 | "TestDecideStateTime": 1536157104625, |
1075| } | "TestEstablishCaseSelected": 0, |
1076| | "TestEstablishStateTime": 1536157104623, |
1077| | "TestMatchCase": 0, |
1078| | "TestMatchCaseSelected": 1, |
1079| | "TestMatchStateTime": 1536157104620, |
1080| | "TestSlogan": "Test slogan for External Event0", |
1081| | "TestTemperature": 9080.866, |
1082| | "TestTimestamp": 1469781869269 |
1083| | } |
1084+----------------------------------------------------------+----------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00001085
1086.. container:: paragraph
1087
1088 Terminate APEX by simply using ``CTRL+C`` in the console.
1089
liamfallon3e524ba2020-07-02 15:32:26 +01001090Verify a Full Installation - REST Client
ramverma3b71c972019-07-10 11:25:37 +00001091########################################
1092
1093 .. container:: paragraph
1094
liamfallon3e524ba2020-07-02 15:32:26 +01001095 APEX has a REST application for deploying, monitoring, and viewing policy models. The
ramverma3b71c972019-07-10 11:25:37 +00001096 application can also be used to create new policy models close to
liamfallon3e524ba2020-07-02 15:32:26 +01001097 the engine native policy language. Start the REST client as
ramverma3b71c972019-07-10 11:25:37 +00001098 follows.
1099
1100 .. container:: listingblock
1101
1102 .. container:: content
1103
ramverma760cce92019-07-11 12:57:49 +00001104 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001105 :number-lines:
1106
liamfallon3e524ba2020-07-02 15:32:26 +01001107 # $APEX_HOME/bin/apexApps.sh full-client
ramverma3b71c972019-07-10 11:25:37 +00001108
1109.. container:: listingblock
1110
1111 .. container:: content
1112
ramverma760cce92019-07-11 12:57:49 +00001113 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001114 :number-lines:
1115
liamfallon3e524ba2020-07-02 15:32:26 +01001116 >%APEX_HOME%\bin\apexApps.bat full-client
ramverma3b71c972019-07-10 11:25:37 +00001117
1118.. container:: paragraph
1119
1120 The script will start a simple web server
1121 (`Grizzly <https://javaee.github.io/grizzly/>`__) and deploy a
liamfallon3e524ba2020-07-02 15:32:26 +01001122 ``war`` web archive in it. Once the client is started, it will be
ramverma3b71c972019-07-10 11:25:37 +00001123 available on ``localhost:18989``. The last few line of the messages
1124 should be:
1125
1126.. container:: listingblock
1127
1128 .. container:: content
1129
ramverma760cce92019-07-11 12:57:49 +00001130 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001131 :number-lines:
1132
liamfallon3e524ba2020-07-02 15:32:26 +01001133 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
1134 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.NetworkListener start
ramverma3b71c972019-07-10 11:25:37 +00001135 INFO: Started listener bound to [localhost:18989]
liamfallon3e524ba2020-07-02 15:32:26 +01001136 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.HttpServer start
ramverma3b71c972019-07-10 11:25:37 +00001137 INFO: [HttpServer] Started.
liamfallon3e524ba2020-07-02 15:32:26 +01001138 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
1139
ramverma3b71c972019-07-10 11:25:37 +00001140
1141.. container:: paragraph
1142
1143 Now open a browser (Firefox, Chrome, Opera, Internet Explorer) and
1144 use the URL ``http://localhost:18989/``. This will connect the
liamfallon40f09542021-10-11 11:57:31 +01001145 browser to the started REST client. Click on the "Policy Editor" button and the Policy Editor start screen should appear.
ramverma3b71c972019-07-10 11:25:37 +00001146
1147.. container:: paragraph
1148
1149 Now load a policy model by clicking the menu ``File`` and then
1150 ``Open``. In the opened dialog, go to the directory where APEX is
1151 installed, then ``examples``, ``models``, ``SampleDomain``, and there
1152 select the file ``SamplePolicyModelJAVA.json``. This will load the
liamfallon40f09542021-10-11 11:57:31 +01001153 policy model used to verify the policy engine (see above).
ramverma3b71c972019-07-10 11:25:37 +00001154
1155.. container:: paragraph
1156
liamfallon75e2bbf2020-07-06 11:41:38 +01001157 Now you can use the Policy editor. To finish this verification, simply
ramverma3b71c972019-07-10 11:25:37 +00001158 terminate your browser (or the tab), and then use ``CTRL+C`` in the
liamfallon75e2bbf2020-07-06 11:41:38 +01001159 console where you started the Policy editor.
ramverma3b71c972019-07-10 11:25:37 +00001160
liamfallon3e524ba2020-07-02 15:32:26 +01001161Installing the WAR Application
1162------------------------------
ramverma3b71c972019-07-10 11:25:37 +00001163
1164 .. container:: paragraph
1165
liamfallon3e524ba2020-07-02 15:32:26 +01001166 The three APEX clients are packaged in a WAR file. This is a complete
1167 application that can be installed and run in an application
1168 server. The application is realized as a servlet. You
1169 can find the WAR application in the `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/client/apex-client-full/>`__.
1170
ramverma3b71c972019-07-10 11:25:37 +00001171
1172 .. container:: paragraph
1173
liamfallon3e524ba2020-07-02 15:32:26 +01001174 Installing and using the WAR application requires a web server
ramverma3b71c972019-07-10 11:25:37 +00001175 that can execute ``war`` web archives. We recommend to use `Apache
1176 Tomcat <https://tomcat.apache.org/>`__, however other web servers
1177 can be used as well.
1178
1179 .. container:: paragraph
1180
1181 Install Apache Tomcat including the ``Manager App``, see `V9.0
1182 Docs <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html#Configuring_Manager_Application_Access>`__
1183 for details. Start the Tomcat service, or make sure that Tomcat is
1184 running.
1185
1186 .. container:: paragraph
1187
liamfallon3e524ba2020-07-02 15:32:26 +01001188 There are multiple ways to install the APEX WAR application:
ramverma3b71c972019-07-10 11:25:37 +00001189
1190 .. container:: ulist
1191
1192 - copy the ``.war`` file into the Tomcat ``webapps`` folder
1193
1194 - use the Tomcat ``Manager App`` to deploy via the web interface
1195
1196 - deploy using a REST call to Tomcat
1197
1198 .. container:: paragraph
1199
1200 For details on how to install ``war`` files please consult the
1201 `Tomcat
1202 Documentation <https://tomcat.apache.org/tomcat-9.0-doc/index.html>`__
1203 or the `Manager App
1204 HOW-TO <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html>`__.
1205 Once you installed an APEX WAR application (and wait for
1206 sufficient time for Tomcat to finalize the installation), open the
1207 ``Manager App`` in Tomcat. You should see the APEX WAR application
1208 being installed and running.
1209
1210 .. container:: paragraph
1211
1212 In case of errors, examine the log files in the Tomcat log
1213 directory. In a conventional install, those log files are in the
1214 logs directory where Tomcat is installed.
1215
1216 .. container:: paragraph
1217
liamfallon3e524ba2020-07-02 15:32:26 +01001218 The WAR application file has a name similar to *apex-client-full-<VERSION>.war*.
ramverma3b71c972019-07-10 11:25:37 +00001219
1220Running APEX in Docker
1221----------------------
1222
1223 .. container:: paragraph
1224
1225 Since APEX is in ONAP, we provide a full virtualization
1226 environment for the engine.
1227
1228Run in ONAP
1229###########
1230
1231 .. container:: paragraph
1232
1233 Running APEX from the ONAP docker repository only requires 2
1234 commands:
1235
liamfallon40f09542021-10-11 11:57:31 +01001236 1. Log into the ONAP docker repo
ramverma3b71c972019-07-10 11:25:37 +00001237
liamfallon40f09542021-10-11 11:57:31 +01001238 .. container:: listingblock
ramverma3b71c972019-07-10 11:25:37 +00001239
liamfallon40f09542021-10-11 11:57:31 +01001240 .. container:: content
ramverma3b71c972019-07-10 11:25:37 +00001241
liamfallon40f09542021-10-11 11:57:31 +01001242 ::
ramverma3b71c972019-07-10 11:25:37 +00001243
1244 docker login -u docker -p docker nexus3.onap.org:10003
1245
liamfallon40f09542021-10-11 11:57:31 +01001246 2. Run the APEX docker image
ramverma3b71c972019-07-10 11:25:37 +00001247
liamfallon40f09542021-10-11 11:57:31 +01001248 .. container:: listingblock
ramverma3b71c972019-07-10 11:25:37 +00001249
liamfallon40f09542021-10-11 11:57:31 +01001250 .. container:: content
ramverma3b71c972019-07-10 11:25:37 +00001251
1252 ::
1253
1254 docker run -it --rm nexus3.onap.org:10003/onap/policy-apex-pdp:latest
1255
1256Build a Docker Image
1257####################
1258
1259 .. container:: paragraph
1260
1261 Alternatively, one can use the Dockerfile defined in the Docker
1262 package to build an image.
1263
1264 .. container:: listingblock
1265
1266 .. container:: title
1267
1268 APEX Dockerfile
1269
1270 .. container:: content
1271
ramverma760cce92019-07-11 12:57:49 +00001272 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001273 :number-lines:
1274
1275 #
1276 # Docker file to build an image that runs APEX on Java 8 in Ubuntu
1277 #
1278 FROM ubuntu:16.04
1279
1280 RUN apt-get update && \
1281 apt-get upgrade -y && \
1282 apt-get install -y software-properties-common && \
1283 add-apt-repository ppa:openjdk-r/ppa -y && \
1284 apt-get update && \
1285 apt-get install -y openjdk-8-jdk
1286
1287 # Create apex user and group
1288 RUN groupadd apexuser
1289 RUN useradd --create-home -g apexuser apexuser
1290
1291 # Add Apex-specific directories and set ownership as the Apex admin user
1292 RUN mkdir -p /opt/app/policy/apex-pdp
1293 RUN mkdir -p /var/log/onap/policy/apex-pdp
1294 RUN chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp
1295
1296 # Unpack the tarball
1297 RUN mkdir /packages
1298 COPY apex-pdp-package-full.tar.gz /packages
1299 RUN tar xvfz /packages/apex-pdp-package-full.tar.gz --directory /opt/app/policy/apex-pdp
1300 RUN rm /packages/apex-pdp-package-full.tar.gz
1301
1302 # Ensure everything has the correct permissions
1303 RUN find /opt/app -type d -perm 755
1304 RUN find /opt/app -type f -perm 644
1305 RUN chmod a+x /opt/app/policy/apex-pdp/bin/*
1306
1307 # Copy examples to Apex user area
1308 RUN cp -pr /opt/app/policy/apex-pdp/examples /home/apexuser
1309
1310 RUN apt-get clean
1311
1312 RUN chown -R apexuser:apexuser /home/apexuser/*
1313
1314 USER apexuser
1315 ENV PATH /opt/app/policy/apex-pdp/bin:$PATH
1316 WORKDIR /home/apexuser
1317
a.sreekumarebd97932020-09-14 13:34:23 +01001318Running APEX in Standalone mode
1319-------------------------------
1320
1321 .. container:: paragraph
1322
1323 APEX Engine can run in standalone mode by taking in a ToscaPolicy
1324 as an argument and executing it.
1325 Assume there is a tosca policy named ToscaPolicy.json in APEX_HOME directory
1326 This policy can be executed in standalone mode using any of the below methods.
1327
1328Run in an APEX installation
1329###########################
1330
1331 .. container:: listingblock
1332
1333 .. container:: content
1334
1335 .. code::
1336 :number-lines:
1337
1338 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/ToscaPolicy.json(1)
1339 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\ToscaPolicy.json(2)
1340
1341.. container:: colist arabic
1342
1343 +-------+---------+
1344 | **1** | UNIX |
1345 +-------+---------+
1346 | **2** | Windows |
1347 +-------+---------+
1348
1349Run in a docker container
1350#########################
1351
1352 .. container:: listingblock
1353
1354 .. container:: content
1355
1356 .. code::
1357 :number-lines:
1358
1359 # docker run -p 6969:6969 -v $APEX_HOME/ToscaPolicy.json:/tmp/policy/ToscaPolicy.json \
Ram Krishna Vermaace4b432021-03-25 10:29:18 -04001360 --name apex -it nexus3.onap.org:10001/onap/policy-apex-pdp:latest \
a.sreekumarebd97932020-09-14 13:34:23 +01001361 -c "/opt/app/policy/apex-pdp/bin/apexEngine.sh -p /tmp/policy/ToscaPolicy.json"
1362
ramverma3b71c972019-07-10 11:25:37 +00001363APEX Configurations Explained
1364^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1365
1366Introduction to APEX Configuration
1367----------------------------------
1368
1369 .. container:: paragraph
1370
1371 An APEX engine can be configured to use various combinations
1372 of event input handlers, event output handlers, event
1373 protocols, context handlers, and logic executors. The system
1374 is build using a plugin architecture. Each configuration
1375 option is realized by a plugin, which can be loaded and
1376 configured when the engine is started. New plugins can be
1377 added to the system at any time, though to benefit from a
1378 new plugin an engine will need to be restarted.
1379
1380 .. container:: imageblock
1381
1382 .. container:: content
1383
liamfallon40f09542021-10-11 11:57:31 +01001384 .. image:: images/apex-intro/ApexEngineConfig.png
ramverma3b71c972019-07-10 11:25:37 +00001385
1386 .. container:: title
1387
1388 Figure 3. APEX Configuration Matrix
1389
1390 .. container:: paragraph
1391
1392 The APEX distribution already comes with a number of
1393 plugins. The figure above shows the provided plugins. Any
1394 combination of input, output, event protocol, context
1395 handlers, and executors is possible.
1396
1397General Configuration Format
1398----------------------------
1399
1400 .. container:: paragraph
1401
1402 The APEX configuration file is a JSON file containing a few
1403 main blocks for different parts of the configuration. Each
1404 block then holds the configuration details. The following
1405 code shows the main blocks:
1406
1407 .. container:: listingblock
1408
1409 .. container:: content
1410
ramverma760cce92019-07-11 12:57:49 +00001411 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001412
1413 {
1414 "engineServiceParameters":{
1415 ... (1)
1416 "engineParameters":{ (2)
a.sreekumarcc0e9172020-03-16 13:36:45 +00001417 "executorParameters":{...}, (3)
ramverma3b71c972019-07-10 11:25:37 +00001418 "contextParameters":{...} (4)
a.sreekumarcc0e9172020-03-16 13:36:45 +00001419 "taskParameters":[...] (5)
ramverma3b71c972019-07-10 11:25:37 +00001420 }
1421 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001422 "eventInputParameters":{ (6)
1423 "input1":{ (7)
ramverma3b71c972019-07-10 11:25:37 +00001424 "carrierTechnologyParameters":{...},
1425 "eventProtocolParameters":{...}
1426 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001427 "input2":{...}, (8)
ramverma3b71c972019-07-10 11:25:37 +00001428 "carrierTechnologyParameters":{...},
1429 "eventProtocolParameters":{...}
1430 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001431 ... (9)
ramverma3b71c972019-07-10 11:25:37 +00001432 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001433 "eventOutputParameters":{ (10)
1434 "output1":{ (11)
ramverma3b71c972019-07-10 11:25:37 +00001435 "carrierTechnologyParameters":{...},
1436 "eventProtocolParameters":{...}
1437 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001438 "output2":{ (12)
ramverma3b71c972019-07-10 11:25:37 +00001439 "carrierTechnologyParameters":{...},
1440 "eventProtocolParameters":{...}
1441 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001442 ... (13)
ramverma3b71c972019-07-10 11:25:37 +00001443 }
1444 }
1445
1446 .. container:: colist arabic
1447
1448 +-----------------------------------+-----------------------------------+
1449 | **1** | main engine configuration |
1450 +-----------------------------------+-----------------------------------+
1451 | **2** | engine parameters for plugin |
1452 | | configurations (execution |
1453 | | environments and context |
1454 | | handling) |
1455 +-----------------------------------+-----------------------------------+
1456 | **3** | engine specific parameters, |
1457 | | mainly for executor plugins |
1458 +-----------------------------------+-----------------------------------+
1459 | **4** | context specific parameters, e.g. |
1460 | | for context schemas, persistence, |
1461 | | etc. |
1462 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001463 | **5** | list of task parameters that |
1464 | | should be made available in task |
1465 | | logic (optional). |
1466 +-----------------------------------+-----------------------------------+
1467 | **6** | configuration of the input |
ramverma3b71c972019-07-10 11:25:37 +00001468 | | interface |
1469 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001470 | **7** | an example input called |
ramverma3b71c972019-07-10 11:25:37 +00001471 | | ``input1`` with carrier |
1472 | | technology and event protocol |
1473 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001474 | **8** | an example input called |
ramverma3b71c972019-07-10 11:25:37 +00001475 | | ``input2`` with carrier |
1476 | | technology and event protocol |
1477 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001478 | **9** | any further input configuration |
ramverma3b71c972019-07-10 11:25:37 +00001479 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001480 | **10** | configuration of the output |
ramverma3b71c972019-07-10 11:25:37 +00001481 | | interface |
1482 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001483 | **11** | an example output called |
ramverma3b71c972019-07-10 11:25:37 +00001484 | | ``output1`` with carrier |
1485 | | technology and event protocol |
1486 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001487 | **12** | an example output called |
ramverma3b71c972019-07-10 11:25:37 +00001488 | | ``output2`` with carrier |
1489 | | technology and event protocol |
1490 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001491 | **13** | any further output configuration |
ramverma3b71c972019-07-10 11:25:37 +00001492 +-----------------------------------+-----------------------------------+
1493
1494Engine Service Parameters
1495-------------------------
1496
1497 .. container:: paragraph
1498
1499 The configuration provides a number of parameters to
1500 configure the engine. An example configuration with
1501 explanations of all options is shown below.
1502
1503 .. container:: listingblock
1504
1505 .. container:: content
1506
ramverma760cce92019-07-11 12:57:49 +00001507 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001508
1509 "engineServiceParameters" : {
1510 "name" : "AADMApexEngine", (1)
1511 "version" : "0.0.1", (2)
1512 "id" : 45, (3)
1513 "instanceCount" : 4, (4)
1514 "deploymentPort" : 12345, (5)
a.sreekumarcf3ff822020-09-16 13:12:29 +01001515 "policy_type_impl" : {...}, (6)
ramverma3b71c972019-07-10 11:25:37 +00001516 "periodicEventPeriod": 1000, (7)
1517 "engineParameters":{ (8)
a.sreekumarcc0e9172020-03-16 13:36:45 +00001518 "executorParameters":{...}, (9)
1519 "contextParameters":{...}, (10)
1520 "taskParameters":[...] (11)
ramverma3b71c972019-07-10 11:25:37 +00001521 }
1522 }
1523
1524 .. container:: colist arabic
1525
1526 +-----------------------------------+-----------------------------------+
1527 | **1** | a name for the engine. The engine |
1528 | | name is used to create a key in a |
1529 | | runtime engine. An name matching |
1530 | | the following regular expression |
1531 | | can be used here: |
1532 | | ``[A-Za-z0-9\\-_\\.]+`` |
1533 +-----------------------------------+-----------------------------------+
1534 | **2** | a version of the engine, use |
1535 | | semantic versioning as explained |
1536 | | here: `Semantic |
1537 | | Versioning <http://semver.org/>`_ |
1538 | | _. |
1539 | | This version is used in a runtime |
1540 | | engine to create a version of the |
1541 | | engine. For that reason, the |
1542 | | version must match the following |
1543 | | regular expression ``[A-Z0-9.]+`` |
1544 +-----------------------------------+-----------------------------------+
1545 | **3** | a numeric identifier for the |
1546 | | engine |
1547 +-----------------------------------+-----------------------------------+
1548 | **4** | the number of threads (policy |
1549 | | instances executed in parallel) |
1550 | | the engine should use, use ``1`` |
1551 | | for single threaded engines |
1552 +-----------------------------------+-----------------------------------+
1553 | **5** | the port for the deployment |
1554 | | Websocket connection to the |
1555 | | engine |
1556 +-----------------------------------+-----------------------------------+
a.sreekumarcf3ff822020-09-16 13:12:29 +01001557 | **6** | the APEX policy model as a JSON |
liamfallon3e524ba2020-07-02 15:32:26 +01001558 | | or YAML block to load into the |
1559 | | engine on startup when |
1560 | | APEX is running a policy that has |
1561 | | its logic and parameters |
1562 | | specified in TOSCA |
1563 | | (optional) |
ramverma3b71c972019-07-10 11:25:37 +00001564 +-----------------------------------+-----------------------------------+
1565 | **7** | an optional timer for periodic |
1566 | | policies, in milliseconds (a |
1567 | | defined periodic policy will be |
1568 | | executed every ``X`` |
1569 | | milliseconds), not used of not |
1570 | | set or ``0`` |
1571 +-----------------------------------+-----------------------------------+
1572 | **8** | engine parameters for plugin |
1573 | | configurations (execution |
1574 | | environments and context |
1575 | | handling) |
1576 +-----------------------------------+-----------------------------------+
1577 | **9** | engine specific parameters, |
1578 | | mainly for executor plugins |
1579 +-----------------------------------+-----------------------------------+
1580 | **10** | context specific parameters, e.g. |
1581 | | for context schemas, persistence, |
1582 | | etc. |
1583 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001584 | **11** | list of task parameters that |
1585 | | should be made available in task |
1586 | | logic (optional). |
1587 +-----------------------------------+-----------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00001588
1589 .. container:: paragraph
1590
1591 The model file is optional, it can also be specified via
1592 command line. In any case, make sure all execution and other
1593 required plug-ins for the loaded model are loaded as
1594 required.
1595
1596Input and Output Interfaces
1597---------------------------
1598
1599 .. container:: paragraph
1600
1601 An APEX engine has two main interfaces:
1602
1603 .. container:: ulist
1604
1605 - An *input* interface to receive events: also known as
1606 ingress interface or consumer, receiving (consuming)
1607 events commonly named triggers, and
1608
1609 - An *output* interface to publish produced events: also
1610 known as egress interface or producer, sending
1611 (publishing) events commonly named actions or action
1612 events.
1613
1614 .. container:: paragraph
1615
1616 The input and output interface is configured in terms of
1617 inputs and outputs, respectively. Each input and output is a
1618 combination of a carrier technology and an event protocol.
1619 Carrier technologies and event protocols are provided by
1620 plugins, each with its own specific configuration. Most
1621 carrier technologies can be configured for input as well as
1622 output. Most event protocols can be used for all carrier
1623 technologies. One exception is the JMS object event
1624 protocol, which can only be used for the JMS carrier
1625 technology. Some further restrictions apply (for instance
1626 for carrier technologies using bi- or uni-directional
1627 modes).
1628
1629 .. container:: paragraph
1630
1631 Input and output interface can be configured separately, in
1632 isolation, with any number of carrier technologies. The
1633 resulting general configuration options are:
1634
1635 .. container:: ulist
1636
1637 - Input interface with one or more inputs
1638
1639 .. container:: ulist
1640
1641 - each input with a carrier technology and an event
1642 protocol
1643
1644 - some inputs with optional synchronous mode
1645
1646 - some event protocols with additional parameters
1647
1648 - Output interface with one or more outputs
1649
1650 .. container:: ulist
1651
1652 - each output with a carrier technology and an event
1653 encoding
1654
1655 - some outputs with optional synchronous mode
1656
1657 - some event protocols with additional parameters
1658
1659 .. container:: paragraph
1660
1661 The configuration for input and output is contained in
1662 ``eventInputParameters`` and ``eventOutputParameters``,
1663 respectively. Inside here, one can configure any number of
1664 inputs and outputs. Each of them needs to have a unique
1665 identifier (name), the content of the name is free form. The
1666 example below shows a configuration for two inputs and two
1667 outputs.
1668
1669 .. container:: listingblock
1670
1671 .. container:: content
1672
ramverma760cce92019-07-11 12:57:49 +00001673 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001674
1675 "eventInputParameters": { (1)
1676 "FirstConsumer": { (2)
1677 "carrierTechnologyParameters" : {...}, (3)
1678 "eventProtocolParameters":{...}, (4)
1679 ... (5)
1680 },
1681 "SecondConsumer": { (6)
1682 "carrierTechnologyParameters" : {...}, (7)
1683 "eventProtocolParameters":{...}, (8)
1684 ... (9)
1685 },
1686 },
1687 "eventOutputParameters": { (10)
1688 "FirstProducer": { (11)
1689 "carrierTechnologyParameters":{...}, (12)
1690 "eventProtocolParameters":{...}, (13)
1691 ... (14)
1692 },
1693 "SecondProducer": { (15)
1694 "carrierTechnologyParameters":{...}, (16)
1695 "eventProtocolParameters":{...}, (17)
1696 ... (18)
1697 }
1698 }
1699
1700 .. container:: colist arabic
1701
1702 +--------+--------------------------------------------------------------------+
1703 | **1** | input interface configuration, APEX input plugins |
1704 +--------+--------------------------------------------------------------------+
1705 | **2** | first input called ``FirstConsumer`` |
1706 +--------+--------------------------------------------------------------------+
1707 | **3** | carrier technology for plugin |
1708 +--------+--------------------------------------------------------------------+
1709 | **4** | event protocol for plugin |
1710 +--------+--------------------------------------------------------------------+
1711 | **5** | any other input configuration (e.g. event name filter, see below) |
1712 +--------+--------------------------------------------------------------------+
1713 | **6** | second input called ``SecondConsumer`` |
1714 +--------+--------------------------------------------------------------------+
1715 | **7** | carrier technology for plugin |
1716 +--------+--------------------------------------------------------------------+
1717 | **8** | event protocol for plugin |
1718 +--------+--------------------------------------------------------------------+
1719 | **9** | any other plugin configuration |
1720 +--------+--------------------------------------------------------------------+
1721 | **10** | output interface configuration, APEX output plugins |
1722 +--------+--------------------------------------------------------------------+
1723 | **11** | first output called ``FirstProducer`` |
1724 +--------+--------------------------------------------------------------------+
1725 | **12** | carrier technology for plugin |
1726 +--------+--------------------------------------------------------------------+
1727 | **13** | event protocol for plugin |
1728 +--------+--------------------------------------------------------------------+
1729 | **14** | any other plugin configuration |
1730 +--------+--------------------------------------------------------------------+
1731 | **15** | second output called ``SecondProducer`` |
1732 +--------+--------------------------------------------------------------------+
1733 | **16** | carrier technology for plugin |
1734 +--------+--------------------------------------------------------------------+
1735 | **17** | event protocol for plugin |
1736 +--------+--------------------------------------------------------------------+
1737 | **18** | any other output configuration (e.g. event name filter, see below) |
1738 +--------+--------------------------------------------------------------------+
1739
a.sreekumar61cb1ef2020-10-06 10:37:45 +01001740Event Name
1741##########
1742
1743 .. container:: paragraph
1744
1745 Any event defined in APEX has to be unique. The "name" of
1746 of an event is used as an identifier for an ApexEvent. Every
1747 event has to be tagged to an eventName. This can be done in different
1748 ways. Either the actual event can have a field called "name". Or, the
1749 event has some other field that can act as the identifier, which can be
1750 specified using "nameAlias". But in other cases, where a "name" or "nameAlias"
1751 cannot be specified, the incoming event coming over an endpoint can be
1752 manually tagged to an "eventName" before consuming it.
1753
1754 .. container:: paragraph
1755
1756 The "eventName" can have a single event's name if the event coming
1757 over the endpoint has to be always mapped to the specified eventName's
1758 definition. Otherwise, if different events can come over the endpoint,
1759 then "eventName" field can consist of multiple event names separated by
1760 "|" symbol. In this case, based on the received event's structure, it is
1761 mapped to any one of the event name specified in the "eventName" field.
1762
1763 .. container:: paragraph
1764
1765 The following code shows some examples on how to specify the eventName field:
1766
1767 .. container:: listingblock
1768
1769 .. container:: content
1770
1771 .. code::
1772
1773 "eventInputParameters": {
1774 "Input1": {
1775 "carrierTechnologyParameters" : {...},
1776 "eventProtocolParameters":{...},
1777 "eventName" : "VesEvent" (1)
1778 },
1779 "Input2": {
1780 "carrierTechnologyParameters" : {...},
1781 "eventProtocolParameters":{...},
1782 "eventName" : "AAISuccessResponseEvent|AAIFailureResponseEvent" (2)
1783 }
1784 }
1785
ramverma3b71c972019-07-10 11:25:37 +00001786Event Filters
1787#############
1788
1789 .. container:: paragraph
1790
1791 APEX will always send an event after a policy execution
1792 is finished. For a successful execution, the event sent
1793 is the output event created by the policy. In case the
1794 policy does not create an output event, APEX will create
1795 a new event with all input event fields plus an
1796 additional field ``exceptionMessage`` with an exception
1797 message.
1798
1799 .. container:: paragraph
1800
1801 There are situations in which this auto-generated error
1802 event might not be required or wanted:
1803
1804 .. container:: ulist
1805
1806 - when a policy failing should not result in an event
1807 send out via an output interface
1808
1809 - when the auto-generated event goes back in an APEX
1810 engine (or the same APEX engine), this can create
1811 endless loops
1812
1813 - the auto-generated event should go to a special output
1814 interface or channel
1815
1816 .. container:: paragraph
1817
1818 All of these situations are supported by a filter option
1819 using a wildecard (regular expression) configuration on
1820 APEX I/O interfaces. The parameter is called
1821 ``eventNameFilter`` and the value are `Java regular
1822 expressions <https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html>`__
1823 (a
1824 `tutorial <http://www.vogella.com/tutorials/JavaRegularExpressions/article.html>`__).
1825 The following code shows some examples:
1826
1827 .. container:: listingblock
1828
1829 .. container:: content
1830
ramverma760cce92019-07-11 12:57:49 +00001831 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001832
1833 "eventInputParameters": {
1834 "Input1": {
1835 "carrierTechnologyParameters" : {...},
1836 "eventProtocolParameters":{...},
1837 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]004$" (1)
1838 }
1839 },
1840 "eventOutputParameters": {
1841 "Output1": {
1842 "carrierTechnologyParameters":{...},
1843 "eventProtocolParameters":{...},
1844 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]104$" (2)
1845 }
1846 }
1847
1848Executors
1849---------
1850
1851 .. container:: paragraph
1852
1853 Executors are plugins that realize the execution of logic
1854 contained in a policy model. Logic can be in a task
1855 selector, a task, and a state finalizer. Using plugins for
1856 execution environments makes APEX very flexible to support
1857 virtually any executable logic expressions.
1858
1859 .. container:: paragraph
1860
1861 APEX 2.0.0-SNAPSHOT supports the following executors:
1862
1863 .. container:: ulist
1864
1865 - Java, for Java implemented logic
1866
1867 .. container:: ulist
1868
1869 - This executor requires logic implemented using the
1870 APEX Java interfaces.
1871
1872 - Generated JAR files must be in the classpath of the
1873 APEX engine at start time.
1874
1875 - Javascript
1876
1877 - JRuby,
1878
1879 - Jython,
1880
1881 - MVEL
1882
1883 .. container:: ulist
1884
1885 - This executor uses the latest version of the MVEL
1886 engine, which can be very hard to debug and can
1887 produce unwanted side effects during execution
1888
1889Configure the Javascript Executor
1890#################################
1891
1892 .. container:: paragraph
1893
1894 The Javascript executor is added to the configuration as
1895 follows:
1896
1897 .. container:: listingblock
1898
1899 .. container:: content
1900
ramverma760cce92019-07-11 12:57:49 +00001901 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001902
1903 "engineServiceParameters":{
1904 "engineParameters":{
1905 "executorParameters":{
1906 "JAVASCRIPT":{
1907 "parameterClassName" :
1908 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
1909 }
1910 }
1911 }
1912 }
1913
1914Configure the Jython Executor
1915#############################
1916
1917 .. container:: paragraph
1918
1919 The Jython executor is added to the configuration as
1920 follows:
1921
1922 .. container:: listingblock
1923
1924 .. container:: content
1925
ramverma760cce92019-07-11 12:57:49 +00001926 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001927
1928 "engineServiceParameters":{
1929 "engineParameters":{
1930 "executorParameters":{
1931 "JYTHON":{
1932 "parameterClassName" :
1933 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
1934 }
1935 }
1936 }
1937 }
1938
1939Configure the JRuby Executor
1940############################
1941
1942 .. container:: paragraph
1943
1944 The JRuby executor is added to the configuration as
1945 follows:
1946
1947 .. container:: listingblock
1948
1949 .. container:: content
1950
ramverma760cce92019-07-11 12:57:49 +00001951 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001952
1953 "engineServiceParameters":{
1954 "engineParameters":{
1955 "executorParameters":{
1956 "JRUBY":{
1957 "parameterClassName" :
1958 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
1959 }
1960 }
1961 }
1962 }
1963
1964Configure the Java Executor
1965###########################
1966
1967 .. container:: paragraph
1968
1969 The Java executor is added to the configuration as
1970 follows:
1971
1972 .. container:: listingblock
1973
1974 .. container:: content
1975
ramverma760cce92019-07-11 12:57:49 +00001976 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001977
1978 "engineServiceParameters":{
1979 "engineParameters":{
1980 "executorParameters":{
1981 "JAVA":{
1982 "parameterClassName" :
1983 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
1984 }
1985 }
1986 }
1987 }
1988
1989Configure the MVEL Executor
1990###########################
1991
1992 .. container:: paragraph
1993
1994 The MVEL executor is added to the configuration as
1995 follows:
1996
1997 .. container:: listingblock
1998
1999 .. container:: content
2000
ramverma760cce92019-07-11 12:57:49 +00002001 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002002
2003 "engineServiceParameters":{
2004 "engineParameters":{
2005 "executorParameters":{
2006 "MVEL":{
2007 "parameterClassName" :
2008 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
2009 }
2010 }
2011 }
2012 }
2013
2014Context Handlers
2015----------------
2016
2017 .. container:: paragraph
2018
2019 Context handlers are responsible for all context processing.
2020 There are the following main areas:
2021
2022 .. container:: ulist
2023
2024 - Context schema: use schema handlers other than Java class
2025 (supported by default without configuration)
2026
2027 - Context distribution: distribute context across multiple
2028 APEX engines
2029
2030 - Context locking: mechanisms to lock context elements for
2031 read/write
2032
2033 - Context persistence: mechanisms to persist context
2034
2035 .. container:: paragraph
2036
2037 APEX provides plugins for each of the main areas.
2038
2039Configure AVRO Schema Handler
2040#############################
2041
2042 .. container:: paragraph
2043
2044 The AVRO schema handler is added to the configuration as
2045 follows:
2046
2047 .. container:: listingblock
2048
2049 .. container:: content
2050
ramverma760cce92019-07-11 12:57:49 +00002051 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002052
2053 "engineServiceParameters":{
2054 "engineParameters":{
2055 "contextParameters":{
2056 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2057 "schemaParameters":{
2058 "Avro":{
2059 "parameterClassName" :
2060 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
2061 }
2062 }
2063 }
2064 }
2065 }
2066
2067 .. container:: paragraph
2068
2069 Using the AVRO schema handler has one limitation: AVRO
2070 only supports field names that represent valid Java class
2071 names. This means only letters and the character ``_``
2072 are supported. Characters commonly used in field names,
2073 such as ``.`` and ``-``, are not supported by AVRO. for
2074 more information see `Avro Spec:
2075 Names <https://avro.apache.org/docs/1.8.1/spec.html#names>`__.
2076
2077 .. container:: paragraph
2078
2079 To work with this limitation, the APEX Avro plugin will
2080 parse a given AVRO definition and replace *all*
2081 occurrences of ``.`` and ``-`` with a ``_``. This means
2082 that
2083
2084 .. container:: ulist
2085
2086 - In a policy model, if the AVRO schema defined a field
2087 as ``my-name`` the policy logic should access it as
2088 ``my_name``
2089
2090 - In a policy model, if the AVRO schema defined a field
2091 as ``my.name`` the policy logic should access it as
2092 ``my_name``
2093
2094 - There should be no field names that convert to the
2095 same internal name
2096
2097 .. container:: ulist
2098
2099 - For instance the simultaneous use of
2100 ``my_name``, ``my.name``, and ``my-name`` should
2101 be avoided
2102
2103 - If not avoided, the event processing might
2104 create unwanted side effects
2105
2106 - If field names use any other not-supported character,
2107 the AVRO plugin will reject it
2108
2109 .. container:: ulist
2110
2111 - Since AVRO uses lazy initialization, this
2112 rejection might only become visible at runtime
2113
a.sreekumarcc0e9172020-03-16 13:36:45 +00002114Configure Task Parameters
2115#########################
2116
2117 .. container:: paragraph
2118
2119 The Task Parameters are added to the configuration as
2120 follows:
2121
2122 .. container:: listingblock
2123
2124 .. container:: content
2125
2126 .. code::
2127
2128 "engineServiceParameters": {
2129 "engineParameters": {
2130 "taskParameters": [
2131 {
2132 "key": "ParameterKey1",
2133 "value": "ParameterValue1"
2134 },
2135 {
2136 "taskId": "Task_Act0",
2137 "key": "ParameterKey2",
2138 "value": "ParameterValue2"
2139 }
2140 ]
2141 }
2142 }
2143
2144 .. container:: paragraph
2145
2146 TaskParameters can be used to pass parameters from ApexConfig
2147 to the policy logic. In the config, these are optional.
2148 The list of task parameters provided in the config may be added
2149 to the tasks or existing task parameters in the task will be overriden.
2150
2151 .. container:: paragraph
2152
2153 If taskId is provided in ApexConfig for an entry, then that
2154 parameter is updated only for that particular task. Otherwise,
2155 the task parameter is added to all tasks.
2156
ramverma3b71c972019-07-10 11:25:37 +00002157Carrier Technologies
2158--------------------
2159
2160 .. container:: paragraph
2161
2162 Carrier technologies define how APEX receives (input) and
2163 sends (output) events. They can be used in any combination,
2164 using asynchronous or synchronous mode. There can also be
2165 any number of carrier technologies for the input (consume)
2166 and the output (produce) interface.
2167
2168 .. container:: paragraph
2169
2170 Supported *input* technologies are:
2171
2172 .. container:: ulist
2173
2174 - Standard input, read events from the standard input
2175 (console), not suitable for APEX background servers
2176
2177 - File input, read events from a file
2178
2179 - Kafka, read events from a Kafka system
2180
2181 - Websockets, read events from a Websocket
2182
2183 - JMS,
2184
2185 - REST (synchronous and asynchronous), additionally as
2186 client or server
2187
2188 - Event Requestor, allows reading of events that have been
2189 looped back into APEX
2190
2191 .. container:: paragraph
2192
2193 Supported *output* technologies are:
2194
2195 .. container:: ulist
2196
2197 - Standard output, write events to the standard output
2198 (console), not suitable for APEX background servers
2199
2200 - File output, write events to a file
2201
2202 - Kafka, write events to a Kafka system
2203
2204 - Websockets, write events to a Websocket
2205
2206 - JMS
2207
2208 - REST (synchronous and asynchronous), additionally as
2209 client or server
2210
2211 - Event Requestor, allows events to be looped back into
2212 APEX
2213
2214 .. container:: paragraph
2215
2216 New carrier technologies can be added as plugins to APEX or
2217 developed outside APEX and added to an APEX deployment.
2218
2219Standard IO
2220###########
2221
2222 .. container:: paragraph
2223
2224 Standard IO does not require a specific plugin, it is
2225 supported be default.
2226
2227Standard Input
2228==============
2229 .. container:: paragraph
2230
2231 APEX will take events from its standard input. This
2232 carrier is good for testing, but certainly not for a
2233 use case where APEX runs as a server. The
2234 configuration is as follows:
2235
2236 .. container:: listingblock
2237
2238 .. container:: content
2239
liamfallon40f09542021-10-11 11:57:31 +01002240 ::
ramverma3b71c972019-07-10 11:25:37 +00002241
2242 "carrierTechnologyParameters" : {
2243 "carrierTechnology" : "FILE", (1)
2244 "parameters" : {
2245 "standardIO" : true (2)
2246 }
2247 }
2248
2249 .. container:: colist arabic
2250
2251 +-------+---------------------------------------+
2252 | **1** | standard input is considered a file |
2253 +-------+---------------------------------------+
2254 | **2** | file descriptor set to standard input |
2255 +-------+---------------------------------------+
2256
2257Standard Output
2258===============
2259
2260 .. container:: paragraph
2261
2262 APEX will send events to its standard output. This
2263 carrier is good for testing, but certainly not for a
2264 use case where APEX runs as a server. The
2265 configuration is as follows:
2266
2267 .. container:: listingblock
2268
2269 .. container:: content
2270
ramverma760cce92019-07-11 12:57:49 +00002271 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002272
2273 "carrierTechnologyParameters" : {
2274 "carrierTechnology" : "FILE", (1)
2275 "parameters" : {
2276 "standardIO" : true (2)
2277 }
2278 }
2279
2280 .. container:: colist arabic
2281
2282 +-------+----------------------------------------+
2283 | **1** | standard output is considered a file |
2284 +-------+----------------------------------------+
2285 | **2** | file descriptor set to standard output |
2286 +-------+----------------------------------------+
2287
22882.7.2. File IO
2289##############
2290
2291 .. container:: paragraph
2292
2293 File IO does not require a specific plugin, it is
2294 supported be default.
2295
2296File Input
2297==========
2298
2299 .. container:: paragraph
2300
2301 APEX will take events from a file. The same file
2302 should not be used as an output. The configuration is
2303 as follows:
2304
2305 .. container:: listingblock
2306
2307 .. container:: content
2308
ramverma760cce92019-07-11 12:57:49 +00002309 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002310
2311 "carrierTechnologyParameters" : {
2312 "carrierTechnology" : "FILE", (1)
2313 "parameters" : {
2314 "fileName" : "examples/events/SampleDomain/EventsIn.xmlfile" (2)
2315 }
2316 }
2317
2318 .. container:: colist arabic
2319
2320 +-------+------------------------------------------+
2321 | **1** | set file input |
2322 +-------+------------------------------------------+
2323 | **2** | the name of the file to read events from |
2324 +-------+------------------------------------------+
2325
2326File Output
2327===========
2328 .. container:: paragraph
2329
2330 APEX will write events to a file. The same file should
2331 not be used as an input. The configuration is as
2332 follows:
2333
2334 .. container:: listingblock
2335
2336 .. container:: content
2337
ramverma760cce92019-07-11 12:57:49 +00002338 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002339
2340 "carrierTechnologyParameters" : {
2341 "carrierTechnology" : "FILE", (1)
2342 "parameters" : {
2343 "fileName" : "examples/events/SampleDomain/EventsOut.xmlfile" (2)
2344 }
2345 }
2346
2347 .. container:: colist arabic
2348
2349 +-------+-----------------------------------------+
2350 | **1** | set file output |
2351 +-------+-----------------------------------------+
2352 | **2** | the name of the file to write events to |
2353 +-------+-----------------------------------------+
2354
2355Event Requestor IO
2356##################
2357
2358 .. container:: paragraph
2359
2360 Event Requestor IO does not require a specific plugin, it
2361 is supported be default. It should only be used with the
2362 APEX event protocol.
2363
2364Event Requestor Input
2365=====================
2366
2367 .. container:: paragraph
2368
2369 APEX will take events from APEX.
2370
2371 .. container:: listingblock
2372
2373 .. container:: content
2374
ramverma760cce92019-07-11 12:57:49 +00002375 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002376
2377 "carrierTechnologyParameters" : {
2378 "carrierTechnology": "EVENT_REQUESTOR" (1)
2379 }
2380
2381 .. container:: colist arabic
2382
2383 +-------+---------------------------+
2384 | **1** | set event requestor input |
2385 +-------+---------------------------+
2386
2387Event Requestor Output
2388======================
2389
2390 .. container:: paragraph
2391
2392 APEX will write events to APEX.
2393
2394 .. container:: listingblock
2395
2396 .. container:: content
2397
ramverma760cce92019-07-11 12:57:49 +00002398 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002399
2400 "carrierTechnologyParameters" : {
2401 "carrierTechnology": "EVENT_REQUESTOR" (1)
2402 }
2403
2404Peering Event Requestors
2405========================
2406
2407 .. container:: paragraph
2408
2409 When using event requestors, they need to be peered.
2410 This means an event requestor output needs to be
2411 peered (associated) with an event requestor input. The
2412 following example shows the use of an event requestor
2413 with the APEX event protocol and the peering of output
2414 and input.
2415
2416 .. container:: listingblock
2417
2418 .. container:: content
2419
ramverma760cce92019-07-11 12:57:49 +00002420 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002421
2422 "eventInputParameters": {
2423 "EventRequestorConsumer": {
2424 "carrierTechnologyParameters": {
2425 "carrierTechnology": "EVENT_REQUESTOR" (1)
2426 },
2427 "eventProtocolParameters": {
2428 "eventProtocol": "APEX" (2)
2429 },
2430 "eventNameFilter": "InputEvent", (3)
2431 "requestorMode": true, (4)
2432 "requestorPeer": "EventRequestorProducer", (5)
2433 "requestorTimeout": 500 (6)
2434 }
2435 },
2436 "eventOutputParameters": {
2437 "EventRequestorProducer": {
2438 "carrierTechnologyParameters": {
2439 "carrierTechnology": "EVENT_REQUESTOR" (7)
2440 },
2441 "eventProtocolParameters": {
2442 "eventProtocol": "APEX" (8)
2443 },
2444 "eventNameFilter": "EventListEvent", (9)
2445 "requestorMode": true, (10)
2446 "requestorPeer": "EventRequestorConsumer", (11)
2447 "requestorTimeout": 500 (12)
2448 }
2449 }
2450
2451 .. container:: colist arabic
2452
2453 +-----------------------------------+-----------------------------------+
2454 | **1** | event requestor on a consumer |
2455 +-----------------------------------+-----------------------------------+
2456 | **2** | with APEX event protocol |
2457 +-----------------------------------+-----------------------------------+
2458 | **3** | optional filter (best to use a |
2459 | | filter to prevent unwanted events |
2460 | | on the consumer side) |
2461 +-----------------------------------+-----------------------------------+
2462 | **4** | activate requestor mode |
2463 +-----------------------------------+-----------------------------------+
2464 | **5** | the peer to the output (must |
2465 | | match the output carrier) |
2466 +-----------------------------------+-----------------------------------+
2467 | **6** | an optional timeout in |
2468 | | milliseconds |
2469 +-----------------------------------+-----------------------------------+
2470 | **7** | event requestor on a producer |
2471 +-----------------------------------+-----------------------------------+
2472 | **8** | with APEX event protocol |
2473 +-----------------------------------+-----------------------------------+
2474 | **9** | optional filter (best to use a |
2475 | | filter to prevent unwanted events |
2476 | | on the consumer side) |
2477 +-----------------------------------+-----------------------------------+
2478 | **10** | activate requestor mode |
2479 +-----------------------------------+-----------------------------------+
2480 | **11** | the peer to the output (must |
2481 | | match the input carrier) |
2482 +-----------------------------------+-----------------------------------+
2483 | **12** | an optional timeout in |
2484 | | milliseconds |
2485 +-----------------------------------+-----------------------------------+
2486
2487Kafka IO
2488########
2489
2490 .. container:: paragraph
2491
2492 Kafka IO is supported by the APEX Kafka plugin. The
2493 configurations below are examples. APEX will take any
2494 configuration inside the parameter object and forward it
2495 to Kafka. More information on Kafka specific
2496 configuration parameters can be found in the Kafka
2497 documentation:
2498
2499 .. container:: ulist
2500
2501 - `Kafka Consumer
2502 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html>`__
2503
2504 - `Kafka Producer
2505 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html>`__
2506
2507Kafka Input
2508===========
2509 .. container:: paragraph
2510
2511 APEX will receive events from the Apache Kafka
2512 messaging system. The input is uni-directional, an
2513 engine will only receive events from the input but not
2514 send any event to the input.
2515
2516 .. container:: listingblock
2517
2518 .. container:: content
2519
ramverma760cce92019-07-11 12:57:49 +00002520 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002521
2522 "carrierTechnologyParameters" : {
2523 "carrierTechnology" : "KAFKA", (1)
2524 "parameterClassName" :
2525 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2526 "parameters" : {
2527 "bootstrapServers" : "localhost:49092", (2)
2528 "groupId" : "apex-group-id", (3)
2529 "enableAutoCommit" : true, (4)
2530 "autoCommitTime" : 1000, (5)
2531 "sessionTimeout" : 30000, (6)
2532 "consumerPollTime" : 100, (7)
2533 "consumerTopicList" : ["apex-in-0", "apex-in-1"], (8)
2534 "keyDeserializer" :
2535 "org.apache.kafka.common.serialization.StringDeserializer", (9)
2536 "valueDeserializer" :
2537 "org.apache.kafka.common.serialization.StringDeserializer" (10)
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002538 "kafkaProperties": [ (11)
2539 [
2540 "security.protocol",
2541 "SASL_SSL"
2542 ],
2543 [
2544 "ssl.truststore.type",
2545 "JKS"
2546 ],
2547 [
2548 "ssl.truststore.location",
2549 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2550 ],
2551 [
2552 "ssl.truststore.password",
2553 "policy0nap"
2554 ],
2555 [
2556 "sasl.mechanism",
2557 "SCRAM-SHA-512"
2558 ],
2559 [
2560 "sasl.jaas.config",
2561 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2562 ],
2563 [
2564 "ssl.endpoint.identification.algorithm",
2565 ""
2566 ]
2567 ]
ramverma3b71c972019-07-10 11:25:37 +00002568 }
2569 }
2570
2571 .. container:: colist arabic
2572
2573 +--------+-------------------------------------+
2574 | **1** | set Kafka as carrier technology |
2575 +--------+-------------------------------------+
2576 | **2** | bootstrap server and port |
2577 +--------+-------------------------------------+
2578 | **3** | a group identifier |
2579 +--------+-------------------------------------+
2580 | **4** | flag for auto-commit |
2581 +--------+-------------------------------------+
2582 | **5** | auto-commit timeout in milliseconds |
2583 +--------+-------------------------------------+
2584 | **6** | session timeout in milliseconds |
2585 +--------+-------------------------------------+
2586 | **7** | consumer poll time in milliseconds |
2587 +--------+-------------------------------------+
2588 | **8** | consumer topic list |
2589 +--------+-------------------------------------+
2590 | **9** | key for the Kafka de-serializer |
2591 +--------+-------------------------------------+
2592 | **10** | value for the Kafka de-serializer |
2593 +--------+-------------------------------------+
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002594 | **11** | properties for Kafka connectivity |
2595 +--------+-------------------------------------+
2596
2597 .. container:: paragraph
2598
2599 Kindly note that the above Kafka properties is just a reference,
2600 and the actual properties required depends on the Kafka server installation.
ramverma3b71c972019-07-10 11:25:37 +00002601
2602Kafka Output
2603============
2604 .. container:: paragraph
2605
2606 APEX will send events to the Apache Kafka messaging
2607 system. The output is uni-directional, an engine will
2608 send events to the output but not receive any event
2609 from the output.
2610
2611 .. container:: listingblock
2612
2613 .. container:: content
2614
ramverma760cce92019-07-11 12:57:49 +00002615 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002616
2617 "carrierTechnologyParameters" : {
2618 "carrierTechnology" : "KAFKA", (1)
2619 "parameterClassName" :
2620 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2621 "parameters" : {
2622 "bootstrapServers" : "localhost:49092", (2)
2623 "acks" : "all", (3)
2624 "retries" : 0, (4)
2625 "batchSize" : 16384, (5)
2626 "lingerTime" : 1, (6)
2627 "bufferMemory" : 33554432, (7)
2628 "producerTopic" : "apex-out", (8)
2629 "keySerializer" :
2630 "org.apache.kafka.common.serialization.StringSerializer", (9)
2631 "valueSerializer" :
2632 "org.apache.kafka.common.serialization.StringSerializer" (10)
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002633 "kafkaProperties": [ (11)
2634 [
2635 "security.protocol",
2636 "SASL_SSL"
2637 ],
2638 [
2639 "ssl.truststore.type",
2640 "JKS"
2641 ],
2642 [
2643 "ssl.truststore.location",
2644 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2645 ],
2646 [
2647 "ssl.truststore.password",
2648 "policy0nap"
2649 ],
2650 [
2651 "sasl.mechanism",
2652 "SCRAM-SHA-512"
2653 ],
2654 [
2655 "sasl.jaas.config",
2656 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2657 ],
2658 [
2659 "ssl.endpoint.identification.algorithm",
2660 ""
2661 ]
2662 ]
ramverma3b71c972019-07-10 11:25:37 +00002663 }
2664 }
2665
2666 .. container:: colist arabic
2667
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002668 +--------+-----------------------------------+
2669 | **1** | set Kafka as carrier technology |
2670 +--------+-----------------------------------+
2671 | **2** | bootstrap server and port |
2672 +--------+-----------------------------------+
2673 | **3** | acknowledgement strategy |
2674 +--------+-----------------------------------+
2675 | **4** | number of retries |
2676 +--------+-----------------------------------+
2677 | **5** | batch size |
2678 +--------+-----------------------------------+
2679 | **6** | time to linger in milliseconds |
2680 +--------+-----------------------------------+
2681 | **7** | buffer memory in byte |
2682 +--------+-----------------------------------+
2683 | **8** | producer topic |
2684 +--------+-----------------------------------+
2685 | **9** | key for the Kafka serializer |
2686 +--------+-----------------------------------+
2687 | **10** | value for the Kafka serializer |
2688 +--------+-----------------------------------+
2689 | **11** | properties for Kafka connectivity |
2690 +--------+-----------------------------------+
2691
2692 .. container:: paragraph
2693
2694 Kindly note that the above Kafka properties is just a reference,
2695 and the actual properties required depends on the Kafka server installation.
ramverma3b71c972019-07-10 11:25:37 +00002696
2697JMS IO
liamfallonb621de42020-08-21 12:59:26 +01002698######
ramverma3b71c972019-07-10 11:25:37 +00002699
2700 .. container:: paragraph
2701
2702 APEX supports the Java Messaging Service (JMS) as input
2703 as well as output. JMS IO is supported by the APEX JMS
2704 plugin. Input and output support an event encoding as
2705 text (JSON string) or object (serialized object). The
2706 input configuration is the same for both encodings, the
2707 output configuration differs.
2708
2709JMS Input
2710=========
2711 .. container:: paragraph
2712
2713 APEX will receive events from a JMS messaging system.
2714 The input is uni-directional, an engine will only
2715 receive events from the input but not send any event
2716 to the input.
2717
2718 .. container:: listingblock
2719
2720 .. container:: content
2721
ramverma760cce92019-07-11 12:57:49 +00002722 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002723
2724 "carrierTechnologyParameters" : {
2725 "carrierTechnology" : "JMS", (1)
2726 "parameterClassName" :
2727 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2728 "parameters" : { (2)
2729 "initialContextFactory" :
2730 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2731 "connectionFactory" : "ConnectionFactory", (4)
2732 "providerURL" : "remote://localhost:5445", (5)
2733 "securityPrincipal" : "guest", (6)
2734 "securityCredentials" : "IAmAGuest", (7)
2735 "consumerTopic" : "jms/topic/apexIn" (8)
2736 }
2737 }
2738
2739 .. container:: colist arabic
2740
2741 +-----------------------------------+-----------------------------------+
2742 | **1** | set JMS as carrier technology |
2743 +-----------------------------------+-----------------------------------+
2744 | **2** | set all JMS specific parameters |
2745 +-----------------------------------+-----------------------------------+
2746 | **3** | the context factory, in this case |
2747 | | from JBOSS (it requires the |
2748 | | dependency |
2749 | | org.jboss:jboss-remote-naming:2.0 |
2750 | | .4.Final |
2751 | | or a different version to be in |
2752 | | the directory ``$APEX_HOME/lib`` |
2753 | | or ``%APEX_HOME%\lib`` |
2754 +-----------------------------------+-----------------------------------+
2755 | **4** | a connection factory for the JMS |
2756 | | connection |
2757 +-----------------------------------+-----------------------------------+
2758 | **5** | URL with host and port of the JMS |
2759 | | provider |
2760 +-----------------------------------+-----------------------------------+
2761 | **6** | access credentials, user name |
2762 +-----------------------------------+-----------------------------------+
2763 | **7** | access credentials, user password |
2764 +-----------------------------------+-----------------------------------+
2765 | **8** | the JMS topic to listen to |
2766 +-----------------------------------+-----------------------------------+
2767
2768JMS Output with Text
2769====================
2770
2771 .. container:: paragraph
2772
2773 APEX engine send events to a JMS messaging system. The
2774 output is uni-directional, an engine will send events
2775 to the output but not receive any event from output.
2776
2777 .. container:: listingblock
2778
2779 .. container:: content
2780
ramverma760cce92019-07-11 12:57:49 +00002781 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002782
2783 "carrierTechnologyParameters" : {
2784 "carrierTechnology" : "JMS", (1)
2785 "parameterClassName" :
2786 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2787 "parameters" : { (2)
2788 "initialContextFactory" :
2789 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2790 "connectionFactory" : "ConnectionFactory", (4)
2791 "providerURL" : "remote://localhost:5445", (5)
2792 "securityPrincipal" : "guest", (6)
2793 "securityCredentials" : "IAmAGuest", (7)
2794 "producerTopic" : "jms/topic/apexOut", (8)
2795 "objectMessageSending": "false" (9)
2796 }
2797 }
2798
2799 .. container:: colist arabic
2800
2801 +-----------------------------------+-----------------------------------+
2802 | **1** | set JMS as carrier technology |
2803 +-----------------------------------+-----------------------------------+
2804 | **2** | set all JMS specific parameters |
2805 +-----------------------------------+-----------------------------------+
2806 | **3** | the context factory, in this case |
2807 | | from JBOSS (it requires the |
2808 | | dependency |
2809 | | org.jboss:jboss-remote-naming:2.0 |
2810 | | .4.Final |
2811 | | or a different version to be in |
2812 | | the directory ``$APEX_HOME/lib`` |
2813 | | or ``%APEX_HOME%\lib`` |
2814 +-----------------------------------+-----------------------------------+
2815 | **4** | a connection factory for the JMS |
2816 | | connection |
2817 +-----------------------------------+-----------------------------------+
2818 | **5** | URL with host and port of the JMS |
2819 | | provider |
2820 +-----------------------------------+-----------------------------------+
2821 | **6** | access credentials, user name |
2822 +-----------------------------------+-----------------------------------+
2823 | **7** | access credentials, user password |
2824 +-----------------------------------+-----------------------------------+
2825 | **8** | the JMS topic to write to |
2826 +-----------------------------------+-----------------------------------+
2827 | **9** | set object messaging to ``false`` |
2828 | | means it sends JSON text |
2829 +-----------------------------------+-----------------------------------+
2830
2831JMS Output with Object
2832======================
2833
2834 .. container:: paragraph
2835
2836 To configure APEX for JMS objects on the output
2837 interface use the same configuration as above (for
2838 output). Simply change the ``objectMessageSending``
2839 parameter to ``true``.
2840
2841Websocket (WS) IO
liamfallonb621de42020-08-21 12:59:26 +01002842#################
ramverma3b71c972019-07-10 11:25:37 +00002843
2844 .. container:: paragraph
2845
2846 APEX supports the Websockets as input as well as output.
2847 WS IO is supported by the APEX Websocket plugin. This
2848 carrier technology does only support uni-directional
2849 communication. APEX will not send events to a Websocket
2850 input and any event sent to a Websocket output will
2851 result in an error log.
2852
2853 .. container:: paragraph
2854
2855 The input can be configured as client (APEX connects to
2856 an existing Websocket server) or server (APEX starts a
2857 Websocket server). The same applies to the output. Input
2858 and output can both use a client or a server
2859 configuration, or separate configurations (input as
2860 client and output as server, input as server and output
2861 as client). Each configuration should use its own
2862 dedicated port to avoid any communication loops. The
2863 configuration of a Websocket client is the same for input
2864 and output. The configuration of a Websocket server is
2865 the same for input and output.
2866
2867Websocket Client
2868================
2869
2870 .. container:: paragraph
2871
2872 APEX will connect to a given Websocket server. As
2873 input, it will receive events from the server but not
2874 send any events. As output, it will send events to the
2875 server and any event received from the server will
2876 result in an error log.
2877
2878 .. container:: listingblock
2879
2880 .. container:: content
2881
ramverma760cce92019-07-11 12:57:49 +00002882 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002883
2884 "carrierTechnologyParameters" : {
2885 "carrierTechnology" : "WEBSOCKET", (1)
2886 "parameterClassName" :
2887 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2888 "parameters" : {
2889 "host" : "localhost", (2)
2890 "port" : 42451 (3)
2891 }
2892 }
2893
2894 .. container:: colist arabic
2895
2896 +-------+------------------------------------------------------+
2897 | **1** | set Websocket as carrier technology |
2898 +-------+------------------------------------------------------+
2899 | **2** | the host name on which a Websocket server is running |
2900 +-------+------------------------------------------------------+
2901 | **3** | the port of that Websocket server |
2902 +-------+------------------------------------------------------+
2903
2904Websocket Server
2905================
2906
2907 .. container:: paragraph
2908
2909 APEX will start a Websocket server, which will accept
2910 any Websocket clients to connect. As input, it will
2911 receive events from the server but not send any
2912 events. As output, it will send events to the server
2913 and any event received from the server will result in
2914 an error log.
2915
2916 .. container:: listingblock
2917
2918 .. container:: content
2919
ramverma760cce92019-07-11 12:57:49 +00002920 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002921
2922 "carrierTechnologyParameters" : {
2923 "carrierTechnology" : "WEBSOCKET", (1)
2924 "parameterClassName" :
2925 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2926 "parameters" : {
2927 "wsClient" : false, (2)
2928 "port" : 42450 (3)
2929 }
2930 }
2931
2932 .. container:: colist arabic
2933
2934 +-------+------------------------------------------------------------+
2935 | **1** | set Websocket as carrier technology |
2936 +-------+------------------------------------------------------------+
2937 | **2** | disable client, so that APEX will start a Websocket server |
2938 +-------+------------------------------------------------------------+
2939 | **3** | the port for the Websocket server APEX will start |
2940 +-------+------------------------------------------------------------+
2941
2942REST Client IO
2943##############
2944
2945 .. container:: paragraph
2946
2947 APEX can act as REST client on the input as well as on
2948 the output interface. The media type is
a.sreekumarcc0e9172020-03-16 13:36:45 +00002949 ``application/json``, so this plugin only works with
ramverma3b71c972019-07-10 11:25:37 +00002950 the JSON Event protocol.
2951
2952REST Client Input
2953=================
2954
2955 .. container:: paragraph
2956
2957 APEX will connect to a given URL to receive events,
2958 but not send any events. The server is polled, i.e.
2959 APEX will do an HTTP GET, take the result, and then do
2960 the next GET. Any required timing needs to be handled
2961 by the server configured via the URL. For instance,
2962 the server could support a wait timeout via the URL as
2963 ``?timeout=100ms``.
Henry.Sun2941bc02019-07-22 08:32:32 +00002964 The httpCodeFilter is used for filtering the status
2965 code, and it can be configured as a regular expression
2966 string. The default httpCodeFilter is "[2][0-9][0-9]"
2967 - for successful response codes.
2968 The response with HTTP status code that matches the
2969 given regular expression is forwarded to the task,
2970 otherwise it is logged as a failure.
ramverma3b71c972019-07-10 11:25:37 +00002971
2972 .. container:: listingblock
2973
2974 .. container:: content
2975
ramverma760cce92019-07-11 12:57:49 +00002976 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002977
2978 "carrierTechnologyParameters" : {
2979 "carrierTechnology" : "RESTCLIENT", (1)
2980 "parameterClassName" :
2981 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
2982 "parameters" : {
2983 "url" : "http://example.org:8080/triggers/events", (2)
liamfallon75e2bbf2020-07-06 11:41:38 +01002984 "httpMethod": "GET", (3)
2985 "httpCodeFilter" : "[2][0-9][0-9]", (4)
2986 "httpHeaders" : [ (5)
2987 ["Keep-Alive", "300"],
2988 ["Cache-Control", "no-cache"]
2989 ]
ramverma3b71c972019-07-10 11:25:37 +00002990 }
2991 }
2992
2993 .. container:: colist arabic
2994
Henry.Sun2941bc02019-07-22 08:32:32 +00002995 +-------+--------------------------------------------------+
2996 | **1** | set REST client as carrier technology |
2997 +-------+--------------------------------------------------+
2998 | **2** | the URL of the HTTP server for events |
2999 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003000 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3001 | | optional, defaults to GET |
3002 +-------+--------------------------------------------------+
3003 | **4** | use HTTP CODE FILTER for filtering status code, |
3004 | | optional, defaults to [2][0-9][0-9] |
3005 +-------+--------------------------------------------------+
3006 | **5** | HTTP headers to use on the REST request, |
3007 | | optional |
Henry.Sun2941bc02019-07-22 08:32:32 +00003008 +-------+--------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003009
3010REST Client Output
3011==================
3012
3013 .. container:: paragraph
3014
3015 APEX will connect to a given URL to send events, but
3016 not receive any events. The default HTTP operation is
3017 POST (no configuration required). To change it to PUT
3018 simply add the configuration parameter (as shown in
3019 the example below).
ning.xi8bc537d2019-07-18 07:50:10 +00003020 The URL can be configured statically or tagged
3021 as ``?example.{site}.org:8080/{trig}/events``,
3022 all tags such as ``site`` and ``trig`` in the URL
Henry.Sun2941bc02019-07-22 08:32:32 +00003023 need to be set in the properties object available to
3024 the tasks. In addition, the keys should exactly match
3025 with the tags defined in url. The scope of the properties
3026 object is per HTTP call. Hence, key/value pairs set
3027 in the properties object by task are only available
3028 for that specific HTTP call.
ramverma3b71c972019-07-10 11:25:37 +00003029
3030 .. container:: listingblock
3031
3032 .. container:: content
3033
ramverma760cce92019-07-11 12:57:49 +00003034 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003035
3036 "carrierTechnologyParameters" : {
3037 "carrierTechnology" : "RESTCLIENT", (1)
3038 "parameterClassName" :
3039 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3040 "parameters" : {
3041 "url" : "http://example.com:8888/actions/events", (2)
ning.xi8bc537d2019-07-18 07:50:10 +00003042 "url" : "http://example.{site}.com:8888/{trig}/events", (2')
liamfallon75e2bbf2020-07-06 11:41:38 +01003043 "httpMethod" : "PUT". (3)
3044 "httpHeaders" : [ (4)
3045 ["Keep-Alive", "300"],
3046 ["Cache-Control", "no-cache"]
3047 ] }
ramverma3b71c972019-07-10 11:25:37 +00003048 }
3049
3050 .. container:: colist arabic
3051
3052 +-------+--------------------------------------------------+
3053 | **1** | set REST client as carrier technology |
3054 +-------+--------------------------------------------------+
ning.xi8bc537d2019-07-18 07:50:10 +00003055 | **2** | the static URL of the HTTP server for events |
3056 +-------+--------------------------------------------------+
3057 | **2'**| the tagged URL of the HTTP server for events |
ramverma3b71c972019-07-10 11:25:37 +00003058 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003059 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3060 | | optional, defaults to POST |
3061 +-------+--------------------------------------------------+
3062 | **4** | HTTP headers to use on the REST request, |
3063 | | optional |
ramverma3b71c972019-07-10 11:25:37 +00003064 +-------+--------------------------------------------------+
3065
3066REST Server IO
3067##############
3068
3069 .. container:: paragraph
3070
3071 APEX supports a REST server for input and output.
3072
3073 .. container:: paragraph
3074
3075 The REST server plugin always uses a synchronous mode. A
3076 client does a HTTP GET on the APEX REST server with the
3077 input event and receives the generated output event in
3078 the server reply. This means that for the REST server
3079 there has to always to be an input with an associated
3080 output. Input or output only are not permitted.
3081
3082 .. container:: paragraph
3083
3084 The plugin will start a Grizzly server as REST server for
3085 a normal APEX engine. If the APEX engine is executed as a
3086 servlet, for instance inside Tomcat, then Tomcat will be
3087 used as REST server (this case requires configuration on
3088 Tomcat as well).
3089
3090 .. container:: paragraph
3091
3092 Some configuration restrictions apply for all scenarios:
3093
3094 .. container:: ulist
3095
3096 - Minimum port: 1024
3097
3098 - Maximum port: 65535
3099
3100 - The media type is ``application/json``, so this plugin
a.sreekumarcc0e9172020-03-16 13:36:45 +00003101 only works with the JSON Event protocol.
ramverma3b71c972019-07-10 11:25:37 +00003102
3103 .. container:: paragraph
3104
3105 The URL the client calls is created using
3106
3107 .. container:: ulist
3108
3109 - the configured host and port, e.g.
3110 ``http://localhost:12345``
3111
3112 - the standard path, e.g. ``/apex/``
3113
3114 - the name of the input/output, e.g. ``FirstConsumer/``
3115
3116 - the input or output name, e.g. ``EventIn``.
3117
3118 .. container:: paragraph
3119
3120 The examples above lead to the URL
3121 ``http://localhost:12345/apex/FirstConsumer/EventIn``.
3122
3123 .. container:: paragraph
3124
3125 A client can also get status information of the REST
3126 server using ``/Status``, e.g.
3127 ``http://localhost:12345/apex/FirstConsumer/Status``.
3128
3129REST Server Stand-alone
3130=======================
3131
3132 .. container:: paragraph
3133
3134 We need to configure a REST server input and a REST
3135 server output. Input and output are associated with
3136 each other via there name.
3137
3138 .. container:: paragraph
3139
3140 Timeouts for REST calls need to be set carefully. If
3141 they are too short, the call might timeout before a
3142 policy finished creating an event.
3143
3144 .. container:: paragraph
3145
3146 The following example configures the input named as
3147 ``MyConsumer`` and associates an output named
3148 ``MyProducer`` with it.
3149
3150 .. container:: listingblock
3151
3152 .. container:: content
3153
ramverma760cce92019-07-11 12:57:49 +00003154 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003155
3156 "eventInputParameters": {
3157 "MyConsumer": {
3158 "carrierTechnologyParameters" : {
3159 "carrierTechnology" : "RESTSERVER", (1)
3160 "parameterClassName" :
3161 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters",
3162 "parameters" : {
3163 "standalone" : true, (2)
3164 "host" : "localhost", (3)
3165 "port" : 12345 (4)
3166 }
3167 },
3168 "eventProtocolParameters":{
3169 "eventProtocol" : "JSON" (5)
3170 },
3171 "synchronousMode" : true, (6)
3172 "synchronousPeer" : "MyProducer", (7)
3173 "synchronousTimeout" : 500 (8)
3174 }
3175 }
3176
3177 .. container:: colist arabic
3178
3179 +-------+---------------------------------------+
3180 | **1** | set REST server as carrier technology |
3181 +-------+---------------------------------------+
3182 | **2** | set the server as stand-alone |
3183 +-------+---------------------------------------+
3184 | **3** | set the server host |
3185 +-------+---------------------------------------+
3186 | **4** | set the server listen port |
3187 +-------+---------------------------------------+
3188 | **5** | use JSON event protocol |
3189 +-------+---------------------------------------+
3190 | **6** | activate synchronous mode |
3191 +-------+---------------------------------------+
3192 | **7** | associate an output ``MyProducer`` |
3193 +-------+---------------------------------------+
3194 | **8** | set a timeout of 500 milliseconds |
3195 +-------+---------------------------------------+
3196
3197 .. container:: paragraph
3198
3199 The following example configures the output named as
3200 ``MyProducer`` and associates the input ``MyConsumer``
3201 with it. Note that for the output there are no more
3202 paramters (such as host or port), since they are
3203 already configured in the associated input
3204
3205 .. container:: listingblock
3206
3207 .. container:: content
3208
ramverma760cce92019-07-11 12:57:49 +00003209 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003210
3211 "eventOutputParameters": {
3212 "MyProducer": {
3213 "carrierTechnologyParameters":{
3214 "carrierTechnology" : "RESTSERVER",
3215 "parameterClassName" :
3216 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters"
3217 },
3218 "eventProtocolParameters":{
3219 "eventProtocol" : "JSON"
3220 },
3221 "synchronousMode" : true,
3222 "synchronousPeer" : "MyConsumer",
3223 "synchronousTimeout" : 500
3224 }
3225 }
3226
3227REST Server Stand-alone, multi input
3228====================================
3229
3230 .. container:: paragraph
3231
3232 Any number of input/output pairs for REST servers can
3233 be configured. For instance, we can configure an input
3234 ``FirstConsumer`` with output ``FirstProducer`` and an
3235 input ``SecondConsumer`` with output
3236 ``SecondProducer``. Important is that there is always
3237 one pair of input/output.
3238
3239REST Server Stand-alone in Servlet
3240==================================
3241
3242 .. container:: paragraph
3243
3244 If APEX is executed as a servlet, e.g. inside Tomcat,
3245 the configuration becomes easier since the plugin can
3246 now use Tomcat as the REST server. In this scenario,
3247 there are not parameters (port, host, etc.) and the
3248 key ``standalone`` must not be used (or set to false).
3249
3250 .. container:: paragraph
3251
3252 For the Tomcat configuration, we need to add the REST
3253 server plugin, e.g.
3254
3255 .. container:: listingblock
3256
3257 .. container:: content
3258
ramverma760cce92019-07-11 12:57:49 +00003259 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003260
3261 <servlet>
3262 ...
3263 <init-param>
3264 ...
3265 <param-value>org.onap.policy.apex.plugins.event.carrier.restserver</param-value>
3266 </init-param>
3267 ...
3268 </servlet>
3269
3270REST Requestor IO
liamfallonb621de42020-08-21 12:59:26 +01003271#################
ramverma3b71c972019-07-10 11:25:37 +00003272
3273 .. container:: paragraph
3274
3275 APEX can act as REST requestor on the input as well as on
3276 the output interface. The media type is
a.sreekumarcc0e9172020-03-16 13:36:45 +00003277 ``application/json``, so this plugin only works with
liamfallon75e2bbf2020-07-06 11:41:38 +01003278 the JSON Event protocol. This plugin allows APEX to send REST requests
3279 and to receive the reply of that request without tying up APEX resources
3280 while the request is being processed. The REST Requestor pairs a REST
3281 requestor producer and consumer together to handle the REST request
3282 and response. The REST request is created from an APEX output event
3283 and the REST response is input into APEX as a new input event.
ramverma3b71c972019-07-10 11:25:37 +00003284
liamfallon75e2bbf2020-07-06 11:41:38 +01003285REST Requestor Output (REST Request Producer)
3286=============================================
ramverma3b71c972019-07-10 11:25:37 +00003287
3288 .. container:: paragraph
3289
liamfallon75e2bbf2020-07-06 11:41:38 +01003290 APEX sends a REST request when events are output by APEX, the REST
3291 request configuration is specified on the REST Request Consumer (see
3292 below).
3293
3294 .. container:: listingblock
3295
3296 .. container:: content
3297
3298 .. code::
3299
3300 "carrierTechnologyParameters": {
3301 "carrierTechnology": "RESTREQUESTOR", (1)
3302 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
3303 },
3304
3305 .. container:: colist arabic
3306
3307 +-------+------------------------------------------+
3308 | **1** | set REST requestor as carrier technology |
3309 +-------+------------------------------------------+
3310
3311 .. container:: paragraph
3312
3313 The settings below are required on the producer to
3314 define the event that triggers the REST request and
3315 to specify the peered consumer configuration for the
3316 REST request, for example:
3317
3318 .. container:: listingblock
3319
3320 .. container:: content
3321
3322 .. code::
3323
3324 "eventNameFilter": "GuardRequestEvent", (1)
3325 "requestorMode": true, (2)
3326 "requestorPeer": "GuardRequestorConsumer", (3)
3327 "requestorTimeout": 500 (4)
3328
3329 .. container:: colist arabic
3330
3331 +-------+-------------------------------------------+
3332 | **1** | a filter on the event |
3333 +-------+-------------------------------------------+
3334 | **2** | requestor mode must be set to *true* |
3335 +-------+-------------------------------------------+
3336 | **3** | the peered consumer for REST requests, |
3337 | | that consumer specifies the full |
3338 | | configuration for REST requests |
3339 +-------+-------------------------------------------+
3340 | **4** | the request timeout in milliseconds, |
3341 | | overridden by timeout on consumer if that |
3342 | | is set, optional defaults to 500 |
3343 | | millisconds |
3344 +-------+-------------------------------------------+
3345
3346REST Requestor Input (REST Request Consumer)
3347============================================
3348
3349 .. container:: paragraph
3350
3351 APEX will connect to a given URL to issue a REST request and
3352 wait for a REST response.
ning.xi8bc537d2019-07-18 07:50:10 +00003353 The URL can be configured statically or tagged
3354 as ``?example.{site}.org:8080/{trig}/events``,
3355 all tags such as ``site`` and ``trig`` in the URL
Henry.Sun2941bc02019-07-22 08:32:32 +00003356 need to be set in the properties object available to
3357 the tasks. In addition, the keys should exactly match
3358 with the tags defined in url. The scope of the properties
3359 object is per HTTP call. Hence, key/value pairs set
3360 in the properties object by task are only available
3361 for that specific HTTP call.
3362 The httpCodeFilter is used for filtering the status
3363 code, and it can be configured as a regular expression
3364 string. The default httpCodeFilter is "[2][0-9][0-9]"
3365 - for successful response codes.
3366 The response with HTTP status code that matches the
3367 given regular expression is forwarded to the task,
3368 otherwise it is logged as a failure.
ramverma3b71c972019-07-10 11:25:37 +00003369
3370 .. container:: listingblock
3371
3372 .. container:: content
3373
ramverma760cce92019-07-11 12:57:49 +00003374 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003375
3376 "carrierTechnologyParameters": {
3377 "carrierTechnology": "RESTREQUESTOR", (1)
3378 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
3379 "parameters": {
3380 "url": "http://localhost:54321/some/path/to/rest/resource", (2)
ning.xi8bc537d2019-07-18 07:50:10 +00003381 "url": "http://localhost:54321/{site}/path/to/rest/{resValue}", (2')
ramverma3b71c972019-07-10 11:25:37 +00003382 "httpMethod": "POST", (3)
liamfallon75e2bbf2020-07-06 11:41:38 +01003383 "requestorMode": true, (4)
3384 "requestorPeer": "GuardRequestorProducer", (5)
3385 "restRequestTimeout": 2000, (6)
3386 "httpCodeFilter" : "[2][0-9][0-9]" (7)
3387 "httpHeaders" : [ (8)
3388 ["Keep-Alive", "300"],
3389 ["Cache-Control", "no-cache"]
3390 ] }
ramverma3b71c972019-07-10 11:25:37 +00003391 },
3392
3393 .. container:: colist arabic
3394
3395 +-------+--------------------------------------------------+
3396 | **1** | set REST requestor as carrier technology |
3397 +-------+--------------------------------------------------+
ning.xi8bc537d2019-07-18 07:50:10 +00003398 | **2** | the static URL of the HTTP server for events |
3399 +-------+--------------------------------------------------+
3400 | **2'**| the tagged URL of the HTTP server for events |
ramverma3b71c972019-07-10 11:25:37 +00003401 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003402 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3403 | | optional, defaults to GET |
ramverma3b71c972019-07-10 11:25:37 +00003404 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003405 | **4** | requestor mode must be set to *true* |
ramverma3b71c972019-07-10 11:25:37 +00003406 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003407 | **5** | the peered producer for REST requests, that |
3408 | | producer specifies the APEX output event that |
3409 | | triggers the REST request |
3410 +-------+--------------------------------------------------+
3411 | **6** | request timeout in milliseconds, overrides any |
3412 | | value set in the REST Requestor Producer, |
3413 | | optional, defaults to 500 millisconds |
3414 +-------+--------------------------------------------------+
3415 | **7** | use HTTP CODE FILTER for filtering status code |
3416 | | optional, defaults to [2][0-9][0-9] |
3417 +-------+--------------------------------------------------+
3418 | **8** | HTTP headers to use on the REST request, |
3419 | | optional |
Henry.Sun2941bc02019-07-22 08:32:32 +00003420 +-------+--------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003421
3422 .. container:: paragraph
3423
liamfallon75e2bbf2020-07-06 11:41:38 +01003424 Further settings may be required on the consumer to
3425 define the input event that is produced and forwarded into
3426 APEX, for example:
ramverma3b71c972019-07-10 11:25:37 +00003427
3428 .. container:: listingblock
3429
3430 .. container:: content
3431
ramverma760cce92019-07-11 12:57:49 +00003432 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003433
3434 "eventName": "GuardResponseEvent", (1)
liamfallon75e2bbf2020-07-06 11:41:38 +01003435 "eventNameFilter": "GuardResponseEvent" (2)
ramverma3b71c972019-07-10 11:25:37 +00003436
3437 .. container:: colist arabic
3438
3439 +-------+---------------------------+
3440 | **1** | the event name |
3441 +-------+---------------------------+
3442 | **2** | a filter on the event |
3443 +-------+---------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003444
a.sreekumarcc0e9172020-03-16 13:36:45 +00003445gRPC IO
3446#######
3447
3448 .. container:: paragraph
3449
3450 APEX can send requests over gRPC at the output side, and get back
3451 response at the input side. This can be used to send requests to CDS
3452 over gRPC. The media type is ``application/json``, so this plugin
3453 only works with the JSON Event protocol.
3454
3455gRPC Output
3456===========
3457
3458 .. container:: paragraph
3459
3460 APEX will connect to a given host to send a request over
3461 gRPC.
3462
3463 .. container:: listingblock
3464
3465 .. container:: content
3466
3467 .. code::
3468
3469 "carrierTechnologyParameters": {
3470 "carrierTechnology": "GRPC", (1)
3471 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
3472 "parameters": {
3473 "host": "cds-blueprints-processor-grpc", (2)
3474 "port": 9111, (2')
3475 "username": "ccsdkapps", (3)
3476 "password": ccsdkapps, (4)
3477 "timeout" : 10 (5)
3478 }
3479 },
3480
3481 .. container:: colist arabic
3482
3483 +-------+--------------------------------------------------+
3484 | **1** | set GRPC as carrier technology |
3485 +-------+--------------------------------------------------+
3486 | **2** | the host to which request is sent |
3487 +-------+--------------------------------------------------+
3488 | **2'**| the value for port |
3489 +-------+--------------------------------------------------+
3490 | **3** | username required to initiate connection |
3491 +-------+--------------------------------------------------+
3492 | **4** | password required to initiate connection |
3493 +-------+--------------------------------------------------+
3494 | **5** | the timeout value for completing the request |
3495 +-------+--------------------------------------------------+
3496
3497 .. container:: paragraph
3498
3499 Further settings are required on the producer to
3500 define the event that is requested, for example:
3501
3502 .. container:: listingblock
3503
3504 .. container:: content
3505
3506 .. code::
3507
3508 "eventName": "GRPCRequestEvent", (1)
3509 "eventNameFilter": "GRPCRequestEvent", (2)
3510 "requestorMode": true, (3)
3511 "requestorPeer": "GRPCRequestConsumer", (4)
3512 "requestorTimeout": 500 (5)
3513
3514 .. container:: colist arabic
3515
3516 +-------+---------------------------+
3517 | **1** | the event name |
3518 +-------+---------------------------+
3519 | **2** | a filter on the event |
3520 +-------+---------------------------+
3521 | **3** | the mode of the requestor |
3522 +-------+---------------------------+
3523 | **4** | a peer for the requestor |
3524 +-------+---------------------------+
3525 | **5** | a general request timeout |
3526 +-------+---------------------------+
3527
3528gRPC Input
3529==========
3530
3531 .. container:: paragraph
3532
3533 APEX will connect to the host specified in the producer
3534 side, anad take in response back at the consumer side.
3535
3536 .. container:: listingblock
3537
3538 .. container:: content
3539
3540 .. code::
3541
3542 "carrierTechnologyParameters": {
3543 "carrierTechnology": "GRPC", (1)
3544 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
3545 },
3546
3547 .. container:: colist arabic
3548
3549 +-------+------------------------------------------+
3550 | **1** | set GRPC as carrier technology |
3551 +-------+------------------------------------------+
3552
3553 .. container:: paragraph
3554
3555 Further settings are required on the consumer to
3556 define the event that is requested, for example:
3557
3558 .. container:: listingblock
3559
3560 .. container:: content
3561
3562 .. code::
3563
3564 "eventNameFilter": "GRPCResponseEvent", (1)
3565 "requestorMode": true, (2)
3566 "requestorPeer": "GRPCRequestProducer", (3)
3567 "requestorTimeout": 500 (4)
3568
3569 .. container:: colist arabic
3570
3571 +-------+---------------------------+
3572 | **1** | a filter on the event |
3573 +-------+---------------------------+
3574 | **2** | the mode of the requestor |
3575 +-------+---------------------------+
3576 | **3** | a peer for the requestor |
3577 +-------+---------------------------+
3578 | **4** | a general request timeout |
3579 +-------+---------------------------+
3580
ramverma3b71c972019-07-10 11:25:37 +00003581Event Protocols, Format and Encoding
3582------------------------------------
3583
3584 .. container:: paragraph
3585
3586 Event protocols define what event formats APEX can receive
3587 (input) and should send (output). They can be used in any
3588 combination for input and output, unless further restricted
3589 by a carrier technology plugin (for instance for JMS
3590 output). There can only be 1 event protocol per event
3591 plugin.
3592
3593 .. container:: paragraph
3594
3595 Supported *input* event protocols are:
3596
3597 .. container:: ulist
3598
3599 - JSON, the event as a JSON string
3600
3601 - APEX, an APEX event
3602
3603 - JMS object, the event as a JMS object,
3604
3605 - JMS text, the event as a JMS text,
3606
3607 - XML, the event as an XML string,
3608
3609 - YAML, the event as YAML text
3610
3611 .. container:: paragraph
3612
3613 Supported *output* event protocols are:
3614
3615 .. container:: ulist
3616
3617 - JSON, the event as a JSON string
3618
3619 - APEX, an APEX event
3620
3621 - JMS object, the event as a JMS object,
3622
3623 - JMS text, the event as a JMS text,
3624
3625 - XML, the event as an XML string,
3626
3627 - YAML, the event as YAML text
3628
3629 .. container:: paragraph
3630
3631 New event protocols can be added as plugins to APEX or
3632 developed outside APEX and added to an APEX deployment.
3633
3634JSON Event
3635##########
3636
3637 .. container:: paragraph
3638
3639 The event protocol for JSON encoding does not require a
3640 specific plugin, it is supported by default. Furthermore,
3641 there is no difference in the configuration for the input
3642 and output interface.
3643
3644 .. container:: paragraph
3645
3646 For an input, APEX requires a well-formed JSON string.
3647 Well-formed here means according to the definitions of a
3648 policy. Any JSON string that is not defined as a trigger
3649 event (consume) will not be consumed (errors will be
3650 thrown). For output JSON events, APEX will always produce
3651 valid JSON strings according to the definition in the
3652 policy model.
3653
3654 .. container:: paragraph
3655
3656 The following JSON shows the configuration.
3657
3658 .. container:: listingblock
3659
3660 .. container:: content
3661
ramverma760cce92019-07-11 12:57:49 +00003662 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003663
3664 "eventProtocolParameters":{
3665 "eventProtocol" : "JSON"
3666 }
3667
3668 .. container:: paragraph
3669
3670 For JSON events, there are a few more optional
3671 parameters, which allow to define a mapping for standard
3672 event fields. An APEX event must have the fields
3673 ``name``, ``version``, ``source``, and ``target``
3674 defined. Sometimes it is not possible to configure a
3675 trigger or actioning system to use those fields. However,
3676 they might be in an event generated outside APEX (or used
3677 outside APEX) just with different names. To configure
3678 APEX to map between the different event names, simply add
3679 the following parameters to a JSON event:
3680
3681 .. container:: listingblock
3682
3683 .. container:: content
3684
ramverma760cce92019-07-11 12:57:49 +00003685 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003686
3687 "eventProtocolParameters":{
3688 "eventProtocol" : "JSON",
3689 "nameAlias" : "policyName", (1)
3690 "versionAlias" : "policyVersion", (2)
3691 "sourceAlias" : "from", (3)
3692 "targetAlias" : "to", (4)
3693 "nameSpaceAlias": "my.name.space" (5)
3694 }
3695
3696 .. container:: colist arabic
3697
3698 +-----------------------------------+-----------------------------------+
3699 | **1** | mapping for the ``name`` field, |
3700 | | here from a field called |
3701 | | ``policyName`` |
3702 +-----------------------------------+-----------------------------------+
3703 | **2** | mapping for the ``version`` |
3704 | | field, here from a field called |
3705 | | ``policyVersion`` |
3706 +-----------------------------------+-----------------------------------+
3707 | **3** | mapping for the ``source`` field, |
3708 | | here from a field called ``from`` |
3709 | | (only for an input event) |
3710 +-----------------------------------+-----------------------------------+
3711 | **4** | mapping for the ``target`` field, |
3712 | | here from a field called ``to`` |
3713 | | (only for an output event) |
3714 +-----------------------------------+-----------------------------------+
3715 | **5** | mapping for the ``nameSpace`` |
3716 | | field, here from a field called |
3717 | | ``my.name.space`` |
3718 +-----------------------------------+-----------------------------------+
3719
3720APEX Event
3721##########
3722 .. container:: paragraph
3723
3724 The event protocol for APEX events does not require a
3725 specific plugin, it is supported by default. Furthermore,
3726 there is no difference in the configuration for the input
3727 and output interface.
3728
3729 .. container:: paragraph
3730
3731 For input and output APEX uses APEX events.
3732
3733 .. container:: paragraph
3734
3735 The following JSON shows the configuration.
3736
3737 .. container:: listingblock
3738
3739 .. container:: content
3740
ramverma760cce92019-07-11 12:57:49 +00003741 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003742
3743 "eventProtocolParameters":{
3744 "eventProtocol" : "APEX"
3745 }
3746
3747JMS Event
3748#########
3749
3750 .. container:: paragraph
3751
3752 The event protocol for JMS is provided by the APEX JMS
3753 plugin. The plugin supports encoding as JSON text or as
3754 object. There is no difference in the configuration for
3755 the input and output interface.
3756
3757JMS Text
3758========
3759 .. container:: paragraph
3760
3761 If used as input, APEX will take a JMS message and
3762 extract a JSON string, then proceed as if a JSON event
3763 was received. If used as output, APEX will take the
3764 event produced by a policy, create a JSON string, and
3765 then wrap it into a JMS message.
3766
3767 .. container:: paragraph
3768
3769 The configuration for JMS text is as follows:
3770
3771 .. container:: listingblock
3772
3773 .. container:: content
3774
ramverma760cce92019-07-11 12:57:49 +00003775 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003776
3777 "eventProtocolParameters":{
3778 "eventProtocol" : "JMSTEXT",
3779 "parameterClassName" :
3780 "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters"
3781 }
3782
3783JMS Object
3784==========
3785 .. container:: paragraph
3786
3787 If used as input, APEX will will take a JMS message,
3788 extract a Java Bean from the ``ObjectMessage``
3789 message, construct an APEX event and put the bean on
3790 the APEX event as a parameter. If used as output, APEX
3791 will take the event produced by a policy, create a
3792 Java Bean and send it as a JMS message.
3793
3794 .. container:: paragraph
3795
3796 The configuration for JMS object is as follows:
3797
3798 .. container:: listingblock
3799
3800 .. container:: content
3801
ramverma760cce92019-07-11 12:57:49 +00003802 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003803
3804 "eventProtocolParameters":{
3805 "eventProtocol" : "JMSOBJECT",
3806 "parameterClassName" :
3807 "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters"
3808 }
3809
3810YAML Event
3811##########
3812
3813 .. container:: paragraph
3814
3815 The event protocol for YAML is provided by the APEX YAML
3816 plugin. There is no difference in the configuration for
3817 the input and output interface.
3818
3819 .. container:: paragraph
3820
3821 If used as input, APEX will consume events as YAML and
3822 map them to policy trigger events. Not well-formed YAML
3823 and not understood trigger events will be rejected. If
3824 used as output, APEX produce YAML encoded events from the
3825 event a policy produces. Those events will always be
3826 well-formed according to the definition in the policy
3827 model.
3828
3829 .. container:: paragraph
3830
3831 The following code shows the configuration.
3832
3833 .. container:: listingblock
3834
3835 .. container:: content
3836
ramverma760cce92019-07-11 12:57:49 +00003837 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003838
3839 "eventProtocolParameters":{
3840 "eventProtocol" : "XML",
3841 "parameterClassName" :
3842 "org.onap.policy.apex.plugins.event.protocol.yaml.YamlEventProtocolParameters"
3843 }
3844
3845XML Event
3846#########
3847 .. container:: paragraph
3848
3849 The event protocol for XML is provided by the APEX XML
3850 plugin. There is no difference in the configuration for
3851 the input and output interface.
3852
3853 .. container:: paragraph
3854
3855 If used as input, APEX will consume events as XML and map
3856 them to policy trigger events. Not well-formed XML and
3857 not understood trigger events will be rejected. If used
3858 as output, APEX produce XML encoded events from the event
3859 a policy produces. Those events will always be
3860 well-formed according to the definition in the policy
3861 model.
3862
3863 .. container:: paragraph
3864
3865 The following code shows the configuration.
3866
3867 .. container:: listingblock
3868
3869 .. container:: content
3870
ramverma760cce92019-07-11 12:57:49 +00003871 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003872
3873 "eventProtocolParameters":{
3874 "eventProtocol" : "XML",
3875 "parameterClassName" :
3876 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3877 }
3878
3879A configuration example
3880-----------------------
3881
3882 .. container:: paragraph
3883
3884 The following example loads all available plug-ins.
3885
3886 .. container:: paragraph
3887
3888 Events are consumed from a Websocket, APEX as client.
3889 Consumed event format is JSON.
3890
3891 .. container:: paragraph
3892
3893 Events are produced to Kafka. Produced event format is XML.
3894
3895 .. container:: listingblock
3896
3897 .. container:: content
3898
ramverma760cce92019-07-11 12:57:49 +00003899 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003900
3901 {
3902 "engineServiceParameters" : {
3903 "name" : "MyApexEngine",
3904 "version" : "0.0.1",
3905 "id" : 45,
3906 "instanceCount" : 4,
3907 "deploymentPort" : 12345,
ramverma3b71c972019-07-10 11:25:37 +00003908 "engineParameters" : {
3909 "executorParameters" : {
3910 "JAVASCRIPT" : {
3911 "parameterClassName" :
3912 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
3913 },
3914 "JYTHON" : {
3915 "parameterClassName" :
3916 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
3917 },
3918 "JRUBY" : {
3919 "parameterClassName" :
3920 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
3921 },
3922 "JAVA" : {
3923 "parameterClassName" :
3924 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
3925 },
3926 "MVEL" : {
3927 "parameterClassName" :
3928 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
3929 }
3930 },
3931 "contextParameters" : {
3932 "parameterClassName" :
3933 "org.onap.policy.apex.context.parameters.ContextParameters",
3934 "schemaParameters" : {
3935 "Avro":{
3936 "parameterClassName" :
3937 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
3938 }
3939 }
3940 }
3941 }
3942 },
3943 "producerCarrierTechnologyParameters" : {
3944 "carrierTechnology" : "KAFKA",
3945 "parameterClassName" :
3946 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
3947 "parameters" : {
3948 "bootstrapServers" : "localhost:49092",
3949 "acks" : "all",
3950 "retries" : 0,
3951 "batchSize" : 16384,
3952 "lingerTime" : 1,
3953 "bufferMemory" : 33554432,
3954 "producerTopic" : "apex-out",
3955 "keySerializer" : "org.apache.kafka.common.serialization.StringSerializer",
3956 "valueSerializer" : "org.apache.kafka.common.serialization.StringSerializer"
3957 }
3958 },
3959 "producerEventProtocolParameters" : {
3960 "eventProtocol" : "XML",
3961 "parameterClassName" :
3962 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3963 },
3964 "consumerCarrierTechnologyParameters" : {
3965 "carrierTechnology" : "WEBSOCKET",
3966 "parameterClassName" :
3967 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
3968 "parameters" : {
3969 "host" : "localhost",
3970 "port" : 88888
3971 }
3972 },
3973 "consumerEventProtocolParameters" : {
3974 "eventProtocol" : "JSON"
3975 }
3976 }
3977
3978Engine and Applications of the APEX System
3979^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3980
3981Introduction to APEX Engine and Applications
3982--------------------------------------------
3983
3984 .. container:: paragraph
3985
3986 The core of APEX is the APEX Engine, also known as the APEX
3987 Policy Engine or the APEX PDP (since it is in fact a Policy
3988 Decision Point). Beside this engine, an APEX system comes
3989 with a few applications intended to help with policy
3990 authoring, deployment, and execution.
3991
3992 .. container:: paragraph
3993
3994 The engine itself and most applications are started from the
3995 command line with command line arguments. This is called a
3996 Command Line Interface (CLI). Some applications require an
3997 installation on a webserver, as for instance the REST
3998 Editor. Those applications can be accessed via a web
3999 browser.
4000
4001 .. container:: paragraph
4002
4003 You can also use the available APEX APIs and applications to
4004 develop other applications as required. This includes policy
4005 languages (and associated parsers and compilers /
4006 interpreters), GUIs to access APEX or to define policies,
4007 clients to connect to APEX, etc.
4008
4009 .. container:: paragraph
4010
4011 For this documentation, we assume an installation of APEX as
4012 a full system based on a current ONAP release.
4013
4014CLI on Unix, Windows, and Cygwin
4015--------------------------------
4016
4017 .. container:: paragraph
4018
4019 A note on APEX CLI applications: all applications and the
4020 engine itself have been deployed and tested on different
4021 operating systems: Red Hat, Ubuntu, Debian, Mac OSX,
4022 Windows, Cygwin. Each operating system comes with its own
4023 way of configuring and executing Java. The main items here
4024 are:
4025
4026 .. container:: ulist
4027
4028 - For UNIX systems (RHL, Ubuntu, Debian, Mac OSX), the
4029 provided bash scripts work as expected with absolute
4030 paths (e.g.
4031 ``/opt/app/policy/apex-pdp/apex-pdp-2.0.0-SNAPSHOT/examples``),
4032 indirect and linked paths (e.g. ``../apex/apex``), and
4033 path substitutions using environment settings (e.g.
4034 ``$APEX_HOME/bin/``)
4035
4036 - For Windows systems, the provided batch files (``.bat``)
4037 work as expected with with absolute paths (e.g.
4038 ``C:\apex\apex-2.0.0-SNAPSHOT\examples``), and path
4039 substitutions using environment settings (e.g.
4040 ``%APEX_HOME%\bin\``)
4041
4042 - For Cygwin system we assume a standard Cygwin
4043 installation with standard tools (mainly bash) using a
4044 Windows Java installation. This means that the bash
4045 scripts can be used as in UNIX, however any argument
4046 pointing to files and directories need to use either a
4047 DOS path (e.g.
4048 ``C:\apex\apex-2.0.0-SNAPSHOT\examples\config...``) or
4049 the command ``cygpath`` with a mixed option. The reason
4050 for that is: Cygwin executes Java using UNIX paths but
4051 then runs Java as a DOS/WINDOWS process, which requires
4052 DOS paths for file access.
4053
4054The APEX Engine
4055---------------
4056
4057 .. container:: paragraph
4058
4059 The APEX engine can be started in different ways, depending
4060 your requirements. All scripts are located in the APEX *bin*
4061 directory
4062
4063 .. container:: paragraph
4064
4065 On UNIX and Cygwin systems use:
4066
4067 .. container:: ulist
4068
4069 - ``apexEngine.sh`` - this script will
4070
4071 .. container:: ulist
4072
4073 - Test if ``$APEX_USER`` is set and if the user
4074 exists, terminate with an error otherwise
4075
4076 - Test if ``$APEX_HOME`` is set. If not set, it will
4077 use the default setting as
4078 ``/opt/app/policy/apex-pdp/apex-pdp``. Then the set
4079 directory is tested to exist, the script will
4080 terminate if not.
4081
4082 - When all tests are passed successfully, the script
4083 will call ``apexApps.sh`` with arguments to start
4084 the APEX engine.
4085
4086 - ``apexApps.sh engine`` - this is the general APEX
4087 application launcher, which will
4088
4089 .. container:: ulist
4090
4091 - Start the engine with the argument ``engine``
4092
4093 - Test if ``$APEX_HOME`` is set and points to an
4094 existing directory. If not set or directory does
4095 not exist, script terminates.
4096
4097 - Not test for any settings of ``$APEX_USER``.
4098
4099 .. container:: paragraph
4100
4101 On Windows systems use ``apexEngine.bat`` and
4102 ``apexApps.bat engine`` respectively. Note: none of the
4103 windows batch files will test for ``%APEX_USER%``.
4104
4105 .. container:: paragraph
4106
4107 Summary of alternatives to start the APEX Engine:
4108
4109 +--------------------------------------------------------+----------------------------------------------------------+
4110 | Unix, Cygwin | Windows |
4111 +========================================================+==========================================================+
4112 | .. container:: | .. container:: |
4113 | | |
4114 | .. container:: listingblock | .. container:: listingblock |
4115 | | |
4116 | .. container:: content | .. container:: content |
4117 | | |
4118 | .. code:: | .. code:: |
4119 | | |
4120 | # $APEX_HOME/bin/apexEngine.sh [args] | > %APEX_HOME%\bin\apexEngine.bat [args] |
4121 | # $APEX_HOME/bin/apexApps.sh engine [args] | > %APEX_HOME%\bin\apexApps.bat engine [args] |
4122 +--------------------------------------------------------+----------------------------------------------------------+
4123
4124 .. container:: paragraph
4125
a.sreekumarcf3ff822020-09-16 13:12:29 +01004126 The APEX engine comes with a few CLI arguments, the main one is for setting
4127 the tosca policy file for execution. The tosca policy file is
4128 always required. The option ``-h`` prints a help screen.
ramverma3b71c972019-07-10 11:25:37 +00004129
4130 .. container:: listingblock
4131
4132 .. container:: content
4133
ramverma760cce92019-07-11 12:57:49 +00004134 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004135
4136 usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]
4137 options
a.sreekumarcf3ff822020-09-16 13:12:29 +01004138 -p,--tosca-policy-file <TOSCA_POLICY_FILE> the full path to the ToscaPolicy file to use.
4139 -h,--help outputs the usage of this command
4140 -v,--version outputs the version of Apex
ramverma3b71c972019-07-10 11:25:37 +00004141
4142The APEX CLI Editor
4143-------------------
4144
4145 .. container:: paragraph
4146
4147 The CLI Editor allows to define policies from the command
4148 line. The application uses a simple language and supports
4149 all elements of an APEX policy. It can be used in to
4150 different ways:
4151
4152 .. container:: ulist
4153
4154 - non-interactive, specifying a file with the commands to
4155 create a policy
4156
4157 - interactive, using the editors CLI to create a policy
4158
4159 .. container:: paragraph
4160
4161 When a policy is fully specified, the editor will generate
4162 the APEX core policy specification in JSON. This core
4163 specification is called the policy model in the APEX engine
4164 and can be used directly with the APEX engine.
4165
4166 .. container:: paragraph
4167
4168 On UNIX and Cygwin systems use:
4169
4170 .. container:: ulist
4171
4172 - ``apexCLIEditor.sh`` - simply starts the CLI editor,
4173 arguments to the script determine the mode of the editor
4174
4175 - ``apexApps.sh cli-editor`` - simply starts the CLI
4176 editor, arguments to the script determine the mode of the
4177 editor
4178
4179 .. container:: paragraph
4180
4181 On Windows systems use:
4182
4183 .. container:: ulist
4184
4185 - ``apexCLIEditor.bat`` - simply starts the CLI editor,
4186 arguments to the script determine the mode of the editor
4187
4188 - ``apexApps.bat cli-editor`` - simply starts the CLI
4189 editor, arguments to the script determine the mode of the
4190 editor
4191
4192 .. container:: paragraph
4193
4194 Summary of alternatives to start the APEX CLI Editor:
4195
4196 +------------------------------------------------------------+--------------------------------------------------------------+
4197 | Unix, Cygwin | Windows |
4198 +============================================================+==============================================================+
4199 | .. container:: | .. container:: |
4200 | | |
4201 | .. container:: listingblock | .. container:: listingblock |
4202 | | |
4203 | .. container:: content | .. container:: content |
4204 | | |
4205 | .. code:: | .. code:: |
4206 | | |
4207 | # $APEX_HOME/bin/apexCLIEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIEditor.bat [args] |
4208 | # $APEX_HOME/bin/apexApps.sh cli-editor [args] | > %APEX_HOME%\bin\apexApps.bat cli-editor [args] |
4209 +------------------------------------------------------------+--------------------------------------------------------------+
4210
4211 .. container:: paragraph
4212
4213 The option ``-h`` provides a help screen with all command
4214 line arguments.
4215
4216 .. container:: listingblock
4217
4218 .. container:: content
4219
ramverma760cce92019-07-11 12:57:49 +00004220 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004221
4222 usage: org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain [options...]
4223 options
4224 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4225 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4226 -h,--help outputs the usage of this command
4227 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4228 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and continue
4229 executing the command file
4230 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will log
4231 to standard output if not specified or suppressed with "-nl" flag
4232 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4233 -nl,--no-log if specified, no logging or output of commands to standard output or log
4234 file is carried out
4235 -nm,--no-model-output if specified, no output of a model to standard output or model output
4236 file is carried out, the user can use the "save" command in a script to
4237 save a model
4238 -o,--output-model-file <OUTPUT_MODEL_FILE> name of a file that will contain the output model for the editor, will
4239 output model to standard output if not specified or suppressed with
4240 "-nm" flag
4241 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4242 root from which to look for included macro files
4243
a.sreekumar717a24a2019-07-26 13:47:42 +00004244The APEX CLI Tosca Editor
4245-------------------------
4246
4247 .. container:: paragraph
4248
4249 As per the new Policy LifeCycle API, the policies are expected to be defined as ToscaServiceTemplate. The CLI Tosca Editor is an extended version of the APEX CLI Editor which can generate the policies in ToscaServiceTemplate way.
4250
4251 .. container:: paragraph
4252
4253 The APEX config file(.json), command file(.apex) and the tosca template skeleton(.json) file paths need to be passed as input arguments to the CLI Tosca Editor. Policy in ToscaServiceTemplate format is generated as the output. This can be used as the input to Policy API for creating policies.
4254
4255 .. container:: paragraph
4256
4257 On UNIX and Cygwin systems use:
4258
4259 .. container:: ulist
4260
4261 - ``apexCLIToscaEditor.sh`` - starts the CLI Tosca editor,
4262 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4263
4264 - ``apexApps.sh cli-tosca-editor`` - starts the CLI Tosca editor,
4265 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4266
4267 .. container:: paragraph
4268
4269 On Windows systems use:
4270
4271 .. container:: ulist
4272
4273 - ``apexCLIToscaEditor.bat`` - starts the CLI Tosca editor,
4274 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4275
4276 - ``apexApps.bat cli-tosca-editor`` - starts the CLI Tosca
4277 editor, all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4278
4279 .. container:: paragraph
4280
4281 Summary of alternatives to start the APEX CLI Tosca Editor:
4282
4283 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4284 | Unix, Cygwin | Windows |
4285 +=================================================================+====================================================================+
4286 | .. container:: | .. container:: |
4287 | | |
4288 | .. container:: listingblock | .. container:: listingblock |
4289 | | |
4290 | .. container:: content | .. container:: content |
4291 | | |
4292 | .. code:: | .. code:: |
4293 | | |
4294 | # $APEX_HOME/bin/apexCLIToscaEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIToscaEditor.bat [args] |
4295 | # $APEX_HOME/bin/apexApps.sh cli-tosca-editor [args]| > %APEX_HOME%\bin\apexApps.bat cli-tosca-editor [args] |
4296 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4297
4298 .. container:: paragraph
4299
4300 The option ``-h`` provides a help screen with all command
4301 line arguments.
4302
4303 .. container:: listingblock
4304
4305 .. container:: content
4306
4307 .. code::
4308
4309 usage: org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain [options...]
4310 options
4311 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4312 -ac,--apex-config-file <APEX_CONFIG_FILE> name of the file containing apex configuration details
4313 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4314 -h,--help outputs the usage of this command
4315 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4316 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and
4317 continue executing the command file
4318 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will
4319 log to standard output if not specified or suppressed with "-nl" flag
4320 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4321 -nl,--no-log if specified, no logging or output of commands to standard output or
4322 log file is carried out
4323 -ot,--output-tosca-file <OUTPUT_TOSCA_FILE> name of a file that will contain the output ToscaServiceTemplate
4324 -t,--tosca-template-file <TOSCA_TEMPLATE_FILE> name of the input file containing tosca template which needs to be
4325 updated with policy
4326 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4327 root from which to look for included macro files
4328
4329 .. container:: paragraph
4330
4331 An example command to run the APEX CLI Tosca editor on windows machine is given below.
4332
4333 .. container:: listingblock
4334
4335 .. container:: content
4336
4337 .. code::
4338
4339 %APEX_HOME%/\bin/\apexCLIToscaEditor.bat -c %APEX_HOME%\examples\PolicyModel.apex -ot %APEX_HOME%\examples\test.json -l %APEX_HOME%\examples\test.log -ac %APEX_HOME%\examples\RESTServerStandaloneJsonEvent.json -t %APEX_HOME%\examples\ToscaTemplate.json
4340
liamfallon75e2bbf2020-07-06 11:41:38 +01004341
4342The APEX Client
liamfallonb621de42020-08-21 12:59:26 +01004343---------------
ramverma3b71c972019-07-10 11:25:37 +00004344
4345 .. container:: paragraph
4346
liamfallon75e2bbf2020-07-06 11:41:38 +01004347 The APEX Client combines the Policy Editor, the
ramverma3b71c972019-07-10 11:25:37 +00004348 Monitoring Client, and the Deployment Client into a single
4349 application. The standard way to use the APEX Full Client is
4350 via an installation of the *war* file on a webserver.
4351 However, the Full Client can also be started via command
4352 line. This will start a Grizzly webserver with the *war*
4353 deployed. Access to the Full Client is then via the provided
4354 URL
4355
4356 .. container:: paragraph
4357
4358 On UNIX and Cygwin systems use:
4359
4360 .. container:: ulist
4361
4362 - ``apexApps.sh full-client`` - simply starts the webserver
4363 with the Full Client
4364
4365 .. container:: paragraph
4366
4367 On Windows systems use:
4368
4369 .. container:: ulist
4370
4371 - ``apexApps.bat full-client`` - simply starts the
4372 webserver with the Full Client
4373
4374 .. container:: paragraph
4375
4376 The option ``-h`` provides a help screen with all command
4377 line arguments.
4378
4379 .. container:: listingblock
4380
4381 .. container:: content
4382
ramverma760cce92019-07-11 12:57:49 +00004383 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004384
4385 usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]
4386 -h,--help outputs the usage of this command
4387 -p,--port <PORT> port to use for the Apex Services REST calls
4388 -t,--time-to-live <TIME_TO_LIVE> the amount of time in seconds that the server will run for before terminating
4389
4390 .. container:: paragraph
4391
4392 If the Full Client is started without any arguments the
4393 final messages will look similar to this:
4394
4395 .. container:: listingblock
4396
4397 .. container:: content
4398
ramverma760cce92019-07-11 12:57:49 +00004399 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004400
4401 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
4402 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.NetworkListener start
4403 INFO: Started listener bound to [localhost:18989]
4404 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.HttpServer start
4405 INFO: [HttpServer] Started.
4406 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
4407
4408 .. container:: paragraph
4409
4410 The last line states the URL on which the Monitoring Client
4411 can be accessed. The example above stated
4412 ``http://localhost:18989/apexservices``. In a web browser
4413 use the URL ``http://localhost:18989``.
4414
aditya.puthuparambil9e67eb72020-04-30 15:59:43 +01004415The APEX Application Launcher
4416-----------------------------
ramverma3b71c972019-07-10 11:25:37 +00004417
4418 .. container:: paragraph
4419
liamfallon75e2bbf2020-07-06 11:41:38 +01004420 The standard applications (Engine and CLI Editor)
ramverma3b71c972019-07-10 11:25:37 +00004421 come with dedicated start scripts. For all other APEX
4422 applications, we provide an application launcher.
4423
4424 .. container:: paragraph
4425
4426 On UNIX and Cygwin systems use:
4427
4428 .. container:: ulist
4429
4430 - apexApps.sh\` - simply starts the application launcher
4431
4432 .. container:: paragraph
4433
4434 On Windows systems use:
4435
4436 .. container:: ulist
4437
4438 - ``apexApps.bat`` - simply starts the application launcher
4439
4440 .. container:: paragraph
4441
4442 Summary of alternatives to start the APEX application
4443 launcher:
4444
4445 +-------------------------------------------------+---------------------------------------------------+
4446 | Unix, Cygwin | Windows |
4447 +=================================================+===================================================+
4448 | .. container:: | .. container:: |
4449 | | |
4450 | .. container:: listingblock | .. container:: listingblock |
4451 | | |
4452 | .. container:: content | .. container:: content |
4453 | | |
4454 | .. code:: | .. code:: |
4455 | | |
4456 | # $APEX_HOME/bin/apexApps.sh [args] | > %APEX_HOME%\bin\apexApps.bat [args] |
4457 +-------------------------------------------------+---------------------------------------------------+
4458
4459 .. container:: paragraph
4460
4461 The option ``-h`` provides a help screen with all launcher
4462 command line arguments.
4463
4464 .. container:: listingblock
4465
4466 .. container:: content
4467
ramverma760cce92019-07-11 12:57:49 +00004468 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004469
4470 apexApps.sh - runs APEX applications
4471
4472 Usage: apexApps.sh [options] | [<application> [<application options>]]
4473
4474 Options
4475 -d <app> - describes an application
4476 -l - lists all applications supported by this script
4477 -h - this help screen
4478
4479 .. container:: paragraph
4480
4481 Using ``-l`` lists all known application the launcher can
4482 start.
4483
4484 .. container:: listingblock
4485
4486 .. container:: content
4487
ramverma760cce92019-07-11 12:57:49 +00004488 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004489
4490 apexApps.sh: supported applications:
4491 --> ws-echo engine eng-monitoring full-client eng-deployment tpl-event-json model-2-cli rest-editor cli-editor ws-console
4492
4493 .. container:: paragraph
4494
4495 Using the ``-d <name>`` option describes the named
4496 application, for instance for the ``ws-console``:
4497
4498 .. container:: listingblock
4499
4500 .. container:: content
4501
ramverma760cce92019-07-11 12:57:49 +00004502 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004503
4504 apexApps.sh: application 'ws-console'
4505 --> a simple console sending events to APEX, connect to APEX consumer port
4506
4507 .. container:: paragraph
4508
4509 Launching an application is done by calling the script with
4510 only the application name and any CLI arguments for the
4511 application. For instance, starting the ``ws-echo``
4512 application with port ``8888``:
4513
4514 .. container:: listingblock
4515
4516 .. container:: content
4517
ramverma760cce92019-07-11 12:57:49 +00004518 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004519
4520 apexApps.sh ws-echo -p 8888
4521
4522Application: Create Event Templates
4523-----------------------------------
4524
4525 .. container:: paragraph
4526
4527 **Status: Experimental**
4528
4529 .. container:: paragraph
4530
4531 This application takes a policy model (JSON or XML encoded)
4532 and generates templates for events in JSON format. This can
4533 help when a policy defines rather complex trigger or action
4534 events or complex events between states. The application can
4535 produce events for the types: stimuli (policy trigger
4536 events), internal (events between policy states), and
4537 response (action events).
4538
4539 +----------------------------------------------------------------+------------------------------------------------------------------+
4540 | Unix, Cygwin | Windows |
4541 +================================================================+==================================================================+
4542 | .. container:: | .. container:: |
4543 | | |
4544 | .. container:: listingblock | .. container:: listingblock |
4545 | | |
4546 | .. container:: content | .. container:: content |
4547 | | |
4548 | .. code:: | .. code:: |
4549 | | |
4550 | # $APEX_HOME/bin/apexApps.sh tpl-event-json [args] | > %APEX_HOME%\bin\apexApps.bat tpl-event-json [args] |
4551 +----------------------------------------------------------------+------------------------------------------------------------------+
4552
4553 .. container:: paragraph
4554
4555 The option ``-h`` provides a help screen.
4556
4557 .. container:: listingblock
4558
4559 .. container:: content
4560
ramverma760cce92019-07-11 12:57:49 +00004561 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004562
4563 gen-model2event v{release-version} - generates JSON templates for events generated from a policy model
4564 usage: gen-model2event
4565 -h,--help prints this help and usage screen
4566 -m,--model <MODEL-FILE> set the input policy model file
4567 -t,--type <TYPE> set the event type for generation, one of:
4568 stimuli (trigger events), response (action
4569 events), internal (events between states)
4570 -v,--version prints the application version
4571
4572 .. container:: paragraph
4573
4574 The created templates are not valid events, instead they use
4575 some markup for values one will need to change to actual
4576 values. For instance, running the tool with the *Sample
4577 Domain* policy model as:
4578
4579 .. container:: listingblock
4580
4581 .. container:: content
4582
ramverma760cce92019-07-11 12:57:49 +00004583 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004584
4585 apexApps.sh tpl-event-json -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json -t stimuli
4586
4587 .. container:: paragraph
4588
4589 will produce the following status messages:
4590
4591 .. container:: listingblock
4592
4593 .. container:: content
4594
ramverma760cce92019-07-11 12:57:49 +00004595 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004596
4597 gen-model2event: starting Event generator
4598 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4599 --> type: stimuli
4600
4601 .. container:: paragraph
4602
4603 and then run the generator application producing two event
4604 templates. The first template is called ``Event0000``.
4605
4606 .. container:: listingblock
4607
4608 .. container:: content
4609
4610 .. code::
4611
4612 {
4613 "name" : "Event0000",
4614 "nameSpace" : "org.onap.policy.apex.sample.events",
4615 "version" : "0.0.1",
4616 "source" : "Outside",
4617 "target" : "Match",
4618 "TestTemperature" : ###double: 0.0###,
4619 "TestTimestamp" : ###long: 0###,
4620 "TestMatchCase" : ###integer: 0###,
4621 "TestSlogan" : "###string###"
4622 }
4623
4624 .. container:: paragraph
4625
4626 The values for the keys are marked with ``#`` and the
4627 expected type of the value. To create an actual stimuli
4628 event, all these markers need to be change to actual values,
4629 for instance:
4630
4631 .. container:: listingblock
4632
4633 .. container:: content
4634
ramverma760cce92019-07-11 12:57:49 +00004635 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004636
4637 {
4638 "name" : "Event0000",
4639 "nameSpace" : "org.onap.policy.apex.sample.events",
4640 "version" : "0.0.1",
4641 "source" : "Outside",
4642 "target" : "Match",
4643 "TestTemperature" : 25,
4644 "TestTimestamp" : 123456789123456789,
4645 "TestMatchCase" : 1,
4646 "TestSlogan" : "Testing the Match Case with Temperature 25"
4647 }
4648
4649Application: Convert a Policy Model to CLI Editor Commands
4650----------------------------------------------------------
4651
4652 .. container:: paragraph
4653
4654 **Status: Experimental**
4655
4656 .. container:: paragraph
4657
4658 This application takes a policy model (JSON or XML encoded)
4659 and generates commands for the APEX CLI Editor. This
4660 effectively reverses a policy specification realized with
4661 the CLI Editor.
4662
4663 +-------------------------------------------------------------+---------------------------------------------------------------+
4664 | Unix, Cygwin | Windows |
4665 +=============================================================+===============================================================+
4666 | .. container:: | .. container:: |
4667 | | |
4668 | .. container:: listingblock | .. container:: listingblock |
4669 | | |
4670 | .. container:: content | .. container:: content |
4671 | | |
4672 | .. code:: | .. code:: |
4673 | | |
4674 | # $APEX_HOME/bin/apexApps.sh model-2-cli [args] | > %APEX_HOME%\bin\apexApps.bat model-2-cli [args] |
4675 +-------------------------------------------------------------+---------------------------------------------------------------+
4676
4677 .. container:: paragraph
4678
4679 The option ``-h`` provides a help screen.
4680
4681 .. container:: listingblock
4682
4683 .. container:: content
4684
ramverma760cce92019-07-11 12:57:49 +00004685 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004686
4687 usage: gen-model2cli
4688 -h,--help prints this help and usage screen
4689 -m,--model <MODEL-FILE> set the input policy model file
4690 -sv,--skip-validation switch of validation of the input file
4691 -v,--version prints the application version
4692
4693 .. container:: paragraph
4694
4695 For instance, running the tool with the *Sample Domain*
4696 policy model as:
4697
4698 .. container:: listingblock
4699
4700 .. container:: content
4701
ramverma760cce92019-07-11 12:57:49 +00004702 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004703
4704 apexApps.sh model-2-cli -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json
4705
4706 .. container:: paragraph
4707
4708 will produce the following status messages:
4709
4710 .. container:: listingblock
4711
4712 .. container:: content
4713
ramverma760cce92019-07-11 12:57:49 +00004714 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004715
4716 gen-model2cli: starting CLI generator
4717 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4718
4719 .. container:: paragraph
4720
4721 and then run the generator application producing all CLI
4722 Editor commands and printing them to standard out.
4723
4724Application: Websocket Clients (Echo and Console)
4725-------------------------------------------------
4726
4727 .. container:: paragraph
4728
4729 **Status: Production**
4730
4731 .. container:: paragraph
4732
4733 The application launcher also provides a Websocket echo
4734 client and a Websocket console client. The echo client
4735 connects to APEX and prints all events it receives from
4736 APEX. The console client connects to APEX, reads input from
4737 the command line, and sends this input as events to APEX.
4738
4739 +------------------------------------------------------------+--------------------------------------------------------------+
4740 | Unix, Cygwin | Windows |
4741 +============================================================+==============================================================+
4742 | .. container:: | .. container:: |
4743 | | |
4744 | .. container:: listingblock | .. container:: listingblock |
4745 | | |
4746 | .. container:: content | .. container:: content |
4747 | | |
4748 | .. code:: | .. code:: |
4749 | | |
4750 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
4751 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
4752 +------------------------------------------------------------+--------------------------------------------------------------+
4753
4754 .. container:: paragraph
4755
4756 The arguments are the same for both applications:
4757
4758 .. container:: ulist
4759
4760 - ``-p`` defines the Websocket port to connect to (defaults
4761 to ``8887``)
4762
4763 - ``-s`` defines the host on which a Websocket server is
4764 running (defaults to ``localhost``)
4765
4766 .. container:: paragraph
4767
4768 A discussion on how to use these two applications to build
4769 an APEX system is detailed HowTo-Websockets.
4770
ramverma3b71c972019-07-10 11:25:37 +00004771APEX Logging
4772^^^^^^^^^^^^
4773
4774Introduction to APEX Logging
4775----------------------------
4776
4777 .. container:: paragraph
4778
4779 All APEX components make extensive use of logging using the
4780 logging façade `SLF4J <https://www.slf4j.org/>`__ with the
4781 backend `Logback <https://logback.qos.ch/>`__. Both are used
4782 off-the-shelve, so the standard documentation and
4783 configuration apply to APEX logging. For details on how to
4784 work with logback please see the `logback
4785 manual <https://logback.qos.ch/manual/index.html>`__.
4786
4787 .. container:: paragraph
4788
4789 The APEX applications is the logback configuration file
4790 ``$APEX_HOME/etc/logback.xml`` (Windows:
4791 ``%APEX_HOME%\etc\logback.xml``). The logging backend is set
4792 to no debug, i.e. logs from the logging framework should be
4793 hidden at runtime.
4794
4795 .. container:: paragraph
4796
4797 The configurable log levels work as expected:
4798
4799 .. container:: ulist
4800
4801 - *error* (or *ERROR*) is used for serious errors in the
4802 APEX runtime engine
4803
4804 - *warn* (or *WARN*) is used for warnings, which in general
4805 can be ignored but might indicate some deeper problems
4806
4807 - *info* (or *INFO*) is used to provide generally
4808 interesting messages for startup and policy execution
4809
4810 - *debug* (or *DEBUG*) provides more details on startup and
4811 policy execution
4812
4813 - *trace* (or *TRACE*) gives full details on every aspect
4814 of the APEX engine from start to end
4815
4816 .. container:: paragraph
4817
4818 The loggers can also be configured as expected. The standard
4819 configuration (after installing APEX) uses log level *info*
4820 on all APEX classes (components).
4821
4822 .. container:: paragraph
4823
4824 The applications and scripts in ``$APEX_HOME/bin`` (Windows:
4825 ``%APEX_HOME\bin``) are configured to use the logback
4826 configuration ``$APEX_HOME/etc/logback.xml`` (Windows:
4827 ``%APEX_HOME\etc\logback.xml``). There are multiple ways to
4828 use different logback configurations, for instance:
4829
4830 .. container:: ulist
4831
4832 - Maintain multiple configurations in ``etc``, for instance
4833 a ``logback-debug.xml`` for deep debugging and a
4834 ``logback-production.xml`` for APEX in production mode,
4835 then copy the required configuration file to the used
4836 ``logback.xml`` prior starting APEX
4837
4838 - Edit the scripts in ``bin`` to use a different logback
4839 configuration file (only recommended if you are familiar
4840 with editing bash scripts or windows batch files)
4841
4842Standard Logging Configuration
4843------------------------------
4844
4845 .. container:: paragraph
4846
4847 The standard logging configuration defines a context *APEX*,
4848 which is used in the standard output pattern. The location
liamfallon1540e472019-11-28 15:14:07 +00004849 for log files is defined in the property ``logDir`` and set
ramverma3b71c972019-07-10 11:25:37 +00004850 to ``/var/log/onap/policy/apex-pdp``. The standard status
4851 listener is set to *NOP* and the overall logback
4852 configuration is set to no debug.
4853
4854 .. container:: listingblock
4855
4856 .. container:: content
4857
ramverma760cce92019-07-11 12:57:49 +00004858 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004859 :number-lines:
4860
4861 <configuration debug="false">
4862 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
4863
4864 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00004865 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00004866
4867 ...appenders
4868 ...loggers
4869 </configuration>
4870
4871.. container:: paragraph
4872
4873 The first appender defined is called ``STDOUT`` for logs to standard
4874 out.
4875
4876.. container:: listingblock
4877
4878 .. container:: content
4879
ramverma760cce92019-07-11 12:57:49 +00004880 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004881 :number-lines:
4882
4883 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4884 <encoder>
4885 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
4886 </encoder>
4887 </appender>
4888
4889.. container:: paragraph
4890
4891 The root level logger then is set to the level *info* using the
4892 standard out appender.
4893
4894.. container:: listingblock
4895
4896 .. container:: content
4897
ramverma760cce92019-07-11 12:57:49 +00004898 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004899 :number-lines:
4900
4901 <root level="info">
4902 <appender-ref ref="STDOUT" />
4903 </root>
4904
4905.. container:: paragraph
4906
4907 The second appender is called ``FILE``. It writes logs to a file
4908 ``apex.log``.
4909
4910.. container:: listingblock
4911
4912 .. container:: content
4913
ramverma760cce92019-07-11 12:57:49 +00004914 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004915 :number-lines:
4916
4917 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00004918 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00004919 <encoder>
4920 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4921 </encoder>
4922 </appender>
4923
4924.. container:: paragraph
4925
4926 The third appender is called ``CTXT_FILE``. It writes logs to a file
4927 ``apex_ctxt.log``.
4928
4929.. container:: listingblock
4930
4931 .. container:: content
4932
ramverma760cce92019-07-11 12:57:49 +00004933 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004934 :number-lines:
4935
4936 <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00004937 <file>${logDir}/apex_ctxt.log</file>
ramverma3b71c972019-07-10 11:25:37 +00004938 <encoder>
4939 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4940 </encoder>
4941 </appender>
4942
4943.. container:: paragraph
4944
4945 The last definitions are for specific loggers. The first logger
4946 captures all standard APEX classes. It is configured for log level
4947 *info* and uses the standard output and file appenders. The second
4948 logger captures APEX context classes responsible for context
4949 monitoring. It is configured for log level *trace* and uses the
4950 context file appender.
4951
4952.. container:: listingblock
4953
4954 .. container:: content
4955
ramverma760cce92019-07-11 12:57:49 +00004956 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004957 :number-lines:
4958
4959
4960 <logger name="org.onap.policy.apex" level="info" additivity="false">
4961 <appender-ref ref="STDOUT" />
4962 <appender-ref ref="FILE" />
4963 </logger>
4964
4965 <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
4966 <appender-ref ref="CTXT_FILE" />
4967 </logger>
4968
4969Adding Logback Status and Debug
4970-------------------------------
4971
4972 .. container:: paragraph
4973
4974 To activate logback status messages change the status listener
4975 from 'NOP' to for instance console.
4976
4977 .. container:: listingblock
4978
4979 .. container:: content
4980
ramverma760cce92019-07-11 12:57:49 +00004981 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004982
4983 <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
4984
4985 .. container:: paragraph
4986
4987 To activate all logback debugging, for instance to debug a new
4988 logback configuration, activate the debug attribute in the
4989 configuration.
4990
4991 .. container:: listingblock
4992
4993 .. container:: content
4994
ramverma760cce92019-07-11 12:57:49 +00004995 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004996
4997 <configuration debug="true">
4998 ...
4999 </configuration>
5000
5001Logging External Components
5002---------------------------
5003
5004 .. container:: paragraph
5005
5006 Logback can also be configured to log any other, external
5007 components APEX is using, if they are using the common logging
5008 framework.
5009
5010 .. container:: paragraph
5011
5012 For instance, the context component of APEX is using *Infinispan*
5013 and one can add a logger for this external component. The
5014 following example adds a logger for *Infinispan* using the
5015 standard output appender.
5016
5017 .. container:: listingblock
5018
5019 .. container:: content
5020
ramverma760cce92019-07-11 12:57:49 +00005021 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005022
5023 <logger name="org.infinispan" level="INFO" additivity="false">
5024 <appender-ref ref="STDOUT" />
5025 </logger>
5026
5027 .. container:: paragraph
5028
5029 Another example is Apache Zookeeper. The following example adds a
5030 logger for Zookeeper using the standard outout appender.
5031
5032 .. container:: listingblock
5033
5034 .. container:: content
5035
ramverma760cce92019-07-11 12:57:49 +00005036 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005037
5038 <logger name="org.apache.zookeeper.ClientCnxn" level="INFO" additivity="false">
5039 <appender-ref ref="STDOUT" />
5040 </logger>
5041
5042Configuring loggers for Policy Logic
5043------------------------------------
5044
5045 .. container:: paragraph
5046
5047 The logging for the logic inside a policy (task logic, task
5048 selection logic, state finalizer logic) can be configured separate
5049 from standard logging. The logger for policy logic is
5050 ``org.onap.policy.apex.executionlogging``. The following example
5051 defines
5052
5053 .. container:: ulist
5054
5055 - a new appender for standard out using a very simple pattern
5056 (simply the actual message)
5057
5058 - a logger for policy logic to standard out using the new
5059 appender and the already described file appender.
5060
5061 .. container:: listingblock
5062
5063 .. container:: content
5064
ramverma760cce92019-07-11 12:57:49 +00005065 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005066
5067 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5068 <encoder>
5069 <pattern>policy: %msg\n</pattern>
5070 </encoder>
5071 </appender>
5072
5073 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5074 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5075 <appender-ref ref="FILE" />
5076 </logger>
5077
5078 .. container:: paragraph
5079
5080 It is also possible to use specific logging for parts of policy
5081 logic. The following example defines a logger for task logic.
5082
5083 .. container:: listingblock
5084
5085 .. container:: content
5086
ramverma760cce92019-07-11 12:57:49 +00005087 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005088
5089 <logger name="org.onap.policy.apex.executionlogging.TaskExecutionLogging" level="TRACE" additivity="false">
5090 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5091 </logger>
5092
5093Rolling File Appenders
5094----------------------
5095
5096 .. container:: paragraph
5097
5098 Rolling file appenders are a good option for more complex logging
5099 of a production or complex testing APEX installation. The standard
5100 logback configuration can be used for these use cases. This
5101 section gives two examples for the standard logging and for
5102 context logging.
5103
5104 .. container:: paragraph
5105
5106 First the standard logging. The following example defines a
5107 rolling file appender. The appender rolls over on a daily basis.
5108 It allows for a file size of 100 MB.
5109
5110 .. container:: listingblock
5111
5112 .. container:: content
5113
ramverma760cce92019-07-11 12:57:49 +00005114 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005115
5116 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005117 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005118 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5119 <!-- rollover daily -->
5120 <!-- <fileNamePattern>xstream-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> -->
liamfallon1540e472019-11-28 15:14:07 +00005121 <fileNamePattern>${logDir}/apex_%d{yyyy-MM-dd}.%i.log.gz
ramverma3b71c972019-07-10 11:25:37 +00005122 </fileNamePattern>
5123 <maxHistory>4</maxHistory>
5124 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5125 <!-- or whenever the file size reaches 100MB -->
5126 <maxFileSize>100MB</maxFileSize>
5127 </timeBasedFileNamingAndTriggeringPolicy>
5128 </rollingPolicy>
5129 <encoder>
5130 <pattern>
5131 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5132 </pattern>
5133 </encoder>
5134 </appender>
5135
5136 .. container:: paragraph
5137
5138 A very similar configuration can be used for a rolling file
5139 appender logging APEX context.
5140
5141 .. container:: listingblock
5142
5143 .. container:: content
5144
ramverma760cce92019-07-11 12:57:49 +00005145 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005146
5147 <appender name="CTXT-FILE"
5148 class="ch.qos.logback.core.rolling.RollingFileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005149 <file>${logDir}/apex_ctxt.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005150 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
liamfallon1540e472019-11-28 15:14:07 +00005151 <fileNamePattern>${logDir}/apex_ctxt_%d{yyyy-MM-dd}.%i.log.gz
ramverma3b71c972019-07-10 11:25:37 +00005152 </fileNamePattern>
5153 <maxHistory>4</maxHistory>
5154 <timeBasedFileNamingAndTriggeringPolicy
5155 class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5156 <maxFileSize>100MB</maxFileSize>
5157 </timeBasedFileNamingAndTriggeringPolicy>
5158 </rollingPolicy>
5159 <encoder>
5160 <pattern>
5161 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5162 </pattern>
5163 </encoder>
5164 </appender>
5165
5166Example Configuration for Logging Logic
5167---------------------------------------
5168
5169 .. container:: paragraph
5170
5171 The following example shows a configuration that logs policy logic
5172 to standard out and a file (*info*). All other APEX components are
5173 logging to a file (*debug*).. This configuration an be used in a
5174 pre-production phase with the APEX engine still running in a
5175 separate terminal to monitor policy execution. This logback
5176 configuration is in the APEX installation as
5177 ``etc/logback-logic.xml``.
5178
5179 .. container:: listingblock
5180
5181 .. container:: content
5182
ramverma760cce92019-07-11 12:57:49 +00005183 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005184
5185 <configuration debug="false">
5186 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5187
5188 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00005189 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00005190
5191 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5192 <encoder>
5193 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
5194 </encoder>
5195 </appender>
5196
5197 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005198 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005199 <encoder>
5200 <pattern>
5201 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5202 </pattern>
5203 </encoder>
5204 </appender>
5205
5206 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5207 <encoder>
5208 <pattern>policy: %msg\n</pattern>
5209 </encoder>
5210 </appender>
5211
5212 <root level="error">
5213 <appender-ref ref="STDOUT" />
5214 </root>
5215
5216 <logger name="org.onap.policy.apex" level="debug" additivity="false">
5217 <appender-ref ref="FILE" />
5218 </logger>
5219
5220 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5221 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5222 <appender-ref ref="FILE" />
5223 </logger>
5224 </configuration>
5225
5226Example Configuration for a Production Server
5227---------------------------------------------
5228
5229 .. container:: paragraph
5230
5231 The following example shows a configuration that logs all APEX
5232 components, including policy logic, to a file (*debug*). This
5233 configuration an be used in a production phase with the APEX
5234 engine being executed as a service on a system without console
5235 output. This logback configuration is in the APEX installation as
5236 ``logback-server.xml``
5237
5238 .. container:: listingblock
5239
5240 .. container:: content
5241
ramverma760cce92019-07-11 12:57:49 +00005242 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005243
5244 <configuration debug="false">
5245 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5246
5247 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00005248 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00005249
5250 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005251 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005252 <encoder>
5253 <pattern>
5254 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5255 </pattern>
5256 </encoder>
5257 </appender>
5258
5259 <root level="debug">
5260 <appender-ref ref="FILE" />
5261 </root>
5262
5263 <logger name="org.onap.policy.apex.executionlogging" level="debug" additivity="false">
5264 <appender-ref ref="FILE" />
5265 </logger>
5266 </configuration>
5267
a.sreekumarcf3ff822020-09-16 13:12:29 +01005268Unsupported Features
5269^^^^^^^^^^^^^^^^^^^^
5270
5271 .. container:: paragraph
5272
5273 This section documents some legacy and unsupported features
5274 in apex-pdp. The documentation here has not been updated for
5275 recent versions of apex-pdp. For example, the apex-pdp models
5276 specified in this example should now be in TOSCA format.
5277
ramverma3b71c972019-07-10 11:25:37 +00005278Building a System with Websocket Backend
a.sreekumarcf3ff822020-09-16 13:12:29 +01005279----------------------------------------
ramverma3b71c972019-07-10 11:25:37 +00005280
5281Websockets
a.sreekumarcf3ff822020-09-16 13:12:29 +01005282##########
ramverma3b71c972019-07-10 11:25:37 +00005283
5284 .. container:: paragraph
5285
5286 Websocket is a protocol to run sockets of HTTP. Since it in
5287 essence a socket, the connection is realized between a
5288 server (waiting for connections) and a client (connecting to
5289 a server). Server/client separation is only important for
5290 connection establishment, once connected, everyone can
5291 send/receive on the same socket (as any standard socket
5292 would allow).
5293
5294 .. container:: paragraph
5295
5296 Standard Websocket implementations are simple, no
5297 publish/subscribe and no special event handling. Most
5298 servers simply send all incoming messages to all
5299 connections. There is a PubSub definition on top of
5300 Websocket called `WAMP <http://wamp-proto.org/>`__. APEX
5301 does not support WAMP at the moment.
5302
5303Websocket in Java
a.sreekumarcf3ff822020-09-16 13:12:29 +01005304#################
ramverma3b71c972019-07-10 11:25:37 +00005305
5306 .. container:: paragraph
5307
5308 In Java, `JSR
5309 356 <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5310 defines the standard Websocket API. This JSR is part of Jave
5311 EE 7 standard. For Java SE, several implementations exist in
5312 open source. Since Websockets are a stable standard and
5313 simple, most implementations are stable and ready to use. A
5314 lot of products support Websockets, like Spring, JBoss,
5315 Netty, … there are also Kafka extensions for Websockets.
5316
5317Websocket Example Code for Websocket clients (FOSS)
a.sreekumarcf3ff822020-09-16 13:12:29 +01005318###################################################
ramverma3b71c972019-07-10 11:25:37 +00005319
5320 .. container:: paragraph
5321
5322 There are a lot of implementations and examples available on
5323 Github for Websocket clients. If one is using Java EE 7,
5324 then one can also use the native Websocket implementation.
5325 Good examples for clients using simply Java SE are here:
5326
5327 .. container:: ulist
5328
5329 - `Websocket
5330 implementation <https://github.com/TooTallNate/Java-WebSocket>`__
5331
5332 - `Websocket sending client example, using
5333 AWT <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ChatClient.java>`__
5334
5335 - `Websocket receiving client example (simple echo
5336 client) <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ExampleClient.java>`__
5337
5338 .. container:: paragraph
5339
5340 For Java EE, the native Websocket API is explained here:
5341
5342 .. container:: ulist
5343
5344 - `Oracle
5345 docs <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5346
5347 - link: `An
5348 example <http://www.programmingforliving.com/2013/08/jsr-356-java-api-for-websocket-client-api.html>`__
5349
5350BCP: Websocket Configuration
a.sreekumarcf3ff822020-09-16 13:12:29 +01005351############################
ramverma3b71c972019-07-10 11:25:37 +00005352
5353 .. container:: paragraph
5354
5355 The probably best is to configure APEX for Websocket servers
5356 for input (ingress, consume) and output (egress, produce)
5357 interfaces. This means that APEX will start Websocket
5358 servers on named ports and wait for clients to connect.
5359 Advantage: once APEX is running all connectivity
5360 infrastructure is running as well. Consequence: if APEX is
5361 not running, everyone else is in the dark, too.
5362
5363 .. container:: paragraph
5364
5365 The best protocol to be used is JSON string. Each event on
5366 any interface is then a string with a JSON encoding. JSON
5367 string is a little bit slower than byte code, but we doubt
5368 that this will be noticeable. A further advantage of JSON
5369 strings over Websockets with APEX starting the servers: it
5370 is very easy to connect web browsers to such a system.
5371 Simple connect the web browser to the APEX sockets and
5372 send/read JSON strings.
5373
5374 .. container:: paragraph
5375
5376 Once APEX is started you simply connect Websocket clients to
5377 it, and send/receive event. When APEX is terminated, the
5378 Websocket servers go down, and the clients will be
5379 disconnected. APEX does not (yet) support auto-client
5380 reconnect nor WAMP, so clients might need to be restarted or
5381 reconnected manually after an APEX boot.
5382
5383Demo with VPN Policy Model
a.sreekumarcf3ff822020-09-16 13:12:29 +01005384##########################
ramverma3b71c972019-07-10 11:25:37 +00005385
5386 .. container:: paragraph
5387
5388 We assume that you have an APEX installation using the full
5389 package, i.e. APEX with all examples, of version ``0.5.6``
5390 or higher. We will use the VPN policy from the APEX examples
5391 here.
5392
5393 .. container:: paragraph
5394
5395 Now, have the following ready to start the demo:
5396
5397 .. container:: ulist
5398
5399 - 3 terminals on the host where APEX is running (we need 1
5400 for APEX and 1 for each client)
5401
5402 - the events in the file
5403 ``$APEX_HOME/examples/events/VPN/SetupEvents.json`` open
5404 in an editor (we need to send those events to APEX)
5405
5406 - the events in the file
5407 ``$APEX_HOME/examples/events/VPN/Link09Events.json`` open
5408 in an editor (we need to send those events to APEX)
5409
5410A Websocket Configuration for the VPN Domain
a.sreekumar98b59692021-07-23 13:38:06 +01005411^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +00005412
5413 .. container:: paragraph
5414
5415 Create a new APEX configuration using the VPN policy
5416 model and configuring APEX as discussed above for
5417 Websockets. Copy the following configuration into
5418 ``$APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json``
5419 (for Windows use
5420 ``%APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json``):
5421
5422 .. container:: listingblock
5423
5424 .. container:: content
5425
ramverma760cce92019-07-11 12:57:49 +00005426 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005427 :number-lines:
5428
5429 {
5430 "engineServiceParameters" : {
5431 "name" : "VPNApexEngine",
5432 "version" : "0.0.1",
5433 "id" : 45,
5434 "instanceCount" : 1,
5435 "deploymentPort" : 12345,
5436 "policyModelFileName" : "examples/models/VPN/VPNPolicyModelAvro.json",
5437 "engineParameters" : {
5438 "executorParameters" : {
5439 "MVEL" : {
5440 "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
5441 }
5442 },
5443 "contextParameters" : {
5444 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
5445 "schemaParameters":{
5446 "Avro":{
5447 "parameterClassName" : "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
5448 }
5449 }
5450 }
5451 }
5452 },
5453 "producerCarrierTechnologyParameters" : {
5454 "carrierTechnology" : "WEBSOCKET",
5455 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5456 "parameters" : {
5457 "wsClient" : false,
5458 "port" : 42452
5459 }
5460 },
5461 "producerEventProtocolParameters" : {
5462 "eventProtocol" : "JSON"
5463 },
5464 "consumerCarrierTechnologyParameters" : {
5465 "carrierTechnology" : "WEBSOCKET",
5466 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5467 "parameters" : {
5468 "wsClient" : false,
5469 "port" : 42450
5470 }
5471 },
5472 "consumerEventProtocolParameters" : {
5473 "eventProtocol" : "JSON"
5474 }
5475 }
5476
5477Start APEX Engine
a.sreekumar98b59692021-07-23 13:38:06 +01005478^^^^^^^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +00005479
5480 .. container:: paragraph
5481
5482 In a new terminal, start APEX with the new configuration for
5483 Websocket-Server ingress/egress:
5484
5485 .. container:: listingblock
5486
5487 .. container:: content
5488
ramverma760cce92019-07-11 12:57:49 +00005489 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005490 :number-lines:
5491
liamfallonb621de42020-08-21 12:59:26 +01005492 #: $APEX_HOME/bin/apexApps.sh engine -c $APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json
ramverma3b71c972019-07-10 11:25:37 +00005493
5494.. container:: listingblock
5495
5496 .. container:: content
5497
ramverma760cce92019-07-11 12:57:49 +00005498 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005499 :number-lines:
5500
liamfallonb621de42020-08-21 12:59:26 +01005501 #: %APEX_HOME%\bin\apexApps.bat engine -c %APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json
ramverma3b71c972019-07-10 11:25:37 +00005502
5503.. container:: paragraph
5504
5505 Wait for APEX to start, it takes a while to create all Websocket
5506 servers (about 8 seconds on a standard laptop without cached
5507 binaries). depending on your log messages, you will see no (some, a
5508 lot) log messages. If APEX starts correctly, the last few messages
5509 you should see are:
5510
5511.. container:: listingblock
5512
5513 .. container:: content
5514
ramverma760cce92019-07-11 12:57:49 +00005515 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005516 :number-lines:
5517
5518 2017-07-28 13:17:20,834 Apex [main] INFO c.e.a.s.engine.runtime.EngineService - engine model VPNPolicyModelAvro:0.0.1 added to the engine-AxArtifactKey:(name=VPNApexEngine-0,version=0.0.1)
5519 2017-07-28 13:17:21,057 Apex [Apex-apex-engine-service-0:0] INFO c.e.a.s.engine.runtime.EngineService - Engine AxArtifactKey:(name=VPNApexEngine-0,version=0.0.1) processing ...
5520 2017-07-28 13:17:21,296 Apex [main] INFO c.e.a.s.e.r.impl.EngineServiceImpl - Added the action listener to the engine
5521 Started Apex service
5522
5523.. container:: paragraph
5524
5525 APEX is running in the new terminal and will produce output when the
5526 policy is triggered/executed.
5527
5528Run the Websocket Echo Client
a.sreekumar98b59692021-07-23 13:38:06 +01005529^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +00005530
5531 .. container:: paragraph
5532
5533 The echo client is included in an APEX full installation. To run
5534 the client, open a new shell (Unix, Cygwin) or command prompt
5535 (``cmd`` on Windows). Then use the APEX application launcher to
5536 start the client.
5537
liamfallon9c7bd672019-10-03 13:42:08 +01005538 .. important::
ramverma3b71c972019-07-10 11:25:37 +00005539 APEX engine needs to run first
ramverma760cce92019-07-11 12:57:49 +00005540 The example assumes that an APEX engine configured for *produce* carrier technology Websocket and *JSON* event protocol is executed first.
ramverma3b71c972019-07-10 11:25:37 +00005541
5542 +---------------------------------------------------------+-----------------------------------------------------------+
5543 | Unix, Cygwin | Windows |
5544 +=========================================================+===========================================================+
5545 | .. container:: | .. container:: |
5546 | | |
5547 | .. container:: listingblock | .. container:: listingblock |
5548 | | |
5549 | .. container:: content | .. container:: content |
5550 | | |
5551 | .. code:: | .. code:: |
5552 | | |
5553 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
5554 +---------------------------------------------------------+-----------------------------------------------------------+
5555
5556 .. container:: paragraph
5557
5558 Use the following command line arguments for server and port of
5559 the Websocket server. The port should be the same as configured in
5560 the APEX engine. The server host should be the host on which the
5561 APEX engine is running
5562
5563 .. container:: ulist
5564
5565 - ``-p`` defines the Websocket port to connect to (defaults to
5566 ``8887``)
5567
5568 - ``-s`` defines the host on which a Websocket server is running
5569 (defaults to ``localhost``)
5570
5571 .. container:: paragraph
5572
5573 Let’s assume that there is an APEX engine running, configured for
5574 produce Websocket carrier technology, as server, for port 42452,
5575 with produce event protocol JSON,. If we start the console client
5576 on the same host, we can omit the ``-s`` options. We start the
5577 console client as:
5578
5579 .. container:: listingblock
5580
5581 .. container:: content
5582
ramverma760cce92019-07-11 12:57:49 +00005583 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005584
5585 # $APEX_HOME/bin/apexApps.sh ws-echo -p 42452 (1)
5586 > %APEX_HOME%\bin\apexApps.bat ws-echo -p 42452 (2)
5587
5588 .. container:: colist arabic
5589
5590 +-------+--------------------------------+
5591 | **1** | Start client on Unix or Cygwin |
5592 +-------+--------------------------------+
5593 | **2** | Start client on Windows |
5594 +-------+--------------------------------+
5595
5596 .. container:: paragraph
5597
5598 Once started successfully, the client will produce the following
5599 messages (assuming we used ``-p 42452`` and an APEX engine is
5600 running on ``localhost`` with the same port:
5601
5602 .. container:: listingblock
5603
5604 .. container:: content
5605
ramverma760cce92019-07-11 12:57:49 +00005606 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005607
5608 ws-simple-echo: starting simple event echo
5609 --> server: localhost
5610 --> port: 42452
5611
5612 Once started, the application will simply print out all received events to standard out.
5613 Each received event will be prefixed by '---' and suffixed by '===='
5614
5615
5616 ws-simple-echo: opened connection to APEX (Web Socket Protocol Handshake)
5617
5618Run the Websocket Console Client
a.sreekumar98b59692021-07-23 13:38:06 +01005619^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +00005620
5621 .. container:: paragraph
5622
5623 The console client is included in an APEX full installation. To
5624 run the client, open a new shell (Unix, Cygwin) or command prompt
5625 (``cmd`` on Windows). Then use the APEX application launcher to
5626 start the client.
5627
liamfallon9c7bd672019-10-03 13:42:08 +01005628 .. important::
ramverma3b71c972019-07-10 11:25:37 +00005629 APEX engine needs to run first
ramverma760cce92019-07-11 12:57:49 +00005630 The example assumes that an APEX engine configured for *consume* carrier technology Websocket and *JSON* event
5631 protocol is executed first.
ramverma3b71c972019-07-10 11:25:37 +00005632
5633 +------------------------------------------------------------+--------------------------------------------------------------+
5634 | Unix, Cygwin | Windows |
5635 +============================================================+==============================================================+
5636 | .. container:: | .. container:: |
5637 | | |
5638 | .. container:: listingblock | .. container:: listingblock |
5639 | | |
5640 | .. container:: content | .. container:: content |
5641 | | |
5642 | .. code:: | .. code:: |
5643 | | |
5644 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
5645 +------------------------------------------------------------+--------------------------------------------------------------+
5646
5647 .. container:: paragraph
5648
5649 Use the following command line arguments for server and port of
5650 the Websocket server. The port should be the same as configured in
5651 the APEX engine. The server host should be the host on which the
5652 APEX engine is running
5653
5654 .. container:: ulist
5655
5656 - ``-p`` defines the Websocket port to connect to (defaults to
5657 ``8887``)
5658
5659 - ``-s`` defines the host on which a Websocket server is running
5660 (defaults to ``localhost``)
5661
5662 .. container:: paragraph
5663
5664 Let’s assume that there is an APEX engine running, configured for
5665 consume Websocket carrier technology, as server, for port 42450,
5666 with consume event protocol JSON,. If we start the console client
5667 on the same host, we can omit the ``-s`` options. We start the
5668 console client as:
5669
5670 .. container:: listingblock
5671
5672 .. container:: content
5673
ramverma760cce92019-07-11 12:57:49 +00005674 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005675
5676 # $APEX_HOME/bin/apexApps.sh ws-console -p 42450 (1)
5677 > %APEX_HOME%\bin\apexApps.sh ws-console -p 42450 (2)
5678
5679 .. container:: colist arabic
5680
5681 +-------+--------------------------------+
5682 | **1** | Start client on Unix or Cygwin |
5683 +-------+--------------------------------+
5684 | **2** | Start client on Windows |
5685 +-------+--------------------------------+
5686
5687 .. container:: paragraph
5688
5689 Once started successfully, the client will produce the following
5690 messages (assuming we used ``-p 42450`` and an APEX engine is
5691 running on ``localhost`` with the same port:
5692
5693 .. container:: listingblock
5694
5695 .. container:: content
5696
ramverma760cce92019-07-11 12:57:49 +00005697 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005698
5699 ws-simple-console: starting simple event console
5700 --> server: localhost
5701 --> port: 42450
5702
5703 - terminate the application typing 'exit<enter>' or using 'CTRL+C'
5704 - events are created by a non-blank starting line and terminated by a blank line
5705
5706
5707 ws-simple-console: opened connection to APEX (Web Socket Protocol Handshake)
5708
5709Send Events
a.sreekumar98b59692021-07-23 13:38:06 +01005710^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +00005711
5712 .. container:: paragraph
5713
5714 Now you have the full system up and running:
5715
5716 .. container:: ulist
5717
5718 - Terminal 1: APEX ready and loaded
5719
5720 - Terminal 2: an echo client, printing received messages produced
5721 by the VPN policy
5722
5723 - Terminal 2: a console client, waiting for input on the console
5724 (standard in) and sending text to APEX
5725
5726 .. container:: paragraph
5727
5728 We started the engine with the VPN policy example. So all the
5729 events we are using now are located in files in the following
5730 example directory:
5731
5732 .. container:: listingblock
5733
5734 .. container:: content
5735
ramverma760cce92019-07-11 12:57:49 +00005736 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005737 :number-lines:
5738
5739 #: $APEX_HOME/examples/events/VPN
5740 > %APEX_HOME%\examples\events\VPN
5741
5742.. container:: paragraph
5743
5744 To sends events, simply copy the content of the event files into
5745 Terminal 3 (the console client). It will read multi-line JSON text
5746 and send the events. So copy the content of ``SetupEvents.json`` into
5747 the client. APEX will trigger a policy and produce some output, the
5748 echo client will also print some events created in the policy. In
5749 Terminal 1 (APEX) you’ll see some status messages from the policy as:
5750
5751.. container:: listingblock
5752
5753 .. container:: content
5754
ramverma760cce92019-07-11 12:57:49 +00005755 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005756 :number-lines:
5757
5758 {Link=L09, LinkUp=true}
5759 L09 true
5760 outFields: {Link=L09, LinkUp=true}
5761 {Link=L10, LinkUp=true}
5762 L09 true
5763 L10 true
5764 outFields: {Link=L10, LinkUp=true}
5765 {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5766 *** Customers ***
5767 C 300 300 [L09, L10]
5768 outFields: {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5769 {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5770 *** Customers ***
5771 A 300 50 [L09, L10]
5772 C 300 300 [L09, L10]
5773 outFields: {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5774 {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5775 *** Customers ***
5776 A 300 50 [L09, L10]
5777 C 300 300 [L09, L10]
5778 D 300 400 [L09, L10]
5779 outFields: {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5780 {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5781 *** Customers ***
5782 A 300 50 [L09, L10]
5783 B 300 299 [L09, L10]
5784 C 300 300 [L09, L10]
5785 D 300 400 [L09, L10]
5786 outFields: {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5787
5788.. container:: paragraph
5789
5790 In Terminal 2 (echo-client) you see the received events, the last two
5791 should look like:
5792
5793.. container:: listingblock
5794
5795 .. container:: content
5796
ramverma760cce92019-07-11 12:57:49 +00005797 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005798 :number-lines:
5799
5800 ws-simple-echo: received
5801 ---------------------------------
5802 {
5803 "name": "VPNCustomerCtxtActEvent",
5804 "version": "0.0.1",
5805 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5806 "source": "Source",
5807 "target": "Target",
5808 "CustomerName": "C",
5809 "LinkList": "L09 L10",
5810 "SlaDT": 300,
5811 "YtdDT": 300
5812 }
5813 =================================
5814
5815 ws-simple-echo: received
5816 ---------------------------------
5817 {
5818 "name": "VPNCustomerCtxtActEvent",
5819 "version": "0.0.1",
5820 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5821 "source": "Source",
5822 "target": "Target",
5823 "CustomerName": "D",
5824 "LinkList": "L09 L10",
5825 "SlaDT": 300,
5826 "YtdDT": 400
5827 }
5828 =================================
5829
5830.. container:: paragraph
5831
5832 Congratulations, you have triggered a policy in APEX using
5833 Websockets, the policy did run through, created events, picked up by
5834 the echo-client.
5835
5836.. container:: paragraph
5837
5838 Now you can send the Link 09 and Link 10 events, they will trigger
5839 the actual VPN policy and some calculations are made. Let’s take the
5840 Link 09 events from ``Link09Events.json``, copy them all into
5841 Terminal 3 (the console). APEX will run the policy (with some status
5842 output), and the echo client will receive and print events.
5843
5844.. container:: paragraph
5845
5846 To terminate the applications, simply press ``CTRL+C`` in Terminal 1
5847 (APEX). This will also terminate the echo-client in Terminal 2. Then
5848 type ``exit<enter>`` in Terminal 3 (or ``CTRL+C``) to terminate the
5849 console-client.