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