1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
4 .. _apex-user-manual-label:
18 .. container:: paragraph
20 APEX is 100% written in Java and runs on any platform
21 that supports a JVM, e.g. Windows, Unix, Cygwin. Some
22 APEX applications (such as the monitoring application)
23 come as web archives, they do require a war-capable web
26 Installation Requirements
27 #########################
31 - Downloaded distribution: JAVA runtime environment
32 (JRE, Java 11 or later, APEX is tested with the
35 - Building from source: JAVA development kit (JDK,
36 Java 11 or later, APEX is tested with the OpenJDK
39 - A web archive capable webserver, for instance for
40 the monitoring application
44 - for instance `Apache
45 Tomcat <https://tomcat.apache.org/>`__
47 - Sufficient rights to install APEX on the system
49 - Installation tools depending on the installation
54 - ZIP to extract from a ZIP distribution
58 - Windows for instance
59 `7Zip <http://www.7-zip.org/>`__
61 - TAR and GZ to extract from that TAR.GZ
66 - Windows for instance
67 `7Zip <http://www.7-zip.org/>`__
69 - DPKG to install from the DEB distribution
73 - Install: ``sudo apt-get install dpkg``
78 .. container:: paragraph
80 APEX supports a number of features that require extra
81 software being installed.
85 - `Apache Kafka <https://kafka.apache.org/>`__ to
86 connect APEX to a Kafka message bus
88 - `Hazelcast <https://hazelcast.com/>`__ to use
89 distributed hash maps for context
91 - `Infinispan <http://infinispan.org/>`__ for
92 distributed context and persistence
94 - `Docker <https://www.docker.com/>`__ to run APEX
95 inside a Docker container
97 Build (Install from Source) Requirements
98 ########################################
100 .. container:: paragraph
102 Installation from source requires a few development
107 - GIT to retrieve the source code
109 - Java SDK, Java version 8 or later
111 - Apache Maven 3 (the APEX build environment)
113 Get the APEX Source Code
114 ------------------------
116 .. container:: paragraph
118 The first APEX source code was hosted on Github in
119 January 2018. By the end of 2018, APEX was added as a
120 project in the ONAP Policy Framework, released later in
121 the ONAP Casablanca release.
123 .. container:: paragraph
125 The APEX source code is hosted in ONAP as project APEX.
126 The current stable version is in the master branch.
127 Simply clone the master branch from ONAP using HTTPS.
129 .. container:: listingblock
131 .. container:: content
136 git clone https://gerrit.onap.org/r/policy/apex-pdp
141 .. container:: paragraph
143 The examples in this document assume that the APEX source
144 repositories are cloned to:
148 - Unix, Cygwin: ``/usr/local/src/apex-pdp``
150 - Windows: ``C:\dev\apex-pdp``
152 - Cygwin: ``/cygdrive/c/dev/apex-pdp``
155 A Build requires ONAP Nexus
156 APEX has a dependency to ONAP parent projects. You might need to adjust your Maven M2 settings. The most current
157 settings can be found in the ONAP oparent repo: `Settings <https://git.onap.org/oparent/plain/settings.xml>`__.
161 Building APEX requires approximately 2-3 GB of hard disc space, 1 GB for the actual build with full
162 distribution and 1-2 GB for the downloaded dependencies
165 A Build requires Internet (for first build)
166 During the build, several (a lot) of Maven dependencies will be downloaded and stored in the configured local Maven
167 repository. The first standard build (and any first specific build) requires Internet access to download those
170 .. container:: paragraph
172 Use Maven to for a standard build without any tests.
174 +-------------------------------------------------------+--------------------------------------------------------+
175 | Unix, Cygwin | Windows |
176 +=======================================================+========================================================+
177 | .. container:: | .. container:: |
179 | .. container:: content | .. container:: content |
181 | .. code:: | .. code:: |
182 | :number-lines: | :number-lines: |
184 | # cd /usr/local/src/apex-pdp | >c: |
185 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
186 | | >mvn clean install -Pdocker -DskipTests |
187 +-------------------------------------------------------+--------------------------------------------------------+
189 .. container:: paragraph
191 The build takes 2-3 minutes on a standard development laptop. It
192 should run through without errors, but with a lot of messages from
195 .. container:: paragraph
197 When Maven is finished with the build, the final screen should look
198 similar to this (omitting some ``success`` lines):
200 .. container:: listingblock
202 .. container:: content
207 [INFO] tools .............................................. SUCCESS [ 0.248 s]
208 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
209 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
210 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
211 [INFO] packages ........................................... SUCCESS [ 0.336 s]
212 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
213 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
214 [INFO] ------------------------------------------------------------------------
216 [INFO] ------------------------------------------------------------------------
217 [INFO] Total time: 03:43 min
218 [INFO] Finished at: 2018-09-03T11:56:01+01:00
219 [INFO] ------------------------------------------------------------------------
221 .. container:: paragraph
223 The build will have created all artifacts required for an APEX
224 installation. The following example show how to change to the target
225 directory and how it should look like.
227 +---------------------------------------------------------------------------------------------------------------------+
229 +=====================================================================================================================+
230 | .. container:: content |
232 | .. container:: listingblock |
234 | .. container:: content |
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 +---------------------------------------------------------------------------------------------------------------------+
256 +----------------------------------------------------------------------------------------------+
258 +==============================================================================================+
261 | .. container:: listingblock |
263 | .. container:: content |
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 +----------------------------------------------------------------------------------------------+
292 .. container:: paragraph
294 APEX can be installed in different ways:
298 - Unix: automatically using ``dpkg`` from
301 - Windows, Unix, Cygwin: manually from a ``.tar.gz`` archive
303 - Windows, Unix, Cygwin: build from source using Maven, then
309 .. container:: paragraph
311 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/>`__.
314 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``.
320 .. container:: paragraph
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
328 +-------------------------------------------------------------------------------+
329 | DPKG Installation |
330 +===============================================================================+
333 | .. container:: listingblock |
335 | .. container:: content |
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 +-------------------------------------------------------------------------------+
356 .. container:: paragraph
358 Once the installation is finished, APEX is fully installed and ready
361 Install Manually from Archive (Unix, Cygwin)
362 ############################################
364 .. container:: paragraph
366 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/>`__.
369 Create a directory where APEX
370 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.
374 .. container:: listingblock
376 .. container:: content
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
388 Install Manually from Archive (Windows, 7Zip, GUI)
389 ##################################################
391 .. container:: paragraph
393 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/>`__.
396 Copy the ``tar.gz`` file into the install
397 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.
401 Now, right-click on the new created TAR file and extract the actual
402 APEX distribution. Inside the new APEX folder you will see the main directories: ``bin``,
403 ``etc``, ``examples``, ``lib``, and ``war``
405 .. container:: paragraph
407 Once extracted, please rename the created folder to
408 ``apex-full-2.0.0-SNAPSHOT``. This will keep the directory name in
409 line with the rest of this documentation.
411 Install Manually from Archive (Windows, 7Zip, CMD)
412 ##################################################
414 .. container:: paragraph
416 You can download a ``tar.gz`` archive from the
417 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
419 Copy the ``tar.gz`` file into the install
420 folder (in this example ``C:\apex``). Start ``cmd``, for instance
421 typing ``Windows+R`` and then ``cmd`` in the dialog. Assuming
422 ``7Zip`` is installed in the standard folder, simply run the
423 following commands (for APEX version 2.0.0-SNAPSHOT full
426 .. container:: listingblock
428 .. container:: content
435 >"\Program Files\7-Zip\7z.exe" x apex-pdp-package-full-2.0.0-SNAPSHOT.tar.gz -so | "\Program Files\7-Zip\7z.exe" x -aoa -si -ttar -o"apex-full-2.0.0-SNAPSHOT"
437 .. container:: paragraph
439 APEX is now installed in the folder
440 ``C:\apex\apex-full-2.0.0-SNAPSHOT``.
445 Build and Install Manually (Unix, Windows, Cygwin)
446 ##################################################
448 .. container:: paragraph
450 Clone the APEX GIT repositories into a directory. Go to that
451 directory. Use Maven to build APEX (all details on building
452 APEX from source can be found in *APEX HowTo: Build*). Install
453 from the created artifacts (``rpm``, ``deb``, ``tar.gz``, or
456 .. container:: paragraph
458 The following example shows how to build the APEX system,
459 without tests (``-DskipTests``) to safe some time. It assumes
460 that the APX GIT repositories are cloned to:
464 - Unix, Cygwin: ``/usr/local/src/apex``
466 - Windows: ``C:\dev\apex``
468 +-------------------------------------------------------+--------------------------------------------------------+
469 | Unix, Cygwin | Windows |
470 +=======================================================+========================================================+
471 | .. container:: | .. container:: |
473 | .. container:: content | .. container:: content |
475 | .. code:: | .. code:: |
476 | :number-lines: | :number-lines: |
478 | # cd /usr/local/src/apex | >c: |
479 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
480 | | >mvn clean install -Pdocker -DskipTests |
481 +-------------------------------------------------------+--------------------------------------------------------+
483 .. container:: paragraph
485 The build takes about 2 minutes without test and about 4-5 minutes
486 with tests on a standard development laptop. It should run through
487 without errors, but with a lot of messages from the build process. If
488 build with tests (i.e. without ``-DskipTests``), there will be error
489 messages and stack trace prints from some tests. This is normal, as
490 long as the build finishes successful.
492 .. container:: paragraph
494 When Maven is finished with the build, the final screen should look
495 similar to this (omitting some ``success`` lines):
497 .. container:: listingblock
499 .. container:: content
504 [INFO] tools .............................................. SUCCESS [ 0.248 s]
505 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
506 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
507 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
508 [INFO] packages ........................................... SUCCESS [ 0.336 s]
509 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
510 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
511 [INFO] ------------------------------------------------------------------------
513 [INFO] ------------------------------------------------------------------------
514 [INFO] Total time: 03:43 min
515 [INFO] Finished at: 2018-09-03T11:56:01+01:00
516 [INFO] ------------------------------------------------------------------------
518 .. container:: paragraph
520 The build will have created all artifacts required for an APEX
521 installation. The following example show how to change to the target
522 directory and how it should look like.
524 +--------------------------------------------------------------------------------------------------------------------+
526 +====================================================================================================================+
529 | .. container:: listingblock |
534 | # cd packages/apex-pdp-package-full/target |
536 | -rwxrwx---+ 1 esvevan Domain Users 772 Sep 3 11:55 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes* |
537 | -rwxrwx---+ 1 esvevan Domain Users 146328082 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT.deb* |
538 | -rwxrwx---+ 1 esvevan Domain Users 15633 Sep 3 11:54 apex-pdp-package-full-2.0.0-SNAPSHOT.jar* |
539 | -rwxrwx---+ 1 esvevan Domain Users 146296819 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz* |
540 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 archive-tmp/ |
541 | -rwxrwx---+ 1 esvevan Domain Users 89 Sep 3 11:54 checkstyle-cachefile* |
542 | -rwxrwx---+ 1 esvevan Domain Users 10621 Sep 3 11:54 checkstyle-checker.xml* |
543 | -rwxrwx---+ 1 esvevan Domain Users 584 Sep 3 11:54 checkstyle-header.txt* |
544 | -rwxrwx---+ 1 esvevan Domain Users 86 Sep 3 11:54 checkstyle-result.xml* |
545 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 classes/ |
546 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 dependency-maven-plugin-markers/ |
547 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 etc/ |
548 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 examples/ |
549 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:55 install_hierarchy/ |
550 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 maven-archiver/ |
551 +--------------------------------------------------------------------------------------------------------------------+
553 +---------------------------------------------------------------------------------------------+
555 +=============================================================================================+
558 | .. container:: listingblock |
563 | >cd packages\apex-pdp-package-full\target |
565 | 03/09/2018 11:55 <DIR> . |
566 | 03/09/2018 11:55 <DIR> .. |
567 | 03/09/2018 11:55 146,296,819 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz |
568 | 03/09/2018 11:55 146,328,082 apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
569 | 03/09/2018 11:54 15,633 apex-pdp-package-full-2.0.0-SNAPSHOT.jar |
570 | 03/09/2018 11:55 772 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes |
571 | 03/09/2018 11:54 <DIR> archive-tmp |
572 | 03/09/2018 11:54 89 checkstyle-cachefile |
573 | 03/09/2018 11:54 10,621 checkstyle-checker.xml |
574 | 03/09/2018 11:54 584 checkstyle-header.txt |
575 | 03/09/2018 11:54 86 checkstyle-result.xml |
576 | 03/09/2018 11:54 <DIR> classes |
577 | 03/09/2018 11:54 <DIR> dependency-maven-plugin-markers |
578 | 03/09/2018 11:54 <DIR> etc |
579 | 03/09/2018 11:54 <DIR> examples |
580 | 03/09/2018 11:55 <DIR> install_hierarchy |
581 | 03/09/2018 11:54 <DIR> maven-archiver |
582 | 8 File(s) 292,652,686 bytes |
583 | 9 Dir(s) 14,138,720,256 bytes free |
584 +---------------------------------------------------------------------------------------------+
586 .. container:: paragraph
588 Now, take the ``.deb`` or the ``.tar.gz`` file and install APEX.
589 Alternatively, copy the content of the folder ``install_hierarchy``
590 to your APEX directory.
595 .. container:: paragraph
597 A full installation of APEX comes with the following layout.
599 .. container:: listingblock
601 .. container:: content
620 │ └───applications (11)
623 .. container:: colist arabic
625 +-----------------------------------+-----------------------------------+
626 | **1** | binaries, mainly scripts (bash |
627 | | and bat) to start the APEX engine |
628 | | and applications |
629 +-----------------------------------+-----------------------------------+
630 | **2** | configuration files, such as |
631 | | logback (logging) and third party |
632 | | library configurations |
633 +-----------------------------------+-----------------------------------+
634 | **3** | example policy models to get |
636 +-----------------------------------+-----------------------------------+
637 | **4** | configurations for the examples |
638 | | (with sub directories for |
639 | | individual examples) |
640 +-----------------------------------+-----------------------------------+
641 | **5** | Docker files and additional |
642 | | Docker instructions for the |
644 +-----------------------------------+-----------------------------------+
645 | **6** | example events for the examples |
646 | | (with sub directories for |
647 | | individual examples) |
648 +-----------------------------------+-----------------------------------+
649 | **7** | HTML files for some examples, |
650 | | e.g. the Decisionmaker example |
651 +-----------------------------------+-----------------------------------+
652 | **8** | the policy models, generated for |
653 | | each example (with sub |
654 | | directories for individual |
656 +-----------------------------------+-----------------------------------+
657 | **9** | additional scripts for the |
658 | | examples (with sub directories |
659 | | for individual examples) |
660 +-----------------------------------+-----------------------------------+
661 | **10** | the library folder with all Java |
663 +-----------------------------------+-----------------------------------+
664 | **11** | applications, also known as jar |
665 | | with dependencies (or fat jars), |
666 | | individually deployable |
667 +-----------------------------------+-----------------------------------+
668 | **12** | WAR files for web applications |
669 +-----------------------------------+-----------------------------------+
674 .. container:: paragraph
676 Once APEX is installed, a few configurations need to be done:
680 - Create an APEX user and an APEX group (optional, if not
681 installed using RPM and DPKG)
683 - Create environment settings for ``APEX_HOME`` and
684 ``APEX_USER``, required by the start scripts
686 - Change settings of the logging framework (optional)
688 - Create directories for logging, required (execution might fail
689 if directories do not exist or cannot be created)
694 .. container:: paragraph
696 On smaller installations and test systems, APEX can run as any
699 .. container:: paragraph
701 However, if APEX is installed in production, we strongly
702 recommend you set up a dedicated user for running APEX. This
703 will isolate the execution of APEX to that user. We recommend
704 you use the userid ``apexuser`` but you may use any user you
707 .. container:: paragraph
709 The following example, for UNIX, creates a group called
710 ``apexuser``, an APEX user called ``apexuser``, adds the group
711 to the user, and changes ownership of the APEX installation to
712 the user. Substitute ``<apex-dir>`` with the directory where
715 .. container:: listingblock
717 .. container:: content
722 # sudo groupadd apexuser
723 # sudo useradd -g apexuser apexuser
724 # sudo chown -R apexuser:apexuser <apex-dir>
726 .. container:: paragraph
728 For other operating systems please consult your manual or system
731 Environment Settings: APEX_HOME and APEX_USER
732 #############################################
734 .. container:: paragraph
736 The provided start scripts for APEX require two environment
741 - ``APEX_USER`` with the user under whos name and permission APEX
742 should be started (Unix only)
744 - ``APEX_HOME`` with the directory where APEX is installed (Unix,
747 .. container:: paragraph
749 The first row in the following table shows how to set these
750 environment variables temporary (assuming the user is
751 ``apexuser``). The second row shows how to verify the settings.
752 The last row explains how to set those variables permanently.
754 +------------------------------------------------+---------------------------------------------------------+
755 | Unix, Cygwin (bash/tcsh) | Windows |
756 +================================================+=========================================================+
757 | .. container:: | .. container:: |
759 | .. container:: content | .. container:: content |
761 | .. code:: | .. code:: |
762 | :number-lines: | :number-lines: |
764 | # export APEX_USER=apexuser | >set APEX_HOME=C:\apex\apex-full-2.0.0-SNAPSHOT |
765 | # cd /opt/app/policy/apex-pdp | |
766 | # export APEX_HOME=`pwd` | |
768 +------------------------------------------------+ |
771 | .. container:: content | |
776 | # setenv APEX_USER apexuser | |
777 | # cd /opt/app/policy/apex-pdp | |
778 | # setenv APEX_HOME `pwd` | |
780 +------------------------------------------------+---------------------------------------------------------+
781 | .. container:: | .. container:: |
783 | .. container:: content | .. container:: content |
785 | .. code:: | .. code:: |
786 | :number-lines: | :number-lines: |
788 | # env | grep APEX | >set APEX_HOME |
789 | # APEX_USER=apexuser | APEX_HOME=\apex\apex-full-2.0.0-SNAPSHOT |
790 | # APEX_HOME=/opt/app/policy/apex-pdp | |
792 +------------------------------------------------+---------------------------------------------------------+
794 Making Environment Settings Permanent (Unix, Cygwin)
795 ====================================================
797 .. container:: paragraph
799 For a per-user setting, edit the a user’s ``bash`` or ``tcsh``
800 settings in ``~/.bashrc`` or ``~/.tcshrc``. For system-wide
801 settings, edit ``/etc/profiles`` (requires permissions).
803 Making Environment Settings Permanent (Windows)
804 ===============================================
806 .. container:: paragraph
812 - Click on the **Start** Menu
814 - Right click on **Computer**
816 - Select **Properties**
818 .. container:: paragraph
824 - Click on the **Start** Menu
828 .. container:: paragraph
830 Then do the following
834 - Select **Advanced System Settings**
836 - On the **Advanced** tab, click the **Environment Variables**
839 - Edit an existing variable, or create a new System variable:
840 'Variable name'="APEX_HOME", 'Variable
841 value'="C:\apex\apex-full-2.0.0-SNAPSHOT"
843 .. container:: paragraph
845 For the settings to take effect, an application needs to be
846 restarted (e.g. any open ``cmd`` window).
848 Edit the APEX Logging Settings
849 ##############################
851 .. container:: paragraph
853 Configure the APEX logging settings to your requirements, for
858 - change the directory where logs are written to, or
860 - change the log levels
862 .. container:: paragraph
864 Edit the file ``$APEX_HOME/etc/logback.xml`` for any required
865 changes. To change the log directory change the line
867 .. container:: paragraph
869 ``<property name="logDir" value="/var/log/onap/policy/apex-pdp/" />``
871 .. container:: paragraph
875 .. container:: paragraph
877 ``<property name="logDir" value="/PATH/TO/LOG/DIRECTORY/" />``
879 .. container:: paragraph
881 On Windows, it is recommended to change the log directory to:
883 .. container:: paragraph
885 ``<property name="logDir" value="C:/apex/apex-full-2.0.0-SNAPSHOT/logs" />``
887 .. container:: paragraph
889 Note: Be careful about when to use ``\`` vs. ``/`` as the path
892 Create Directories for Logging
893 ##############################
895 .. container:: paragraph
897 Make sure that the log directory exists. This is important when
898 APEX was installed manually or when the log directory was changed
899 in the settings (see above).
901 +-----------------------------------------------------------------------+-------------------------------------------------------+
902 | Unix, Cygwin | Windows |
903 +=======================================================================+=======================================================+
904 | .. container:: | .. container:: |
906 | .. container:: content | .. container:: content |
908 | .. code:: | .. code:: |
909 | :number-lines: | :number-lines: |
911 | sudo mkdir -p /var/log/onap/policy/apex-pdp | >mkdir C:\apex\apex-full-2.0.0-SNAPSHOT\logs |
912 | sudo chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp | |
913 +-----------------------------------------------------------------------+-------------------------------------------------------+
915 Verify the APEX Installation
916 ----------------------------
918 .. container:: paragraph
920 When APEX is installed and all settings are realized, the
921 installation can be verified.
923 Verify Installation - run Engine
924 ################################
926 .. container:: paragraph
928 A simple verification of an APEX installation can be done by
929 simply starting the APEX engine without specifying a tosca policy. On
930 Unix (or Cygwin) start the engine using
931 ``$APEX_HOME/bin/apexApps.sh engine``. On Windows start the engine
932 using ``%APEX_HOME%\bin\apexApps.bat engine``. The engine will fail
933 to fully start. However, if the output looks similar to the
934 following line, the APEX installation is realized.
936 .. container:: listingblock
938 .. container:: content
943 Starting Apex service with parameters [] . . .
944 start of Apex service failed.
945 org.onap.policy.apex.model.basicmodel.concepts.ApexException: Arguments validation failed.
946 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:238)
947 at org.onap.policy.apex.service.engine.main.ApexMain.<init>(ApexMain.java:86)
948 at org.onap.policy.apex.service.engine.main.ApexMain.main(ApexMain.java:351)
949 Caused by: org.onap.policy.apex.model.basicmodel.concepts.ApexException: Tosca Policy file was not specified as an argument
950 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validateReadableFile(ApexCommandLineArguments.java:242)
951 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validate(ApexCommandLineArguments.java:172)
952 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:235)
953 ... 2 common frames omitted
955 Verify Installation - run an Example
956 ####################################
958 .. container:: paragraph
960 A full APEX installation comes with several examples. Here, we can
961 fully verify the installation by running one of the examples.
963 .. container:: paragraph
965 We use the example called *SampleDomain* and configure the engine
966 to use standard in and standard out for events. Run the engine
967 with the provided configuration. Note: Cygwin executes scripts as
968 Unix scripts but runs Java as a Windows application, thus the
969 configuration file must be given as a Windows path.
971 .. container:: paragraph
973 On Unix/Linux flavoured platforms, give the commands below:
975 .. container:: listingblock
977 .. container:: content
983 export APEX_HOME <path to apex installation>
984 export APEX_USER apexuser
986 .. container:: paragraph
988 Create a Tosca Policy for the SampleDomain example using ApexCliToscaEditor
989 as explained in the section "The APEX CLI Tosca Editor". Assume the tosca policy name is SampleDomain_tosca.json.
990 You can then try to run apex using the ToscaPolicy.
992 .. container:: listingblock
994 .. container:: content
999 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/examples/SampleDomain_tosca.json (1)
1000 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\examples\SampleDomain_tosca.json(2)
1002 .. container:: colist arabic
1010 .. container:: paragraph
1012 The engine should start successfully. Assuming the logging levels are set to ``info`` in the built system, the output
1013 should look similar to this (last few lines)
1015 .. container:: listingblock
1017 .. container:: content
1022 Starting Apex service with parameters [-p, /home/ubuntu/apex/SampleDomain_tosca.json] . . .
1023 2018-09-05 15:16:42,800 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-0:0.0.1 .
1024 2018-09-05 15:16:42,804 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-1:0.0.1 .
1025 2018-09-05 15:16:42,804 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-2:0.0.1 .
1026 2018-09-05 15:16:42,805 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-3:0.0.1 .
1027 2018-09-05 15:16:42,805 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - APEX service created.
1028 2018-09-05 15:16:43,962 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging starting . . .
1029 2018-09-05 15:16:43,963 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging started
1030 2018-09-05 15:16:44,987 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-0:0.0.1
1031 2018-09-05 15:16:45,112 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-1:0.0.1
1032 2018-09-05 15:16:45,113 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-2:0.0.1
1033 2018-09-05 15:16:45,113 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-3:0.0.1
1034 2018-09-05 15:16:45,120 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Added the action listener to the engine
1035 Started Apex service
1037 .. container:: paragraph
1039 Important are the last two line, stating that APEX has added the
1040 final action listener to the engine and that the engine is started.
1042 .. container:: paragraph
1044 The engine is configured to read events from standard input and write
1045 produced events to standard output. The policy model is a very simple
1048 .. container:: paragraph
1050 The following table shows an input event in the left column and an
1051 output event in the right column. Past the input event into the
1052 console where APEX is running, and the output event should appear in
1053 the console. Pasting the input event multiple times will produce
1054 output events with different values.
1056 +----------------------------------------------------------+----------------------------------------------------------+
1057 | Input Event | Example Output Event |
1058 +==========================================================+==========================================================+
1059 | .. container:: | .. container:: |
1061 | .. container:: content | .. container:: content |
1063 | .. code:: | .. code:: |
1064 | :number-lines: | :number-lines: |
1067 | "nameSpace": "org.onap.policy.apex.sample.events", | "name": "Event0004", |
1068 | "name": "Event0000", | "version": "0.0.1", |
1069 | "version": "0.0.1", | "nameSpace": "org.onap.policy.apex.sample.events", |
1070 | "source": "test", | "source": "Act", |
1071 | "target": "apex", | "target": "Outside", |
1072 | "TestSlogan": "Test slogan for External Event0", | "TestActCaseSelected": 2, |
1073 | "TestMatchCase": 0, | "TestActStateTime": 1536157104627, |
1074 | "TestTimestamp": 1469781869269, | "TestDecideCaseSelected": 0, |
1075 | "TestTemperature": 9080.866 | "TestDecideStateTime": 1536157104625, |
1076 | } | "TestEstablishCaseSelected": 0, |
1077 | | "TestEstablishStateTime": 1536157104623, |
1078 | | "TestMatchCase": 0, |
1079 | | "TestMatchCaseSelected": 1, |
1080 | | "TestMatchStateTime": 1536157104620, |
1081 | | "TestSlogan": "Test slogan for External Event0", |
1082 | | "TestTemperature": 9080.866, |
1083 | | "TestTimestamp": 1469781869269 |
1085 +----------------------------------------------------------+----------------------------------------------------------+
1087 .. container:: paragraph
1089 Terminate APEX by simply using ``CTRL+C`` in the console.
1091 Verify a Full Installation - REST Client
1092 ########################################
1094 .. container:: paragraph
1096 APEX has a REST application for deploying, monitoring, and viewing policy models. The
1097 application can also be used to create new policy models close to
1098 the engine native policy language. Start the REST client as
1101 .. container:: listingblock
1103 .. container:: content
1108 # $APEX_HOME/bin/apexApps.sh full-client
1110 .. container:: listingblock
1112 .. container:: content
1117 >%APEX_HOME%\bin\apexApps.bat full-client
1119 .. container:: paragraph
1121 The script will start a simple web server
1122 (`Grizzly <https://javaee.github.io/grizzly/>`__) and deploy a
1123 ``war`` web archive in it. Once the client is started, it will be
1124 available on ``localhost:18989``. The last few line of the messages
1127 .. container:: listingblock
1129 .. container:: content
1134 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
1135 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.NetworkListener start
1136 INFO: Started listener bound to [localhost:18989]
1137 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.HttpServer start
1138 INFO: [HttpServer] Started.
1139 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
1142 .. container:: paragraph
1144 Now open a browser (Firefox, Chrome, Opera, Internet Explorer) and
1145 use the URL ``http://localhost:18989/``. This will connect the
1146 browser to the started REST client. Click on the "Policy Editor" button and the Policy Editor start screen should appear.
1148 .. container:: paragraph
1150 Now load a policy model by clicking the menu ``File`` and then
1151 ``Open``. In the opened dialog, go to the directory where APEX is
1152 installed, then ``examples``, ``models``, ``SampleDomain``, and there
1153 select the file ``SamplePolicyModelJAVA.json``. This will load the
1154 policy model used to verify the policy engine (see above).
1156 .. container:: paragraph
1158 Now you can use the Policy editor. To finish this verification, simply
1159 terminate your browser (or the tab), and then use ``CTRL+C`` in the
1160 console where you started the Policy editor.
1162 Installing the WAR Application
1163 ------------------------------
1165 .. container:: paragraph
1167 The three APEX clients are packaged in a WAR file. This is a complete
1168 application that can be installed and run in an application
1169 server. The application is realized as a servlet. You
1170 can find the WAR application in the `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/client/apex-client-full/>`__.
1173 .. container:: paragraph
1175 Installing and using the WAR application requires a web server
1176 that can execute ``war`` web archives. We recommend to use `Apache
1177 Tomcat <https://tomcat.apache.org/>`__, however other web servers
1178 can be used as well.
1180 .. container:: paragraph
1182 Install Apache Tomcat including the ``Manager App``, see `V9.0
1183 Docs <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html#Configuring_Manager_Application_Access>`__
1184 for details. Start the Tomcat service, or make sure that Tomcat is
1187 .. container:: paragraph
1189 There are multiple ways to install the APEX WAR application:
1191 .. container:: ulist
1193 - copy the ``.war`` file into the Tomcat ``webapps`` folder
1195 - use the Tomcat ``Manager App`` to deploy via the web interface
1197 - deploy using a REST call to Tomcat
1199 .. container:: paragraph
1201 For details on how to install ``war`` files please consult the
1203 Documentation <https://tomcat.apache.org/tomcat-9.0-doc/index.html>`__
1205 HOW-TO <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html>`__.
1206 Once you installed an APEX WAR application (and wait for
1207 sufficient time for Tomcat to finalize the installation), open the
1208 ``Manager App`` in Tomcat. You should see the APEX WAR application
1209 being installed and running.
1211 .. container:: paragraph
1213 In case of errors, examine the log files in the Tomcat log
1214 directory. In a conventional install, those log files are in the
1215 logs directory where Tomcat is installed.
1217 .. container:: paragraph
1219 The WAR application file has a name similar to *apex-client-full-<VERSION>.war*.
1221 Running APEX in Docker
1222 ----------------------
1224 .. container:: paragraph
1226 Since APEX is in ONAP, we provide a full virtualization
1227 environment for the engine.
1232 .. container:: paragraph
1234 Running APEX from the ONAP docker repository only requires 2
1237 1. Log into the ONAP docker repo
1239 .. container:: listingblock
1241 .. container:: content
1245 docker login -u docker -p docker nexus3.onap.org:10003
1247 2. Run the APEX docker image
1249 .. container:: listingblock
1251 .. container:: content
1255 docker run -it --rm nexus3.onap.org:10003/onap/policy-apex-pdp:latest
1257 Build a Docker Image
1258 ####################
1260 .. container:: paragraph
1262 Alternatively, one can use the Dockerfile defined in the Docker
1263 package to build an image.
1265 .. container:: listingblock
1267 .. container:: title
1271 .. container:: content
1277 # Docker file to build an image that runs APEX on Java 8 in Ubuntu
1281 RUN apt-get update && \
1282 apt-get upgrade -y && \
1283 apt-get install -y software-properties-common && \
1284 add-apt-repository ppa:openjdk-r/ppa -y && \
1286 apt-get install -y openjdk-8-jdk
1288 # Create apex user and group
1289 RUN groupadd apexuser
1290 RUN useradd --create-home -g apexuser apexuser
1292 # Add Apex-specific directories and set ownership as the Apex admin user
1293 RUN mkdir -p /opt/app/policy/apex-pdp
1294 RUN mkdir -p /var/log/onap/policy/apex-pdp
1295 RUN chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp
1297 # Unpack the tarball
1299 COPY apex-pdp-package-full.tar.gz /packages
1300 RUN tar xvfz /packages/apex-pdp-package-full.tar.gz --directory /opt/app/policy/apex-pdp
1301 RUN rm /packages/apex-pdp-package-full.tar.gz
1303 # Ensure everything has the correct permissions
1304 RUN find /opt/app -type d -perm 755
1305 RUN find /opt/app -type f -perm 644
1306 RUN chmod a+x /opt/app/policy/apex-pdp/bin/*
1308 # Copy examples to Apex user area
1309 RUN cp -pr /opt/app/policy/apex-pdp/examples /home/apexuser
1313 RUN chown -R apexuser:apexuser /home/apexuser/*
1316 ENV PATH /opt/app/policy/apex-pdp/bin:$PATH
1317 WORKDIR /home/apexuser
1319 Running APEX in Standalone mode
1320 -------------------------------
1322 .. container:: paragraph
1324 APEX Engine can run in standalone mode by taking in a ToscaPolicy
1325 as an argument and executing it.
1326 Assume there is a tosca policy named ToscaPolicy.json in APEX_HOME directory
1327 This policy can be executed in standalone mode using any of the below methods.
1329 Run in an APEX installation
1330 ###########################
1332 .. container:: listingblock
1334 .. container:: content
1339 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/ToscaPolicy.json(1)
1340 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\ToscaPolicy.json(2)
1342 .. container:: colist arabic
1350 Run in a docker container
1351 #########################
1353 .. container:: listingblock
1355 .. container:: content
1360 # docker run -p 6969:6969 -v $APEX_HOME/ToscaPolicy.json:/tmp/policy/ToscaPolicy.json \
1361 --name apex -it nexus3.onap.org:10001/onap/policy-apex-pdp:latest \
1362 -c "/opt/app/policy/apex-pdp/bin/apexEngine.sh -p /tmp/policy/ToscaPolicy.json"
1364 APEX Configurations Explained
1365 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1367 Introduction to APEX Configuration
1368 ----------------------------------
1370 .. container:: paragraph
1372 An APEX engine can be configured to use various combinations
1373 of event input handlers, event output handlers, event
1374 protocols, context handlers, and logic executors. The system
1375 is build using a plugin architecture. Each configuration
1376 option is realized by a plugin, which can be loaded and
1377 configured when the engine is started. New plugins can be
1378 added to the system at any time, though to benefit from a
1379 new plugin an engine will need to be restarted.
1381 .. container:: imageblock
1383 .. container:: content
1385 .. image:: images/apex-intro/ApexEngineConfig.png
1387 .. container:: title
1389 Figure 3. APEX Configuration Matrix
1391 .. container:: paragraph
1393 The APEX distribution already comes with a number of
1394 plugins. The figure above shows the provided plugins. Any
1395 combination of input, output, event protocol, context
1396 handlers, and executors is possible.
1398 General Configuration Format
1399 ----------------------------
1401 .. container:: paragraph
1403 The APEX configuration file is a JSON file containing a few
1404 main blocks for different parts of the configuration. Each
1405 block then holds the configuration details. The following
1406 code shows the main blocks:
1408 .. container:: listingblock
1410 .. container:: content
1415 "engineServiceParameters":{
1417 "engineParameters":{ (2)
1418 "executorParameters":{...}, (3)
1419 "contextParameters":{...} (4)
1420 "taskParameters":[...] (5)
1423 "eventInputParameters":{ (6)
1425 "carrierTechnologyParameters":{...},
1426 "eventProtocolParameters":{...}
1429 "carrierTechnologyParameters":{...},
1430 "eventProtocolParameters":{...}
1434 "eventOutputParameters":{ (10)
1436 "carrierTechnologyParameters":{...},
1437 "eventProtocolParameters":{...}
1440 "carrierTechnologyParameters":{...},
1441 "eventProtocolParameters":{...}
1447 .. container:: colist arabic
1449 +-----------------------------------+-----------------------------------+
1450 | **1** | main engine configuration |
1451 +-----------------------------------+-----------------------------------+
1452 | **2** | engine parameters for plugin |
1453 | | configurations (execution |
1454 | | environments and context |
1456 +-----------------------------------+-----------------------------------+
1457 | **3** | engine specific parameters, |
1458 | | mainly for executor plugins |
1459 +-----------------------------------+-----------------------------------+
1460 | **4** | context specific parameters, e.g. |
1461 | | for context schemas, persistence, |
1463 +-----------------------------------+-----------------------------------+
1464 | **5** | list of task parameters that |
1465 | | should be made available in task |
1466 | | logic (optional). |
1467 +-----------------------------------+-----------------------------------+
1468 | **6** | configuration of the input |
1470 +-----------------------------------+-----------------------------------+
1471 | **7** | an example input called |
1472 | | ``input1`` with carrier |
1473 | | technology and event protocol |
1474 +-----------------------------------+-----------------------------------+
1475 | **8** | an example input called |
1476 | | ``input2`` with carrier |
1477 | | technology and event protocol |
1478 +-----------------------------------+-----------------------------------+
1479 | **9** | any further input configuration |
1480 +-----------------------------------+-----------------------------------+
1481 | **10** | configuration of the output |
1483 +-----------------------------------+-----------------------------------+
1484 | **11** | an example output called |
1485 | | ``output1`` with carrier |
1486 | | technology and event protocol |
1487 +-----------------------------------+-----------------------------------+
1488 | **12** | an example output called |
1489 | | ``output2`` with carrier |
1490 | | technology and event protocol |
1491 +-----------------------------------+-----------------------------------+
1492 | **13** | any further output configuration |
1493 +-----------------------------------+-----------------------------------+
1495 Engine Service Parameters
1496 -------------------------
1498 .. container:: paragraph
1500 The configuration provides a number of parameters to
1501 configure the engine. An example configuration with
1502 explanations of all options is shown below.
1504 .. container:: listingblock
1506 .. container:: content
1510 "engineServiceParameters" : {
1511 "name" : "AADMApexEngine", (1)
1512 "version" : "0.0.1", (2)
1514 "instanceCount" : 4, (4)
1515 "deploymentPort" : 12345, (5)
1516 "policy_type_impl" : {...}, (6)
1517 "periodicEventPeriod": 1000, (7)
1518 "engineParameters":{ (8)
1519 "executorParameters":{...}, (9)
1520 "contextParameters":{...}, (10)
1521 "taskParameters":[...] (11)
1525 .. container:: colist arabic
1527 +-----------------------------------+-----------------------------------+
1528 | **1** | a name for the engine. The engine |
1529 | | name is used to create a key in a |
1530 | | runtime engine. An name matching |
1531 | | the following regular expression |
1532 | | can be used here: |
1533 | | ``[A-Za-z0-9\\-_\\.]+`` |
1534 +-----------------------------------+-----------------------------------+
1535 | **2** | a version of the engine, use |
1536 | | semantic versioning as explained |
1537 | | here: `Semantic |
1538 | | Versioning <http://semver.org/>`_ |
1540 | | This version is used in a runtime |
1541 | | engine to create a version of the |
1542 | | engine. For that reason, the |
1543 | | version must match the following |
1544 | | regular expression ``[A-Z0-9.]+`` |
1545 +-----------------------------------+-----------------------------------+
1546 | **3** | a numeric identifier for the |
1548 +-----------------------------------+-----------------------------------+
1549 | **4** | the number of threads (policy |
1550 | | instances executed in parallel) |
1551 | | the engine should use, use ``1`` |
1552 | | for single threaded engines |
1553 +-----------------------------------+-----------------------------------+
1554 | **5** | the port for the deployment |
1555 | | Websocket connection to the |
1557 +-----------------------------------+-----------------------------------+
1558 | **6** | the APEX policy model as a JSON |
1559 | | or YAML block to load into the |
1560 | | engine on startup when |
1561 | | APEX is running a policy that has |
1562 | | its logic and parameters |
1563 | | specified in TOSCA |
1565 +-----------------------------------+-----------------------------------+
1566 | **7** | an optional timer for periodic |
1567 | | policies, in milliseconds (a |
1568 | | defined periodic policy will be |
1569 | | executed every ``X`` |
1570 | | milliseconds), not used of not |
1572 +-----------------------------------+-----------------------------------+
1573 | **8** | engine parameters for plugin |
1574 | | configurations (execution |
1575 | | environments and context |
1577 +-----------------------------------+-----------------------------------+
1578 | **9** | engine specific parameters, |
1579 | | mainly for executor plugins |
1580 +-----------------------------------+-----------------------------------+
1581 | **10** | context specific parameters, e.g. |
1582 | | for context schemas, persistence, |
1584 +-----------------------------------+-----------------------------------+
1585 | **11** | list of task parameters that |
1586 | | should be made available in task |
1587 | | logic (optional). |
1588 +-----------------------------------+-----------------------------------+
1590 .. container:: paragraph
1592 The model file is optional, it can also be specified via
1593 command line. In any case, make sure all execution and other
1594 required plug-ins for the loaded model are loaded as
1597 Input and Output Interfaces
1598 ---------------------------
1600 .. container:: paragraph
1602 An APEX engine has two main interfaces:
1604 .. container:: ulist
1606 - An *input* interface to receive events: also known as
1607 ingress interface or consumer, receiving (consuming)
1608 events commonly named triggers, and
1610 - An *output* interface to publish produced events: also
1611 known as egress interface or producer, sending
1612 (publishing) events commonly named actions or action
1615 .. container:: paragraph
1617 The input and output interface is configured in terms of
1618 inputs and outputs, respectively. Each input and output is a
1619 combination of a carrier technology and an event protocol.
1620 Carrier technologies and event protocols are provided by
1621 plugins, each with its own specific configuration. Most
1622 carrier technologies can be configured for input as well as
1623 output. Most event protocols can be used for all carrier
1624 technologies. One exception is the JMS object event
1625 protocol, which can only be used for the JMS carrier
1626 technology. Some further restrictions apply (for instance
1627 for carrier technologies using bi- or uni-directional
1630 .. container:: paragraph
1632 Input and output interface can be configured separately, in
1633 isolation, with any number of carrier technologies. The
1634 resulting general configuration options are:
1636 .. container:: ulist
1638 - Input interface with one or more inputs
1640 .. container:: ulist
1642 - each input with a carrier technology and an event
1645 - some inputs with optional synchronous mode
1647 - some event protocols with additional parameters
1649 - Output interface with one or more outputs
1651 .. container:: ulist
1653 - each output with a carrier technology and an event
1656 - some outputs with optional synchronous mode
1658 - some event protocols with additional parameters
1660 .. container:: paragraph
1662 The configuration for input and output is contained in
1663 ``eventInputParameters`` and ``eventOutputParameters``,
1664 respectively. Inside here, one can configure any number of
1665 inputs and outputs. Each of them needs to have a unique
1666 identifier (name), the content of the name is free form. The
1667 example below shows a configuration for two inputs and two
1670 .. container:: listingblock
1672 .. container:: content
1676 "eventInputParameters": { (1)
1677 "FirstConsumer": { (2)
1678 "carrierTechnologyParameters" : {...}, (3)
1679 "eventProtocolParameters":{...}, (4)
1682 "SecondConsumer": { (6)
1683 "carrierTechnologyParameters" : {...}, (7)
1684 "eventProtocolParameters":{...}, (8)
1688 "eventOutputParameters": { (10)
1689 "FirstProducer": { (11)
1690 "carrierTechnologyParameters":{...}, (12)
1691 "eventProtocolParameters":{...}, (13)
1694 "SecondProducer": { (15)
1695 "carrierTechnologyParameters":{...}, (16)
1696 "eventProtocolParameters":{...}, (17)
1701 .. container:: colist arabic
1703 +--------+--------------------------------------------------------------------+
1704 | **1** | input interface configuration, APEX input plugins |
1705 +--------+--------------------------------------------------------------------+
1706 | **2** | first input called ``FirstConsumer`` |
1707 +--------+--------------------------------------------------------------------+
1708 | **3** | carrier technology for plugin |
1709 +--------+--------------------------------------------------------------------+
1710 | **4** | event protocol for plugin |
1711 +--------+--------------------------------------------------------------------+
1712 | **5** | any other input configuration (e.g. event name filter, see below) |
1713 +--------+--------------------------------------------------------------------+
1714 | **6** | second input called ``SecondConsumer`` |
1715 +--------+--------------------------------------------------------------------+
1716 | **7** | carrier technology for plugin |
1717 +--------+--------------------------------------------------------------------+
1718 | **8** | event protocol for plugin |
1719 +--------+--------------------------------------------------------------------+
1720 | **9** | any other plugin configuration |
1721 +--------+--------------------------------------------------------------------+
1722 | **10** | output interface configuration, APEX output plugins |
1723 +--------+--------------------------------------------------------------------+
1724 | **11** | first output called ``FirstProducer`` |
1725 +--------+--------------------------------------------------------------------+
1726 | **12** | carrier technology for plugin |
1727 +--------+--------------------------------------------------------------------+
1728 | **13** | event protocol for plugin |
1729 +--------+--------------------------------------------------------------------+
1730 | **14** | any other plugin configuration |
1731 +--------+--------------------------------------------------------------------+
1732 | **15** | second output called ``SecondProducer`` |
1733 +--------+--------------------------------------------------------------------+
1734 | **16** | carrier technology for plugin |
1735 +--------+--------------------------------------------------------------------+
1736 | **17** | event protocol for plugin |
1737 +--------+--------------------------------------------------------------------+
1738 | **18** | any other output configuration (e.g. event name filter, see below) |
1739 +--------+--------------------------------------------------------------------+
1744 .. container:: paragraph
1746 Any event defined in APEX has to be unique. The "name" of
1747 of an event is used as an identifier for an ApexEvent. Every
1748 event has to be tagged to an eventName. This can be done in different
1749 ways. Either the actual event can have a field called "name". Or, the
1750 event has some other field that can act as the identifier, which can be
1751 specified using "nameAlias". But in other cases, where a "name" or "nameAlias"
1752 cannot be specified, the incoming event coming over an endpoint can be
1753 manually tagged to an "eventName" before consuming it.
1755 .. container:: paragraph
1757 The "eventName" can have a single event's name if the event coming
1758 over the endpoint has to be always mapped to the specified eventName's
1759 definition. Otherwise, if different events can come over the endpoint,
1760 then "eventName" field can consist of multiple event names separated by
1761 "|" symbol. In this case, based on the received event's structure, it is
1762 mapped to any one of the event name specified in the "eventName" field.
1764 .. container:: paragraph
1766 The following code shows some examples on how to specify the eventName field:
1768 .. container:: listingblock
1770 .. container:: content
1774 "eventInputParameters": {
1776 "carrierTechnologyParameters" : {...},
1777 "eventProtocolParameters":{...},
1778 "eventName" : "VesEvent" (1)
1781 "carrierTechnologyParameters" : {...},
1782 "eventProtocolParameters":{...},
1783 "eventName" : "AAISuccessResponseEvent|AAIFailureResponseEvent" (2)
1790 .. container:: paragraph
1792 APEX will always send an event after a policy execution
1793 is finished. For a successful execution, the event sent
1794 is the output event created by the policy. In case the
1795 policy does not create an output event, APEX will create
1796 a new event with all input event fields plus an
1797 additional field ``exceptionMessage`` with an exception
1800 .. container:: paragraph
1802 There are situations in which this auto-generated error
1803 event might not be required or wanted:
1805 .. container:: ulist
1807 - when a policy failing should not result in an event
1808 send out via an output interface
1810 - when the auto-generated event goes back in an APEX
1811 engine (or the same APEX engine), this can create
1814 - the auto-generated event should go to a special output
1815 interface or channel
1817 .. container:: paragraph
1819 All of these situations are supported by a filter option
1820 using a wildecard (regular expression) configuration on
1821 APEX I/O interfaces. The parameter is called
1822 ``eventNameFilter`` and the value are `Java regular
1823 expressions <https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html>`__
1825 `tutorial <http://www.vogella.com/tutorials/JavaRegularExpressions/article.html>`__).
1826 The following code shows some examples:
1828 .. container:: listingblock
1830 .. container:: content
1834 "eventInputParameters": {
1836 "carrierTechnologyParameters" : {...},
1837 "eventProtocolParameters":{...},
1838 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]004$" (1)
1841 "eventOutputParameters": {
1843 "carrierTechnologyParameters":{...},
1844 "eventProtocolParameters":{...},
1845 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]104$" (2)
1852 .. container:: paragraph
1854 Executors are plugins that realize the execution of logic
1855 contained in a policy model. Logic can be in a task
1856 selector, a task, and a state finalizer. Using plugins for
1857 execution environments makes APEX very flexible to support
1858 virtually any executable logic expressions.
1860 .. container:: paragraph
1862 APEX 2.0.0-SNAPSHOT supports the following executors:
1864 .. container:: ulist
1866 - Java, for Java implemented logic
1868 .. container:: ulist
1870 - This executor requires logic implemented using the
1871 APEX Java interfaces.
1873 - Generated JAR files must be in the classpath of the
1874 APEX engine at start time.
1884 .. container:: ulist
1886 - This executor uses the latest version of the MVEL
1887 engine, which can be very hard to debug and can
1888 produce unwanted side effects during execution
1890 Configure the Javascript Executor
1891 #################################
1893 .. container:: paragraph
1895 The Javascript executor is added to the configuration as
1898 .. container:: listingblock
1900 .. container:: content
1904 "engineServiceParameters":{
1905 "engineParameters":{
1906 "executorParameters":{
1908 "parameterClassName" :
1909 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
1915 Configure the Jython Executor
1916 #############################
1918 .. container:: paragraph
1920 The Jython executor is added to the configuration as
1923 .. container:: listingblock
1925 .. container:: content
1929 "engineServiceParameters":{
1930 "engineParameters":{
1931 "executorParameters":{
1933 "parameterClassName" :
1934 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
1940 Configure the JRuby Executor
1941 ############################
1943 .. container:: paragraph
1945 The JRuby executor is added to the configuration as
1948 .. container:: listingblock
1950 .. container:: content
1954 "engineServiceParameters":{
1955 "engineParameters":{
1956 "executorParameters":{
1958 "parameterClassName" :
1959 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
1965 Configure the Java Executor
1966 ###########################
1968 .. container:: paragraph
1970 The Java executor is added to the configuration as
1973 .. container:: listingblock
1975 .. container:: content
1979 "engineServiceParameters":{
1980 "engineParameters":{
1981 "executorParameters":{
1983 "parameterClassName" :
1984 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
1990 Configure the MVEL Executor
1991 ###########################
1993 .. container:: paragraph
1995 The MVEL executor is added to the configuration as
1998 .. container:: listingblock
2000 .. container:: content
2004 "engineServiceParameters":{
2005 "engineParameters":{
2006 "executorParameters":{
2008 "parameterClassName" :
2009 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
2018 .. container:: paragraph
2020 Context handlers are responsible for all context processing.
2021 There are the following main areas:
2023 .. container:: ulist
2025 - Context schema: use schema handlers other than Java class
2026 (supported by default without configuration)
2028 - Context distribution: distribute context across multiple
2031 - Context locking: mechanisms to lock context elements for
2034 - Context persistence: mechanisms to persist context
2036 .. container:: paragraph
2038 APEX provides plugins for each of the main areas.
2040 Configure Context Schema Handler
2041 ################################
2043 .. container:: paragraph
2045 There are 2 choices available for defining schema: JSON & AVRO.
2046 JSON based schemas are recommended because of the flexibility, better tooling & easier integration.
2048 The JSON schema handler is added to the configuration as
2051 .. container:: listingblock
2053 .. container:: content
2057 "engineServiceParameters":{
2058 "engineParameters":{
2059 "contextParameters":{
2060 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2061 "schemaParameters":{
2063 "parameterClassName" :
2064 "org.onap.policy.apex.plugins.context.schema.json.JsonSchemaHelperParameters"
2071 The AVRO schema handler is added to the configuration as
2074 .. container:: listingblock
2076 .. container:: content
2080 "engineServiceParameters":{
2081 "engineParameters":{
2082 "contextParameters":{
2083 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2084 "schemaParameters":{
2086 "parameterClassName" :
2087 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
2094 .. container:: paragraph
2096 Using the AVRO schema handler has one limitation: AVRO
2097 only supports field names that represent valid Java class
2098 names. This means only letters and the character ``_``
2099 are supported. Characters commonly used in field names,
2100 such as ``.`` and ``-``, are not supported by AVRO. for
2101 more information see `Avro Spec:
2102 Names <https://avro.apache.org/docs/1.8.1/spec.html#names>`__.
2104 .. container:: paragraph
2106 To work with this limitation, the APEX Avro plugin will
2107 parse a given AVRO definition and replace *all*
2108 occurrences of ``.`` and ``-`` with a ``_``. This means
2111 .. container:: ulist
2113 - In a policy model, if the AVRO schema defined a field
2114 as ``my-name`` the policy logic should access it as
2117 - In a policy model, if the AVRO schema defined a field
2118 as ``my.name`` the policy logic should access it as
2121 - There should be no field names that convert to the
2124 .. container:: ulist
2126 - For instance the simultaneous use of
2127 ``my_name``, ``my.name``, and ``my-name`` should
2130 - If not avoided, the event processing might
2131 create unwanted side effects
2133 - If field names use any other not-supported character,
2134 the AVRO plugin will reject it
2136 .. container:: ulist
2138 - Since AVRO uses lazy initialization, this
2139 rejection might only become visible at runtime
2141 Configure Task Parameters
2142 #########################
2144 .. container:: paragraph
2146 The Task Parameters are added to the configuration as
2149 .. container:: listingblock
2151 .. container:: content
2155 "engineServiceParameters": {
2156 "engineParameters": {
2159 "key": "ParameterKey1",
2160 "value": "ParameterValue1"
2163 "taskId": "Task_Act0",
2164 "key": "ParameterKey2",
2165 "value": "ParameterValue2"
2171 .. container:: paragraph
2173 TaskParameters can be used to pass parameters from ApexConfig
2174 to the policy logic. In the config, these are optional.
2175 The list of task parameters provided in the config may be added
2176 to the tasks or existing task parameters in the task will be overriden.
2178 .. container:: paragraph
2180 If taskId is provided in ApexConfig for an entry, then that
2181 parameter is updated only for that particular task. Otherwise,
2182 the task parameter is added to all tasks.
2184 Carrier Technologies
2185 --------------------
2187 .. container:: paragraph
2189 Carrier technologies define how APEX receives (input) and
2190 sends (output) events. They can be used in any combination,
2191 using asynchronous or synchronous mode. There can also be
2192 any number of carrier technologies for the input (consume)
2193 and the output (produce) interface.
2195 .. container:: paragraph
2197 Supported *input* technologies are:
2199 .. container:: ulist
2201 - Standard input, read events from the standard input
2202 (console), not suitable for APEX background servers
2204 - File input, read events from a file
2206 - Kafka, read events from a Kafka system
2208 - Websockets, read events from a Websocket
2212 - REST (synchronous and asynchronous), additionally as
2215 - Event Requestor, allows reading of events that have been
2216 looped back into APEX
2218 .. container:: paragraph
2220 Supported *output* technologies are:
2222 .. container:: ulist
2224 - Standard output, write events to the standard output
2225 (console), not suitable for APEX background servers
2227 - File output, write events to a file
2229 - Kafka, write events to a Kafka system
2231 - Websockets, write events to a Websocket
2235 - REST (synchronous and asynchronous), additionally as
2238 - Event Requestor, allows events to be looped back into
2241 .. container:: paragraph
2243 New carrier technologies can be added as plugins to APEX or
2244 developed outside APEX and added to an APEX deployment.
2249 .. container:: paragraph
2251 Standard IO does not require a specific plugin, it is
2252 supported be default.
2256 .. container:: paragraph
2258 APEX will take events from its standard input. This
2259 carrier is good for testing, but certainly not for a
2260 use case where APEX runs as a server. The
2261 configuration is as follows:
2263 .. container:: listingblock
2265 .. container:: content
2269 "carrierTechnologyParameters" : {
2270 "carrierTechnology" : "FILE", (1)
2272 "standardIO" : true (2)
2276 .. container:: colist arabic
2278 +-------+---------------------------------------+
2279 | **1** | standard input is considered a file |
2280 +-------+---------------------------------------+
2281 | **2** | file descriptor set to standard input |
2282 +-------+---------------------------------------+
2287 .. container:: paragraph
2289 APEX will send events to its standard output. This
2290 carrier is good for testing, but certainly not for a
2291 use case where APEX runs as a server. The
2292 configuration is as follows:
2294 .. container:: listingblock
2296 .. container:: content
2300 "carrierTechnologyParameters" : {
2301 "carrierTechnology" : "FILE", (1)
2303 "standardIO" : true (2)
2307 .. container:: colist arabic
2309 +-------+----------------------------------------+
2310 | **1** | standard output is considered a file |
2311 +-------+----------------------------------------+
2312 | **2** | file descriptor set to standard output |
2313 +-------+----------------------------------------+
2318 .. container:: paragraph
2320 File IO does not require a specific plugin, it is
2321 supported be default.
2326 .. container:: paragraph
2328 APEX will take events from a file. The same file
2329 should not be used as an output. The configuration is
2332 .. container:: listingblock
2334 .. container:: content
2338 "carrierTechnologyParameters" : {
2339 "carrierTechnology" : "FILE", (1)
2341 "fileName" : "examples/events/SampleDomain/EventsIn.xmlfile" (2)
2345 .. container:: colist arabic
2347 +-------+------------------------------------------+
2348 | **1** | set file input |
2349 +-------+------------------------------------------+
2350 | **2** | the name of the file to read events from |
2351 +-------+------------------------------------------+
2355 .. container:: paragraph
2357 APEX will write events to a file. The same file should
2358 not be used as an input. The configuration is as
2361 .. container:: listingblock
2363 .. container:: content
2367 "carrierTechnologyParameters" : {
2368 "carrierTechnology" : "FILE", (1)
2370 "fileName" : "examples/events/SampleDomain/EventsOut.xmlfile" (2)
2374 .. container:: colist arabic
2376 +-------+-----------------------------------------+
2377 | **1** | set file output |
2378 +-------+-----------------------------------------+
2379 | **2** | the name of the file to write events to |
2380 +-------+-----------------------------------------+
2385 .. container:: paragraph
2387 Event Requestor IO does not require a specific plugin, it
2388 is supported be default. It should only be used with the
2389 APEX event protocol.
2391 Event Requestor Input
2392 =====================
2394 .. container:: paragraph
2396 APEX will take events from APEX.
2398 .. container:: listingblock
2400 .. container:: content
2404 "carrierTechnologyParameters" : {
2405 "carrierTechnology": "EVENT_REQUESTOR" (1)
2408 .. container:: colist arabic
2410 +-------+---------------------------+
2411 | **1** | set event requestor input |
2412 +-------+---------------------------+
2414 Event Requestor Output
2415 ======================
2417 .. container:: paragraph
2419 APEX will write events to APEX.
2421 .. container:: listingblock
2423 .. container:: content
2427 "carrierTechnologyParameters" : {
2428 "carrierTechnology": "EVENT_REQUESTOR" (1)
2431 Peering Event Requestors
2432 ========================
2434 .. container:: paragraph
2436 When using event requestors, they need to be peered.
2437 This means an event requestor output needs to be
2438 peered (associated) with an event requestor input. The
2439 following example shows the use of an event requestor
2440 with the APEX event protocol and the peering of output
2443 .. container:: listingblock
2445 .. container:: content
2449 "eventInputParameters": {
2450 "EventRequestorConsumer": {
2451 "carrierTechnologyParameters": {
2452 "carrierTechnology": "EVENT_REQUESTOR" (1)
2454 "eventProtocolParameters": {
2455 "eventProtocol": "APEX" (2)
2457 "eventNameFilter": "InputEvent", (3)
2458 "requestorMode": true, (4)
2459 "requestorPeer": "EventRequestorProducer", (5)
2460 "requestorTimeout": 500 (6)
2463 "eventOutputParameters": {
2464 "EventRequestorProducer": {
2465 "carrierTechnologyParameters": {
2466 "carrierTechnology": "EVENT_REQUESTOR" (7)
2468 "eventProtocolParameters": {
2469 "eventProtocol": "APEX" (8)
2471 "eventNameFilter": "EventListEvent", (9)
2472 "requestorMode": true, (10)
2473 "requestorPeer": "EventRequestorConsumer", (11)
2474 "requestorTimeout": 500 (12)
2478 .. container:: colist arabic
2480 +-----------------------------------+-----------------------------------+
2481 | **1** | event requestor on a consumer |
2482 +-----------------------------------+-----------------------------------+
2483 | **2** | with APEX event protocol |
2484 +-----------------------------------+-----------------------------------+
2485 | **3** | optional filter (best to use a |
2486 | | filter to prevent unwanted events |
2487 | | on the consumer side) |
2488 +-----------------------------------+-----------------------------------+
2489 | **4** | activate requestor mode |
2490 +-----------------------------------+-----------------------------------+
2491 | **5** | the peer to the output (must |
2492 | | match the output carrier) |
2493 +-----------------------------------+-----------------------------------+
2494 | **6** | an optional timeout in |
2496 +-----------------------------------+-----------------------------------+
2497 | **7** | event requestor on a producer |
2498 +-----------------------------------+-----------------------------------+
2499 | **8** | with APEX event protocol |
2500 +-----------------------------------+-----------------------------------+
2501 | **9** | optional filter (best to use a |
2502 | | filter to prevent unwanted events |
2503 | | on the consumer side) |
2504 +-----------------------------------+-----------------------------------+
2505 | **10** | activate requestor mode |
2506 +-----------------------------------+-----------------------------------+
2507 | **11** | the peer to the output (must |
2508 | | match the input carrier) |
2509 +-----------------------------------+-----------------------------------+
2510 | **12** | an optional timeout in |
2512 +-----------------------------------+-----------------------------------+
2517 .. container:: paragraph
2519 Kafka IO is supported by the APEX Kafka plugin. The
2520 configurations below are examples. APEX will take any
2521 configuration inside the parameter object and forward it
2522 to Kafka. More information on Kafka specific
2523 configuration parameters can be found in the Kafka
2526 .. container:: ulist
2529 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html>`__
2532 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html>`__
2536 .. container:: paragraph
2538 APEX will receive events from the Apache Kafka
2539 messaging system. The input is uni-directional, an
2540 engine will only receive events from the input but not
2541 send any event to the input.
2543 .. container:: listingblock
2545 .. container:: content
2549 "carrierTechnologyParameters" : {
2550 "carrierTechnology" : "KAFKA", (1)
2551 "parameterClassName" :
2552 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2554 "bootstrapServers" : "localhost:49092", (2)
2555 "groupId" : "apex-group-id", (3)
2556 "enableAutoCommit" : true, (4)
2557 "autoCommitTime" : 1000, (5)
2558 "sessionTimeout" : 30000, (6)
2559 "consumerPollTime" : 100, (7)
2560 "consumerTopicList" : ["apex-in-0", "apex-in-1"], (8)
2562 "org.apache.kafka.common.serialization.StringDeserializer", (9)
2563 "valueDeserializer" :
2564 "org.apache.kafka.common.serialization.StringDeserializer" (10)
2565 "kafkaProperties": [ (11)
2567 "security.protocol",
2571 "ssl.truststore.type",
2575 "ssl.truststore.location",
2576 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2579 "ssl.truststore.password",
2588 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2591 "ssl.endpoint.identification.algorithm",
2598 .. container:: colist arabic
2600 +--------+-------------------------------------+
2601 | **1** | set Kafka as carrier technology |
2602 +--------+-------------------------------------+
2603 | **2** | bootstrap server and port |
2604 +--------+-------------------------------------+
2605 | **3** | a group identifier |
2606 +--------+-------------------------------------+
2607 | **4** | flag for auto-commit |
2608 +--------+-------------------------------------+
2609 | **5** | auto-commit timeout in milliseconds |
2610 +--------+-------------------------------------+
2611 | **6** | session timeout in milliseconds |
2612 +--------+-------------------------------------+
2613 | **7** | consumer poll time in milliseconds |
2614 +--------+-------------------------------------+
2615 | **8** | consumer topic list |
2616 +--------+-------------------------------------+
2617 | **9** | key for the Kafka de-serializer |
2618 +--------+-------------------------------------+
2619 | **10** | value for the Kafka de-serializer |
2620 +--------+-------------------------------------+
2621 | **11** | properties for Kafka connectivity |
2622 +--------+-------------------------------------+
2624 .. container:: paragraph
2626 Kindly note that the above Kafka properties is just a reference,
2627 and the actual properties required depends on the Kafka server installation.
2631 .. container:: paragraph
2633 APEX will send events to the Apache Kafka messaging
2634 system. The output is uni-directional, an engine will
2635 send events to the output but not receive any event
2638 .. container:: listingblock
2640 .. container:: content
2644 "carrierTechnologyParameters" : {
2645 "carrierTechnology" : "KAFKA", (1)
2646 "parameterClassName" :
2647 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2649 "bootstrapServers" : "localhost:49092", (2)
2652 "batchSize" : 16384, (5)
2653 "lingerTime" : 1, (6)
2654 "bufferMemory" : 33554432, (7)
2655 "producerTopic" : "apex-out", (8)
2657 "org.apache.kafka.common.serialization.StringSerializer", (9)
2659 "org.apache.kafka.common.serialization.StringSerializer" (10)
2660 "kafkaProperties": [ (11)
2662 "security.protocol",
2666 "ssl.truststore.type",
2670 "ssl.truststore.location",
2671 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2674 "ssl.truststore.password",
2683 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2686 "ssl.endpoint.identification.algorithm",
2693 .. container:: colist arabic
2695 +--------+-----------------------------------+
2696 | **1** | set Kafka as carrier technology |
2697 +--------+-----------------------------------+
2698 | **2** | bootstrap server and port |
2699 +--------+-----------------------------------+
2700 | **3** | acknowledgement strategy |
2701 +--------+-----------------------------------+
2702 | **4** | number of retries |
2703 +--------+-----------------------------------+
2704 | **5** | batch size |
2705 +--------+-----------------------------------+
2706 | **6** | time to linger in milliseconds |
2707 +--------+-----------------------------------+
2708 | **7** | buffer memory in byte |
2709 +--------+-----------------------------------+
2710 | **8** | producer topic |
2711 +--------+-----------------------------------+
2712 | **9** | key for the Kafka serializer |
2713 +--------+-----------------------------------+
2714 | **10** | value for the Kafka serializer |
2715 +--------+-----------------------------------+
2716 | **11** | properties for Kafka connectivity |
2717 +--------+-----------------------------------+
2719 .. container:: paragraph
2721 Kindly note that the above Kafka properties is just a reference,
2722 and the actual properties required depends on the Kafka server installation.
2727 .. container:: paragraph
2729 APEX supports the Java Messaging Service (JMS) as input
2730 as well as output. JMS IO is supported by the APEX JMS
2731 plugin. Input and output support an event encoding as
2732 text (JSON string) or object (serialized object). The
2733 input configuration is the same for both encodings, the
2734 output configuration differs.
2738 .. container:: paragraph
2740 APEX will receive events from a JMS messaging system.
2741 The input is uni-directional, an engine will only
2742 receive events from the input but not send any event
2745 .. container:: listingblock
2747 .. container:: content
2751 "carrierTechnologyParameters" : {
2752 "carrierTechnology" : "JMS", (1)
2753 "parameterClassName" :
2754 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2755 "parameters" : { (2)
2756 "initialContextFactory" :
2757 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2758 "connectionFactory" : "ConnectionFactory", (4)
2759 "providerURL" : "remote://localhost:5445", (5)
2760 "securityPrincipal" : "guest", (6)
2761 "securityCredentials" : "IAmAGuest", (7)
2762 "consumerTopic" : "jms/topic/apexIn" (8)
2766 .. container:: colist arabic
2768 +-----------------------------------+-----------------------------------+
2769 | **1** | set JMS as carrier technology |
2770 +-----------------------------------+-----------------------------------+
2771 | **2** | set all JMS specific parameters |
2772 +-----------------------------------+-----------------------------------+
2773 | **3** | the context factory, in this case |
2774 | | from JBOSS (it requires the |
2776 | | org.jboss:jboss-remote-naming:2.0 |
2778 | | or a different version to be in |
2779 | | the directory ``$APEX_HOME/lib`` |
2780 | | or ``%APEX_HOME%\lib`` |
2781 +-----------------------------------+-----------------------------------+
2782 | **4** | a connection factory for the JMS |
2784 +-----------------------------------+-----------------------------------+
2785 | **5** | URL with host and port of the JMS |
2787 +-----------------------------------+-----------------------------------+
2788 | **6** | access credentials, user name |
2789 +-----------------------------------+-----------------------------------+
2790 | **7** | access credentials, user password |
2791 +-----------------------------------+-----------------------------------+
2792 | **8** | the JMS topic to listen to |
2793 +-----------------------------------+-----------------------------------+
2795 JMS Output with Text
2796 ====================
2798 .. container:: paragraph
2800 APEX engine send events to a JMS messaging system. The
2801 output is uni-directional, an engine will send events
2802 to the output but not receive any event from output.
2804 .. container:: listingblock
2806 .. container:: content
2810 "carrierTechnologyParameters" : {
2811 "carrierTechnology" : "JMS", (1)
2812 "parameterClassName" :
2813 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2814 "parameters" : { (2)
2815 "initialContextFactory" :
2816 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2817 "connectionFactory" : "ConnectionFactory", (4)
2818 "providerURL" : "remote://localhost:5445", (5)
2819 "securityPrincipal" : "guest", (6)
2820 "securityCredentials" : "IAmAGuest", (7)
2821 "producerTopic" : "jms/topic/apexOut", (8)
2822 "objectMessageSending": "false" (9)
2826 .. container:: colist arabic
2828 +-----------------------------------+-----------------------------------+
2829 | **1** | set JMS as carrier technology |
2830 +-----------------------------------+-----------------------------------+
2831 | **2** | set all JMS specific parameters |
2832 +-----------------------------------+-----------------------------------+
2833 | **3** | the context factory, in this case |
2834 | | from JBOSS (it requires the |
2836 | | org.jboss:jboss-remote-naming:2.0 |
2838 | | or a different version to be in |
2839 | | the directory ``$APEX_HOME/lib`` |
2840 | | or ``%APEX_HOME%\lib`` |
2841 +-----------------------------------+-----------------------------------+
2842 | **4** | a connection factory for the JMS |
2844 +-----------------------------------+-----------------------------------+
2845 | **5** | URL with host and port of the JMS |
2847 +-----------------------------------+-----------------------------------+
2848 | **6** | access credentials, user name |
2849 +-----------------------------------+-----------------------------------+
2850 | **7** | access credentials, user password |
2851 +-----------------------------------+-----------------------------------+
2852 | **8** | the JMS topic to write to |
2853 +-----------------------------------+-----------------------------------+
2854 | **9** | set object messaging to ``false`` |
2855 | | means it sends JSON text |
2856 +-----------------------------------+-----------------------------------+
2858 JMS Output with Object
2859 ======================
2861 .. container:: paragraph
2863 To configure APEX for JMS objects on the output
2864 interface use the same configuration as above (for
2865 output). Simply change the ``objectMessageSending``
2866 parameter to ``true``.
2871 .. container:: paragraph
2873 APEX supports the Websockets as input as well as output.
2874 WS IO is supported by the APEX Websocket plugin. This
2875 carrier technology does only support uni-directional
2876 communication. APEX will not send events to a Websocket
2877 input and any event sent to a Websocket output will
2878 result in an error log.
2880 .. container:: paragraph
2882 The input can be configured as client (APEX connects to
2883 an existing Websocket server) or server (APEX starts a
2884 Websocket server). The same applies to the output. Input
2885 and output can both use a client or a server
2886 configuration, or separate configurations (input as
2887 client and output as server, input as server and output
2888 as client). Each configuration should use its own
2889 dedicated port to avoid any communication loops. The
2890 configuration of a Websocket client is the same for input
2891 and output. The configuration of a Websocket server is
2892 the same for input and output.
2897 .. container:: paragraph
2899 APEX will connect to a given Websocket server. As
2900 input, it will receive events from the server but not
2901 send any events. As output, it will send events to the
2902 server and any event received from the server will
2903 result in an error log.
2905 .. container:: listingblock
2907 .. container:: content
2911 "carrierTechnologyParameters" : {
2912 "carrierTechnology" : "WEBSOCKET", (1)
2913 "parameterClassName" :
2914 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2916 "host" : "localhost", (2)
2921 .. container:: colist arabic
2923 +-------+------------------------------------------------------+
2924 | **1** | set Websocket as carrier technology |
2925 +-------+------------------------------------------------------+
2926 | **2** | the host name on which a Websocket server is running |
2927 +-------+------------------------------------------------------+
2928 | **3** | the port of that Websocket server |
2929 +-------+------------------------------------------------------+
2934 .. container:: paragraph
2936 APEX will start a Websocket server, which will accept
2937 any Websocket clients to connect. As input, it will
2938 receive events from the server but not send any
2939 events. As output, it will send events to the server
2940 and any event received from the server will result in
2943 .. container:: listingblock
2945 .. container:: content
2949 "carrierTechnologyParameters" : {
2950 "carrierTechnology" : "WEBSOCKET", (1)
2951 "parameterClassName" :
2952 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2954 "wsClient" : false, (2)
2959 .. container:: colist arabic
2961 +-------+------------------------------------------------------------+
2962 | **1** | set Websocket as carrier technology |
2963 +-------+------------------------------------------------------------+
2964 | **2** | disable client, so that APEX will start a Websocket server |
2965 +-------+------------------------------------------------------------+
2966 | **3** | the port for the Websocket server APEX will start |
2967 +-------+------------------------------------------------------------+
2972 .. container:: paragraph
2974 APEX can act as REST client on the input as well as on
2975 the output interface. The media type is
2976 ``application/json``, so this plugin only works with
2977 the JSON Event protocol.
2982 .. container:: paragraph
2984 APEX will connect to a given URL to receive events,
2985 but not send any events. The server is polled, i.e.
2986 APEX will do an HTTP GET, take the result, and then do
2987 the next GET. Any required timing needs to be handled
2988 by the server configured via the URL. For instance,
2989 the server could support a wait timeout via the URL as
2991 The httpCodeFilter is used for filtering the status
2992 code, and it can be configured as a regular expression
2993 string. The default httpCodeFilter is "[2][0-9][0-9]"
2994 - for successful response codes.
2995 The response with HTTP status code that matches the
2996 given regular expression is forwarded to the task,
2997 otherwise it is logged as a failure.
2999 .. container:: listingblock
3001 .. container:: content
3005 "carrierTechnologyParameters" : {
3006 "carrierTechnology" : "RESTCLIENT", (1)
3007 "parameterClassName" :
3008 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3010 "url" : "http://example.org:8080/triggers/events", (2)
3011 "httpMethod": "GET", (3)
3012 "httpCodeFilter" : "[2][0-9][0-9]", (4)
3013 "httpHeaders" : [ (5)
3014 ["Keep-Alive", "300"],
3015 ["Cache-Control", "no-cache"]
3020 .. container:: colist arabic
3022 +-------+--------------------------------------------------+
3023 | **1** | set REST client as carrier technology |
3024 +-------+--------------------------------------------------+
3025 | **2** | the URL of the HTTP server for events |
3026 +-------+--------------------------------------------------+
3027 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3028 | | optional, defaults to GET |
3029 +-------+--------------------------------------------------+
3030 | **4** | use HTTP CODE FILTER for filtering status code, |
3031 | | optional, defaults to [2][0-9][0-9] |
3032 +-------+--------------------------------------------------+
3033 | **5** | HTTP headers to use on the REST request, |
3035 +-------+--------------------------------------------------+
3040 .. container:: paragraph
3042 APEX will connect to a given URL to send events, but
3043 not receive any events. The default HTTP operation is
3044 POST (no configuration required). To change it to PUT
3045 simply add the configuration parameter (as shown in
3047 The URL can be configured statically or tagged
3048 as ``?example.{site}.org:8080/{trig}/events``,
3049 all tags such as ``site`` and ``trig`` in the URL
3050 need to be set in the properties object available to
3051 the tasks. In addition, the keys should exactly match
3052 with the tags defined in url. The scope of the properties
3053 object is per HTTP call. Hence, key/value pairs set
3054 in the properties object by task are only available
3055 for that specific HTTP call.
3057 .. container:: listingblock
3059 .. container:: content
3063 "carrierTechnologyParameters" : {
3064 "carrierTechnology" : "RESTCLIENT", (1)
3065 "parameterClassName" :
3066 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3068 "url" : "http://example.com:8888/actions/events", (2)
3069 "url" : "http://example.{site}.com:8888/{trig}/events", (2')
3070 "httpMethod" : "PUT". (3)
3071 "httpHeaders" : [ (4)
3072 ["Keep-Alive", "300"],
3073 ["Cache-Control", "no-cache"]
3077 .. container:: colist arabic
3079 +-------+--------------------------------------------------+
3080 | **1** | set REST client as carrier technology |
3081 +-------+--------------------------------------------------+
3082 | **2** | the static URL of the HTTP server for events |
3083 +-------+--------------------------------------------------+
3084 | **2'**| the tagged URL of the HTTP server for events |
3085 +-------+--------------------------------------------------+
3086 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3087 | | optional, defaults to POST |
3088 +-------+--------------------------------------------------+
3089 | **4** | HTTP headers to use on the REST request, |
3091 +-------+--------------------------------------------------+
3096 .. container:: paragraph
3098 APEX supports a REST server for input and output.
3100 .. container:: paragraph
3102 The REST server plugin always uses a synchronous mode. A
3103 client does a HTTP GET on the APEX REST server with the
3104 input event and receives the generated output event in
3105 the server reply. This means that for the REST server
3106 there has to always to be an input with an associated
3107 output. Input or output only are not permitted.
3109 .. container:: paragraph
3111 The plugin will start a Grizzly server as REST server for
3112 a normal APEX engine. If the APEX engine is executed as a
3113 servlet, for instance inside Tomcat, then Tomcat will be
3114 used as REST server (this case requires configuration on
3117 .. container:: paragraph
3119 Some configuration restrictions apply for all scenarios:
3121 .. container:: ulist
3123 - Minimum port: 1024
3125 - Maximum port: 65535
3127 - The media type is ``application/json``, so this plugin
3128 only works with the JSON Event protocol.
3130 .. container:: paragraph
3132 The URL the client calls is created using
3134 .. container:: ulist
3136 - the configured host and port, e.g.
3137 ``http://localhost:12345``
3139 - the standard path, e.g. ``/apex/``
3141 - the name of the input/output, e.g. ``FirstConsumer/``
3143 - the input or output name, e.g. ``EventIn``.
3145 .. container:: paragraph
3147 The examples above lead to the URL
3148 ``http://localhost:12345/apex/FirstConsumer/EventIn``.
3150 .. container:: paragraph
3152 A client can also get status information of the REST
3153 server using ``/Status``, e.g.
3154 ``http://localhost:12345/apex/FirstConsumer/Status``.
3156 REST Server Stand-alone
3157 =======================
3159 .. container:: paragraph
3161 We need to configure a REST server input and a REST
3162 server output. Input and output are associated with
3163 each other via there name.
3165 .. container:: paragraph
3167 Timeouts for REST calls need to be set carefully. If
3168 they are too short, the call might timeout before a
3169 policy finished creating an event.
3171 .. container:: paragraph
3173 The following example configures the input named as
3174 ``MyConsumer`` and associates an output named
3175 ``MyProducer`` with it.
3177 .. container:: listingblock
3179 .. container:: content
3183 "eventInputParameters": {
3185 "carrierTechnologyParameters" : {
3186 "carrierTechnology" : "RESTSERVER", (1)
3187 "parameterClassName" :
3188 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters",
3190 "standalone" : true, (2)
3191 "host" : "localhost", (3)
3195 "eventProtocolParameters":{
3196 "eventProtocol" : "JSON" (5)
3198 "synchronousMode" : true, (6)
3199 "synchronousPeer" : "MyProducer", (7)
3200 "synchronousTimeout" : 500 (8)
3204 .. container:: colist arabic
3206 +-------+---------------------------------------+
3207 | **1** | set REST server as carrier technology |
3208 +-------+---------------------------------------+
3209 | **2** | set the server as stand-alone |
3210 +-------+---------------------------------------+
3211 | **3** | set the server host |
3212 +-------+---------------------------------------+
3213 | **4** | set the server listen port |
3214 +-------+---------------------------------------+
3215 | **5** | use JSON event protocol |
3216 +-------+---------------------------------------+
3217 | **6** | activate synchronous mode |
3218 +-------+---------------------------------------+
3219 | **7** | associate an output ``MyProducer`` |
3220 +-------+---------------------------------------+
3221 | **8** | set a timeout of 500 milliseconds |
3222 +-------+---------------------------------------+
3224 .. container:: paragraph
3226 The following example configures the output named as
3227 ``MyProducer`` and associates the input ``MyConsumer``
3228 with it. Note that for the output there are no more
3229 paramters (such as host or port), since they are
3230 already configured in the associated input
3232 .. container:: listingblock
3234 .. container:: content
3238 "eventOutputParameters": {
3240 "carrierTechnologyParameters":{
3241 "carrierTechnology" : "RESTSERVER",
3242 "parameterClassName" :
3243 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters"
3245 "eventProtocolParameters":{
3246 "eventProtocol" : "JSON"
3248 "synchronousMode" : true,
3249 "synchronousPeer" : "MyConsumer",
3250 "synchronousTimeout" : 500
3254 REST Server Stand-alone, multi input
3255 ====================================
3257 .. container:: paragraph
3259 Any number of input/output pairs for REST servers can
3260 be configured. For instance, we can configure an input
3261 ``FirstConsumer`` with output ``FirstProducer`` and an
3262 input ``SecondConsumer`` with output
3263 ``SecondProducer``. Important is that there is always
3264 one pair of input/output.
3266 REST Server Stand-alone in Servlet
3267 ==================================
3269 .. container:: paragraph
3271 If APEX is executed as a servlet, e.g. inside Tomcat,
3272 the configuration becomes easier since the plugin can
3273 now use Tomcat as the REST server. In this scenario,
3274 there are not parameters (port, host, etc.) and the
3275 key ``standalone`` must not be used (or set to false).
3277 .. container:: paragraph
3279 For the Tomcat configuration, we need to add the REST
3282 .. container:: listingblock
3284 .. container:: content
3292 <param-value>org.onap.policy.apex.plugins.event.carrier.restserver</param-value>
3300 .. container:: paragraph
3302 APEX can act as REST requestor on the input as well as on
3303 the output interface. The media type is
3304 ``application/json``, so this plugin only works with
3305 the JSON Event protocol. This plugin allows APEX to send REST requests
3306 and to receive the reply of that request without tying up APEX resources
3307 while the request is being processed. The REST Requestor pairs a REST
3308 requestor producer and consumer together to handle the REST request
3309 and response. The REST request is created from an APEX output event
3310 and the REST response is input into APEX as a new input event.
3312 REST Requestor Output (REST Request Producer)
3313 =============================================
3315 .. container:: paragraph
3317 APEX sends a REST request when events are output by APEX, the REST
3318 request configuration is specified on the REST Request Consumer (see
3321 .. container:: listingblock
3323 .. container:: content
3327 "carrierTechnologyParameters": {
3328 "carrierTechnology": "RESTREQUESTOR", (1)
3329 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
3332 .. container:: colist arabic
3334 +-------+------------------------------------------+
3335 | **1** | set REST requestor as carrier technology |
3336 +-------+------------------------------------------+
3338 .. container:: paragraph
3340 The settings below are required on the producer to
3341 define the event that triggers the REST request and
3342 to specify the peered consumer configuration for the
3343 REST request, for example:
3345 .. container:: listingblock
3347 .. container:: content
3351 "eventNameFilter": "GuardRequestEvent", (1)
3352 "requestorMode": true, (2)
3353 "requestorPeer": "GuardRequestorConsumer", (3)
3354 "requestorTimeout": 500 (4)
3356 .. container:: colist arabic
3358 +-------+-------------------------------------------+
3359 | **1** | a filter on the event |
3360 +-------+-------------------------------------------+
3361 | **2** | requestor mode must be set to *true* |
3362 +-------+-------------------------------------------+
3363 | **3** | the peered consumer for REST requests, |
3364 | | that consumer specifies the full |
3365 | | configuration for REST requests |
3366 +-------+-------------------------------------------+
3367 | **4** | the request timeout in milliseconds, |
3368 | | overridden by timeout on consumer if that |
3369 | | is set, optional defaults to 500 |
3371 +-------+-------------------------------------------+
3373 REST Requestor Input (REST Request Consumer)
3374 ============================================
3376 .. container:: paragraph
3378 APEX will connect to a given URL to issue a REST request and
3379 wait for a REST response.
3380 The URL can be configured statically or tagged
3381 as ``?example.{site}.org:8080/{trig}/events``,
3382 all tags such as ``site`` and ``trig`` in the URL
3383 need to be set in the properties object available to
3384 the tasks. In addition, the keys should exactly match
3385 with the tags defined in url. The scope of the properties
3386 object is per HTTP call. Hence, key/value pairs set
3387 in the properties object by task are only available
3388 for that specific HTTP call.
3389 The httpCodeFilter is used for filtering the status
3390 code, and it can be configured as a regular expression
3391 string. The default httpCodeFilter is "[2][0-9][0-9]"
3392 - for successful response codes.
3393 The response with HTTP status code that matches the
3394 given regular expression is forwarded to the task,
3395 otherwise it is logged as a failure.
3397 .. container:: listingblock
3399 .. container:: content
3403 "carrierTechnologyParameters": {
3404 "carrierTechnology": "RESTREQUESTOR", (1)
3405 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
3407 "url": "http://localhost:54321/some/path/to/rest/resource", (2)
3408 "url": "http://localhost:54321/{site}/path/to/rest/{resValue}", (2')
3409 "httpMethod": "POST", (3)
3410 "requestorMode": true, (4)
3411 "requestorPeer": "GuardRequestorProducer", (5)
3412 "restRequestTimeout": 2000, (6)
3413 "httpCodeFilter" : "[2][0-9][0-9]" (7)
3414 "httpHeaders" : [ (8)
3415 ["Keep-Alive", "300"],
3416 ["Cache-Control", "no-cache"]
3420 .. container:: colist arabic
3422 +-------+--------------------------------------------------+
3423 | **1** | set REST requestor as carrier technology |
3424 +-------+--------------------------------------------------+
3425 | **2** | the static URL of the HTTP server for events |
3426 +-------+--------------------------------------------------+
3427 | **2'**| the tagged URL of the HTTP server for events |
3428 +-------+--------------------------------------------------+
3429 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3430 | | optional, defaults to GET |
3431 +-------+--------------------------------------------------+
3432 | **4** | requestor mode must be set to *true* |
3433 +-------+--------------------------------------------------+
3434 | **5** | the peered producer for REST requests, that |
3435 | | producer specifies the APEX output event that |
3436 | | triggers the REST request |
3437 +-------+--------------------------------------------------+
3438 | **6** | request timeout in milliseconds, overrides any |
3439 | | value set in the REST Requestor Producer, |
3440 | | optional, defaults to 500 millisconds |
3441 +-------+--------------------------------------------------+
3442 | **7** | use HTTP CODE FILTER for filtering status code |
3443 | | optional, defaults to [2][0-9][0-9] |
3444 +-------+--------------------------------------------------+
3445 | **8** | HTTP headers to use on the REST request, |
3447 +-------+--------------------------------------------------+
3449 .. container:: paragraph
3451 Further settings may be required on the consumer to
3452 define the input event that is produced and forwarded into
3455 .. container:: listingblock
3457 .. container:: content
3461 "eventName": "GuardResponseEvent", (1)
3462 "eventNameFilter": "GuardResponseEvent" (2)
3464 .. container:: colist arabic
3466 +-------+---------------------------+
3467 | **1** | the event name |
3468 +-------+---------------------------+
3469 | **2** | a filter on the event |
3470 +-------+---------------------------+
3475 .. container:: paragraph
3477 APEX can send requests over gRPC at the output side, and get back
3478 response at the input side. This can be used to send requests to CDS
3479 over gRPC. The media type is ``application/json``, so this plugin
3480 only works with the JSON Event protocol.
3485 .. container:: paragraph
3487 APEX will connect to a given host to send a request over
3490 .. container:: listingblock
3492 .. container:: content
3496 "carrierTechnologyParameters": {
3497 "carrierTechnology": "GRPC", (1)
3498 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
3500 "host": "cds-blueprints-processor-grpc", (2)
3502 "username": "ccsdkapps", (3)
3503 "password": ccsdkapps, (4)
3508 .. container:: colist arabic
3510 +-------+--------------------------------------------------+
3511 | **1** | set GRPC as carrier technology |
3512 +-------+--------------------------------------------------+
3513 | **2** | the host to which request is sent |
3514 +-------+--------------------------------------------------+
3515 | **2'**| the value for port |
3516 +-------+--------------------------------------------------+
3517 | **3** | username required to initiate connection |
3518 +-------+--------------------------------------------------+
3519 | **4** | password required to initiate connection |
3520 +-------+--------------------------------------------------+
3521 | **5** | the timeout value for completing the request |
3522 +-------+--------------------------------------------------+
3524 .. container:: paragraph
3526 Further settings are required on the producer to
3527 define the event that is requested, for example:
3529 .. container:: listingblock
3531 .. container:: content
3535 "eventName": "GRPCRequestEvent", (1)
3536 "eventNameFilter": "GRPCRequestEvent", (2)
3537 "requestorMode": true, (3)
3538 "requestorPeer": "GRPCRequestConsumer", (4)
3539 "requestorTimeout": 500 (5)
3541 .. container:: colist arabic
3543 +-------+---------------------------+
3544 | **1** | the event name |
3545 +-------+---------------------------+
3546 | **2** | a filter on the event |
3547 +-------+---------------------------+
3548 | **3** | the mode of the requestor |
3549 +-------+---------------------------+
3550 | **4** | a peer for the requestor |
3551 +-------+---------------------------+
3552 | **5** | a general request timeout |
3553 +-------+---------------------------+
3558 .. container:: paragraph
3560 APEX will connect to the host specified in the producer
3561 side, anad take in response back at the consumer side.
3563 .. container:: listingblock
3565 .. container:: content
3569 "carrierTechnologyParameters": {
3570 "carrierTechnology": "GRPC", (1)
3571 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
3574 .. container:: colist arabic
3576 +-------+------------------------------------------+
3577 | **1** | set GRPC as carrier technology |
3578 +-------+------------------------------------------+
3580 .. container:: paragraph
3582 Further settings are required on the consumer to
3583 define the event that is requested, for example:
3585 .. container:: listingblock
3587 .. container:: content
3591 "eventNameFilter": "GRPCResponseEvent", (1)
3592 "requestorMode": true, (2)
3593 "requestorPeer": "GRPCRequestProducer", (3)
3594 "requestorTimeout": 500 (4)
3596 .. container:: colist arabic
3598 +-------+---------------------------+
3599 | **1** | a filter on the event |
3600 +-------+---------------------------+
3601 | **2** | the mode of the requestor |
3602 +-------+---------------------------+
3603 | **3** | a peer for the requestor |
3604 +-------+---------------------------+
3605 | **4** | a general request timeout |
3606 +-------+---------------------------+
3608 Event Protocols, Format and Encoding
3609 ------------------------------------
3611 .. container:: paragraph
3613 Event protocols define what event formats APEX can receive
3614 (input) and should send (output). They can be used in any
3615 combination for input and output, unless further restricted
3616 by a carrier technology plugin (for instance for JMS
3617 output). There can only be 1 event protocol per event
3620 .. container:: paragraph
3622 Supported *input* event protocols are:
3624 .. container:: ulist
3626 - JSON, the event as a JSON string
3628 - APEX, an APEX event
3630 - JMS object, the event as a JMS object,
3632 - JMS text, the event as a JMS text,
3634 - XML, the event as an XML string,
3636 - YAML, the event as YAML text
3638 .. container:: paragraph
3640 Supported *output* event protocols are:
3642 .. container:: ulist
3644 - JSON, the event as a JSON string
3646 - APEX, an APEX event
3648 - JMS object, the event as a JMS object,
3650 - JMS text, the event as a JMS text,
3652 - XML, the event as an XML string,
3654 - YAML, the event as YAML text
3656 .. container:: paragraph
3658 New event protocols can be added as plugins to APEX or
3659 developed outside APEX and added to an APEX deployment.
3664 .. container:: paragraph
3666 The event protocol for JSON encoding does not require a
3667 specific plugin, it is supported by default. Furthermore,
3668 there is no difference in the configuration for the input
3669 and output interface.
3671 .. container:: paragraph
3673 For an input, APEX requires a well-formed JSON string.
3674 Well-formed here means according to the definitions of a
3675 policy. Any JSON string that is not defined as a trigger
3676 event (consume) will not be consumed (errors will be
3677 thrown). For output JSON events, APEX will always produce
3678 valid JSON strings according to the definition in the
3681 .. container:: paragraph
3683 The following JSON shows the configuration.
3685 .. container:: listingblock
3687 .. container:: content
3691 "eventProtocolParameters":{
3692 "eventProtocol" : "JSON"
3695 .. container:: paragraph
3697 For JSON events, there are a few more optional
3698 parameters, which allow to define a mapping for standard
3699 event fields. An APEX event must have the fields
3700 ``name``, ``version``, ``source``, and ``target``
3701 defined. Sometimes it is not possible to configure a
3702 trigger or actioning system to use those fields. However,
3703 they might be in an event generated outside APEX (or used
3704 outside APEX) just with different names. To configure
3705 APEX to map between the different event names, simply add
3706 the following parameters to a JSON event:
3708 .. container:: listingblock
3710 .. container:: content
3714 "eventProtocolParameters":{
3715 "eventProtocol" : "JSON",
3716 "nameAlias" : "policyName", (1)
3717 "versionAlias" : "policyVersion", (2)
3718 "sourceAlias" : "from", (3)
3719 "targetAlias" : "to", (4)
3720 "nameSpaceAlias": "my.name.space" (5)
3723 .. container:: colist arabic
3725 +-----------------------------------+-----------------------------------+
3726 | **1** | mapping for the ``name`` field, |
3727 | | here from a field called |
3728 | | ``policyName`` |
3729 +-----------------------------------+-----------------------------------+
3730 | **2** | mapping for the ``version`` |
3731 | | field, here from a field called |
3732 | | ``policyVersion`` |
3733 +-----------------------------------+-----------------------------------+
3734 | **3** | mapping for the ``source`` field, |
3735 | | here from a field called ``from`` |
3736 | | (only for an input event) |
3737 +-----------------------------------+-----------------------------------+
3738 | **4** | mapping for the ``target`` field, |
3739 | | here from a field called ``to`` |
3740 | | (only for an output event) |
3741 +-----------------------------------+-----------------------------------+
3742 | **5** | mapping for the ``nameSpace`` |
3743 | | field, here from a field called |
3744 | | ``my.name.space`` |
3745 +-----------------------------------+-----------------------------------+
3749 .. container:: paragraph
3751 The event protocol for APEX events does not require a
3752 specific plugin, it is supported by default. Furthermore,
3753 there is no difference in the configuration for the input
3754 and output interface.
3756 .. container:: paragraph
3758 For input and output APEX uses APEX events.
3760 .. container:: paragraph
3762 The following JSON shows the configuration.
3764 .. container:: listingblock
3766 .. container:: content
3770 "eventProtocolParameters":{
3771 "eventProtocol" : "APEX"
3777 .. container:: paragraph
3779 The event protocol for JMS is provided by the APEX JMS
3780 plugin. The plugin supports encoding as JSON text or as
3781 object. There is no difference in the configuration for
3782 the input and output interface.
3786 .. container:: paragraph
3788 If used as input, APEX will take a JMS message and
3789 extract a JSON string, then proceed as if a JSON event
3790 was received. If used as output, APEX will take the
3791 event produced by a policy, create a JSON string, and
3792 then wrap it into a JMS message.
3794 .. container:: paragraph
3796 The configuration for JMS text is as follows:
3798 .. container:: listingblock
3800 .. container:: content
3804 "eventProtocolParameters":{
3805 "eventProtocol" : "JMSTEXT",
3806 "parameterClassName" :
3807 "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters"
3812 .. container:: paragraph
3814 If used as input, APEX will will take a JMS message,
3815 extract a Java Bean from the ``ObjectMessage``
3816 message, construct an APEX event and put the bean on
3817 the APEX event as a parameter. If used as output, APEX
3818 will take the event produced by a policy, create a
3819 Java Bean and send it as a JMS message.
3821 .. container:: paragraph
3823 The configuration for JMS object is as follows:
3825 .. container:: listingblock
3827 .. container:: content
3831 "eventProtocolParameters":{
3832 "eventProtocol" : "JMSOBJECT",
3833 "parameterClassName" :
3834 "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters"
3840 .. container:: paragraph
3842 The event protocol for YAML is provided by the APEX YAML
3843 plugin. There is no difference in the configuration for
3844 the input and output interface.
3846 .. container:: paragraph
3848 If used as input, APEX will consume events as YAML and
3849 map them to policy trigger events. Not well-formed YAML
3850 and not understood trigger events will be rejected. If
3851 used as output, APEX produce YAML encoded events from the
3852 event a policy produces. Those events will always be
3853 well-formed according to the definition in the policy
3856 .. container:: paragraph
3858 The following code shows the configuration.
3860 .. container:: listingblock
3862 .. container:: content
3866 "eventProtocolParameters":{
3867 "eventProtocol" : "XML",
3868 "parameterClassName" :
3869 "org.onap.policy.apex.plugins.event.protocol.yaml.YamlEventProtocolParameters"
3874 .. container:: paragraph
3876 The event protocol for XML is provided by the APEX XML
3877 plugin. There is no difference in the configuration for
3878 the input and output interface.
3880 .. container:: paragraph
3882 If used as input, APEX will consume events as XML and map
3883 them to policy trigger events. Not well-formed XML and
3884 not understood trigger events will be rejected. If used
3885 as output, APEX produce XML encoded events from the event
3886 a policy produces. Those events will always be
3887 well-formed according to the definition in the policy
3890 .. container:: paragraph
3892 The following code shows the configuration.
3894 .. container:: listingblock
3896 .. container:: content
3900 "eventProtocolParameters":{
3901 "eventProtocol" : "XML",
3902 "parameterClassName" :
3903 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3906 A configuration example
3907 -----------------------
3909 .. container:: paragraph
3911 The following example loads all available plug-ins.
3913 .. container:: paragraph
3915 Events are consumed from a Websocket, APEX as client.
3916 Consumed event format is JSON.
3918 .. container:: paragraph
3920 Events are produced to Kafka. Produced event format is XML.
3922 .. container:: listingblock
3924 .. container:: content
3929 "engineServiceParameters" : {
3930 "name" : "MyApexEngine",
3931 "version" : "0.0.1",
3933 "instanceCount" : 4,
3934 "deploymentPort" : 12345,
3935 "engineParameters" : {
3936 "executorParameters" : {
3938 "parameterClassName" :
3939 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
3942 "parameterClassName" :
3943 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
3946 "parameterClassName" :
3947 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
3950 "parameterClassName" :
3951 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
3954 "parameterClassName" :
3955 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
3958 "contextParameters" : {
3959 "parameterClassName" :
3960 "org.onap.policy.apex.context.parameters.ContextParameters",
3961 "schemaParameters" : {
3963 "parameterClassName" :
3964 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
3970 "producerCarrierTechnologyParameters" : {
3971 "carrierTechnology" : "KAFKA",
3972 "parameterClassName" :
3973 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
3975 "bootstrapServers" : "localhost:49092",
3978 "batchSize" : 16384,
3980 "bufferMemory" : 33554432,
3981 "producerTopic" : "apex-out",
3982 "keySerializer" : "org.apache.kafka.common.serialization.StringSerializer",
3983 "valueSerializer" : "org.apache.kafka.common.serialization.StringSerializer"
3986 "producerEventProtocolParameters" : {
3987 "eventProtocol" : "XML",
3988 "parameterClassName" :
3989 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3991 "consumerCarrierTechnologyParameters" : {
3992 "carrierTechnology" : "WEBSOCKET",
3993 "parameterClassName" :
3994 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
3996 "host" : "localhost",
4000 "consumerEventProtocolParameters" : {
4001 "eventProtocol" : "JSON"
4005 Engine and Applications of the APEX System
4006 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4008 Introduction to APEX Engine and Applications
4009 --------------------------------------------
4011 .. container:: paragraph
4013 The core of APEX is the APEX Engine, also known as the APEX
4014 Policy Engine or the APEX PDP (since it is in fact a Policy
4015 Decision Point). Beside this engine, an APEX system comes
4016 with a few applications intended to help with policy
4017 authoring, deployment, and execution.
4019 .. container:: paragraph
4021 The engine itself and most applications are started from the
4022 command line with command line arguments. This is called a
4023 Command Line Interface (CLI). Some applications require an
4024 installation on a webserver, as for instance the REST
4025 Editor. Those applications can be accessed via a web
4028 .. container:: paragraph
4030 You can also use the available APEX APIs and applications to
4031 develop other applications as required. This includes policy
4032 languages (and associated parsers and compilers /
4033 interpreters), GUIs to access APEX or to define policies,
4034 clients to connect to APEX, etc.
4036 .. container:: paragraph
4038 For this documentation, we assume an installation of APEX as
4039 a full system based on a current ONAP release.
4041 CLI on Unix, Windows, and Cygwin
4042 --------------------------------
4044 .. container:: paragraph
4046 A note on APEX CLI applications: all applications and the
4047 engine itself have been deployed and tested on different
4048 operating systems: Red Hat, Ubuntu, Debian, Mac OSX,
4049 Windows, Cygwin. Each operating system comes with its own
4050 way of configuring and executing Java. The main items here
4053 .. container:: ulist
4055 - For UNIX systems (RHL, Ubuntu, Debian, Mac OSX), the
4056 provided bash scripts work as expected with absolute
4058 ``/opt/app/policy/apex-pdp/apex-pdp-2.0.0-SNAPSHOT/examples``),
4059 indirect and linked paths (e.g. ``../apex/apex``), and
4060 path substitutions using environment settings (e.g.
4061 ``$APEX_HOME/bin/``)
4063 - For Windows systems, the provided batch files (``.bat``)
4064 work as expected with with absolute paths (e.g.
4065 ``C:\apex\apex-2.0.0-SNAPSHOT\examples``), and path
4066 substitutions using environment settings (e.g.
4067 ``%APEX_HOME%\bin\``)
4069 - For Cygwin system we assume a standard Cygwin
4070 installation with standard tools (mainly bash) using a
4071 Windows Java installation. This means that the bash
4072 scripts can be used as in UNIX, however any argument
4073 pointing to files and directories need to use either a
4075 ``C:\apex\apex-2.0.0-SNAPSHOT\examples\config...``) or
4076 the command ``cygpath`` with a mixed option. The reason
4077 for that is: Cygwin executes Java using UNIX paths but
4078 then runs Java as a DOS/WINDOWS process, which requires
4079 DOS paths for file access.
4084 .. container:: paragraph
4086 The APEX engine can be started in different ways, depending
4087 your requirements. All scripts are located in the APEX *bin*
4090 .. container:: paragraph
4092 On UNIX and Cygwin systems use:
4094 .. container:: ulist
4096 - ``apexEngine.sh`` - this script will
4098 .. container:: ulist
4100 - Test if ``$APEX_USER`` is set and if the user
4101 exists, terminate with an error otherwise
4103 - Test if ``$APEX_HOME`` is set. If not set, it will
4104 use the default setting as
4105 ``/opt/app/policy/apex-pdp/apex-pdp``. Then the set
4106 directory is tested to exist, the script will
4109 - When all tests are passed successfully, the script
4110 will call ``apexApps.sh`` with arguments to start
4113 - ``apexApps.sh engine`` - this is the general APEX
4114 application launcher, which will
4116 .. container:: ulist
4118 - Start the engine with the argument ``engine``
4120 - Test if ``$APEX_HOME`` is set and points to an
4121 existing directory. If not set or directory does
4122 not exist, script terminates.
4124 - Not test for any settings of ``$APEX_USER``.
4126 .. container:: paragraph
4128 On Windows systems use ``apexEngine.bat`` and
4129 ``apexApps.bat engine`` respectively. Note: none of the
4130 windows batch files will test for ``%APEX_USER%``.
4132 .. container:: paragraph
4134 Summary of alternatives to start the APEX Engine:
4136 +--------------------------------------------------------+----------------------------------------------------------+
4137 | Unix, Cygwin | Windows |
4138 +========================================================+==========================================================+
4139 | .. container:: | .. container:: |
4141 | .. container:: listingblock | .. container:: listingblock |
4143 | .. container:: content | .. container:: content |
4145 | .. code:: | .. code:: |
4147 | # $APEX_HOME/bin/apexEngine.sh [args] | > %APEX_HOME%\bin\apexEngine.bat [args] |
4148 | # $APEX_HOME/bin/apexApps.sh engine [args] | > %APEX_HOME%\bin\apexApps.bat engine [args] |
4149 +--------------------------------------------------------+----------------------------------------------------------+
4151 .. container:: paragraph
4153 The APEX engine comes with a few CLI arguments, the main one is for setting
4154 the tosca policy file for execution. The tosca policy file is
4155 always required. The option ``-h`` prints a help screen.
4157 .. container:: listingblock
4159 .. container:: content
4163 usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]
4165 -p,--tosca-policy-file <TOSCA_POLICY_FILE> the full path to the ToscaPolicy file to use.
4166 -h,--help outputs the usage of this command
4167 -v,--version outputs the version of Apex
4172 .. container:: paragraph
4174 The CLI Editor allows to define policies from the command
4175 line. The application uses a simple language and supports
4176 all elements of an APEX policy. It can be used in to
4179 .. container:: ulist
4181 - non-interactive, specifying a file with the commands to
4184 - interactive, using the editors CLI to create a policy
4186 .. container:: paragraph
4188 When a policy is fully specified, the editor will generate
4189 the APEX core policy specification in JSON. This core
4190 specification is called the policy model in the APEX engine
4191 and can be used directly with the APEX engine.
4193 .. container:: paragraph
4195 On UNIX and Cygwin systems use:
4197 .. container:: ulist
4199 - ``apexCLIEditor.sh`` - simply starts the CLI editor,
4200 arguments to the script determine the mode of the editor
4202 - ``apexApps.sh cli-editor`` - simply starts the CLI
4203 editor, arguments to the script determine the mode of the
4206 .. container:: paragraph
4208 On Windows systems use:
4210 .. container:: ulist
4212 - ``apexCLIEditor.bat`` - simply starts the CLI editor,
4213 arguments to the script determine the mode of the editor
4215 - ``apexApps.bat cli-editor`` - simply starts the CLI
4216 editor, arguments to the script determine the mode of the
4219 .. container:: paragraph
4221 Summary of alternatives to start the APEX CLI Editor:
4223 +------------------------------------------------------------+--------------------------------------------------------------+
4224 | Unix, Cygwin | Windows |
4225 +============================================================+==============================================================+
4226 | .. container:: | .. container:: |
4228 | .. container:: listingblock | .. container:: listingblock |
4230 | .. container:: content | .. container:: content |
4232 | .. code:: | .. code:: |
4234 | # $APEX_HOME/bin/apexCLIEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIEditor.bat [args] |
4235 | # $APEX_HOME/bin/apexApps.sh cli-editor [args] | > %APEX_HOME%\bin\apexApps.bat cli-editor [args] |
4236 +------------------------------------------------------------+--------------------------------------------------------------+
4238 .. container:: paragraph
4240 The option ``-h`` provides a help screen with all command
4243 .. container:: listingblock
4245 .. container:: content
4249 usage: org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain [options...]
4251 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4252 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4253 -h,--help outputs the usage of this command
4254 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4255 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and continue
4256 executing the command file
4257 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will log
4258 to standard output if not specified or suppressed with "-nl" flag
4259 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4260 -nl,--no-log if specified, no logging or output of commands to standard output or log
4262 -nm,--no-model-output if specified, no output of a model to standard output or model output
4263 file is carried out, the user can use the "save" command in a script to
4265 -o,--output-model-file <OUTPUT_MODEL_FILE> name of a file that will contain the output model for the editor, will
4266 output model to standard output if not specified or suppressed with
4268 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4269 root from which to look for included macro files
4271 The APEX CLI Tosca Editor
4272 -------------------------
4274 .. container:: paragraph
4276 As per the new Policy LifeCycle API, the policies are expected to be defined as ToscaServiceTemplate. The CLI Tosca Editor is an extended version of the APEX CLI Editor which can generate the policies in ToscaServiceTemplate way.
4278 .. container:: paragraph
4280 The APEX config file(.json), command file(.apex) and the tosca template skeleton(.json) file paths need to be passed as input arguments to the CLI Tosca Editor. Policy in ToscaServiceTemplate format is generated as the output. This can be used as the input to Policy API for creating policies.
4282 .. container:: paragraph
4284 On UNIX and Cygwin systems use:
4286 .. container:: ulist
4288 - ``apexCLIToscaEditor.sh`` - starts the CLI Tosca editor,
4289 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4291 - ``apexApps.sh cli-tosca-editor`` - starts the CLI Tosca editor,
4292 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4294 .. container:: paragraph
4296 On Windows systems use:
4298 .. container:: ulist
4300 - ``apexCLIToscaEditor.bat`` - starts the CLI Tosca editor,
4301 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4303 - ``apexApps.bat cli-tosca-editor`` - starts the CLI Tosca
4304 editor, all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4306 .. container:: paragraph
4308 Summary of alternatives to start the APEX CLI Tosca Editor:
4310 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4311 | Unix, Cygwin | Windows |
4312 +=================================================================+====================================================================+
4313 | .. container:: | .. container:: |
4315 | .. container:: listingblock | .. container:: listingblock |
4317 | .. container:: content | .. container:: content |
4319 | .. code:: | .. code:: |
4321 | # $APEX_HOME/bin/apexCLIToscaEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIToscaEditor.bat [args] |
4322 | # $APEX_HOME/bin/apexApps.sh cli-tosca-editor [args]| > %APEX_HOME%\bin\apexApps.bat cli-tosca-editor [args] |
4323 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4325 .. container:: paragraph
4327 The option ``-h`` provides a help screen with all command
4330 .. container:: listingblock
4332 .. container:: content
4336 usage: org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain [options...]
4338 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4339 -ac,--apex-config-file <APEX_CONFIG_FILE> name of the file containing apex configuration details
4340 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4341 -h,--help outputs the usage of this command
4342 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4343 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and
4344 continue executing the command file
4345 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will
4346 log to standard output if not specified or suppressed with "-nl" flag
4347 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4348 -nl,--no-log if specified, no logging or output of commands to standard output or
4349 log file is carried out
4350 -ot,--output-tosca-file <OUTPUT_TOSCA_FILE> name of a file that will contain the output ToscaServiceTemplate
4351 -t,--tosca-template-file <TOSCA_TEMPLATE_FILE> name of the input file containing tosca template which needs to be
4353 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4354 root from which to look for included macro files
4356 .. container:: paragraph
4358 An example command to run the APEX CLI Tosca editor on windows machine is given below.
4360 .. container:: listingblock
4362 .. container:: content
4366 %APEX_HOME%/\bin/\apexCLIToscaEditor.bat -c %APEX_HOME%\examples\PolicyModel.apex -ot %APEX_HOME%\examples\test.json -l %APEX_HOME%\examples\test.log -ac %APEX_HOME%\examples\RESTServerStandaloneJsonEvent.json -t %APEX_HOME%\examples\ToscaTemplate.json
4372 .. container:: paragraph
4374 The APEX Client combines the Policy Editor, the
4375 Monitoring Client, and the Deployment Client into a single
4376 application. The standard way to use the APEX Full Client is
4377 via an installation of the *war* file on a webserver.
4378 However, the Full Client can also be started via command
4379 line. This will start a Grizzly webserver with the *war*
4380 deployed. Access to the Full Client is then via the provided
4383 .. container:: paragraph
4385 On UNIX and Cygwin systems use:
4387 .. container:: ulist
4389 - ``apexApps.sh full-client`` - simply starts the webserver
4390 with the Full Client
4392 .. container:: paragraph
4394 On Windows systems use:
4396 .. container:: ulist
4398 - ``apexApps.bat full-client`` - simply starts the
4399 webserver with the Full Client
4401 .. container:: paragraph
4403 The option ``-h`` provides a help screen with all command
4406 .. container:: listingblock
4408 .. container:: content
4412 usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]
4413 -h,--help outputs the usage of this command
4414 -p,--port <PORT> port to use for the Apex Services REST calls
4415 -t,--time-to-live <TIME_TO_LIVE> the amount of time in seconds that the server will run for before terminating
4417 .. container:: paragraph
4419 If the Full Client is started without any arguments the
4420 final messages will look similar to this:
4422 .. container:: listingblock
4424 .. container:: content
4428 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
4429 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.NetworkListener start
4430 INFO: Started listener bound to [localhost:18989]
4431 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.HttpServer start
4432 INFO: [HttpServer] Started.
4433 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
4435 .. container:: paragraph
4437 The last line states the URL on which the Monitoring Client
4438 can be accessed. The example above stated
4439 ``http://localhost:18989/apexservices``. In a web browser
4440 use the URL ``http://localhost:18989``.
4442 The APEX Application Launcher
4443 -----------------------------
4445 .. container:: paragraph
4447 The standard applications (Engine and CLI Editor)
4448 come with dedicated start scripts. For all other APEX
4449 applications, we provide an application launcher.
4451 .. container:: paragraph
4453 On UNIX and Cygwin systems use:
4455 .. container:: ulist
4457 - apexApps.sh\` - simply starts the application launcher
4459 .. container:: paragraph
4461 On Windows systems use:
4463 .. container:: ulist
4465 - ``apexApps.bat`` - simply starts the application launcher
4467 .. container:: paragraph
4469 Summary of alternatives to start the APEX application
4472 +-------------------------------------------------+---------------------------------------------------+
4473 | Unix, Cygwin | Windows |
4474 +=================================================+===================================================+
4475 | .. container:: | .. container:: |
4477 | .. container:: listingblock | .. container:: listingblock |
4479 | .. container:: content | .. container:: content |
4481 | .. code:: | .. code:: |
4483 | # $APEX_HOME/bin/apexApps.sh [args] | > %APEX_HOME%\bin\apexApps.bat [args] |
4484 +-------------------------------------------------+---------------------------------------------------+
4486 .. container:: paragraph
4488 The option ``-h`` provides a help screen with all launcher
4489 command line arguments.
4491 .. container:: listingblock
4493 .. container:: content
4497 apexApps.sh - runs APEX applications
4499 Usage: apexApps.sh [options] | [<application> [<application options>]]
4502 -d <app> - describes an application
4503 -l - lists all applications supported by this script
4504 -h - this help screen
4506 .. container:: paragraph
4508 Using ``-l`` lists all known application the launcher can
4511 .. container:: listingblock
4513 .. container:: content
4517 apexApps.sh: supported applications:
4518 --> ws-echo engine eng-monitoring full-client eng-deployment tpl-event-json model-2-cli rest-editor cli-editor ws-console
4520 .. container:: paragraph
4522 Using the ``-d <name>`` option describes the named
4523 application, for instance for the ``ws-console``:
4525 .. container:: listingblock
4527 .. container:: content
4531 apexApps.sh: application 'ws-console'
4532 --> a simple console sending events to APEX, connect to APEX consumer port
4534 .. container:: paragraph
4536 Launching an application is done by calling the script with
4537 only the application name and any CLI arguments for the
4538 application. For instance, starting the ``ws-echo``
4539 application with port ``8888``:
4541 .. container:: listingblock
4543 .. container:: content
4547 apexApps.sh ws-echo -p 8888
4549 Application: Create Event Templates
4550 -----------------------------------
4552 .. container:: paragraph
4554 **Status: Experimental**
4556 .. container:: paragraph
4558 This application takes a policy model (JSON or XML encoded)
4559 and generates templates for events in JSON format. This can
4560 help when a policy defines rather complex trigger or action
4561 events or complex events between states. The application can
4562 produce events for the types: stimuli (policy trigger
4563 events), internal (events between policy states), and
4564 response (action events).
4566 +----------------------------------------------------------------+------------------------------------------------------------------+
4567 | Unix, Cygwin | Windows |
4568 +================================================================+==================================================================+
4569 | .. container:: | .. container:: |
4571 | .. container:: listingblock | .. container:: listingblock |
4573 | .. container:: content | .. container:: content |
4575 | .. code:: | .. code:: |
4577 | # $APEX_HOME/bin/apexApps.sh tpl-event-json [args] | > %APEX_HOME%\bin\apexApps.bat tpl-event-json [args] |
4578 +----------------------------------------------------------------+------------------------------------------------------------------+
4580 .. container:: paragraph
4582 The option ``-h`` provides a help screen.
4584 .. container:: listingblock
4586 .. container:: content
4590 gen-model2event v{release-version} - generates JSON templates for events generated from a policy model
4591 usage: gen-model2event
4592 -h,--help prints this help and usage screen
4593 -m,--model <MODEL-FILE> set the input policy model file
4594 -t,--type <TYPE> set the event type for generation, one of:
4595 stimuli (trigger events), response (action
4596 events), internal (events between states)
4597 -v,--version prints the application version
4599 .. container:: paragraph
4601 The created templates are not valid events, instead they use
4602 some markup for values one will need to change to actual
4603 values. For instance, running the tool with the *Sample
4604 Domain* policy model as:
4606 .. container:: listingblock
4608 .. container:: content
4612 apexApps.sh tpl-event-json -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json -t stimuli
4614 .. container:: paragraph
4616 will produce the following status messages:
4618 .. container:: listingblock
4620 .. container:: content
4624 gen-model2event: starting Event generator
4625 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4628 .. container:: paragraph
4630 and then run the generator application producing two event
4631 templates. The first template is called ``Event0000``.
4633 .. container:: listingblock
4635 .. container:: content
4640 "name" : "Event0000",
4641 "nameSpace" : "org.onap.policy.apex.sample.events",
4642 "version" : "0.0.1",
4643 "source" : "Outside",
4645 "TestTemperature" : ###double: 0.0###,
4646 "TestTimestamp" : ###long: 0###,
4647 "TestMatchCase" : ###integer: 0###,
4648 "TestSlogan" : "###string###"
4651 .. container:: paragraph
4653 The values for the keys are marked with ``#`` and the
4654 expected type of the value. To create an actual stimuli
4655 event, all these markers need to be change to actual values,
4658 .. container:: listingblock
4660 .. container:: content
4665 "name" : "Event0000",
4666 "nameSpace" : "org.onap.policy.apex.sample.events",
4667 "version" : "0.0.1",
4668 "source" : "Outside",
4670 "TestTemperature" : 25,
4671 "TestTimestamp" : 123456789123456789,
4672 "TestMatchCase" : 1,
4673 "TestSlogan" : "Testing the Match Case with Temperature 25"
4676 Application: Convert a Policy Model to CLI Editor Commands
4677 ----------------------------------------------------------
4679 .. container:: paragraph
4681 **Status: Experimental**
4683 .. container:: paragraph
4685 This application takes a policy model (JSON or XML encoded)
4686 and generates commands for the APEX CLI Editor. This
4687 effectively reverses a policy specification realized with
4690 +-------------------------------------------------------------+---------------------------------------------------------------+
4691 | Unix, Cygwin | Windows |
4692 +=============================================================+===============================================================+
4693 | .. container:: | .. container:: |
4695 | .. container:: listingblock | .. container:: listingblock |
4697 | .. container:: content | .. container:: content |
4699 | .. code:: | .. code:: |
4701 | # $APEX_HOME/bin/apexApps.sh model-2-cli [args] | > %APEX_HOME%\bin\apexApps.bat model-2-cli [args] |
4702 +-------------------------------------------------------------+---------------------------------------------------------------+
4704 .. container:: paragraph
4706 The option ``-h`` provides a help screen.
4708 .. container:: listingblock
4710 .. container:: content
4714 usage: gen-model2cli
4715 -h,--help prints this help and usage screen
4716 -m,--model <MODEL-FILE> set the input policy model file
4717 -sv,--skip-validation switch of validation of the input file
4718 -v,--version prints the application version
4720 .. container:: paragraph
4722 For instance, running the tool with the *Sample Domain*
4725 .. container:: listingblock
4727 .. container:: content
4731 apexApps.sh model-2-cli -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json
4733 .. container:: paragraph
4735 will produce the following status messages:
4737 .. container:: listingblock
4739 .. container:: content
4743 gen-model2cli: starting CLI generator
4744 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4746 .. container:: paragraph
4748 and then run the generator application producing all CLI
4749 Editor commands and printing them to standard out.
4751 Application: Websocket Clients (Echo and Console)
4752 -------------------------------------------------
4754 .. container:: paragraph
4756 **Status: Production**
4758 .. container:: paragraph
4760 The application launcher also provides a Websocket echo
4761 client and a Websocket console client. The echo client
4762 connects to APEX and prints all events it receives from
4763 APEX. The console client connects to APEX, reads input from
4764 the command line, and sends this input as events to APEX.
4766 +------------------------------------------------------------+--------------------------------------------------------------+
4767 | Unix, Cygwin | Windows |
4768 +============================================================+==============================================================+
4769 | .. container:: | .. container:: |
4771 | .. container:: listingblock | .. container:: listingblock |
4773 | .. container:: content | .. container:: content |
4775 | .. code:: | .. code:: |
4777 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
4778 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
4779 +------------------------------------------------------------+--------------------------------------------------------------+
4781 .. container:: paragraph
4783 The arguments are the same for both applications:
4785 .. container:: ulist
4787 - ``-p`` defines the Websocket port to connect to (defaults
4790 - ``-s`` defines the host on which a Websocket server is
4791 running (defaults to ``localhost``)
4793 .. container:: paragraph
4795 A discussion on how to use these two applications to build
4796 an APEX system is detailed HowTo-Websockets.
4801 Introduction to APEX Logging
4802 ----------------------------
4804 .. container:: paragraph
4806 All APEX components make extensive use of logging using the
4807 logging façade `SLF4J <https://www.slf4j.org/>`__ with the
4808 backend `Logback <https://logback.qos.ch/>`__. Both are used
4809 off-the-shelve, so the standard documentation and
4810 configuration apply to APEX logging. For details on how to
4811 work with logback please see the `logback
4812 manual <https://logback.qos.ch/manual/index.html>`__.
4814 .. container:: paragraph
4816 The APEX applications is the logback configuration file
4817 ``$APEX_HOME/etc/logback.xml`` (Windows:
4818 ``%APEX_HOME%\etc\logback.xml``). The logging backend is set
4819 to no debug, i.e. logs from the logging framework should be
4822 .. container:: paragraph
4824 The configurable log levels work as expected:
4826 .. container:: ulist
4828 - *error* (or *ERROR*) is used for serious errors in the
4831 - *warn* (or *WARN*) is used for warnings, which in general
4832 can be ignored but might indicate some deeper problems
4834 - *info* (or *INFO*) is used to provide generally
4835 interesting messages for startup and policy execution
4837 - *debug* (or *DEBUG*) provides more details on startup and
4840 - *trace* (or *TRACE*) gives full details on every aspect
4841 of the APEX engine from start to end
4843 .. container:: paragraph
4845 The loggers can also be configured as expected. The standard
4846 configuration (after installing APEX) uses log level *info*
4847 on all APEX classes (components).
4849 .. container:: paragraph
4851 The applications and scripts in ``$APEX_HOME/bin`` (Windows:
4852 ``%APEX_HOME\bin``) are configured to use the logback
4853 configuration ``$APEX_HOME/etc/logback.xml`` (Windows:
4854 ``%APEX_HOME\etc\logback.xml``). There are multiple ways to
4855 use different logback configurations, for instance:
4857 .. container:: ulist
4859 - Maintain multiple configurations in ``etc``, for instance
4860 a ``logback-debug.xml`` for deep debugging and a
4861 ``logback-production.xml`` for APEX in production mode,
4862 then copy the required configuration file to the used
4863 ``logback.xml`` prior starting APEX
4865 - Edit the scripts in ``bin`` to use a different logback
4866 configuration file (only recommended if you are familiar
4867 with editing bash scripts or windows batch files)
4869 Standard Logging Configuration
4870 ------------------------------
4872 .. container:: paragraph
4874 The standard logging configuration defines a context *APEX*,
4875 which is used in the standard output pattern. The location
4876 for log files is defined in the property ``logDir`` and set
4877 to ``/var/log/onap/policy/apex-pdp``. The standard status
4878 listener is set to *NOP* and the overall logback
4879 configuration is set to no debug.
4881 .. container:: listingblock
4883 .. container:: content
4888 <configuration debug="false">
4889 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
4891 <contextName>Apex</contextName>
4892 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
4898 .. container:: paragraph
4900 The first appender defined is called ``STDOUT`` for logs to standard
4903 .. container:: listingblock
4905 .. container:: content
4910 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4912 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
4916 .. container:: paragraph
4918 The root level logger then is set to the level *info* using the
4919 standard out appender.
4921 .. container:: listingblock
4923 .. container:: content
4929 <appender-ref ref="STDOUT" />
4932 .. container:: paragraph
4934 The second appender is called ``FILE``. It writes logs to a file
4937 .. container:: listingblock
4939 .. container:: content
4944 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
4945 <file>${logDir}/apex.log</file>
4947 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4951 .. container:: paragraph
4953 The third appender is called ``CTXT_FILE``. It writes logs to a file
4956 .. container:: listingblock
4958 .. container:: content
4963 <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
4964 <file>${logDir}/apex_ctxt.log</file>
4966 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4970 .. container:: paragraph
4972 The last definitions are for specific loggers. The first logger
4973 captures all standard APEX classes. It is configured for log level
4974 *info* and uses the standard output and file appenders. The second
4975 logger captures APEX context classes responsible for context
4976 monitoring. It is configured for log level *trace* and uses the
4977 context file appender.
4979 .. container:: listingblock
4981 .. container:: content
4987 <logger name="org.onap.policy.apex" level="info" additivity="false">
4988 <appender-ref ref="STDOUT" />
4989 <appender-ref ref="FILE" />
4992 <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
4993 <appender-ref ref="CTXT_FILE" />
4996 Adding Logback Status and Debug
4997 -------------------------------
4999 .. container:: paragraph
5001 To activate logback status messages change the status listener
5002 from 'NOP' to for instance console.
5004 .. container:: listingblock
5006 .. container:: content
5010 <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
5012 .. container:: paragraph
5014 To activate all logback debugging, for instance to debug a new
5015 logback configuration, activate the debug attribute in the
5018 .. container:: listingblock
5020 .. container:: content
5024 <configuration debug="true">
5028 Logging External Components
5029 ---------------------------
5031 .. container:: paragraph
5033 Logback can also be configured to log any other, external
5034 components APEX is using, if they are using the common logging
5037 .. container:: paragraph
5039 For instance, the context component of APEX is using *Infinispan*
5040 and one can add a logger for this external component. The
5041 following example adds a logger for *Infinispan* using the
5042 standard output appender.
5044 .. container:: listingblock
5046 .. container:: content
5050 <logger name="org.infinispan" level="INFO" additivity="false">
5051 <appender-ref ref="STDOUT" />
5054 .. container:: paragraph
5056 Another example is Apache Zookeeper. The following example adds a
5057 logger for Zookeeper using the standard outout appender.
5059 .. container:: listingblock
5061 .. container:: content
5065 <logger name="org.apache.zookeeper.ClientCnxn" level="INFO" additivity="false">
5066 <appender-ref ref="STDOUT" />
5069 Configuring loggers for Policy Logic
5070 ------------------------------------
5072 .. container:: paragraph
5074 The logging for the logic inside a policy (task logic, task
5075 selection logic, state finalizer logic) can be configured separate
5076 from standard logging. The logger for policy logic is
5077 ``org.onap.policy.apex.executionlogging``. The following example
5080 .. container:: ulist
5082 - a new appender for standard out using a very simple pattern
5083 (simply the actual message)
5085 - a logger for policy logic to standard out using the new
5086 appender and the already described file appender.
5088 .. container:: listingblock
5090 .. container:: content
5094 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5096 <pattern>policy: %msg\n</pattern>
5100 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5101 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5102 <appender-ref ref="FILE" />
5105 .. container:: paragraph
5107 It is also possible to use specific logging for parts of policy
5108 logic. The following example defines a logger for task logic.
5110 .. container:: listingblock
5112 .. container:: content
5116 <logger name="org.onap.policy.apex.executionlogging.TaskExecutionLogging" level="TRACE" additivity="false">
5117 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5120 Rolling File Appenders
5121 ----------------------
5123 .. container:: paragraph
5125 Rolling file appenders are a good option for more complex logging
5126 of a production or complex testing APEX installation. The standard
5127 logback configuration can be used for these use cases. This
5128 section gives two examples for the standard logging and for
5131 .. container:: paragraph
5133 First the standard logging. The following example defines a
5134 rolling file appender. The appender rolls over on a daily basis.
5135 It allows for a file size of 100 MB.
5137 .. container:: listingblock
5139 .. container:: content
5143 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
5144 <file>${logDir}/apex.log</file>
5145 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5146 <!-- rollover daily -->
5147 <!-- <fileNamePattern>xstream-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> -->
5148 <fileNamePattern>${logDir}/apex_%d{yyyy-MM-dd}.%i.log.gz
5150 <maxHistory>4</maxHistory>
5151 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5152 <!-- or whenever the file size reaches 100MB -->
5153 <maxFileSize>100MB</maxFileSize>
5154 </timeBasedFileNamingAndTriggeringPolicy>
5158 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5163 .. container:: paragraph
5165 A very similar configuration can be used for a rolling file
5166 appender logging APEX context.
5168 .. container:: listingblock
5170 .. container:: content
5174 <appender name="CTXT-FILE"
5175 class="ch.qos.logback.core.rolling.RollingFileAppender">
5176 <file>${logDir}/apex_ctxt.log</file>
5177 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5178 <fileNamePattern>${logDir}/apex_ctxt_%d{yyyy-MM-dd}.%i.log.gz
5180 <maxHistory>4</maxHistory>
5181 <timeBasedFileNamingAndTriggeringPolicy
5182 class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5183 <maxFileSize>100MB</maxFileSize>
5184 </timeBasedFileNamingAndTriggeringPolicy>
5188 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5193 Example Configuration for Logging Logic
5194 ---------------------------------------
5196 .. container:: paragraph
5198 The following example shows a configuration that logs policy logic
5199 to standard out and a file (*info*). All other APEX components are
5200 logging to a file (*debug*).. This configuration an be used in a
5201 pre-production phase with the APEX engine still running in a
5202 separate terminal to monitor policy execution. This logback
5203 configuration is in the APEX installation as
5204 ``etc/logback-logic.xml``.
5206 .. container:: listingblock
5208 .. container:: content
5212 <configuration debug="false">
5213 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5215 <contextName>Apex</contextName>
5216 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5218 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5220 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
5224 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5225 <file>${logDir}/apex.log</file>
5228 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5233 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5235 <pattern>policy: %msg\n</pattern>
5239 <root level="error">
5240 <appender-ref ref="STDOUT" />
5243 <logger name="org.onap.policy.apex" level="debug" additivity="false">
5244 <appender-ref ref="FILE" />
5247 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5248 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5249 <appender-ref ref="FILE" />
5253 Example Configuration for a Production Server
5254 ---------------------------------------------
5256 .. container:: paragraph
5258 The following example shows a configuration that logs all APEX
5259 components, including policy logic, to a file (*debug*). This
5260 configuration an be used in a production phase with the APEX
5261 engine being executed as a service on a system without console
5262 output. This logback configuration is in the APEX installation as
5263 ``logback-server.xml``
5265 .. container:: listingblock
5267 .. container:: content
5271 <configuration debug="false">
5272 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5274 <contextName>Apex</contextName>
5275 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5277 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5278 <file>${logDir}/apex.log</file>
5281 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5286 <root level="debug">
5287 <appender-ref ref="FILE" />
5290 <logger name="org.onap.policy.apex.executionlogging" level="debug" additivity="false">
5291 <appender-ref ref="FILE" />
5295 Unsupported Features
5296 ^^^^^^^^^^^^^^^^^^^^
5298 .. container:: paragraph
5300 This section documents some legacy and unsupported features
5301 in apex-pdp. The documentation here has not been updated for
5302 recent versions of apex-pdp. For example, the apex-pdp models
5303 specified in this example should now be in TOSCA format.
5305 Building a System with Websocket Backend
5306 ----------------------------------------
5311 .. container:: paragraph
5313 Websocket is a protocol to run sockets of HTTP. Since it in
5314 essence a socket, the connection is realized between a
5315 server (waiting for connections) and a client (connecting to
5316 a server). Server/client separation is only important for
5317 connection establishment, once connected, everyone can
5318 send/receive on the same socket (as any standard socket
5321 .. container:: paragraph
5323 Standard Websocket implementations are simple, no
5324 publish/subscribe and no special event handling. Most
5325 servers simply send all incoming messages to all
5326 connections. There is a PubSub definition on top of
5327 Websocket called `WAMP <http://wamp-proto.org/>`__. APEX
5328 does not support WAMP at the moment.
5333 .. container:: paragraph
5336 356 <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5337 defines the standard Websocket API. This JSR is part of Jave
5338 EE 7 standard. For Java SE, several implementations exist in
5339 open source. Since Websockets are a stable standard and
5340 simple, most implementations are stable and ready to use. A
5341 lot of products support Websockets, like Spring, JBoss,
5342 Netty, … there are also Kafka extensions for Websockets.
5344 Websocket Example Code for Websocket clients (FOSS)
5345 ###################################################
5347 .. container:: paragraph
5349 There are a lot of implementations and examples available on
5350 Github for Websocket clients. If one is using Java EE 7,
5351 then one can also use the native Websocket implementation.
5352 Good examples for clients using simply Java SE are here:
5354 .. container:: ulist
5357 implementation <https://github.com/TooTallNate/Java-WebSocket>`__
5359 - `Websocket sending client example, using
5360 AWT <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ChatClient.java>`__
5362 - `Websocket receiving client example (simple echo
5363 client) <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ExampleClient.java>`__
5365 .. container:: paragraph
5367 For Java EE, the native Websocket API is explained here:
5369 .. container:: ulist
5372 docs <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5375 example <http://www.programmingforliving.com/2013/08/jsr-356-java-api-for-websocket-client-api.html>`__
5377 BCP: Websocket Configuration
5378 ############################
5380 .. container:: paragraph
5382 The probably best is to configure APEX for Websocket servers
5383 for input (ingress, consume) and output (egress, produce)
5384 interfaces. This means that APEX will start Websocket
5385 servers on named ports and wait for clients to connect.
5386 Advantage: once APEX is running all connectivity
5387 infrastructure is running as well. Consequence: if APEX is
5388 not running, everyone else is in the dark, too.
5390 .. container:: paragraph
5392 The best protocol to be used is JSON string. Each event on
5393 any interface is then a string with a JSON encoding. JSON
5394 string is a little bit slower than byte code, but we doubt
5395 that this will be noticeable. A further advantage of JSON
5396 strings over Websockets with APEX starting the servers: it
5397 is very easy to connect web browsers to such a system.
5398 Simple connect the web browser to the APEX sockets and
5399 send/read JSON strings.
5401 .. container:: paragraph
5403 Once APEX is started you simply connect Websocket clients to
5404 it, and send/receive event. When APEX is terminated, the
5405 Websocket servers go down, and the clients will be
5406 disconnected. APEX does not (yet) support auto-client
5407 reconnect nor WAMP, so clients might need to be restarted or
5408 reconnected manually after an APEX boot.
5410 Demo with VPN Policy Model
5411 ##########################
5413 .. container:: paragraph
5415 We assume that you have an APEX installation using the full
5416 package, i.e. APEX with all examples, of version ``0.5.6``
5417 or higher. We will use the VPN policy from the APEX examples
5420 .. container:: paragraph
5422 Now, have the following ready to start the demo:
5424 .. container:: ulist
5426 - 3 terminals on the host where APEX is running (we need 1
5427 for APEX and 1 for each client)
5429 - the events in the file
5430 ``$APEX_HOME/examples/events/VPN/SetupEvents.json`` open
5431 in an editor (we need to send those events to APEX)
5433 - the events in the file
5434 ``$APEX_HOME/examples/events/VPN/Link09Events.json`` open
5435 in an editor (we need to send those events to APEX)
5437 A Websocket Configuration for the VPN Domain
5438 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5440 .. container:: paragraph
5442 Create a new APEX configuration using the VPN policy
5443 model and configuring APEX as discussed above for
5444 Websockets. Copy the following configuration into
5445 ``$APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json``
5447 ``%APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json``):
5449 .. container:: listingblock
5451 .. container:: content
5457 "engineServiceParameters" : {
5458 "name" : "VPNApexEngine",
5459 "version" : "0.0.1",
5461 "instanceCount" : 1,
5462 "deploymentPort" : 12345,
5463 "policyModelFileName" : "examples/models/VPN/VPNPolicyModelAvro.json",
5464 "engineParameters" : {
5465 "executorParameters" : {
5467 "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
5470 "contextParameters" : {
5471 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
5472 "schemaParameters":{
5474 "parameterClassName" : "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
5480 "producerCarrierTechnologyParameters" : {
5481 "carrierTechnology" : "WEBSOCKET",
5482 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5488 "producerEventProtocolParameters" : {
5489 "eventProtocol" : "JSON"
5491 "consumerCarrierTechnologyParameters" : {
5492 "carrierTechnology" : "WEBSOCKET",
5493 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5499 "consumerEventProtocolParameters" : {
5500 "eventProtocol" : "JSON"
5507 .. container:: paragraph
5509 In a new terminal, start APEX with the new configuration for
5510 Websocket-Server ingress/egress:
5512 .. container:: listingblock
5514 .. container:: content
5519 #: $APEX_HOME/bin/apexApps.sh engine -c $APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json
5521 .. container:: listingblock
5523 .. container:: content
5528 #: %APEX_HOME%\bin\apexApps.bat engine -c %APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json
5530 .. container:: paragraph
5532 Wait for APEX to start, it takes a while to create all Websocket
5533 servers (about 8 seconds on a standard laptop without cached
5534 binaries). depending on your log messages, you will see no (some, a
5535 lot) log messages. If APEX starts correctly, the last few messages
5538 .. container:: listingblock
5540 .. container:: content
5545 2017-07-28 13:17:20,834 Apex [main] INFO c.e.a.s.engine.runtime.EngineService - engine model VPNPolicyModelAvro:0.0.1 added to the engine-AxArtifactKey:(name=VPNApexEngine-0,version=0.0.1)
5546 2017-07-28 13:17:21,057 Apex [Apex-apex-engine-service-0:0] INFO c.e.a.s.engine.runtime.EngineService - Engine AxArtifactKey:(name=VPNApexEngine-0,version=0.0.1) processing ...
5547 2017-07-28 13:17:21,296 Apex [main] INFO c.e.a.s.e.r.impl.EngineServiceImpl - Added the action listener to the engine
5548 Started Apex service
5550 .. container:: paragraph
5552 APEX is running in the new terminal and will produce output when the
5553 policy is triggered/executed.
5555 Run the Websocket Echo Client
5556 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5558 .. container:: paragraph
5560 The echo client is included in an APEX full installation. To run
5561 the client, open a new shell (Unix, Cygwin) or command prompt
5562 (``cmd`` on Windows). Then use the APEX application launcher to
5566 APEX engine needs to run first
5567 The example assumes that an APEX engine configured for *produce* carrier technology Websocket and *JSON* event protocol is executed first.
5569 +---------------------------------------------------------+-----------------------------------------------------------+
5570 | Unix, Cygwin | Windows |
5571 +=========================================================+===========================================================+
5572 | .. container:: | .. container:: |
5574 | .. container:: listingblock | .. container:: listingblock |
5576 | .. container:: content | .. container:: content |
5578 | .. code:: | .. code:: |
5580 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
5581 +---------------------------------------------------------+-----------------------------------------------------------+
5583 .. container:: paragraph
5585 Use the following command line arguments for server and port of
5586 the Websocket server. The port should be the same as configured in
5587 the APEX engine. The server host should be the host on which the
5588 APEX engine is running
5590 .. container:: ulist
5592 - ``-p`` defines the Websocket port to connect to (defaults to
5595 - ``-s`` defines the host on which a Websocket server is running
5596 (defaults to ``localhost``)
5598 .. container:: paragraph
5600 Let’s assume that there is an APEX engine running, configured for
5601 produce Websocket carrier technology, as server, for port 42452,
5602 with produce event protocol JSON,. If we start the console client
5603 on the same host, we can omit the ``-s`` options. We start the
5606 .. container:: listingblock
5608 .. container:: content
5612 # $APEX_HOME/bin/apexApps.sh ws-echo -p 42452 (1)
5613 > %APEX_HOME%\bin\apexApps.bat ws-echo -p 42452 (2)
5615 .. container:: colist arabic
5617 +-------+--------------------------------+
5618 | **1** | Start client on Unix or Cygwin |
5619 +-------+--------------------------------+
5620 | **2** | Start client on Windows |
5621 +-------+--------------------------------+
5623 .. container:: paragraph
5625 Once started successfully, the client will produce the following
5626 messages (assuming we used ``-p 42452`` and an APEX engine is
5627 running on ``localhost`` with the same port:
5629 .. container:: listingblock
5631 .. container:: content
5635 ws-simple-echo: starting simple event echo
5636 --> server: localhost
5639 Once started, the application will simply print out all received events to standard out.
5640 Each received event will be prefixed by '---' and suffixed by '===='
5643 ws-simple-echo: opened connection to APEX (Web Socket Protocol Handshake)
5645 Run the Websocket Console Client
5646 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5648 .. container:: paragraph
5650 The console client is included in an APEX full installation. To
5651 run the client, open a new shell (Unix, Cygwin) or command prompt
5652 (``cmd`` on Windows). Then use the APEX application launcher to
5656 APEX engine needs to run first
5657 The example assumes that an APEX engine configured for *consume* carrier technology Websocket and *JSON* event
5658 protocol is executed first.
5660 +------------------------------------------------------------+--------------------------------------------------------------+
5661 | Unix, Cygwin | Windows |
5662 +============================================================+==============================================================+
5663 | .. container:: | .. container:: |
5665 | .. container:: listingblock | .. container:: listingblock |
5667 | .. container:: content | .. container:: content |
5669 | .. code:: | .. code:: |
5671 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
5672 +------------------------------------------------------------+--------------------------------------------------------------+
5674 .. container:: paragraph
5676 Use the following command line arguments for server and port of
5677 the Websocket server. The port should be the same as configured in
5678 the APEX engine. The server host should be the host on which the
5679 APEX engine is running
5681 .. container:: ulist
5683 - ``-p`` defines the Websocket port to connect to (defaults to
5686 - ``-s`` defines the host on which a Websocket server is running
5687 (defaults to ``localhost``)
5689 .. container:: paragraph
5691 Let’s assume that there is an APEX engine running, configured for
5692 consume Websocket carrier technology, as server, for port 42450,
5693 with consume event protocol JSON,. If we start the console client
5694 on the same host, we can omit the ``-s`` options. We start the
5697 .. container:: listingblock
5699 .. container:: content
5703 # $APEX_HOME/bin/apexApps.sh ws-console -p 42450 (1)
5704 > %APEX_HOME%\bin\apexApps.sh ws-console -p 42450 (2)
5706 .. container:: colist arabic
5708 +-------+--------------------------------+
5709 | **1** | Start client on Unix or Cygwin |
5710 +-------+--------------------------------+
5711 | **2** | Start client on Windows |
5712 +-------+--------------------------------+
5714 .. container:: paragraph
5716 Once started successfully, the client will produce the following
5717 messages (assuming we used ``-p 42450`` and an APEX engine is
5718 running on ``localhost`` with the same port:
5720 .. container:: listingblock
5722 .. container:: content
5726 ws-simple-console: starting simple event console
5727 --> server: localhost
5730 - terminate the application typing 'exit<enter>' or using 'CTRL+C'
5731 - events are created by a non-blank starting line and terminated by a blank line
5734 ws-simple-console: opened connection to APEX (Web Socket Protocol Handshake)
5739 .. container:: paragraph
5741 Now you have the full system up and running:
5743 .. container:: ulist
5745 - Terminal 1: APEX ready and loaded
5747 - Terminal 2: an echo client, printing received messages produced
5750 - Terminal 2: a console client, waiting for input on the console
5751 (standard in) and sending text to APEX
5753 .. container:: paragraph
5755 We started the engine with the VPN policy example. So all the
5756 events we are using now are located in files in the following
5759 .. container:: listingblock
5761 .. container:: content
5766 #: $APEX_HOME/examples/events/VPN
5767 > %APEX_HOME%\examples\events\VPN
5769 .. container:: paragraph
5771 To sends events, simply copy the content of the event files into
5772 Terminal 3 (the console client). It will read multi-line JSON text
5773 and send the events. So copy the content of ``SetupEvents.json`` into
5774 the client. APEX will trigger a policy and produce some output, the
5775 echo client will also print some events created in the policy. In
5776 Terminal 1 (APEX) you’ll see some status messages from the policy as:
5778 .. container:: listingblock
5780 .. container:: content
5785 {Link=L09, LinkUp=true}
5787 outFields: {Link=L09, LinkUp=true}
5788 {Link=L10, LinkUp=true}
5791 outFields: {Link=L10, LinkUp=true}
5792 {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5794 C 300 300 [L09, L10]
5795 outFields: {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5796 {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5799 C 300 300 [L09, L10]
5800 outFields: {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5801 {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5804 C 300 300 [L09, L10]
5805 D 300 400 [L09, L10]
5806 outFields: {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5807 {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5810 B 300 299 [L09, L10]
5811 C 300 300 [L09, L10]
5812 D 300 400 [L09, L10]
5813 outFields: {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5815 .. container:: paragraph
5817 In Terminal 2 (echo-client) you see the received events, the last two
5820 .. container:: listingblock
5822 .. container:: content
5827 ws-simple-echo: received
5828 ---------------------------------
5830 "name": "VPNCustomerCtxtActEvent",
5832 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5835 "CustomerName": "C",
5836 "LinkList": "L09 L10",
5840 =================================
5842 ws-simple-echo: received
5843 ---------------------------------
5845 "name": "VPNCustomerCtxtActEvent",
5847 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5850 "CustomerName": "D",
5851 "LinkList": "L09 L10",
5855 =================================
5857 .. container:: paragraph
5859 Congratulations, you have triggered a policy in APEX using
5860 Websockets, the policy did run through, created events, picked up by
5863 .. container:: paragraph
5865 Now you can send the Link 09 and Link 10 events, they will trigger
5866 the actual VPN policy and some calculations are made. Let’s take the
5867 Link 09 events from ``Link09Events.json``, copy them all into
5868 Terminal 3 (the console). APEX will run the policy (with some status
5869 output), and the echo client will receive and print events.
5871 .. container:: paragraph
5873 To terminate the applications, simply press ``CTRL+C`` in Terminal 1
5874 (APEX). This will also terminate the echo-client in Terminal 2. Then
5875 type ``exit<enter>`` in Terminal 3 (or ``CTRL+C``) to terminate the