blob: 21e9dbcb7f3a01a50327ffafaf45441159b8d48b [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
Ram Krishna Vermacf6dd0f2022-08-25 17:24:51 -04002039Configure Context Schema Handler
2040################################
ramverma3b71c972019-07-10 11:25:37 +00002041
2042 .. container:: paragraph
2043
Ram Krishna Vermacf6dd0f2022-08-25 17:24:51 -04002044 There are 2 choices available for defining schema: JSON & AVRO.
2045 JSON based schemas are recommended because of the flexibility, better tooling & easier integration.
2046
2047 The JSON schema handler is added to the configuration as
2048 follows:
2049
2050 .. container:: listingblock
2051
2052 .. container:: content
2053
2054 .. code::
2055
2056 "engineServiceParameters":{
2057 "engineParameters":{
2058 "contextParameters":{
2059 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2060 "schemaParameters":{
2061 "Json":{
2062 "parameterClassName" :
2063 "org.onap.policy.apex.plugins.context.schema.json.JsonSchemaHelperParameters"
2064 }
2065 }
2066 }
2067 }
2068 }
2069
ramverma3b71c972019-07-10 11:25:37 +00002070 The AVRO schema handler is added to the configuration as
2071 follows:
2072
2073 .. container:: listingblock
2074
2075 .. container:: content
2076
ramverma760cce92019-07-11 12:57:49 +00002077 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002078
2079 "engineServiceParameters":{
2080 "engineParameters":{
2081 "contextParameters":{
2082 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2083 "schemaParameters":{
2084 "Avro":{
2085 "parameterClassName" :
2086 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
2087 }
2088 }
2089 }
2090 }
2091 }
2092
2093 .. container:: paragraph
2094
2095 Using the AVRO schema handler has one limitation: AVRO
2096 only supports field names that represent valid Java class
2097 names. This means only letters and the character ``_``
2098 are supported. Characters commonly used in field names,
2099 such as ``.`` and ``-``, are not supported by AVRO. for
2100 more information see `Avro Spec:
2101 Names <https://avro.apache.org/docs/1.8.1/spec.html#names>`__.
2102
2103 .. container:: paragraph
2104
2105 To work with this limitation, the APEX Avro plugin will
2106 parse a given AVRO definition and replace *all*
2107 occurrences of ``.`` and ``-`` with a ``_``. This means
2108 that
2109
2110 .. container:: ulist
2111
2112 - In a policy model, if the AVRO schema defined a field
2113 as ``my-name`` the policy logic should access it as
2114 ``my_name``
2115
2116 - In a policy model, if the AVRO schema defined a field
2117 as ``my.name`` the policy logic should access it as
2118 ``my_name``
2119
2120 - There should be no field names that convert to the
2121 same internal name
2122
2123 .. container:: ulist
2124
2125 - For instance the simultaneous use of
2126 ``my_name``, ``my.name``, and ``my-name`` should
2127 be avoided
2128
2129 - If not avoided, the event processing might
2130 create unwanted side effects
2131
2132 - If field names use any other not-supported character,
2133 the AVRO plugin will reject it
2134
2135 .. container:: ulist
2136
2137 - Since AVRO uses lazy initialization, this
2138 rejection might only become visible at runtime
2139
a.sreekumarcc0e9172020-03-16 13:36:45 +00002140Configure Task Parameters
2141#########################
2142
2143 .. container:: paragraph
2144
2145 The Task Parameters are added to the configuration as
2146 follows:
2147
2148 .. container:: listingblock
2149
2150 .. container:: content
2151
2152 .. code::
2153
2154 "engineServiceParameters": {
2155 "engineParameters": {
2156 "taskParameters": [
2157 {
2158 "key": "ParameterKey1",
2159 "value": "ParameterValue1"
2160 },
2161 {
2162 "taskId": "Task_Act0",
2163 "key": "ParameterKey2",
2164 "value": "ParameterValue2"
2165 }
2166 ]
2167 }
2168 }
2169
2170 .. container:: paragraph
2171
2172 TaskParameters can be used to pass parameters from ApexConfig
2173 to the policy logic. In the config, these are optional.
2174 The list of task parameters provided in the config may be added
2175 to the tasks or existing task parameters in the task will be overriden.
2176
2177 .. container:: paragraph
2178
2179 If taskId is provided in ApexConfig for an entry, then that
2180 parameter is updated only for that particular task. Otherwise,
2181 the task parameter is added to all tasks.
2182
ramverma3b71c972019-07-10 11:25:37 +00002183Carrier Technologies
2184--------------------
2185
2186 .. container:: paragraph
2187
2188 Carrier technologies define how APEX receives (input) and
2189 sends (output) events. They can be used in any combination,
2190 using asynchronous or synchronous mode. There can also be
2191 any number of carrier technologies for the input (consume)
2192 and the output (produce) interface.
2193
2194 .. container:: paragraph
2195
2196 Supported *input* technologies are:
2197
2198 .. container:: ulist
2199
2200 - Standard input, read events from the standard input
2201 (console), not suitable for APEX background servers
2202
2203 - File input, read events from a file
2204
2205 - Kafka, read events from a Kafka system
2206
2207 - Websockets, read events from a Websocket
2208
2209 - JMS,
2210
2211 - REST (synchronous and asynchronous), additionally as
2212 client or server
2213
2214 - Event Requestor, allows reading of events that have been
2215 looped back into APEX
2216
2217 .. container:: paragraph
2218
2219 Supported *output* technologies are:
2220
2221 .. container:: ulist
2222
2223 - Standard output, write events to the standard output
2224 (console), not suitable for APEX background servers
2225
2226 - File output, write events to a file
2227
2228 - Kafka, write events to a Kafka system
2229
2230 - Websockets, write events to a Websocket
2231
2232 - JMS
2233
2234 - REST (synchronous and asynchronous), additionally as
2235 client or server
2236
2237 - Event Requestor, allows events to be looped back into
2238 APEX
2239
2240 .. container:: paragraph
2241
2242 New carrier technologies can be added as plugins to APEX or
2243 developed outside APEX and added to an APEX deployment.
2244
2245Standard IO
2246###########
2247
2248 .. container:: paragraph
2249
2250 Standard IO does not require a specific plugin, it is
2251 supported be default.
2252
2253Standard Input
2254==============
2255 .. container:: paragraph
2256
2257 APEX will take events from its standard input. This
2258 carrier is good for testing, but certainly not for a
2259 use case where APEX runs as a server. The
2260 configuration is as follows:
2261
2262 .. container:: listingblock
2263
2264 .. container:: content
2265
liamfallon40f09542021-10-11 11:57:31 +01002266 ::
ramverma3b71c972019-07-10 11:25:37 +00002267
2268 "carrierTechnologyParameters" : {
2269 "carrierTechnology" : "FILE", (1)
2270 "parameters" : {
2271 "standardIO" : true (2)
2272 }
2273 }
2274
2275 .. container:: colist arabic
2276
2277 +-------+---------------------------------------+
2278 | **1** | standard input is considered a file |
2279 +-------+---------------------------------------+
2280 | **2** | file descriptor set to standard input |
2281 +-------+---------------------------------------+
2282
2283Standard Output
2284===============
2285
2286 .. container:: paragraph
2287
2288 APEX will send events to its standard output. This
2289 carrier is good for testing, but certainly not for a
2290 use case where APEX runs as a server. The
2291 configuration is as follows:
2292
2293 .. container:: listingblock
2294
2295 .. container:: content
2296
ramverma760cce92019-07-11 12:57:49 +00002297 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002298
2299 "carrierTechnologyParameters" : {
2300 "carrierTechnology" : "FILE", (1)
2301 "parameters" : {
2302 "standardIO" : true (2)
2303 }
2304 }
2305
2306 .. container:: colist arabic
2307
2308 +-------+----------------------------------------+
2309 | **1** | standard output is considered a file |
2310 +-------+----------------------------------------+
2311 | **2** | file descriptor set to standard output |
2312 +-------+----------------------------------------+
2313
23142.7.2. File IO
2315##############
2316
2317 .. container:: paragraph
2318
2319 File IO does not require a specific plugin, it is
2320 supported be default.
2321
2322File Input
2323==========
2324
2325 .. container:: paragraph
2326
2327 APEX will take events from a file. The same file
2328 should not be used as an output. The configuration is
2329 as follows:
2330
2331 .. container:: listingblock
2332
2333 .. container:: content
2334
ramverma760cce92019-07-11 12:57:49 +00002335 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002336
2337 "carrierTechnologyParameters" : {
2338 "carrierTechnology" : "FILE", (1)
2339 "parameters" : {
2340 "fileName" : "examples/events/SampleDomain/EventsIn.xmlfile" (2)
2341 }
2342 }
2343
2344 .. container:: colist arabic
2345
2346 +-------+------------------------------------------+
2347 | **1** | set file input |
2348 +-------+------------------------------------------+
2349 | **2** | the name of the file to read events from |
2350 +-------+------------------------------------------+
2351
2352File Output
2353===========
2354 .. container:: paragraph
2355
2356 APEX will write events to a file. The same file should
2357 not be used as an input. The configuration is as
2358 follows:
2359
2360 .. container:: listingblock
2361
2362 .. container:: content
2363
ramverma760cce92019-07-11 12:57:49 +00002364 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002365
2366 "carrierTechnologyParameters" : {
2367 "carrierTechnology" : "FILE", (1)
2368 "parameters" : {
2369 "fileName" : "examples/events/SampleDomain/EventsOut.xmlfile" (2)
2370 }
2371 }
2372
2373 .. container:: colist arabic
2374
2375 +-------+-----------------------------------------+
2376 | **1** | set file output |
2377 +-------+-----------------------------------------+
2378 | **2** | the name of the file to write events to |
2379 +-------+-----------------------------------------+
2380
2381Event Requestor IO
2382##################
2383
2384 .. container:: paragraph
2385
2386 Event Requestor IO does not require a specific plugin, it
2387 is supported be default. It should only be used with the
2388 APEX event protocol.
2389
2390Event Requestor Input
2391=====================
2392
2393 .. container:: paragraph
2394
2395 APEX will take events from APEX.
2396
2397 .. container:: listingblock
2398
2399 .. container:: content
2400
ramverma760cce92019-07-11 12:57:49 +00002401 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002402
2403 "carrierTechnologyParameters" : {
2404 "carrierTechnology": "EVENT_REQUESTOR" (1)
2405 }
2406
2407 .. container:: colist arabic
2408
2409 +-------+---------------------------+
2410 | **1** | set event requestor input |
2411 +-------+---------------------------+
2412
2413Event Requestor Output
2414======================
2415
2416 .. container:: paragraph
2417
2418 APEX will write events to APEX.
2419
2420 .. container:: listingblock
2421
2422 .. container:: content
2423
ramverma760cce92019-07-11 12:57:49 +00002424 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002425
2426 "carrierTechnologyParameters" : {
2427 "carrierTechnology": "EVENT_REQUESTOR" (1)
2428 }
2429
2430Peering Event Requestors
2431========================
2432
2433 .. container:: paragraph
2434
2435 When using event requestors, they need to be peered.
2436 This means an event requestor output needs to be
2437 peered (associated) with an event requestor input. The
2438 following example shows the use of an event requestor
2439 with the APEX event protocol and the peering of output
2440 and input.
2441
2442 .. container:: listingblock
2443
2444 .. container:: content
2445
ramverma760cce92019-07-11 12:57:49 +00002446 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002447
2448 "eventInputParameters": {
2449 "EventRequestorConsumer": {
2450 "carrierTechnologyParameters": {
2451 "carrierTechnology": "EVENT_REQUESTOR" (1)
2452 },
2453 "eventProtocolParameters": {
2454 "eventProtocol": "APEX" (2)
2455 },
2456 "eventNameFilter": "InputEvent", (3)
2457 "requestorMode": true, (4)
2458 "requestorPeer": "EventRequestorProducer", (5)
2459 "requestorTimeout": 500 (6)
2460 }
2461 },
2462 "eventOutputParameters": {
2463 "EventRequestorProducer": {
2464 "carrierTechnologyParameters": {
2465 "carrierTechnology": "EVENT_REQUESTOR" (7)
2466 },
2467 "eventProtocolParameters": {
2468 "eventProtocol": "APEX" (8)
2469 },
2470 "eventNameFilter": "EventListEvent", (9)
2471 "requestorMode": true, (10)
2472 "requestorPeer": "EventRequestorConsumer", (11)
2473 "requestorTimeout": 500 (12)
2474 }
2475 }
2476
2477 .. container:: colist arabic
2478
2479 +-----------------------------------+-----------------------------------+
2480 | **1** | event requestor on a consumer |
2481 +-----------------------------------+-----------------------------------+
2482 | **2** | with APEX event protocol |
2483 +-----------------------------------+-----------------------------------+
2484 | **3** | optional filter (best to use a |
2485 | | filter to prevent unwanted events |
2486 | | on the consumer side) |
2487 +-----------------------------------+-----------------------------------+
2488 | **4** | activate requestor mode |
2489 +-----------------------------------+-----------------------------------+
2490 | **5** | the peer to the output (must |
2491 | | match the output carrier) |
2492 +-----------------------------------+-----------------------------------+
2493 | **6** | an optional timeout in |
2494 | | milliseconds |
2495 +-----------------------------------+-----------------------------------+
2496 | **7** | event requestor on a producer |
2497 +-----------------------------------+-----------------------------------+
2498 | **8** | with APEX event protocol |
2499 +-----------------------------------+-----------------------------------+
2500 | **9** | optional filter (best to use a |
2501 | | filter to prevent unwanted events |
2502 | | on the consumer side) |
2503 +-----------------------------------+-----------------------------------+
2504 | **10** | activate requestor mode |
2505 +-----------------------------------+-----------------------------------+
2506 | **11** | the peer to the output (must |
2507 | | match the input carrier) |
2508 +-----------------------------------+-----------------------------------+
2509 | **12** | an optional timeout in |
2510 | | milliseconds |
2511 +-----------------------------------+-----------------------------------+
2512
2513Kafka IO
2514########
2515
2516 .. container:: paragraph
2517
2518 Kafka IO is supported by the APEX Kafka plugin. The
2519 configurations below are examples. APEX will take any
2520 configuration inside the parameter object and forward it
2521 to Kafka. More information on Kafka specific
2522 configuration parameters can be found in the Kafka
2523 documentation:
2524
2525 .. container:: ulist
2526
2527 - `Kafka Consumer
2528 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html>`__
2529
2530 - `Kafka Producer
2531 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html>`__
2532
2533Kafka Input
2534===========
2535 .. container:: paragraph
2536
2537 APEX will receive events from the Apache Kafka
2538 messaging system. The input is uni-directional, an
2539 engine will only receive events from the input but not
2540 send any event to the input.
2541
2542 .. container:: listingblock
2543
2544 .. container:: content
2545
ramverma760cce92019-07-11 12:57:49 +00002546 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002547
2548 "carrierTechnologyParameters" : {
2549 "carrierTechnology" : "KAFKA", (1)
2550 "parameterClassName" :
2551 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2552 "parameters" : {
2553 "bootstrapServers" : "localhost:49092", (2)
2554 "groupId" : "apex-group-id", (3)
2555 "enableAutoCommit" : true, (4)
2556 "autoCommitTime" : 1000, (5)
2557 "sessionTimeout" : 30000, (6)
2558 "consumerPollTime" : 100, (7)
2559 "consumerTopicList" : ["apex-in-0", "apex-in-1"], (8)
2560 "keyDeserializer" :
2561 "org.apache.kafka.common.serialization.StringDeserializer", (9)
2562 "valueDeserializer" :
2563 "org.apache.kafka.common.serialization.StringDeserializer" (10)
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002564 "kafkaProperties": [ (11)
2565 [
2566 "security.protocol",
2567 "SASL_SSL"
2568 ],
2569 [
2570 "ssl.truststore.type",
2571 "JKS"
2572 ],
2573 [
2574 "ssl.truststore.location",
2575 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2576 ],
2577 [
2578 "ssl.truststore.password",
2579 "policy0nap"
2580 ],
2581 [
2582 "sasl.mechanism",
2583 "SCRAM-SHA-512"
2584 ],
2585 [
2586 "sasl.jaas.config",
2587 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2588 ],
2589 [
2590 "ssl.endpoint.identification.algorithm",
2591 ""
2592 ]
2593 ]
ramverma3b71c972019-07-10 11:25:37 +00002594 }
2595 }
2596
2597 .. container:: colist arabic
2598
2599 +--------+-------------------------------------+
2600 | **1** | set Kafka as carrier technology |
2601 +--------+-------------------------------------+
2602 | **2** | bootstrap server and port |
2603 +--------+-------------------------------------+
2604 | **3** | a group identifier |
2605 +--------+-------------------------------------+
2606 | **4** | flag for auto-commit |
2607 +--------+-------------------------------------+
2608 | **5** | auto-commit timeout in milliseconds |
2609 +--------+-------------------------------------+
2610 | **6** | session timeout in milliseconds |
2611 +--------+-------------------------------------+
2612 | **7** | consumer poll time in milliseconds |
2613 +--------+-------------------------------------+
2614 | **8** | consumer topic list |
2615 +--------+-------------------------------------+
2616 | **9** | key for the Kafka de-serializer |
2617 +--------+-------------------------------------+
2618 | **10** | value for the Kafka de-serializer |
2619 +--------+-------------------------------------+
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002620 | **11** | properties for Kafka connectivity |
2621 +--------+-------------------------------------+
2622
2623 .. container:: paragraph
2624
2625 Kindly note that the above Kafka properties is just a reference,
2626 and the actual properties required depends on the Kafka server installation.
ramverma3b71c972019-07-10 11:25:37 +00002627
2628Kafka Output
2629============
2630 .. container:: paragraph
2631
2632 APEX will send events to the Apache Kafka messaging
2633 system. The output is uni-directional, an engine will
2634 send events to the output but not receive any event
2635 from the output.
2636
2637 .. container:: listingblock
2638
2639 .. container:: content
2640
ramverma760cce92019-07-11 12:57:49 +00002641 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002642
2643 "carrierTechnologyParameters" : {
2644 "carrierTechnology" : "KAFKA", (1)
2645 "parameterClassName" :
2646 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2647 "parameters" : {
2648 "bootstrapServers" : "localhost:49092", (2)
2649 "acks" : "all", (3)
2650 "retries" : 0, (4)
2651 "batchSize" : 16384, (5)
2652 "lingerTime" : 1, (6)
2653 "bufferMemory" : 33554432, (7)
2654 "producerTopic" : "apex-out", (8)
2655 "keySerializer" :
2656 "org.apache.kafka.common.serialization.StringSerializer", (9)
2657 "valueSerializer" :
2658 "org.apache.kafka.common.serialization.StringSerializer" (10)
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002659 "kafkaProperties": [ (11)
2660 [
2661 "security.protocol",
2662 "SASL_SSL"
2663 ],
2664 [
2665 "ssl.truststore.type",
2666 "JKS"
2667 ],
2668 [
2669 "ssl.truststore.location",
2670 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2671 ],
2672 [
2673 "ssl.truststore.password",
2674 "policy0nap"
2675 ],
2676 [
2677 "sasl.mechanism",
2678 "SCRAM-SHA-512"
2679 ],
2680 [
2681 "sasl.jaas.config",
2682 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2683 ],
2684 [
2685 "ssl.endpoint.identification.algorithm",
2686 ""
2687 ]
2688 ]
ramverma3b71c972019-07-10 11:25:37 +00002689 }
2690 }
2691
2692 .. container:: colist arabic
2693
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002694 +--------+-----------------------------------+
2695 | **1** | set Kafka as carrier technology |
2696 +--------+-----------------------------------+
2697 | **2** | bootstrap server and port |
2698 +--------+-----------------------------------+
2699 | **3** | acknowledgement strategy |
2700 +--------+-----------------------------------+
2701 | **4** | number of retries |
2702 +--------+-----------------------------------+
2703 | **5** | batch size |
2704 +--------+-----------------------------------+
2705 | **6** | time to linger in milliseconds |
2706 +--------+-----------------------------------+
2707 | **7** | buffer memory in byte |
2708 +--------+-----------------------------------+
2709 | **8** | producer topic |
2710 +--------+-----------------------------------+
2711 | **9** | key for the Kafka serializer |
2712 +--------+-----------------------------------+
2713 | **10** | value for the Kafka serializer |
2714 +--------+-----------------------------------+
2715 | **11** | properties for Kafka connectivity |
2716 +--------+-----------------------------------+
2717
2718 .. container:: paragraph
2719
2720 Kindly note that the above Kafka properties is just a reference,
2721 and the actual properties required depends on the Kafka server installation.
ramverma3b71c972019-07-10 11:25:37 +00002722
2723JMS IO
liamfallonb621de42020-08-21 12:59:26 +01002724######
ramverma3b71c972019-07-10 11:25:37 +00002725
2726 .. container:: paragraph
2727
2728 APEX supports the Java Messaging Service (JMS) as input
2729 as well as output. JMS IO is supported by the APEX JMS
2730 plugin. Input and output support an event encoding as
2731 text (JSON string) or object (serialized object). The
2732 input configuration is the same for both encodings, the
2733 output configuration differs.
2734
2735JMS Input
2736=========
2737 .. container:: paragraph
2738
2739 APEX will receive events from a JMS messaging system.
2740 The input is uni-directional, an engine will only
2741 receive events from the input but not send any event
2742 to the input.
2743
2744 .. container:: listingblock
2745
2746 .. container:: content
2747
ramverma760cce92019-07-11 12:57:49 +00002748 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002749
2750 "carrierTechnologyParameters" : {
2751 "carrierTechnology" : "JMS", (1)
2752 "parameterClassName" :
2753 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2754 "parameters" : { (2)
2755 "initialContextFactory" :
2756 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2757 "connectionFactory" : "ConnectionFactory", (4)
2758 "providerURL" : "remote://localhost:5445", (5)
2759 "securityPrincipal" : "guest", (6)
2760 "securityCredentials" : "IAmAGuest", (7)
2761 "consumerTopic" : "jms/topic/apexIn" (8)
2762 }
2763 }
2764
2765 .. container:: colist arabic
2766
2767 +-----------------------------------+-----------------------------------+
2768 | **1** | set JMS as carrier technology |
2769 +-----------------------------------+-----------------------------------+
2770 | **2** | set all JMS specific parameters |
2771 +-----------------------------------+-----------------------------------+
2772 | **3** | the context factory, in this case |
2773 | | from JBOSS (it requires the |
2774 | | dependency |
2775 | | org.jboss:jboss-remote-naming:2.0 |
2776 | | .4.Final |
2777 | | or a different version to be in |
2778 | | the directory ``$APEX_HOME/lib`` |
2779 | | or ``%APEX_HOME%\lib`` |
2780 +-----------------------------------+-----------------------------------+
2781 | **4** | a connection factory for the JMS |
2782 | | connection |
2783 +-----------------------------------+-----------------------------------+
2784 | **5** | URL with host and port of the JMS |
2785 | | provider |
2786 +-----------------------------------+-----------------------------------+
2787 | **6** | access credentials, user name |
2788 +-----------------------------------+-----------------------------------+
2789 | **7** | access credentials, user password |
2790 +-----------------------------------+-----------------------------------+
2791 | **8** | the JMS topic to listen to |
2792 +-----------------------------------+-----------------------------------+
2793
2794JMS Output with Text
2795====================
2796
2797 .. container:: paragraph
2798
2799 APEX engine send events to a JMS messaging system. The
2800 output is uni-directional, an engine will send events
2801 to the output but not receive any event from output.
2802
2803 .. container:: listingblock
2804
2805 .. container:: content
2806
ramverma760cce92019-07-11 12:57:49 +00002807 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002808
2809 "carrierTechnologyParameters" : {
2810 "carrierTechnology" : "JMS", (1)
2811 "parameterClassName" :
2812 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2813 "parameters" : { (2)
2814 "initialContextFactory" :
2815 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2816 "connectionFactory" : "ConnectionFactory", (4)
2817 "providerURL" : "remote://localhost:5445", (5)
2818 "securityPrincipal" : "guest", (6)
2819 "securityCredentials" : "IAmAGuest", (7)
2820 "producerTopic" : "jms/topic/apexOut", (8)
2821 "objectMessageSending": "false" (9)
2822 }
2823 }
2824
2825 .. container:: colist arabic
2826
2827 +-----------------------------------+-----------------------------------+
2828 | **1** | set JMS as carrier technology |
2829 +-----------------------------------+-----------------------------------+
2830 | **2** | set all JMS specific parameters |
2831 +-----------------------------------+-----------------------------------+
2832 | **3** | the context factory, in this case |
2833 | | from JBOSS (it requires the |
2834 | | dependency |
2835 | | org.jboss:jboss-remote-naming:2.0 |
2836 | | .4.Final |
2837 | | or a different version to be in |
2838 | | the directory ``$APEX_HOME/lib`` |
2839 | | or ``%APEX_HOME%\lib`` |
2840 +-----------------------------------+-----------------------------------+
2841 | **4** | a connection factory for the JMS |
2842 | | connection |
2843 +-----------------------------------+-----------------------------------+
2844 | **5** | URL with host and port of the JMS |
2845 | | provider |
2846 +-----------------------------------+-----------------------------------+
2847 | **6** | access credentials, user name |
2848 +-----------------------------------+-----------------------------------+
2849 | **7** | access credentials, user password |
2850 +-----------------------------------+-----------------------------------+
2851 | **8** | the JMS topic to write to |
2852 +-----------------------------------+-----------------------------------+
2853 | **9** | set object messaging to ``false`` |
2854 | | means it sends JSON text |
2855 +-----------------------------------+-----------------------------------+
2856
2857JMS Output with Object
2858======================
2859
2860 .. container:: paragraph
2861
2862 To configure APEX for JMS objects on the output
2863 interface use the same configuration as above (for
2864 output). Simply change the ``objectMessageSending``
2865 parameter to ``true``.
2866
2867Websocket (WS) IO
liamfallonb621de42020-08-21 12:59:26 +01002868#################
ramverma3b71c972019-07-10 11:25:37 +00002869
2870 .. container:: paragraph
2871
2872 APEX supports the Websockets as input as well as output.
2873 WS IO is supported by the APEX Websocket plugin. This
2874 carrier technology does only support uni-directional
2875 communication. APEX will not send events to a Websocket
2876 input and any event sent to a Websocket output will
2877 result in an error log.
2878
2879 .. container:: paragraph
2880
2881 The input can be configured as client (APEX connects to
2882 an existing Websocket server) or server (APEX starts a
2883 Websocket server). The same applies to the output. Input
2884 and output can both use a client or a server
2885 configuration, or separate configurations (input as
2886 client and output as server, input as server and output
2887 as client). Each configuration should use its own
2888 dedicated port to avoid any communication loops. The
2889 configuration of a Websocket client is the same for input
2890 and output. The configuration of a Websocket server is
2891 the same for input and output.
2892
2893Websocket Client
2894================
2895
2896 .. container:: paragraph
2897
2898 APEX will connect to a given Websocket server. As
2899 input, it will receive events from the server but not
2900 send any events. As output, it will send events to the
2901 server and any event received from the server will
2902 result in an error log.
2903
2904 .. container:: listingblock
2905
2906 .. container:: content
2907
ramverma760cce92019-07-11 12:57:49 +00002908 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002909
2910 "carrierTechnologyParameters" : {
2911 "carrierTechnology" : "WEBSOCKET", (1)
2912 "parameterClassName" :
2913 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2914 "parameters" : {
2915 "host" : "localhost", (2)
2916 "port" : 42451 (3)
2917 }
2918 }
2919
2920 .. container:: colist arabic
2921
2922 +-------+------------------------------------------------------+
2923 | **1** | set Websocket as carrier technology |
2924 +-------+------------------------------------------------------+
2925 | **2** | the host name on which a Websocket server is running |
2926 +-------+------------------------------------------------------+
2927 | **3** | the port of that Websocket server |
2928 +-------+------------------------------------------------------+
2929
2930Websocket Server
2931================
2932
2933 .. container:: paragraph
2934
2935 APEX will start a Websocket server, which will accept
2936 any Websocket clients to connect. As input, it will
2937 receive events from the server but not send any
2938 events. As output, it will send events to the server
2939 and any event received from the server will result in
2940 an error log.
2941
2942 .. container:: listingblock
2943
2944 .. container:: content
2945
ramverma760cce92019-07-11 12:57:49 +00002946 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002947
2948 "carrierTechnologyParameters" : {
2949 "carrierTechnology" : "WEBSOCKET", (1)
2950 "parameterClassName" :
2951 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2952 "parameters" : {
2953 "wsClient" : false, (2)
2954 "port" : 42450 (3)
2955 }
2956 }
2957
2958 .. container:: colist arabic
2959
2960 +-------+------------------------------------------------------------+
2961 | **1** | set Websocket as carrier technology |
2962 +-------+------------------------------------------------------------+
2963 | **2** | disable client, so that APEX will start a Websocket server |
2964 +-------+------------------------------------------------------------+
2965 | **3** | the port for the Websocket server APEX will start |
2966 +-------+------------------------------------------------------------+
2967
2968REST Client IO
2969##############
2970
2971 .. container:: paragraph
2972
2973 APEX can act as REST client on the input as well as on
2974 the output interface. The media type is
a.sreekumarcc0e9172020-03-16 13:36:45 +00002975 ``application/json``, so this plugin only works with
ramverma3b71c972019-07-10 11:25:37 +00002976 the JSON Event protocol.
2977
2978REST Client Input
2979=================
2980
2981 .. container:: paragraph
2982
2983 APEX will connect to a given URL to receive events,
2984 but not send any events. The server is polled, i.e.
2985 APEX will do an HTTP GET, take the result, and then do
2986 the next GET. Any required timing needs to be handled
2987 by the server configured via the URL. For instance,
2988 the server could support a wait timeout via the URL as
2989 ``?timeout=100ms``.
Henry.Sun2941bc02019-07-22 08:32:32 +00002990 The httpCodeFilter is used for filtering the status
2991 code, and it can be configured as a regular expression
2992 string. The default httpCodeFilter is "[2][0-9][0-9]"
2993 - for successful response codes.
2994 The response with HTTP status code that matches the
2995 given regular expression is forwarded to the task,
2996 otherwise it is logged as a failure.
ramverma3b71c972019-07-10 11:25:37 +00002997
2998 .. container:: listingblock
2999
3000 .. container:: content
3001
ramverma760cce92019-07-11 12:57:49 +00003002 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003003
3004 "carrierTechnologyParameters" : {
3005 "carrierTechnology" : "RESTCLIENT", (1)
3006 "parameterClassName" :
3007 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3008 "parameters" : {
3009 "url" : "http://example.org:8080/triggers/events", (2)
liamfallon75e2bbf2020-07-06 11:41:38 +01003010 "httpMethod": "GET", (3)
3011 "httpCodeFilter" : "[2][0-9][0-9]", (4)
3012 "httpHeaders" : [ (5)
3013 ["Keep-Alive", "300"],
3014 ["Cache-Control", "no-cache"]
3015 ]
ramverma3b71c972019-07-10 11:25:37 +00003016 }
3017 }
3018
3019 .. container:: colist arabic
3020
Henry.Sun2941bc02019-07-22 08:32:32 +00003021 +-------+--------------------------------------------------+
3022 | **1** | set REST client as carrier technology |
3023 +-------+--------------------------------------------------+
3024 | **2** | the URL of the HTTP server for events |
3025 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003026 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3027 | | optional, defaults to GET |
3028 +-------+--------------------------------------------------+
3029 | **4** | use HTTP CODE FILTER for filtering status code, |
3030 | | optional, defaults to [2][0-9][0-9] |
3031 +-------+--------------------------------------------------+
3032 | **5** | HTTP headers to use on the REST request, |
3033 | | optional |
Henry.Sun2941bc02019-07-22 08:32:32 +00003034 +-------+--------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003035
3036REST Client Output
3037==================
3038
3039 .. container:: paragraph
3040
3041 APEX will connect to a given URL to send events, but
3042 not receive any events. The default HTTP operation is
3043 POST (no configuration required). To change it to PUT
3044 simply add the configuration parameter (as shown in
3045 the example below).
ning.xi8bc537d2019-07-18 07:50:10 +00003046 The URL can be configured statically or tagged
3047 as ``?example.{site}.org:8080/{trig}/events``,
3048 all tags such as ``site`` and ``trig`` in the URL
Henry.Sun2941bc02019-07-22 08:32:32 +00003049 need to be set in the properties object available to
3050 the tasks. In addition, the keys should exactly match
3051 with the tags defined in url. The scope of the properties
3052 object is per HTTP call. Hence, key/value pairs set
3053 in the properties object by task are only available
3054 for that specific HTTP call.
ramverma3b71c972019-07-10 11:25:37 +00003055
3056 .. container:: listingblock
3057
3058 .. container:: content
3059
ramverma760cce92019-07-11 12:57:49 +00003060 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003061
3062 "carrierTechnologyParameters" : {
3063 "carrierTechnology" : "RESTCLIENT", (1)
3064 "parameterClassName" :
3065 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3066 "parameters" : {
3067 "url" : "http://example.com:8888/actions/events", (2)
ning.xi8bc537d2019-07-18 07:50:10 +00003068 "url" : "http://example.{site}.com:8888/{trig}/events", (2')
liamfallon75e2bbf2020-07-06 11:41:38 +01003069 "httpMethod" : "PUT". (3)
3070 "httpHeaders" : [ (4)
3071 ["Keep-Alive", "300"],
3072 ["Cache-Control", "no-cache"]
3073 ] }
ramverma3b71c972019-07-10 11:25:37 +00003074 }
3075
3076 .. container:: colist arabic
3077
3078 +-------+--------------------------------------------------+
3079 | **1** | set REST client as carrier technology |
3080 +-------+--------------------------------------------------+
ning.xi8bc537d2019-07-18 07:50:10 +00003081 | **2** | the static URL of the HTTP server for events |
3082 +-------+--------------------------------------------------+
3083 | **2'**| the tagged URL of the HTTP server for events |
ramverma3b71c972019-07-10 11:25:37 +00003084 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003085 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3086 | | optional, defaults to POST |
3087 +-------+--------------------------------------------------+
3088 | **4** | HTTP headers to use on the REST request, |
3089 | | optional |
ramverma3b71c972019-07-10 11:25:37 +00003090 +-------+--------------------------------------------------+
3091
3092REST Server IO
3093##############
3094
3095 .. container:: paragraph
3096
3097 APEX supports a REST server for input and output.
3098
3099 .. container:: paragraph
3100
3101 The REST server plugin always uses a synchronous mode. A
3102 client does a HTTP GET on the APEX REST server with the
3103 input event and receives the generated output event in
3104 the server reply. This means that for the REST server
3105 there has to always to be an input with an associated
3106 output. Input or output only are not permitted.
3107
3108 .. container:: paragraph
3109
3110 The plugin will start a Grizzly server as REST server for
3111 a normal APEX engine. If the APEX engine is executed as a
3112 servlet, for instance inside Tomcat, then Tomcat will be
3113 used as REST server (this case requires configuration on
3114 Tomcat as well).
3115
3116 .. container:: paragraph
3117
3118 Some configuration restrictions apply for all scenarios:
3119
3120 .. container:: ulist
3121
3122 - Minimum port: 1024
3123
3124 - Maximum port: 65535
3125
3126 - The media type is ``application/json``, so this plugin
a.sreekumarcc0e9172020-03-16 13:36:45 +00003127 only works with the JSON Event protocol.
ramverma3b71c972019-07-10 11:25:37 +00003128
3129 .. container:: paragraph
3130
3131 The URL the client calls is created using
3132
3133 .. container:: ulist
3134
3135 - the configured host and port, e.g.
3136 ``http://localhost:12345``
3137
3138 - the standard path, e.g. ``/apex/``
3139
3140 - the name of the input/output, e.g. ``FirstConsumer/``
3141
3142 - the input or output name, e.g. ``EventIn``.
3143
3144 .. container:: paragraph
3145
3146 The examples above lead to the URL
3147 ``http://localhost:12345/apex/FirstConsumer/EventIn``.
3148
3149 .. container:: paragraph
3150
3151 A client can also get status information of the REST
3152 server using ``/Status``, e.g.
3153 ``http://localhost:12345/apex/FirstConsumer/Status``.
3154
3155REST Server Stand-alone
3156=======================
3157
3158 .. container:: paragraph
3159
3160 We need to configure a REST server input and a REST
3161 server output. Input and output are associated with
3162 each other via there name.
3163
3164 .. container:: paragraph
3165
3166 Timeouts for REST calls need to be set carefully. If
3167 they are too short, the call might timeout before a
3168 policy finished creating an event.
3169
3170 .. container:: paragraph
3171
3172 The following example configures the input named as
3173 ``MyConsumer`` and associates an output named
3174 ``MyProducer`` with it.
3175
3176 .. container:: listingblock
3177
3178 .. container:: content
3179
ramverma760cce92019-07-11 12:57:49 +00003180 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003181
3182 "eventInputParameters": {
3183 "MyConsumer": {
3184 "carrierTechnologyParameters" : {
3185 "carrierTechnology" : "RESTSERVER", (1)
3186 "parameterClassName" :
3187 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters",
3188 "parameters" : {
3189 "standalone" : true, (2)
3190 "host" : "localhost", (3)
3191 "port" : 12345 (4)
3192 }
3193 },
3194 "eventProtocolParameters":{
3195 "eventProtocol" : "JSON" (5)
3196 },
3197 "synchronousMode" : true, (6)
3198 "synchronousPeer" : "MyProducer", (7)
3199 "synchronousTimeout" : 500 (8)
3200 }
3201 }
3202
3203 .. container:: colist arabic
3204
3205 +-------+---------------------------------------+
3206 | **1** | set REST server as carrier technology |
3207 +-------+---------------------------------------+
3208 | **2** | set the server as stand-alone |
3209 +-------+---------------------------------------+
3210 | **3** | set the server host |
3211 +-------+---------------------------------------+
3212 | **4** | set the server listen port |
3213 +-------+---------------------------------------+
3214 | **5** | use JSON event protocol |
3215 +-------+---------------------------------------+
3216 | **6** | activate synchronous mode |
3217 +-------+---------------------------------------+
3218 | **7** | associate an output ``MyProducer`` |
3219 +-------+---------------------------------------+
3220 | **8** | set a timeout of 500 milliseconds |
3221 +-------+---------------------------------------+
3222
3223 .. container:: paragraph
3224
3225 The following example configures the output named as
3226 ``MyProducer`` and associates the input ``MyConsumer``
3227 with it. Note that for the output there are no more
3228 paramters (such as host or port), since they are
3229 already configured in the associated input
3230
3231 .. container:: listingblock
3232
3233 .. container:: content
3234
ramverma760cce92019-07-11 12:57:49 +00003235 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003236
3237 "eventOutputParameters": {
3238 "MyProducer": {
3239 "carrierTechnologyParameters":{
3240 "carrierTechnology" : "RESTSERVER",
3241 "parameterClassName" :
3242 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters"
3243 },
3244 "eventProtocolParameters":{
3245 "eventProtocol" : "JSON"
3246 },
3247 "synchronousMode" : true,
3248 "synchronousPeer" : "MyConsumer",
3249 "synchronousTimeout" : 500
3250 }
3251 }
3252
3253REST Server Stand-alone, multi input
3254====================================
3255
3256 .. container:: paragraph
3257
3258 Any number of input/output pairs for REST servers can
3259 be configured. For instance, we can configure an input
3260 ``FirstConsumer`` with output ``FirstProducer`` and an
3261 input ``SecondConsumer`` with output
3262 ``SecondProducer``. Important is that there is always
3263 one pair of input/output.
3264
3265REST Server Stand-alone in Servlet
3266==================================
3267
3268 .. container:: paragraph
3269
3270 If APEX is executed as a servlet, e.g. inside Tomcat,
3271 the configuration becomes easier since the plugin can
3272 now use Tomcat as the REST server. In this scenario,
3273 there are not parameters (port, host, etc.) and the
3274 key ``standalone`` must not be used (or set to false).
3275
3276 .. container:: paragraph
3277
3278 For the Tomcat configuration, we need to add the REST
3279 server plugin, e.g.
3280
3281 .. container:: listingblock
3282
3283 .. container:: content
3284
ramverma760cce92019-07-11 12:57:49 +00003285 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003286
3287 <servlet>
3288 ...
3289 <init-param>
3290 ...
3291 <param-value>org.onap.policy.apex.plugins.event.carrier.restserver</param-value>
3292 </init-param>
3293 ...
3294 </servlet>
3295
3296REST Requestor IO
liamfallonb621de42020-08-21 12:59:26 +01003297#################
ramverma3b71c972019-07-10 11:25:37 +00003298
3299 .. container:: paragraph
3300
3301 APEX can act as REST requestor on the input as well as on
3302 the output interface. The media type is
a.sreekumarcc0e9172020-03-16 13:36:45 +00003303 ``application/json``, so this plugin only works with
liamfallon75e2bbf2020-07-06 11:41:38 +01003304 the JSON Event protocol. This plugin allows APEX to send REST requests
3305 and to receive the reply of that request without tying up APEX resources
3306 while the request is being processed. The REST Requestor pairs a REST
3307 requestor producer and consumer together to handle the REST request
3308 and response. The REST request is created from an APEX output event
3309 and the REST response is input into APEX as a new input event.
ramverma3b71c972019-07-10 11:25:37 +00003310
liamfallon75e2bbf2020-07-06 11:41:38 +01003311REST Requestor Output (REST Request Producer)
3312=============================================
ramverma3b71c972019-07-10 11:25:37 +00003313
3314 .. container:: paragraph
3315
liamfallon75e2bbf2020-07-06 11:41:38 +01003316 APEX sends a REST request when events are output by APEX, the REST
3317 request configuration is specified on the REST Request Consumer (see
3318 below).
3319
3320 .. container:: listingblock
3321
3322 .. container:: content
3323
3324 .. code::
3325
3326 "carrierTechnologyParameters": {
3327 "carrierTechnology": "RESTREQUESTOR", (1)
3328 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
3329 },
3330
3331 .. container:: colist arabic
3332
3333 +-------+------------------------------------------+
3334 | **1** | set REST requestor as carrier technology |
3335 +-------+------------------------------------------+
3336
3337 .. container:: paragraph
3338
3339 The settings below are required on the producer to
3340 define the event that triggers the REST request and
3341 to specify the peered consumer configuration for the
3342 REST request, for example:
3343
3344 .. container:: listingblock
3345
3346 .. container:: content
3347
3348 .. code::
3349
3350 "eventNameFilter": "GuardRequestEvent", (1)
3351 "requestorMode": true, (2)
3352 "requestorPeer": "GuardRequestorConsumer", (3)
3353 "requestorTimeout": 500 (4)
3354
3355 .. container:: colist arabic
3356
3357 +-------+-------------------------------------------+
3358 | **1** | a filter on the event |
3359 +-------+-------------------------------------------+
3360 | **2** | requestor mode must be set to *true* |
3361 +-------+-------------------------------------------+
3362 | **3** | the peered consumer for REST requests, |
3363 | | that consumer specifies the full |
3364 | | configuration for REST requests |
3365 +-------+-------------------------------------------+
3366 | **4** | the request timeout in milliseconds, |
3367 | | overridden by timeout on consumer if that |
3368 | | is set, optional defaults to 500 |
3369 | | millisconds |
3370 +-------+-------------------------------------------+
3371
3372REST Requestor Input (REST Request Consumer)
3373============================================
3374
3375 .. container:: paragraph
3376
3377 APEX will connect to a given URL to issue a REST request and
3378 wait for a REST response.
ning.xi8bc537d2019-07-18 07:50:10 +00003379 The URL can be configured statically or tagged
3380 as ``?example.{site}.org:8080/{trig}/events``,
3381 all tags such as ``site`` and ``trig`` in the URL
Henry.Sun2941bc02019-07-22 08:32:32 +00003382 need to be set in the properties object available to
3383 the tasks. In addition, the keys should exactly match
3384 with the tags defined in url. The scope of the properties
3385 object is per HTTP call. Hence, key/value pairs set
3386 in the properties object by task are only available
3387 for that specific HTTP call.
3388 The httpCodeFilter is used for filtering the status
3389 code, and it can be configured as a regular expression
3390 string. The default httpCodeFilter is "[2][0-9][0-9]"
3391 - for successful response codes.
3392 The response with HTTP status code that matches the
3393 given regular expression is forwarded to the task,
3394 otherwise it is logged as a failure.
ramverma3b71c972019-07-10 11:25:37 +00003395
3396 .. container:: listingblock
3397
3398 .. container:: content
3399
ramverma760cce92019-07-11 12:57:49 +00003400 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003401
3402 "carrierTechnologyParameters": {
3403 "carrierTechnology": "RESTREQUESTOR", (1)
3404 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
3405 "parameters": {
3406 "url": "http://localhost:54321/some/path/to/rest/resource", (2)
ning.xi8bc537d2019-07-18 07:50:10 +00003407 "url": "http://localhost:54321/{site}/path/to/rest/{resValue}", (2')
ramverma3b71c972019-07-10 11:25:37 +00003408 "httpMethod": "POST", (3)
liamfallon75e2bbf2020-07-06 11:41:38 +01003409 "requestorMode": true, (4)
3410 "requestorPeer": "GuardRequestorProducer", (5)
3411 "restRequestTimeout": 2000, (6)
3412 "httpCodeFilter" : "[2][0-9][0-9]" (7)
3413 "httpHeaders" : [ (8)
3414 ["Keep-Alive", "300"],
3415 ["Cache-Control", "no-cache"]
3416 ] }
ramverma3b71c972019-07-10 11:25:37 +00003417 },
3418
3419 .. container:: colist arabic
3420
3421 +-------+--------------------------------------------------+
3422 | **1** | set REST requestor as carrier technology |
3423 +-------+--------------------------------------------------+
ning.xi8bc537d2019-07-18 07:50:10 +00003424 | **2** | the static URL of the HTTP server for events |
3425 +-------+--------------------------------------------------+
3426 | **2'**| the tagged URL of the HTTP server for events |
ramverma3b71c972019-07-10 11:25:37 +00003427 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003428 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3429 | | optional, defaults to GET |
ramverma3b71c972019-07-10 11:25:37 +00003430 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003431 | **4** | requestor mode must be set to *true* |
ramverma3b71c972019-07-10 11:25:37 +00003432 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003433 | **5** | the peered producer for REST requests, that |
3434 | | producer specifies the APEX output event that |
3435 | | triggers the REST request |
3436 +-------+--------------------------------------------------+
3437 | **6** | request timeout in milliseconds, overrides any |
3438 | | value set in the REST Requestor Producer, |
3439 | | optional, defaults to 500 millisconds |
3440 +-------+--------------------------------------------------+
3441 | **7** | use HTTP CODE FILTER for filtering status code |
3442 | | optional, defaults to [2][0-9][0-9] |
3443 +-------+--------------------------------------------------+
3444 | **8** | HTTP headers to use on the REST request, |
3445 | | optional |
Henry.Sun2941bc02019-07-22 08:32:32 +00003446 +-------+--------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003447
3448 .. container:: paragraph
3449
liamfallon75e2bbf2020-07-06 11:41:38 +01003450 Further settings may be required on the consumer to
3451 define the input event that is produced and forwarded into
3452 APEX, for example:
ramverma3b71c972019-07-10 11:25:37 +00003453
3454 .. container:: listingblock
3455
3456 .. container:: content
3457
ramverma760cce92019-07-11 12:57:49 +00003458 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003459
3460 "eventName": "GuardResponseEvent", (1)
liamfallon75e2bbf2020-07-06 11:41:38 +01003461 "eventNameFilter": "GuardResponseEvent" (2)
ramverma3b71c972019-07-10 11:25:37 +00003462
3463 .. container:: colist arabic
3464
3465 +-------+---------------------------+
3466 | **1** | the event name |
3467 +-------+---------------------------+
3468 | **2** | a filter on the event |
3469 +-------+---------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003470
a.sreekumarcc0e9172020-03-16 13:36:45 +00003471gRPC IO
3472#######
3473
3474 .. container:: paragraph
3475
3476 APEX can send requests over gRPC at the output side, and get back
3477 response at the input side. This can be used to send requests to CDS
3478 over gRPC. The media type is ``application/json``, so this plugin
3479 only works with the JSON Event protocol.
3480
3481gRPC Output
3482===========
3483
3484 .. container:: paragraph
3485
3486 APEX will connect to a given host to send a request over
3487 gRPC.
3488
3489 .. container:: listingblock
3490
3491 .. container:: content
3492
3493 .. code::
3494
3495 "carrierTechnologyParameters": {
3496 "carrierTechnology": "GRPC", (1)
3497 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
3498 "parameters": {
3499 "host": "cds-blueprints-processor-grpc", (2)
3500 "port": 9111, (2')
3501 "username": "ccsdkapps", (3)
3502 "password": ccsdkapps, (4)
3503 "timeout" : 10 (5)
3504 }
3505 },
3506
3507 .. container:: colist arabic
3508
3509 +-------+--------------------------------------------------+
3510 | **1** | set GRPC as carrier technology |
3511 +-------+--------------------------------------------------+
3512 | **2** | the host to which request is sent |
3513 +-------+--------------------------------------------------+
3514 | **2'**| the value for port |
3515 +-------+--------------------------------------------------+
3516 | **3** | username required to initiate connection |
3517 +-------+--------------------------------------------------+
3518 | **4** | password required to initiate connection |
3519 +-------+--------------------------------------------------+
3520 | **5** | the timeout value for completing the request |
3521 +-------+--------------------------------------------------+
3522
3523 .. container:: paragraph
3524
3525 Further settings are required on the producer to
3526 define the event that is requested, for example:
3527
3528 .. container:: listingblock
3529
3530 .. container:: content
3531
3532 .. code::
3533
3534 "eventName": "GRPCRequestEvent", (1)
3535 "eventNameFilter": "GRPCRequestEvent", (2)
3536 "requestorMode": true, (3)
3537 "requestorPeer": "GRPCRequestConsumer", (4)
3538 "requestorTimeout": 500 (5)
3539
3540 .. container:: colist arabic
3541
3542 +-------+---------------------------+
3543 | **1** | the event name |
3544 +-------+---------------------------+
3545 | **2** | a filter on the event |
3546 +-------+---------------------------+
3547 | **3** | the mode of the requestor |
3548 +-------+---------------------------+
3549 | **4** | a peer for the requestor |
3550 +-------+---------------------------+
3551 | **5** | a general request timeout |
3552 +-------+---------------------------+
3553
3554gRPC Input
3555==========
3556
3557 .. container:: paragraph
3558
3559 APEX will connect to the host specified in the producer
3560 side, anad take in response back at the consumer side.
3561
3562 .. container:: listingblock
3563
3564 .. container:: content
3565
3566 .. code::
3567
3568 "carrierTechnologyParameters": {
3569 "carrierTechnology": "GRPC", (1)
3570 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
3571 },
3572
3573 .. container:: colist arabic
3574
3575 +-------+------------------------------------------+
3576 | **1** | set GRPC as carrier technology |
3577 +-------+------------------------------------------+
3578
3579 .. container:: paragraph
3580
3581 Further settings are required on the consumer to
3582 define the event that is requested, for example:
3583
3584 .. container:: listingblock
3585
3586 .. container:: content
3587
3588 .. code::
3589
3590 "eventNameFilter": "GRPCResponseEvent", (1)
3591 "requestorMode": true, (2)
3592 "requestorPeer": "GRPCRequestProducer", (3)
3593 "requestorTimeout": 500 (4)
3594
3595 .. container:: colist arabic
3596
3597 +-------+---------------------------+
3598 | **1** | a filter on the event |
3599 +-------+---------------------------+
3600 | **2** | the mode of the requestor |
3601 +-------+---------------------------+
3602 | **3** | a peer for the requestor |
3603 +-------+---------------------------+
3604 | **4** | a general request timeout |
3605 +-------+---------------------------+
3606
ramverma3b71c972019-07-10 11:25:37 +00003607Event Protocols, Format and Encoding
3608------------------------------------
3609
3610 .. container:: paragraph
3611
3612 Event protocols define what event formats APEX can receive
3613 (input) and should send (output). They can be used in any
3614 combination for input and output, unless further restricted
3615 by a carrier technology plugin (for instance for JMS
3616 output). There can only be 1 event protocol per event
3617 plugin.
3618
3619 .. container:: paragraph
3620
3621 Supported *input* event protocols are:
3622
3623 .. container:: ulist
3624
3625 - JSON, the event as a JSON string
3626
3627 - APEX, an APEX event
3628
3629 - JMS object, the event as a JMS object,
3630
3631 - JMS text, the event as a JMS text,
3632
3633 - XML, the event as an XML string,
3634
3635 - YAML, the event as YAML text
3636
3637 .. container:: paragraph
3638
3639 Supported *output* event protocols are:
3640
3641 .. container:: ulist
3642
3643 - JSON, the event as a JSON string
3644
3645 - APEX, an APEX event
3646
3647 - JMS object, the event as a JMS object,
3648
3649 - JMS text, the event as a JMS text,
3650
3651 - XML, the event as an XML string,
3652
3653 - YAML, the event as YAML text
3654
3655 .. container:: paragraph
3656
3657 New event protocols can be added as plugins to APEX or
3658 developed outside APEX and added to an APEX deployment.
3659
3660JSON Event
3661##########
3662
3663 .. container:: paragraph
3664
3665 The event protocol for JSON encoding does not require a
3666 specific plugin, it is supported by default. Furthermore,
3667 there is no difference in the configuration for the input
3668 and output interface.
3669
3670 .. container:: paragraph
3671
3672 For an input, APEX requires a well-formed JSON string.
3673 Well-formed here means according to the definitions of a
3674 policy. Any JSON string that is not defined as a trigger
3675 event (consume) will not be consumed (errors will be
3676 thrown). For output JSON events, APEX will always produce
3677 valid JSON strings according to the definition in the
3678 policy model.
3679
3680 .. container:: paragraph
3681
3682 The following JSON shows the configuration.
3683
3684 .. container:: listingblock
3685
3686 .. container:: content
3687
ramverma760cce92019-07-11 12:57:49 +00003688 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003689
3690 "eventProtocolParameters":{
3691 "eventProtocol" : "JSON"
3692 }
3693
3694 .. container:: paragraph
3695
3696 For JSON events, there are a few more optional
3697 parameters, which allow to define a mapping for standard
3698 event fields. An APEX event must have the fields
3699 ``name``, ``version``, ``source``, and ``target``
3700 defined. Sometimes it is not possible to configure a
3701 trigger or actioning system to use those fields. However,
3702 they might be in an event generated outside APEX (or used
3703 outside APEX) just with different names. To configure
3704 APEX to map between the different event names, simply add
3705 the following parameters to a JSON event:
3706
3707 .. container:: listingblock
3708
3709 .. container:: content
3710
ramverma760cce92019-07-11 12:57:49 +00003711 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003712
3713 "eventProtocolParameters":{
3714 "eventProtocol" : "JSON",
3715 "nameAlias" : "policyName", (1)
3716 "versionAlias" : "policyVersion", (2)
3717 "sourceAlias" : "from", (3)
3718 "targetAlias" : "to", (4)
3719 "nameSpaceAlias": "my.name.space" (5)
3720 }
3721
3722 .. container:: colist arabic
3723
3724 +-----------------------------------+-----------------------------------+
3725 | **1** | mapping for the ``name`` field, |
3726 | | here from a field called |
3727 | | ``policyName`` |
3728 +-----------------------------------+-----------------------------------+
3729 | **2** | mapping for the ``version`` |
3730 | | field, here from a field called |
3731 | | ``policyVersion`` |
3732 +-----------------------------------+-----------------------------------+
3733 | **3** | mapping for the ``source`` field, |
3734 | | here from a field called ``from`` |
3735 | | (only for an input event) |
3736 +-----------------------------------+-----------------------------------+
3737 | **4** | mapping for the ``target`` field, |
3738 | | here from a field called ``to`` |
3739 | | (only for an output event) |
3740 +-----------------------------------+-----------------------------------+
3741 | **5** | mapping for the ``nameSpace`` |
3742 | | field, here from a field called |
3743 | | ``my.name.space`` |
3744 +-----------------------------------+-----------------------------------+
3745
3746APEX Event
3747##########
3748 .. container:: paragraph
3749
3750 The event protocol for APEX events does not require a
3751 specific plugin, it is supported by default. Furthermore,
3752 there is no difference in the configuration for the input
3753 and output interface.
3754
3755 .. container:: paragraph
3756
3757 For input and output APEX uses APEX events.
3758
3759 .. container:: paragraph
3760
3761 The following JSON shows the configuration.
3762
3763 .. container:: listingblock
3764
3765 .. container:: content
3766
ramverma760cce92019-07-11 12:57:49 +00003767 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003768
3769 "eventProtocolParameters":{
3770 "eventProtocol" : "APEX"
3771 }
3772
3773JMS Event
3774#########
3775
3776 .. container:: paragraph
3777
3778 The event protocol for JMS is provided by the APEX JMS
3779 plugin. The plugin supports encoding as JSON text or as
3780 object. There is no difference in the configuration for
3781 the input and output interface.
3782
3783JMS Text
3784========
3785 .. container:: paragraph
3786
3787 If used as input, APEX will take a JMS message and
3788 extract a JSON string, then proceed as if a JSON event
3789 was received. If used as output, APEX will take the
3790 event produced by a policy, create a JSON string, and
3791 then wrap it into a JMS message.
3792
3793 .. container:: paragraph
3794
3795 The configuration for JMS text is as follows:
3796
3797 .. container:: listingblock
3798
3799 .. container:: content
3800
ramverma760cce92019-07-11 12:57:49 +00003801 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003802
3803 "eventProtocolParameters":{
3804 "eventProtocol" : "JMSTEXT",
3805 "parameterClassName" :
3806 "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters"
3807 }
3808
3809JMS Object
3810==========
3811 .. container:: paragraph
3812
3813 If used as input, APEX will will take a JMS message,
3814 extract a Java Bean from the ``ObjectMessage``
3815 message, construct an APEX event and put the bean on
3816 the APEX event as a parameter. If used as output, APEX
3817 will take the event produced by a policy, create a
3818 Java Bean and send it as a JMS message.
3819
3820 .. container:: paragraph
3821
3822 The configuration for JMS object is as follows:
3823
3824 .. container:: listingblock
3825
3826 .. container:: content
3827
ramverma760cce92019-07-11 12:57:49 +00003828 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003829
3830 "eventProtocolParameters":{
3831 "eventProtocol" : "JMSOBJECT",
3832 "parameterClassName" :
3833 "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters"
3834 }
3835
3836YAML Event
3837##########
3838
3839 .. container:: paragraph
3840
3841 The event protocol for YAML is provided by the APEX YAML
3842 plugin. There is no difference in the configuration for
3843 the input and output interface.
3844
3845 .. container:: paragraph
3846
3847 If used as input, APEX will consume events as YAML and
3848 map them to policy trigger events. Not well-formed YAML
3849 and not understood trigger events will be rejected. If
3850 used as output, APEX produce YAML encoded events from the
3851 event a policy produces. Those events will always be
3852 well-formed according to the definition in the policy
3853 model.
3854
3855 .. container:: paragraph
3856
3857 The following code shows the configuration.
3858
3859 .. container:: listingblock
3860
3861 .. container:: content
3862
ramverma760cce92019-07-11 12:57:49 +00003863 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003864
3865 "eventProtocolParameters":{
3866 "eventProtocol" : "XML",
3867 "parameterClassName" :
3868 "org.onap.policy.apex.plugins.event.protocol.yaml.YamlEventProtocolParameters"
3869 }
3870
3871XML Event
3872#########
3873 .. container:: paragraph
3874
3875 The event protocol for XML is provided by the APEX XML
3876 plugin. There is no difference in the configuration for
3877 the input and output interface.
3878
3879 .. container:: paragraph
3880
3881 If used as input, APEX will consume events as XML and map
3882 them to policy trigger events. Not well-formed XML and
3883 not understood trigger events will be rejected. If used
3884 as output, APEX produce XML encoded events from the event
3885 a policy produces. Those events will always be
3886 well-formed according to the definition in the policy
3887 model.
3888
3889 .. container:: paragraph
3890
3891 The following code shows the configuration.
3892
3893 .. container:: listingblock
3894
3895 .. container:: content
3896
ramverma760cce92019-07-11 12:57:49 +00003897 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003898
3899 "eventProtocolParameters":{
3900 "eventProtocol" : "XML",
3901 "parameterClassName" :
3902 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3903 }
3904
3905A configuration example
3906-----------------------
3907
3908 .. container:: paragraph
3909
3910 The following example loads all available plug-ins.
3911
3912 .. container:: paragraph
3913
3914 Events are consumed from a Websocket, APEX as client.
3915 Consumed event format is JSON.
3916
3917 .. container:: paragraph
3918
3919 Events are produced to Kafka. Produced event format is XML.
3920
3921 .. container:: listingblock
3922
3923 .. container:: content
3924
ramverma760cce92019-07-11 12:57:49 +00003925 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003926
3927 {
3928 "engineServiceParameters" : {
3929 "name" : "MyApexEngine",
3930 "version" : "0.0.1",
3931 "id" : 45,
3932 "instanceCount" : 4,
3933 "deploymentPort" : 12345,
ramverma3b71c972019-07-10 11:25:37 +00003934 "engineParameters" : {
3935 "executorParameters" : {
3936 "JAVASCRIPT" : {
3937 "parameterClassName" :
3938 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
3939 },
3940 "JYTHON" : {
3941 "parameterClassName" :
3942 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
3943 },
3944 "JRUBY" : {
3945 "parameterClassName" :
3946 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
3947 },
3948 "JAVA" : {
3949 "parameterClassName" :
3950 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
3951 },
3952 "MVEL" : {
3953 "parameterClassName" :
3954 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
3955 }
3956 },
3957 "contextParameters" : {
3958 "parameterClassName" :
3959 "org.onap.policy.apex.context.parameters.ContextParameters",
3960 "schemaParameters" : {
3961 "Avro":{
3962 "parameterClassName" :
3963 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
3964 }
3965 }
3966 }
3967 }
3968 },
3969 "producerCarrierTechnologyParameters" : {
3970 "carrierTechnology" : "KAFKA",
3971 "parameterClassName" :
3972 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
3973 "parameters" : {
3974 "bootstrapServers" : "localhost:49092",
3975 "acks" : "all",
3976 "retries" : 0,
3977 "batchSize" : 16384,
3978 "lingerTime" : 1,
3979 "bufferMemory" : 33554432,
3980 "producerTopic" : "apex-out",
3981 "keySerializer" : "org.apache.kafka.common.serialization.StringSerializer",
3982 "valueSerializer" : "org.apache.kafka.common.serialization.StringSerializer"
3983 }
3984 },
3985 "producerEventProtocolParameters" : {
3986 "eventProtocol" : "XML",
3987 "parameterClassName" :
3988 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3989 },
3990 "consumerCarrierTechnologyParameters" : {
3991 "carrierTechnology" : "WEBSOCKET",
3992 "parameterClassName" :
3993 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
3994 "parameters" : {
3995 "host" : "localhost",
3996 "port" : 88888
3997 }
3998 },
3999 "consumerEventProtocolParameters" : {
4000 "eventProtocol" : "JSON"
4001 }
4002 }
4003
4004Engine and Applications of the APEX System
4005^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4006
4007Introduction to APEX Engine and Applications
4008--------------------------------------------
4009
4010 .. container:: paragraph
4011
4012 The core of APEX is the APEX Engine, also known as the APEX
4013 Policy Engine or the APEX PDP (since it is in fact a Policy
4014 Decision Point). Beside this engine, an APEX system comes
4015 with a few applications intended to help with policy
4016 authoring, deployment, and execution.
4017
4018 .. container:: paragraph
4019
4020 The engine itself and most applications are started from the
4021 command line with command line arguments. This is called a
4022 Command Line Interface (CLI). Some applications require an
4023 installation on a webserver, as for instance the REST
4024 Editor. Those applications can be accessed via a web
4025 browser.
4026
4027 .. container:: paragraph
4028
4029 You can also use the available APEX APIs and applications to
4030 develop other applications as required. This includes policy
4031 languages (and associated parsers and compilers /
4032 interpreters), GUIs to access APEX or to define policies,
4033 clients to connect to APEX, etc.
4034
4035 .. container:: paragraph
4036
4037 For this documentation, we assume an installation of APEX as
4038 a full system based on a current ONAP release.
4039
4040CLI on Unix, Windows, and Cygwin
4041--------------------------------
4042
4043 .. container:: paragraph
4044
4045 A note on APEX CLI applications: all applications and the
4046 engine itself have been deployed and tested on different
4047 operating systems: Red Hat, Ubuntu, Debian, Mac OSX,
4048 Windows, Cygwin. Each operating system comes with its own
4049 way of configuring and executing Java. The main items here
4050 are:
4051
4052 .. container:: ulist
4053
4054 - For UNIX systems (RHL, Ubuntu, Debian, Mac OSX), the
4055 provided bash scripts work as expected with absolute
4056 paths (e.g.
4057 ``/opt/app/policy/apex-pdp/apex-pdp-2.0.0-SNAPSHOT/examples``),
4058 indirect and linked paths (e.g. ``../apex/apex``), and
4059 path substitutions using environment settings (e.g.
4060 ``$APEX_HOME/bin/``)
4061
4062 - For Windows systems, the provided batch files (``.bat``)
4063 work as expected with with absolute paths (e.g.
4064 ``C:\apex\apex-2.0.0-SNAPSHOT\examples``), and path
4065 substitutions using environment settings (e.g.
4066 ``%APEX_HOME%\bin\``)
4067
4068 - For Cygwin system we assume a standard Cygwin
4069 installation with standard tools (mainly bash) using a
4070 Windows Java installation. This means that the bash
4071 scripts can be used as in UNIX, however any argument
4072 pointing to files and directories need to use either a
4073 DOS path (e.g.
4074 ``C:\apex\apex-2.0.0-SNAPSHOT\examples\config...``) or
4075 the command ``cygpath`` with a mixed option. The reason
4076 for that is: Cygwin executes Java using UNIX paths but
4077 then runs Java as a DOS/WINDOWS process, which requires
4078 DOS paths for file access.
4079
4080The APEX Engine
4081---------------
4082
4083 .. container:: paragraph
4084
4085 The APEX engine can be started in different ways, depending
4086 your requirements. All scripts are located in the APEX *bin*
4087 directory
4088
4089 .. container:: paragraph
4090
4091 On UNIX and Cygwin systems use:
4092
4093 .. container:: ulist
4094
4095 - ``apexEngine.sh`` - this script will
4096
4097 .. container:: ulist
4098
4099 - Test if ``$APEX_USER`` is set and if the user
4100 exists, terminate with an error otherwise
4101
4102 - Test if ``$APEX_HOME`` is set. If not set, it will
4103 use the default setting as
4104 ``/opt/app/policy/apex-pdp/apex-pdp``. Then the set
4105 directory is tested to exist, the script will
4106 terminate if not.
4107
4108 - When all tests are passed successfully, the script
4109 will call ``apexApps.sh`` with arguments to start
4110 the APEX engine.
4111
4112 - ``apexApps.sh engine`` - this is the general APEX
4113 application launcher, which will
4114
4115 .. container:: ulist
4116
4117 - Start the engine with the argument ``engine``
4118
4119 - Test if ``$APEX_HOME`` is set and points to an
4120 existing directory. If not set or directory does
4121 not exist, script terminates.
4122
4123 - Not test for any settings of ``$APEX_USER``.
4124
4125 .. container:: paragraph
4126
4127 On Windows systems use ``apexEngine.bat`` and
4128 ``apexApps.bat engine`` respectively. Note: none of the
4129 windows batch files will test for ``%APEX_USER%``.
4130
4131 .. container:: paragraph
4132
4133 Summary of alternatives to start the APEX Engine:
4134
4135 +--------------------------------------------------------+----------------------------------------------------------+
4136 | Unix, Cygwin | Windows |
4137 +========================================================+==========================================================+
4138 | .. container:: | .. container:: |
4139 | | |
4140 | .. container:: listingblock | .. container:: listingblock |
4141 | | |
4142 | .. container:: content | .. container:: content |
4143 | | |
4144 | .. code:: | .. code:: |
4145 | | |
4146 | # $APEX_HOME/bin/apexEngine.sh [args] | > %APEX_HOME%\bin\apexEngine.bat [args] |
4147 | # $APEX_HOME/bin/apexApps.sh engine [args] | > %APEX_HOME%\bin\apexApps.bat engine [args] |
4148 +--------------------------------------------------------+----------------------------------------------------------+
4149
4150 .. container:: paragraph
4151
a.sreekumarcf3ff822020-09-16 13:12:29 +01004152 The APEX engine comes with a few CLI arguments, the main one is for setting
4153 the tosca policy file for execution. The tosca policy file is
4154 always required. The option ``-h`` prints a help screen.
ramverma3b71c972019-07-10 11:25:37 +00004155
4156 .. container:: listingblock
4157
4158 .. container:: content
4159
ramverma760cce92019-07-11 12:57:49 +00004160 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004161
4162 usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]
4163 options
a.sreekumarcf3ff822020-09-16 13:12:29 +01004164 -p,--tosca-policy-file <TOSCA_POLICY_FILE> the full path to the ToscaPolicy file to use.
4165 -h,--help outputs the usage of this command
4166 -v,--version outputs the version of Apex
ramverma3b71c972019-07-10 11:25:37 +00004167
4168The APEX CLI Editor
4169-------------------
4170
4171 .. container:: paragraph
4172
4173 The CLI Editor allows to define policies from the command
4174 line. The application uses a simple language and supports
4175 all elements of an APEX policy. It can be used in to
4176 different ways:
4177
4178 .. container:: ulist
4179
4180 - non-interactive, specifying a file with the commands to
4181 create a policy
4182
4183 - interactive, using the editors CLI to create a policy
4184
4185 .. container:: paragraph
4186
4187 When a policy is fully specified, the editor will generate
4188 the APEX core policy specification in JSON. This core
4189 specification is called the policy model in the APEX engine
4190 and can be used directly with the APEX engine.
4191
4192 .. container:: paragraph
4193
4194 On UNIX and Cygwin systems use:
4195
4196 .. container:: ulist
4197
4198 - ``apexCLIEditor.sh`` - simply starts the CLI editor,
4199 arguments to the script determine the mode of the editor
4200
4201 - ``apexApps.sh cli-editor`` - simply starts the CLI
4202 editor, arguments to the script determine the mode of the
4203 editor
4204
4205 .. container:: paragraph
4206
4207 On Windows systems use:
4208
4209 .. container:: ulist
4210
4211 - ``apexCLIEditor.bat`` - simply starts the CLI editor,
4212 arguments to the script determine the mode of the editor
4213
4214 - ``apexApps.bat cli-editor`` - simply starts the CLI
4215 editor, arguments to the script determine the mode of the
4216 editor
4217
4218 .. container:: paragraph
4219
4220 Summary of alternatives to start the APEX CLI Editor:
4221
4222 +------------------------------------------------------------+--------------------------------------------------------------+
4223 | Unix, Cygwin | Windows |
4224 +============================================================+==============================================================+
4225 | .. container:: | .. container:: |
4226 | | |
4227 | .. container:: listingblock | .. container:: listingblock |
4228 | | |
4229 | .. container:: content | .. container:: content |
4230 | | |
4231 | .. code:: | .. code:: |
4232 | | |
4233 | # $APEX_HOME/bin/apexCLIEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIEditor.bat [args] |
4234 | # $APEX_HOME/bin/apexApps.sh cli-editor [args] | > %APEX_HOME%\bin\apexApps.bat cli-editor [args] |
4235 +------------------------------------------------------------+--------------------------------------------------------------+
4236
4237 .. container:: paragraph
4238
4239 The option ``-h`` provides a help screen with all command
4240 line arguments.
4241
4242 .. container:: listingblock
4243
4244 .. container:: content
4245
ramverma760cce92019-07-11 12:57:49 +00004246 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004247
4248 usage: org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain [options...]
4249 options
4250 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4251 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4252 -h,--help outputs the usage of this command
4253 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4254 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and continue
4255 executing the command file
4256 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will log
4257 to standard output if not specified or suppressed with "-nl" flag
4258 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4259 -nl,--no-log if specified, no logging or output of commands to standard output or log
4260 file is carried out
4261 -nm,--no-model-output if specified, no output of a model to standard output or model output
4262 file is carried out, the user can use the "save" command in a script to
4263 save a model
4264 -o,--output-model-file <OUTPUT_MODEL_FILE> name of a file that will contain the output model for the editor, will
4265 output model to standard output if not specified or suppressed with
4266 "-nm" flag
4267 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4268 root from which to look for included macro files
4269
a.sreekumar717a24a2019-07-26 13:47:42 +00004270The APEX CLI Tosca Editor
4271-------------------------
4272
4273 .. container:: paragraph
4274
4275 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.
4276
4277 .. container:: paragraph
4278
4279 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.
4280
4281 .. container:: paragraph
4282
4283 On UNIX and Cygwin systems use:
4284
4285 .. container:: ulist
4286
4287 - ``apexCLIToscaEditor.sh`` - starts the CLI Tosca editor,
4288 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4289
4290 - ``apexApps.sh cli-tosca-editor`` - starts the CLI Tosca editor,
4291 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4292
4293 .. container:: paragraph
4294
4295 On Windows systems use:
4296
4297 .. container:: ulist
4298
4299 - ``apexCLIToscaEditor.bat`` - starts the CLI Tosca editor,
4300 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4301
4302 - ``apexApps.bat cli-tosca-editor`` - starts the CLI Tosca
4303 editor, all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4304
4305 .. container:: paragraph
4306
4307 Summary of alternatives to start the APEX CLI Tosca Editor:
4308
4309 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4310 | Unix, Cygwin | Windows |
4311 +=================================================================+====================================================================+
4312 | .. container:: | .. container:: |
4313 | | |
4314 | .. container:: listingblock | .. container:: listingblock |
4315 | | |
4316 | .. container:: content | .. container:: content |
4317 | | |
4318 | .. code:: | .. code:: |
4319 | | |
4320 | # $APEX_HOME/bin/apexCLIToscaEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIToscaEditor.bat [args] |
4321 | # $APEX_HOME/bin/apexApps.sh cli-tosca-editor [args]| > %APEX_HOME%\bin\apexApps.bat cli-tosca-editor [args] |
4322 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4323
4324 .. container:: paragraph
4325
4326 The option ``-h`` provides a help screen with all command
4327 line arguments.
4328
4329 .. container:: listingblock
4330
4331 .. container:: content
4332
4333 .. code::
4334
4335 usage: org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain [options...]
4336 options
4337 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4338 -ac,--apex-config-file <APEX_CONFIG_FILE> name of the file containing apex configuration details
4339 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4340 -h,--help outputs the usage of this command
4341 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4342 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and
4343 continue executing the command file
4344 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will
4345 log to standard output if not specified or suppressed with "-nl" flag
4346 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4347 -nl,--no-log if specified, no logging or output of commands to standard output or
4348 log file is carried out
4349 -ot,--output-tosca-file <OUTPUT_TOSCA_FILE> name of a file that will contain the output ToscaServiceTemplate
4350 -t,--tosca-template-file <TOSCA_TEMPLATE_FILE> name of the input file containing tosca template which needs to be
4351 updated with policy
4352 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4353 root from which to look for included macro files
4354
4355 .. container:: paragraph
4356
4357 An example command to run the APEX CLI Tosca editor on windows machine is given below.
4358
4359 .. container:: listingblock
4360
4361 .. container:: content
4362
4363 .. code::
4364
4365 %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
4366
liamfallon75e2bbf2020-07-06 11:41:38 +01004367
4368The APEX Client
liamfallonb621de42020-08-21 12:59:26 +01004369---------------
ramverma3b71c972019-07-10 11:25:37 +00004370
4371 .. container:: paragraph
4372
liamfallon75e2bbf2020-07-06 11:41:38 +01004373 The APEX Client combines the Policy Editor, the
ramverma3b71c972019-07-10 11:25:37 +00004374 Monitoring Client, and the Deployment Client into a single
4375 application. The standard way to use the APEX Full Client is
4376 via an installation of the *war* file on a webserver.
4377 However, the Full Client can also be started via command
4378 line. This will start a Grizzly webserver with the *war*
4379 deployed. Access to the Full Client is then via the provided
4380 URL
4381
4382 .. container:: paragraph
4383
4384 On UNIX and Cygwin systems use:
4385
4386 .. container:: ulist
4387
4388 - ``apexApps.sh full-client`` - simply starts the webserver
4389 with the Full Client
4390
4391 .. container:: paragraph
4392
4393 On Windows systems use:
4394
4395 .. container:: ulist
4396
4397 - ``apexApps.bat full-client`` - simply starts the
4398 webserver with the Full Client
4399
4400 .. container:: paragraph
4401
4402 The option ``-h`` provides a help screen with all command
4403 line arguments.
4404
4405 .. container:: listingblock
4406
4407 .. container:: content
4408
ramverma760cce92019-07-11 12:57:49 +00004409 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004410
4411 usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]
4412 -h,--help outputs the usage of this command
4413 -p,--port <PORT> port to use for the Apex Services REST calls
4414 -t,--time-to-live <TIME_TO_LIVE> the amount of time in seconds that the server will run for before terminating
4415
4416 .. container:: paragraph
4417
4418 If the Full Client is started without any arguments the
4419 final messages will look similar to this:
4420
4421 .. container:: listingblock
4422
4423 .. container:: content
4424
ramverma760cce92019-07-11 12:57:49 +00004425 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004426
4427 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
4428 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.NetworkListener start
4429 INFO: Started listener bound to [localhost:18989]
4430 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.HttpServer start
4431 INFO: [HttpServer] Started.
4432 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
4433
4434 .. container:: paragraph
4435
4436 The last line states the URL on which the Monitoring Client
4437 can be accessed. The example above stated
4438 ``http://localhost:18989/apexservices``. In a web browser
4439 use the URL ``http://localhost:18989``.
4440
aditya.puthuparambil9e67eb72020-04-30 15:59:43 +01004441The APEX Application Launcher
4442-----------------------------
ramverma3b71c972019-07-10 11:25:37 +00004443
4444 .. container:: paragraph
4445
liamfallon75e2bbf2020-07-06 11:41:38 +01004446 The standard applications (Engine and CLI Editor)
ramverma3b71c972019-07-10 11:25:37 +00004447 come with dedicated start scripts. For all other APEX
4448 applications, we provide an application launcher.
4449
4450 .. container:: paragraph
4451
4452 On UNIX and Cygwin systems use:
4453
4454 .. container:: ulist
4455
4456 - apexApps.sh\` - simply starts the application launcher
4457
4458 .. container:: paragraph
4459
4460 On Windows systems use:
4461
4462 .. container:: ulist
4463
4464 - ``apexApps.bat`` - simply starts the application launcher
4465
4466 .. container:: paragraph
4467
4468 Summary of alternatives to start the APEX application
4469 launcher:
4470
4471 +-------------------------------------------------+---------------------------------------------------+
4472 | Unix, Cygwin | Windows |
4473 +=================================================+===================================================+
4474 | .. container:: | .. container:: |
4475 | | |
4476 | .. container:: listingblock | .. container:: listingblock |
4477 | | |
4478 | .. container:: content | .. container:: content |
4479 | | |
4480 | .. code:: | .. code:: |
4481 | | |
4482 | # $APEX_HOME/bin/apexApps.sh [args] | > %APEX_HOME%\bin\apexApps.bat [args] |
4483 +-------------------------------------------------+---------------------------------------------------+
4484
4485 .. container:: paragraph
4486
4487 The option ``-h`` provides a help screen with all launcher
4488 command line arguments.
4489
4490 .. container:: listingblock
4491
4492 .. container:: content
4493
ramverma760cce92019-07-11 12:57:49 +00004494 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004495
4496 apexApps.sh - runs APEX applications
4497
4498 Usage: apexApps.sh [options] | [<application> [<application options>]]
4499
4500 Options
4501 -d <app> - describes an application
4502 -l - lists all applications supported by this script
4503 -h - this help screen
4504
4505 .. container:: paragraph
4506
4507 Using ``-l`` lists all known application the launcher can
4508 start.
4509
4510 .. container:: listingblock
4511
4512 .. container:: content
4513
ramverma760cce92019-07-11 12:57:49 +00004514 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004515
4516 apexApps.sh: supported applications:
4517 --> ws-echo engine eng-monitoring full-client eng-deployment tpl-event-json model-2-cli rest-editor cli-editor ws-console
4518
4519 .. container:: paragraph
4520
4521 Using the ``-d <name>`` option describes the named
4522 application, for instance for the ``ws-console``:
4523
4524 .. container:: listingblock
4525
4526 .. container:: content
4527
ramverma760cce92019-07-11 12:57:49 +00004528 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004529
4530 apexApps.sh: application 'ws-console'
4531 --> a simple console sending events to APEX, connect to APEX consumer port
4532
4533 .. container:: paragraph
4534
4535 Launching an application is done by calling the script with
4536 only the application name and any CLI arguments for the
4537 application. For instance, starting the ``ws-echo``
4538 application with port ``8888``:
4539
4540 .. container:: listingblock
4541
4542 .. container:: content
4543
ramverma760cce92019-07-11 12:57:49 +00004544 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004545
4546 apexApps.sh ws-echo -p 8888
4547
4548Application: Create Event Templates
4549-----------------------------------
4550
4551 .. container:: paragraph
4552
4553 **Status: Experimental**
4554
4555 .. container:: paragraph
4556
4557 This application takes a policy model (JSON or XML encoded)
4558 and generates templates for events in JSON format. This can
4559 help when a policy defines rather complex trigger or action
4560 events or complex events between states. The application can
4561 produce events for the types: stimuli (policy trigger
4562 events), internal (events between policy states), and
4563 response (action events).
4564
4565 +----------------------------------------------------------------+------------------------------------------------------------------+
4566 | Unix, Cygwin | Windows |
4567 +================================================================+==================================================================+
4568 | .. container:: | .. container:: |
4569 | | |
4570 | .. container:: listingblock | .. container:: listingblock |
4571 | | |
4572 | .. container:: content | .. container:: content |
4573 | | |
4574 | .. code:: | .. code:: |
4575 | | |
4576 | # $APEX_HOME/bin/apexApps.sh tpl-event-json [args] | > %APEX_HOME%\bin\apexApps.bat tpl-event-json [args] |
4577 +----------------------------------------------------------------+------------------------------------------------------------------+
4578
4579 .. container:: paragraph
4580
4581 The option ``-h`` provides a help screen.
4582
4583 .. container:: listingblock
4584
4585 .. container:: content
4586
ramverma760cce92019-07-11 12:57:49 +00004587 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004588
4589 gen-model2event v{release-version} - generates JSON templates for events generated from a policy model
4590 usage: gen-model2event
4591 -h,--help prints this help and usage screen
4592 -m,--model <MODEL-FILE> set the input policy model file
4593 -t,--type <TYPE> set the event type for generation, one of:
4594 stimuli (trigger events), response (action
4595 events), internal (events between states)
4596 -v,--version prints the application version
4597
4598 .. container:: paragraph
4599
4600 The created templates are not valid events, instead they use
4601 some markup for values one will need to change to actual
4602 values. For instance, running the tool with the *Sample
4603 Domain* policy model as:
4604
4605 .. container:: listingblock
4606
4607 .. container:: content
4608
ramverma760cce92019-07-11 12:57:49 +00004609 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004610
4611 apexApps.sh tpl-event-json -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json -t stimuli
4612
4613 .. container:: paragraph
4614
4615 will produce the following status messages:
4616
4617 .. container:: listingblock
4618
4619 .. container:: content
4620
ramverma760cce92019-07-11 12:57:49 +00004621 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004622
4623 gen-model2event: starting Event generator
4624 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4625 --> type: stimuli
4626
4627 .. container:: paragraph
4628
4629 and then run the generator application producing two event
4630 templates. The first template is called ``Event0000``.
4631
4632 .. container:: listingblock
4633
4634 .. container:: content
4635
4636 .. code::
4637
4638 {
4639 "name" : "Event0000",
4640 "nameSpace" : "org.onap.policy.apex.sample.events",
4641 "version" : "0.0.1",
4642 "source" : "Outside",
4643 "target" : "Match",
4644 "TestTemperature" : ###double: 0.0###,
4645 "TestTimestamp" : ###long: 0###,
4646 "TestMatchCase" : ###integer: 0###,
4647 "TestSlogan" : "###string###"
4648 }
4649
4650 .. container:: paragraph
4651
4652 The values for the keys are marked with ``#`` and the
4653 expected type of the value. To create an actual stimuli
4654 event, all these markers need to be change to actual values,
4655 for instance:
4656
4657 .. container:: listingblock
4658
4659 .. container:: content
4660
ramverma760cce92019-07-11 12:57:49 +00004661 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004662
4663 {
4664 "name" : "Event0000",
4665 "nameSpace" : "org.onap.policy.apex.sample.events",
4666 "version" : "0.0.1",
4667 "source" : "Outside",
4668 "target" : "Match",
4669 "TestTemperature" : 25,
4670 "TestTimestamp" : 123456789123456789,
4671 "TestMatchCase" : 1,
4672 "TestSlogan" : "Testing the Match Case with Temperature 25"
4673 }
4674
4675Application: Convert a Policy Model to CLI Editor Commands
4676----------------------------------------------------------
4677
4678 .. container:: paragraph
4679
4680 **Status: Experimental**
4681
4682 .. container:: paragraph
4683
4684 This application takes a policy model (JSON or XML encoded)
4685 and generates commands for the APEX CLI Editor. This
4686 effectively reverses a policy specification realized with
4687 the CLI Editor.
4688
4689 +-------------------------------------------------------------+---------------------------------------------------------------+
4690 | Unix, Cygwin | Windows |
4691 +=============================================================+===============================================================+
4692 | .. container:: | .. container:: |
4693 | | |
4694 | .. container:: listingblock | .. container:: listingblock |
4695 | | |
4696 | .. container:: content | .. container:: content |
4697 | | |
4698 | .. code:: | .. code:: |
4699 | | |
4700 | # $APEX_HOME/bin/apexApps.sh model-2-cli [args] | > %APEX_HOME%\bin\apexApps.bat model-2-cli [args] |
4701 +-------------------------------------------------------------+---------------------------------------------------------------+
4702
4703 .. container:: paragraph
4704
4705 The option ``-h`` provides a help screen.
4706
4707 .. container:: listingblock
4708
4709 .. container:: content
4710
ramverma760cce92019-07-11 12:57:49 +00004711 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004712
4713 usage: gen-model2cli
4714 -h,--help prints this help and usage screen
4715 -m,--model <MODEL-FILE> set the input policy model file
4716 -sv,--skip-validation switch of validation of the input file
4717 -v,--version prints the application version
4718
4719 .. container:: paragraph
4720
4721 For instance, running the tool with the *Sample Domain*
4722 policy model as:
4723
4724 .. container:: listingblock
4725
4726 .. container:: content
4727
ramverma760cce92019-07-11 12:57:49 +00004728 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004729
4730 apexApps.sh model-2-cli -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json
4731
4732 .. container:: paragraph
4733
4734 will produce the following status messages:
4735
4736 .. container:: listingblock
4737
4738 .. container:: content
4739
ramverma760cce92019-07-11 12:57:49 +00004740 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004741
4742 gen-model2cli: starting CLI generator
4743 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4744
4745 .. container:: paragraph
4746
4747 and then run the generator application producing all CLI
4748 Editor commands and printing them to standard out.
4749
4750Application: Websocket Clients (Echo and Console)
4751-------------------------------------------------
4752
4753 .. container:: paragraph
4754
4755 **Status: Production**
4756
4757 .. container:: paragraph
4758
4759 The application launcher also provides a Websocket echo
4760 client and a Websocket console client. The echo client
4761 connects to APEX and prints all events it receives from
4762 APEX. The console client connects to APEX, reads input from
4763 the command line, and sends this input as events to APEX.
4764
4765 +------------------------------------------------------------+--------------------------------------------------------------+
4766 | Unix, Cygwin | Windows |
4767 +============================================================+==============================================================+
4768 | .. container:: | .. container:: |
4769 | | |
4770 | .. container:: listingblock | .. container:: listingblock |
4771 | | |
4772 | .. container:: content | .. container:: content |
4773 | | |
4774 | .. code:: | .. code:: |
4775 | | |
4776 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
4777 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
4778 +------------------------------------------------------------+--------------------------------------------------------------+
4779
4780 .. container:: paragraph
4781
4782 The arguments are the same for both applications:
4783
4784 .. container:: ulist
4785
4786 - ``-p`` defines the Websocket port to connect to (defaults
4787 to ``8887``)
4788
4789 - ``-s`` defines the host on which a Websocket server is
4790 running (defaults to ``localhost``)
4791
4792 .. container:: paragraph
4793
4794 A discussion on how to use these two applications to build
4795 an APEX system is detailed HowTo-Websockets.
4796
ramverma3b71c972019-07-10 11:25:37 +00004797APEX Logging
4798^^^^^^^^^^^^
4799
4800Introduction to APEX Logging
4801----------------------------
4802
4803 .. container:: paragraph
4804
4805 All APEX components make extensive use of logging using the
4806 logging façade `SLF4J <https://www.slf4j.org/>`__ with the
4807 backend `Logback <https://logback.qos.ch/>`__. Both are used
4808 off-the-shelve, so the standard documentation and
4809 configuration apply to APEX logging. For details on how to
4810 work with logback please see the `logback
4811 manual <https://logback.qos.ch/manual/index.html>`__.
4812
4813 .. container:: paragraph
4814
4815 The APEX applications is the logback configuration file
4816 ``$APEX_HOME/etc/logback.xml`` (Windows:
4817 ``%APEX_HOME%\etc\logback.xml``). The logging backend is set
4818 to no debug, i.e. logs from the logging framework should be
4819 hidden at runtime.
4820
4821 .. container:: paragraph
4822
4823 The configurable log levels work as expected:
4824
4825 .. container:: ulist
4826
4827 - *error* (or *ERROR*) is used for serious errors in the
4828 APEX runtime engine
4829
4830 - *warn* (or *WARN*) is used for warnings, which in general
4831 can be ignored but might indicate some deeper problems
4832
4833 - *info* (or *INFO*) is used to provide generally
4834 interesting messages for startup and policy execution
4835
4836 - *debug* (or *DEBUG*) provides more details on startup and
4837 policy execution
4838
4839 - *trace* (or *TRACE*) gives full details on every aspect
4840 of the APEX engine from start to end
4841
4842 .. container:: paragraph
4843
4844 The loggers can also be configured as expected. The standard
4845 configuration (after installing APEX) uses log level *info*
4846 on all APEX classes (components).
4847
4848 .. container:: paragraph
4849
4850 The applications and scripts in ``$APEX_HOME/bin`` (Windows:
4851 ``%APEX_HOME\bin``) are configured to use the logback
4852 configuration ``$APEX_HOME/etc/logback.xml`` (Windows:
4853 ``%APEX_HOME\etc\logback.xml``). There are multiple ways to
4854 use different logback configurations, for instance:
4855
4856 .. container:: ulist
4857
4858 - Maintain multiple configurations in ``etc``, for instance
4859 a ``logback-debug.xml`` for deep debugging and a
4860 ``logback-production.xml`` for APEX in production mode,
4861 then copy the required configuration file to the used
4862 ``logback.xml`` prior starting APEX
4863
4864 - Edit the scripts in ``bin`` to use a different logback
4865 configuration file (only recommended if you are familiar
4866 with editing bash scripts or windows batch files)
4867
4868Standard Logging Configuration
4869------------------------------
4870
4871 .. container:: paragraph
4872
4873 The standard logging configuration defines a context *APEX*,
4874 which is used in the standard output pattern. The location
liamfallon1540e472019-11-28 15:14:07 +00004875 for log files is defined in the property ``logDir`` and set
ramverma3b71c972019-07-10 11:25:37 +00004876 to ``/var/log/onap/policy/apex-pdp``. The standard status
4877 listener is set to *NOP* and the overall logback
4878 configuration is set to no debug.
4879
4880 .. container:: listingblock
4881
4882 .. container:: content
4883
ramverma760cce92019-07-11 12:57:49 +00004884 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004885 :number-lines:
4886
4887 <configuration debug="false">
4888 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
4889
4890 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00004891 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00004892
4893 ...appenders
4894 ...loggers
4895 </configuration>
4896
4897.. container:: paragraph
4898
4899 The first appender defined is called ``STDOUT`` for logs to standard
4900 out.
4901
4902.. container:: listingblock
4903
4904 .. container:: content
4905
ramverma760cce92019-07-11 12:57:49 +00004906 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004907 :number-lines:
4908
4909 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4910 <encoder>
4911 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
4912 </encoder>
4913 </appender>
4914
4915.. container:: paragraph
4916
4917 The root level logger then is set to the level *info* using the
4918 standard out appender.
4919
4920.. container:: listingblock
4921
4922 .. container:: content
4923
ramverma760cce92019-07-11 12:57:49 +00004924 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004925 :number-lines:
4926
4927 <root level="info">
4928 <appender-ref ref="STDOUT" />
4929 </root>
4930
4931.. container:: paragraph
4932
4933 The second appender is called ``FILE``. It writes logs to a file
4934 ``apex.log``.
4935
4936.. container:: listingblock
4937
4938 .. container:: content
4939
ramverma760cce92019-07-11 12:57:49 +00004940 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004941 :number-lines:
4942
4943 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00004944 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00004945 <encoder>
4946 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4947 </encoder>
4948 </appender>
4949
4950.. container:: paragraph
4951
4952 The third appender is called ``CTXT_FILE``. It writes logs to a file
4953 ``apex_ctxt.log``.
4954
4955.. container:: listingblock
4956
4957 .. container:: content
4958
ramverma760cce92019-07-11 12:57:49 +00004959 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004960 :number-lines:
4961
4962 <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00004963 <file>${logDir}/apex_ctxt.log</file>
ramverma3b71c972019-07-10 11:25:37 +00004964 <encoder>
4965 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4966 </encoder>
4967 </appender>
4968
4969.. container:: paragraph
4970
4971 The last definitions are for specific loggers. The first logger
4972 captures all standard APEX classes. It is configured for log level
4973 *info* and uses the standard output and file appenders. The second
4974 logger captures APEX context classes responsible for context
4975 monitoring. It is configured for log level *trace* and uses the
4976 context file appender.
4977
4978.. container:: listingblock
4979
4980 .. container:: content
4981
ramverma760cce92019-07-11 12:57:49 +00004982 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004983 :number-lines:
4984
4985
4986 <logger name="org.onap.policy.apex" level="info" additivity="false">
4987 <appender-ref ref="STDOUT" />
4988 <appender-ref ref="FILE" />
4989 </logger>
4990
4991 <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
4992 <appender-ref ref="CTXT_FILE" />
4993 </logger>
4994
4995Adding Logback Status and Debug
4996-------------------------------
4997
4998 .. container:: paragraph
4999
5000 To activate logback status messages change the status listener
5001 from 'NOP' to for instance console.
5002
5003 .. container:: listingblock
5004
5005 .. container:: content
5006
ramverma760cce92019-07-11 12:57:49 +00005007 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005008
5009 <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
5010
5011 .. container:: paragraph
5012
5013 To activate all logback debugging, for instance to debug a new
5014 logback configuration, activate the debug attribute in the
5015 configuration.
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 <configuration debug="true">
5024 ...
5025 </configuration>
5026
5027Logging External Components
5028---------------------------
5029
5030 .. container:: paragraph
5031
5032 Logback can also be configured to log any other, external
5033 components APEX is using, if they are using the common logging
5034 framework.
5035
5036 .. container:: paragraph
5037
5038 For instance, the context component of APEX is using *Infinispan*
5039 and one can add a logger for this external component. The
5040 following example adds a logger for *Infinispan* using the
5041 standard output appender.
5042
5043 .. container:: listingblock
5044
5045 .. container:: content
5046
ramverma760cce92019-07-11 12:57:49 +00005047 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005048
5049 <logger name="org.infinispan" level="INFO" additivity="false">
5050 <appender-ref ref="STDOUT" />
5051 </logger>
5052
5053 .. container:: paragraph
5054
5055 Another example is Apache Zookeeper. The following example adds a
5056 logger for Zookeeper using the standard outout appender.
5057
5058 .. container:: listingblock
5059
5060 .. container:: content
5061
ramverma760cce92019-07-11 12:57:49 +00005062 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005063
5064 <logger name="org.apache.zookeeper.ClientCnxn" level="INFO" additivity="false">
5065 <appender-ref ref="STDOUT" />
5066 </logger>
5067
5068Configuring loggers for Policy Logic
5069------------------------------------
5070
5071 .. container:: paragraph
5072
5073 The logging for the logic inside a policy (task logic, task
5074 selection logic, state finalizer logic) can be configured separate
5075 from standard logging. The logger for policy logic is
5076 ``org.onap.policy.apex.executionlogging``. The following example
5077 defines
5078
5079 .. container:: ulist
5080
5081 - a new appender for standard out using a very simple pattern
5082 (simply the actual message)
5083
5084 - a logger for policy logic to standard out using the new
5085 appender and the already described file appender.
5086
5087 .. container:: listingblock
5088
5089 .. container:: content
5090
ramverma760cce92019-07-11 12:57:49 +00005091 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005092
5093 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5094 <encoder>
5095 <pattern>policy: %msg\n</pattern>
5096 </encoder>
5097 </appender>
5098
5099 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5100 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5101 <appender-ref ref="FILE" />
5102 </logger>
5103
5104 .. container:: paragraph
5105
5106 It is also possible to use specific logging for parts of policy
5107 logic. The following example defines a logger for task logic.
5108
5109 .. container:: listingblock
5110
5111 .. container:: content
5112
ramverma760cce92019-07-11 12:57:49 +00005113 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005114
5115 <logger name="org.onap.policy.apex.executionlogging.TaskExecutionLogging" level="TRACE" additivity="false">
5116 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5117 </logger>
5118
5119Rolling File Appenders
5120----------------------
5121
5122 .. container:: paragraph
5123
5124 Rolling file appenders are a good option for more complex logging
5125 of a production or complex testing APEX installation. The standard
5126 logback configuration can be used for these use cases. This
5127 section gives two examples for the standard logging and for
5128 context logging.
5129
5130 .. container:: paragraph
5131
5132 First the standard logging. The following example defines a
5133 rolling file appender. The appender rolls over on a daily basis.
5134 It allows for a file size of 100 MB.
5135
5136 .. container:: listingblock
5137
5138 .. container:: content
5139
ramverma760cce92019-07-11 12:57:49 +00005140 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005141
5142 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005143 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005144 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5145 <!-- rollover daily -->
5146 <!-- <fileNamePattern>xstream-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> -->
liamfallon1540e472019-11-28 15:14:07 +00005147 <fileNamePattern>${logDir}/apex_%d{yyyy-MM-dd}.%i.log.gz
ramverma3b71c972019-07-10 11:25:37 +00005148 </fileNamePattern>
5149 <maxHistory>4</maxHistory>
5150 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5151 <!-- or whenever the file size reaches 100MB -->
5152 <maxFileSize>100MB</maxFileSize>
5153 </timeBasedFileNamingAndTriggeringPolicy>
5154 </rollingPolicy>
5155 <encoder>
5156 <pattern>
5157 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5158 </pattern>
5159 </encoder>
5160 </appender>
5161
5162 .. container:: paragraph
5163
5164 A very similar configuration can be used for a rolling file
5165 appender logging APEX context.
5166
5167 .. container:: listingblock
5168
5169 .. container:: content
5170
ramverma760cce92019-07-11 12:57:49 +00005171 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005172
5173 <appender name="CTXT-FILE"
5174 class="ch.qos.logback.core.rolling.RollingFileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005175 <file>${logDir}/apex_ctxt.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005176 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
liamfallon1540e472019-11-28 15:14:07 +00005177 <fileNamePattern>${logDir}/apex_ctxt_%d{yyyy-MM-dd}.%i.log.gz
ramverma3b71c972019-07-10 11:25:37 +00005178 </fileNamePattern>
5179 <maxHistory>4</maxHistory>
5180 <timeBasedFileNamingAndTriggeringPolicy
5181 class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5182 <maxFileSize>100MB</maxFileSize>
5183 </timeBasedFileNamingAndTriggeringPolicy>
5184 </rollingPolicy>
5185 <encoder>
5186 <pattern>
5187 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5188 </pattern>
5189 </encoder>
5190 </appender>
5191
5192Example Configuration for Logging Logic
5193---------------------------------------
5194
5195 .. container:: paragraph
5196
5197 The following example shows a configuration that logs policy logic
5198 to standard out and a file (*info*). All other APEX components are
5199 logging to a file (*debug*).. This configuration an be used in a
5200 pre-production phase with the APEX engine still running in a
5201 separate terminal to monitor policy execution. This logback
5202 configuration is in the APEX installation as
5203 ``etc/logback-logic.xml``.
5204
5205 .. container:: listingblock
5206
5207 .. container:: content
5208
ramverma760cce92019-07-11 12:57:49 +00005209 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005210
5211 <configuration debug="false">
5212 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5213
5214 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00005215 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00005216
5217 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5218 <encoder>
5219 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
5220 </encoder>
5221 </appender>
5222
5223 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005224 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005225 <encoder>
5226 <pattern>
5227 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5228 </pattern>
5229 </encoder>
5230 </appender>
5231
5232 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5233 <encoder>
5234 <pattern>policy: %msg\n</pattern>
5235 </encoder>
5236 </appender>
5237
5238 <root level="error">
5239 <appender-ref ref="STDOUT" />
5240 </root>
5241
5242 <logger name="org.onap.policy.apex" level="debug" additivity="false">
5243 <appender-ref ref="FILE" />
5244 </logger>
5245
5246 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5247 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5248 <appender-ref ref="FILE" />
5249 </logger>
5250 </configuration>
5251
5252Example Configuration for a Production Server
5253---------------------------------------------
5254
5255 .. container:: paragraph
5256
5257 The following example shows a configuration that logs all APEX
5258 components, including policy logic, to a file (*debug*). This
5259 configuration an be used in a production phase with the APEX
5260 engine being executed as a service on a system without console
5261 output. This logback configuration is in the APEX installation as
5262 ``logback-server.xml``
5263
5264 .. container:: listingblock
5265
5266 .. container:: content
5267
ramverma760cce92019-07-11 12:57:49 +00005268 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005269
5270 <configuration debug="false">
5271 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5272
5273 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00005274 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00005275
5276 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005277 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005278 <encoder>
5279 <pattern>
5280 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5281 </pattern>
5282 </encoder>
5283 </appender>
5284
5285 <root level="debug">
5286 <appender-ref ref="FILE" />
5287 </root>
5288
5289 <logger name="org.onap.policy.apex.executionlogging" level="debug" additivity="false">
5290 <appender-ref ref="FILE" />
5291 </logger>
5292 </configuration>
5293
a.sreekumarcf3ff822020-09-16 13:12:29 +01005294Unsupported Features
5295^^^^^^^^^^^^^^^^^^^^
5296
5297 .. container:: paragraph
5298
5299 This section documents some legacy and unsupported features
5300 in apex-pdp. The documentation here has not been updated for
5301 recent versions of apex-pdp. For example, the apex-pdp models
5302 specified in this example should now be in TOSCA format.
5303
ramverma3b71c972019-07-10 11:25:37 +00005304Building a System with Websocket Backend
a.sreekumarcf3ff822020-09-16 13:12:29 +01005305----------------------------------------
ramverma3b71c972019-07-10 11:25:37 +00005306
5307Websockets
a.sreekumarcf3ff822020-09-16 13:12:29 +01005308##########
ramverma3b71c972019-07-10 11:25:37 +00005309
5310 .. container:: paragraph
5311
5312 Websocket is a protocol to run sockets of HTTP. Since it in
5313 essence a socket, the connection is realized between a
5314 server (waiting for connections) and a client (connecting to
5315 a server). Server/client separation is only important for
5316 connection establishment, once connected, everyone can
5317 send/receive on the same socket (as any standard socket
5318 would allow).
5319
5320 .. container:: paragraph
5321
5322 Standard Websocket implementations are simple, no
5323 publish/subscribe and no special event handling. Most
5324 servers simply send all incoming messages to all
5325 connections. There is a PubSub definition on top of
5326 Websocket called `WAMP <http://wamp-proto.org/>`__. APEX
5327 does not support WAMP at the moment.
5328
5329Websocket in Java
a.sreekumarcf3ff822020-09-16 13:12:29 +01005330#################
ramverma3b71c972019-07-10 11:25:37 +00005331
5332 .. container:: paragraph
5333
5334 In Java, `JSR
5335 356 <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5336 defines the standard Websocket API. This JSR is part of Jave
5337 EE 7 standard. For Java SE, several implementations exist in
5338 open source. Since Websockets are a stable standard and
5339 simple, most implementations are stable and ready to use. A
5340 lot of products support Websockets, like Spring, JBoss,
5341 Netty, … there are also Kafka extensions for Websockets.
5342
5343Websocket Example Code for Websocket clients (FOSS)
a.sreekumarcf3ff822020-09-16 13:12:29 +01005344###################################################
ramverma3b71c972019-07-10 11:25:37 +00005345
5346 .. container:: paragraph
5347
5348 There are a lot of implementations and examples available on
5349 Github for Websocket clients. If one is using Java EE 7,
5350 then one can also use the native Websocket implementation.
5351 Good examples for clients using simply Java SE are here:
5352
5353 .. container:: ulist
5354
5355 - `Websocket
5356 implementation <https://github.com/TooTallNate/Java-WebSocket>`__
5357
5358 - `Websocket sending client example, using
5359 AWT <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ChatClient.java>`__
5360
5361 - `Websocket receiving client example (simple echo
5362 client) <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ExampleClient.java>`__
5363
5364 .. container:: paragraph
5365
5366 For Java EE, the native Websocket API is explained here:
5367
5368 .. container:: ulist
5369
5370 - `Oracle
5371 docs <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5372
5373 - link: `An
5374 example <http://www.programmingforliving.com/2013/08/jsr-356-java-api-for-websocket-client-api.html>`__
5375
5376BCP: Websocket Configuration
a.sreekumarcf3ff822020-09-16 13:12:29 +01005377############################
ramverma3b71c972019-07-10 11:25:37 +00005378
5379 .. container:: paragraph
5380
5381 The probably best is to configure APEX for Websocket servers
5382 for input (ingress, consume) and output (egress, produce)
5383 interfaces. This means that APEX will start Websocket
5384 servers on named ports and wait for clients to connect.
5385 Advantage: once APEX is running all connectivity
5386 infrastructure is running as well. Consequence: if APEX is
5387 not running, everyone else is in the dark, too.
5388
5389 .. container:: paragraph
5390
5391 The best protocol to be used is JSON string. Each event on
5392 any interface is then a string with a JSON encoding. JSON
5393 string is a little bit slower than byte code, but we doubt
5394 that this will be noticeable. A further advantage of JSON
5395 strings over Websockets with APEX starting the servers: it
5396 is very easy to connect web browsers to such a system.
5397 Simple connect the web browser to the APEX sockets and
5398 send/read JSON strings.
5399
5400 .. container:: paragraph
5401
5402 Once APEX is started you simply connect Websocket clients to
5403 it, and send/receive event. When APEX is terminated, the
5404 Websocket servers go down, and the clients will be
5405 disconnected. APEX does not (yet) support auto-client
5406 reconnect nor WAMP, so clients might need to be restarted or
5407 reconnected manually after an APEX boot.
5408
5409Demo with VPN Policy Model
a.sreekumarcf3ff822020-09-16 13:12:29 +01005410##########################
ramverma3b71c972019-07-10 11:25:37 +00005411
5412 .. container:: paragraph
5413
5414 We assume that you have an APEX installation using the full
5415 package, i.e. APEX with all examples, of version ``0.5.6``
5416 or higher. We will use the VPN policy from the APEX examples
5417 here.
5418
5419 .. container:: paragraph
5420
5421 Now, have the following ready to start the demo:
5422
5423 .. container:: ulist
5424
5425 - 3 terminals on the host where APEX is running (we need 1
5426 for APEX and 1 for each client)
5427
5428 - the events in the file
5429 ``$APEX_HOME/examples/events/VPN/SetupEvents.json`` open
5430 in an editor (we need to send those events to APEX)
5431
5432 - the events in the file
5433 ``$APEX_HOME/examples/events/VPN/Link09Events.json`` open
5434 in an editor (we need to send those events to APEX)
5435
5436A Websocket Configuration for the VPN Domain
a.sreekumar98b59692021-07-23 13:38:06 +01005437^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +00005438
5439 .. container:: paragraph
5440
5441 Create a new APEX configuration using the VPN policy
5442 model and configuring APEX as discussed above for
5443 Websockets. Copy the following configuration into
5444 ``$APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json``
5445 (for Windows use
5446 ``%APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json``):
5447
5448 .. container:: listingblock
5449
5450 .. container:: content
5451
ramverma760cce92019-07-11 12:57:49 +00005452 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005453 :number-lines:
5454
5455 {
5456 "engineServiceParameters" : {
5457 "name" : "VPNApexEngine",
5458 "version" : "0.0.1",
5459 "id" : 45,
5460 "instanceCount" : 1,
5461 "deploymentPort" : 12345,
5462 "policyModelFileName" : "examples/models/VPN/VPNPolicyModelAvro.json",
5463 "engineParameters" : {
5464 "executorParameters" : {
5465 "MVEL" : {
5466 "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
5467 }
5468 },
5469 "contextParameters" : {
5470 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
5471 "schemaParameters":{
5472 "Avro":{
5473 "parameterClassName" : "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
5474 }
5475 }
5476 }
5477 }
5478 },
5479 "producerCarrierTechnologyParameters" : {
5480 "carrierTechnology" : "WEBSOCKET",
5481 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5482 "parameters" : {
5483 "wsClient" : false,
5484 "port" : 42452
5485 }
5486 },
5487 "producerEventProtocolParameters" : {
5488 "eventProtocol" : "JSON"
5489 },
5490 "consumerCarrierTechnologyParameters" : {
5491 "carrierTechnology" : "WEBSOCKET",
5492 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5493 "parameters" : {
5494 "wsClient" : false,
5495 "port" : 42450
5496 }
5497 },
5498 "consumerEventProtocolParameters" : {
5499 "eventProtocol" : "JSON"
5500 }
5501 }
5502
5503Start APEX Engine
a.sreekumar98b59692021-07-23 13:38:06 +01005504^^^^^^^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +00005505
5506 .. container:: paragraph
5507
5508 In a new terminal, start APEX with the new configuration for
5509 Websocket-Server ingress/egress:
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
liamfallonb621de42020-08-21 12:59:26 +01005518 #: $APEX_HOME/bin/apexApps.sh engine -c $APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json
ramverma3b71c972019-07-10 11:25:37 +00005519
5520.. container:: listingblock
5521
5522 .. container:: content
5523
ramverma760cce92019-07-11 12:57:49 +00005524 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005525 :number-lines:
5526
liamfallonb621de42020-08-21 12:59:26 +01005527 #: %APEX_HOME%\bin\apexApps.bat engine -c %APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json
ramverma3b71c972019-07-10 11:25:37 +00005528
5529.. container:: paragraph
5530
5531 Wait for APEX to start, it takes a while to create all Websocket
5532 servers (about 8 seconds on a standard laptop without cached
5533 binaries). depending on your log messages, you will see no (some, a
5534 lot) log messages. If APEX starts correctly, the last few messages
5535 you should see are:
5536
5537.. container:: listingblock
5538
5539 .. container:: content
5540
ramverma760cce92019-07-11 12:57:49 +00005541 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005542 :number-lines:
5543
5544 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)
5545 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 ...
5546 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
5547 Started Apex service
5548
5549.. container:: paragraph
5550
5551 APEX is running in the new terminal and will produce output when the
5552 policy is triggered/executed.
5553
5554Run the Websocket Echo Client
a.sreekumar98b59692021-07-23 13:38:06 +01005555^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +00005556
5557 .. container:: paragraph
5558
5559 The echo client is included in an APEX full installation. To run
5560 the client, open a new shell (Unix, Cygwin) or command prompt
5561 (``cmd`` on Windows). Then use the APEX application launcher to
5562 start the client.
5563
liamfallon9c7bd672019-10-03 13:42:08 +01005564 .. important::
ramverma3b71c972019-07-10 11:25:37 +00005565 APEX engine needs to run first
ramverma760cce92019-07-11 12:57:49 +00005566 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 +00005567
5568 +---------------------------------------------------------+-----------------------------------------------------------+
5569 | Unix, Cygwin | Windows |
5570 +=========================================================+===========================================================+
5571 | .. container:: | .. container:: |
5572 | | |
5573 | .. container:: listingblock | .. container:: listingblock |
5574 | | |
5575 | .. container:: content | .. container:: content |
5576 | | |
5577 | .. code:: | .. code:: |
5578 | | |
5579 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
5580 +---------------------------------------------------------+-----------------------------------------------------------+
5581
5582 .. container:: paragraph
5583
5584 Use the following command line arguments for server and port of
5585 the Websocket server. The port should be the same as configured in
5586 the APEX engine. The server host should be the host on which the
5587 APEX engine is running
5588
5589 .. container:: ulist
5590
5591 - ``-p`` defines the Websocket port to connect to (defaults to
5592 ``8887``)
5593
5594 - ``-s`` defines the host on which a Websocket server is running
5595 (defaults to ``localhost``)
5596
5597 .. container:: paragraph
5598
5599 Let’s assume that there is an APEX engine running, configured for
5600 produce Websocket carrier technology, as server, for port 42452,
5601 with produce event protocol JSON,. If we start the console client
5602 on the same host, we can omit the ``-s`` options. We start the
5603 console client as:
5604
5605 .. container:: listingblock
5606
5607 .. container:: content
5608
ramverma760cce92019-07-11 12:57:49 +00005609 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005610
5611 # $APEX_HOME/bin/apexApps.sh ws-echo -p 42452 (1)
5612 > %APEX_HOME%\bin\apexApps.bat ws-echo -p 42452 (2)
5613
5614 .. container:: colist arabic
5615
5616 +-------+--------------------------------+
5617 | **1** | Start client on Unix or Cygwin |
5618 +-------+--------------------------------+
5619 | **2** | Start client on Windows |
5620 +-------+--------------------------------+
5621
5622 .. container:: paragraph
5623
5624 Once started successfully, the client will produce the following
5625 messages (assuming we used ``-p 42452`` and an APEX engine is
5626 running on ``localhost`` with the same port:
5627
5628 .. container:: listingblock
5629
5630 .. container:: content
5631
ramverma760cce92019-07-11 12:57:49 +00005632 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005633
5634 ws-simple-echo: starting simple event echo
5635 --> server: localhost
5636 --> port: 42452
5637
5638 Once started, the application will simply print out all received events to standard out.
5639 Each received event will be prefixed by '---' and suffixed by '===='
5640
5641
5642 ws-simple-echo: opened connection to APEX (Web Socket Protocol Handshake)
5643
5644Run the Websocket Console Client
a.sreekumar98b59692021-07-23 13:38:06 +01005645^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +00005646
5647 .. container:: paragraph
5648
5649 The console client is included in an APEX full installation. To
5650 run the client, open a new shell (Unix, Cygwin) or command prompt
5651 (``cmd`` on Windows). Then use the APEX application launcher to
5652 start the client.
5653
liamfallon9c7bd672019-10-03 13:42:08 +01005654 .. important::
ramverma3b71c972019-07-10 11:25:37 +00005655 APEX engine needs to run first
ramverma760cce92019-07-11 12:57:49 +00005656 The example assumes that an APEX engine configured for *consume* carrier technology Websocket and *JSON* event
5657 protocol is executed first.
ramverma3b71c972019-07-10 11:25:37 +00005658
5659 +------------------------------------------------------------+--------------------------------------------------------------+
5660 | Unix, Cygwin | Windows |
5661 +============================================================+==============================================================+
5662 | .. container:: | .. container:: |
5663 | | |
5664 | .. container:: listingblock | .. container:: listingblock |
5665 | | |
5666 | .. container:: content | .. container:: content |
5667 | | |
5668 | .. code:: | .. code:: |
5669 | | |
5670 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
5671 +------------------------------------------------------------+--------------------------------------------------------------+
5672
5673 .. container:: paragraph
5674
5675 Use the following command line arguments for server and port of
5676 the Websocket server. The port should be the same as configured in
5677 the APEX engine. The server host should be the host on which the
5678 APEX engine is running
5679
5680 .. container:: ulist
5681
5682 - ``-p`` defines the Websocket port to connect to (defaults to
5683 ``8887``)
5684
5685 - ``-s`` defines the host on which a Websocket server is running
5686 (defaults to ``localhost``)
5687
5688 .. container:: paragraph
5689
5690 Let’s assume that there is an APEX engine running, configured for
5691 consume Websocket carrier technology, as server, for port 42450,
5692 with consume event protocol JSON,. If we start the console client
5693 on the same host, we can omit the ``-s`` options. We start the
5694 console client as:
5695
5696 .. container:: listingblock
5697
5698 .. container:: content
5699
ramverma760cce92019-07-11 12:57:49 +00005700 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005701
5702 # $APEX_HOME/bin/apexApps.sh ws-console -p 42450 (1)
5703 > %APEX_HOME%\bin\apexApps.sh ws-console -p 42450 (2)
5704
5705 .. container:: colist arabic
5706
5707 +-------+--------------------------------+
5708 | **1** | Start client on Unix or Cygwin |
5709 +-------+--------------------------------+
5710 | **2** | Start client on Windows |
5711 +-------+--------------------------------+
5712
5713 .. container:: paragraph
5714
5715 Once started successfully, the client will produce the following
5716 messages (assuming we used ``-p 42450`` and an APEX engine is
5717 running on ``localhost`` with the same port:
5718
5719 .. container:: listingblock
5720
5721 .. container:: content
5722
ramverma760cce92019-07-11 12:57:49 +00005723 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005724
5725 ws-simple-console: starting simple event console
5726 --> server: localhost
5727 --> port: 42450
5728
5729 - terminate the application typing 'exit<enter>' or using 'CTRL+C'
5730 - events are created by a non-blank starting line and terminated by a blank line
5731
5732
5733 ws-simple-console: opened connection to APEX (Web Socket Protocol Handshake)
5734
5735Send Events
a.sreekumar98b59692021-07-23 13:38:06 +01005736^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +00005737
5738 .. container:: paragraph
5739
5740 Now you have the full system up and running:
5741
5742 .. container:: ulist
5743
5744 - Terminal 1: APEX ready and loaded
5745
5746 - Terminal 2: an echo client, printing received messages produced
5747 by the VPN policy
5748
5749 - Terminal 2: a console client, waiting for input on the console
5750 (standard in) and sending text to APEX
5751
5752 .. container:: paragraph
5753
5754 We started the engine with the VPN policy example. So all the
5755 events we are using now are located in files in the following
5756 example directory:
5757
5758 .. container:: listingblock
5759
5760 .. container:: content
5761
ramverma760cce92019-07-11 12:57:49 +00005762 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005763 :number-lines:
5764
5765 #: $APEX_HOME/examples/events/VPN
5766 > %APEX_HOME%\examples\events\VPN
5767
5768.. container:: paragraph
5769
5770 To sends events, simply copy the content of the event files into
5771 Terminal 3 (the console client). It will read multi-line JSON text
5772 and send the events. So copy the content of ``SetupEvents.json`` into
5773 the client. APEX will trigger a policy and produce some output, the
5774 echo client will also print some events created in the policy. In
5775 Terminal 1 (APEX) you’ll see some status messages from the policy as:
5776
5777.. container:: listingblock
5778
5779 .. container:: content
5780
ramverma760cce92019-07-11 12:57:49 +00005781 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005782 :number-lines:
5783
5784 {Link=L09, LinkUp=true}
5785 L09 true
5786 outFields: {Link=L09, LinkUp=true}
5787 {Link=L10, LinkUp=true}
5788 L09 true
5789 L10 true
5790 outFields: {Link=L10, LinkUp=true}
5791 {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5792 *** Customers ***
5793 C 300 300 [L09, L10]
5794 outFields: {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5795 {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5796 *** Customers ***
5797 A 300 50 [L09, L10]
5798 C 300 300 [L09, L10]
5799 outFields: {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5800 {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5801 *** Customers ***
5802 A 300 50 [L09, L10]
5803 C 300 300 [L09, L10]
5804 D 300 400 [L09, L10]
5805 outFields: {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5806 {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5807 *** Customers ***
5808 A 300 50 [L09, L10]
5809 B 300 299 [L09, L10]
5810 C 300 300 [L09, L10]
5811 D 300 400 [L09, L10]
5812 outFields: {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5813
5814.. container:: paragraph
5815
5816 In Terminal 2 (echo-client) you see the received events, the last two
5817 should look like:
5818
5819.. container:: listingblock
5820
5821 .. container:: content
5822
ramverma760cce92019-07-11 12:57:49 +00005823 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005824 :number-lines:
5825
5826 ws-simple-echo: received
5827 ---------------------------------
5828 {
5829 "name": "VPNCustomerCtxtActEvent",
5830 "version": "0.0.1",
5831 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5832 "source": "Source",
5833 "target": "Target",
5834 "CustomerName": "C",
5835 "LinkList": "L09 L10",
5836 "SlaDT": 300,
5837 "YtdDT": 300
5838 }
5839 =================================
5840
5841 ws-simple-echo: received
5842 ---------------------------------
5843 {
5844 "name": "VPNCustomerCtxtActEvent",
5845 "version": "0.0.1",
5846 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5847 "source": "Source",
5848 "target": "Target",
5849 "CustomerName": "D",
5850 "LinkList": "L09 L10",
5851 "SlaDT": 300,
5852 "YtdDT": 400
5853 }
5854 =================================
5855
5856.. container:: paragraph
5857
5858 Congratulations, you have triggered a policy in APEX using
5859 Websockets, the policy did run through, created events, picked up by
5860 the echo-client.
5861
5862.. container:: paragraph
5863
5864 Now you can send the Link 09 and Link 10 events, they will trigger
5865 the actual VPN policy and some calculations are made. Let’s take the
5866 Link 09 events from ``Link09Events.json``, copy them all into
5867 Terminal 3 (the console). APEX will run the policy (with some status
5868 output), and the echo client will receive and print events.
5869
5870.. container:: paragraph
5871
5872 To terminate the applications, simply press ``CTRL+C`` in Terminal 1
5873 (APEX). This will also terminate the echo-client in Terminal 2. Then
5874 type ``exit<enter>`` in Terminal 3 (or ``CTRL+C``) to terminate the
5875 console-client.