blob: 75032466ee40180d99cfbccbadba9c6bbf007f8d [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)
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002583 "kafkaProperties": [ (11)
2584 [
2585 "security.protocol",
2586 "SASL_SSL"
2587 ],
2588 [
2589 "ssl.truststore.type",
2590 "JKS"
2591 ],
2592 [
2593 "ssl.truststore.location",
2594 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2595 ],
2596 [
2597 "ssl.truststore.password",
2598 "policy0nap"
2599 ],
2600 [
2601 "sasl.mechanism",
2602 "SCRAM-SHA-512"
2603 ],
2604 [
2605 "sasl.jaas.config",
2606 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2607 ],
2608 [
2609 "ssl.endpoint.identification.algorithm",
2610 ""
2611 ]
2612 ]
ramverma3b71c972019-07-10 11:25:37 +00002613 }
2614 }
2615
2616 .. container:: colist arabic
2617
2618 +--------+-------------------------------------+
2619 | **1** | set Kafka as carrier technology |
2620 +--------+-------------------------------------+
2621 | **2** | bootstrap server and port |
2622 +--------+-------------------------------------+
2623 | **3** | a group identifier |
2624 +--------+-------------------------------------+
2625 | **4** | flag for auto-commit |
2626 +--------+-------------------------------------+
2627 | **5** | auto-commit timeout in milliseconds |
2628 +--------+-------------------------------------+
2629 | **6** | session timeout in milliseconds |
2630 +--------+-------------------------------------+
2631 | **7** | consumer poll time in milliseconds |
2632 +--------+-------------------------------------+
2633 | **8** | consumer topic list |
2634 +--------+-------------------------------------+
2635 | **9** | key for the Kafka de-serializer |
2636 +--------+-------------------------------------+
2637 | **10** | value for the Kafka de-serializer |
2638 +--------+-------------------------------------+
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002639 | **11** | properties for Kafka connectivity |
2640 +--------+-------------------------------------+
2641
2642 .. container:: paragraph
2643
2644 Kindly note that the above Kafka properties is just a reference,
2645 and the actual properties required depends on the Kafka server installation.
ramverma3b71c972019-07-10 11:25:37 +00002646
2647Kafka Output
2648============
2649 .. container:: paragraph
2650
2651 APEX will send events to the Apache Kafka messaging
2652 system. The output is uni-directional, an engine will
2653 send events to the output but not receive any event
2654 from the output.
2655
2656 .. container:: listingblock
2657
2658 .. container:: content
2659
ramverma760cce92019-07-11 12:57:49 +00002660 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002661
2662 "carrierTechnologyParameters" : {
2663 "carrierTechnology" : "KAFKA", (1)
2664 "parameterClassName" :
2665 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2666 "parameters" : {
2667 "bootstrapServers" : "localhost:49092", (2)
2668 "acks" : "all", (3)
2669 "retries" : 0, (4)
2670 "batchSize" : 16384, (5)
2671 "lingerTime" : 1, (6)
2672 "bufferMemory" : 33554432, (7)
2673 "producerTopic" : "apex-out", (8)
2674 "keySerializer" :
2675 "org.apache.kafka.common.serialization.StringSerializer", (9)
2676 "valueSerializer" :
2677 "org.apache.kafka.common.serialization.StringSerializer" (10)
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002678 "kafkaProperties": [ (11)
2679 [
2680 "security.protocol",
2681 "SASL_SSL"
2682 ],
2683 [
2684 "ssl.truststore.type",
2685 "JKS"
2686 ],
2687 [
2688 "ssl.truststore.location",
2689 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2690 ],
2691 [
2692 "ssl.truststore.password",
2693 "policy0nap"
2694 ],
2695 [
2696 "sasl.mechanism",
2697 "SCRAM-SHA-512"
2698 ],
2699 [
2700 "sasl.jaas.config",
2701 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2702 ],
2703 [
2704 "ssl.endpoint.identification.algorithm",
2705 ""
2706 ]
2707 ]
ramverma3b71c972019-07-10 11:25:37 +00002708 }
2709 }
2710
2711 .. container:: colist arabic
2712
Ram Krishna Verma508fe1a2021-05-20 16:22:44 -04002713 +--------+-----------------------------------+
2714 | **1** | set Kafka as carrier technology |
2715 +--------+-----------------------------------+
2716 | **2** | bootstrap server and port |
2717 +--------+-----------------------------------+
2718 | **3** | acknowledgement strategy |
2719 +--------+-----------------------------------+
2720 | **4** | number of retries |
2721 +--------+-----------------------------------+
2722 | **5** | batch size |
2723 +--------+-----------------------------------+
2724 | **6** | time to linger in milliseconds |
2725 +--------+-----------------------------------+
2726 | **7** | buffer memory in byte |
2727 +--------+-----------------------------------+
2728 | **8** | producer topic |
2729 +--------+-----------------------------------+
2730 | **9** | key for the Kafka serializer |
2731 +--------+-----------------------------------+
2732 | **10** | value for the Kafka serializer |
2733 +--------+-----------------------------------+
2734 | **11** | properties for Kafka connectivity |
2735 +--------+-----------------------------------+
2736
2737 .. container:: paragraph
2738
2739 Kindly note that the above Kafka properties is just a reference,
2740 and the actual properties required depends on the Kafka server installation.
ramverma3b71c972019-07-10 11:25:37 +00002741
2742JMS IO
liamfallonb621de42020-08-21 12:59:26 +01002743######
ramverma3b71c972019-07-10 11:25:37 +00002744
2745 .. container:: paragraph
2746
2747 APEX supports the Java Messaging Service (JMS) as input
2748 as well as output. JMS IO is supported by the APEX JMS
2749 plugin. Input and output support an event encoding as
2750 text (JSON string) or object (serialized object). The
2751 input configuration is the same for both encodings, the
2752 output configuration differs.
2753
2754JMS Input
2755=========
2756 .. container:: paragraph
2757
2758 APEX will receive events from a JMS messaging system.
2759 The input is uni-directional, an engine will only
2760 receive events from the input but not send any event
2761 to the input.
2762
2763 .. container:: listingblock
2764
2765 .. container:: content
2766
ramverma760cce92019-07-11 12:57:49 +00002767 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002768
2769 "carrierTechnologyParameters" : {
2770 "carrierTechnology" : "JMS", (1)
2771 "parameterClassName" :
2772 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2773 "parameters" : { (2)
2774 "initialContextFactory" :
2775 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2776 "connectionFactory" : "ConnectionFactory", (4)
2777 "providerURL" : "remote://localhost:5445", (5)
2778 "securityPrincipal" : "guest", (6)
2779 "securityCredentials" : "IAmAGuest", (7)
2780 "consumerTopic" : "jms/topic/apexIn" (8)
2781 }
2782 }
2783
2784 .. container:: colist arabic
2785
2786 +-----------------------------------+-----------------------------------+
2787 | **1** | set JMS as carrier technology |
2788 +-----------------------------------+-----------------------------------+
2789 | **2** | set all JMS specific parameters |
2790 +-----------------------------------+-----------------------------------+
2791 | **3** | the context factory, in this case |
2792 | | from JBOSS (it requires the |
2793 | | dependency |
2794 | | org.jboss:jboss-remote-naming:2.0 |
2795 | | .4.Final |
2796 | | or a different version to be in |
2797 | | the directory ``$APEX_HOME/lib`` |
2798 | | or ``%APEX_HOME%\lib`` |
2799 +-----------------------------------+-----------------------------------+
2800 | **4** | a connection factory for the JMS |
2801 | | connection |
2802 +-----------------------------------+-----------------------------------+
2803 | **5** | URL with host and port of the JMS |
2804 | | provider |
2805 +-----------------------------------+-----------------------------------+
2806 | **6** | access credentials, user name |
2807 +-----------------------------------+-----------------------------------+
2808 | **7** | access credentials, user password |
2809 +-----------------------------------+-----------------------------------+
2810 | **8** | the JMS topic to listen to |
2811 +-----------------------------------+-----------------------------------+
2812
2813JMS Output with Text
2814====================
2815
2816 .. container:: paragraph
2817
2818 APEX engine send events to a JMS messaging system. The
2819 output is uni-directional, an engine will send events
2820 to the output but not receive any event from output.
2821
2822 .. container:: listingblock
2823
2824 .. container:: content
2825
ramverma760cce92019-07-11 12:57:49 +00002826 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002827
2828 "carrierTechnologyParameters" : {
2829 "carrierTechnology" : "JMS", (1)
2830 "parameterClassName" :
2831 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2832 "parameters" : { (2)
2833 "initialContextFactory" :
2834 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2835 "connectionFactory" : "ConnectionFactory", (4)
2836 "providerURL" : "remote://localhost:5445", (5)
2837 "securityPrincipal" : "guest", (6)
2838 "securityCredentials" : "IAmAGuest", (7)
2839 "producerTopic" : "jms/topic/apexOut", (8)
2840 "objectMessageSending": "false" (9)
2841 }
2842 }
2843
2844 .. container:: colist arabic
2845
2846 +-----------------------------------+-----------------------------------+
2847 | **1** | set JMS as carrier technology |
2848 +-----------------------------------+-----------------------------------+
2849 | **2** | set all JMS specific parameters |
2850 +-----------------------------------+-----------------------------------+
2851 | **3** | the context factory, in this case |
2852 | | from JBOSS (it requires the |
2853 | | dependency |
2854 | | org.jboss:jboss-remote-naming:2.0 |
2855 | | .4.Final |
2856 | | or a different version to be in |
2857 | | the directory ``$APEX_HOME/lib`` |
2858 | | or ``%APEX_HOME%\lib`` |
2859 +-----------------------------------+-----------------------------------+
2860 | **4** | a connection factory for the JMS |
2861 | | connection |
2862 +-----------------------------------+-----------------------------------+
2863 | **5** | URL with host and port of the JMS |
2864 | | provider |
2865 +-----------------------------------+-----------------------------------+
2866 | **6** | access credentials, user name |
2867 +-----------------------------------+-----------------------------------+
2868 | **7** | access credentials, user password |
2869 +-----------------------------------+-----------------------------------+
2870 | **8** | the JMS topic to write to |
2871 +-----------------------------------+-----------------------------------+
2872 | **9** | set object messaging to ``false`` |
2873 | | means it sends JSON text |
2874 +-----------------------------------+-----------------------------------+
2875
2876JMS Output with Object
2877======================
2878
2879 .. container:: paragraph
2880
2881 To configure APEX for JMS objects on the output
2882 interface use the same configuration as above (for
2883 output). Simply change the ``objectMessageSending``
2884 parameter to ``true``.
2885
2886Websocket (WS) IO
liamfallonb621de42020-08-21 12:59:26 +01002887#################
ramverma3b71c972019-07-10 11:25:37 +00002888
2889 .. container:: paragraph
2890
2891 APEX supports the Websockets as input as well as output.
2892 WS IO is supported by the APEX Websocket plugin. This
2893 carrier technology does only support uni-directional
2894 communication. APEX will not send events to a Websocket
2895 input and any event sent to a Websocket output will
2896 result in an error log.
2897
2898 .. container:: paragraph
2899
2900 The input can be configured as client (APEX connects to
2901 an existing Websocket server) or server (APEX starts a
2902 Websocket server). The same applies to the output. Input
2903 and output can both use a client or a server
2904 configuration, or separate configurations (input as
2905 client and output as server, input as server and output
2906 as client). Each configuration should use its own
2907 dedicated port to avoid any communication loops. The
2908 configuration of a Websocket client is the same for input
2909 and output. The configuration of a Websocket server is
2910 the same for input and output.
2911
2912Websocket Client
2913================
2914
2915 .. container:: paragraph
2916
2917 APEX will connect to a given Websocket server. As
2918 input, it will receive events from the server but not
2919 send any events. As output, it will send events to the
2920 server and any event received from the server will
2921 result in an error log.
2922
2923 .. container:: listingblock
2924
2925 .. container:: content
2926
ramverma760cce92019-07-11 12:57:49 +00002927 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002928
2929 "carrierTechnologyParameters" : {
2930 "carrierTechnology" : "WEBSOCKET", (1)
2931 "parameterClassName" :
2932 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2933 "parameters" : {
2934 "host" : "localhost", (2)
2935 "port" : 42451 (3)
2936 }
2937 }
2938
2939 .. container:: colist arabic
2940
2941 +-------+------------------------------------------------------+
2942 | **1** | set Websocket as carrier technology |
2943 +-------+------------------------------------------------------+
2944 | **2** | the host name on which a Websocket server is running |
2945 +-------+------------------------------------------------------+
2946 | **3** | the port of that Websocket server |
2947 +-------+------------------------------------------------------+
2948
2949Websocket Server
2950================
2951
2952 .. container:: paragraph
2953
2954 APEX will start a Websocket server, which will accept
2955 any Websocket clients to connect. As input, it will
2956 receive events from the server but not send any
2957 events. As output, it will send events to the server
2958 and any event received from the server will result in
2959 an error log.
2960
2961 .. container:: listingblock
2962
2963 .. container:: content
2964
ramverma760cce92019-07-11 12:57:49 +00002965 .. code::
ramverma3b71c972019-07-10 11:25:37 +00002966
2967 "carrierTechnologyParameters" : {
2968 "carrierTechnology" : "WEBSOCKET", (1)
2969 "parameterClassName" :
2970 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2971 "parameters" : {
2972 "wsClient" : false, (2)
2973 "port" : 42450 (3)
2974 }
2975 }
2976
2977 .. container:: colist arabic
2978
2979 +-------+------------------------------------------------------------+
2980 | **1** | set Websocket as carrier technology |
2981 +-------+------------------------------------------------------------+
2982 | **2** | disable client, so that APEX will start a Websocket server |
2983 +-------+------------------------------------------------------------+
2984 | **3** | the port for the Websocket server APEX will start |
2985 +-------+------------------------------------------------------------+
2986
2987REST Client IO
2988##############
2989
2990 .. container:: paragraph
2991
2992 APEX can act as REST client on the input as well as on
2993 the output interface. The media type is
a.sreekumarcc0e9172020-03-16 13:36:45 +00002994 ``application/json``, so this plugin only works with
ramverma3b71c972019-07-10 11:25:37 +00002995 the JSON Event protocol.
2996
2997REST Client Input
2998=================
2999
3000 .. container:: paragraph
3001
3002 APEX will connect to a given URL to receive events,
3003 but not send any events. The server is polled, i.e.
3004 APEX will do an HTTP GET, take the result, and then do
3005 the next GET. Any required timing needs to be handled
3006 by the server configured via the URL. For instance,
3007 the server could support a wait timeout via the URL as
3008 ``?timeout=100ms``.
Henry.Sun2941bc02019-07-22 08:32:32 +00003009 The httpCodeFilter is used for filtering the status
3010 code, and it can be configured as a regular expression
3011 string. The default httpCodeFilter is "[2][0-9][0-9]"
3012 - for successful response codes.
3013 The response with HTTP status code that matches the
3014 given regular expression is forwarded to the task,
3015 otherwise it is logged as a failure.
ramverma3b71c972019-07-10 11:25:37 +00003016
3017 .. container:: listingblock
3018
3019 .. container:: content
3020
ramverma760cce92019-07-11 12:57:49 +00003021 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003022
3023 "carrierTechnologyParameters" : {
3024 "carrierTechnology" : "RESTCLIENT", (1)
3025 "parameterClassName" :
3026 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3027 "parameters" : {
3028 "url" : "http://example.org:8080/triggers/events", (2)
liamfallon75e2bbf2020-07-06 11:41:38 +01003029 "httpMethod": "GET", (3)
3030 "httpCodeFilter" : "[2][0-9][0-9]", (4)
3031 "httpHeaders" : [ (5)
3032 ["Keep-Alive", "300"],
3033 ["Cache-Control", "no-cache"]
3034 ]
ramverma3b71c972019-07-10 11:25:37 +00003035 }
3036 }
3037
3038 .. container:: colist arabic
3039
Henry.Sun2941bc02019-07-22 08:32:32 +00003040 +-------+--------------------------------------------------+
3041 | **1** | set REST client as carrier technology |
3042 +-------+--------------------------------------------------+
3043 | **2** | the URL of the HTTP server for events |
3044 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003045 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3046 | | optional, defaults to GET |
3047 +-------+--------------------------------------------------+
3048 | **4** | use HTTP CODE FILTER for filtering status code, |
3049 | | optional, defaults to [2][0-9][0-9] |
3050 +-------+--------------------------------------------------+
3051 | **5** | HTTP headers to use on the REST request, |
3052 | | optional |
Henry.Sun2941bc02019-07-22 08:32:32 +00003053 +-------+--------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003054
3055REST Client Output
3056==================
3057
3058 .. container:: paragraph
3059
3060 APEX will connect to a given URL to send events, but
3061 not receive any events. The default HTTP operation is
3062 POST (no configuration required). To change it to PUT
3063 simply add the configuration parameter (as shown in
3064 the example below).
ning.xi8bc537d2019-07-18 07:50:10 +00003065 The URL can be configured statically or tagged
3066 as ``?example.{site}.org:8080/{trig}/events``,
3067 all tags such as ``site`` and ``trig`` in the URL
Henry.Sun2941bc02019-07-22 08:32:32 +00003068 need to be set in the properties object available to
3069 the tasks. In addition, the keys should exactly match
3070 with the tags defined in url. The scope of the properties
3071 object is per HTTP call. Hence, key/value pairs set
3072 in the properties object by task are only available
3073 for that specific HTTP call.
ramverma3b71c972019-07-10 11:25:37 +00003074
3075 .. container:: listingblock
3076
3077 .. container:: content
3078
ramverma760cce92019-07-11 12:57:49 +00003079 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003080
3081 "carrierTechnologyParameters" : {
3082 "carrierTechnology" : "RESTCLIENT", (1)
3083 "parameterClassName" :
3084 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3085 "parameters" : {
3086 "url" : "http://example.com:8888/actions/events", (2)
ning.xi8bc537d2019-07-18 07:50:10 +00003087 "url" : "http://example.{site}.com:8888/{trig}/events", (2')
liamfallon75e2bbf2020-07-06 11:41:38 +01003088 "httpMethod" : "PUT". (3)
3089 "httpHeaders" : [ (4)
3090 ["Keep-Alive", "300"],
3091 ["Cache-Control", "no-cache"]
3092 ] }
ramverma3b71c972019-07-10 11:25:37 +00003093 }
3094
3095 .. container:: colist arabic
3096
3097 +-------+--------------------------------------------------+
3098 | **1** | set REST client as carrier technology |
3099 +-------+--------------------------------------------------+
ning.xi8bc537d2019-07-18 07:50:10 +00003100 | **2** | the static URL of the HTTP server for events |
3101 +-------+--------------------------------------------------+
3102 | **2'**| the tagged URL of the HTTP server for events |
ramverma3b71c972019-07-10 11:25:37 +00003103 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003104 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3105 | | optional, defaults to POST |
3106 +-------+--------------------------------------------------+
3107 | **4** | HTTP headers to use on the REST request, |
3108 | | optional |
ramverma3b71c972019-07-10 11:25:37 +00003109 +-------+--------------------------------------------------+
3110
3111REST Server IO
3112##############
3113
3114 .. container:: paragraph
3115
3116 APEX supports a REST server for input and output.
3117
3118 .. container:: paragraph
3119
3120 The REST server plugin always uses a synchronous mode. A
3121 client does a HTTP GET on the APEX REST server with the
3122 input event and receives the generated output event in
3123 the server reply. This means that for the REST server
3124 there has to always to be an input with an associated
3125 output. Input or output only are not permitted.
3126
3127 .. container:: paragraph
3128
3129 The plugin will start a Grizzly server as REST server for
3130 a normal APEX engine. If the APEX engine is executed as a
3131 servlet, for instance inside Tomcat, then Tomcat will be
3132 used as REST server (this case requires configuration on
3133 Tomcat as well).
3134
3135 .. container:: paragraph
3136
3137 Some configuration restrictions apply for all scenarios:
3138
3139 .. container:: ulist
3140
3141 - Minimum port: 1024
3142
3143 - Maximum port: 65535
3144
3145 - The media type is ``application/json``, so this plugin
a.sreekumarcc0e9172020-03-16 13:36:45 +00003146 only works with the JSON Event protocol.
ramverma3b71c972019-07-10 11:25:37 +00003147
3148 .. container:: paragraph
3149
3150 The URL the client calls is created using
3151
3152 .. container:: ulist
3153
3154 - the configured host and port, e.g.
3155 ``http://localhost:12345``
3156
3157 - the standard path, e.g. ``/apex/``
3158
3159 - the name of the input/output, e.g. ``FirstConsumer/``
3160
3161 - the input or output name, e.g. ``EventIn``.
3162
3163 .. container:: paragraph
3164
3165 The examples above lead to the URL
3166 ``http://localhost:12345/apex/FirstConsumer/EventIn``.
3167
3168 .. container:: paragraph
3169
3170 A client can also get status information of the REST
3171 server using ``/Status``, e.g.
3172 ``http://localhost:12345/apex/FirstConsumer/Status``.
3173
3174REST Server Stand-alone
3175=======================
3176
3177 .. container:: paragraph
3178
3179 We need to configure a REST server input and a REST
3180 server output. Input and output are associated with
3181 each other via there name.
3182
3183 .. container:: paragraph
3184
3185 Timeouts for REST calls need to be set carefully. If
3186 they are too short, the call might timeout before a
3187 policy finished creating an event.
3188
3189 .. container:: paragraph
3190
3191 The following example configures the input named as
3192 ``MyConsumer`` and associates an output named
3193 ``MyProducer`` with it.
3194
3195 .. container:: listingblock
3196
3197 .. container:: content
3198
ramverma760cce92019-07-11 12:57:49 +00003199 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003200
3201 "eventInputParameters": {
3202 "MyConsumer": {
3203 "carrierTechnologyParameters" : {
3204 "carrierTechnology" : "RESTSERVER", (1)
3205 "parameterClassName" :
3206 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters",
3207 "parameters" : {
3208 "standalone" : true, (2)
3209 "host" : "localhost", (3)
3210 "port" : 12345 (4)
3211 }
3212 },
3213 "eventProtocolParameters":{
3214 "eventProtocol" : "JSON" (5)
3215 },
3216 "synchronousMode" : true, (6)
3217 "synchronousPeer" : "MyProducer", (7)
3218 "synchronousTimeout" : 500 (8)
3219 }
3220 }
3221
3222 .. container:: colist arabic
3223
3224 +-------+---------------------------------------+
3225 | **1** | set REST server as carrier technology |
3226 +-------+---------------------------------------+
3227 | **2** | set the server as stand-alone |
3228 +-------+---------------------------------------+
3229 | **3** | set the server host |
3230 +-------+---------------------------------------+
3231 | **4** | set the server listen port |
3232 +-------+---------------------------------------+
3233 | **5** | use JSON event protocol |
3234 +-------+---------------------------------------+
3235 | **6** | activate synchronous mode |
3236 +-------+---------------------------------------+
3237 | **7** | associate an output ``MyProducer`` |
3238 +-------+---------------------------------------+
3239 | **8** | set a timeout of 500 milliseconds |
3240 +-------+---------------------------------------+
3241
3242 .. container:: paragraph
3243
3244 The following example configures the output named as
3245 ``MyProducer`` and associates the input ``MyConsumer``
3246 with it. Note that for the output there are no more
3247 paramters (such as host or port), since they are
3248 already configured in the associated input
3249
3250 .. container:: listingblock
3251
3252 .. container:: content
3253
ramverma760cce92019-07-11 12:57:49 +00003254 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003255
3256 "eventOutputParameters": {
3257 "MyProducer": {
3258 "carrierTechnologyParameters":{
3259 "carrierTechnology" : "RESTSERVER",
3260 "parameterClassName" :
3261 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters"
3262 },
3263 "eventProtocolParameters":{
3264 "eventProtocol" : "JSON"
3265 },
3266 "synchronousMode" : true,
3267 "synchronousPeer" : "MyConsumer",
3268 "synchronousTimeout" : 500
3269 }
3270 }
3271
3272REST Server Stand-alone, multi input
3273====================================
3274
3275 .. container:: paragraph
3276
3277 Any number of input/output pairs for REST servers can
3278 be configured. For instance, we can configure an input
3279 ``FirstConsumer`` with output ``FirstProducer`` and an
3280 input ``SecondConsumer`` with output
3281 ``SecondProducer``. Important is that there is always
3282 one pair of input/output.
3283
3284REST Server Stand-alone in Servlet
3285==================================
3286
3287 .. container:: paragraph
3288
3289 If APEX is executed as a servlet, e.g. inside Tomcat,
3290 the configuration becomes easier since the plugin can
3291 now use Tomcat as the REST server. In this scenario,
3292 there are not parameters (port, host, etc.) and the
3293 key ``standalone`` must not be used (or set to false).
3294
3295 .. container:: paragraph
3296
3297 For the Tomcat configuration, we need to add the REST
3298 server plugin, e.g.
3299
3300 .. container:: listingblock
3301
3302 .. container:: content
3303
ramverma760cce92019-07-11 12:57:49 +00003304 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003305
3306 <servlet>
3307 ...
3308 <init-param>
3309 ...
3310 <param-value>org.onap.policy.apex.plugins.event.carrier.restserver</param-value>
3311 </init-param>
3312 ...
3313 </servlet>
3314
3315REST Requestor IO
liamfallonb621de42020-08-21 12:59:26 +01003316#################
ramverma3b71c972019-07-10 11:25:37 +00003317
3318 .. container:: paragraph
3319
3320 APEX can act as REST requestor on the input as well as on
3321 the output interface. The media type is
a.sreekumarcc0e9172020-03-16 13:36:45 +00003322 ``application/json``, so this plugin only works with
liamfallon75e2bbf2020-07-06 11:41:38 +01003323 the JSON Event protocol. This plugin allows APEX to send REST requests
3324 and to receive the reply of that request without tying up APEX resources
3325 while the request is being processed. The REST Requestor pairs a REST
3326 requestor producer and consumer together to handle the REST request
3327 and response. The REST request is created from an APEX output event
3328 and the REST response is input into APEX as a new input event.
ramverma3b71c972019-07-10 11:25:37 +00003329
liamfallon75e2bbf2020-07-06 11:41:38 +01003330REST Requestor Output (REST Request Producer)
3331=============================================
ramverma3b71c972019-07-10 11:25:37 +00003332
3333 .. container:: paragraph
3334
liamfallon75e2bbf2020-07-06 11:41:38 +01003335 APEX sends a REST request when events are output by APEX, the REST
3336 request configuration is specified on the REST Request Consumer (see
3337 below).
3338
3339 .. container:: listingblock
3340
3341 .. container:: content
3342
3343 .. code::
3344
3345 "carrierTechnologyParameters": {
3346 "carrierTechnology": "RESTREQUESTOR", (1)
3347 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
3348 },
3349
3350 .. container:: colist arabic
3351
3352 +-------+------------------------------------------+
3353 | **1** | set REST requestor as carrier technology |
3354 +-------+------------------------------------------+
3355
3356 .. container:: paragraph
3357
3358 The settings below are required on the producer to
3359 define the event that triggers the REST request and
3360 to specify the peered consumer configuration for the
3361 REST request, for example:
3362
3363 .. container:: listingblock
3364
3365 .. container:: content
3366
3367 .. code::
3368
3369 "eventNameFilter": "GuardRequestEvent", (1)
3370 "requestorMode": true, (2)
3371 "requestorPeer": "GuardRequestorConsumer", (3)
3372 "requestorTimeout": 500 (4)
3373
3374 .. container:: colist arabic
3375
3376 +-------+-------------------------------------------+
3377 | **1** | a filter on the event |
3378 +-------+-------------------------------------------+
3379 | **2** | requestor mode must be set to *true* |
3380 +-------+-------------------------------------------+
3381 | **3** | the peered consumer for REST requests, |
3382 | | that consumer specifies the full |
3383 | | configuration for REST requests |
3384 +-------+-------------------------------------------+
3385 | **4** | the request timeout in milliseconds, |
3386 | | overridden by timeout on consumer if that |
3387 | | is set, optional defaults to 500 |
3388 | | millisconds |
3389 +-------+-------------------------------------------+
3390
3391REST Requestor Input (REST Request Consumer)
3392============================================
3393
3394 .. container:: paragraph
3395
3396 APEX will connect to a given URL to issue a REST request and
3397 wait for a REST response.
ning.xi8bc537d2019-07-18 07:50:10 +00003398 The URL can be configured statically or tagged
3399 as ``?example.{site}.org:8080/{trig}/events``,
3400 all tags such as ``site`` and ``trig`` in the URL
Henry.Sun2941bc02019-07-22 08:32:32 +00003401 need to be set in the properties object available to
3402 the tasks. In addition, the keys should exactly match
3403 with the tags defined in url. The scope of the properties
3404 object is per HTTP call. Hence, key/value pairs set
3405 in the properties object by task are only available
3406 for that specific HTTP call.
3407 The httpCodeFilter is used for filtering the status
3408 code, and it can be configured as a regular expression
3409 string. The default httpCodeFilter is "[2][0-9][0-9]"
3410 - for successful response codes.
3411 The response with HTTP status code that matches the
3412 given regular expression is forwarded to the task,
3413 otherwise it is logged as a failure.
ramverma3b71c972019-07-10 11:25:37 +00003414
3415 .. container:: listingblock
3416
3417 .. container:: content
3418
ramverma760cce92019-07-11 12:57:49 +00003419 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003420
3421 "carrierTechnologyParameters": {
3422 "carrierTechnology": "RESTREQUESTOR", (1)
3423 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
3424 "parameters": {
3425 "url": "http://localhost:54321/some/path/to/rest/resource", (2)
ning.xi8bc537d2019-07-18 07:50:10 +00003426 "url": "http://localhost:54321/{site}/path/to/rest/{resValue}", (2')
ramverma3b71c972019-07-10 11:25:37 +00003427 "httpMethod": "POST", (3)
liamfallon75e2bbf2020-07-06 11:41:38 +01003428 "requestorMode": true, (4)
3429 "requestorPeer": "GuardRequestorProducer", (5)
3430 "restRequestTimeout": 2000, (6)
3431 "httpCodeFilter" : "[2][0-9][0-9]" (7)
3432 "httpHeaders" : [ (8)
3433 ["Keep-Alive", "300"],
3434 ["Cache-Control", "no-cache"]
3435 ] }
ramverma3b71c972019-07-10 11:25:37 +00003436 },
3437
3438 .. container:: colist arabic
3439
3440 +-------+--------------------------------------------------+
3441 | **1** | set REST requestor as carrier technology |
3442 +-------+--------------------------------------------------+
ning.xi8bc537d2019-07-18 07:50:10 +00003443 | **2** | the static URL of the HTTP server for events |
3444 +-------+--------------------------------------------------+
3445 | **2'**| the tagged URL of the HTTP server for events |
ramverma3b71c972019-07-10 11:25:37 +00003446 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003447 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3448 | | optional, defaults to GET |
ramverma3b71c972019-07-10 11:25:37 +00003449 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003450 | **4** | requestor mode must be set to *true* |
ramverma3b71c972019-07-10 11:25:37 +00003451 +-------+--------------------------------------------------+
liamfallon75e2bbf2020-07-06 11:41:38 +01003452 | **5** | the peered producer for REST requests, that |
3453 | | producer specifies the APEX output event that |
3454 | | triggers the REST request |
3455 +-------+--------------------------------------------------+
3456 | **6** | request timeout in milliseconds, overrides any |
3457 | | value set in the REST Requestor Producer, |
3458 | | optional, defaults to 500 millisconds |
3459 +-------+--------------------------------------------------+
3460 | **7** | use HTTP CODE FILTER for filtering status code |
3461 | | optional, defaults to [2][0-9][0-9] |
3462 +-------+--------------------------------------------------+
3463 | **8** | HTTP headers to use on the REST request, |
3464 | | optional |
Henry.Sun2941bc02019-07-22 08:32:32 +00003465 +-------+--------------------------------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003466
3467 .. container:: paragraph
3468
liamfallon75e2bbf2020-07-06 11:41:38 +01003469 Further settings may be required on the consumer to
3470 define the input event that is produced and forwarded into
3471 APEX, for example:
ramverma3b71c972019-07-10 11:25:37 +00003472
3473 .. container:: listingblock
3474
3475 .. container:: content
3476
ramverma760cce92019-07-11 12:57:49 +00003477 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003478
3479 "eventName": "GuardResponseEvent", (1)
liamfallon75e2bbf2020-07-06 11:41:38 +01003480 "eventNameFilter": "GuardResponseEvent" (2)
ramverma3b71c972019-07-10 11:25:37 +00003481
3482 .. container:: colist arabic
3483
3484 +-------+---------------------------+
3485 | **1** | the event name |
3486 +-------+---------------------------+
3487 | **2** | a filter on the event |
3488 +-------+---------------------------+
ramverma3b71c972019-07-10 11:25:37 +00003489
a.sreekumarcc0e9172020-03-16 13:36:45 +00003490gRPC IO
3491#######
3492
3493 .. container:: paragraph
3494
3495 APEX can send requests over gRPC at the output side, and get back
3496 response at the input side. This can be used to send requests to CDS
3497 over gRPC. The media type is ``application/json``, so this plugin
3498 only works with the JSON Event protocol.
3499
3500gRPC Output
3501===========
3502
3503 .. container:: paragraph
3504
3505 APEX will connect to a given host to send a request over
3506 gRPC.
3507
3508 .. container:: listingblock
3509
3510 .. container:: content
3511
3512 .. code::
3513
3514 "carrierTechnologyParameters": {
3515 "carrierTechnology": "GRPC", (1)
3516 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
3517 "parameters": {
3518 "host": "cds-blueprints-processor-grpc", (2)
3519 "port": 9111, (2')
3520 "username": "ccsdkapps", (3)
3521 "password": ccsdkapps, (4)
3522 "timeout" : 10 (5)
3523 }
3524 },
3525
3526 .. container:: colist arabic
3527
3528 +-------+--------------------------------------------------+
3529 | **1** | set GRPC as carrier technology |
3530 +-------+--------------------------------------------------+
3531 | **2** | the host to which request is sent |
3532 +-------+--------------------------------------------------+
3533 | **2'**| the value for port |
3534 +-------+--------------------------------------------------+
3535 | **3** | username required to initiate connection |
3536 +-------+--------------------------------------------------+
3537 | **4** | password required to initiate connection |
3538 +-------+--------------------------------------------------+
3539 | **5** | the timeout value for completing the request |
3540 +-------+--------------------------------------------------+
3541
3542 .. container:: paragraph
3543
3544 Further settings are required on the producer to
3545 define the event that is requested, for example:
3546
3547 .. container:: listingblock
3548
3549 .. container:: content
3550
3551 .. code::
3552
3553 "eventName": "GRPCRequestEvent", (1)
3554 "eventNameFilter": "GRPCRequestEvent", (2)
3555 "requestorMode": true, (3)
3556 "requestorPeer": "GRPCRequestConsumer", (4)
3557 "requestorTimeout": 500 (5)
3558
3559 .. container:: colist arabic
3560
3561 +-------+---------------------------+
3562 | **1** | the event name |
3563 +-------+---------------------------+
3564 | **2** | a filter on the event |
3565 +-------+---------------------------+
3566 | **3** | the mode of the requestor |
3567 +-------+---------------------------+
3568 | **4** | a peer for the requestor |
3569 +-------+---------------------------+
3570 | **5** | a general request timeout |
3571 +-------+---------------------------+
3572
3573gRPC Input
3574==========
3575
3576 .. container:: paragraph
3577
3578 APEX will connect to the host specified in the producer
3579 side, anad take in response back at the consumer side.
3580
3581 .. container:: listingblock
3582
3583 .. container:: content
3584
3585 .. code::
3586
3587 "carrierTechnologyParameters": {
3588 "carrierTechnology": "GRPC", (1)
3589 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
3590 },
3591
3592 .. container:: colist arabic
3593
3594 +-------+------------------------------------------+
3595 | **1** | set GRPC as carrier technology |
3596 +-------+------------------------------------------+
3597
3598 .. container:: paragraph
3599
3600 Further settings are required on the consumer to
3601 define the event that is requested, for example:
3602
3603 .. container:: listingblock
3604
3605 .. container:: content
3606
3607 .. code::
3608
3609 "eventNameFilter": "GRPCResponseEvent", (1)
3610 "requestorMode": true, (2)
3611 "requestorPeer": "GRPCRequestProducer", (3)
3612 "requestorTimeout": 500 (4)
3613
3614 .. container:: colist arabic
3615
3616 +-------+---------------------------+
3617 | **1** | a filter on the event |
3618 +-------+---------------------------+
3619 | **2** | the mode of the requestor |
3620 +-------+---------------------------+
3621 | **3** | a peer for the requestor |
3622 +-------+---------------------------+
3623 | **4** | a general request timeout |
3624 +-------+---------------------------+
3625
ramverma3b71c972019-07-10 11:25:37 +00003626Event Protocols, Format and Encoding
3627------------------------------------
3628
3629 .. container:: paragraph
3630
3631 Event protocols define what event formats APEX can receive
3632 (input) and should send (output). They can be used in any
3633 combination for input and output, unless further restricted
3634 by a carrier technology plugin (for instance for JMS
3635 output). There can only be 1 event protocol per event
3636 plugin.
3637
3638 .. container:: paragraph
3639
3640 Supported *input* event protocols are:
3641
3642 .. container:: ulist
3643
3644 - JSON, the event as a JSON string
3645
3646 - APEX, an APEX event
3647
3648 - JMS object, the event as a JMS object,
3649
3650 - JMS text, the event as a JMS text,
3651
3652 - XML, the event as an XML string,
3653
3654 - YAML, the event as YAML text
3655
3656 .. container:: paragraph
3657
3658 Supported *output* event protocols are:
3659
3660 .. container:: ulist
3661
3662 - JSON, the event as a JSON string
3663
3664 - APEX, an APEX event
3665
3666 - JMS object, the event as a JMS object,
3667
3668 - JMS text, the event as a JMS text,
3669
3670 - XML, the event as an XML string,
3671
3672 - YAML, the event as YAML text
3673
3674 .. container:: paragraph
3675
3676 New event protocols can be added as plugins to APEX or
3677 developed outside APEX and added to an APEX deployment.
3678
3679JSON Event
3680##########
3681
3682 .. container:: paragraph
3683
3684 The event protocol for JSON encoding does not require a
3685 specific plugin, it is supported by default. Furthermore,
3686 there is no difference in the configuration for the input
3687 and output interface.
3688
3689 .. container:: paragraph
3690
3691 For an input, APEX requires a well-formed JSON string.
3692 Well-formed here means according to the definitions of a
3693 policy. Any JSON string that is not defined as a trigger
3694 event (consume) will not be consumed (errors will be
3695 thrown). For output JSON events, APEX will always produce
3696 valid JSON strings according to the definition in the
3697 policy model.
3698
3699 .. container:: paragraph
3700
3701 The following JSON shows the configuration.
3702
3703 .. container:: listingblock
3704
3705 .. container:: content
3706
ramverma760cce92019-07-11 12:57:49 +00003707 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003708
3709 "eventProtocolParameters":{
3710 "eventProtocol" : "JSON"
3711 }
3712
3713 .. container:: paragraph
3714
3715 For JSON events, there are a few more optional
3716 parameters, which allow to define a mapping for standard
3717 event fields. An APEX event must have the fields
3718 ``name``, ``version``, ``source``, and ``target``
3719 defined. Sometimes it is not possible to configure a
3720 trigger or actioning system to use those fields. However,
3721 they might be in an event generated outside APEX (or used
3722 outside APEX) just with different names. To configure
3723 APEX to map between the different event names, simply add
3724 the following parameters to a JSON event:
3725
3726 .. container:: listingblock
3727
3728 .. container:: content
3729
ramverma760cce92019-07-11 12:57:49 +00003730 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003731
3732 "eventProtocolParameters":{
3733 "eventProtocol" : "JSON",
3734 "nameAlias" : "policyName", (1)
3735 "versionAlias" : "policyVersion", (2)
3736 "sourceAlias" : "from", (3)
3737 "targetAlias" : "to", (4)
3738 "nameSpaceAlias": "my.name.space" (5)
3739 }
3740
3741 .. container:: colist arabic
3742
3743 +-----------------------------------+-----------------------------------+
3744 | **1** | mapping for the ``name`` field, |
3745 | | here from a field called |
3746 | | ``policyName`` |
3747 +-----------------------------------+-----------------------------------+
3748 | **2** | mapping for the ``version`` |
3749 | | field, here from a field called |
3750 | | ``policyVersion`` |
3751 +-----------------------------------+-----------------------------------+
3752 | **3** | mapping for the ``source`` field, |
3753 | | here from a field called ``from`` |
3754 | | (only for an input event) |
3755 +-----------------------------------+-----------------------------------+
3756 | **4** | mapping for the ``target`` field, |
3757 | | here from a field called ``to`` |
3758 | | (only for an output event) |
3759 +-----------------------------------+-----------------------------------+
3760 | **5** | mapping for the ``nameSpace`` |
3761 | | field, here from a field called |
3762 | | ``my.name.space`` |
3763 +-----------------------------------+-----------------------------------+
3764
3765APEX Event
3766##########
3767 .. container:: paragraph
3768
3769 The event protocol for APEX events does not require a
3770 specific plugin, it is supported by default. Furthermore,
3771 there is no difference in the configuration for the input
3772 and output interface.
3773
3774 .. container:: paragraph
3775
3776 For input and output APEX uses APEX events.
3777
3778 .. container:: paragraph
3779
3780 The following JSON shows the configuration.
3781
3782 .. container:: listingblock
3783
3784 .. container:: content
3785
ramverma760cce92019-07-11 12:57:49 +00003786 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003787
3788 "eventProtocolParameters":{
3789 "eventProtocol" : "APEX"
3790 }
3791
3792JMS Event
3793#########
3794
3795 .. container:: paragraph
3796
3797 The event protocol for JMS is provided by the APEX JMS
3798 plugin. The plugin supports encoding as JSON text or as
3799 object. There is no difference in the configuration for
3800 the input and output interface.
3801
3802JMS Text
3803========
3804 .. container:: paragraph
3805
3806 If used as input, APEX will take a JMS message and
3807 extract a JSON string, then proceed as if a JSON event
3808 was received. If used as output, APEX will take the
3809 event produced by a policy, create a JSON string, and
3810 then wrap it into a JMS message.
3811
3812 .. container:: paragraph
3813
3814 The configuration for JMS text is as follows:
3815
3816 .. container:: listingblock
3817
3818 .. container:: content
3819
ramverma760cce92019-07-11 12:57:49 +00003820 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003821
3822 "eventProtocolParameters":{
3823 "eventProtocol" : "JMSTEXT",
3824 "parameterClassName" :
3825 "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters"
3826 }
3827
3828JMS Object
3829==========
3830 .. container:: paragraph
3831
3832 If used as input, APEX will will take a JMS message,
3833 extract a Java Bean from the ``ObjectMessage``
3834 message, construct an APEX event and put the bean on
3835 the APEX event as a parameter. If used as output, APEX
3836 will take the event produced by a policy, create a
3837 Java Bean and send it as a JMS message.
3838
3839 .. container:: paragraph
3840
3841 The configuration for JMS object is as follows:
3842
3843 .. container:: listingblock
3844
3845 .. container:: content
3846
ramverma760cce92019-07-11 12:57:49 +00003847 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003848
3849 "eventProtocolParameters":{
3850 "eventProtocol" : "JMSOBJECT",
3851 "parameterClassName" :
3852 "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters"
3853 }
3854
3855YAML Event
3856##########
3857
3858 .. container:: paragraph
3859
3860 The event protocol for YAML is provided by the APEX YAML
3861 plugin. There is no difference in the configuration for
3862 the input and output interface.
3863
3864 .. container:: paragraph
3865
3866 If used as input, APEX will consume events as YAML and
3867 map them to policy trigger events. Not well-formed YAML
3868 and not understood trigger events will be rejected. If
3869 used as output, APEX produce YAML encoded events from the
3870 event a policy produces. Those events will always be
3871 well-formed according to the definition in the policy
3872 model.
3873
3874 .. container:: paragraph
3875
3876 The following code shows the configuration.
3877
3878 .. container:: listingblock
3879
3880 .. container:: content
3881
ramverma760cce92019-07-11 12:57:49 +00003882 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003883
3884 "eventProtocolParameters":{
3885 "eventProtocol" : "XML",
3886 "parameterClassName" :
3887 "org.onap.policy.apex.plugins.event.protocol.yaml.YamlEventProtocolParameters"
3888 }
3889
3890XML Event
3891#########
3892 .. container:: paragraph
3893
3894 The event protocol for XML is provided by the APEX XML
3895 plugin. There is no difference in the configuration for
3896 the input and output interface.
3897
3898 .. container:: paragraph
3899
3900 If used as input, APEX will consume events as XML and map
3901 them to policy trigger events. Not well-formed XML and
3902 not understood trigger events will be rejected. If used
3903 as output, APEX produce XML encoded events from the event
3904 a policy produces. Those events will always be
3905 well-formed according to the definition in the policy
3906 model.
3907
3908 .. container:: paragraph
3909
3910 The following code shows the configuration.
3911
3912 .. container:: listingblock
3913
3914 .. container:: content
3915
ramverma760cce92019-07-11 12:57:49 +00003916 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003917
3918 "eventProtocolParameters":{
3919 "eventProtocol" : "XML",
3920 "parameterClassName" :
3921 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3922 }
3923
3924A configuration example
3925-----------------------
3926
3927 .. container:: paragraph
3928
3929 The following example loads all available plug-ins.
3930
3931 .. container:: paragraph
3932
3933 Events are consumed from a Websocket, APEX as client.
3934 Consumed event format is JSON.
3935
3936 .. container:: paragraph
3937
3938 Events are produced to Kafka. Produced event format is XML.
3939
3940 .. container:: listingblock
3941
3942 .. container:: content
3943
ramverma760cce92019-07-11 12:57:49 +00003944 .. code::
ramverma3b71c972019-07-10 11:25:37 +00003945
3946 {
3947 "engineServiceParameters" : {
3948 "name" : "MyApexEngine",
3949 "version" : "0.0.1",
3950 "id" : 45,
3951 "instanceCount" : 4,
3952 "deploymentPort" : 12345,
ramverma3b71c972019-07-10 11:25:37 +00003953 "engineParameters" : {
3954 "executorParameters" : {
3955 "JAVASCRIPT" : {
3956 "parameterClassName" :
3957 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
3958 },
3959 "JYTHON" : {
3960 "parameterClassName" :
3961 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
3962 },
3963 "JRUBY" : {
3964 "parameterClassName" :
3965 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
3966 },
3967 "JAVA" : {
3968 "parameterClassName" :
3969 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
3970 },
3971 "MVEL" : {
3972 "parameterClassName" :
3973 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
3974 }
3975 },
3976 "contextParameters" : {
3977 "parameterClassName" :
3978 "org.onap.policy.apex.context.parameters.ContextParameters",
3979 "schemaParameters" : {
3980 "Avro":{
3981 "parameterClassName" :
3982 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
3983 }
3984 }
3985 }
3986 }
3987 },
3988 "producerCarrierTechnologyParameters" : {
3989 "carrierTechnology" : "KAFKA",
3990 "parameterClassName" :
3991 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
3992 "parameters" : {
3993 "bootstrapServers" : "localhost:49092",
3994 "acks" : "all",
3995 "retries" : 0,
3996 "batchSize" : 16384,
3997 "lingerTime" : 1,
3998 "bufferMemory" : 33554432,
3999 "producerTopic" : "apex-out",
4000 "keySerializer" : "org.apache.kafka.common.serialization.StringSerializer",
4001 "valueSerializer" : "org.apache.kafka.common.serialization.StringSerializer"
4002 }
4003 },
4004 "producerEventProtocolParameters" : {
4005 "eventProtocol" : "XML",
4006 "parameterClassName" :
4007 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
4008 },
4009 "consumerCarrierTechnologyParameters" : {
4010 "carrierTechnology" : "WEBSOCKET",
4011 "parameterClassName" :
4012 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
4013 "parameters" : {
4014 "host" : "localhost",
4015 "port" : 88888
4016 }
4017 },
4018 "consumerEventProtocolParameters" : {
4019 "eventProtocol" : "JSON"
4020 }
4021 }
4022
4023Engine and Applications of the APEX System
4024^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4025
4026Introduction to APEX Engine and Applications
4027--------------------------------------------
4028
4029 .. container:: paragraph
4030
4031 The core of APEX is the APEX Engine, also known as the APEX
4032 Policy Engine or the APEX PDP (since it is in fact a Policy
4033 Decision Point). Beside this engine, an APEX system comes
4034 with a few applications intended to help with policy
4035 authoring, deployment, and execution.
4036
4037 .. container:: paragraph
4038
4039 The engine itself and most applications are started from the
4040 command line with command line arguments. This is called a
4041 Command Line Interface (CLI). Some applications require an
4042 installation on a webserver, as for instance the REST
4043 Editor. Those applications can be accessed via a web
4044 browser.
4045
4046 .. container:: paragraph
4047
4048 You can also use the available APEX APIs and applications to
4049 develop other applications as required. This includes policy
4050 languages (and associated parsers and compilers /
4051 interpreters), GUIs to access APEX or to define policies,
4052 clients to connect to APEX, etc.
4053
4054 .. container:: paragraph
4055
4056 For this documentation, we assume an installation of APEX as
4057 a full system based on a current ONAP release.
4058
4059CLI on Unix, Windows, and Cygwin
4060--------------------------------
4061
4062 .. container:: paragraph
4063
4064 A note on APEX CLI applications: all applications and the
4065 engine itself have been deployed and tested on different
4066 operating systems: Red Hat, Ubuntu, Debian, Mac OSX,
4067 Windows, Cygwin. Each operating system comes with its own
4068 way of configuring and executing Java. The main items here
4069 are:
4070
4071 .. container:: ulist
4072
4073 - For UNIX systems (RHL, Ubuntu, Debian, Mac OSX), the
4074 provided bash scripts work as expected with absolute
4075 paths (e.g.
4076 ``/opt/app/policy/apex-pdp/apex-pdp-2.0.0-SNAPSHOT/examples``),
4077 indirect and linked paths (e.g. ``../apex/apex``), and
4078 path substitutions using environment settings (e.g.
4079 ``$APEX_HOME/bin/``)
4080
4081 - For Windows systems, the provided batch files (``.bat``)
4082 work as expected with with absolute paths (e.g.
4083 ``C:\apex\apex-2.0.0-SNAPSHOT\examples``), and path
4084 substitutions using environment settings (e.g.
4085 ``%APEX_HOME%\bin\``)
4086
4087 - For Cygwin system we assume a standard Cygwin
4088 installation with standard tools (mainly bash) using a
4089 Windows Java installation. This means that the bash
4090 scripts can be used as in UNIX, however any argument
4091 pointing to files and directories need to use either a
4092 DOS path (e.g.
4093 ``C:\apex\apex-2.0.0-SNAPSHOT\examples\config...``) or
4094 the command ``cygpath`` with a mixed option. The reason
4095 for that is: Cygwin executes Java using UNIX paths but
4096 then runs Java as a DOS/WINDOWS process, which requires
4097 DOS paths for file access.
4098
4099The APEX Engine
4100---------------
4101
4102 .. container:: paragraph
4103
4104 The APEX engine can be started in different ways, depending
4105 your requirements. All scripts are located in the APEX *bin*
4106 directory
4107
4108 .. container:: paragraph
4109
4110 On UNIX and Cygwin systems use:
4111
4112 .. container:: ulist
4113
4114 - ``apexEngine.sh`` - this script will
4115
4116 .. container:: ulist
4117
4118 - Test if ``$APEX_USER`` is set and if the user
4119 exists, terminate with an error otherwise
4120
4121 - Test if ``$APEX_HOME`` is set. If not set, it will
4122 use the default setting as
4123 ``/opt/app/policy/apex-pdp/apex-pdp``. Then the set
4124 directory is tested to exist, the script will
4125 terminate if not.
4126
4127 - When all tests are passed successfully, the script
4128 will call ``apexApps.sh`` with arguments to start
4129 the APEX engine.
4130
4131 - ``apexApps.sh engine`` - this is the general APEX
4132 application launcher, which will
4133
4134 .. container:: ulist
4135
4136 - Start the engine with the argument ``engine``
4137
4138 - Test if ``$APEX_HOME`` is set and points to an
4139 existing directory. If not set or directory does
4140 not exist, script terminates.
4141
4142 - Not test for any settings of ``$APEX_USER``.
4143
4144 .. container:: paragraph
4145
4146 On Windows systems use ``apexEngine.bat`` and
4147 ``apexApps.bat engine`` respectively. Note: none of the
4148 windows batch files will test for ``%APEX_USER%``.
4149
4150 .. container:: paragraph
4151
4152 Summary of alternatives to start the APEX Engine:
4153
4154 +--------------------------------------------------------+----------------------------------------------------------+
4155 | Unix, Cygwin | Windows |
4156 +========================================================+==========================================================+
4157 | .. container:: | .. container:: |
4158 | | |
4159 | .. container:: listingblock | .. container:: listingblock |
4160 | | |
4161 | .. container:: content | .. container:: content |
4162 | | |
4163 | .. code:: | .. code:: |
4164 | | |
4165 | # $APEX_HOME/bin/apexEngine.sh [args] | > %APEX_HOME%\bin\apexEngine.bat [args] |
4166 | # $APEX_HOME/bin/apexApps.sh engine [args] | > %APEX_HOME%\bin\apexApps.bat engine [args] |
4167 +--------------------------------------------------------+----------------------------------------------------------+
4168
4169 .. container:: paragraph
4170
a.sreekumarcf3ff822020-09-16 13:12:29 +01004171 The APEX engine comes with a few CLI arguments, the main one is for setting
4172 the tosca policy file for execution. The tosca policy file is
4173 always required. The option ``-h`` prints a help screen.
ramverma3b71c972019-07-10 11:25:37 +00004174
4175 .. container:: listingblock
4176
4177 .. container:: content
4178
ramverma760cce92019-07-11 12:57:49 +00004179 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004180
4181 usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]
4182 options
a.sreekumarcf3ff822020-09-16 13:12:29 +01004183 -p,--tosca-policy-file <TOSCA_POLICY_FILE> the full path to the ToscaPolicy file to use.
4184 -h,--help outputs the usage of this command
4185 -v,--version outputs the version of Apex
ramverma3b71c972019-07-10 11:25:37 +00004186
4187The APEX CLI Editor
4188-------------------
4189
4190 .. container:: paragraph
4191
4192 The CLI Editor allows to define policies from the command
4193 line. The application uses a simple language and supports
4194 all elements of an APEX policy. It can be used in to
4195 different ways:
4196
4197 .. container:: ulist
4198
4199 - non-interactive, specifying a file with the commands to
4200 create a policy
4201
4202 - interactive, using the editors CLI to create a policy
4203
4204 .. container:: paragraph
4205
4206 When a policy is fully specified, the editor will generate
4207 the APEX core policy specification in JSON. This core
4208 specification is called the policy model in the APEX engine
4209 and can be used directly with the APEX engine.
4210
4211 .. container:: paragraph
4212
4213 On UNIX and Cygwin systems use:
4214
4215 .. container:: ulist
4216
4217 - ``apexCLIEditor.sh`` - simply starts the CLI editor,
4218 arguments to the script determine the mode of the editor
4219
4220 - ``apexApps.sh cli-editor`` - simply starts the CLI
4221 editor, arguments to the script determine the mode of the
4222 editor
4223
4224 .. container:: paragraph
4225
4226 On Windows systems use:
4227
4228 .. container:: ulist
4229
4230 - ``apexCLIEditor.bat`` - simply starts the CLI editor,
4231 arguments to the script determine the mode of the editor
4232
4233 - ``apexApps.bat cli-editor`` - simply starts the CLI
4234 editor, arguments to the script determine the mode of the
4235 editor
4236
4237 .. container:: paragraph
4238
4239 Summary of alternatives to start the APEX CLI Editor:
4240
4241 +------------------------------------------------------------+--------------------------------------------------------------+
4242 | Unix, Cygwin | Windows |
4243 +============================================================+==============================================================+
4244 | .. container:: | .. container:: |
4245 | | |
4246 | .. container:: listingblock | .. container:: listingblock |
4247 | | |
4248 | .. container:: content | .. container:: content |
4249 | | |
4250 | .. code:: | .. code:: |
4251 | | |
4252 | # $APEX_HOME/bin/apexCLIEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIEditor.bat [args] |
4253 | # $APEX_HOME/bin/apexApps.sh cli-editor [args] | > %APEX_HOME%\bin\apexApps.bat cli-editor [args] |
4254 +------------------------------------------------------------+--------------------------------------------------------------+
4255
4256 .. container:: paragraph
4257
4258 The option ``-h`` provides a help screen with all command
4259 line arguments.
4260
4261 .. container:: listingblock
4262
4263 .. container:: content
4264
ramverma760cce92019-07-11 12:57:49 +00004265 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004266
4267 usage: org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain [options...]
4268 options
4269 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4270 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4271 -h,--help outputs the usage of this command
4272 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4273 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and continue
4274 executing the command file
4275 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will log
4276 to standard output if not specified or suppressed with "-nl" flag
4277 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4278 -nl,--no-log if specified, no logging or output of commands to standard output or log
4279 file is carried out
4280 -nm,--no-model-output if specified, no output of a model to standard output or model output
4281 file is carried out, the user can use the "save" command in a script to
4282 save a model
4283 -o,--output-model-file <OUTPUT_MODEL_FILE> name of a file that will contain the output model for the editor, will
4284 output model to standard output if not specified or suppressed with
4285 "-nm" flag
4286 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4287 root from which to look for included macro files
4288
a.sreekumar717a24a2019-07-26 13:47:42 +00004289The APEX CLI Tosca Editor
4290-------------------------
4291
4292 .. container:: paragraph
4293
4294 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.
4295
4296 .. container:: paragraph
4297
4298 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.
4299
4300 .. container:: paragraph
4301
4302 On UNIX and Cygwin systems use:
4303
4304 .. container:: ulist
4305
4306 - ``apexCLIToscaEditor.sh`` - starts the CLI Tosca editor,
4307 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4308
4309 - ``apexApps.sh cli-tosca-editor`` - starts the CLI Tosca editor,
4310 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4311
4312 .. container:: paragraph
4313
4314 On Windows systems use:
4315
4316 .. container:: ulist
4317
4318 - ``apexCLIToscaEditor.bat`` - starts the CLI Tosca editor,
4319 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4320
4321 - ``apexApps.bat cli-tosca-editor`` - starts the CLI Tosca
4322 editor, all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4323
4324 .. container:: paragraph
4325
4326 Summary of alternatives to start the APEX CLI Tosca Editor:
4327
4328 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4329 | Unix, Cygwin | Windows |
4330 +=================================================================+====================================================================+
4331 | .. container:: | .. container:: |
4332 | | |
4333 | .. container:: listingblock | .. container:: listingblock |
4334 | | |
4335 | .. container:: content | .. container:: content |
4336 | | |
4337 | .. code:: | .. code:: |
4338 | | |
4339 | # $APEX_HOME/bin/apexCLIToscaEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIToscaEditor.bat [args] |
4340 | # $APEX_HOME/bin/apexApps.sh cli-tosca-editor [args]| > %APEX_HOME%\bin\apexApps.bat cli-tosca-editor [args] |
4341 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4342
4343 .. container:: paragraph
4344
4345 The option ``-h`` provides a help screen with all command
4346 line arguments.
4347
4348 .. container:: listingblock
4349
4350 .. container:: content
4351
4352 .. code::
4353
4354 usage: org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain [options...]
4355 options
4356 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4357 -ac,--apex-config-file <APEX_CONFIG_FILE> name of the file containing apex configuration details
4358 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4359 -h,--help outputs the usage of this command
4360 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4361 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and
4362 continue executing the command file
4363 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will
4364 log to standard output if not specified or suppressed with "-nl" flag
4365 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4366 -nl,--no-log if specified, no logging or output of commands to standard output or
4367 log file is carried out
4368 -ot,--output-tosca-file <OUTPUT_TOSCA_FILE> name of a file that will contain the output ToscaServiceTemplate
4369 -t,--tosca-template-file <TOSCA_TEMPLATE_FILE> name of the input file containing tosca template which needs to be
4370 updated with policy
4371 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4372 root from which to look for included macro files
4373
4374 .. container:: paragraph
4375
4376 An example command to run the APEX CLI Tosca editor on windows machine is given below.
4377
4378 .. container:: listingblock
4379
4380 .. container:: content
4381
4382 .. code::
4383
4384 %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
4385
liamfallon75e2bbf2020-07-06 11:41:38 +01004386
4387The APEX Client
liamfallonb621de42020-08-21 12:59:26 +01004388---------------
ramverma3b71c972019-07-10 11:25:37 +00004389
4390 .. container:: paragraph
4391
liamfallon75e2bbf2020-07-06 11:41:38 +01004392 The APEX Client combines the Policy Editor, the
ramverma3b71c972019-07-10 11:25:37 +00004393 Monitoring Client, and the Deployment Client into a single
4394 application. The standard way to use the APEX Full Client is
4395 via an installation of the *war* file on a webserver.
4396 However, the Full Client can also be started via command
4397 line. This will start a Grizzly webserver with the *war*
4398 deployed. Access to the Full Client is then via the provided
4399 URL
4400
4401 .. container:: paragraph
4402
4403 On UNIX and Cygwin systems use:
4404
4405 .. container:: ulist
4406
4407 - ``apexApps.sh full-client`` - simply starts the webserver
4408 with the Full Client
4409
4410 .. container:: paragraph
4411
4412 On Windows systems use:
4413
4414 .. container:: ulist
4415
4416 - ``apexApps.bat full-client`` - simply starts the
4417 webserver with the Full Client
4418
4419 .. container:: paragraph
4420
4421 The option ``-h`` provides a help screen with all command
4422 line arguments.
4423
4424 .. container:: listingblock
4425
4426 .. container:: content
4427
ramverma760cce92019-07-11 12:57:49 +00004428 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004429
4430 usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]
4431 -h,--help outputs the usage of this command
4432 -p,--port <PORT> port to use for the Apex Services REST calls
4433 -t,--time-to-live <TIME_TO_LIVE> the amount of time in seconds that the server will run for before terminating
4434
4435 .. container:: paragraph
4436
4437 If the Full Client is started without any arguments the
4438 final messages will look similar to this:
4439
4440 .. container:: listingblock
4441
4442 .. container:: content
4443
ramverma760cce92019-07-11 12:57:49 +00004444 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004445
4446 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
4447 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.NetworkListener start
4448 INFO: Started listener bound to [localhost:18989]
4449 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.HttpServer start
4450 INFO: [HttpServer] Started.
4451 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
4452
4453 .. container:: paragraph
4454
4455 The last line states the URL on which the Monitoring Client
4456 can be accessed. The example above stated
4457 ``http://localhost:18989/apexservices``. In a web browser
4458 use the URL ``http://localhost:18989``.
4459
aditya.puthuparambil9e67eb72020-04-30 15:59:43 +01004460The APEX Application Launcher
4461-----------------------------
ramverma3b71c972019-07-10 11:25:37 +00004462
4463 .. container:: paragraph
4464
liamfallon75e2bbf2020-07-06 11:41:38 +01004465 The standard applications (Engine and CLI Editor)
ramverma3b71c972019-07-10 11:25:37 +00004466 come with dedicated start scripts. For all other APEX
4467 applications, we provide an application launcher.
4468
4469 .. container:: paragraph
4470
4471 On UNIX and Cygwin systems use:
4472
4473 .. container:: ulist
4474
4475 - apexApps.sh\` - simply starts the application launcher
4476
4477 .. container:: paragraph
4478
4479 On Windows systems use:
4480
4481 .. container:: ulist
4482
4483 - ``apexApps.bat`` - simply starts the application launcher
4484
4485 .. container:: paragraph
4486
4487 Summary of alternatives to start the APEX application
4488 launcher:
4489
4490 +-------------------------------------------------+---------------------------------------------------+
4491 | Unix, Cygwin | Windows |
4492 +=================================================+===================================================+
4493 | .. container:: | .. container:: |
4494 | | |
4495 | .. container:: listingblock | .. container:: listingblock |
4496 | | |
4497 | .. container:: content | .. container:: content |
4498 | | |
4499 | .. code:: | .. code:: |
4500 | | |
4501 | # $APEX_HOME/bin/apexApps.sh [args] | > %APEX_HOME%\bin\apexApps.bat [args] |
4502 +-------------------------------------------------+---------------------------------------------------+
4503
4504 .. container:: paragraph
4505
4506 The option ``-h`` provides a help screen with all launcher
4507 command line arguments.
4508
4509 .. container:: listingblock
4510
4511 .. container:: content
4512
ramverma760cce92019-07-11 12:57:49 +00004513 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004514
4515 apexApps.sh - runs APEX applications
4516
4517 Usage: apexApps.sh [options] | [<application> [<application options>]]
4518
4519 Options
4520 -d <app> - describes an application
4521 -l - lists all applications supported by this script
4522 -h - this help screen
4523
4524 .. container:: paragraph
4525
4526 Using ``-l`` lists all known application the launcher can
4527 start.
4528
4529 .. container:: listingblock
4530
4531 .. container:: content
4532
ramverma760cce92019-07-11 12:57:49 +00004533 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004534
4535 apexApps.sh: supported applications:
4536 --> ws-echo engine eng-monitoring full-client eng-deployment tpl-event-json model-2-cli rest-editor cli-editor ws-console
4537
4538 .. container:: paragraph
4539
4540 Using the ``-d <name>`` option describes the named
4541 application, for instance for the ``ws-console``:
4542
4543 .. container:: listingblock
4544
4545 .. container:: content
4546
ramverma760cce92019-07-11 12:57:49 +00004547 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004548
4549 apexApps.sh: application 'ws-console'
4550 --> a simple console sending events to APEX, connect to APEX consumer port
4551
4552 .. container:: paragraph
4553
4554 Launching an application is done by calling the script with
4555 only the application name and any CLI arguments for the
4556 application. For instance, starting the ``ws-echo``
4557 application with port ``8888``:
4558
4559 .. container:: listingblock
4560
4561 .. container:: content
4562
ramverma760cce92019-07-11 12:57:49 +00004563 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004564
4565 apexApps.sh ws-echo -p 8888
4566
4567Application: Create Event Templates
4568-----------------------------------
4569
4570 .. container:: paragraph
4571
4572 **Status: Experimental**
4573
4574 .. container:: paragraph
4575
4576 This application takes a policy model (JSON or XML encoded)
4577 and generates templates for events in JSON format. This can
4578 help when a policy defines rather complex trigger or action
4579 events or complex events between states. The application can
4580 produce events for the types: stimuli (policy trigger
4581 events), internal (events between policy states), and
4582 response (action events).
4583
4584 +----------------------------------------------------------------+------------------------------------------------------------------+
4585 | Unix, Cygwin | Windows |
4586 +================================================================+==================================================================+
4587 | .. container:: | .. container:: |
4588 | | |
4589 | .. container:: listingblock | .. container:: listingblock |
4590 | | |
4591 | .. container:: content | .. container:: content |
4592 | | |
4593 | .. code:: | .. code:: |
4594 | | |
4595 | # $APEX_HOME/bin/apexApps.sh tpl-event-json [args] | > %APEX_HOME%\bin\apexApps.bat tpl-event-json [args] |
4596 +----------------------------------------------------------------+------------------------------------------------------------------+
4597
4598 .. container:: paragraph
4599
4600 The option ``-h`` provides a help screen.
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 gen-model2event v{release-version} - generates JSON templates for events generated from a policy model
4609 usage: gen-model2event
4610 -h,--help prints this help and usage screen
4611 -m,--model <MODEL-FILE> set the input policy model file
4612 -t,--type <TYPE> set the event type for generation, one of:
4613 stimuli (trigger events), response (action
4614 events), internal (events between states)
4615 -v,--version prints the application version
4616
4617 .. container:: paragraph
4618
4619 The created templates are not valid events, instead they use
4620 some markup for values one will need to change to actual
4621 values. For instance, running the tool with the *Sample
4622 Domain* policy model as:
4623
4624 .. container:: listingblock
4625
4626 .. container:: content
4627
ramverma760cce92019-07-11 12:57:49 +00004628 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004629
4630 apexApps.sh tpl-event-json -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json -t stimuli
4631
4632 .. container:: paragraph
4633
4634 will produce the following status messages:
4635
4636 .. container:: listingblock
4637
4638 .. container:: content
4639
ramverma760cce92019-07-11 12:57:49 +00004640 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004641
4642 gen-model2event: starting Event generator
4643 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4644 --> type: stimuli
4645
4646 .. container:: paragraph
4647
4648 and then run the generator application producing two event
4649 templates. The first template is called ``Event0000``.
4650
4651 .. container:: listingblock
4652
4653 .. container:: content
4654
4655 .. code::
4656
4657 {
4658 "name" : "Event0000",
4659 "nameSpace" : "org.onap.policy.apex.sample.events",
4660 "version" : "0.0.1",
4661 "source" : "Outside",
4662 "target" : "Match",
4663 "TestTemperature" : ###double: 0.0###,
4664 "TestTimestamp" : ###long: 0###,
4665 "TestMatchCase" : ###integer: 0###,
4666 "TestSlogan" : "###string###"
4667 }
4668
4669 .. container:: paragraph
4670
4671 The values for the keys are marked with ``#`` and the
4672 expected type of the value. To create an actual stimuli
4673 event, all these markers need to be change to actual values,
4674 for instance:
4675
4676 .. container:: listingblock
4677
4678 .. container:: content
4679
ramverma760cce92019-07-11 12:57:49 +00004680 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004681
4682 {
4683 "name" : "Event0000",
4684 "nameSpace" : "org.onap.policy.apex.sample.events",
4685 "version" : "0.0.1",
4686 "source" : "Outside",
4687 "target" : "Match",
4688 "TestTemperature" : 25,
4689 "TestTimestamp" : 123456789123456789,
4690 "TestMatchCase" : 1,
4691 "TestSlogan" : "Testing the Match Case with Temperature 25"
4692 }
4693
4694Application: Convert a Policy Model to CLI Editor Commands
4695----------------------------------------------------------
4696
4697 .. container:: paragraph
4698
4699 **Status: Experimental**
4700
4701 .. container:: paragraph
4702
4703 This application takes a policy model (JSON or XML encoded)
4704 and generates commands for the APEX CLI Editor. This
4705 effectively reverses a policy specification realized with
4706 the CLI Editor.
4707
4708 +-------------------------------------------------------------+---------------------------------------------------------------+
4709 | Unix, Cygwin | Windows |
4710 +=============================================================+===============================================================+
4711 | .. container:: | .. container:: |
4712 | | |
4713 | .. container:: listingblock | .. container:: listingblock |
4714 | | |
4715 | .. container:: content | .. container:: content |
4716 | | |
4717 | .. code:: | .. code:: |
4718 | | |
4719 | # $APEX_HOME/bin/apexApps.sh model-2-cli [args] | > %APEX_HOME%\bin\apexApps.bat model-2-cli [args] |
4720 +-------------------------------------------------------------+---------------------------------------------------------------+
4721
4722 .. container:: paragraph
4723
4724 The option ``-h`` provides a help screen.
4725
4726 .. container:: listingblock
4727
4728 .. container:: content
4729
ramverma760cce92019-07-11 12:57:49 +00004730 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004731
4732 usage: gen-model2cli
4733 -h,--help prints this help and usage screen
4734 -m,--model <MODEL-FILE> set the input policy model file
4735 -sv,--skip-validation switch of validation of the input file
4736 -v,--version prints the application version
4737
4738 .. container:: paragraph
4739
4740 For instance, running the tool with the *Sample Domain*
4741 policy model as:
4742
4743 .. container:: listingblock
4744
4745 .. container:: content
4746
ramverma760cce92019-07-11 12:57:49 +00004747 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004748
4749 apexApps.sh model-2-cli -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json
4750
4751 .. container:: paragraph
4752
4753 will produce the following status messages:
4754
4755 .. container:: listingblock
4756
4757 .. container:: content
4758
ramverma760cce92019-07-11 12:57:49 +00004759 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004760
4761 gen-model2cli: starting CLI generator
4762 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4763
4764 .. container:: paragraph
4765
4766 and then run the generator application producing all CLI
4767 Editor commands and printing them to standard out.
4768
4769Application: Websocket Clients (Echo and Console)
4770-------------------------------------------------
4771
4772 .. container:: paragraph
4773
4774 **Status: Production**
4775
4776 .. container:: paragraph
4777
4778 The application launcher also provides a Websocket echo
4779 client and a Websocket console client. The echo client
4780 connects to APEX and prints all events it receives from
4781 APEX. The console client connects to APEX, reads input from
4782 the command line, and sends this input as events to APEX.
4783
4784 +------------------------------------------------------------+--------------------------------------------------------------+
4785 | Unix, Cygwin | Windows |
4786 +============================================================+==============================================================+
4787 | .. container:: | .. container:: |
4788 | | |
4789 | .. container:: listingblock | .. container:: listingblock |
4790 | | |
4791 | .. container:: content | .. container:: content |
4792 | | |
4793 | .. code:: | .. code:: |
4794 | | |
4795 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
4796 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
4797 +------------------------------------------------------------+--------------------------------------------------------------+
4798
4799 .. container:: paragraph
4800
4801 The arguments are the same for both applications:
4802
4803 .. container:: ulist
4804
4805 - ``-p`` defines the Websocket port to connect to (defaults
4806 to ``8887``)
4807
4808 - ``-s`` defines the host on which a Websocket server is
4809 running (defaults to ``localhost``)
4810
4811 .. container:: paragraph
4812
4813 A discussion on how to use these two applications to build
4814 an APEX system is detailed HowTo-Websockets.
4815
ramverma3b71c972019-07-10 11:25:37 +00004816APEX Logging
4817^^^^^^^^^^^^
4818
4819Introduction to APEX Logging
4820----------------------------
4821
4822 .. container:: paragraph
4823
4824 All APEX components make extensive use of logging using the
4825 logging façade `SLF4J <https://www.slf4j.org/>`__ with the
4826 backend `Logback <https://logback.qos.ch/>`__. Both are used
4827 off-the-shelve, so the standard documentation and
4828 configuration apply to APEX logging. For details on how to
4829 work with logback please see the `logback
4830 manual <https://logback.qos.ch/manual/index.html>`__.
4831
4832 .. container:: paragraph
4833
4834 The APEX applications is the logback configuration file
4835 ``$APEX_HOME/etc/logback.xml`` (Windows:
4836 ``%APEX_HOME%\etc\logback.xml``). The logging backend is set
4837 to no debug, i.e. logs from the logging framework should be
4838 hidden at runtime.
4839
4840 .. container:: paragraph
4841
4842 The configurable log levels work as expected:
4843
4844 .. container:: ulist
4845
4846 - *error* (or *ERROR*) is used for serious errors in the
4847 APEX runtime engine
4848
4849 - *warn* (or *WARN*) is used for warnings, which in general
4850 can be ignored but might indicate some deeper problems
4851
4852 - *info* (or *INFO*) is used to provide generally
4853 interesting messages for startup and policy execution
4854
4855 - *debug* (or *DEBUG*) provides more details on startup and
4856 policy execution
4857
4858 - *trace* (or *TRACE*) gives full details on every aspect
4859 of the APEX engine from start to end
4860
4861 .. container:: paragraph
4862
4863 The loggers can also be configured as expected. The standard
4864 configuration (after installing APEX) uses log level *info*
4865 on all APEX classes (components).
4866
4867 .. container:: paragraph
4868
4869 The applications and scripts in ``$APEX_HOME/bin`` (Windows:
4870 ``%APEX_HOME\bin``) are configured to use the logback
4871 configuration ``$APEX_HOME/etc/logback.xml`` (Windows:
4872 ``%APEX_HOME\etc\logback.xml``). There are multiple ways to
4873 use different logback configurations, for instance:
4874
4875 .. container:: ulist
4876
4877 - Maintain multiple configurations in ``etc``, for instance
4878 a ``logback-debug.xml`` for deep debugging and a
4879 ``logback-production.xml`` for APEX in production mode,
4880 then copy the required configuration file to the used
4881 ``logback.xml`` prior starting APEX
4882
4883 - Edit the scripts in ``bin`` to use a different logback
4884 configuration file (only recommended if you are familiar
4885 with editing bash scripts or windows batch files)
4886
4887Standard Logging Configuration
4888------------------------------
4889
4890 .. container:: paragraph
4891
4892 The standard logging configuration defines a context *APEX*,
4893 which is used in the standard output pattern. The location
liamfallon1540e472019-11-28 15:14:07 +00004894 for log files is defined in the property ``logDir`` and set
ramverma3b71c972019-07-10 11:25:37 +00004895 to ``/var/log/onap/policy/apex-pdp``. The standard status
4896 listener is set to *NOP* and the overall logback
4897 configuration is set to no debug.
4898
4899 .. container:: listingblock
4900
4901 .. container:: content
4902
ramverma760cce92019-07-11 12:57:49 +00004903 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004904 :number-lines:
4905
4906 <configuration debug="false">
4907 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
4908
4909 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00004910 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00004911
4912 ...appenders
4913 ...loggers
4914 </configuration>
4915
4916.. container:: paragraph
4917
4918 The first appender defined is called ``STDOUT`` for logs to standard
4919 out.
4920
4921.. container:: listingblock
4922
4923 .. container:: content
4924
ramverma760cce92019-07-11 12:57:49 +00004925 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004926 :number-lines:
4927
4928 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4929 <encoder>
4930 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
4931 </encoder>
4932 </appender>
4933
4934.. container:: paragraph
4935
4936 The root level logger then is set to the level *info* using the
4937 standard out appender.
4938
4939.. container:: listingblock
4940
4941 .. container:: content
4942
ramverma760cce92019-07-11 12:57:49 +00004943 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004944 :number-lines:
4945
4946 <root level="info">
4947 <appender-ref ref="STDOUT" />
4948 </root>
4949
4950.. container:: paragraph
4951
4952 The second appender is called ``FILE``. It writes logs to a file
4953 ``apex.log``.
4954
4955.. container:: listingblock
4956
4957 .. container:: content
4958
ramverma760cce92019-07-11 12:57:49 +00004959 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004960 :number-lines:
4961
4962 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00004963 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00004964 <encoder>
4965 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4966 </encoder>
4967 </appender>
4968
4969.. container:: paragraph
4970
4971 The third appender is called ``CTXT_FILE``. It writes logs to a file
4972 ``apex_ctxt.log``.
4973
4974.. container:: listingblock
4975
4976 .. container:: content
4977
ramverma760cce92019-07-11 12:57:49 +00004978 .. code::
ramverma3b71c972019-07-10 11:25:37 +00004979 :number-lines:
4980
4981 <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00004982 <file>${logDir}/apex_ctxt.log</file>
ramverma3b71c972019-07-10 11:25:37 +00004983 <encoder>
4984 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4985 </encoder>
4986 </appender>
4987
4988.. container:: paragraph
4989
4990 The last definitions are for specific loggers. The first logger
4991 captures all standard APEX classes. It is configured for log level
4992 *info* and uses the standard output and file appenders. The second
4993 logger captures APEX context classes responsible for context
4994 monitoring. It is configured for log level *trace* and uses the
4995 context file appender.
4996
4997.. container:: listingblock
4998
4999 .. container:: content
5000
ramverma760cce92019-07-11 12:57:49 +00005001 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005002 :number-lines:
5003
5004
5005 <logger name="org.onap.policy.apex" level="info" additivity="false">
5006 <appender-ref ref="STDOUT" />
5007 <appender-ref ref="FILE" />
5008 </logger>
5009
5010 <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
5011 <appender-ref ref="CTXT_FILE" />
5012 </logger>
5013
5014Adding Logback Status and Debug
5015-------------------------------
5016
5017 .. container:: paragraph
5018
5019 To activate logback status messages change the status listener
5020 from 'NOP' to for instance console.
5021
5022 .. container:: listingblock
5023
5024 .. container:: content
5025
ramverma760cce92019-07-11 12:57:49 +00005026 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005027
5028 <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
5029
5030 .. container:: paragraph
5031
5032 To activate all logback debugging, for instance to debug a new
5033 logback configuration, activate the debug attribute in the
5034 configuration.
5035
5036 .. container:: listingblock
5037
5038 .. container:: content
5039
ramverma760cce92019-07-11 12:57:49 +00005040 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005041
5042 <configuration debug="true">
5043 ...
5044 </configuration>
5045
5046Logging External Components
5047---------------------------
5048
5049 .. container:: paragraph
5050
5051 Logback can also be configured to log any other, external
5052 components APEX is using, if they are using the common logging
5053 framework.
5054
5055 .. container:: paragraph
5056
5057 For instance, the context component of APEX is using *Infinispan*
5058 and one can add a logger for this external component. The
5059 following example adds a logger for *Infinispan* using the
5060 standard output appender.
5061
5062 .. container:: listingblock
5063
5064 .. container:: content
5065
ramverma760cce92019-07-11 12:57:49 +00005066 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005067
5068 <logger name="org.infinispan" level="INFO" additivity="false">
5069 <appender-ref ref="STDOUT" />
5070 </logger>
5071
5072 .. container:: paragraph
5073
5074 Another example is Apache Zookeeper. The following example adds a
5075 logger for Zookeeper using the standard outout appender.
5076
5077 .. container:: listingblock
5078
5079 .. container:: content
5080
ramverma760cce92019-07-11 12:57:49 +00005081 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005082
5083 <logger name="org.apache.zookeeper.ClientCnxn" level="INFO" additivity="false">
5084 <appender-ref ref="STDOUT" />
5085 </logger>
5086
5087Configuring loggers for Policy Logic
5088------------------------------------
5089
5090 .. container:: paragraph
5091
5092 The logging for the logic inside a policy (task logic, task
5093 selection logic, state finalizer logic) can be configured separate
5094 from standard logging. The logger for policy logic is
5095 ``org.onap.policy.apex.executionlogging``. The following example
5096 defines
5097
5098 .. container:: ulist
5099
5100 - a new appender for standard out using a very simple pattern
5101 (simply the actual message)
5102
5103 - a logger for policy logic to standard out using the new
5104 appender and the already described file appender.
5105
5106 .. container:: listingblock
5107
5108 .. container:: content
5109
ramverma760cce92019-07-11 12:57:49 +00005110 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005111
5112 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5113 <encoder>
5114 <pattern>policy: %msg\n</pattern>
5115 </encoder>
5116 </appender>
5117
5118 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5119 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5120 <appender-ref ref="FILE" />
5121 </logger>
5122
5123 .. container:: paragraph
5124
5125 It is also possible to use specific logging for parts of policy
5126 logic. The following example defines a logger for task logic.
5127
5128 .. container:: listingblock
5129
5130 .. container:: content
5131
ramverma760cce92019-07-11 12:57:49 +00005132 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005133
5134 <logger name="org.onap.policy.apex.executionlogging.TaskExecutionLogging" level="TRACE" additivity="false">
5135 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5136 </logger>
5137
5138Rolling File Appenders
5139----------------------
5140
5141 .. container:: paragraph
5142
5143 Rolling file appenders are a good option for more complex logging
5144 of a production or complex testing APEX installation. The standard
5145 logback configuration can be used for these use cases. This
5146 section gives two examples for the standard logging and for
5147 context logging.
5148
5149 .. container:: paragraph
5150
5151 First the standard logging. The following example defines a
5152 rolling file appender. The appender rolls over on a daily basis.
5153 It allows for a file size of 100 MB.
5154
5155 .. container:: listingblock
5156
5157 .. container:: content
5158
ramverma760cce92019-07-11 12:57:49 +00005159 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005160
5161 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005162 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005163 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5164 <!-- rollover daily -->
5165 <!-- <fileNamePattern>xstream-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> -->
liamfallon1540e472019-11-28 15:14:07 +00005166 <fileNamePattern>${logDir}/apex_%d{yyyy-MM-dd}.%i.log.gz
ramverma3b71c972019-07-10 11:25:37 +00005167 </fileNamePattern>
5168 <maxHistory>4</maxHistory>
5169 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5170 <!-- or whenever the file size reaches 100MB -->
5171 <maxFileSize>100MB</maxFileSize>
5172 </timeBasedFileNamingAndTriggeringPolicy>
5173 </rollingPolicy>
5174 <encoder>
5175 <pattern>
5176 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5177 </pattern>
5178 </encoder>
5179 </appender>
5180
5181 .. container:: paragraph
5182
5183 A very similar configuration can be used for a rolling file
5184 appender logging APEX context.
5185
5186 .. container:: listingblock
5187
5188 .. container:: content
5189
ramverma760cce92019-07-11 12:57:49 +00005190 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005191
5192 <appender name="CTXT-FILE"
5193 class="ch.qos.logback.core.rolling.RollingFileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005194 <file>${logDir}/apex_ctxt.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005195 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
liamfallon1540e472019-11-28 15:14:07 +00005196 <fileNamePattern>${logDir}/apex_ctxt_%d{yyyy-MM-dd}.%i.log.gz
ramverma3b71c972019-07-10 11:25:37 +00005197 </fileNamePattern>
5198 <maxHistory>4</maxHistory>
5199 <timeBasedFileNamingAndTriggeringPolicy
5200 class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5201 <maxFileSize>100MB</maxFileSize>
5202 </timeBasedFileNamingAndTriggeringPolicy>
5203 </rollingPolicy>
5204 <encoder>
5205 <pattern>
5206 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5207 </pattern>
5208 </encoder>
5209 </appender>
5210
5211Example Configuration for Logging Logic
5212---------------------------------------
5213
5214 .. container:: paragraph
5215
5216 The following example shows a configuration that logs policy logic
5217 to standard out and a file (*info*). All other APEX components are
5218 logging to a file (*debug*).. This configuration an be used in a
5219 pre-production phase with the APEX engine still running in a
5220 separate terminal to monitor policy execution. This logback
5221 configuration is in the APEX installation as
5222 ``etc/logback-logic.xml``.
5223
5224 .. container:: listingblock
5225
5226 .. container:: content
5227
ramverma760cce92019-07-11 12:57:49 +00005228 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005229
5230 <configuration debug="false">
5231 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5232
5233 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00005234 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00005235
5236 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5237 <encoder>
5238 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
5239 </encoder>
5240 </appender>
5241
5242 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005243 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005244 <encoder>
5245 <pattern>
5246 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5247 </pattern>
5248 </encoder>
5249 </appender>
5250
5251 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5252 <encoder>
5253 <pattern>policy: %msg\n</pattern>
5254 </encoder>
5255 </appender>
5256
5257 <root level="error">
5258 <appender-ref ref="STDOUT" />
5259 </root>
5260
5261 <logger name="org.onap.policy.apex" level="debug" additivity="false">
5262 <appender-ref ref="FILE" />
5263 </logger>
5264
5265 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5266 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5267 <appender-ref ref="FILE" />
5268 </logger>
5269 </configuration>
5270
5271Example Configuration for a Production Server
5272---------------------------------------------
5273
5274 .. container:: paragraph
5275
5276 The following example shows a configuration that logs all APEX
5277 components, including policy logic, to a file (*debug*). This
5278 configuration an be used in a production phase with the APEX
5279 engine being executed as a service on a system without console
5280 output. This logback configuration is in the APEX installation as
5281 ``logback-server.xml``
5282
5283 .. container:: listingblock
5284
5285 .. container:: content
5286
ramverma760cce92019-07-11 12:57:49 +00005287 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005288
5289 <configuration debug="false">
5290 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5291
5292 <contextName>Apex</contextName>
liamfallon1540e472019-11-28 15:14:07 +00005293 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
ramverma3b71c972019-07-10 11:25:37 +00005294
5295 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
liamfallon1540e472019-11-28 15:14:07 +00005296 <file>${logDir}/apex.log</file>
ramverma3b71c972019-07-10 11:25:37 +00005297 <encoder>
5298 <pattern>
5299 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5300 </pattern>
5301 </encoder>
5302 </appender>
5303
5304 <root level="debug">
5305 <appender-ref ref="FILE" />
5306 </root>
5307
5308 <logger name="org.onap.policy.apex.executionlogging" level="debug" additivity="false">
5309 <appender-ref ref="FILE" />
5310 </logger>
5311 </configuration>
5312
a.sreekumarcf3ff822020-09-16 13:12:29 +01005313Unsupported Features
5314^^^^^^^^^^^^^^^^^^^^
5315
5316 .. container:: paragraph
5317
5318 This section documents some legacy and unsupported features
5319 in apex-pdp. The documentation here has not been updated for
5320 recent versions of apex-pdp. For example, the apex-pdp models
5321 specified in this example should now be in TOSCA format.
5322
ramverma3b71c972019-07-10 11:25:37 +00005323Building a System with Websocket Backend
a.sreekumarcf3ff822020-09-16 13:12:29 +01005324----------------------------------------
ramverma3b71c972019-07-10 11:25:37 +00005325
5326Websockets
a.sreekumarcf3ff822020-09-16 13:12:29 +01005327##########
ramverma3b71c972019-07-10 11:25:37 +00005328
5329 .. container:: paragraph
5330
5331 Websocket is a protocol to run sockets of HTTP. Since it in
5332 essence a socket, the connection is realized between a
5333 server (waiting for connections) and a client (connecting to
5334 a server). Server/client separation is only important for
5335 connection establishment, once connected, everyone can
5336 send/receive on the same socket (as any standard socket
5337 would allow).
5338
5339 .. container:: paragraph
5340
5341 Standard Websocket implementations are simple, no
5342 publish/subscribe and no special event handling. Most
5343 servers simply send all incoming messages to all
5344 connections. There is a PubSub definition on top of
5345 Websocket called `WAMP <http://wamp-proto.org/>`__. APEX
5346 does not support WAMP at the moment.
5347
5348Websocket in Java
a.sreekumarcf3ff822020-09-16 13:12:29 +01005349#################
ramverma3b71c972019-07-10 11:25:37 +00005350
5351 .. container:: paragraph
5352
5353 In Java, `JSR
5354 356 <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5355 defines the standard Websocket API. This JSR is part of Jave
5356 EE 7 standard. For Java SE, several implementations exist in
5357 open source. Since Websockets are a stable standard and
5358 simple, most implementations are stable and ready to use. A
5359 lot of products support Websockets, like Spring, JBoss,
5360 Netty, … there are also Kafka extensions for Websockets.
5361
5362Websocket Example Code for Websocket clients (FOSS)
a.sreekumarcf3ff822020-09-16 13:12:29 +01005363###################################################
ramverma3b71c972019-07-10 11:25:37 +00005364
5365 .. container:: paragraph
5366
5367 There are a lot of implementations and examples available on
5368 Github for Websocket clients. If one is using Java EE 7,
5369 then one can also use the native Websocket implementation.
5370 Good examples for clients using simply Java SE are here:
5371
5372 .. container:: ulist
5373
5374 - `Websocket
5375 implementation <https://github.com/TooTallNate/Java-WebSocket>`__
5376
5377 - `Websocket sending client example, using
5378 AWT <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ChatClient.java>`__
5379
5380 - `Websocket receiving client example (simple echo
5381 client) <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ExampleClient.java>`__
5382
5383 .. container:: paragraph
5384
5385 For Java EE, the native Websocket API is explained here:
5386
5387 .. container:: ulist
5388
5389 - `Oracle
5390 docs <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5391
5392 - link: `An
5393 example <http://www.programmingforliving.com/2013/08/jsr-356-java-api-for-websocket-client-api.html>`__
5394
5395BCP: Websocket Configuration
a.sreekumarcf3ff822020-09-16 13:12:29 +01005396############################
ramverma3b71c972019-07-10 11:25:37 +00005397
5398 .. container:: paragraph
5399
5400 The probably best is to configure APEX for Websocket servers
5401 for input (ingress, consume) and output (egress, produce)
5402 interfaces. This means that APEX will start Websocket
5403 servers on named ports and wait for clients to connect.
5404 Advantage: once APEX is running all connectivity
5405 infrastructure is running as well. Consequence: if APEX is
5406 not running, everyone else is in the dark, too.
5407
5408 .. container:: paragraph
5409
5410 The best protocol to be used is JSON string. Each event on
5411 any interface is then a string with a JSON encoding. JSON
5412 string is a little bit slower than byte code, but we doubt
5413 that this will be noticeable. A further advantage of JSON
5414 strings over Websockets with APEX starting the servers: it
5415 is very easy to connect web browsers to such a system.
5416 Simple connect the web browser to the APEX sockets and
5417 send/read JSON strings.
5418
5419 .. container:: paragraph
5420
5421 Once APEX is started you simply connect Websocket clients to
5422 it, and send/receive event. When APEX is terminated, the
5423 Websocket servers go down, and the clients will be
5424 disconnected. APEX does not (yet) support auto-client
5425 reconnect nor WAMP, so clients might need to be restarted or
5426 reconnected manually after an APEX boot.
5427
5428Demo with VPN Policy Model
a.sreekumarcf3ff822020-09-16 13:12:29 +01005429##########################
ramverma3b71c972019-07-10 11:25:37 +00005430
5431 .. container:: paragraph
5432
5433 We assume that you have an APEX installation using the full
5434 package, i.e. APEX with all examples, of version ``0.5.6``
5435 or higher. We will use the VPN policy from the APEX examples
5436 here.
5437
5438 .. container:: paragraph
5439
5440 Now, have the following ready to start the demo:
5441
5442 .. container:: ulist
5443
5444 - 3 terminals on the host where APEX is running (we need 1
5445 for APEX and 1 for each client)
5446
5447 - the events in the file
5448 ``$APEX_HOME/examples/events/VPN/SetupEvents.json`` open
5449 in an editor (we need to send those events to APEX)
5450
5451 - the events in the file
5452 ``$APEX_HOME/examples/events/VPN/Link09Events.json`` open
5453 in an editor (we need to send those events to APEX)
5454
5455A Websocket Configuration for the VPN Domain
a.sreekumarcf3ff822020-09-16 13:12:29 +01005456********************************************
ramverma3b71c972019-07-10 11:25:37 +00005457
5458 .. container:: paragraph
5459
5460 Create a new APEX configuration using the VPN policy
5461 model and configuring APEX as discussed above for
5462 Websockets. Copy the following configuration into
5463 ``$APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json``
5464 (for Windows use
5465 ``%APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json``):
5466
5467 .. container:: listingblock
5468
5469 .. container:: content
5470
ramverma760cce92019-07-11 12:57:49 +00005471 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005472 :number-lines:
5473
5474 {
5475 "engineServiceParameters" : {
5476 "name" : "VPNApexEngine",
5477 "version" : "0.0.1",
5478 "id" : 45,
5479 "instanceCount" : 1,
5480 "deploymentPort" : 12345,
5481 "policyModelFileName" : "examples/models/VPN/VPNPolicyModelAvro.json",
5482 "engineParameters" : {
5483 "executorParameters" : {
5484 "MVEL" : {
5485 "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
5486 }
5487 },
5488 "contextParameters" : {
5489 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
5490 "schemaParameters":{
5491 "Avro":{
5492 "parameterClassName" : "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
5493 }
5494 }
5495 }
5496 }
5497 },
5498 "producerCarrierTechnologyParameters" : {
5499 "carrierTechnology" : "WEBSOCKET",
5500 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5501 "parameters" : {
5502 "wsClient" : false,
5503 "port" : 42452
5504 }
5505 },
5506 "producerEventProtocolParameters" : {
5507 "eventProtocol" : "JSON"
5508 },
5509 "consumerCarrierTechnologyParameters" : {
5510 "carrierTechnology" : "WEBSOCKET",
5511 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5512 "parameters" : {
5513 "wsClient" : false,
5514 "port" : 42450
5515 }
5516 },
5517 "consumerEventProtocolParameters" : {
5518 "eventProtocol" : "JSON"
5519 }
5520 }
5521
5522Start APEX Engine
a.sreekumarcf3ff822020-09-16 13:12:29 +01005523*****************
ramverma3b71c972019-07-10 11:25:37 +00005524
5525 .. container:: paragraph
5526
5527 In a new terminal, start APEX with the new configuration for
5528 Websocket-Server ingress/egress:
5529
5530 .. container:: listingblock
5531
5532 .. container:: content
5533
ramverma760cce92019-07-11 12:57:49 +00005534 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005535 :number-lines:
5536
liamfallonb621de42020-08-21 12:59:26 +01005537 #: $APEX_HOME/bin/apexApps.sh engine -c $APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json
ramverma3b71c972019-07-10 11:25:37 +00005538
5539.. container:: listingblock
5540
5541 .. container:: content
5542
ramverma760cce92019-07-11 12:57:49 +00005543 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005544 :number-lines:
5545
liamfallonb621de42020-08-21 12:59:26 +01005546 #: %APEX_HOME%\bin\apexApps.bat engine -c %APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json
ramverma3b71c972019-07-10 11:25:37 +00005547
5548.. container:: paragraph
5549
5550 Wait for APEX to start, it takes a while to create all Websocket
5551 servers (about 8 seconds on a standard laptop without cached
5552 binaries). depending on your log messages, you will see no (some, a
5553 lot) log messages. If APEX starts correctly, the last few messages
5554 you should see are:
5555
5556.. container:: listingblock
5557
5558 .. container:: content
5559
ramverma760cce92019-07-11 12:57:49 +00005560 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005561 :number-lines:
5562
5563 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)
5564 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 ...
5565 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
5566 Started Apex service
5567
5568.. container:: paragraph
5569
5570 APEX is running in the new terminal and will produce output when the
5571 policy is triggered/executed.
5572
5573Run the Websocket Echo Client
a.sreekumarcf3ff822020-09-16 13:12:29 +01005574*****************************
ramverma3b71c972019-07-10 11:25:37 +00005575
5576 .. container:: paragraph
5577
5578 The echo client is included in an APEX full installation. To run
5579 the client, open a new shell (Unix, Cygwin) or command prompt
5580 (``cmd`` on Windows). Then use the APEX application launcher to
5581 start the client.
5582
liamfallon9c7bd672019-10-03 13:42:08 +01005583 .. important::
ramverma3b71c972019-07-10 11:25:37 +00005584 APEX engine needs to run first
ramverma760cce92019-07-11 12:57:49 +00005585 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 +00005586
5587 +---------------------------------------------------------+-----------------------------------------------------------+
5588 | Unix, Cygwin | Windows |
5589 +=========================================================+===========================================================+
5590 | .. container:: | .. container:: |
5591 | | |
5592 | .. container:: listingblock | .. container:: listingblock |
5593 | | |
5594 | .. container:: content | .. container:: content |
5595 | | |
5596 | .. code:: | .. code:: |
5597 | | |
5598 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
5599 +---------------------------------------------------------+-----------------------------------------------------------+
5600
5601 .. container:: paragraph
5602
5603 Use the following command line arguments for server and port of
5604 the Websocket server. The port should be the same as configured in
5605 the APEX engine. The server host should be the host on which the
5606 APEX engine is running
5607
5608 .. container:: ulist
5609
5610 - ``-p`` defines the Websocket port to connect to (defaults to
5611 ``8887``)
5612
5613 - ``-s`` defines the host on which a Websocket server is running
5614 (defaults to ``localhost``)
5615
5616 .. container:: paragraph
5617
5618 Let’s assume that there is an APEX engine running, configured for
5619 produce Websocket carrier technology, as server, for port 42452,
5620 with produce event protocol JSON,. If we start the console client
5621 on the same host, we can omit the ``-s`` options. We start the
5622 console client as:
5623
5624 .. container:: listingblock
5625
5626 .. container:: content
5627
ramverma760cce92019-07-11 12:57:49 +00005628 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005629
5630 # $APEX_HOME/bin/apexApps.sh ws-echo -p 42452 (1)
5631 > %APEX_HOME%\bin\apexApps.bat ws-echo -p 42452 (2)
5632
5633 .. container:: colist arabic
5634
5635 +-------+--------------------------------+
5636 | **1** | Start client on Unix or Cygwin |
5637 +-------+--------------------------------+
5638 | **2** | Start client on Windows |
5639 +-------+--------------------------------+
5640
5641 .. container:: paragraph
5642
5643 Once started successfully, the client will produce the following
5644 messages (assuming we used ``-p 42452`` and an APEX engine is
5645 running on ``localhost`` with the same port:
5646
5647 .. container:: listingblock
5648
5649 .. container:: content
5650
ramverma760cce92019-07-11 12:57:49 +00005651 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005652
5653 ws-simple-echo: starting simple event echo
5654 --> server: localhost
5655 --> port: 42452
5656
5657 Once started, the application will simply print out all received events to standard out.
5658 Each received event will be prefixed by '---' and suffixed by '===='
5659
5660
5661 ws-simple-echo: opened connection to APEX (Web Socket Protocol Handshake)
5662
5663Run the Websocket Console Client
a.sreekumarcf3ff822020-09-16 13:12:29 +01005664********************************
ramverma3b71c972019-07-10 11:25:37 +00005665
5666 .. container:: paragraph
5667
5668 The console client is included in an APEX full installation. To
5669 run the client, open a new shell (Unix, Cygwin) or command prompt
5670 (``cmd`` on Windows). Then use the APEX application launcher to
5671 start the client.
5672
liamfallon9c7bd672019-10-03 13:42:08 +01005673 .. important::
ramverma3b71c972019-07-10 11:25:37 +00005674 APEX engine needs to run first
ramverma760cce92019-07-11 12:57:49 +00005675 The example assumes that an APEX engine configured for *consume* carrier technology Websocket and *JSON* event
5676 protocol is executed first.
ramverma3b71c972019-07-10 11:25:37 +00005677
5678 +------------------------------------------------------------+--------------------------------------------------------------+
5679 | Unix, Cygwin | Windows |
5680 +============================================================+==============================================================+
5681 | .. container:: | .. container:: |
5682 | | |
5683 | .. container:: listingblock | .. container:: listingblock |
5684 | | |
5685 | .. container:: content | .. container:: content |
5686 | | |
5687 | .. code:: | .. code:: |
5688 | | |
5689 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
5690 +------------------------------------------------------------+--------------------------------------------------------------+
5691
5692 .. container:: paragraph
5693
5694 Use the following command line arguments for server and port of
5695 the Websocket server. The port should be the same as configured in
5696 the APEX engine. The server host should be the host on which the
5697 APEX engine is running
5698
5699 .. container:: ulist
5700
5701 - ``-p`` defines the Websocket port to connect to (defaults to
5702 ``8887``)
5703
5704 - ``-s`` defines the host on which a Websocket server is running
5705 (defaults to ``localhost``)
5706
5707 .. container:: paragraph
5708
5709 Let’s assume that there is an APEX engine running, configured for
5710 consume Websocket carrier technology, as server, for port 42450,
5711 with consume event protocol JSON,. If we start the console client
5712 on the same host, we can omit the ``-s`` options. We start the
5713 console client as:
5714
5715 .. container:: listingblock
5716
5717 .. container:: content
5718
ramverma760cce92019-07-11 12:57:49 +00005719 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005720
5721 # $APEX_HOME/bin/apexApps.sh ws-console -p 42450 (1)
5722 > %APEX_HOME%\bin\apexApps.sh ws-console -p 42450 (2)
5723
5724 .. container:: colist arabic
5725
5726 +-------+--------------------------------+
5727 | **1** | Start client on Unix or Cygwin |
5728 +-------+--------------------------------+
5729 | **2** | Start client on Windows |
5730 +-------+--------------------------------+
5731
5732 .. container:: paragraph
5733
5734 Once started successfully, the client will produce the following
5735 messages (assuming we used ``-p 42450`` and an APEX engine is
5736 running on ``localhost`` with the same port:
5737
5738 .. container:: listingblock
5739
5740 .. container:: content
5741
ramverma760cce92019-07-11 12:57:49 +00005742 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005743
5744 ws-simple-console: starting simple event console
5745 --> server: localhost
5746 --> port: 42450
5747
5748 - terminate the application typing 'exit<enter>' or using 'CTRL+C'
5749 - events are created by a non-blank starting line and terminated by a blank line
5750
5751
5752 ws-simple-console: opened connection to APEX (Web Socket Protocol Handshake)
5753
5754Send Events
a.sreekumarcf3ff822020-09-16 13:12:29 +01005755***********
ramverma3b71c972019-07-10 11:25:37 +00005756
5757 .. container:: paragraph
5758
5759 Now you have the full system up and running:
5760
5761 .. container:: ulist
5762
5763 - Terminal 1: APEX ready and loaded
5764
5765 - Terminal 2: an echo client, printing received messages produced
5766 by the VPN policy
5767
5768 - Terminal 2: a console client, waiting for input on the console
5769 (standard in) and sending text to APEX
5770
5771 .. container:: paragraph
5772
5773 We started the engine with the VPN policy example. So all the
5774 events we are using now are located in files in the following
5775 example directory:
5776
5777 .. container:: listingblock
5778
5779 .. container:: content
5780
ramverma760cce92019-07-11 12:57:49 +00005781 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005782 :number-lines:
5783
5784 #: $APEX_HOME/examples/events/VPN
5785 > %APEX_HOME%\examples\events\VPN
5786
5787.. container:: paragraph
5788
5789 To sends events, simply copy the content of the event files into
5790 Terminal 3 (the console client). It will read multi-line JSON text
5791 and send the events. So copy the content of ``SetupEvents.json`` into
5792 the client. APEX will trigger a policy and produce some output, the
5793 echo client will also print some events created in the policy. In
5794 Terminal 1 (APEX) you’ll see some status messages from the policy as:
5795
5796.. container:: listingblock
5797
5798 .. container:: content
5799
ramverma760cce92019-07-11 12:57:49 +00005800 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005801 :number-lines:
5802
5803 {Link=L09, LinkUp=true}
5804 L09 true
5805 outFields: {Link=L09, LinkUp=true}
5806 {Link=L10, LinkUp=true}
5807 L09 true
5808 L10 true
5809 outFields: {Link=L10, LinkUp=true}
5810 {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5811 *** Customers ***
5812 C 300 300 [L09, L10]
5813 outFields: {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5814 {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5815 *** Customers ***
5816 A 300 50 [L09, L10]
5817 C 300 300 [L09, L10]
5818 outFields: {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5819 {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5820 *** Customers ***
5821 A 300 50 [L09, L10]
5822 C 300 300 [L09, L10]
5823 D 300 400 [L09, L10]
5824 outFields: {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5825 {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5826 *** Customers ***
5827 A 300 50 [L09, L10]
5828 B 300 299 [L09, L10]
5829 C 300 300 [L09, L10]
5830 D 300 400 [L09, L10]
5831 outFields: {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5832
5833.. container:: paragraph
5834
5835 In Terminal 2 (echo-client) you see the received events, the last two
5836 should look like:
5837
5838.. container:: listingblock
5839
5840 .. container:: content
5841
ramverma760cce92019-07-11 12:57:49 +00005842 .. code::
ramverma3b71c972019-07-10 11:25:37 +00005843 :number-lines:
5844
5845 ws-simple-echo: received
5846 ---------------------------------
5847 {
5848 "name": "VPNCustomerCtxtActEvent",
5849 "version": "0.0.1",
5850 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5851 "source": "Source",
5852 "target": "Target",
5853 "CustomerName": "C",
5854 "LinkList": "L09 L10",
5855 "SlaDT": 300,
5856 "YtdDT": 300
5857 }
5858 =================================
5859
5860 ws-simple-echo: received
5861 ---------------------------------
5862 {
5863 "name": "VPNCustomerCtxtActEvent",
5864 "version": "0.0.1",
5865 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5866 "source": "Source",
5867 "target": "Target",
5868 "CustomerName": "D",
5869 "LinkList": "L09 L10",
5870 "SlaDT": 300,
5871 "YtdDT": 400
5872 }
5873 =================================
5874
5875.. container:: paragraph
5876
5877 Congratulations, you have triggered a policy in APEX using
5878 Websockets, the policy did run through, created events, picked up by
5879 the echo-client.
5880
5881.. container:: paragraph
5882
5883 Now you can send the Link 09 and Link 10 events, they will trigger
5884 the actual VPN policy and some calculations are made. Let’s take the
5885 Link 09 events from ``Link09Events.json``, copy them all into
5886 Terminal 3 (the console). APEX will run the policy (with some status
5887 output), and the echo client will receive and print events.
5888
5889.. container:: paragraph
5890
5891 To terminate the applications, simply press ``CTRL+C`` in Terminal 1
5892 (APEX). This will also terminate the echo-client in Terminal 2. Then
5893 type ``exit<enter>`` in Terminal 3 (or ``CTRL+C``) to terminate the
5894 console-client.
5895
5896.. container::
5897 :name: footer
5898
5899 .. container::
5900 :name: footer-text