blob: c48583a872b5c154ae17480394c08105103fa826 [file] [log] [blame]
ramverma3b71c972019-07-10 11:25:37 +00001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3
4
5APEX User Manual
6****************
7
8.. contents::
9 :depth: 3
10
waynedunicane5430c12021-03-31 11:06:56 +010011Installation of Apex
12^^^^^^^^^^^^^^^^^^^^
ramverma3b71c972019-07-10 11:25:37 +000013
14Requirements
15------------
16
17 .. container:: paragraph
18
19 APEX is 100% written in Java and runs on any platform
20 that supports a JVM, e.g. Windows, Unix, Cygwin. Some
21 APEX applications (such as the monitoring application)
22 come as web archives, they do require a war-capable web
23 server installed.
24
25Installation Requirements
26#########################
27
28 .. container:: ulist
29
30 - Downloaded distribution: JAVA runtime environment
liamfallon3e524ba2020-07-02 15:32:26 +010031 (JRE, Java 11 or later, APEX is tested with the
32 OpenJDK Java)
ramverma3b71c972019-07-10 11:25:37 +000033
34 - Building from source: JAVA development kit (JDK,
liamfallon3e524ba2020-07-02 15:32:26 +010035 Java 11 or later, APEX is tested with the OpenJDK
ramverma3b71c972019-07-10 11:25:37 +000036 Java)
37
38 - A web archive capable webserver, for instance for
39 the monitoring application
40
41 .. container:: ulist
42
43 - for instance `Apache
44 Tomcat <https://tomcat.apache.org/>`__
45
46 - Sufficient rights to install APEX on the system
47
48 - Installation tools depending on the installation
49 method used:
50
51 .. container:: ulist
52
53 - ZIP to extract from a ZIP distribution
54
55 .. container:: ulist
56
57 - Windows for instance
58 `7Zip <http://www.7-zip.org/>`__
59
60 - TAR and GZ to extract from that TAR.GZ
61 distribution
62
63 .. container:: ulist
64
65 - Windows for instance
66 `7Zip <http://www.7-zip.org/>`__
67
ramverma3b71c972019-07-10 11:25:37 +000068 - DPKG to install from the DEB distribution
69
70 .. container:: ulist
71
72 - Install: ``sudo apt-get install dpkg``
73
74Feature Requirements
75####################
76
77 .. container:: paragraph
78
79 APEX supports a number of features that require extra
80 software being installed.
81
82 .. container:: ulist
83
84 - `Apache Kafka <https://kafka.apache.org/>`__ to
85 connect APEX to a Kafka message bus
86
87 - `Hazelcast <https://hazelcast.com/>`__ to use
88 distributed hash maps for context
89
90 - `Infinispan <http://infinispan.org/>`__ for
91 distributed context and persistence
92
93 - `Docker <https://www.docker.com/>`__ to run APEX
94 inside a Docker container
95
96Build (Install from Source) Requirements
97########################################
98
99 .. container:: paragraph
100
101 Installation from source requires a few development
102 tools
103
104 .. container:: ulist
105
106 - GIT to retrieve the source code
107
108 - Java SDK, Java version 8 or later
109
110 - Apache Maven 3 (the APEX build environment)
111
112Get the APEX Source Code
113------------------------
114
115 .. container:: paragraph
116
117 The first APEX source code was hosted on Github in
118 January 2018. By the end of 2018, APEX was added as a
119 project in the ONAP Policy Framework, released later in
120 the ONAP Casablanca release.
121
122 .. container:: paragraph
123
124 The APEX source code is hosted in ONAP as project APEX.
125 The current stable version is in the master branch.
126 Simply clone the master branch from ONAP using HTTPS.
127
128 .. container:: listingblock
129
130 .. container:: content
131
ramverma760cce92019-07-11 12:57:49 +0000132 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000133 :number-lines:
134
135 git clone https://gerrit.onap.org/r/policy/apex-pdp
136
137Build APEX
138----------
139
140 .. container:: paragraph
141
142 The examples in this document assume that the APEX source
143 repositories are cloned to:
144
145 .. container:: ulist
146
147 - Unix, Cygwin: ``/usr/local/src/apex-pdp``
148
149 - Windows: ``C:\dev\apex-pdp``
150
151 - Cygwin: ``/cygdrive/c/dev/apex-pdp``
152
ramverma760cce92019-07-11 12:57:49 +0000153 .. important::
ramverma3b71c972019-07-10 11:25:37 +0000154 A Build requires ONAP Nexus
ramverma760cce92019-07-11 12:57:49 +0000155 APEX has a dependency to ONAP parent projects. You might need to adjust your Maven M2 settings. The most current
156 settings can be found in the ONAP oparent repo: `Settings <https://git.onap.org/oparent/plain/settings.xml>`__.
ramverma3b71c972019-07-10 11:25:37 +0000157
ramverma760cce92019-07-11 12:57:49 +0000158 .. important::
159 A Build needs Space
160 Building APEX requires approximately 2-3 GB of hard disc space, 1 GB for the actual build with full
161 distribution and 1-2 GB for the downloaded dependencies
ramverma3b71c972019-07-10 11:25:37 +0000162
ramverma760cce92019-07-11 12:57:49 +0000163 .. important::
ramverma3b71c972019-07-10 11:25:37 +0000164 A Build requires Internet (for first build)
ramverma760cce92019-07-11 12:57:49 +0000165 During the build, several (a lot) of Maven dependencies will be downloaded and stored in the configured local Maven
166 repository. The first standard build (and any first specific build) requires Internet access to download those
167 dependencies.
ramverma3b71c972019-07-10 11:25:37 +0000168
ramverma3b71c972019-07-10 11:25:37 +0000169 .. container:: paragraph
170
171 Use Maven to for a standard build without any tests.
172
173 +-------------------------------------------------------+--------------------------------------------------------+
174 | Unix, Cygwin | Windows |
175 +=======================================================+========================================================+
176 | .. container:: | .. container:: |
177 | | |
178 | .. container:: content | .. container:: content |
179 | | |
180 | .. code:: | .. code:: |
181 | :number-lines: | :number-lines: |
182 | | |
183 | # cd /usr/local/src/apex-pdp | >c: |
liamfallon1540e472019-11-28 15:14:07 +0000184 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
185 | | >mvn clean install -Pdocker -DskipTests |
ramverma3b71c972019-07-10 11:25:37 +0000186 +-------------------------------------------------------+--------------------------------------------------------+
187
188.. container:: paragraph
189
190 The build takes 2-3 minutes on a standard development laptop. It
191 should run through without errors, but with a lot of messages from
192 the build process.
193
194.. container:: paragraph
195
196 When Maven is finished with the build, the final screen should look
197 similar to this (omitting some ``success`` lines):
198
199.. container:: listingblock
200
201 .. container:: content
202
ramverma760cce92019-07-11 12:57:49 +0000203 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000204 :number-lines:
205
206 [INFO] tools .............................................. SUCCESS [ 0.248 s]
207 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
208 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
209 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
210 [INFO] packages ........................................... SUCCESS [ 0.336 s]
211 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
212 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
213 [INFO] ------------------------------------------------------------------------
214 [INFO] BUILD SUCCESS
215 [INFO] ------------------------------------------------------------------------
216 [INFO] Total time: 03:43 min
217 [INFO] Finished at: 2018-09-03T11:56:01+01:00
218 [INFO] ------------------------------------------------------------------------
219
220.. container:: paragraph
221
222 The build will have created all artifacts required for an APEX
223 installation. The following example show how to change to the target
224 directory and how it should look like.
225
liamfallonb621de42020-08-21 12:59:26 +0100226+----------------------------------------------------------------------------------------------------------------+
227| Unix, Cygwin |
228+================================================================================================================+
waynedunicane5430c12021-03-31 11:06:56 +0100229| .. container:: content |
liamfallonb621de42020-08-21 12:59:26 +0100230| |
231| .. container:: listingblock |
232| |
233| .. container:: content |
234| |
235| .. code:: |
waynedunicane5430c12021-03-31 11:06:56 +0100236| |
liamfallonb621de42020-08-21 12:59:26 +0100237| :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
liamfallonb621de42020-08-21 12:59:26 +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
liamfallonb621de42020-08-21 12:59:26 +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
401 .. container:: imageblock
402
403 .. container:: content
404
405 |Extract the TAR archive|
406
407 .. container:: paragraph
408
409 The right-click on the new created TAR file and extract the actual
410 APEX distribution.
411
412 .. container:: imageblock
413
414 .. container:: content
415
416 |Extract the APEX distribution|
417
418 .. container:: paragraph
419
420 Inside the new APEX folder you see the main directories: ``bin``,
421 ``etc``, ``examples``, ``lib``, and ``war``
422
423 .. container:: paragraph
424
425 Once extracted, please rename the created folder to
426 ``apex-full-2.0.0-SNAPSHOT``. This will keep the directory name in
427 line with the rest of this documentation.
428
429Install Manually from Archive (Windows, 7Zip, CMD)
430##################################################
431
432 .. container:: paragraph
433
liamfallon3e524ba2020-07-02 15:32:26 +0100434 You can download a ``tar.gz`` archive from the
435 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
436
437 Copy the ``tar.gz`` file into the install
ramverma3b71c972019-07-10 11:25:37 +0000438 folder (in this example ``C:\apex``). Start ``cmd``, for instance
439 typing ``Windows+R`` and then ``cmd`` in the dialog. Assuming
440 ``7Zip`` is installed in the standard folder, simply run the
441 following commands (for APEX version 2.0.0-SNAPSHOT full
442 distribution)
443
444 .. container:: listingblock
445
446 .. container:: content
447
ramverma760cce92019-07-11 12:57:49 +0000448 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000449 :number-lines:
450
451 >c:
452 >cd \apex
453 >"\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"
454
455.. container:: paragraph
456
457 APEX is now installed in the folder
458 ``C:\apex\apex-full-2.0.0-SNAPSHOT``.
459
460Build from Source
461-----------------
462
463Build and Install Manually (Unix, Windows, Cygwin)
464##################################################
465
466 .. container:: paragraph
467
468 Clone the APEX GIT repositories into a directory. Go to that
469 directory. Use Maven to build APEX (all details on building
470 APEX from source can be found in *APEX HowTo: Build*). Install
471 from the created artifacts (``rpm``, ``deb``, ``tar.gz``, or
472 copying manually).
473
ramverma3b71c972019-07-10 11:25:37 +0000474 .. container:: paragraph
475
476 The following example shows how to build the APEX system,
477 without tests (``-DskipTests``) to safe some time. It assumes
478 that the APX GIT repositories are cloned to:
479
480 .. container:: ulist
481
482 - Unix, Cygwin: ``/usr/local/src/apex``
483
484 - Windows: ``C:\dev\apex``
485
ramverma760cce92019-07-11 12:57:49 +0000486 +-------------------------------------------------------+--------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000487 | Unix, Cygwin | Windows |
488 +=======================================================+========================================================+
489 | .. container:: | .. container:: |
490 | | |
491 | .. container:: content | .. container:: content |
492 | | |
493 | .. code:: | .. code:: |
494 | :number-lines: | :number-lines: |
495 | | |
496 | # cd /usr/local/src/apex | >c: |
liamfallon1540e472019-11-28 15:14:07 +0000497 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
498 | | >mvn clean install -Pdocker -DskipTests |
ramverma3b71c972019-07-10 11:25:37 +0000499 +-------------------------------------------------------+--------------------------------------------------------+
500
501.. container:: paragraph
502
503 The build takes about 2 minutes without test and about 4-5 minutes
504 with tests on a standard development laptop. It should run through
505 without errors, but with a lot of messages from the build process. If
506 build with tests (i.e. without ``-DskipTests``), there will be error
507 messages and stack trace prints from some tests. This is normal, as
508 long as the build finishes successful.
509
510.. container:: paragraph
511
512 When Maven is finished with the build, the final screen should look
513 similar to this (omitting some ``success`` lines):
514
515.. container:: listingblock
516
517 .. container:: content
518
ramverma760cce92019-07-11 12:57:49 +0000519 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000520 :number-lines:
521
522 [INFO] tools .............................................. SUCCESS [ 0.248 s]
523 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
524 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
525 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
526 [INFO] packages ........................................... SUCCESS [ 0.336 s]
527 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
528 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
529 [INFO] ------------------------------------------------------------------------
530 [INFO] BUILD SUCCESS
531 [INFO] ------------------------------------------------------------------------
532 [INFO] Total time: 03:43 min
533 [INFO] Finished at: 2018-09-03T11:56:01+01:00
534 [INFO] ------------------------------------------------------------------------
535
536.. container:: paragraph
537
538 The build will have created all artifacts required for an APEX
539 installation. The following example show how to change to the target
540 directory and how it should look like.
541
liamfallonb621de42020-08-21 12:59:26 +0100542+----------------------------------------------------------------------------------------------------------------+
543| Unix, Cygwin |
544+================================================================================================================+
545| .. container:: |
546| |
547| .. container:: listingblock |
548| |
549| .. code:: |
550| :number-lines: |
551| |
552| # cd packages/apex-pdp-package-full/target |
553| # ls -l |
554| -rwxrwx---+ 1 esvevan Domain Users 772 Sep 3 11:55 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes* |
555| -rwxrwx---+ 1 esvevan Domain Users 146328082 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT.deb* |
556| -rwxrwx---+ 1 esvevan Domain Users 15633 Sep 3 11:54 apex-pdp-package-full-2.0.0-SNAPSHOT.jar* |
557| -rwxrwx---+ 1 esvevan Domain Users 146296819 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz* |
558| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 archive-tmp/ |
559| -rwxrwx---+ 1 esvevan Domain Users 89 Sep 3 11:54 checkstyle-cachefile* |
560| -rwxrwx---+ 1 esvevan Domain Users 10621 Sep 3 11:54 checkstyle-checker.xml* |
561| -rwxrwx---+ 1 esvevan Domain Users 584 Sep 3 11:54 checkstyle-header.txt* |
562| -rwxrwx---+ 1 esvevan Domain Users 86 Sep 3 11:54 checkstyle-result.xml* |
563| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 classes/ |
564| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 dependency-maven-plugin-markers/ |
565| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 etc/ |
566| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 examples/ |
567| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:55 install_hierarchy/ |
568| drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 maven-archiver/ |
569+----------------------------------------------------------------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000570
liamfallonb621de42020-08-21 12:59:26 +0100571+-----------------------------------------------------------------------------------------+
572| Windows |
573+=========================================================================================+
574| .. container:: |
575| |
576| .. container:: listingblock |
577| |
578| .. code:: |
579| :number-lines: |
580| |
581| >cd packages\apex-pdp-package-full\target |
582| >dir |
583| 03/09/2018 11:55 <DIR> . |
584| 03/09/2018 11:55 <DIR> .. |
585| 03/09/2018 11:55 146,296,819 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz |
586| 03/09/2018 11:55 146,328,082 apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
587| 03/09/2018 11:54 15,633 apex-pdp-package-full-2.0.0-SNAPSHOT.jar |
588| 03/09/2018 11:55 772 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes |
589| 03/09/2018 11:54 <DIR> archive-tmp |
590| 03/09/2018 11:54 89 checkstyle-cachefile |
591| 03/09/2018 11:54 10,621 checkstyle-checker.xml |
592| 03/09/2018 11:54 584 checkstyle-header.txt |
593| 03/09/2018 11:54 86 checkstyle-result.xml |
594| 03/09/2018 11:54 <DIR> classes |
595| 03/09/2018 11:54 <DIR> dependency-maven-plugin-markers |
596| 03/09/2018 11:54 <DIR> etc |
597| 03/09/2018 11:54 <DIR> examples |
598| 03/09/2018 11:55 <DIR> install_hierarchy |
599| 03/09/2018 11:54 <DIR> maven-archiver |
600| 8 File(s) 292,652,686 bytes |
601| 9 Dir(s) 14,138,720,256 bytes free |
602+-----------------------------------------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000603
604.. container:: paragraph
605
606 Now, take the ``.deb`` or the ``.tar.gz`` file and install APEX.
607 Alternatively, copy the content of the folder ``install_hierarchy``
608 to your APEX directory.
609
610Installation Layout
611-------------------
612
613 .. container:: paragraph
614
615 A full installation of APEX comes with the following layout.
616
617 .. container:: listingblock
618
619 .. container:: content
620
liamfallonb621de42020-08-21 12:59:26 +0100621::
ramverma3b71c972019-07-10 11:25:37 +0000622
623 $APEX_HOME
624 ├───bin (1)
625 ├───etc (2)
626 │ ├───editor
627 │ ├───hazelcast
628 │ ├───infinispan
629 │ └───META-INF
630 ├───examples (3)
631 │ ├───config (4)
632 │ ├───docker (5)
633 │ ├───events (6)
634 │ ├───html (7)
635 │ ├───models (8)
636 │ └───scripts (9)
637 ├───lib (10)
638 │ └───applications (11)
639 └───war (12)
640
641 .. container:: colist arabic
642
643 +-----------------------------------+-----------------------------------+
644 | **1** | binaries, mainly scripts (bash |
645 | | and bat) to start the APEX engine |
646 | | and applications |
647 +-----------------------------------+-----------------------------------+
648 | **2** | configuration files, such as |
649 | | logback (logging) and third party |
650 | | library configurations |
651 +-----------------------------------+-----------------------------------+
652 | **3** | example policy models to get |
653 | | started |
654 +-----------------------------------+-----------------------------------+
655 | **4** | configurations for the examples |
656 | | (with sub directories for |
657 | | individual examples) |
658 +-----------------------------------+-----------------------------------+
659 | **5** | Docker files and additional |
660 | | Docker instructions for the |
661 | | exampples |
662 +-----------------------------------+-----------------------------------+
663 | **6** | example events for the examples |
664 | | (with sub directories for |
665 | | individual examples) |
666 +-----------------------------------+-----------------------------------+
667 | **7** | HTML files for some examples, |
668 | | e.g. the Decisionmaker example |
669 +-----------------------------------+-----------------------------------+
670 | **8** | the policy models, generated for |
671 | | each example (with sub |
672 | | directories for individual |
673 | | examples) |
674 +-----------------------------------+-----------------------------------+
675 | **9** | additional scripts for the |
676 | | examples (with sub directories |
677 | | for individual examples) |
678 +-----------------------------------+-----------------------------------+
679 | **10** | the library folder with all Java |
680 | | JAR files |
681 +-----------------------------------+-----------------------------------+
682 | **11** | applications, also known as jar |
683 | | with dependencies (or fat jars), |
684 | | individually deployable |
685 +-----------------------------------+-----------------------------------+
686 | **12** | WAR files for web applications |
687 +-----------------------------------+-----------------------------------+
688
689System Configuration
690--------------------
691
692 .. container:: paragraph
693
694 Once APEX is installed, a few configurations need to be done:
695
696 .. container:: ulist
697
698 - Create an APEX user and an APEX group (optional, if not
699 installed using RPM and DPKG)
700
701 - Create environment settings for ``APEX_HOME`` and
702 ``APEX_USER``, required by the start scripts
703
704 - Change settings of the logging framework (optional)
705
706 - Create directories for logging, required (execution might fail
707 if directories do not exist or cannot be created)
708
709APEX User and Group
710###################
711
712 .. container:: paragraph
713
714 On smaller installations and test systems, APEX can run as any
715 user or group.
716
717 .. container:: paragraph
718
719 However, if APEX is installed in production, we strongly
720 recommend you set up a dedicated user for running APEX. This
721 will isolate the execution of APEX to that user. We recommend
722 you use the userid ``apexuser`` but you may use any user you
723 choose.
724
725 .. container:: paragraph
726
727 The following example, for UNIX, creates a group called
728 ``apexuser``, an APEX user called ``apexuser``, adds the group
729 to the user, and changes ownership of the APEX installation to
730 the user. Substitute ``<apex-dir>`` with the directory where
731 APEX is installed.
732
733 .. container:: listingblock
734
735 .. container:: content
736
ramverma760cce92019-07-11 12:57:49 +0000737 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000738 :number-lines:
739
740 # sudo groupadd apexuser
741 # sudo useradd -g apexuser apexuser
742 # sudo chown -R apexuser:apexuser <apex-dir>
743
744.. container:: paragraph
745
746 For other operating systems please consult your manual or system
747 administrator.
748
749Environment Settings: APEX_HOME and APEX_USER
750#############################################
751
752 .. container:: paragraph
753
754 The provided start scripts for APEX require two environment
755 variables being set:
756
757 .. container:: ulist
758
759 - ``APEX_USER`` with the user under whos name and permission APEX
760 should be started (Unix only)
761
762 - ``APEX_HOME`` with the directory where APEX is installed (Unix,
763 Windows, Cygwin)
764
765 .. container:: paragraph
766
767 The first row in the following table shows how to set these
768 environment variables temporary (assuming the user is
769 ``apexuser``). The second row shows how to verify the settings.
770 The last row explains how to set those variables permanently.
771
772 +------------------------------------------------+---------------------------------------------------------+
773 | Unix, Cygwin (bash/tcsh) | Windows |
774 +================================================+=========================================================+
775 | .. container:: | .. container:: |
776 | | |
777 | .. container:: content | .. container:: content |
778 | | |
779 | .. code:: | .. code:: |
780 | :number-lines: | :number-lines: |
781 | | |
782 | # export APEX_USER=apexuser | >set APEX_HOME=C:\apex\apex-full-2.0.0-SNAPSHOT |
783 | # cd /opt/app/policy/apex-pdp | |
ramverma760cce92019-07-11 12:57:49 +0000784 | # export APEX_HOME=`pwd` | |
ramverma3b71c972019-07-10 11:25:37 +0000785 | | |
786 +------------------------------------------------+ |
787 | .. container:: | |
788 | | |
789 | .. container:: content | |
790 | | |
ramverma760cce92019-07-11 12:57:49 +0000791 | .. code::tcsh | |
ramverma3b71c972019-07-10 11:25:37 +0000792 | :number-lines: | |
793 | | |
794 | # setenv APEX_USER apexuser | |
795 | # cd /opt/app/policy/apex-pdp | |
ramverma760cce92019-07-11 12:57:49 +0000796 | # setenv APEX_HOME `pwd` | |
ramverma3b71c972019-07-10 11:25:37 +0000797 | | |
798 +------------------------------------------------+---------------------------------------------------------+
799 | .. container:: | .. container:: |
800 | | |
801 | .. container:: content | .. container:: content |
802 | | |
803 | .. code:: | .. code:: |
804 | :number-lines: | :number-lines: |
805 | | |
806 | # env | grep APEX | >set APEX_HOME |
807 | # APEX_USER=apexuser | APEX_HOME=\apex\apex-full-2.0.0-SNAPSHOT |
ramverma760cce92019-07-11 12:57:49 +0000808 | # APEX_HOME=/opt/app/policy/apex-pdp | |
ramverma3b71c972019-07-10 11:25:37 +0000809 | | |
810 +------------------------------------------------+---------------------------------------------------------+
811
812Making Environment Settings Permanent (Unix, Cygwin)
813====================================================
814
815 .. container:: paragraph
816
817 For a per-user setting, edit the a user’s ``bash`` or ``tcsh``
818 settings in ``~/.bashrc`` or ``~/.tcshrc``. For system-wide
819 settings, edit ``/etc/profiles`` (requires permissions).
820
821Making Environment Settings Permanent (Windows)
822===============================================
823
824 .. container:: paragraph
825
826 On Windows 7 do
827
828 .. container:: ulist
829
830 - Click on the **Start** Menu
831
832 - Right click on **Computer**
833
834 - Select **Properties**
835
836 .. container:: paragraph
837
838 On Windows 8/10 do
839
840 .. container:: ulist
841
842 - Click on the **Start** Menu
843
844 - Select **System**
845
846 .. container:: paragraph
847
848 Then do the following
849
850 .. container:: ulist
851
852 - Select **Advanced System Settings**
853
854 - On the **Advanced** tab, click the **Environment Variables**
855 button
856
857 - Edit an existing variable, or create a new System variable:
858 'Variable name'="APEX_HOME", 'Variable
859 value'="C:\apex\apex-full-2.0.0-SNAPSHOT"
860
861 .. container:: paragraph
862
863 For the settings to take effect, an application needs to be
864 restarted (e.g. any open ``cmd`` window).
865
866Edit the APEX Logging Settings
867##############################
868
869 .. container:: paragraph
870
871 Configure the APEX logging settings to your requirements, for
872 instance:
873
874 .. container:: ulist
875
876 - change the directory where logs are written to, or
877
878 - change the log levels
879
880 .. container:: paragraph
881
882 Edit the file ``$APEX_HOME/etc/logback.xml`` for any required
883 changes. To change the log directory change the line
884
885 .. container:: paragraph
886
liamfallon1540e472019-11-28 15:14:07 +0000887 ``<property name="logDir" value="/var/log/onap/policy/apex-pdp/" />``
ramverma3b71c972019-07-10 11:25:37 +0000888
889 .. container:: paragraph
890
891 to
892
893 .. container:: paragraph
894
liamfallon1540e472019-11-28 15:14:07 +0000895 ``<property name="logDir" value="/PATH/TO/LOG/DIRECTORY/" />``
ramverma3b71c972019-07-10 11:25:37 +0000896
897 .. container:: paragraph
898
899 On Windows, it is recommended to change the log directory to:
900
901 .. container:: paragraph
902
liamfallon1540e472019-11-28 15:14:07 +0000903 ``<property name="logDir" value="C:/apex/apex-full-2.0.0-SNAPSHOT/logs" />``
ramverma3b71c972019-07-10 11:25:37 +0000904
905 .. container:: paragraph
906
907 Note: Be careful about when to use ``\`` vs. ``/`` as the path
908 separator!
909
910Create Directories for Logging
911##############################
912
913 .. container:: paragraph
914
915 Make sure that the log directory exists. This is important when
916 APEX was installed manually or when the log directory was changed
917 in the settings (see above).
918
liamfallon9c7bd672019-10-03 13:42:08 +0100919 +-----------------------------------------------------------------------+-------------------------------------------------------+
920 | Unix, Cygwin | Windows |
921 +=======================================================================+=======================================================+
922 | .. container:: | .. container:: |
923 | | |
924 | .. container:: content | .. container:: content |
925 | | |
926 | .. code:: | .. code:: |
927 | :number-lines: | :number-lines: |
928 | | |
929 | sudo mkdir -p /var/log/onap/policy/apex-pdp | >mkdir C:\apex\apex-full-2.0.0-SNAPSHOT\logs |
930 | sudo chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp | |
931 +-----------------------------------------------------------------------+-------------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +0000932
933Verify the APEX Installation
934----------------------------
935
936 .. container:: paragraph
937
938 When APEX is installed and all settings are realized, the
939 installation can be verified.
940
941Verify Installation - run Engine
942################################
943
944 .. container:: paragraph
945
946 A simple verification of an APEX installation can be done by
a.sreekumarebd97932020-09-14 13:34:23 +0100947 simply starting the APEX engine without specifying a tosca policy. On
ramverma3b71c972019-07-10 11:25:37 +0000948 Unix (or Cygwin) start the engine using
liamfallonb621de42020-08-21 12:59:26 +0100949 ``$APEX_HOME/bin/apexApps.sh engine``. On Windows start the engine
950 using ``%APEX_HOME%\bin\apexApps.bat engine``. The engine will fail
ramverma3b71c972019-07-10 11:25:37 +0000951 to fully start. However, if the output looks similar to the
952 following line, the APEX installation is realized.
953
954 .. container:: listingblock
955
956 .. container:: content
957
ramverma760cce92019-07-11 12:57:49 +0000958 .. code::
ramverma3b71c972019-07-10 11:25:37 +0000959 :number-lines:
960
961 Starting Apex service with parameters [] . . .
a.sreekumarebd97932020-09-14 13:34:23 +0100962 start of Apex service failed.
963 org.onap.policy.apex.model.basicmodel.concepts.ApexException: Arguments validation failed.
964 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:238)
965 at org.onap.policy.apex.service.engine.main.ApexMain.<init>(ApexMain.java:86)
966 at org.onap.policy.apex.service.engine.main.ApexMain.main(ApexMain.java:351)
967 Caused by: org.onap.policy.apex.model.basicmodel.concepts.ApexException: Tosca Policy file was not specified as an argument
968 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validateReadableFile(ApexCommandLineArguments.java:242)
969 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validate(ApexCommandLineArguments.java:172)
970 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:235)
971 ... 2 common frames omitted
ramverma3b71c972019-07-10 11:25:37 +0000972
973Verify Installation - run an Example
974####################################
975
976 .. container:: paragraph
977
978 A full APEX installation comes with several examples. Here, we can
979 fully verify the installation by running one of the examples.
980
981 .. container:: paragraph
982
983 We use the example called *SampleDomain* and configure the engine
984 to use standard in and standard out for events. Run the engine
985 with the provided configuration. Note: Cygwin executes scripts as
986 Unix scripts but runs Java as a Windows application, thus the
987 configuration file must be given as a Windows path.
988
liamfallon9c7bd672019-10-03 13:42:08 +0100989 .. container:: paragraph
990
991 On Unix/Linux flavoured platforms, give the commands below:
992
ramverma3b71c972019-07-10 11:25:37 +0000993 .. container:: listingblock
994
995 .. container:: content
996
aditya.puthuparambil9e67eb72020-04-30 15:59:43 +0100997 .. code::
liamfallon9c7bd672019-10-03 13:42:08 +0100998 :number-lines:
ramverma3b71c972019-07-10 11:25:37 +0000999
aditya.puthuparambil9e67eb72020-04-30 15:59:43 +01001000 sudo su - apexuser
1001 export APEX_HOME <path to apex installation>
1002 export APEX_USER apexuser
liamfallon9c7bd672019-10-03 13:42:08 +01001003
1004 .. container:: paragraph
1005
a.sreekumarebd97932020-09-14 13:34:23 +01001006 Create a Tosca Policy for the SampleDomain example using ApexCliToscaEditor
1007 as explained in the section "The APEX CLI Tosca Editor". Assume the tosca policy name is SampleDomain_tosca.json.
1008 You can then try to run apex using the ToscaPolicy.
liamfallon9c7bd672019-10-03 13:42:08 +01001009
1010 .. container:: listingblock
1011
1012 .. container:: content
1013
aditya.puthuparambil9e67eb72020-04-30 15:59:43 +01001014 .. code::
liamfallon9c7bd672019-10-03 13:42:08 +01001015 :number-lines:
1016
a.sreekumarebd97932020-09-14 13:34:23 +01001017 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/examples/SampleDomain_tosca.json (1)
1018 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\examples\SampleDomain_tosca.json(2)
ramverma3b71c972019-07-10 11:25:37 +00001019
1020.. container:: colist arabic
1021
1022 +-------+---------+
1023 | **1** | UNIX |
1024 +-------+---------+
liamfallonb621de42020-08-21 12:59:26 +01001025 | **2** | Windows |
ramverma3b71c972019-07-10 11:25:37 +00001026 +-------+---------+
1027
1028.. container:: paragraph
1029
liamfallon9c7bd672019-10-03 13:42:08 +01001030 The engine should start successfully. Assuming the logging levels are set to ``info`` in the built system, the output
1031 should look similar to this (last few lines)
ramverma3b71c972019-07-10 11:25:37 +00001032
1033.. container:: listingblock
1034
1035 .. container:: content
1036
ramverma760cce92019-07-11 12:57:49 +00001037 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001038 :number-lines:
1039
a.sreekumarebd97932020-09-14 13:34:23 +01001040 Starting Apex service with parameters [-p, /home/ubuntu/apex/SampleDomain_tosca.json] . . .
ramverma3b71c972019-07-10 11:25:37 +00001041 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 .
1042 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 .
1043 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 .
1044 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 .
1045 2018-09-05 15:16:42,805 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - APEX service created.
1046 2018-09-05 15:16:43,962 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging starting . . .
1047 2018-09-05 15:16:43,963 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging started
1048 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
1049 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
1050 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
1051 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
1052 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
1053 Started Apex service
1054
1055.. container:: paragraph
1056
1057 Important are the last two line, stating that APEX has added the
1058 final action listener to the engine and that the engine is started.
1059
1060.. container:: paragraph
1061
1062 The engine is configured to read events from standard input and write
1063 produced events to standard output. The policy model is a very simple
1064 policy.
1065
1066.. container:: paragraph
1067
1068 The following table shows an input event in the left column and an
1069 output event in the right column. Past the input event into the
1070 console where APEX is running, and the output event should appear in
1071 the console. Pasting the input event multiple times will produce
1072 output events with different values.
1073
liamfallonb621de42020-08-21 12:59:26 +01001074+----------------------------------------------------+----------------------------------------------------+
1075| Input Event | Example Output Event |
1076+====================================================+====================================================+
1077| .. container:: | .. container:: |
1078| | |
1079| .. container:: content | .. container:: content |
1080| | |
1081| .. code:: | .. code:: |
1082| :number-lines: | :number-lines: |
1083| | |
1084| { | { |
1085| "nameSpace": "org.onap.policy.apex.sample.events", | "name": "Event0004", |
1086| "name": "Event0000", | "version": "0.0.1", |
1087| "version": "0.0.1", | "nameSpace": "org.onap.policy.apex.sample.events", |
1088| "source": "test", | "source": "Act", |
1089| "target": "apex", | "target": "Outside", |
1090| "TestSlogan": "Test slogan for External Event0", | "TestActCaseSelected": 2, |
1091| "TestMatchCase": 0, | "TestActStateTime": 1536157104627, |
1092| "TestTimestamp": 1469781869269, | "TestDecideCaseSelected": 0, |
1093| "TestTemperature": 9080.866 | "TestDecideStateTime": 1536157104625, |
1094| } | "TestEstablishCaseSelected": 0, |
1095| | "TestEstablishStateTime": 1536157104623, |
1096| | "TestMatchCase": 0, |
1097| | "TestMatchCaseSelected": 1, |
1098| | "TestMatchStateTime": 1536157104620, |
1099| | "TestSlogan": "Test slogan for External Event0", |
1100| | "TestTemperature": 9080.866, |
1101| | "TestTimestamp": 1469781869269 |
1102| | } |
1103+----------------------------------------------------+----------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00001104
1105.. container:: paragraph
1106
1107 Terminate APEX by simply using ``CTRL+C`` in the console.
1108
liamfallon3e524ba2020-07-02 15:32:26 +01001109Verify a Full Installation - REST Client
ramverma3b71c972019-07-10 11:25:37 +00001110########################################
1111
1112 .. container:: paragraph
1113
liamfallon3e524ba2020-07-02 15:32:26 +01001114 APEX has a REST application for deploying, monitoring, and viewing policy models. The
ramverma3b71c972019-07-10 11:25:37 +00001115 application can also be used to create new policy models close to
liamfallon3e524ba2020-07-02 15:32:26 +01001116 the engine native policy language. Start the REST client as
ramverma3b71c972019-07-10 11:25:37 +00001117 follows.
1118
1119 .. container:: listingblock
1120
1121 .. container:: content
1122
ramverma760cce92019-07-11 12:57:49 +00001123 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001124 :number-lines:
1125
liamfallon3e524ba2020-07-02 15:32:26 +01001126 # $APEX_HOME/bin/apexApps.sh full-client
ramverma3b71c972019-07-10 11:25:37 +00001127
1128.. container:: listingblock
1129
1130 .. container:: content
1131
ramverma760cce92019-07-11 12:57:49 +00001132 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001133 :number-lines:
1134
liamfallon3e524ba2020-07-02 15:32:26 +01001135 >%APEX_HOME%\bin\apexApps.bat full-client
ramverma3b71c972019-07-10 11:25:37 +00001136
1137.. container:: paragraph
1138
1139 The script will start a simple web server
1140 (`Grizzly <https://javaee.github.io/grizzly/>`__) and deploy a
liamfallon3e524ba2020-07-02 15:32:26 +01001141 ``war`` web archive in it. Once the client is started, it will be
ramverma3b71c972019-07-10 11:25:37 +00001142 available on ``localhost:18989``. The last few line of the messages
1143 should be:
1144
1145.. container:: listingblock
1146
1147 .. container:: content
1148
ramverma760cce92019-07-11 12:57:49 +00001149 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001150 :number-lines:
1151
liamfallon3e524ba2020-07-02 15:32:26 +01001152 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
1153 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.NetworkListener start
ramverma3b71c972019-07-10 11:25:37 +00001154 INFO: Started listener bound to [localhost:18989]
liamfallon3e524ba2020-07-02 15:32:26 +01001155 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.HttpServer start
ramverma3b71c972019-07-10 11:25:37 +00001156 INFO: [HttpServer] Started.
liamfallon3e524ba2020-07-02 15:32:26 +01001157 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
1158
ramverma3b71c972019-07-10 11:25:37 +00001159
1160.. container:: paragraph
1161
1162 Now open a browser (Firefox, Chrome, Opera, Internet Explorer) and
1163 use the URL ``http://localhost:18989/``. This will connect the
liamfallon3e524ba2020-07-02 15:32:26 +01001164 browser to the started REST client. Click on the "Policy Editor" button and the Policy Editor start screen should be as
ramverma3b71c972019-07-10 11:25:37 +00001165 follows.
1166
1167.. container:: imageblock
1168
1169 .. container:: content
1170
liamfallon75e2bbf2020-07-06 11:41:38 +01001171 |Policy Editor Start Screen|
ramverma3b71c972019-07-10 11:25:37 +00001172
1173 .. container:: title
1174
liamfallon75e2bbf2020-07-06 11:41:38 +01001175 Figure 1. Policy Editor Start Screen
ramverma3b71c972019-07-10 11:25:37 +00001176
1177.. container:: paragraph
1178
1179 Now load a policy model by clicking the menu ``File`` and then
1180 ``Open``. In the opened dialog, go to the directory where APEX is
1181 installed, then ``examples``, ``models``, ``SampleDomain``, and there
1182 select the file ``SamplePolicyModelJAVA.json``. This will load the
1183 policy model used to verify the policy engine (see above). Once
1184 loaded, the screen should look as follows.
1185
1186.. container:: imageblock
1187
1188 .. container:: content
1189
liamfallon75e2bbf2020-07-06 11:41:38 +01001190 |Policy Editor with loaded SampleDomain Policy Model|
ramverma3b71c972019-07-10 11:25:37 +00001191
1192 .. container:: title
1193
liamfallon75e2bbf2020-07-06 11:41:38 +01001194 Figure 2. Policy Editor with loaded SampleDomain Policy Model
ramverma3b71c972019-07-10 11:25:37 +00001195
1196.. container:: paragraph
1197
liamfallon75e2bbf2020-07-06 11:41:38 +01001198 Now you can use the Policy editor. To finish this verification, simply
ramverma3b71c972019-07-10 11:25:37 +00001199 terminate your browser (or the tab), and then use ``CTRL+C`` in the
liamfallon75e2bbf2020-07-06 11:41:38 +01001200 console where you started the Policy editor.
ramverma3b71c972019-07-10 11:25:37 +00001201
liamfallon3e524ba2020-07-02 15:32:26 +01001202Installing the WAR Application
1203------------------------------
ramverma3b71c972019-07-10 11:25:37 +00001204
1205 .. container:: paragraph
1206
liamfallon3e524ba2020-07-02 15:32:26 +01001207 The three APEX clients are packaged in a WAR file. This is a complete
1208 application that can be installed and run in an application
1209 server. The application is realized as a servlet. You
1210 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/>`__.
1211
ramverma3b71c972019-07-10 11:25:37 +00001212
1213 .. container:: paragraph
1214
liamfallon3e524ba2020-07-02 15:32:26 +01001215 Installing and using the WAR application requires a web server
ramverma3b71c972019-07-10 11:25:37 +00001216 that can execute ``war`` web archives. We recommend to use `Apache
1217 Tomcat <https://tomcat.apache.org/>`__, however other web servers
1218 can be used as well.
1219
1220 .. container:: paragraph
1221
1222 Install Apache Tomcat including the ``Manager App``, see `V9.0
1223 Docs <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html#Configuring_Manager_Application_Access>`__
1224 for details. Start the Tomcat service, or make sure that Tomcat is
1225 running.
1226
1227 .. container:: paragraph
1228
liamfallon3e524ba2020-07-02 15:32:26 +01001229 There are multiple ways to install the APEX WAR application:
ramverma3b71c972019-07-10 11:25:37 +00001230
1231 .. container:: ulist
1232
1233 - copy the ``.war`` file into the Tomcat ``webapps`` folder
1234
1235 - use the Tomcat ``Manager App`` to deploy via the web interface
1236
1237 - deploy using a REST call to Tomcat
1238
1239 .. container:: paragraph
1240
1241 For details on how to install ``war`` files please consult the
1242 `Tomcat
1243 Documentation <https://tomcat.apache.org/tomcat-9.0-doc/index.html>`__
1244 or the `Manager App
1245 HOW-TO <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html>`__.
1246 Once you installed an APEX WAR application (and wait for
1247 sufficient time for Tomcat to finalize the installation), open the
1248 ``Manager App`` in Tomcat. You should see the APEX WAR application
1249 being installed and running.
1250
1251 .. container:: paragraph
1252
1253 In case of errors, examine the log files in the Tomcat log
1254 directory. In a conventional install, those log files are in the
1255 logs directory where Tomcat is installed.
1256
1257 .. container:: paragraph
1258
liamfallon3e524ba2020-07-02 15:32:26 +01001259 The WAR application file has a name similar to *apex-client-full-<VERSION>.war*.
ramverma3b71c972019-07-10 11:25:37 +00001260
1261Running APEX in Docker
1262----------------------
1263
1264 .. container:: paragraph
1265
1266 Since APEX is in ONAP, we provide a full virtualization
1267 environment for the engine.
1268
1269Run in ONAP
1270###########
1271
1272 .. container:: paragraph
1273
1274 Running APEX from the ONAP docker repository only requires 2
1275 commands:
1276
1277 .. container:: olist arabic
1278
1279 #. Log into the ONAP docker repo
1280
1281 .. container:: listingblock
1282
1283 .. container:: content
1284
liamfallonb621de42020-08-21 12:59:26 +01001285::
ramverma3b71c972019-07-10 11:25:37 +00001286
1287 docker login -u docker -p docker nexus3.onap.org:10003
1288
1289 .. container:: olist arabic
1290
1291 #. Run the APEX docker image
1292
1293 .. container:: listingblock
1294
1295 .. container:: content
1296
1297 ::
1298
1299 docker run -it --rm nexus3.onap.org:10003/onap/policy-apex-pdp:latest
1300
1301Build a Docker Image
1302####################
1303
1304 .. container:: paragraph
1305
1306 Alternatively, one can use the Dockerfile defined in the Docker
1307 package to build an image.
1308
1309 .. container:: listingblock
1310
1311 .. container:: title
1312
1313 APEX Dockerfile
1314
1315 .. container:: content
1316
ramverma760cce92019-07-11 12:57:49 +00001317 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001318 :number-lines:
1319
1320 #
1321 # Docker file to build an image that runs APEX on Java 8 in Ubuntu
1322 #
1323 FROM ubuntu:16.04
1324
1325 RUN apt-get update && \
1326 apt-get upgrade -y && \
1327 apt-get install -y software-properties-common && \
1328 add-apt-repository ppa:openjdk-r/ppa -y && \
1329 apt-get update && \
1330 apt-get install -y openjdk-8-jdk
1331
1332 # Create apex user and group
1333 RUN groupadd apexuser
1334 RUN useradd --create-home -g apexuser apexuser
1335
1336 # Add Apex-specific directories and set ownership as the Apex admin user
1337 RUN mkdir -p /opt/app/policy/apex-pdp
1338 RUN mkdir -p /var/log/onap/policy/apex-pdp
1339 RUN chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp
1340
1341 # Unpack the tarball
1342 RUN mkdir /packages
1343 COPY apex-pdp-package-full.tar.gz /packages
1344 RUN tar xvfz /packages/apex-pdp-package-full.tar.gz --directory /opt/app/policy/apex-pdp
1345 RUN rm /packages/apex-pdp-package-full.tar.gz
1346
1347 # Ensure everything has the correct permissions
1348 RUN find /opt/app -type d -perm 755
1349 RUN find /opt/app -type f -perm 644
1350 RUN chmod a+x /opt/app/policy/apex-pdp/bin/*
1351
1352 # Copy examples to Apex user area
1353 RUN cp -pr /opt/app/policy/apex-pdp/examples /home/apexuser
1354
1355 RUN apt-get clean
1356
1357 RUN chown -R apexuser:apexuser /home/apexuser/*
1358
1359 USER apexuser
1360 ENV PATH /opt/app/policy/apex-pdp/bin:$PATH
1361 WORKDIR /home/apexuser
1362
a.sreekumarebd97932020-09-14 13:34:23 +01001363Running APEX in Standalone mode
1364-------------------------------
1365
1366 .. container:: paragraph
1367
1368 APEX Engine can run in standalone mode by taking in a ToscaPolicy
1369 as an argument and executing it.
1370 Assume there is a tosca policy named ToscaPolicy.json in APEX_HOME directory
1371 This policy can be executed in standalone mode using any of the below methods.
1372
1373Run in an APEX installation
1374###########################
1375
1376 .. container:: listingblock
1377
1378 .. container:: content
1379
1380 .. code::
1381 :number-lines:
1382
1383 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/ToscaPolicy.json(1)
1384 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\ToscaPolicy.json(2)
1385
1386.. container:: colist arabic
1387
1388 +-------+---------+
1389 | **1** | UNIX |
1390 +-------+---------+
1391 | **2** | Windows |
1392 +-------+---------+
1393
1394Run in a docker container
1395#########################
1396
1397 .. container:: listingblock
1398
1399 .. container:: content
1400
1401 .. code::
1402 :number-lines:
1403
1404 # docker run -p 6969:6969 -v $APEX_HOME/ToscaPolicy.json:/tmp/policy/ToscaPolicy.json \
Ram Krishna Vermaace4b432021-03-25 10:29:18 -04001405 --name apex -it nexus3.onap.org:10001/onap/policy-apex-pdp:latest \
a.sreekumarebd97932020-09-14 13:34:23 +01001406 -c "/opt/app/policy/apex-pdp/bin/apexEngine.sh -p /tmp/policy/ToscaPolicy.json"
1407
ramverma3b71c972019-07-10 11:25:37 +00001408APEX Configurations Explained
1409^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1410
1411Introduction to APEX Configuration
1412----------------------------------
1413
1414 .. container:: paragraph
1415
1416 An APEX engine can be configured to use various combinations
1417 of event input handlers, event output handlers, event
1418 protocols, context handlers, and logic executors. The system
1419 is build using a plugin architecture. Each configuration
1420 option is realized by a plugin, which can be loaded and
1421 configured when the engine is started. New plugins can be
1422 added to the system at any time, though to benefit from a
1423 new plugin an engine will need to be restarted.
1424
1425 .. container:: imageblock
1426
1427 .. container:: content
1428
1429 |APEX Configuration Matrix|
1430
1431 .. container:: title
1432
1433 Figure 3. APEX Configuration Matrix
1434
1435 .. container:: paragraph
1436
1437 The APEX distribution already comes with a number of
1438 plugins. The figure above shows the provided plugins. Any
1439 combination of input, output, event protocol, context
1440 handlers, and executors is possible.
1441
1442General Configuration Format
1443----------------------------
1444
1445 .. container:: paragraph
1446
1447 The APEX configuration file is a JSON file containing a few
1448 main blocks for different parts of the configuration. Each
1449 block then holds the configuration details. The following
1450 code shows the main blocks:
1451
1452 .. container:: listingblock
1453
1454 .. container:: content
1455
ramverma760cce92019-07-11 12:57:49 +00001456 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001457
1458 {
1459 "engineServiceParameters":{
1460 ... (1)
1461 "engineParameters":{ (2)
a.sreekumarcc0e9172020-03-16 13:36:45 +00001462 "executorParameters":{...}, (3)
ramverma3b71c972019-07-10 11:25:37 +00001463 "contextParameters":{...} (4)
a.sreekumarcc0e9172020-03-16 13:36:45 +00001464 "taskParameters":[...] (5)
ramverma3b71c972019-07-10 11:25:37 +00001465 }
1466 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001467 "eventInputParameters":{ (6)
1468 "input1":{ (7)
ramverma3b71c972019-07-10 11:25:37 +00001469 "carrierTechnologyParameters":{...},
1470 "eventProtocolParameters":{...}
1471 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001472 "input2":{...}, (8)
ramverma3b71c972019-07-10 11:25:37 +00001473 "carrierTechnologyParameters":{...},
1474 "eventProtocolParameters":{...}
1475 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001476 ... (9)
ramverma3b71c972019-07-10 11:25:37 +00001477 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001478 "eventOutputParameters":{ (10)
1479 "output1":{ (11)
ramverma3b71c972019-07-10 11:25:37 +00001480 "carrierTechnologyParameters":{...},
1481 "eventProtocolParameters":{...}
1482 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001483 "output2":{ (12)
ramverma3b71c972019-07-10 11:25:37 +00001484 "carrierTechnologyParameters":{...},
1485 "eventProtocolParameters":{...}
1486 },
a.sreekumarcc0e9172020-03-16 13:36:45 +00001487 ... (13)
ramverma3b71c972019-07-10 11:25:37 +00001488 }
1489 }
1490
1491 .. container:: colist arabic
1492
1493 +-----------------------------------+-----------------------------------+
1494 | **1** | main engine configuration |
1495 +-----------------------------------+-----------------------------------+
1496 | **2** | engine parameters for plugin |
1497 | | configurations (execution |
1498 | | environments and context |
1499 | | handling) |
1500 +-----------------------------------+-----------------------------------+
1501 | **3** | engine specific parameters, |
1502 | | mainly for executor plugins |
1503 +-----------------------------------+-----------------------------------+
1504 | **4** | context specific parameters, e.g. |
1505 | | for context schemas, persistence, |
1506 | | etc. |
1507 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001508 | **5** | list of task parameters that |
1509 | | should be made available in task |
1510 | | logic (optional). |
1511 +-----------------------------------+-----------------------------------+
1512 | **6** | configuration of the input |
ramverma3b71c972019-07-10 11:25:37 +00001513 | | interface |
1514 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001515 | **7** | an example input called |
ramverma3b71c972019-07-10 11:25:37 +00001516 | | ``input1`` with carrier |
1517 | | technology and event protocol |
1518 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001519 | **8** | an example input called |
ramverma3b71c972019-07-10 11:25:37 +00001520 | | ``input2`` with carrier |
1521 | | technology and event protocol |
1522 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001523 | **9** | any further input configuration |
ramverma3b71c972019-07-10 11:25:37 +00001524 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001525 | **10** | configuration of the output |
ramverma3b71c972019-07-10 11:25:37 +00001526 | | interface |
1527 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001528 | **11** | an example output called |
ramverma3b71c972019-07-10 11:25:37 +00001529 | | ``output1`` with carrier |
1530 | | technology and event protocol |
1531 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001532 | **12** | an example output called |
ramverma3b71c972019-07-10 11:25:37 +00001533 | | ``output2`` with carrier |
1534 | | technology and event protocol |
1535 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001536 | **13** | any further output configuration |
ramverma3b71c972019-07-10 11:25:37 +00001537 +-----------------------------------+-----------------------------------+
1538
1539Engine Service Parameters
1540-------------------------
1541
1542 .. container:: paragraph
1543
1544 The configuration provides a number of parameters to
1545 configure the engine. An example configuration with
1546 explanations of all options is shown below.
1547
1548 .. container:: listingblock
1549
1550 .. container:: content
1551
ramverma760cce92019-07-11 12:57:49 +00001552 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001553
1554 "engineServiceParameters" : {
1555 "name" : "AADMApexEngine", (1)
1556 "version" : "0.0.1", (2)
1557 "id" : 45, (3)
1558 "instanceCount" : 4, (4)
1559 "deploymentPort" : 12345, (5)
a.sreekumarcf3ff822020-09-16 13:12:29 +01001560 "policy_type_impl" : {...}, (6)
ramverma3b71c972019-07-10 11:25:37 +00001561 "periodicEventPeriod": 1000, (7)
1562 "engineParameters":{ (8)
a.sreekumarcc0e9172020-03-16 13:36:45 +00001563 "executorParameters":{...}, (9)
1564 "contextParameters":{...}, (10)
1565 "taskParameters":[...] (11)
ramverma3b71c972019-07-10 11:25:37 +00001566 }
1567 }
1568
1569 .. container:: colist arabic
1570
1571 +-----------------------------------+-----------------------------------+
1572 | **1** | a name for the engine. The engine |
1573 | | name is used to create a key in a |
1574 | | runtime engine. An name matching |
1575 | | the following regular expression |
1576 | | can be used here: |
1577 | | ``[A-Za-z0-9\\-_\\.]+`` |
1578 +-----------------------------------+-----------------------------------+
1579 | **2** | a version of the engine, use |
1580 | | semantic versioning as explained |
1581 | | here: `Semantic |
1582 | | Versioning <http://semver.org/>`_ |
1583 | | _. |
1584 | | This version is used in a runtime |
1585 | | engine to create a version of the |
1586 | | engine. For that reason, the |
1587 | | version must match the following |
1588 | | regular expression ``[A-Z0-9.]+`` |
1589 +-----------------------------------+-----------------------------------+
1590 | **3** | a numeric identifier for the |
1591 | | engine |
1592 +-----------------------------------+-----------------------------------+
1593 | **4** | the number of threads (policy |
1594 | | instances executed in parallel) |
1595 | | the engine should use, use ``1`` |
1596 | | for single threaded engines |
1597 +-----------------------------------+-----------------------------------+
1598 | **5** | the port for the deployment |
1599 | | Websocket connection to the |
1600 | | engine |
1601 +-----------------------------------+-----------------------------------+
a.sreekumarcf3ff822020-09-16 13:12:29 +01001602 | **6** | the APEX policy model as a JSON |
liamfallon3e524ba2020-07-02 15:32:26 +01001603 | | or YAML block to load into the |
1604 | | engine on startup when |
1605 | | APEX is running a policy that has |
1606 | | its logic and parameters |
1607 | | specified in TOSCA |
1608 | | (optional) |
ramverma3b71c972019-07-10 11:25:37 +00001609 +-----------------------------------+-----------------------------------+
1610 | **7** | an optional timer for periodic |
1611 | | policies, in milliseconds (a |
1612 | | defined periodic policy will be |
1613 | | executed every ``X`` |
1614 | | milliseconds), not used of not |
1615 | | set or ``0`` |
1616 +-----------------------------------+-----------------------------------+
1617 | **8** | engine parameters for plugin |
1618 | | configurations (execution |
1619 | | environments and context |
1620 | | handling) |
1621 +-----------------------------------+-----------------------------------+
1622 | **9** | engine specific parameters, |
1623 | | mainly for executor plugins |
1624 +-----------------------------------+-----------------------------------+
1625 | **10** | context specific parameters, e.g. |
1626 | | for context schemas, persistence, |
1627 | | etc. |
1628 +-----------------------------------+-----------------------------------+
a.sreekumarcc0e9172020-03-16 13:36:45 +00001629 | **11** | list of task parameters that |
1630 | | should be made available in task |
1631 | | logic (optional). |
1632 +-----------------------------------+-----------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00001633
1634 .. container:: paragraph
1635
1636 The model file is optional, it can also be specified via
1637 command line. In any case, make sure all execution and other
1638 required plug-ins for the loaded model are loaded as
1639 required.
1640
1641Input and Output Interfaces
1642---------------------------
1643
1644 .. container:: paragraph
1645
1646 An APEX engine has two main interfaces:
1647
1648 .. container:: ulist
1649
1650 - An *input* interface to receive events: also known as
1651 ingress interface or consumer, receiving (consuming)
1652 events commonly named triggers, and
1653
1654 - An *output* interface to publish produced events: also
1655 known as egress interface or producer, sending
1656 (publishing) events commonly named actions or action
1657 events.
1658
1659 .. container:: paragraph
1660
1661 The input and output interface is configured in terms of
1662 inputs and outputs, respectively. Each input and output is a
1663 combination of a carrier technology and an event protocol.
1664 Carrier technologies and event protocols are provided by
1665 plugins, each with its own specific configuration. Most
1666 carrier technologies can be configured for input as well as
1667 output. Most event protocols can be used for all carrier
1668 technologies. One exception is the JMS object event
1669 protocol, which can only be used for the JMS carrier
1670 technology. Some further restrictions apply (for instance
1671 for carrier technologies using bi- or uni-directional
1672 modes).
1673
1674 .. container:: paragraph
1675
1676 Input and output interface can be configured separately, in
1677 isolation, with any number of carrier technologies. The
1678 resulting general configuration options are:
1679
1680 .. container:: ulist
1681
1682 - Input interface with one or more inputs
1683
1684 .. container:: ulist
1685
1686 - each input with a carrier technology and an event
1687 protocol
1688
1689 - some inputs with optional synchronous mode
1690
1691 - some event protocols with additional parameters
1692
1693 - Output interface with one or more outputs
1694
1695 .. container:: ulist
1696
1697 - each output with a carrier technology and an event
1698 encoding
1699
1700 - some outputs with optional synchronous mode
1701
1702 - some event protocols with additional parameters
1703
1704 .. container:: paragraph
1705
1706 The configuration for input and output is contained in
1707 ``eventInputParameters`` and ``eventOutputParameters``,
1708 respectively. Inside here, one can configure any number of
1709 inputs and outputs. Each of them needs to have a unique
1710 identifier (name), the content of the name is free form. The
1711 example below shows a configuration for two inputs and two
1712 outputs.
1713
1714 .. container:: listingblock
1715
1716 .. container:: content
1717
ramverma760cce92019-07-11 12:57:49 +00001718 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001719
1720 "eventInputParameters": { (1)
1721 "FirstConsumer": { (2)
1722 "carrierTechnologyParameters" : {...}, (3)
1723 "eventProtocolParameters":{...}, (4)
1724 ... (5)
1725 },
1726 "SecondConsumer": { (6)
1727 "carrierTechnologyParameters" : {...}, (7)
1728 "eventProtocolParameters":{...}, (8)
1729 ... (9)
1730 },
1731 },
1732 "eventOutputParameters": { (10)
1733 "FirstProducer": { (11)
1734 "carrierTechnologyParameters":{...}, (12)
1735 "eventProtocolParameters":{...}, (13)
1736 ... (14)
1737 },
1738 "SecondProducer": { (15)
1739 "carrierTechnologyParameters":{...}, (16)
1740 "eventProtocolParameters":{...}, (17)
1741 ... (18)
1742 }
1743 }
1744
1745 .. container:: colist arabic
1746
1747 +--------+--------------------------------------------------------------------+
1748 | **1** | input interface configuration, APEX input plugins |
1749 +--------+--------------------------------------------------------------------+
1750 | **2** | first input called ``FirstConsumer`` |
1751 +--------+--------------------------------------------------------------------+
1752 | **3** | carrier technology for plugin |
1753 +--------+--------------------------------------------------------------------+
1754 | **4** | event protocol for plugin |
1755 +--------+--------------------------------------------------------------------+
1756 | **5** | any other input configuration (e.g. event name filter, see below) |
1757 +--------+--------------------------------------------------------------------+
1758 | **6** | second input called ``SecondConsumer`` |
1759 +--------+--------------------------------------------------------------------+
1760 | **7** | carrier technology for plugin |
1761 +--------+--------------------------------------------------------------------+
1762 | **8** | event protocol for plugin |
1763 +--------+--------------------------------------------------------------------+
1764 | **9** | any other plugin configuration |
1765 +--------+--------------------------------------------------------------------+
1766 | **10** | output interface configuration, APEX output plugins |
1767 +--------+--------------------------------------------------------------------+
1768 | **11** | first output called ``FirstProducer`` |
1769 +--------+--------------------------------------------------------------------+
1770 | **12** | carrier technology for plugin |
1771 +--------+--------------------------------------------------------------------+
1772 | **13** | event protocol for plugin |
1773 +--------+--------------------------------------------------------------------+
1774 | **14** | any other plugin configuration |
1775 +--------+--------------------------------------------------------------------+
1776 | **15** | second output called ``SecondProducer`` |
1777 +--------+--------------------------------------------------------------------+
1778 | **16** | carrier technology for plugin |
1779 +--------+--------------------------------------------------------------------+
1780 | **17** | event protocol for plugin |
1781 +--------+--------------------------------------------------------------------+
1782 | **18** | any other output configuration (e.g. event name filter, see below) |
1783 +--------+--------------------------------------------------------------------+
1784
a.sreekumar61cb1ef2020-10-06 10:37:45 +01001785Event Name
1786##########
1787
1788 .. container:: paragraph
1789
1790 Any event defined in APEX has to be unique. The "name" of
1791 of an event is used as an identifier for an ApexEvent. Every
1792 event has to be tagged to an eventName. This can be done in different
1793 ways. Either the actual event can have a field called "name". Or, the
1794 event has some other field that can act as the identifier, which can be
1795 specified using "nameAlias". But in other cases, where a "name" or "nameAlias"
1796 cannot be specified, the incoming event coming over an endpoint can be
1797 manually tagged to an "eventName" before consuming it.
1798
1799 .. container:: paragraph
1800
1801 The "eventName" can have a single event's name if the event coming
1802 over the endpoint has to be always mapped to the specified eventName's
1803 definition. Otherwise, if different events can come over the endpoint,
1804 then "eventName" field can consist of multiple event names separated by
1805 "|" symbol. In this case, based on the received event's structure, it is
1806 mapped to any one of the event name specified in the "eventName" field.
1807
1808 .. container:: paragraph
1809
1810 The following code shows some examples on how to specify the eventName field:
1811
1812 .. container:: listingblock
1813
1814 .. container:: content
1815
1816 .. code::
1817
1818 "eventInputParameters": {
1819 "Input1": {
1820 "carrierTechnologyParameters" : {...},
1821 "eventProtocolParameters":{...},
1822 "eventName" : "VesEvent" (1)
1823 },
1824 "Input2": {
1825 "carrierTechnologyParameters" : {...},
1826 "eventProtocolParameters":{...},
1827 "eventName" : "AAISuccessResponseEvent|AAIFailureResponseEvent" (2)
1828 }
1829 }
1830
ramverma3b71c972019-07-10 11:25:37 +00001831Event Filters
1832#############
1833
1834 .. container:: paragraph
1835
1836 APEX will always send an event after a policy execution
1837 is finished. For a successful execution, the event sent
1838 is the output event created by the policy. In case the
1839 policy does not create an output event, APEX will create
1840 a new event with all input event fields plus an
1841 additional field ``exceptionMessage`` with an exception
1842 message.
1843
1844 .. container:: paragraph
1845
1846 There are situations in which this auto-generated error
1847 event might not be required or wanted:
1848
1849 .. container:: ulist
1850
1851 - when a policy failing should not result in an event
1852 send out via an output interface
1853
1854 - when the auto-generated event goes back in an APEX
1855 engine (or the same APEX engine), this can create
1856 endless loops
1857
1858 - the auto-generated event should go to a special output
1859 interface or channel
1860
1861 .. container:: paragraph
1862
1863 All of these situations are supported by a filter option
1864 using a wildecard (regular expression) configuration on
1865 APEX I/O interfaces. The parameter is called
1866 ``eventNameFilter`` and the value are `Java regular
1867 expressions <https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html>`__
1868 (a
1869 `tutorial <http://www.vogella.com/tutorials/JavaRegularExpressions/article.html>`__).
1870 The following code shows some examples:
1871
1872 .. container:: listingblock
1873
1874 .. container:: content
1875
ramverma760cce92019-07-11 12:57:49 +00001876 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001877
1878 "eventInputParameters": {
1879 "Input1": {
1880 "carrierTechnologyParameters" : {...},
1881 "eventProtocolParameters":{...},
1882 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]004$" (1)
1883 }
1884 },
1885 "eventOutputParameters": {
1886 "Output1": {
1887 "carrierTechnologyParameters":{...},
1888 "eventProtocolParameters":{...},
1889 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]104$" (2)
1890 }
1891 }
1892
1893Executors
1894---------
1895
1896 .. container:: paragraph
1897
1898 Executors are plugins that realize the execution of logic
1899 contained in a policy model. Logic can be in a task
1900 selector, a task, and a state finalizer. Using plugins for
1901 execution environments makes APEX very flexible to support
1902 virtually any executable logic expressions.
1903
1904 .. container:: paragraph
1905
1906 APEX 2.0.0-SNAPSHOT supports the following executors:
1907
1908 .. container:: ulist
1909
1910 - Java, for Java implemented logic
1911
1912 .. container:: ulist
1913
1914 - This executor requires logic implemented using the
1915 APEX Java interfaces.
1916
1917 - Generated JAR files must be in the classpath of the
1918 APEX engine at start time.
1919
1920 - Javascript
1921
1922 - JRuby,
1923
1924 - Jython,
1925
1926 - MVEL
1927
1928 .. container:: ulist
1929
1930 - This executor uses the latest version of the MVEL
1931 engine, which can be very hard to debug and can
1932 produce unwanted side effects during execution
1933
1934Configure the Javascript Executor
1935#################################
1936
1937 .. container:: paragraph
1938
1939 The Javascript executor is added to the configuration as
1940 follows:
1941
1942 .. container:: listingblock
1943
1944 .. container:: content
1945
ramverma760cce92019-07-11 12:57:49 +00001946 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001947
1948 "engineServiceParameters":{
1949 "engineParameters":{
1950 "executorParameters":{
1951 "JAVASCRIPT":{
1952 "parameterClassName" :
1953 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
1954 }
1955 }
1956 }
1957 }
1958
1959Configure the Jython Executor
1960#############################
1961
1962 .. container:: paragraph
1963
1964 The Jython executor is added to the configuration as
1965 follows:
1966
1967 .. container:: listingblock
1968
1969 .. container:: content
1970
ramverma760cce92019-07-11 12:57:49 +00001971 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001972
1973 "engineServiceParameters":{
1974 "engineParameters":{
1975 "executorParameters":{
1976 "JYTHON":{
1977 "parameterClassName" :
1978 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
1979 }
1980 }
1981 }
1982 }
1983
1984Configure the JRuby Executor
1985############################
1986
1987 .. container:: paragraph
1988
1989 The JRuby executor is added to the configuration as
1990 follows:
1991
1992 .. container:: listingblock
1993
1994 .. container:: content
1995
ramverma760cce92019-07-11 12:57:49 +00001996 .. code::
ramverma3b71c972019-07-10 11:25:37 +00001997
1998 "engineServiceParameters":{
1999 "engineParameters":{
2000 "executorParameters":{
2001 "JRUBY":{
2002 "parameterClassName" :
2003 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
2004 }
2005 }
2006 }
2007 }
2008
2009Configure the Java Executor
2010###########################
2011
2012 .. container:: paragraph
2013
2014 The Java executor is added to the configuration as
2015 follows:
2016
2017 .. container:: listingblock
2018
2019 .. container:: content
2020
ramverma760cce92019-07-11 12:57:49 +00002021 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002022
2023 "engineServiceParameters":{
2024 "engineParameters":{
2025 "executorParameters":{
2026 "JAVA":{
2027 "parameterClassName" :
2028 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
2029 }
2030 }
2031 }
2032 }
2033
2034Configure the MVEL Executor
2035###########################
2036
2037 .. container:: paragraph
2038
2039 The MVEL executor is added to the configuration as
2040 follows:
2041
2042 .. container:: listingblock
2043
2044 .. container:: content
2045
ramverma760cce92019-07-11 12:57:49 +00002046 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002047
2048 "engineServiceParameters":{
2049 "engineParameters":{
2050 "executorParameters":{
2051 "MVEL":{
2052 "parameterClassName" :
2053 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
2054 }
2055 }
2056 }
2057 }
2058
2059Context Handlers
2060----------------
2061
2062 .. container:: paragraph
2063
2064 Context handlers are responsible for all context processing.
2065 There are the following main areas:
2066
2067 .. container:: ulist
2068
2069 - Context schema: use schema handlers other than Java class
2070 (supported by default without configuration)
2071
2072 - Context distribution: distribute context across multiple
2073 APEX engines
2074
2075 - Context locking: mechanisms to lock context elements for
2076 read/write
2077
2078 - Context persistence: mechanisms to persist context
2079
2080 .. container:: paragraph
2081
2082 APEX provides plugins for each of the main areas.
2083
2084Configure AVRO Schema Handler
2085#############################
2086
2087 .. container:: paragraph
2088
2089 The AVRO schema handler is added to the configuration as
2090 follows:
2091
2092 .. container:: listingblock
2093
2094 .. container:: content
2095
ramverma760cce92019-07-11 12:57:49 +00002096 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002097
2098 "engineServiceParameters":{
2099 "engineParameters":{
2100 "contextParameters":{
2101 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2102 "schemaParameters":{
2103 "Avro":{
2104 "parameterClassName" :
2105 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
2106 }
2107 }
2108 }
2109 }
2110 }
2111
2112 .. container:: paragraph
2113
2114 Using the AVRO schema handler has one limitation: AVRO
2115 only supports field names that represent valid Java class
2116 names. This means only letters and the character ``_``
2117 are supported. Characters commonly used in field names,
2118 such as ``.`` and ``-``, are not supported by AVRO. for
2119 more information see `Avro Spec:
2120 Names <https://avro.apache.org/docs/1.8.1/spec.html#names>`__.
2121
2122 .. container:: paragraph
2123
2124 To work with this limitation, the APEX Avro plugin will
2125 parse a given AVRO definition and replace *all*
2126 occurrences of ``.`` and ``-`` with a ``_``. This means
2127 that
2128
2129 .. container:: ulist
2130
2131 - In a policy model, if the AVRO schema defined a field
2132 as ``my-name`` the policy logic should access it as
2133 ``my_name``
2134
2135 - In a policy model, if the AVRO schema defined a field
2136 as ``my.name`` the policy logic should access it as
2137 ``my_name``
2138
2139 - There should be no field names that convert to the
2140 same internal name
2141
2142 .. container:: ulist
2143
2144 - For instance the simultaneous use of
2145 ``my_name``, ``my.name``, and ``my-name`` should
2146 be avoided
2147
2148 - If not avoided, the event processing might
2149 create unwanted side effects
2150
2151 - If field names use any other not-supported character,
2152 the AVRO plugin will reject it
2153
2154 .. container:: ulist
2155
2156 - Since AVRO uses lazy initialization, this
2157 rejection might only become visible at runtime
2158
a.sreekumarcc0e9172020-03-16 13:36:45 +00002159Configure Task Parameters
2160#########################
2161
2162 .. container:: paragraph
2163
2164 The Task Parameters are added to the configuration as
2165 follows:
2166
2167 .. container:: listingblock
2168
2169 .. container:: content
2170
2171 .. code::
2172
2173 "engineServiceParameters": {
2174 "engineParameters": {
2175 "taskParameters": [
2176 {
2177 "key": "ParameterKey1",
2178 "value": "ParameterValue1"
2179 },
2180 {
2181 "taskId": "Task_Act0",
2182 "key": "ParameterKey2",
2183 "value": "ParameterValue2"
2184 }
2185 ]
2186 }
2187 }
2188
2189 .. container:: paragraph
2190
2191 TaskParameters can be used to pass parameters from ApexConfig
2192 to the policy logic. In the config, these are optional.
2193 The list of task parameters provided in the config may be added
2194 to the tasks or existing task parameters in the task will be overriden.
2195
2196 .. container:: paragraph
2197
2198 If taskId is provided in ApexConfig for an entry, then that
2199 parameter is updated only for that particular task. Otherwise,
2200 the task parameter is added to all tasks.
2201
ramverma3b71c972019-07-10 11:25:37 +00002202Carrier Technologies
2203--------------------
2204
2205 .. container:: paragraph
2206
2207 Carrier technologies define how APEX receives (input) and
2208 sends (output) events. They can be used in any combination,
2209 using asynchronous or synchronous mode. There can also be
2210 any number of carrier technologies for the input (consume)
2211 and the output (produce) interface.
2212
2213 .. container:: paragraph
2214
2215 Supported *input* technologies are:
2216
2217 .. container:: ulist
2218
2219 - Standard input, read events from the standard input
2220 (console), not suitable for APEX background servers
2221
2222 - File input, read events from a file
2223
2224 - Kafka, read events from a Kafka system
2225
2226 - Websockets, read events from a Websocket
2227
2228 - JMS,
2229
2230 - REST (synchronous and asynchronous), additionally as
2231 client or server
2232
2233 - Event Requestor, allows reading of events that have been
2234 looped back into APEX
2235
2236 .. container:: paragraph
2237
2238 Supported *output* technologies are:
2239
2240 .. container:: ulist
2241
2242 - Standard output, write events to the standard output
2243 (console), not suitable for APEX background servers
2244
2245 - File output, write events to a file
2246
2247 - Kafka, write events to a Kafka system
2248
2249 - Websockets, write events to a Websocket
2250
2251 - JMS
2252
2253 - REST (synchronous and asynchronous), additionally as
2254 client or server
2255
2256 - Event Requestor, allows events to be looped back into
2257 APEX
2258
2259 .. container:: paragraph
2260
2261 New carrier technologies can be added as plugins to APEX or
2262 developed outside APEX and added to an APEX deployment.
2263
2264Standard IO
2265###########
2266
2267 .. container:: paragraph
2268
2269 Standard IO does not require a specific plugin, it is
2270 supported be default.
2271
2272Standard Input
2273==============
2274 .. container:: paragraph
2275
2276 APEX will take events from its standard input. This
2277 carrier is good for testing, but certainly not for a
2278 use case where APEX runs as a server. The
2279 configuration is as follows:
2280
2281 .. container:: listingblock
2282
2283 .. container:: content
2284
liamfallonb621de42020-08-21 12:59:26 +01002285::
ramverma3b71c972019-07-10 11:25:37 +00002286
2287 "carrierTechnologyParameters" : {
2288 "carrierTechnology" : "FILE", (1)
2289 "parameters" : {
2290 "standardIO" : true (2)
2291 }
2292 }
2293
2294 .. container:: colist arabic
2295
2296 +-------+---------------------------------------+
2297 | **1** | standard input is considered a file |
2298 +-------+---------------------------------------+
2299 | **2** | file descriptor set to standard input |
2300 +-------+---------------------------------------+
2301
2302Standard Output
2303===============
2304
2305 .. container:: paragraph
2306
2307 APEX will send events to its standard output. This
2308 carrier is good for testing, but certainly not for a
2309 use case where APEX runs as a server. The
2310 configuration is as follows:
2311
2312 .. container:: listingblock
2313
2314 .. container:: content
2315
ramverma760cce92019-07-11 12:57:49 +00002316 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002317
2318 "carrierTechnologyParameters" : {
2319 "carrierTechnology" : "FILE", (1)
2320 "parameters" : {
2321 "standardIO" : true (2)
2322 }
2323 }
2324
2325 .. container:: colist arabic
2326
2327 +-------+----------------------------------------+
2328 | **1** | standard output is considered a file |
2329 +-------+----------------------------------------+
2330 | **2** | file descriptor set to standard output |
2331 +-------+----------------------------------------+
2332
23332.7.2. File IO
2334##############
2335
2336 .. container:: paragraph
2337
2338 File IO does not require a specific plugin, it is
2339 supported be default.
2340
2341File Input
2342==========
2343
2344 .. container:: paragraph
2345
2346 APEX will take events from a file. The same file
2347 should not be used as an output. The configuration is
2348 as follows:
2349
2350 .. container:: listingblock
2351
2352 .. container:: content
2353
ramverma760cce92019-07-11 12:57:49 +00002354 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002355
2356 "carrierTechnologyParameters" : {
2357 "carrierTechnology" : "FILE", (1)
2358 "parameters" : {
2359 "fileName" : "examples/events/SampleDomain/EventsIn.xmlfile" (2)
2360 }
2361 }
2362
2363 .. container:: colist arabic
2364
2365 +-------+------------------------------------------+
2366 | **1** | set file input |
2367 +-------+------------------------------------------+
2368 | **2** | the name of the file to read events from |
2369 +-------+------------------------------------------+
2370
2371File Output
2372===========
2373 .. container:: paragraph
2374
2375 APEX will write events to a file. The same file should
2376 not be used as an input. The configuration is as
2377 follows:
2378
2379 .. container:: listingblock
2380
2381 .. container:: content
2382
ramverma760cce92019-07-11 12:57:49 +00002383 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002384
2385 "carrierTechnologyParameters" : {
2386 "carrierTechnology" : "FILE", (1)
2387 "parameters" : {
2388 "fileName" : "examples/events/SampleDomain/EventsOut.xmlfile" (2)
2389 }
2390 }
2391
2392 .. container:: colist arabic
2393
2394 +-------+-----------------------------------------+
2395 | **1** | set file output |
2396 +-------+-----------------------------------------+
2397 | **2** | the name of the file to write events to |
2398 +-------+-----------------------------------------+
2399
2400Event Requestor IO
2401##################
2402
2403 .. container:: paragraph
2404
2405 Event Requestor IO does not require a specific plugin, it
2406 is supported be default. It should only be used with the
2407 APEX event protocol.
2408
2409Event Requestor Input
2410=====================
2411
2412 .. container:: paragraph
2413
2414 APEX will take events from APEX.
2415
2416 .. container:: listingblock
2417
2418 .. container:: content
2419
ramverma760cce92019-07-11 12:57:49 +00002420 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002421
2422 "carrierTechnologyParameters" : {
2423 "carrierTechnology": "EVENT_REQUESTOR" (1)
2424 }
2425
2426 .. container:: colist arabic
2427
2428 +-------+---------------------------+
2429 | **1** | set event requestor input |
2430 +-------+---------------------------+
2431
2432Event Requestor Output
2433======================
2434
2435 .. container:: paragraph
2436
2437 APEX will write events to APEX.
2438
2439 .. container:: listingblock
2440
2441 .. container:: content
2442
ramverma760cce92019-07-11 12:57:49 +00002443 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002444
2445 "carrierTechnologyParameters" : {
2446 "carrierTechnology": "EVENT_REQUESTOR" (1)
2447 }
2448
2449Peering Event Requestors
2450========================
2451
2452 .. container:: paragraph
2453
2454 When using event requestors, they need to be peered.
2455 This means an event requestor output needs to be
2456 peered (associated) with an event requestor input. The
2457 following example shows the use of an event requestor
2458 with the APEX event protocol and the peering of output
2459 and input.
2460
2461 .. container:: listingblock
2462
2463 .. container:: content
2464
ramverma760cce92019-07-11 12:57:49 +00002465 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002466
2467 "eventInputParameters": {
2468 "EventRequestorConsumer": {
2469 "carrierTechnologyParameters": {
2470 "carrierTechnology": "EVENT_REQUESTOR" (1)
2471 },
2472 "eventProtocolParameters": {
2473 "eventProtocol": "APEX" (2)
2474 },
2475 "eventNameFilter": "InputEvent", (3)
2476 "requestorMode": true, (4)
2477 "requestorPeer": "EventRequestorProducer", (5)
2478 "requestorTimeout": 500 (6)
2479 }
2480 },
2481 "eventOutputParameters": {
2482 "EventRequestorProducer": {
2483 "carrierTechnologyParameters": {
2484 "carrierTechnology": "EVENT_REQUESTOR" (7)
2485 },
2486 "eventProtocolParameters": {
2487 "eventProtocol": "APEX" (8)
2488 },
2489 "eventNameFilter": "EventListEvent", (9)
2490 "requestorMode": true, (10)
2491 "requestorPeer": "EventRequestorConsumer", (11)
2492 "requestorTimeout": 500 (12)
2493 }
2494 }
2495
2496 .. container:: colist arabic
2497
2498 +-----------------------------------+-----------------------------------+
2499 | **1** | event requestor on a consumer |
2500 +-----------------------------------+-----------------------------------+
2501 | **2** | with APEX event protocol |
2502 +-----------------------------------+-----------------------------------+
2503 | **3** | optional filter (best to use a |
2504 | | filter to prevent unwanted events |
2505 | | on the consumer side) |
2506 +-----------------------------------+-----------------------------------+
2507 | **4** | activate requestor mode |
2508 +-----------------------------------+-----------------------------------+
2509 | **5** | the peer to the output (must |
2510 | | match the output carrier) |
2511 +-----------------------------------+-----------------------------------+
2512 | **6** | an optional timeout in |
2513 | | milliseconds |
2514 +-----------------------------------+-----------------------------------+
2515 | **7** | event requestor on a producer |
2516 +-----------------------------------+-----------------------------------+
2517 | **8** | with APEX event protocol |
2518 +-----------------------------------+-----------------------------------+
2519 | **9** | optional filter (best to use a |
2520 | | filter to prevent unwanted events |
2521 | | on the consumer side) |
2522 +-----------------------------------+-----------------------------------+
2523 | **10** | activate requestor mode |
2524 +-----------------------------------+-----------------------------------+
2525 | **11** | the peer to the output (must |
2526 | | match the input carrier) |
2527 +-----------------------------------+-----------------------------------+
2528 | **12** | an optional timeout in |
2529 | | milliseconds |
2530 +-----------------------------------+-----------------------------------+
2531
2532Kafka IO
2533########
2534
2535 .. container:: paragraph
2536
2537 Kafka IO is supported by the APEX Kafka plugin. The
2538 configurations below are examples. APEX will take any
2539 configuration inside the parameter object and forward it
2540 to Kafka. More information on Kafka specific
2541 configuration parameters can be found in the Kafka
2542 documentation:
2543
2544 .. container:: ulist
2545
2546 - `Kafka Consumer
2547 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html>`__
2548
2549 - `Kafka Producer
2550 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html>`__
2551
2552Kafka Input
2553===========
2554 .. container:: paragraph
2555
2556 APEX will receive events from the Apache Kafka
2557 messaging system. The input is uni-directional, an
2558 engine will only receive events from the input but not
2559 send any event to the input.
2560
2561 .. container:: listingblock
2562
2563 .. container:: content
2564
ramverma760cce92019-07-11 12:57:49 +00002565 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002566
2567 "carrierTechnologyParameters" : {
2568 "carrierTechnology" : "KAFKA", (1)
2569 "parameterClassName" :
2570 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2571 "parameters" : {
2572 "bootstrapServers" : "localhost:49092", (2)
2573 "groupId" : "apex-group-id", (3)
2574 "enableAutoCommit" : true, (4)
2575 "autoCommitTime" : 1000, (5)
2576 "sessionTimeout" : 30000, (6)
2577 "consumerPollTime" : 100, (7)
2578 "consumerTopicList" : ["apex-in-0", "apex-in-1"], (8)
2579 "keyDeserializer" :
2580 "org.apache.kafka.common.serialization.StringDeserializer", (9)
2581 "valueDeserializer" :
2582 "org.apache.kafka.common.serialization.StringDeserializer" (10)
2583 }
2584 }
2585
2586 .. container:: colist arabic
2587
2588 +--------+-------------------------------------+
2589 | **1** | set Kafka as carrier technology |
2590 +--------+-------------------------------------+
2591 | **2** | bootstrap server and port |
2592 +--------+-------------------------------------+
2593 | **3** | a group identifier |
2594 +--------+-------------------------------------+
2595 | **4** | flag for auto-commit |
2596 +--------+-------------------------------------+
2597 | **5** | auto-commit timeout in milliseconds |
2598 +--------+-------------------------------------+
2599 | **6** | session timeout in milliseconds |
2600 +--------+-------------------------------------+
2601 | **7** | consumer poll time in milliseconds |
2602 +--------+-------------------------------------+
2603 | **8** | consumer topic list |
2604 +--------+-------------------------------------+
2605 | **9** | key for the Kafka de-serializer |
2606 +--------+-------------------------------------+
2607 | **10** | value for the Kafka de-serializer |
2608 +--------+-------------------------------------+
2609
2610Kafka Output
2611============
2612 .. container:: paragraph
2613
2614 APEX will send events to the Apache Kafka messaging
2615 system. The output is uni-directional, an engine will
2616 send events to the output but not receive any event
2617 from the output.
2618
2619 .. container:: listingblock
2620
2621 .. container:: content
2622
ramverma760cce92019-07-11 12:57:49 +00002623 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002624
2625 "carrierTechnologyParameters" : {
2626 "carrierTechnology" : "KAFKA", (1)
2627 "parameterClassName" :
2628 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2629 "parameters" : {
2630 "bootstrapServers" : "localhost:49092", (2)
2631 "acks" : "all", (3)
2632 "retries" : 0, (4)
2633 "batchSize" : 16384, (5)
2634 "lingerTime" : 1, (6)
2635 "bufferMemory" : 33554432, (7)
2636 "producerTopic" : "apex-out", (8)
2637 "keySerializer" :
2638 "org.apache.kafka.common.serialization.StringSerializer", (9)
2639 "valueSerializer" :
2640 "org.apache.kafka.common.serialization.StringSerializer" (10)
2641 }
2642 }
2643
2644 .. container:: colist arabic
2645
2646 +--------+---------------------------------+
2647 | **1** | set Kafka as carrier technology |
2648 +--------+---------------------------------+
2649 | **2** | bootstrap server and port |
2650 +--------+---------------------------------+
2651 | **3** | acknowledgement strategy |
2652 +--------+---------------------------------+
2653 | **4** | number of retries |
2654 +--------+---------------------------------+
2655 | **5** | batch size |
2656 +--------+---------------------------------+
2657 | **6** | time to linger in milliseconds |
2658 +--------+---------------------------------+
2659 | **7** | buffer memory in byte |
2660 +--------+---------------------------------+
2661 | **8** | producer topic |
2662 +--------+---------------------------------+
2663 | **9** | key for the Kafka serializer |
2664 +--------+---------------------------------+
2665 | **10** | value for the Kafka serializer |
2666 +--------+---------------------------------+
2667
2668JMS IO
liamfallonb621de42020-08-21 12:59:26 +01002669######
ramverma3b71c972019-07-10 11:25:37 +00002670
2671 .. container:: paragraph
2672
2673 APEX supports the Java Messaging Service (JMS) as input
2674 as well as output. JMS IO is supported by the APEX JMS
2675 plugin. Input and output support an event encoding as
2676 text (JSON string) or object (serialized object). The
2677 input configuration is the same for both encodings, the
2678 output configuration differs.
2679
2680JMS Input
2681=========
2682 .. container:: paragraph
2683
2684 APEX will receive events from a JMS messaging system.
2685 The input is uni-directional, an engine will only
2686 receive events from the input but not send any event
2687 to the input.
2688
2689 .. container:: listingblock
2690
2691 .. container:: content
2692
ramverma760cce92019-07-11 12:57:49 +00002693 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002694
2695 "carrierTechnologyParameters" : {
2696 "carrierTechnology" : "JMS", (1)
2697 "parameterClassName" :
2698 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2699 "parameters" : { (2)
2700 "initialContextFactory" :
2701 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2702 "connectionFactory" : "ConnectionFactory", (4)
2703 "providerURL" : "remote://localhost:5445", (5)
2704 "securityPrincipal" : "guest", (6)
2705 "securityCredentials" : "IAmAGuest", (7)
2706 "consumerTopic" : "jms/topic/apexIn" (8)
2707 }
2708 }
2709
2710 .. container:: colist arabic
2711
2712 +-----------------------------------+-----------------------------------+
2713 | **1** | set JMS as carrier technology |
2714 +-----------------------------------+-----------------------------------+
2715 | **2** | set all JMS specific parameters |
2716 +-----------------------------------+-----------------------------------+
2717 | **3** | the context factory, in this case |
2718 | | from JBOSS (it requires the |
2719 | | dependency |
2720 | | org.jboss:jboss-remote-naming:2.0 |
2721 | | .4.Final |
2722 | | or a different version to be in |
2723 | | the directory ``$APEX_HOME/lib`` |
2724 | | or ``%APEX_HOME%\lib`` |
2725 +-----------------------------------+-----------------------------------+
2726 | **4** | a connection factory for the JMS |
2727 | | connection |
2728 +-----------------------------------+-----------------------------------+
2729 | **5** | URL with host and port of the JMS |
2730 | | provider |
2731 +-----------------------------------+-----------------------------------+
2732 | **6** | access credentials, user name |
2733 +-----------------------------------+-----------------------------------+
2734 | **7** | access credentials, user password |
2735 +-----------------------------------+-----------------------------------+
2736 | **8** | the JMS topic to listen to |
2737 +-----------------------------------+-----------------------------------+
2738
2739JMS Output with Text
2740====================
2741
2742 .. container:: paragraph
2743
2744 APEX engine send events to a JMS messaging system. The
2745 output is uni-directional, an engine will send events
2746 to the output but not receive any event from output.
2747
2748 .. container:: listingblock
2749
2750 .. container:: content
2751
ramverma760cce92019-07-11 12:57:49 +00002752 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002753
2754 "carrierTechnologyParameters" : {
2755 "carrierTechnology" : "JMS", (1)
2756 "parameterClassName" :
2757 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2758 "parameters" : { (2)
2759 "initialContextFactory" :
2760 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2761 "connectionFactory" : "ConnectionFactory", (4)
2762 "providerURL" : "remote://localhost:5445", (5)
2763 "securityPrincipal" : "guest", (6)
2764 "securityCredentials" : "IAmAGuest", (7)
2765 "producerTopic" : "jms/topic/apexOut", (8)
2766 "objectMessageSending": "false" (9)
2767 }
2768 }
2769
2770 .. container:: colist arabic
2771
2772 +-----------------------------------+-----------------------------------+
2773 | **1** | set JMS as carrier technology |
2774 +-----------------------------------+-----------------------------------+
2775 | **2** | set all JMS specific parameters |
2776 +-----------------------------------+-----------------------------------+
2777 | **3** | the context factory, in this case |
2778 | | from JBOSS (it requires the |
2779 | | dependency |
2780 | | org.jboss:jboss-remote-naming:2.0 |
2781 | | .4.Final |
2782 | | or a different version to be in |
2783 | | the directory ``$APEX_HOME/lib`` |
2784 | | or ``%APEX_HOME%\lib`` |
2785 +-----------------------------------+-----------------------------------+
2786 | **4** | a connection factory for the JMS |
2787 | | connection |
2788 +-----------------------------------+-----------------------------------+
2789 | **5** | URL with host and port of the JMS |
2790 | | provider |
2791 +-----------------------------------+-----------------------------------+
2792 | **6** | access credentials, user name |
2793 +-----------------------------------+-----------------------------------+
2794 | **7** | access credentials, user password |
2795 +-----------------------------------+-----------------------------------+
2796 | **8** | the JMS topic to write to |
2797 +-----------------------------------+-----------------------------------+
2798 | **9** | set object messaging to ``false`` |
2799 | | means it sends JSON text |
2800 +-----------------------------------+-----------------------------------+
2801
2802JMS Output with Object
2803======================
2804
2805 .. container:: paragraph
2806
2807 To configure APEX for JMS objects on the output
2808 interface use the same configuration as above (for
2809 output). Simply change the ``objectMessageSending``
2810 parameter to ``true``.
2811
2812Websocket (WS) IO
liamfallonb621de42020-08-21 12:59:26 +01002813#################
ramverma3b71c972019-07-10 11:25:37 +00002814
2815 .. container:: paragraph
2816
2817 APEX supports the Websockets as input as well as output.
2818 WS IO is supported by the APEX Websocket plugin. This
2819 carrier technology does only support uni-directional
2820 communication. APEX will not send events to a Websocket
2821 input and any event sent to a Websocket output will
2822 result in an error log.
2823
2824 .. container:: paragraph
2825
2826 The input can be configured as client (APEX connects to
2827 an existing Websocket server) or server (APEX starts a
2828 Websocket server). The same applies to the output. Input
2829 and output can both use a client or a server
2830 configuration, or separate configurations (input as
2831 client and output as server, input as server and output
2832 as client). Each configuration should use its own
2833 dedicated port to avoid any communication loops. The
2834 configuration of a Websocket client is the same for input
2835 and output. The configuration of a Websocket server is
2836 the same for input and output.
2837
2838Websocket Client
2839================
2840
2841 .. container:: paragraph
2842
2843 APEX will connect to a given Websocket server. As
2844 input, it will receive events from the server but not
2845 send any events. As output, it will send events to the
2846 server and any event received from the server will
2847 result in an error log.
2848
2849 .. container:: listingblock
2850
2851 .. container:: content
2852
ramverma760cce92019-07-11 12:57:49 +00002853 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002854
2855 "carrierTechnologyParameters" : {
2856 "carrierTechnology" : "WEBSOCKET", (1)
2857 "parameterClassName" :
2858 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2859 "parameters" : {
2860 "host" : "localhost", (2)
2861 "port" : 42451 (3)
2862 }
2863 }
2864
2865 .. container:: colist arabic
2866
2867 +-------+------------------------------------------------------+
2868 | **1** | set Websocket as carrier technology |
2869 +-------+------------------------------------------------------+
2870 | **2** | the host name on which a Websocket server is running |
2871 +-------+------------------------------------------------------+
2872 | **3** | the port of that Websocket server |
2873 +-------+------------------------------------------------------+
2874
2875Websocket Server
2876================
2877
2878 .. container:: paragraph
2879
2880 APEX will start a Websocket server, which will accept
2881 any Websocket clients to connect. As input, it will
2882 receive events from the server but not send any
2883 events. As output, it will send events to the server
2884 and any event received from the server will result in
2885 an error log.
2886
2887 .. container:: listingblock
2888
2889 .. container:: content
2890
ramverma760cce92019-07-11 12:57:49 +00002891 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002892
2893 "carrierTechnologyParameters" : {
2894 "carrierTechnology" : "WEBSOCKET", (1)
2895 "parameterClassName" :
2896 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2897 "parameters" : {
2898 "wsClient" : false, (2)
2899 "port" : 42450 (3)
2900 }
2901 }
2902
2903 .. container:: colist arabic
2904
2905 +-------+------------------------------------------------------------+
2906 | **1** | set Websocket as carrier technology |
2907 +-------+------------------------------------------------------------+
2908 | **2** | disable client, so that APEX will start a Websocket server |
2909 +-------+------------------------------------------------------------+
2910 | **3** | the port for the Websocket server APEX will start |
2911 +-------+------------------------------------------------------------+
2912
2913REST Client IO
2914##############
2915
2916 .. container:: paragraph
2917
2918 APEX can act as REST client on the input as well as on
2919 the output interface. The media type is
a.sreekumarcc0e9172020-03-16 13:36:45 +00002920 ``application/json``, so this plugin only works with
ramverma3b71c972019-07-10 11:25:37 +00002921 the JSON Event protocol.
2922
2923REST Client Input
2924=================
2925
2926 .. container:: paragraph
2927
2928 APEX will connect to a given URL to receive events,
2929 but not send any events. The server is polled, i.e.
2930 APEX will do an HTTP GET, take the result, and then do
2931 the next GET. Any required timing needs to be handled
2932 by the server configured via the URL. For instance,
2933 the server could support a wait timeout via the URL as
2934 ``?timeout=100ms``.
Henry.Sun2941bc02019-07-22 08:32:32 +00002935 The httpCodeFilter is used for filtering the status
2936 code, and it can be configured as a regular expression
2937 string. The default httpCodeFilter is "[2][0-9][0-9]"
2938 - for successful response codes.
2939 The response with HTTP status code that matches the
2940 given regular expression is forwarded to the task,
2941 otherwise it is logged as a failure.
ramverma3b71c972019-07-10 11:25:37 +00002942
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" : "RESTCLIENT", (1)
2951 "parameterClassName" :
2952 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
2953 "parameters" : {
2954 "url" : "http://example.org:8080/triggers/events", (2)
liamfallon75e2bbf2020-07-06 11:41:38 +01002955 "httpMethod": "GET", (3)
2956 "httpCodeFilter" : "[2][0-9][0-9]", (4)
2957 "httpHeaders" : [ (5)
2958 ["Keep-Alive", "300"],
2959 ["Cache-Control", "no-cache"]
2960 ]
ramverma3b71c972019-07-10 11:25:37 +00002961 }
2962 }
2963
2964 .. container:: colist arabic
2965
Henry.Sun2941bc02019-07-22 08:32:32 +00002966 +-------+--------------------------------------------------+
2967 | **1** | set REST client as carrier technology |
2968 +-------+--------------------------------------------------+
2969 | **2** | the URL of the HTTP server for events |
2970 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01002971 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
2972 | | optional, defaults to GET |
2973 +-------+--------------------------------------------------+
2974 | **4** | use HTTP CODE FILTER for filtering status code, |
2975 | | optional, defaults to [2][0-9][0-9] |
2976 +-------+--------------------------------------------------+
2977 | **5** | HTTP headers to use on the REST request, |
2978 | | optional |
Henry.Sun2941bc02019-07-22 08:32:32 +00002979 +-------+--------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00002980
2981REST Client Output
2982==================
2983
2984 .. container:: paragraph
2985
2986 APEX will connect to a given URL to send events, but
2987 not receive any events. The default HTTP operation is
2988 POST (no configuration required). To change it to PUT
2989 simply add the configuration parameter (as shown in
2990 the example below).
ning.xi8bc537d2019-07-18 07:50:10 +00002991 The URL can be configured statically or tagged
2992 as ``?example.{site}.org:8080/{trig}/events``,
2993 all tags such as ``site`` and ``trig`` in the URL
Henry.Sun2941bc02019-07-22 08:32:32 +00002994 need to be set in the properties object available to
2995 the tasks. In addition, the keys should exactly match
2996 with the tags defined in url. The scope of the properties
2997 object is per HTTP call. Hence, key/value pairs set
2998 in the properties object by task are only available
2999 for that specific HTTP call.
ramverma3b71c972019-07-10 11:25:37 +00003000
3001 .. container:: listingblock
3002
3003 .. container:: content
3004
ramverma760cce92019-07-11 12:57:49 +00003005 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003006
3007 "carrierTechnologyParameters" : {
3008 "carrierTechnology" : "RESTCLIENT", (1)
3009 "parameterClassName" :
3010 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3011 "parameters" : {
3012 "url" : "http://example.com:8888/actions/events", (2)
ning.xi8bc537d2019-07-18 07:50:10 +00003013 "url" : "http://example.{site}.com:8888/{trig}/events", (2')
liamfallon75e2bbf2020-07-06 11:41:38 +01003014 "httpMethod" : "PUT". (3)
3015 "httpHeaders" : [ (4)
3016 ["Keep-Alive", "300"],
3017 ["Cache-Control", "no-cache"]
3018 ] }
ramverma3b71c972019-07-10 11:25:37 +00003019 }
3020
3021 .. container:: colist arabic
3022
3023 +-------+--------------------------------------------------+
3024 | **1** | set REST client as carrier technology |
3025 +-------+--------------------------------------------------+
ning.xi8bc537d2019-07-18 07:50:10 +00003026 | **2** | the static URL of the HTTP server for events |
3027 +-------+--------------------------------------------------+
3028 | **2'**| the tagged URL of the HTTP server for events |
ramverma3b71c972019-07-10 11:25:37 +00003029 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003030 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3031 | | optional, defaults to POST |
3032 +-------+--------------------------------------------------+
3033 | **4** | HTTP headers to use on the REST request, |
3034 | | optional |
ramverma3b71c972019-07-10 11:25:37 +00003035 +-------+--------------------------------------------------+
3036
3037REST Server IO
3038##############
3039
3040 .. container:: paragraph
3041
3042 APEX supports a REST server for input and output.
3043
3044 .. container:: paragraph
3045
3046 The REST server plugin always uses a synchronous mode. A
3047 client does a HTTP GET on the APEX REST server with the
3048 input event and receives the generated output event in
3049 the server reply. This means that for the REST server
3050 there has to always to be an input with an associated
3051 output. Input or output only are not permitted.
3052
3053 .. container:: paragraph
3054
3055 The plugin will start a Grizzly server as REST server for
3056 a normal APEX engine. If the APEX engine is executed as a
3057 servlet, for instance inside Tomcat, then Tomcat will be
3058 used as REST server (this case requires configuration on
3059 Tomcat as well).
3060
3061 .. container:: paragraph
3062
3063 Some configuration restrictions apply for all scenarios:
3064
3065 .. container:: ulist
3066
3067 - Minimum port: 1024
3068
3069 - Maximum port: 65535
3070
3071 - The media type is ``application/json``, so this plugin
a.sreekumarcc0e9172020-03-16 13:36:45 +00003072 only works with the JSON Event protocol.
ramverma3b71c972019-07-10 11:25:37 +00003073
3074 .. container:: paragraph
3075
3076 The URL the client calls is created using
3077
3078 .. container:: ulist
3079
3080 - the configured host and port, e.g.
3081 ``http://localhost:12345``
3082
3083 - the standard path, e.g. ``/apex/``
3084
3085 - the name of the input/output, e.g. ``FirstConsumer/``
3086
3087 - the input or output name, e.g. ``EventIn``.
3088
3089 .. container:: paragraph
3090
3091 The examples above lead to the URL
3092 ``http://localhost:12345/apex/FirstConsumer/EventIn``.
3093
3094 .. container:: paragraph
3095
3096 A client can also get status information of the REST
3097 server using ``/Status``, e.g.
3098 ``http://localhost:12345/apex/FirstConsumer/Status``.
3099
3100REST Server Stand-alone
3101=======================
3102
3103 .. container:: paragraph
3104
3105 We need to configure a REST server input and a REST
3106 server output. Input and output are associated with
3107 each other via there name.
3108
3109 .. container:: paragraph
3110
3111 Timeouts for REST calls need to be set carefully. If
3112 they are too short, the call might timeout before a
3113 policy finished creating an event.
3114
3115 .. container:: paragraph
3116
3117 The following example configures the input named as
3118 ``MyConsumer`` and associates an output named
3119 ``MyProducer`` with it.
3120
3121 .. container:: listingblock
3122
3123 .. container:: content
3124
ramverma760cce92019-07-11 12:57:49 +00003125 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003126
3127 "eventInputParameters": {
3128 "MyConsumer": {
3129 "carrierTechnologyParameters" : {
3130 "carrierTechnology" : "RESTSERVER", (1)
3131 "parameterClassName" :
3132 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters",
3133 "parameters" : {
3134 "standalone" : true, (2)
3135 "host" : "localhost", (3)
3136 "port" : 12345 (4)
3137 }
3138 },
3139 "eventProtocolParameters":{
3140 "eventProtocol" : "JSON" (5)
3141 },
3142 "synchronousMode" : true, (6)
3143 "synchronousPeer" : "MyProducer", (7)
3144 "synchronousTimeout" : 500 (8)
3145 }
3146 }
3147
3148 .. container:: colist arabic
3149
3150 +-------+---------------------------------------+
3151 | **1** | set REST server as carrier technology |
3152 +-------+---------------------------------------+
3153 | **2** | set the server as stand-alone |
3154 +-------+---------------------------------------+
3155 | **3** | set the server host |
3156 +-------+---------------------------------------+
3157 | **4** | set the server listen port |
3158 +-------+---------------------------------------+
3159 | **5** | use JSON event protocol |
3160 +-------+---------------------------------------+
3161 | **6** | activate synchronous mode |
3162 +-------+---------------------------------------+
3163 | **7** | associate an output ``MyProducer`` |
3164 +-------+---------------------------------------+
3165 | **8** | set a timeout of 500 milliseconds |
3166 +-------+---------------------------------------+
3167
3168 .. container:: paragraph
3169
3170 The following example configures the output named as
3171 ``MyProducer`` and associates the input ``MyConsumer``
3172 with it. Note that for the output there are no more
3173 paramters (such as host or port), since they are
3174 already configured in the associated input
3175
3176 .. container:: listingblock
3177
3178 .. container:: content
3179
ramverma760cce92019-07-11 12:57:49 +00003180 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003181
3182 "eventOutputParameters": {
3183 "MyProducer": {
3184 "carrierTechnologyParameters":{
3185 "carrierTechnology" : "RESTSERVER",
3186 "parameterClassName" :
3187 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters"
3188 },
3189 "eventProtocolParameters":{
3190 "eventProtocol" : "JSON"
3191 },
3192 "synchronousMode" : true,
3193 "synchronousPeer" : "MyConsumer",
3194 "synchronousTimeout" : 500
3195 }
3196 }
3197
3198REST Server Stand-alone, multi input
3199====================================
3200
3201 .. container:: paragraph
3202
3203 Any number of input/output pairs for REST servers can
3204 be configured. For instance, we can configure an input
3205 ``FirstConsumer`` with output ``FirstProducer`` and an
3206 input ``SecondConsumer`` with output
3207 ``SecondProducer``. Important is that there is always
3208 one pair of input/output.
3209
3210REST Server Stand-alone in Servlet
3211==================================
3212
3213 .. container:: paragraph
3214
3215 If APEX is executed as a servlet, e.g. inside Tomcat,
3216 the configuration becomes easier since the plugin can
3217 now use Tomcat as the REST server. In this scenario,
3218 there are not parameters (port, host, etc.) and the
3219 key ``standalone`` must not be used (or set to false).
3220
3221 .. container:: paragraph
3222
3223 For the Tomcat configuration, we need to add the REST
3224 server plugin, e.g.
3225
3226 .. container:: listingblock
3227
3228 .. container:: content
3229
ramverma760cce92019-07-11 12:57:49 +00003230 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003231
3232 <servlet>
3233 ...
3234 <init-param>
3235 ...
3236 <param-value>org.onap.policy.apex.plugins.event.carrier.restserver</param-value>
3237 </init-param>
3238 ...
3239 </servlet>
3240
3241REST Requestor IO
liamfallonb621de42020-08-21 12:59:26 +01003242#################
ramverma3b71c972019-07-10 11:25:37 +00003243
3244 .. container:: paragraph
3245
3246 APEX can act as REST requestor on the input as well as on
3247 the output interface. The media type is
a.sreekumarcc0e9172020-03-16 13:36:45 +00003248 ``application/json``, so this plugin only works with
liamfallon75e2bbf2020-07-06 11:41:38 +01003249 the JSON Event protocol. This plugin allows APEX to send REST requests
3250 and to receive the reply of that request without tying up APEX resources
3251 while the request is being processed. The REST Requestor pairs a REST
3252 requestor producer and consumer together to handle the REST request
3253 and response. The REST request is created from an APEX output event
3254 and the REST response is input into APEX as a new input event.
ramverma3b71c972019-07-10 11:25:37 +00003255
liamfallon75e2bbf2020-07-06 11:41:38 +01003256REST Requestor Output (REST Request Producer)
3257=============================================
ramverma3b71c972019-07-10 11:25:37 +00003258
3259 .. container:: paragraph
3260
liamfallon75e2bbf2020-07-06 11:41:38 +01003261 APEX sends a REST request when events are output by APEX, the REST
3262 request configuration is specified on the REST Request Consumer (see
3263 below).
3264
3265 .. container:: listingblock
3266
3267 .. container:: content
3268
3269 .. code::
3270
3271 "carrierTechnologyParameters": {
3272 "carrierTechnology": "RESTREQUESTOR", (1)
3273 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
3274 },
3275
3276 .. container:: colist arabic
3277
3278 +-------+------------------------------------------+
3279 | **1** | set REST requestor as carrier technology |
3280 +-------+------------------------------------------+
3281
3282 .. container:: paragraph
3283
3284 The settings below are required on the producer to
3285 define the event that triggers the REST request and
3286 to specify the peered consumer configuration for the
3287 REST request, for example:
3288
3289 .. container:: listingblock
3290
3291 .. container:: content
3292
3293 .. code::
3294
3295 "eventNameFilter": "GuardRequestEvent", (1)
3296 "requestorMode": true, (2)
3297 "requestorPeer": "GuardRequestorConsumer", (3)
3298 "requestorTimeout": 500 (4)
3299
3300 .. container:: colist arabic
3301
3302 +-------+-------------------------------------------+
3303 | **1** | a filter on the event |
3304 +-------+-------------------------------------------+
3305 | **2** | requestor mode must be set to *true* |
3306 +-------+-------------------------------------------+
3307 | **3** | the peered consumer for REST requests, |
3308 | | that consumer specifies the full |
3309 | | configuration for REST requests |
3310 +-------+-------------------------------------------+
3311 | **4** | the request timeout in milliseconds, |
3312 | | overridden by timeout on consumer if that |
3313 | | is set, optional defaults to 500 |
3314 | | millisconds |
3315 +-------+-------------------------------------------+
3316
3317REST Requestor Input (REST Request Consumer)
3318============================================
3319
3320 .. container:: paragraph
3321
3322 APEX will connect to a given URL to issue a REST request and
3323 wait for a REST response.
ning.xi8bc537d2019-07-18 07:50:10 +00003324 The URL can be configured statically or tagged
3325 as ``?example.{site}.org:8080/{trig}/events``,
3326 all tags such as ``site`` and ``trig`` in the URL
Henry.Sun2941bc02019-07-22 08:32:32 +00003327 need to be set in the properties object available to
3328 the tasks. In addition, the keys should exactly match
3329 with the tags defined in url. The scope of the properties
3330 object is per HTTP call. Hence, key/value pairs set
3331 in the properties object by task are only available
3332 for that specific HTTP call.
3333 The httpCodeFilter is used for filtering the status
3334 code, and it can be configured as a regular expression
3335 string. The default httpCodeFilter is "[2][0-9][0-9]"
3336 - for successful response codes.
3337 The response with HTTP status code that matches the
3338 given regular expression is forwarded to the task,
3339 otherwise it is logged as a failure.
ramverma3b71c972019-07-10 11:25:37 +00003340
3341 .. container:: listingblock
3342
3343 .. container:: content
3344
ramverma760cce92019-07-11 12:57:49 +00003345 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003346
3347 "carrierTechnologyParameters": {
3348 "carrierTechnology": "RESTREQUESTOR", (1)
3349 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
3350 "parameters": {
3351 "url": "http://localhost:54321/some/path/to/rest/resource", (2)
ning.xi8bc537d2019-07-18 07:50:10 +00003352 "url": "http://localhost:54321/{site}/path/to/rest/{resValue}", (2')
ramverma3b71c972019-07-10 11:25:37 +00003353 "httpMethod": "POST", (3)
liamfallon75e2bbf2020-07-06 11:41:38 +01003354 "requestorMode": true, (4)
3355 "requestorPeer": "GuardRequestorProducer", (5)
3356 "restRequestTimeout": 2000, (6)
3357 "httpCodeFilter" : "[2][0-9][0-9]" (7)
3358 "httpHeaders" : [ (8)
3359 ["Keep-Alive", "300"],
3360 ["Cache-Control", "no-cache"]
3361 ] }
ramverma3b71c972019-07-10 11:25:37 +00003362 },
3363
3364 .. container:: colist arabic
3365
3366 +-------+--------------------------------------------------+
3367 | **1** | set REST requestor as carrier technology |
3368 +-------+--------------------------------------------------+
ning.xi8bc537d2019-07-18 07:50:10 +00003369 | **2** | the static URL of the HTTP server for events |
3370 +-------+--------------------------------------------------+
3371 | **2'**| the tagged URL of the HTTP server for events |
ramverma3b71c972019-07-10 11:25:37 +00003372 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003373 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3374 | | optional, defaults to GET |
ramverma3b71c972019-07-10 11:25:37 +00003375 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003376 | **4** | requestor mode must be set to *true* |
ramverma3b71c972019-07-10 11:25:37 +00003377 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003378 | **5** | the peered producer for REST requests, that |
3379 | | producer specifies the APEX output event that |
3380 | | triggers the REST request |
3381 +-------+--------------------------------------------------+
3382 | **6** | request timeout in milliseconds, overrides any |
3383 | | value set in the REST Requestor Producer, |
3384 | | optional, defaults to 500 millisconds |
3385 +-------+--------------------------------------------------+
3386 | **7** | use HTTP CODE FILTER for filtering status code |
3387 | | optional, defaults to [2][0-9][0-9] |
3388 +-------+--------------------------------------------------+
3389 | **8** | HTTP headers to use on the REST request, |
3390 | | optional |
Henry.Sun2941bc02019-07-22 08:32:32 +00003391 +-------+--------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003392
3393 .. container:: paragraph
3394
liamfallon75e2bbf2020-07-06 11:41:38 +01003395 Further settings may be required on the consumer to
3396 define the input event that is produced and forwarded into
3397 APEX, for example:
ramverma3b71c972019-07-10 11:25:37 +00003398
3399 .. container:: listingblock
3400
3401 .. container:: content
3402
ramverma760cce92019-07-11 12:57:49 +00003403 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003404
3405 "eventName": "GuardResponseEvent", (1)
liamfallon75e2bbf2020-07-06 11:41:38 +01003406 "eventNameFilter": "GuardResponseEvent" (2)
ramverma3b71c972019-07-10 11:25:37 +00003407
3408 .. container:: colist arabic
3409
3410 +-------+---------------------------+
3411 | **1** | the event name |
3412 +-------+---------------------------+
3413 | **2** | a filter on the event |
3414 +-------+---------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003415
a.sreekumarcc0e9172020-03-16 13:36:45 +00003416gRPC IO
3417#######
3418
3419 .. container:: paragraph
3420
3421 APEX can send requests over gRPC at the output side, and get back
3422 response at the input side. This can be used to send requests to CDS
3423 over gRPC. The media type is ``application/json``, so this plugin
3424 only works with the JSON Event protocol.
3425
3426gRPC Output
3427===========
3428
3429 .. container:: paragraph
3430
3431 APEX will connect to a given host to send a request over
3432 gRPC.
3433
3434 .. container:: listingblock
3435
3436 .. container:: content
3437
3438 .. code::
3439
3440 "carrierTechnologyParameters": {
3441 "carrierTechnology": "GRPC", (1)
3442 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
3443 "parameters": {
3444 "host": "cds-blueprints-processor-grpc", (2)
3445 "port": 9111, (2')
3446 "username": "ccsdkapps", (3)
3447 "password": ccsdkapps, (4)
3448 "timeout" : 10 (5)
3449 }
3450 },
3451
3452 .. container:: colist arabic
3453
3454 +-------+--------------------------------------------------+
3455 | **1** | set GRPC as carrier technology |
3456 +-------+--------------------------------------------------+
3457 | **2** | the host to which request is sent |
3458 +-------+--------------------------------------------------+
3459 | **2'**| the value for port |
3460 +-------+--------------------------------------------------+
3461 | **3** | username required to initiate connection |
3462 +-------+--------------------------------------------------+
3463 | **4** | password required to initiate connection |
3464 +-------+--------------------------------------------------+
3465 | **5** | the timeout value for completing the request |
3466 +-------+--------------------------------------------------+
3467
3468 .. container:: paragraph
3469
3470 Further settings are required on the producer to
3471 define the event that is requested, for example:
3472
3473 .. container:: listingblock
3474
3475 .. container:: content
3476
3477 .. code::
3478
3479 "eventName": "GRPCRequestEvent", (1)
3480 "eventNameFilter": "GRPCRequestEvent", (2)
3481 "requestorMode": true, (3)
3482 "requestorPeer": "GRPCRequestConsumer", (4)
3483 "requestorTimeout": 500 (5)
3484
3485 .. container:: colist arabic
3486
3487 +-------+---------------------------+
3488 | **1** | the event name |
3489 +-------+---------------------------+
3490 | **2** | a filter on the event |
3491 +-------+---------------------------+
3492 | **3** | the mode of the requestor |
3493 +-------+---------------------------+
3494 | **4** | a peer for the requestor |
3495 +-------+---------------------------+
3496 | **5** | a general request timeout |
3497 +-------+---------------------------+
3498
3499gRPC Input
3500==========
3501
3502 .. container:: paragraph
3503
3504 APEX will connect to the host specified in the producer
3505 side, anad take in response back at the consumer side.
3506
3507 .. container:: listingblock
3508
3509 .. container:: content
3510
3511 .. code::
3512
3513 "carrierTechnologyParameters": {
3514 "carrierTechnology": "GRPC", (1)
3515 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
3516 },
3517
3518 .. container:: colist arabic
3519
3520 +-------+------------------------------------------+
3521 | **1** | set GRPC as carrier technology |
3522 +-------+------------------------------------------+
3523
3524 .. container:: paragraph
3525
3526 Further settings are required on the consumer to
3527 define the event that is requested, for example:
3528
3529 .. container:: listingblock
3530
3531 .. container:: content
3532
3533 .. code::
3534
3535 "eventNameFilter": "GRPCResponseEvent", (1)
3536 "requestorMode": true, (2)
3537 "requestorPeer": "GRPCRequestProducer", (3)
3538 "requestorTimeout": 500 (4)
3539
3540 .. container:: colist arabic
3541
3542 +-------+---------------------------+
3543 | **1** | a filter on the event |
3544 +-------+---------------------------+
3545 | **2** | the mode of the requestor |
3546 +-------+---------------------------+
3547 | **3** | a peer for the requestor |
3548 +-------+---------------------------+
3549 | **4** | a general request timeout |
3550 +-------+---------------------------+
3551
ramverma3b71c972019-07-10 11:25:37 +00003552Event Protocols, Format and Encoding
3553------------------------------------
3554
3555 .. container:: paragraph
3556
3557 Event protocols define what event formats APEX can receive
3558 (input) and should send (output). They can be used in any
3559 combination for input and output, unless further restricted
3560 by a carrier technology plugin (for instance for JMS
3561 output). There can only be 1 event protocol per event
3562 plugin.
3563
3564 .. container:: paragraph
3565
3566 Supported *input* event protocols are:
3567
3568 .. container:: ulist
3569
3570 - JSON, the event as a JSON string
3571
3572 - APEX, an APEX event
3573
3574 - JMS object, the event as a JMS object,
3575
3576 - JMS text, the event as a JMS text,
3577
3578 - XML, the event as an XML string,
3579
3580 - YAML, the event as YAML text
3581
3582 .. container:: paragraph
3583
3584 Supported *output* event protocols are:
3585
3586 .. container:: ulist
3587
3588 - JSON, the event as a JSON string
3589
3590 - APEX, an APEX event
3591
3592 - JMS object, the event as a JMS object,
3593
3594 - JMS text, the event as a JMS text,
3595
3596 - XML, the event as an XML string,
3597
3598 - YAML, the event as YAML text
3599
3600 .. container:: paragraph
3601
3602 New event protocols can be added as plugins to APEX or
3603 developed outside APEX and added to an APEX deployment.
3604
3605JSON Event
3606##########
3607
3608 .. container:: paragraph
3609
3610 The event protocol for JSON encoding does not require a
3611 specific plugin, it is supported by default. Furthermore,
3612 there is no difference in the configuration for the input
3613 and output interface.
3614
3615 .. container:: paragraph
3616
3617 For an input, APEX requires a well-formed JSON string.
3618 Well-formed here means according to the definitions of a
3619 policy. Any JSON string that is not defined as a trigger
3620 event (consume) will not be consumed (errors will be
3621 thrown). For output JSON events, APEX will always produce
3622 valid JSON strings according to the definition in the
3623 policy model.
3624
3625 .. container:: paragraph
3626
3627 The following JSON shows the configuration.
3628
3629 .. container:: listingblock
3630
3631 .. container:: content
3632
ramverma760cce92019-07-11 12:57:49 +00003633 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003634
3635 "eventProtocolParameters":{
3636 "eventProtocol" : "JSON"
3637 }
3638
3639 .. container:: paragraph
3640
3641 For JSON events, there are a few more optional
3642 parameters, which allow to define a mapping for standard
3643 event fields. An APEX event must have the fields
3644 ``name``, ``version``, ``source``, and ``target``
3645 defined. Sometimes it is not possible to configure a
3646 trigger or actioning system to use those fields. However,
3647 they might be in an event generated outside APEX (or used
3648 outside APEX) just with different names. To configure
3649 APEX to map between the different event names, simply add
3650 the following parameters to a JSON event:
3651
3652 .. container:: listingblock
3653
3654 .. container:: content
3655
ramverma760cce92019-07-11 12:57:49 +00003656 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003657
3658 "eventProtocolParameters":{
3659 "eventProtocol" : "JSON",
3660 "nameAlias" : "policyName", (1)
3661 "versionAlias" : "policyVersion", (2)
3662 "sourceAlias" : "from", (3)
3663 "targetAlias" : "to", (4)
3664 "nameSpaceAlias": "my.name.space" (5)
3665 }
3666
3667 .. container:: colist arabic
3668
3669 +-----------------------------------+-----------------------------------+
3670 | **1** | mapping for the ``name`` field, |
3671 | | here from a field called |
3672 | | ``policyName`` |
3673 +-----------------------------------+-----------------------------------+
3674 | **2** | mapping for the ``version`` |
3675 | | field, here from a field called |
3676 | | ``policyVersion`` |
3677 +-----------------------------------+-----------------------------------+
3678 | **3** | mapping for the ``source`` field, |
3679 | | here from a field called ``from`` |
3680 | | (only for an input event) |
3681 +-----------------------------------+-----------------------------------+
3682 | **4** | mapping for the ``target`` field, |
3683 | | here from a field called ``to`` |
3684 | | (only for an output event) |
3685 +-----------------------------------+-----------------------------------+
3686 | **5** | mapping for the ``nameSpace`` |
3687 | | field, here from a field called |
3688 | | ``my.name.space`` |
3689 +-----------------------------------+-----------------------------------+
3690
3691APEX Event
3692##########
3693 .. container:: paragraph
3694
3695 The event protocol for APEX events does not require a
3696 specific plugin, it is supported by default. Furthermore,
3697 there is no difference in the configuration for the input
3698 and output interface.
3699
3700 .. container:: paragraph
3701
3702 For input and output APEX uses APEX events.
3703
3704 .. container:: paragraph
3705
3706 The following JSON shows the configuration.
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" : "APEX"
3716 }
3717
3718JMS Event
3719#########
3720
3721 .. container:: paragraph
3722
3723 The event protocol for JMS is provided by the APEX JMS
3724 plugin. The plugin supports encoding as JSON text or as
3725 object. There is no difference in the configuration for
3726 the input and output interface.
3727
3728JMS Text
3729========
3730 .. container:: paragraph
3731
3732 If used as input, APEX will take a JMS message and
3733 extract a JSON string, then proceed as if a JSON event
3734 was received. If used as output, APEX will take the
3735 event produced by a policy, create a JSON string, and
3736 then wrap it into a JMS message.
3737
3738 .. container:: paragraph
3739
3740 The configuration for JMS text is as follows:
3741
3742 .. container:: listingblock
3743
3744 .. container:: content
3745
ramverma760cce92019-07-11 12:57:49 +00003746 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003747
3748 "eventProtocolParameters":{
3749 "eventProtocol" : "JMSTEXT",
3750 "parameterClassName" :
3751 "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters"
3752 }
3753
3754JMS Object
3755==========
3756 .. container:: paragraph
3757
3758 If used as input, APEX will will take a JMS message,
3759 extract a Java Bean from the ``ObjectMessage``
3760 message, construct an APEX event and put the bean on
3761 the APEX event as a parameter. If used as output, APEX
3762 will take the event produced by a policy, create a
3763 Java Bean and send it as a JMS message.
3764
3765 .. container:: paragraph
3766
3767 The configuration for JMS object is as follows:
3768
3769 .. container:: listingblock
3770
3771 .. container:: content
3772
ramverma760cce92019-07-11 12:57:49 +00003773 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003774
3775 "eventProtocolParameters":{
3776 "eventProtocol" : "JMSOBJECT",
3777 "parameterClassName" :
3778 "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters"
3779 }
3780
3781YAML Event
3782##########
3783
3784 .. container:: paragraph
3785
3786 The event protocol for YAML is provided by the APEX YAML
3787 plugin. There is no difference in the configuration for
3788 the input and output interface.
3789
3790 .. container:: paragraph
3791
3792 If used as input, APEX will consume events as YAML and
3793 map them to policy trigger events. Not well-formed YAML
3794 and not understood trigger events will be rejected. If
3795 used as output, APEX produce YAML encoded events from the
3796 event a policy produces. Those events will always be
3797 well-formed according to the definition in the policy
3798 model.
3799
3800 .. container:: paragraph
3801
3802 The following code shows the configuration.
3803
3804 .. container:: listingblock
3805
3806 .. container:: content
3807
ramverma760cce92019-07-11 12:57:49 +00003808 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003809
3810 "eventProtocolParameters":{
3811 "eventProtocol" : "XML",
3812 "parameterClassName" :
3813 "org.onap.policy.apex.plugins.event.protocol.yaml.YamlEventProtocolParameters"
3814 }
3815
3816XML Event
3817#########
3818 .. container:: paragraph
3819
3820 The event protocol for XML is provided by the APEX XML
3821 plugin. There is no difference in the configuration for
3822 the input and output interface.
3823
3824 .. container:: paragraph
3825
3826 If used as input, APEX will consume events as XML and map
3827 them to policy trigger events. Not well-formed XML and
3828 not understood trigger events will be rejected. If used
3829 as output, APEX produce XML encoded events from the event
3830 a policy produces. Those events will always be
3831 well-formed according to the definition in the policy
3832 model.
3833
3834 .. container:: paragraph
3835
3836 The following code shows the configuration.
3837
3838 .. container:: listingblock
3839
3840 .. container:: content
3841
ramverma760cce92019-07-11 12:57:49 +00003842 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003843
3844 "eventProtocolParameters":{
3845 "eventProtocol" : "XML",
3846 "parameterClassName" :
3847 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3848 }
3849
3850A configuration example
3851-----------------------
3852
3853 .. container:: paragraph
3854
3855 The following example loads all available plug-ins.
3856
3857 .. container:: paragraph
3858
3859 Events are consumed from a Websocket, APEX as client.
3860 Consumed event format is JSON.
3861
3862 .. container:: paragraph
3863
3864 Events are produced to Kafka. Produced event format is XML.
3865
3866 .. container:: listingblock
3867
3868 .. container:: content
3869
ramverma760cce92019-07-11 12:57:49 +00003870 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003871
3872 {
3873 "engineServiceParameters" : {
3874 "name" : "MyApexEngine",
3875 "version" : "0.0.1",
3876 "id" : 45,
3877 "instanceCount" : 4,
3878 "deploymentPort" : 12345,
ramverma3b71c972019-07-10 11:25:37 +00003879 "engineParameters" : {
3880 "executorParameters" : {
3881 "JAVASCRIPT" : {
3882 "parameterClassName" :
3883 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
3884 },
3885 "JYTHON" : {
3886 "parameterClassName" :
3887 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
3888 },
3889 "JRUBY" : {
3890 "parameterClassName" :
3891 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
3892 },
3893 "JAVA" : {
3894 "parameterClassName" :
3895 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
3896 },
3897 "MVEL" : {
3898 "parameterClassName" :
3899 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
3900 }
3901 },
3902 "contextParameters" : {
3903 "parameterClassName" :
3904 "org.onap.policy.apex.context.parameters.ContextParameters",
3905 "schemaParameters" : {
3906 "Avro":{
3907 "parameterClassName" :
3908 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
3909 }
3910 }
3911 }
3912 }
3913 },
3914 "producerCarrierTechnologyParameters" : {
3915 "carrierTechnology" : "KAFKA",
3916 "parameterClassName" :
3917 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
3918 "parameters" : {
3919 "bootstrapServers" : "localhost:49092",
3920 "acks" : "all",
3921 "retries" : 0,
3922 "batchSize" : 16384,
3923 "lingerTime" : 1,
3924 "bufferMemory" : 33554432,
3925 "producerTopic" : "apex-out",
3926 "keySerializer" : "org.apache.kafka.common.serialization.StringSerializer",
3927 "valueSerializer" : "org.apache.kafka.common.serialization.StringSerializer"
3928 }
3929 },
3930 "producerEventProtocolParameters" : {
3931 "eventProtocol" : "XML",
3932 "parameterClassName" :
3933 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3934 },
3935 "consumerCarrierTechnologyParameters" : {
3936 "carrierTechnology" : "WEBSOCKET",
3937 "parameterClassName" :
3938 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
3939 "parameters" : {
3940 "host" : "localhost",
3941 "port" : 88888
3942 }
3943 },
3944 "consumerEventProtocolParameters" : {
3945 "eventProtocol" : "JSON"
3946 }
3947 }
3948
3949Engine and Applications of the APEX System
3950^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3951
3952Introduction to APEX Engine and Applications
3953--------------------------------------------
3954
3955 .. container:: paragraph
3956
3957 The core of APEX is the APEX Engine, also known as the APEX
3958 Policy Engine or the APEX PDP (since it is in fact a Policy
3959 Decision Point). Beside this engine, an APEX system comes
3960 with a few applications intended to help with policy
3961 authoring, deployment, and execution.
3962
3963 .. container:: paragraph
3964
3965 The engine itself and most applications are started from the
3966 command line with command line arguments. This is called a
3967 Command Line Interface (CLI). Some applications require an
3968 installation on a webserver, as for instance the REST
3969 Editor. Those applications can be accessed via a web
3970 browser.
3971
3972 .. container:: paragraph
3973
3974 You can also use the available APEX APIs and applications to
3975 develop other applications as required. This includes policy
3976 languages (and associated parsers and compilers /
3977 interpreters), GUIs to access APEX or to define policies,
3978 clients to connect to APEX, etc.
3979
3980 .. container:: paragraph
3981
3982 For this documentation, we assume an installation of APEX as
3983 a full system based on a current ONAP release.
3984
3985CLI on Unix, Windows, and Cygwin
3986--------------------------------
3987
3988 .. container:: paragraph
3989
3990 A note on APEX CLI applications: all applications and the
3991 engine itself have been deployed and tested on different
3992 operating systems: Red Hat, Ubuntu, Debian, Mac OSX,
3993 Windows, Cygwin. Each operating system comes with its own
3994 way of configuring and executing Java. The main items here
3995 are:
3996
3997 .. container:: ulist
3998
3999 - For UNIX systems (RHL, Ubuntu, Debian, Mac OSX), the
4000 provided bash scripts work as expected with absolute
4001 paths (e.g.
4002 ``/opt/app/policy/apex-pdp/apex-pdp-2.0.0-SNAPSHOT/examples``),
4003 indirect and linked paths (e.g. ``../apex/apex``), and
4004 path substitutions using environment settings (e.g.
4005 ``$APEX_HOME/bin/``)
4006
4007 - For Windows systems, the provided batch files (``.bat``)
4008 work as expected with with absolute paths (e.g.
4009 ``C:\apex\apex-2.0.0-SNAPSHOT\examples``), and path
4010 substitutions using environment settings (e.g.
4011 ``%APEX_HOME%\bin\``)
4012
4013 - For Cygwin system we assume a standard Cygwin
4014 installation with standard tools (mainly bash) using a
4015 Windows Java installation. This means that the bash
4016 scripts can be used as in UNIX, however any argument
4017 pointing to files and directories need to use either a
4018 DOS path (e.g.
4019 ``C:\apex\apex-2.0.0-SNAPSHOT\examples\config...``) or
4020 the command ``cygpath`` with a mixed option. The reason
4021 for that is: Cygwin executes Java using UNIX paths but
4022 then runs Java as a DOS/WINDOWS process, which requires
4023 DOS paths for file access.
4024
4025The APEX Engine
4026---------------
4027
4028 .. container:: paragraph
4029
4030 The APEX engine can be started in different ways, depending
4031 your requirements. All scripts are located in the APEX *bin*
4032 directory
4033
4034 .. container:: paragraph
4035
4036 On UNIX and Cygwin systems use:
4037
4038 .. container:: ulist
4039
4040 - ``apexEngine.sh`` - this script will
4041
4042 .. container:: ulist
4043
4044 - Test if ``$APEX_USER`` is set and if the user
4045 exists, terminate with an error otherwise
4046
4047 - Test if ``$APEX_HOME`` is set. If not set, it will
4048 use the default setting as
4049 ``/opt/app/policy/apex-pdp/apex-pdp``. Then the set
4050 directory is tested to exist, the script will
4051 terminate if not.
4052
4053 - When all tests are passed successfully, the script
4054 will call ``apexApps.sh`` with arguments to start
4055 the APEX engine.
4056
4057 - ``apexApps.sh engine`` - this is the general APEX
4058 application launcher, which will
4059
4060 .. container:: ulist
4061
4062 - Start the engine with the argument ``engine``
4063
4064 - Test if ``$APEX_HOME`` is set and points to an
4065 existing directory. If not set or directory does
4066 not exist, script terminates.
4067
4068 - Not test for any settings of ``$APEX_USER``.
4069
4070 .. container:: paragraph
4071
4072 On Windows systems use ``apexEngine.bat`` and
4073 ``apexApps.bat engine`` respectively. Note: none of the
4074 windows batch files will test for ``%APEX_USER%``.
4075
4076 .. container:: paragraph
4077
4078 Summary of alternatives to start the APEX Engine:
4079
4080 +--------------------------------------------------------+----------------------------------------------------------+
4081 | Unix, Cygwin | Windows |
4082 +========================================================+==========================================================+
4083 | .. container:: | .. container:: |
4084 | | |
4085 | .. container:: listingblock | .. container:: listingblock |
4086 | | |
4087 | .. container:: content | .. container:: content |
4088 | | |
4089 | .. code:: | .. code:: |
4090 | | |
4091 | # $APEX_HOME/bin/apexEngine.sh [args] | > %APEX_HOME%\bin\apexEngine.bat [args] |
4092 | # $APEX_HOME/bin/apexApps.sh engine [args] | > %APEX_HOME%\bin\apexApps.bat engine [args] |
4093 +--------------------------------------------------------+----------------------------------------------------------+
4094
4095 .. container:: paragraph
4096
a.sreekumarcf3ff822020-09-16 13:12:29 +01004097 The APEX engine comes with a few CLI arguments, the main one is for setting
4098 the tosca policy file for execution. The tosca policy file is
4099 always required. The option ``-h`` prints a help screen.
ramverma3b71c972019-07-10 11:25:37 +00004100
4101 .. container:: listingblock
4102
4103 .. container:: content
4104
ramverma760cce92019-07-11 12:57:49 +00004105 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004106
4107 usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]
4108 options
a.sreekumarcf3ff822020-09-16 13:12:29 +01004109 -p,--tosca-policy-file <TOSCA_POLICY_FILE> the full path to the ToscaPolicy file to use.
4110 -h,--help outputs the usage of this command
4111 -v,--version outputs the version of Apex
ramverma3b71c972019-07-10 11:25:37 +00004112
4113The APEX CLI Editor
4114-------------------
4115
4116 .. container:: paragraph
4117
4118 The CLI Editor allows to define policies from the command
4119 line. The application uses a simple language and supports
4120 all elements of an APEX policy. It can be used in to
4121 different ways:
4122
4123 .. container:: ulist
4124
4125 - non-interactive, specifying a file with the commands to
4126 create a policy
4127
4128 - interactive, using the editors CLI to create a policy
4129
4130 .. container:: paragraph
4131
4132 When a policy is fully specified, the editor will generate
4133 the APEX core policy specification in JSON. This core
4134 specification is called the policy model in the APEX engine
4135 and can be used directly with the APEX engine.
4136
4137 .. container:: paragraph
4138
4139 On UNIX and Cygwin systems use:
4140
4141 .. container:: ulist
4142
4143 - ``apexCLIEditor.sh`` - simply starts the CLI editor,
4144 arguments to the script determine the mode of the editor
4145
4146 - ``apexApps.sh cli-editor`` - simply starts the CLI
4147 editor, arguments to the script determine the mode of the
4148 editor
4149
4150 .. container:: paragraph
4151
4152 On Windows systems use:
4153
4154 .. container:: ulist
4155
4156 - ``apexCLIEditor.bat`` - simply starts the CLI editor,
4157 arguments to the script determine the mode of the editor
4158
4159 - ``apexApps.bat cli-editor`` - simply starts the CLI
4160 editor, arguments to the script determine the mode of the
4161 editor
4162
4163 .. container:: paragraph
4164
4165 Summary of alternatives to start the APEX CLI Editor:
4166
4167 +------------------------------------------------------------+--------------------------------------------------------------+
4168 | Unix, Cygwin | Windows |
4169 +============================================================+==============================================================+
4170 | .. container:: | .. container:: |
4171 | | |
4172 | .. container:: listingblock | .. container:: listingblock |
4173 | | |
4174 | .. container:: content | .. container:: content |
4175 | | |
4176 | .. code:: | .. code:: |
4177 | | |
4178 | # $APEX_HOME/bin/apexCLIEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIEditor.bat [args] |
4179 | # $APEX_HOME/bin/apexApps.sh cli-editor [args] | > %APEX_HOME%\bin\apexApps.bat cli-editor [args] |
4180 +------------------------------------------------------------+--------------------------------------------------------------+
4181
4182 .. container:: paragraph
4183
4184 The option ``-h`` provides a help screen with all command
4185 line arguments.
4186
4187 .. container:: listingblock
4188
4189 .. container:: content
4190
ramverma760cce92019-07-11 12:57:49 +00004191 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004192
4193 usage: org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain [options...]
4194 options
4195 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4196 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4197 -h,--help outputs the usage of this command
4198 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4199 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and continue
4200 executing the command file
4201 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will log
4202 to standard output if not specified or suppressed with "-nl" flag
4203 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4204 -nl,--no-log if specified, no logging or output of commands to standard output or log
4205 file is carried out
4206 -nm,--no-model-output if specified, no output of a model to standard output or model output
4207 file is carried out, the user can use the "save" command in a script to
4208 save a model
4209 -o,--output-model-file <OUTPUT_MODEL_FILE> name of a file that will contain the output model for the editor, will
4210 output model to standard output if not specified or suppressed with
4211 "-nm" flag
4212 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4213 root from which to look for included macro files
4214
a.sreekumar717a24a2019-07-26 13:47:42 +00004215The APEX CLI Tosca Editor
4216-------------------------
4217
4218 .. container:: paragraph
4219
4220 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.
4221
4222 .. container:: paragraph
4223
4224 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.
4225
4226 .. container:: paragraph
4227
4228 On UNIX and Cygwin systems use:
4229
4230 .. container:: ulist
4231
4232 - ``apexCLIToscaEditor.sh`` - starts the CLI Tosca editor,
4233 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4234
4235 - ``apexApps.sh cli-tosca-editor`` - starts the CLI Tosca editor,
4236 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4237
4238 .. container:: paragraph
4239
4240 On Windows systems use:
4241
4242 .. container:: ulist
4243
4244 - ``apexCLIToscaEditor.bat`` - starts the CLI Tosca editor,
4245 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4246
4247 - ``apexApps.bat cli-tosca-editor`` - starts the CLI Tosca
4248 editor, all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4249
4250 .. container:: paragraph
4251
4252 Summary of alternatives to start the APEX CLI Tosca Editor:
4253
4254 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4255 | Unix, Cygwin | Windows |
4256 +=================================================================+====================================================================+
4257 | .. container:: | .. container:: |
4258 | | |
4259 | .. container:: listingblock | .. container:: listingblock |
4260 | | |
4261 | .. container:: content | .. container:: content |
4262 | | |
4263 | .. code:: | .. code:: |
4264 | | |
4265 | # $APEX_HOME/bin/apexCLIToscaEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIToscaEditor.bat [args] |
4266 | # $APEX_HOME/bin/apexApps.sh cli-tosca-editor [args]| > %APEX_HOME%\bin\apexApps.bat cli-tosca-editor [args] |
4267 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4268
4269 .. container:: paragraph
4270
4271 The option ``-h`` provides a help screen with all command
4272 line arguments.
4273
4274 .. container:: listingblock
4275
4276 .. container:: content
4277
4278 .. code::
4279
4280 usage: org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain [options...]
4281 options
4282 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4283 -ac,--apex-config-file <APEX_CONFIG_FILE> name of the file containing apex configuration details
4284 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4285 -h,--help outputs the usage of this command
4286 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4287 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and
4288 continue executing the command file
4289 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will
4290 log to standard output if not specified or suppressed with "-nl" flag
4291 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4292 -nl,--no-log if specified, no logging or output of commands to standard output or
4293 log file is carried out
4294 -ot,--output-tosca-file <OUTPUT_TOSCA_FILE> name of a file that will contain the output ToscaServiceTemplate
4295 -t,--tosca-template-file <TOSCA_TEMPLATE_FILE> name of the input file containing tosca template which needs to be
4296 updated with policy
4297 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4298 root from which to look for included macro files
4299
4300 .. container:: paragraph
4301
4302 An example command to run the APEX CLI Tosca editor on windows machine is given below.
4303
4304 .. container:: listingblock
4305
4306 .. container:: content
4307
4308 .. code::
4309
4310 %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
4311
liamfallon75e2bbf2020-07-06 11:41:38 +01004312
4313The APEX Client
liamfallonb621de42020-08-21 12:59:26 +01004314---------------
ramverma3b71c972019-07-10 11:25:37 +00004315
4316 .. container:: paragraph
4317
liamfallon75e2bbf2020-07-06 11:41:38 +01004318 The APEX Client combines the Policy Editor, the
ramverma3b71c972019-07-10 11:25:37 +00004319 Monitoring Client, and the Deployment Client into a single
4320 application. The standard way to use the APEX Full Client is
4321 via an installation of the *war* file on a webserver.
4322 However, the Full Client can also be started via command
4323 line. This will start a Grizzly webserver with the *war*
4324 deployed. Access to the Full Client is then via the provided
4325 URL
4326
4327 .. container:: paragraph
4328
4329 On UNIX and Cygwin systems use:
4330
4331 .. container:: ulist
4332
4333 - ``apexApps.sh full-client`` - simply starts the webserver
4334 with the Full Client
4335
4336 .. container:: paragraph
4337
4338 On Windows systems use:
4339
4340 .. container:: ulist
4341
4342 - ``apexApps.bat full-client`` - simply starts the
4343 webserver with the Full Client
4344
4345 .. container:: paragraph
4346
4347 The option ``-h`` provides a help screen with all command
4348 line arguments.
4349
4350 .. container:: listingblock
4351
4352 .. container:: content
4353
ramverma760cce92019-07-11 12:57:49 +00004354 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004355
4356 usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]
4357 -h,--help outputs the usage of this command
4358 -p,--port <PORT> port to use for the Apex Services REST calls
4359 -t,--time-to-live <TIME_TO_LIVE> the amount of time in seconds that the server will run for before terminating
4360
4361 .. container:: paragraph
4362
4363 If the Full Client is started without any arguments the
4364 final messages will look similar to this:
4365
4366 .. container:: listingblock
4367
4368 .. container:: content
4369
ramverma760cce92019-07-11 12:57:49 +00004370 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004371
4372 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
4373 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.NetworkListener start
4374 INFO: Started listener bound to [localhost:18989]
4375 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.HttpServer start
4376 INFO: [HttpServer] Started.
4377 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
4378
4379 .. container:: paragraph
4380
4381 The last line states the URL on which the Monitoring Client
4382 can be accessed. The example above stated
4383 ``http://localhost:18989/apexservices``. In a web browser
4384 use the URL ``http://localhost:18989``.
4385
aditya.puthuparambil9e67eb72020-04-30 15:59:43 +01004386The APEX Application Launcher
4387-----------------------------
ramverma3b71c972019-07-10 11:25:37 +00004388
4389 .. container:: paragraph
4390
liamfallon75e2bbf2020-07-06 11:41:38 +01004391 The standard applications (Engine and CLI Editor)
ramverma3b71c972019-07-10 11:25:37 +00004392 come with dedicated start scripts. For all other APEX
4393 applications, we provide an application launcher.
4394
4395 .. container:: paragraph
4396
4397 On UNIX and Cygwin systems use:
4398
4399 .. container:: ulist
4400
4401 - apexApps.sh\` - simply starts the application launcher
4402
4403 .. container:: paragraph
4404
4405 On Windows systems use:
4406
4407 .. container:: ulist
4408
4409 - ``apexApps.bat`` - simply starts the application launcher
4410
4411 .. container:: paragraph
4412
4413 Summary of alternatives to start the APEX application
4414 launcher:
4415
4416 +-------------------------------------------------+---------------------------------------------------+
4417 | Unix, Cygwin | Windows |
4418 +=================================================+===================================================+
4419 | .. container:: | .. container:: |
4420 | | |
4421 | .. container:: listingblock | .. container:: listingblock |
4422 | | |
4423 | .. container:: content | .. container:: content |
4424 | | |
4425 | .. code:: | .. code:: |
4426 | | |
4427 | # $APEX_HOME/bin/apexApps.sh [args] | > %APEX_HOME%\bin\apexApps.bat [args] |
4428 +-------------------------------------------------+---------------------------------------------------+
4429
4430 .. container:: paragraph
4431
4432 The option ``-h`` provides a help screen with all launcher
4433 command line arguments.
4434
4435 .. container:: listingblock
4436
4437 .. container:: content
4438
ramverma760cce92019-07-11 12:57:49 +00004439 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004440
4441 apexApps.sh - runs APEX applications
4442
4443 Usage: apexApps.sh [options] | [<application> [<application options>]]
4444
4445 Options
4446 -d <app> - describes an application
4447 -l - lists all applications supported by this script
4448 -h - this help screen
4449
4450 .. container:: paragraph
4451
4452 Using ``-l`` lists all known application the launcher can
4453 start.
4454
4455 .. container:: listingblock
4456
4457 .. container:: content
4458
ramverma760cce92019-07-11 12:57:49 +00004459 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004460
4461 apexApps.sh: supported applications:
4462 --> ws-echo engine eng-monitoring full-client eng-deployment tpl-event-json model-2-cli rest-editor cli-editor ws-console
4463
4464 .. container:: paragraph
4465
4466 Using the ``-d <name>`` option describes the named
4467 application, for instance for the ``ws-console``:
4468
4469 .. container:: listingblock
4470
4471 .. container:: content
4472
ramverma760cce92019-07-11 12:57:49 +00004473 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004474
4475 apexApps.sh: application 'ws-console'
4476 --> a simple console sending events to APEX, connect to APEX consumer port
4477
4478 .. container:: paragraph
4479
4480 Launching an application is done by calling the script with
4481 only the application name and any CLI arguments for the
4482 application. For instance, starting the ``ws-echo``
4483 application with port ``8888``:
4484
4485 .. container:: listingblock
4486
4487 .. container:: content
4488
ramverma760cce92019-07-11 12:57:49 +00004489 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004490
4491 apexApps.sh ws-echo -p 8888
4492
4493Application: Create Event Templates
4494-----------------------------------
4495
4496 .. container:: paragraph
4497
4498 **Status: Experimental**
4499
4500 .. container:: paragraph
4501
4502 This application takes a policy model (JSON or XML encoded)
4503 and generates templates for events in JSON format. This can
4504 help when a policy defines rather complex trigger or action
4505 events or complex events between states. The application can
4506 produce events for the types: stimuli (policy trigger
4507 events), internal (events between policy states), and
4508 response (action events).
4509
4510 +----------------------------------------------------------------+------------------------------------------------------------------+
4511 | Unix, Cygwin | Windows |
4512 +================================================================+==================================================================+
4513 | .. container:: | .. container:: |
4514 | | |
4515 | .. container:: listingblock | .. container:: listingblock |
4516 | | |
4517 | .. container:: content | .. container:: content |
4518 | | |
4519 | .. code:: | .. code:: |
4520 | | |
4521 | # $APEX_HOME/bin/apexApps.sh tpl-event-json [args] | > %APEX_HOME%\bin\apexApps.bat tpl-event-json [args] |
4522 +----------------------------------------------------------------+------------------------------------------------------------------+
4523
4524 .. container:: paragraph
4525
4526 The option ``-h`` provides a help screen.
4527
4528 .. container:: listingblock
4529
4530 .. container:: content
4531
ramverma760cce92019-07-11 12:57:49 +00004532 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004533
4534 gen-model2event v{release-version} - generates JSON templates for events generated from a policy model
4535 usage: gen-model2event
4536 -h,--help prints this help and usage screen
4537 -m,--model <MODEL-FILE> set the input policy model file
4538 -t,--type <TYPE> set the event type for generation, one of:
4539 stimuli (trigger events), response (action
4540 events), internal (events between states)
4541 -v,--version prints the application version
4542
4543 .. container:: paragraph
4544
4545 The created templates are not valid events, instead they use
4546 some markup for values one will need to change to actual
4547 values. For instance, running the tool with the *Sample
4548 Domain* policy model as:
4549
4550 .. container:: listingblock
4551
4552 .. container:: content
4553
ramverma760cce92019-07-11 12:57:49 +00004554 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004555
4556 apexApps.sh tpl-event-json -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json -t stimuli
4557
4558 .. container:: paragraph
4559
4560 will produce the following status messages:
4561
4562 .. container:: listingblock
4563
4564 .. container:: content
4565
ramverma760cce92019-07-11 12:57:49 +00004566 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004567
4568 gen-model2event: starting Event generator
4569 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4570 --> type: stimuli
4571
4572 .. container:: paragraph
4573
4574 and then run the generator application producing two event
4575 templates. The first template is called ``Event0000``.
4576
4577 .. container:: listingblock
4578
4579 .. container:: content
4580
4581 .. code::
4582
4583 {
4584 "name" : "Event0000",
4585 "nameSpace" : "org.onap.policy.apex.sample.events",
4586 "version" : "0.0.1",
4587 "source" : "Outside",
4588 "target" : "Match",
4589 "TestTemperature" : ###double: 0.0###,
4590 "TestTimestamp" : ###long: 0###,
4591 "TestMatchCase" : ###integer: 0###,
4592 "TestSlogan" : "###string###"
4593 }
4594
4595 .. container:: paragraph
4596
4597 The values for the keys are marked with ``#`` and the
4598 expected type of the value. To create an actual stimuli
4599 event, all these markers need to be change to actual values,
4600 for instance:
4601
4602 .. container:: listingblock
4603
4604 .. container:: content
4605
ramverma760cce92019-07-11 12:57:49 +00004606 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004607
4608 {
4609 "name" : "Event0000",
4610 "nameSpace" : "org.onap.policy.apex.sample.events",
4611 "version" : "0.0.1",
4612 "source" : "Outside",
4613 "target" : "Match",
4614 "TestTemperature" : 25,
4615 "TestTimestamp" : 123456789123456789,
4616 "TestMatchCase" : 1,
4617 "TestSlogan" : "Testing the Match Case with Temperature 25"
4618 }
4619
4620Application: Convert a Policy Model to CLI Editor Commands
4621----------------------------------------------------------
4622
4623 .. container:: paragraph
4624
4625 **Status: Experimental**
4626
4627 .. container:: paragraph
4628
4629 This application takes a policy model (JSON or XML encoded)
4630 and generates commands for the APEX CLI Editor. This
4631 effectively reverses a policy specification realized with
4632 the CLI Editor.
4633
4634 +-------------------------------------------------------------+---------------------------------------------------------------+
4635 | Unix, Cygwin | Windows |
4636 +=============================================================+===============================================================+
4637 | .. container:: | .. container:: |
4638 | | |
4639 | .. container:: listingblock | .. container:: listingblock |
4640 | | |
4641 | .. container:: content | .. container:: content |
4642 | | |
4643 | .. code:: | .. code:: |
4644 | | |
4645 | # $APEX_HOME/bin/apexApps.sh model-2-cli [args] | > %APEX_HOME%\bin\apexApps.bat model-2-cli [args] |
4646 +-------------------------------------------------------------+---------------------------------------------------------------+
4647
4648 .. container:: paragraph
4649
4650 The option ``-h`` provides a help screen.
4651
4652 .. container:: listingblock
4653
4654 .. container:: content
4655
ramverma760cce92019-07-11 12:57:49 +00004656 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004657
4658 usage: gen-model2cli
4659 -h,--help prints this help and usage screen
4660 -m,--model <MODEL-FILE> set the input policy model file
4661 -sv,--skip-validation switch of validation of the input file
4662 -v,--version prints the application version
4663
4664 .. container:: paragraph
4665
4666 For instance, running the tool with the *Sample Domain*
4667 policy model as:
4668
4669 .. container:: listingblock
4670
4671 .. container:: content
4672
ramverma760cce92019-07-11 12:57:49 +00004673 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004674
4675 apexApps.sh model-2-cli -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json
4676
4677 .. container:: paragraph
4678
4679 will produce the following status messages:
4680
4681 .. container:: listingblock
4682
4683 .. container:: content
4684
ramverma760cce92019-07-11 12:57:49 +00004685 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004686
4687 gen-model2cli: starting CLI generator
4688 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4689
4690 .. container:: paragraph
4691
4692 and then run the generator application producing all CLI
4693 Editor commands and printing them to standard out.
4694
4695Application: Websocket Clients (Echo and Console)
4696-------------------------------------------------
4697
4698 .. container:: paragraph
4699
4700 **Status: Production**
4701
4702 .. container:: paragraph
4703
4704 The application launcher also provides a Websocket echo
4705 client and a Websocket console client. The echo client
4706 connects to APEX and prints all events it receives from
4707 APEX. The console client connects to APEX, reads input from
4708 the command line, and sends this input as events to APEX.
4709
4710 +------------------------------------------------------------+--------------------------------------------------------------+
4711 | Unix, Cygwin | Windows |
4712 +============================================================+==============================================================+
4713 | .. container:: | .. container:: |
4714 | | |
4715 | .. container:: listingblock | .. container:: listingblock |
4716 | | |
4717 | .. container:: content | .. container:: content |
4718 | | |
4719 | .. code:: | .. code:: |
4720 | | |
4721 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
4722 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
4723 +------------------------------------------------------------+--------------------------------------------------------------+
4724
4725 .. container:: paragraph
4726
4727 The arguments are the same for both applications:
4728
4729 .. container:: ulist
4730
4731 - ``-p`` defines the Websocket port to connect to (defaults
4732 to ``8887``)
4733
4734 - ``-s`` defines the host on which a Websocket server is
4735 running (defaults to ``localhost``)
4736
4737 .. container:: paragraph
4738
4739 A discussion on how to use these two applications to build
4740 an APEX system is detailed HowTo-Websockets.
4741
ramverma3b71c972019-07-10 11:25:37 +00004742APEX Logging
4743^^^^^^^^^^^^
4744
4745Introduction to APEX Logging
4746----------------------------
4747
4748 .. container:: paragraph
4749
4750 All APEX components make extensive use of logging using the
4751 logging façade `SLF4J <https://www.slf4j.org/>`__ with the
4752 backend `Logback <https://logback.qos.ch/>`__. Both are used
4753 off-the-shelve, so the standard documentation and
4754 configuration apply to APEX logging. For details on how to
4755 work with logback please see the `logback
4756 manual <https://logback.qos.ch/manual/index.html>`__.
4757
4758 .. container:: paragraph
4759
4760 The APEX applications is the logback configuration file
4761 ``$APEX_HOME/etc/logback.xml`` (Windows:
4762 ``%APEX_HOME%\etc\logback.xml``). The logging backend is set
4763 to no debug, i.e. logs from the logging framework should be
4764 hidden at runtime.
4765
4766 .. container:: paragraph
4767
4768 The configurable log levels work as expected:
4769
4770 .. container:: ulist
4771
4772 - *error* (or *ERROR*) is used for serious errors in the
4773 APEX runtime engine
4774
4775 - *warn* (or *WARN*) is used for warnings, which in general
4776 can be ignored but might indicate some deeper problems
4777
4778 - *info* (or *INFO*) is used to provide generally
4779 interesting messages for startup and policy execution
4780
4781 - *debug* (or *DEBUG*) provides more details on startup and
4782 policy execution
4783
4784 - *trace* (or *TRACE*) gives full details on every aspect
4785 of the APEX engine from start to end
4786
4787 .. container:: paragraph
4788
4789 The loggers can also be configured as expected. The standard
4790 configuration (after installing APEX) uses log level *info*
4791 on all APEX classes (components).
4792
4793 .. container:: paragraph
4794
4795 The applications and scripts in ``$APEX_HOME/bin`` (Windows:
4796 ``%APEX_HOME\bin``) are configured to use the logback
4797 configuration ``$APEX_HOME/etc/logback.xml`` (Windows:
4798 ``%APEX_HOME\etc\logback.xml``). There are multiple ways to
4799 use different logback configurations, for instance:
4800
4801 .. container:: ulist
4802
4803 - Maintain multiple configurations in ``etc``, for instance
4804 a ``logback-debug.xml`` for deep debugging and a
4805 ``logback-production.xml`` for APEX in production mode,
4806 then copy the required configuration file to the used
4807 ``logback.xml`` prior starting APEX
4808
4809 - Edit the scripts in ``bin`` to use a different logback
4810 configuration file (only recommended if you are familiar
4811 with editing bash scripts or windows batch files)
4812
4813Standard Logging Configuration
4814------------------------------
4815
4816 .. container:: paragraph
4817
4818 The standard logging configuration defines a context *APEX*,
4819 which is used in the standard output pattern. The location
liamfallon1540e472019-11-28 15:14:07 +00004820 for log files is defined in the property ``logDir`` and set
ramverma3b71c972019-07-10 11:25:37 +00004821 to ``/var/log/onap/policy/apex-pdp``. The standard status
4822 listener is set to *NOP* and the overall logback
4823 configuration is set to no debug.
4824
4825 .. container:: listingblock
4826
4827 .. container:: content
4828
ramverma760cce92019-07-11 12:57:49 +00004829 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004830 :number-lines:
4831
4832 <configuration debug="false">
4833 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
4834
4835 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00004836 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00004837
4838 ...appenders
4839 ...loggers
4840 </configuration>
4841
4842.. container:: paragraph
4843
4844 The first appender defined is called ``STDOUT`` for logs to standard
4845 out.
4846
4847.. container:: listingblock
4848
4849 .. container:: content
4850
ramverma760cce92019-07-11 12:57:49 +00004851 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004852 :number-lines:
4853
4854 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4855 <encoder>
4856 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
4857 </encoder>
4858 </appender>
4859
4860.. container:: paragraph
4861
4862 The root level logger then is set to the level *info* using the
4863 standard out appender.
4864
4865.. container:: listingblock
4866
4867 .. container:: content
4868
ramverma760cce92019-07-11 12:57:49 +00004869 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004870 :number-lines:
4871
4872 <root level="info">
4873 <appender-ref ref="STDOUT" />
4874 </root>
4875
4876.. container:: paragraph
4877
4878 The second appender is called ``FILE``. It writes logs to a file
4879 ``apex.log``.
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 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00004889 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00004890 <encoder>
4891 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4892 </encoder>
4893 </appender>
4894
4895.. container:: paragraph
4896
4897 The third appender is called ``CTXT_FILE``. It writes logs to a file
4898 ``apex_ctxt.log``.
4899
4900.. container:: listingblock
4901
4902 .. container:: content
4903
ramverma760cce92019-07-11 12:57:49 +00004904 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004905 :number-lines:
4906
4907 <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00004908 <file>${logDir}/apex_ctxt.log</file>
ramverma3b71c972019-07-10 11:25:37 +00004909 <encoder>
4910 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4911 </encoder>
4912 </appender>
4913
4914.. container:: paragraph
4915
4916 The last definitions are for specific loggers. The first logger
4917 captures all standard APEX classes. It is configured for log level
4918 *info* and uses the standard output and file appenders. The second
4919 logger captures APEX context classes responsible for context
4920 monitoring. It is configured for log level *trace* and uses the
4921 context file appender.
4922
4923.. container:: listingblock
4924
4925 .. container:: content
4926
ramverma760cce92019-07-11 12:57:49 +00004927 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004928 :number-lines:
4929
4930
4931 <logger name="org.onap.policy.apex" level="info" additivity="false">
4932 <appender-ref ref="STDOUT" />
4933 <appender-ref ref="FILE" />
4934 </logger>
4935
4936 <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
4937 <appender-ref ref="CTXT_FILE" />
4938 </logger>
4939
4940Adding Logback Status and Debug
4941-------------------------------
4942
4943 .. container:: paragraph
4944
4945 To activate logback status messages change the status listener
4946 from 'NOP' to for instance console.
4947
4948 .. container:: listingblock
4949
4950 .. container:: content
4951
ramverma760cce92019-07-11 12:57:49 +00004952 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004953
4954 <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
4955
4956 .. container:: paragraph
4957
4958 To activate all logback debugging, for instance to debug a new
4959 logback configuration, activate the debug attribute in the
4960 configuration.
4961
4962 .. container:: listingblock
4963
4964 .. container:: content
4965
ramverma760cce92019-07-11 12:57:49 +00004966 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004967
4968 <configuration debug="true">
4969 ...
4970 </configuration>
4971
4972Logging External Components
4973---------------------------
4974
4975 .. container:: paragraph
4976
4977 Logback can also be configured to log any other, external
4978 components APEX is using, if they are using the common logging
4979 framework.
4980
4981 .. container:: paragraph
4982
4983 For instance, the context component of APEX is using *Infinispan*
4984 and one can add a logger for this external component. The
4985 following example adds a logger for *Infinispan* using the
4986 standard output appender.
4987
4988 .. container:: listingblock
4989
4990 .. container:: content
4991
ramverma760cce92019-07-11 12:57:49 +00004992 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004993
4994 <logger name="org.infinispan" level="INFO" additivity="false">
4995 <appender-ref ref="STDOUT" />
4996 </logger>
4997
4998 .. container:: paragraph
4999
5000 Another example is Apache Zookeeper. The following example adds a
5001 logger for Zookeeper using the standard outout appender.
5002
5003 .. container:: listingblock
5004
5005 .. container:: content
5006
ramverma760cce92019-07-11 12:57:49 +00005007 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005008
5009 <logger name="org.apache.zookeeper.ClientCnxn" level="INFO" additivity="false">
5010 <appender-ref ref="STDOUT" />
5011 </logger>
5012
5013Configuring loggers for Policy Logic
5014------------------------------------
5015
5016 .. container:: paragraph
5017
5018 The logging for the logic inside a policy (task logic, task
5019 selection logic, state finalizer logic) can be configured separate
5020 from standard logging. The logger for policy logic is
5021 ``org.onap.policy.apex.executionlogging``. The following example
5022 defines
5023
5024 .. container:: ulist
5025
5026 - a new appender for standard out using a very simple pattern
5027 (simply the actual message)
5028
5029 - a logger for policy logic to standard out using the new
5030 appender and the already described file appender.
5031
5032 .. container:: listingblock
5033
5034 .. container:: content
5035
ramverma760cce92019-07-11 12:57:49 +00005036 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005037
5038 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5039 <encoder>
5040 <pattern>policy: %msg\n</pattern>
5041 </encoder>
5042 </appender>
5043
5044 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5045 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5046 <appender-ref ref="FILE" />
5047 </logger>
5048
5049 .. container:: paragraph
5050
5051 It is also possible to use specific logging for parts of policy
5052 logic. The following example defines a logger for task logic.
5053
5054 .. container:: listingblock
5055
5056 .. container:: content
5057
ramverma760cce92019-07-11 12:57:49 +00005058 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005059
5060 <logger name="org.onap.policy.apex.executionlogging.TaskExecutionLogging" level="TRACE" additivity="false">
5061 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5062 </logger>
5063
5064Rolling File Appenders
5065----------------------
5066
5067 .. container:: paragraph
5068
5069 Rolling file appenders are a good option for more complex logging
5070 of a production or complex testing APEX installation. The standard
5071 logback configuration can be used for these use cases. This
5072 section gives two examples for the standard logging and for
5073 context logging.
5074
5075 .. container:: paragraph
5076
5077 First the standard logging. The following example defines a
5078 rolling file appender. The appender rolls over on a daily basis.
5079 It allows for a file size of 100 MB.
5080
5081 .. container:: listingblock
5082
5083 .. container:: content
5084
ramverma760cce92019-07-11 12:57:49 +00005085 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005086
5087 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005088 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005089 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5090 <!-- rollover daily -->
5091 <!-- <fileNamePattern>xstream-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> -->
liamfallon1540e472019-11-28 15:14:07 +00005092 <fileNamePattern>${logDir}/apex_%d{yyyy-MM-dd}.%i.log.gz
ramverma3b71c972019-07-10 11:25:37 +00005093 </fileNamePattern>
5094 <maxHistory>4</maxHistory>
5095 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5096 <!-- or whenever the file size reaches 100MB -->
5097 <maxFileSize>100MB</maxFileSize>
5098 </timeBasedFileNamingAndTriggeringPolicy>
5099 </rollingPolicy>
5100 <encoder>
5101 <pattern>
5102 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5103 </pattern>
5104 </encoder>
5105 </appender>
5106
5107 .. container:: paragraph
5108
5109 A very similar configuration can be used for a rolling file
5110 appender logging APEX context.
5111
5112 .. container:: listingblock
5113
5114 .. container:: content
5115
ramverma760cce92019-07-11 12:57:49 +00005116 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005117
5118 <appender name="CTXT-FILE"
5119 class="ch.qos.logback.core.rolling.RollingFileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005120 <file>${logDir}/apex_ctxt.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005121 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
liamfallon1540e472019-11-28 15:14:07 +00005122 <fileNamePattern>${logDir}/apex_ctxt_%d{yyyy-MM-dd}.%i.log.gz
ramverma3b71c972019-07-10 11:25:37 +00005123 </fileNamePattern>
5124 <maxHistory>4</maxHistory>
5125 <timeBasedFileNamingAndTriggeringPolicy
5126 class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5127 <maxFileSize>100MB</maxFileSize>
5128 </timeBasedFileNamingAndTriggeringPolicy>
5129 </rollingPolicy>
5130 <encoder>
5131 <pattern>
5132 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5133 </pattern>
5134 </encoder>
5135 </appender>
5136
5137Example Configuration for Logging Logic
5138---------------------------------------
5139
5140 .. container:: paragraph
5141
5142 The following example shows a configuration that logs policy logic
5143 to standard out and a file (*info*). All other APEX components are
5144 logging to a file (*debug*).. This configuration an be used in a
5145 pre-production phase with the APEX engine still running in a
5146 separate terminal to monitor policy execution. This logback
5147 configuration is in the APEX installation as
5148 ``etc/logback-logic.xml``.
5149
5150 .. container:: listingblock
5151
5152 .. container:: content
5153
ramverma760cce92019-07-11 12:57:49 +00005154 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005155
5156 <configuration debug="false">
5157 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5158
5159 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00005160 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00005161
5162 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5163 <encoder>
5164 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
5165 </encoder>
5166 </appender>
5167
5168 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005169 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005170 <encoder>
5171 <pattern>
5172 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5173 </pattern>
5174 </encoder>
5175 </appender>
5176
5177 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5178 <encoder>
5179 <pattern>policy: %msg\n</pattern>
5180 </encoder>
5181 </appender>
5182
5183 <root level="error">
5184 <appender-ref ref="STDOUT" />
5185 </root>
5186
5187 <logger name="org.onap.policy.apex" level="debug" additivity="false">
5188 <appender-ref ref="FILE" />
5189 </logger>
5190
5191 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5192 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5193 <appender-ref ref="FILE" />
5194 </logger>
5195 </configuration>
5196
5197Example Configuration for a Production Server
5198---------------------------------------------
5199
5200 .. container:: paragraph
5201
5202 The following example shows a configuration that logs all APEX
5203 components, including policy logic, to a file (*debug*). This
5204 configuration an be used in a production phase with the APEX
5205 engine being executed as a service on a system without console
5206 output. This logback configuration is in the APEX installation as
5207 ``logback-server.xml``
5208
5209 .. container:: listingblock
5210
5211 .. container:: content
5212
ramverma760cce92019-07-11 12:57:49 +00005213 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005214
5215 <configuration debug="false">
5216 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5217
5218 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00005219 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00005220
5221 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005222 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005223 <encoder>
5224 <pattern>
5225 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5226 </pattern>
5227 </encoder>
5228 </appender>
5229
5230 <root level="debug">
5231 <appender-ref ref="FILE" />
5232 </root>
5233
5234 <logger name="org.onap.policy.apex.executionlogging" level="debug" additivity="false">
5235 <appender-ref ref="FILE" />
5236 </logger>
5237 </configuration>
5238
a.sreekumarcf3ff822020-09-16 13:12:29 +01005239Unsupported Features
5240^^^^^^^^^^^^^^^^^^^^
5241
5242 .. container:: paragraph
5243
5244 This section documents some legacy and unsupported features
5245 in apex-pdp. The documentation here has not been updated for
5246 recent versions of apex-pdp. For example, the apex-pdp models
5247 specified in this example should now be in TOSCA format.
5248
ramverma3b71c972019-07-10 11:25:37 +00005249Building a System with Websocket Backend
a.sreekumarcf3ff822020-09-16 13:12:29 +01005250----------------------------------------
ramverma3b71c972019-07-10 11:25:37 +00005251
5252Websockets
a.sreekumarcf3ff822020-09-16 13:12:29 +01005253##########
ramverma3b71c972019-07-10 11:25:37 +00005254
5255 .. container:: paragraph
5256
5257 Websocket is a protocol to run sockets of HTTP. Since it in
5258 essence a socket, the connection is realized between a
5259 server (waiting for connections) and a client (connecting to
5260 a server). Server/client separation is only important for
5261 connection establishment, once connected, everyone can
5262 send/receive on the same socket (as any standard socket
5263 would allow).
5264
5265 .. container:: paragraph
5266
5267 Standard Websocket implementations are simple, no
5268 publish/subscribe and no special event handling. Most
5269 servers simply send all incoming messages to all
5270 connections. There is a PubSub definition on top of
5271 Websocket called `WAMP <http://wamp-proto.org/>`__. APEX
5272 does not support WAMP at the moment.
5273
5274Websocket in Java
a.sreekumarcf3ff822020-09-16 13:12:29 +01005275#################
ramverma3b71c972019-07-10 11:25:37 +00005276
5277 .. container:: paragraph
5278
5279 In Java, `JSR
5280 356 <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5281 defines the standard Websocket API. This JSR is part of Jave
5282 EE 7 standard. For Java SE, several implementations exist in
5283 open source. Since Websockets are a stable standard and
5284 simple, most implementations are stable and ready to use. A
5285 lot of products support Websockets, like Spring, JBoss,
5286 Netty, … there are also Kafka extensions for Websockets.
5287
5288Websocket Example Code for Websocket clients (FOSS)
a.sreekumarcf3ff822020-09-16 13:12:29 +01005289###################################################
ramverma3b71c972019-07-10 11:25:37 +00005290
5291 .. container:: paragraph
5292
5293 There are a lot of implementations and examples available on
5294 Github for Websocket clients. If one is using Java EE 7,
5295 then one can also use the native Websocket implementation.
5296 Good examples for clients using simply Java SE are here:
5297
5298 .. container:: ulist
5299
5300 - `Websocket
5301 implementation <https://github.com/TooTallNate/Java-WebSocket>`__
5302
5303 - `Websocket sending client example, using
5304 AWT <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ChatClient.java>`__
5305
5306 - `Websocket receiving client example (simple echo
5307 client) <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ExampleClient.java>`__
5308
5309 .. container:: paragraph
5310
5311 For Java EE, the native Websocket API is explained here:
5312
5313 .. container:: ulist
5314
5315 - `Oracle
5316 docs <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5317
5318 - link: `An
5319 example <http://www.programmingforliving.com/2013/08/jsr-356-java-api-for-websocket-client-api.html>`__
5320
5321BCP: Websocket Configuration
a.sreekumarcf3ff822020-09-16 13:12:29 +01005322############################
ramverma3b71c972019-07-10 11:25:37 +00005323
5324 .. container:: paragraph
5325
5326 The probably best is to configure APEX for Websocket servers
5327 for input (ingress, consume) and output (egress, produce)
5328 interfaces. This means that APEX will start Websocket
5329 servers on named ports and wait for clients to connect.
5330 Advantage: once APEX is running all connectivity
5331 infrastructure is running as well. Consequence: if APEX is
5332 not running, everyone else is in the dark, too.
5333
5334 .. container:: paragraph
5335
5336 The best protocol to be used is JSON string. Each event on
5337 any interface is then a string with a JSON encoding. JSON
5338 string is a little bit slower than byte code, but we doubt
5339 that this will be noticeable. A further advantage of JSON
5340 strings over Websockets with APEX starting the servers: it
5341 is very easy to connect web browsers to such a system.
5342 Simple connect the web browser to the APEX sockets and
5343 send/read JSON strings.
5344
5345 .. container:: paragraph
5346
5347 Once APEX is started you simply connect Websocket clients to
5348 it, and send/receive event. When APEX is terminated, the
5349 Websocket servers go down, and the clients will be
5350 disconnected. APEX does not (yet) support auto-client
5351 reconnect nor WAMP, so clients might need to be restarted or
5352 reconnected manually after an APEX boot.
5353
5354Demo with VPN Policy Model
a.sreekumarcf3ff822020-09-16 13:12:29 +01005355##########################
ramverma3b71c972019-07-10 11:25:37 +00005356
5357 .. container:: paragraph
5358
5359 We assume that you have an APEX installation using the full
5360 package, i.e. APEX with all examples, of version ``0.5.6``
5361 or higher. We will use the VPN policy from the APEX examples
5362 here.
5363
5364 .. container:: paragraph
5365
5366 Now, have the following ready to start the demo:
5367
5368 .. container:: ulist
5369
5370 - 3 terminals on the host where APEX is running (we need 1
5371 for APEX and 1 for each client)
5372
5373 - the events in the file
5374 ``$APEX_HOME/examples/events/VPN/SetupEvents.json`` open
5375 in an editor (we need to send those events to APEX)
5376
5377 - the events in the file
5378 ``$APEX_HOME/examples/events/VPN/Link09Events.json`` open
5379 in an editor (we need to send those events to APEX)
5380
5381A Websocket Configuration for the VPN Domain
a.sreekumarcf3ff822020-09-16 13:12:29 +01005382********************************************
ramverma3b71c972019-07-10 11:25:37 +00005383
5384 .. container:: paragraph
5385
5386 Create a new APEX configuration using the VPN policy
5387 model and configuring APEX as discussed above for
5388 Websockets. Copy the following configuration into
5389 ``$APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json``
5390 (for Windows use
5391 ``%APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json``):
5392
5393 .. container:: listingblock
5394
5395 .. container:: content
5396
ramverma760cce92019-07-11 12:57:49 +00005397 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005398 :number-lines:
5399
5400 {
5401 "engineServiceParameters" : {
5402 "name" : "VPNApexEngine",
5403 "version" : "0.0.1",
5404 "id" : 45,
5405 "instanceCount" : 1,
5406 "deploymentPort" : 12345,
5407 "policyModelFileName" : "examples/models/VPN/VPNPolicyModelAvro.json",
5408 "engineParameters" : {
5409 "executorParameters" : {
5410 "MVEL" : {
5411 "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
5412 }
5413 },
5414 "contextParameters" : {
5415 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
5416 "schemaParameters":{
5417 "Avro":{
5418 "parameterClassName" : "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
5419 }
5420 }
5421 }
5422 }
5423 },
5424 "producerCarrierTechnologyParameters" : {
5425 "carrierTechnology" : "WEBSOCKET",
5426 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5427 "parameters" : {
5428 "wsClient" : false,
5429 "port" : 42452
5430 }
5431 },
5432 "producerEventProtocolParameters" : {
5433 "eventProtocol" : "JSON"
5434 },
5435 "consumerCarrierTechnologyParameters" : {
5436 "carrierTechnology" : "WEBSOCKET",
5437 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5438 "parameters" : {
5439 "wsClient" : false,
5440 "port" : 42450
5441 }
5442 },
5443 "consumerEventProtocolParameters" : {
5444 "eventProtocol" : "JSON"
5445 }
5446 }
5447
5448Start APEX Engine
a.sreekumarcf3ff822020-09-16 13:12:29 +01005449*****************
ramverma3b71c972019-07-10 11:25:37 +00005450
5451 .. container:: paragraph
5452
5453 In a new terminal, start APEX with the new configuration for
5454 Websocket-Server ingress/egress:
5455
5456 .. container:: listingblock
5457
5458 .. container:: content
5459
ramverma760cce92019-07-11 12:57:49 +00005460 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005461 :number-lines:
5462
liamfallonb621de42020-08-21 12:59:26 +01005463 #: $APEX_HOME/bin/apexApps.sh engine -c $APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json
ramverma3b71c972019-07-10 11:25:37 +00005464
5465.. container:: listingblock
5466
5467 .. container:: content
5468
ramverma760cce92019-07-11 12:57:49 +00005469 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005470 :number-lines:
5471
liamfallonb621de42020-08-21 12:59:26 +01005472 #: %APEX_HOME%\bin\apexApps.bat engine -c %APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json
ramverma3b71c972019-07-10 11:25:37 +00005473
5474.. container:: paragraph
5475
5476 Wait for APEX to start, it takes a while to create all Websocket
5477 servers (about 8 seconds on a standard laptop without cached
5478 binaries). depending on your log messages, you will see no (some, a
5479 lot) log messages. If APEX starts correctly, the last few messages
5480 you should see are:
5481
5482.. container:: listingblock
5483
5484 .. container:: content
5485
ramverma760cce92019-07-11 12:57:49 +00005486 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005487 :number-lines:
5488
5489 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)
5490 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 ...
5491 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
5492 Started Apex service
5493
5494.. container:: paragraph
5495
5496 APEX is running in the new terminal and will produce output when the
5497 policy is triggered/executed.
5498
5499Run the Websocket Echo Client
a.sreekumarcf3ff822020-09-16 13:12:29 +01005500*****************************
ramverma3b71c972019-07-10 11:25:37 +00005501
5502 .. container:: paragraph
5503
5504 The echo client is included in an APEX full installation. To run
5505 the client, open a new shell (Unix, Cygwin) or command prompt
5506 (``cmd`` on Windows). Then use the APEX application launcher to
5507 start the client.
5508
liamfallon9c7bd672019-10-03 13:42:08 +01005509 .. important::
ramverma3b71c972019-07-10 11:25:37 +00005510 APEX engine needs to run first
ramverma760cce92019-07-11 12:57:49 +00005511 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 +00005512
5513 +---------------------------------------------------------+-----------------------------------------------------------+
5514 | Unix, Cygwin | Windows |
5515 +=========================================================+===========================================================+
5516 | .. container:: | .. container:: |
5517 | | |
5518 | .. container:: listingblock | .. container:: listingblock |
5519 | | |
5520 | .. container:: content | .. container:: content |
5521 | | |
5522 | .. code:: | .. code:: |
5523 | | |
5524 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
5525 +---------------------------------------------------------+-----------------------------------------------------------+
5526
5527 .. container:: paragraph
5528
5529 Use the following command line arguments for server and port of
5530 the Websocket server. The port should be the same as configured in
5531 the APEX engine. The server host should be the host on which the
5532 APEX engine is running
5533
5534 .. container:: ulist
5535
5536 - ``-p`` defines the Websocket port to connect to (defaults to
5537 ``8887``)
5538
5539 - ``-s`` defines the host on which a Websocket server is running
5540 (defaults to ``localhost``)
5541
5542 .. container:: paragraph
5543
5544 Let’s assume that there is an APEX engine running, configured for
5545 produce Websocket carrier technology, as server, for port 42452,
5546 with produce event protocol JSON,. If we start the console client
5547 on the same host, we can omit the ``-s`` options. We start the
5548 console client as:
5549
5550 .. container:: listingblock
5551
5552 .. container:: content
5553
ramverma760cce92019-07-11 12:57:49 +00005554 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005555
5556 # $APEX_HOME/bin/apexApps.sh ws-echo -p 42452 (1)
5557 > %APEX_HOME%\bin\apexApps.bat ws-echo -p 42452 (2)
5558
5559 .. container:: colist arabic
5560
5561 +-------+--------------------------------+
5562 | **1** | Start client on Unix or Cygwin |
5563 +-------+--------------------------------+
5564 | **2** | Start client on Windows |
5565 +-------+--------------------------------+
5566
5567 .. container:: paragraph
5568
5569 Once started successfully, the client will produce the following
5570 messages (assuming we used ``-p 42452`` and an APEX engine is
5571 running on ``localhost`` with the same port:
5572
5573 .. container:: listingblock
5574
5575 .. container:: content
5576
ramverma760cce92019-07-11 12:57:49 +00005577 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005578
5579 ws-simple-echo: starting simple event echo
5580 --> server: localhost
5581 --> port: 42452
5582
5583 Once started, the application will simply print out all received events to standard out.
5584 Each received event will be prefixed by '---' and suffixed by '===='
5585
5586
5587 ws-simple-echo: opened connection to APEX (Web Socket Protocol Handshake)
5588
5589Run the Websocket Console Client
a.sreekumarcf3ff822020-09-16 13:12:29 +01005590********************************
ramverma3b71c972019-07-10 11:25:37 +00005591
5592 .. container:: paragraph
5593
5594 The console client is included in an APEX full installation. To
5595 run the client, open a new shell (Unix, Cygwin) or command prompt
5596 (``cmd`` on Windows). Then use the APEX application launcher to
5597 start the client.
5598
liamfallon9c7bd672019-10-03 13:42:08 +01005599 .. important::
ramverma3b71c972019-07-10 11:25:37 +00005600 APEX engine needs to run first
ramverma760cce92019-07-11 12:57:49 +00005601 The example assumes that an APEX engine configured for *consume* carrier technology Websocket and *JSON* event
5602 protocol is executed first.
ramverma3b71c972019-07-10 11:25:37 +00005603
5604 +------------------------------------------------------------+--------------------------------------------------------------+
5605 | Unix, Cygwin | Windows |
5606 +============================================================+==============================================================+
5607 | .. container:: | .. container:: |
5608 | | |
5609 | .. container:: listingblock | .. container:: listingblock |
5610 | | |
5611 | .. container:: content | .. container:: content |
5612 | | |
5613 | .. code:: | .. code:: |
5614 | | |
5615 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
5616 +------------------------------------------------------------+--------------------------------------------------------------+
5617
5618 .. container:: paragraph
5619
5620 Use the following command line arguments for server and port of
5621 the Websocket server. The port should be the same as configured in
5622 the APEX engine. The server host should be the host on which the
5623 APEX engine is running
5624
5625 .. container:: ulist
5626
5627 - ``-p`` defines the Websocket port to connect to (defaults to
5628 ``8887``)
5629
5630 - ``-s`` defines the host on which a Websocket server is running
5631 (defaults to ``localhost``)
5632
5633 .. container:: paragraph
5634
5635 Let’s assume that there is an APEX engine running, configured for
5636 consume Websocket carrier technology, as server, for port 42450,
5637 with consume event protocol JSON,. If we start the console client
5638 on the same host, we can omit the ``-s`` options. We start the
5639 console client as:
5640
5641 .. container:: listingblock
5642
5643 .. container:: content
5644
ramverma760cce92019-07-11 12:57:49 +00005645 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005646
5647 # $APEX_HOME/bin/apexApps.sh ws-console -p 42450 (1)
5648 > %APEX_HOME%\bin\apexApps.sh ws-console -p 42450 (2)
5649
5650 .. container:: colist arabic
5651
5652 +-------+--------------------------------+
5653 | **1** | Start client on Unix or Cygwin |
5654 +-------+--------------------------------+
5655 | **2** | Start client on Windows |
5656 +-------+--------------------------------+
5657
5658 .. container:: paragraph
5659
5660 Once started successfully, the client will produce the following
5661 messages (assuming we used ``-p 42450`` and an APEX engine is
5662 running on ``localhost`` with the same port:
5663
5664 .. container:: listingblock
5665
5666 .. container:: content
5667
ramverma760cce92019-07-11 12:57:49 +00005668 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005669
5670 ws-simple-console: starting simple event console
5671 --> server: localhost
5672 --> port: 42450
5673
5674 - terminate the application typing 'exit<enter>' or using 'CTRL+C'
5675 - events are created by a non-blank starting line and terminated by a blank line
5676
5677
5678 ws-simple-console: opened connection to APEX (Web Socket Protocol Handshake)
5679
5680Send Events
a.sreekumarcf3ff822020-09-16 13:12:29 +01005681***********
ramverma3b71c972019-07-10 11:25:37 +00005682
5683 .. container:: paragraph
5684
5685 Now you have the full system up and running:
5686
5687 .. container:: ulist
5688
5689 - Terminal 1: APEX ready and loaded
5690
5691 - Terminal 2: an echo client, printing received messages produced
5692 by the VPN policy
5693
5694 - Terminal 2: a console client, waiting for input on the console
5695 (standard in) and sending text to APEX
5696
5697 .. container:: paragraph
5698
5699 We started the engine with the VPN policy example. So all the
5700 events we are using now are located in files in the following
5701 example directory:
5702
5703 .. container:: listingblock
5704
5705 .. container:: content
5706
ramverma760cce92019-07-11 12:57:49 +00005707 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005708 :number-lines:
5709
5710 #: $APEX_HOME/examples/events/VPN
5711 > %APEX_HOME%\examples\events\VPN
5712
5713.. container:: paragraph
5714
5715 To sends events, simply copy the content of the event files into
5716 Terminal 3 (the console client). It will read multi-line JSON text
5717 and send the events. So copy the content of ``SetupEvents.json`` into
5718 the client. APEX will trigger a policy and produce some output, the
5719 echo client will also print some events created in the policy. In
5720 Terminal 1 (APEX) you’ll see some status messages from the policy as:
5721
5722.. container:: listingblock
5723
5724 .. container:: content
5725
ramverma760cce92019-07-11 12:57:49 +00005726 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005727 :number-lines:
5728
5729 {Link=L09, LinkUp=true}
5730 L09 true
5731 outFields: {Link=L09, LinkUp=true}
5732 {Link=L10, LinkUp=true}
5733 L09 true
5734 L10 true
5735 outFields: {Link=L10, LinkUp=true}
5736 {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5737 *** Customers ***
5738 C 300 300 [L09, L10]
5739 outFields: {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5740 {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5741 *** Customers ***
5742 A 300 50 [L09, L10]
5743 C 300 300 [L09, L10]
5744 outFields: {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5745 {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5746 *** Customers ***
5747 A 300 50 [L09, L10]
5748 C 300 300 [L09, L10]
5749 D 300 400 [L09, L10]
5750 outFields: {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5751 {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5752 *** Customers ***
5753 A 300 50 [L09, L10]
5754 B 300 299 [L09, L10]
5755 C 300 300 [L09, L10]
5756 D 300 400 [L09, L10]
5757 outFields: {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5758
5759.. container:: paragraph
5760
5761 In Terminal 2 (echo-client) you see the received events, the last two
5762 should look like:
5763
5764.. container:: listingblock
5765
5766 .. container:: content
5767
ramverma760cce92019-07-11 12:57:49 +00005768 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005769 :number-lines:
5770
5771 ws-simple-echo: received
5772 ---------------------------------
5773 {
5774 "name": "VPNCustomerCtxtActEvent",
5775 "version": "0.0.1",
5776 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5777 "source": "Source",
5778 "target": "Target",
5779 "CustomerName": "C",
5780 "LinkList": "L09 L10",
5781 "SlaDT": 300,
5782 "YtdDT": 300
5783 }
5784 =================================
5785
5786 ws-simple-echo: received
5787 ---------------------------------
5788 {
5789 "name": "VPNCustomerCtxtActEvent",
5790 "version": "0.0.1",
5791 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5792 "source": "Source",
5793 "target": "Target",
5794 "CustomerName": "D",
5795 "LinkList": "L09 L10",
5796 "SlaDT": 300,
5797 "YtdDT": 400
5798 }
5799 =================================
5800
5801.. container:: paragraph
5802
5803 Congratulations, you have triggered a policy in APEX using
5804 Websockets, the policy did run through, created events, picked up by
5805 the echo-client.
5806
5807.. container:: paragraph
5808
5809 Now you can send the Link 09 and Link 10 events, they will trigger
5810 the actual VPN policy and some calculations are made. Let’s take the
5811 Link 09 events from ``Link09Events.json``, copy them all into
5812 Terminal 3 (the console). APEX will run the policy (with some status
5813 output), and the echo client will receive and print events.
5814
5815.. container:: paragraph
5816
5817 To terminate the applications, simply press ``CTRL+C`` in Terminal 1
5818 (APEX). This will also terminate the echo-client in Terminal 2. Then
5819 type ``exit<enter>`` in Terminal 3 (or ``CTRL+C``) to terminate the
5820 console-client.
5821
5822.. container::
5823 :name: footer
5824
5825 .. container::
5826 :name: footer-text