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.
2629 In cases where the message produced in Kafka topic has been serialized using KafkaAvroSerializer,
2630 then the following parameters needs to be additionally added to `KafkaProperties` for the consumer
2631 to have the capability of deserializing the message properly while consuming.
2633 .. container:: listingblock
2635 .. container:: content
2640 "value.deserializer",
2641 "io.confluent.kafka.serializers.KafkaAvroDeserializer"
2644 "schema.registry.url",
2645 "<url of the schema registry configured in Kafka cluster for registering Avro schemas>"
2648 .. container:: paragraph
2650 For more details on how to setup schema registry for Kafka cluster,
2651 kindly take a look `here <https://github.com/confluentinc/schema-registry/blob/master/README.md>`__.
2656 .. container:: paragraph
2658 APEX will send events to the Apache Kafka messaging
2659 system. The output is uni-directional, an engine will
2660 send events to the output but not receive any event
2663 .. container:: listingblock
2665 .. container:: content
2669 "carrierTechnologyParameters" : {
2670 "carrierTechnology" : "KAFKA", (1)
2671 "parameterClassName" :
2672 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2674 "bootstrapServers" : "localhost:49092", (2)
2677 "batchSize" : 16384, (5)
2678 "lingerTime" : 1, (6)
2679 "bufferMemory" : 33554432, (7)
2680 "producerTopic" : "apex-out", (8)
2682 "org.apache.kafka.common.serialization.StringSerializer", (9)
2684 "org.apache.kafka.common.serialization.StringSerializer" (10)
2685 "kafkaProperties": [ (11)
2687 "security.protocol",
2691 "ssl.truststore.type",
2695 "ssl.truststore.location",
2696 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2699 "ssl.truststore.password",
2708 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2711 "ssl.endpoint.identification.algorithm",
2718 .. container:: colist arabic
2720 +--------+-----------------------------------+
2721 | **1** | set Kafka as carrier technology |
2722 +--------+-----------------------------------+
2723 | **2** | bootstrap server and port |
2724 +--------+-----------------------------------+
2725 | **3** | acknowledgement strategy |
2726 +--------+-----------------------------------+
2727 | **4** | number of retries |
2728 +--------+-----------------------------------+
2729 | **5** | batch size |
2730 +--------+-----------------------------------+
2731 | **6** | time to linger in milliseconds |
2732 +--------+-----------------------------------+
2733 | **7** | buffer memory in byte |
2734 +--------+-----------------------------------+
2735 | **8** | producer topic |
2736 +--------+-----------------------------------+
2737 | **9** | key for the Kafka serializer |
2738 +--------+-----------------------------------+
2739 | **10** | value for the Kafka serializer |
2740 +--------+-----------------------------------+
2741 | **11** | properties for Kafka connectivity |
2742 +--------+-----------------------------------+
2744 .. container:: paragraph
2746 Kindly note that the above Kafka properties is just a reference,
2747 and the actual properties required depends on the Kafka server installation.
2752 .. container:: paragraph
2754 APEX supports the Java Messaging Service (JMS) as input
2755 as well as output. JMS IO is supported by the APEX JMS
2756 plugin. Input and output support an event encoding as
2757 text (JSON string) or object (serialized object). The
2758 input configuration is the same for both encodings, the
2759 output configuration differs.
2763 .. container:: paragraph
2765 APEX will receive events from a JMS messaging system.
2766 The input is uni-directional, an engine will only
2767 receive events from the input but not send any event
2770 .. container:: listingblock
2772 .. container:: content
2776 "carrierTechnologyParameters" : {
2777 "carrierTechnology" : "JMS", (1)
2778 "parameterClassName" :
2779 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2780 "parameters" : { (2)
2781 "initialContextFactory" :
2782 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2783 "connectionFactory" : "ConnectionFactory", (4)
2784 "providerURL" : "remote://localhost:5445", (5)
2785 "securityPrincipal" : "guest", (6)
2786 "securityCredentials" : "IAmAGuest", (7)
2787 "consumerTopic" : "jms/topic/apexIn" (8)
2791 .. container:: colist arabic
2793 +-----------------------------------+-----------------------------------+
2794 | **1** | set JMS as carrier technology |
2795 +-----------------------------------+-----------------------------------+
2796 | **2** | set all JMS specific parameters |
2797 +-----------------------------------+-----------------------------------+
2798 | **3** | the context factory, in this case |
2799 | | from JBOSS (it requires the |
2801 | | org.jboss:jboss-remote-naming:2.0 |
2803 | | or a different version to be in |
2804 | | the directory ``$APEX_HOME/lib`` |
2805 | | or ``%APEX_HOME%\lib`` |
2806 +-----------------------------------+-----------------------------------+
2807 | **4** | a connection factory for the JMS |
2809 +-----------------------------------+-----------------------------------+
2810 | **5** | URL with host and port of the JMS |
2812 +-----------------------------------+-----------------------------------+
2813 | **6** | access credentials, user name |
2814 +-----------------------------------+-----------------------------------+
2815 | **7** | access credentials, user password |
2816 +-----------------------------------+-----------------------------------+
2817 | **8** | the JMS topic to listen to |
2818 +-----------------------------------+-----------------------------------+
2820 JMS Output with Text
2821 ====================
2823 .. container:: paragraph
2825 APEX engine send events to a JMS messaging system. The
2826 output is uni-directional, an engine will send events
2827 to the output but not receive any event from output.
2829 .. container:: listingblock
2831 .. container:: content
2835 "carrierTechnologyParameters" : {
2836 "carrierTechnology" : "JMS", (1)
2837 "parameterClassName" :
2838 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2839 "parameters" : { (2)
2840 "initialContextFactory" :
2841 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2842 "connectionFactory" : "ConnectionFactory", (4)
2843 "providerURL" : "remote://localhost:5445", (5)
2844 "securityPrincipal" : "guest", (6)
2845 "securityCredentials" : "IAmAGuest", (7)
2846 "producerTopic" : "jms/topic/apexOut", (8)
2847 "objectMessageSending": "false" (9)
2851 .. container:: colist arabic
2853 +-----------------------------------+-----------------------------------+
2854 | **1** | set JMS as carrier technology |
2855 +-----------------------------------+-----------------------------------+
2856 | **2** | set all JMS specific parameters |
2857 +-----------------------------------+-----------------------------------+
2858 | **3** | the context factory, in this case |
2859 | | from JBOSS (it requires the |
2861 | | org.jboss:jboss-remote-naming:2.0 |
2863 | | or a different version to be in |
2864 | | the directory ``$APEX_HOME/lib`` |
2865 | | or ``%APEX_HOME%\lib`` |
2866 +-----------------------------------+-----------------------------------+
2867 | **4** | a connection factory for the JMS |
2869 +-----------------------------------+-----------------------------------+
2870 | **5** | URL with host and port of the JMS |
2872 +-----------------------------------+-----------------------------------+
2873 | **6** | access credentials, user name |
2874 +-----------------------------------+-----------------------------------+
2875 | **7** | access credentials, user password |
2876 +-----------------------------------+-----------------------------------+
2877 | **8** | the JMS topic to write to |
2878 +-----------------------------------+-----------------------------------+
2879 | **9** | set object messaging to ``false`` |
2880 | | means it sends JSON text |
2881 +-----------------------------------+-----------------------------------+
2883 JMS Output with Object
2884 ======================
2886 .. container:: paragraph
2888 To configure APEX for JMS objects on the output
2889 interface use the same configuration as above (for
2890 output). Simply change the ``objectMessageSending``
2891 parameter to ``true``.
2896 .. container:: paragraph
2898 APEX supports the Websockets as input as well as output.
2899 WS IO is supported by the APEX Websocket plugin. This
2900 carrier technology does only support uni-directional
2901 communication. APEX will not send events to a Websocket
2902 input and any event sent to a Websocket output will
2903 result in an error log.
2905 .. container:: paragraph
2907 The input can be configured as client (APEX connects to
2908 an existing Websocket server) or server (APEX starts a
2909 Websocket server). The same applies to the output. Input
2910 and output can both use a client or a server
2911 configuration, or separate configurations (input as
2912 client and output as server, input as server and output
2913 as client). Each configuration should use its own
2914 dedicated port to avoid any communication loops. The
2915 configuration of a Websocket client is the same for input
2916 and output. The configuration of a Websocket server is
2917 the same for input and output.
2922 .. container:: paragraph
2924 APEX will connect to a given Websocket server. As
2925 input, it will receive events from the server but not
2926 send any events. As output, it will send events to the
2927 server and any event received from the server will
2928 result in an error log.
2930 .. container:: listingblock
2932 .. container:: content
2936 "carrierTechnologyParameters" : {
2937 "carrierTechnology" : "WEBSOCKET", (1)
2938 "parameterClassName" :
2939 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2941 "host" : "localhost", (2)
2946 .. container:: colist arabic
2948 +-------+------------------------------------------------------+
2949 | **1** | set Websocket as carrier technology |
2950 +-------+------------------------------------------------------+
2951 | **2** | the host name on which a Websocket server is running |
2952 +-------+------------------------------------------------------+
2953 | **3** | the port of that Websocket server |
2954 +-------+------------------------------------------------------+
2959 .. container:: paragraph
2961 APEX will start a Websocket server, which will accept
2962 any Websocket clients to connect. As input, it will
2963 receive events from the server but not send any
2964 events. As output, it will send events to the server
2965 and any event received from the server will result in
2968 .. container:: listingblock
2970 .. container:: content
2974 "carrierTechnologyParameters" : {
2975 "carrierTechnology" : "WEBSOCKET", (1)
2976 "parameterClassName" :
2977 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2979 "wsClient" : false, (2)
2984 .. container:: colist arabic
2986 +-------+------------------------------------------------------------+
2987 | **1** | set Websocket as carrier technology |
2988 +-------+------------------------------------------------------------+
2989 | **2** | disable client, so that APEX will start a Websocket server |
2990 +-------+------------------------------------------------------------+
2991 | **3** | the port for the Websocket server APEX will start |
2992 +-------+------------------------------------------------------------+
2997 .. container:: paragraph
2999 APEX can act as REST client on the input as well as on
3000 the output interface. The media type is
3001 ``application/json``, so this plugin only works with
3002 the JSON Event protocol.
3007 .. container:: paragraph
3009 APEX will connect to a given URL to receive events,
3010 but not send any events. The server is polled, i.e.
3011 APEX will do an HTTP GET, take the result, and then do
3012 the next GET. Any required timing needs to be handled
3013 by the server configured via the URL. For instance,
3014 the server could support a wait timeout via the URL as
3016 The httpCodeFilter is used for filtering the status
3017 code, and it can be configured as a regular expression
3018 string. The default httpCodeFilter is "[2][0-9][0-9]"
3019 - for successful response codes.
3020 The response with HTTP status code that matches the
3021 given regular expression is forwarded to the task,
3022 otherwise it is logged as a failure.
3024 .. container:: listingblock
3026 .. container:: content
3030 "carrierTechnologyParameters" : {
3031 "carrierTechnology" : "RESTCLIENT", (1)
3032 "parameterClassName" :
3033 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3035 "url" : "http://example.org:8080/triggers/events", (2)
3036 "httpMethod": "GET", (3)
3037 "httpCodeFilter" : "[2][0-9][0-9]", (4)
3038 "httpHeaders" : [ (5)
3039 ["Keep-Alive", "300"],
3040 ["Cache-Control", "no-cache"]
3045 .. container:: colist arabic
3047 +-------+--------------------------------------------------+
3048 | **1** | set REST client as carrier technology |
3049 +-------+--------------------------------------------------+
3050 | **2** | the URL of the HTTP server for events |
3051 +-------+--------------------------------------------------+
3052 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3053 | | optional, defaults to GET |
3054 +-------+--------------------------------------------------+
3055 | **4** | use HTTP CODE FILTER for filtering status code, |
3056 | | optional, defaults to [2][0-9][0-9] |
3057 +-------+--------------------------------------------------+
3058 | **5** | HTTP headers to use on the REST request, |
3060 +-------+--------------------------------------------------+
3065 .. container:: paragraph
3067 APEX will connect to a given URL to send events, but
3068 not receive any events. The default HTTP operation is
3069 POST (no configuration required). To change it to PUT
3070 simply add the configuration parameter (as shown in
3072 The URL can be configured statically or tagged
3073 as ``?example.{site}.org:8080/{trig}/events``,
3074 all tags such as ``site`` and ``trig`` in the URL
3075 need to be set in the properties object available to
3076 the tasks. In addition, the keys should exactly match
3077 with the tags defined in url. The scope of the properties
3078 object is per HTTP call. Hence, key/value pairs set
3079 in the properties object by task are only available
3080 for that specific HTTP call.
3082 .. container:: listingblock
3084 .. container:: content
3088 "carrierTechnologyParameters" : {
3089 "carrierTechnology" : "RESTCLIENT", (1)
3090 "parameterClassName" :
3091 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3093 "url" : "http://example.com:8888/actions/events", (2)
3094 "url" : "http://example.{site}.com:8888/{trig}/events", (2')
3095 "httpMethod" : "PUT". (3)
3096 "httpHeaders" : [ (4)
3097 ["Keep-Alive", "300"],
3098 ["Cache-Control", "no-cache"]
3102 .. container:: colist arabic
3104 +-------+--------------------------------------------------+
3105 | **1** | set REST client as carrier technology |
3106 +-------+--------------------------------------------------+
3107 | **2** | the static URL of the HTTP server for events |
3108 +-------+--------------------------------------------------+
3109 | **2'**| the tagged URL of the HTTP server for events |
3110 +-------+--------------------------------------------------+
3111 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3112 | | optional, defaults to POST |
3113 +-------+--------------------------------------------------+
3114 | **4** | HTTP headers to use on the REST request, |
3116 +-------+--------------------------------------------------+
3121 .. container:: paragraph
3123 APEX supports a REST server for input and output.
3125 .. container:: paragraph
3127 The REST server plugin always uses a synchronous mode. A
3128 client does a HTTP GET on the APEX REST server with the
3129 input event and receives the generated output event in
3130 the server reply. This means that for the REST server
3131 there has to always to be an input with an associated
3132 output. Input or output only are not permitted.
3134 .. container:: paragraph
3136 The plugin will start a Grizzly server as REST server for
3137 a normal APEX engine. If the APEX engine is executed as a
3138 servlet, for instance inside Tomcat, then Tomcat will be
3139 used as REST server (this case requires configuration on
3142 .. container:: paragraph
3144 Some configuration restrictions apply for all scenarios:
3146 .. container:: ulist
3148 - Minimum port: 1024
3150 - Maximum port: 65535
3152 - The media type is ``application/json``, so this plugin
3153 only works with the JSON Event protocol.
3155 .. container:: paragraph
3157 The URL the client calls is created using
3159 .. container:: ulist
3161 - the configured host and port, e.g.
3162 ``http://localhost:12345``
3164 - the standard path, e.g. ``/apex/``
3166 - the name of the input/output, e.g. ``FirstConsumer/``
3168 - the input or output name, e.g. ``EventIn``.
3170 .. container:: paragraph
3172 The examples above lead to the URL
3173 ``http://localhost:12345/apex/FirstConsumer/EventIn``.
3175 .. container:: paragraph
3177 A client can also get status information of the REST
3178 server using ``/Status``, e.g.
3179 ``http://localhost:12345/apex/FirstConsumer/Status``.
3181 REST Server Stand-alone
3182 =======================
3184 .. container:: paragraph
3186 We need to configure a REST server input and a REST
3187 server output. Input and output are associated with
3188 each other via there name.
3190 .. container:: paragraph
3192 Timeouts for REST calls need to be set carefully. If
3193 they are too short, the call might timeout before a
3194 policy finished creating an event.
3196 .. container:: paragraph
3198 The following example configures the input named as
3199 ``MyConsumer`` and associates an output named
3200 ``MyProducer`` with it.
3202 .. container:: listingblock
3204 .. container:: content
3208 "eventInputParameters": {
3210 "carrierTechnologyParameters" : {
3211 "carrierTechnology" : "RESTSERVER", (1)
3212 "parameterClassName" :
3213 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters",
3215 "standalone" : true, (2)
3216 "host" : "localhost", (3)
3220 "eventProtocolParameters":{
3221 "eventProtocol" : "JSON" (5)
3223 "synchronousMode" : true, (6)
3224 "synchronousPeer" : "MyProducer", (7)
3225 "synchronousTimeout" : 500 (8)
3229 .. container:: colist arabic
3231 +-------+---------------------------------------+
3232 | **1** | set REST server as carrier technology |
3233 +-------+---------------------------------------+
3234 | **2** | set the server as stand-alone |
3235 +-------+---------------------------------------+
3236 | **3** | set the server host |
3237 +-------+---------------------------------------+
3238 | **4** | set the server listen port |
3239 +-------+---------------------------------------+
3240 | **5** | use JSON event protocol |
3241 +-------+---------------------------------------+
3242 | **6** | activate synchronous mode |
3243 +-------+---------------------------------------+
3244 | **7** | associate an output ``MyProducer`` |
3245 +-------+---------------------------------------+
3246 | **8** | set a timeout of 500 milliseconds |
3247 +-------+---------------------------------------+
3249 .. container:: paragraph
3251 The following example configures the output named as
3252 ``MyProducer`` and associates the input ``MyConsumer``
3253 with it. Note that for the output there are no more
3254 paramters (such as host or port), since they are
3255 already configured in the associated input
3257 .. container:: listingblock
3259 .. container:: content
3263 "eventOutputParameters": {
3265 "carrierTechnologyParameters":{
3266 "carrierTechnology" : "RESTSERVER",
3267 "parameterClassName" :
3268 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters"
3270 "eventProtocolParameters":{
3271 "eventProtocol" : "JSON"
3273 "synchronousMode" : true,
3274 "synchronousPeer" : "MyConsumer",
3275 "synchronousTimeout" : 500
3279 REST Server Stand-alone, multi input
3280 ====================================
3282 .. container:: paragraph
3284 Any number of input/output pairs for REST servers can
3285 be configured. For instance, we can configure an input
3286 ``FirstConsumer`` with output ``FirstProducer`` and an
3287 input ``SecondConsumer`` with output
3288 ``SecondProducer``. Important is that there is always
3289 one pair of input/output.
3291 REST Server Stand-alone in Servlet
3292 ==================================
3294 .. container:: paragraph
3296 If APEX is executed as a servlet, e.g. inside Tomcat,
3297 the configuration becomes easier since the plugin can
3298 now use Tomcat as the REST server. In this scenario,
3299 there are not parameters (port, host, etc.) and the
3300 key ``standalone`` must not be used (or set to false).
3302 .. container:: paragraph
3304 For the Tomcat configuration, we need to add the REST
3307 .. container:: listingblock
3309 .. container:: content
3317 <param-value>org.onap.policy.apex.plugins.event.carrier.restserver</param-value>
3325 .. container:: paragraph
3327 APEX can act as REST requestor on the input as well as on
3328 the output interface. The media type is
3329 ``application/json``, so this plugin only works with
3330 the JSON Event protocol. This plugin allows APEX to send REST requests
3331 and to receive the reply of that request without tying up APEX resources
3332 while the request is being processed. The REST Requestor pairs a REST
3333 requestor producer and consumer together to handle the REST request
3334 and response. The REST request is created from an APEX output event
3335 and the REST response is input into APEX as a new input event.
3337 REST Requestor Output (REST Request Producer)
3338 =============================================
3340 .. container:: paragraph
3342 APEX sends a REST request when events are output by APEX, the REST
3343 request configuration is specified on the REST Request Consumer (see
3346 .. container:: listingblock
3348 .. container:: content
3352 "carrierTechnologyParameters": {
3353 "carrierTechnology": "RESTREQUESTOR", (1)
3354 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
3357 .. container:: colist arabic
3359 +-------+------------------------------------------+
3360 | **1** | set REST requestor as carrier technology |
3361 +-------+------------------------------------------+
3363 .. container:: paragraph
3365 The settings below are required on the producer to
3366 define the event that triggers the REST request and
3367 to specify the peered consumer configuration for the
3368 REST request, for example:
3370 .. container:: listingblock
3372 .. container:: content
3376 "eventNameFilter": "GuardRequestEvent", (1)
3377 "requestorMode": true, (2)
3378 "requestorPeer": "GuardRequestorConsumer", (3)
3379 "requestorTimeout": 500 (4)
3381 .. container:: colist arabic
3383 +-------+-------------------------------------------+
3384 | **1** | a filter on the event |
3385 +-------+-------------------------------------------+
3386 | **2** | requestor mode must be set to *true* |
3387 +-------+-------------------------------------------+
3388 | **3** | the peered consumer for REST requests, |
3389 | | that consumer specifies the full |
3390 | | configuration for REST requests |
3391 +-------+-------------------------------------------+
3392 | **4** | the request timeout in milliseconds, |
3393 | | overridden by timeout on consumer if that |
3394 | | is set, optional defaults to 500 |
3396 +-------+-------------------------------------------+
3398 REST Requestor Input (REST Request Consumer)
3399 ============================================
3401 .. container:: paragraph
3403 APEX will connect to a given URL to issue a REST request and
3404 wait for a REST response.
3405 The URL can be configured statically or tagged
3406 as ``?example.{site}.org:8080/{trig}/events``,
3407 all tags such as ``site`` and ``trig`` in the URL
3408 need to be set in the properties object available to
3409 the tasks. In addition, the keys should exactly match
3410 with the tags defined in url. The scope of the properties
3411 object is per HTTP call. Hence, key/value pairs set
3412 in the properties object by task are only available
3413 for that specific HTTP call.
3414 The httpCodeFilter is used for filtering the status
3415 code, and it can be configured as a regular expression
3416 string. The default httpCodeFilter is "[2][0-9][0-9]"
3417 - for successful response codes.
3418 The response with HTTP status code that matches the
3419 given regular expression is forwarded to the task,
3420 otherwise it is logged as a failure.
3422 .. container:: listingblock
3424 .. container:: content
3428 "carrierTechnologyParameters": {
3429 "carrierTechnology": "RESTREQUESTOR", (1)
3430 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
3432 "url": "http://localhost:54321/some/path/to/rest/resource", (2)
3433 "url": "http://localhost:54321/{site}/path/to/rest/{resValue}", (2')
3434 "httpMethod": "POST", (3)
3435 "requestorMode": true, (4)
3436 "requestorPeer": "GuardRequestorProducer", (5)
3437 "restRequestTimeout": 2000, (6)
3438 "httpCodeFilter" : "[2][0-9][0-9]" (7)
3439 "httpHeaders" : [ (8)
3440 ["Keep-Alive", "300"],
3441 ["Cache-Control", "no-cache"]
3445 .. container:: colist arabic
3447 +-------+--------------------------------------------------+
3448 | **1** | set REST requestor as carrier technology |
3449 +-------+--------------------------------------------------+
3450 | **2** | the static URL of the HTTP server for events |
3451 +-------+--------------------------------------------------+
3452 | **2'**| the tagged URL of the HTTP server for events |
3453 +-------+--------------------------------------------------+
3454 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3455 | | optional, defaults to GET |
3456 +-------+--------------------------------------------------+
3457 | **4** | requestor mode must be set to *true* |
3458 +-------+--------------------------------------------------+
3459 | **5** | the peered producer for REST requests, that |
3460 | | producer specifies the APEX output event that |
3461 | | triggers the REST request |
3462 +-------+--------------------------------------------------+
3463 | **6** | request timeout in milliseconds, overrides any |
3464 | | value set in the REST Requestor Producer, |
3465 | | optional, defaults to 500 millisconds |
3466 +-------+--------------------------------------------------+
3467 | **7** | use HTTP CODE FILTER for filtering status code |
3468 | | optional, defaults to [2][0-9][0-9] |
3469 +-------+--------------------------------------------------+
3470 | **8** | HTTP headers to use on the REST request, |
3472 +-------+--------------------------------------------------+
3474 .. container:: paragraph
3476 Further settings may be required on the consumer to
3477 define the input event that is produced and forwarded into
3480 .. container:: listingblock
3482 .. container:: content
3486 "eventName": "GuardResponseEvent", (1)
3487 "eventNameFilter": "GuardResponseEvent" (2)
3489 .. container:: colist arabic
3491 +-------+---------------------------+
3492 | **1** | the event name |
3493 +-------+---------------------------+
3494 | **2** | a filter on the event |
3495 +-------+---------------------------+
3500 .. container:: paragraph
3502 APEX can send requests over gRPC at the output side, and get back
3503 response at the input side. This can be used to send requests to CDS
3504 over gRPC. The media type is ``application/json``, so this plugin
3505 only works with the JSON Event protocol.
3510 .. container:: paragraph
3512 APEX will connect to a given host to send a request over
3515 .. container:: listingblock
3517 .. container:: content
3521 "carrierTechnologyParameters": {
3522 "carrierTechnology": "GRPC", (1)
3523 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
3525 "host": "cds-blueprints-processor-grpc", (2)
3527 "username": "ccsdkapps", (3)
3528 "password": ccsdkapps, (4)
3533 .. container:: colist arabic
3535 +-------+--------------------------------------------------+
3536 | **1** | set GRPC as carrier technology |
3537 +-------+--------------------------------------------------+
3538 | **2** | the host to which request is sent |
3539 +-------+--------------------------------------------------+
3540 | **2'**| the value for port |
3541 +-------+--------------------------------------------------+
3542 | **3** | username required to initiate connection |
3543 +-------+--------------------------------------------------+
3544 | **4** | password required to initiate connection |
3545 +-------+--------------------------------------------------+
3546 | **5** | the timeout value for completing the request |
3547 +-------+--------------------------------------------------+
3549 .. container:: paragraph
3551 Further settings are required on the producer to
3552 define the event that is requested, for example:
3554 .. container:: listingblock
3556 .. container:: content
3560 "eventName": "GRPCRequestEvent", (1)
3561 "eventNameFilter": "GRPCRequestEvent", (2)
3562 "requestorMode": true, (3)
3563 "requestorPeer": "GRPCRequestConsumer", (4)
3564 "requestorTimeout": 500 (5)
3566 .. container:: colist arabic
3568 +-------+---------------------------+
3569 | **1** | the event name |
3570 +-------+---------------------------+
3571 | **2** | a filter on the event |
3572 +-------+---------------------------+
3573 | **3** | the mode of the requestor |
3574 +-------+---------------------------+
3575 | **4** | a peer for the requestor |
3576 +-------+---------------------------+
3577 | **5** | a general request timeout |
3578 +-------+---------------------------+
3583 .. container:: paragraph
3585 APEX will connect to the host specified in the producer
3586 side, anad take in response back at the consumer side.
3588 .. container:: listingblock
3590 .. container:: content
3594 "carrierTechnologyParameters": {
3595 "carrierTechnology": "GRPC", (1)
3596 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
3599 .. container:: colist arabic
3601 +-------+------------------------------------------+
3602 | **1** | set GRPC as carrier technology |
3603 +-------+------------------------------------------+
3605 .. container:: paragraph
3607 Further settings are required on the consumer to
3608 define the event that is requested, for example:
3610 .. container:: listingblock
3612 .. container:: content
3616 "eventNameFilter": "GRPCResponseEvent", (1)
3617 "requestorMode": true, (2)
3618 "requestorPeer": "GRPCRequestProducer", (3)
3619 "requestorTimeout": 500 (4)
3621 .. container:: colist arabic
3623 +-------+---------------------------+
3624 | **1** | a filter on the event |
3625 +-------+---------------------------+
3626 | **2** | the mode of the requestor |
3627 +-------+---------------------------+
3628 | **3** | a peer for the requestor |
3629 +-------+---------------------------+
3630 | **4** | a general request timeout |
3631 +-------+---------------------------+
3633 Event Protocols, Format and Encoding
3634 ------------------------------------
3636 .. container:: paragraph
3638 Event protocols define what event formats APEX can receive
3639 (input) and should send (output). They can be used in any
3640 combination for input and output, unless further restricted
3641 by a carrier technology plugin (for instance for JMS
3642 output). There can only be 1 event protocol per event
3645 .. container:: paragraph
3647 Supported *input* event protocols are:
3649 .. container:: ulist
3651 - JSON, the event as a JSON string
3653 - APEX, an APEX event
3655 - JMS object, the event as a JMS object,
3657 - JMS text, the event as a JMS text,
3659 - XML, the event as an XML string,
3661 - YAML, the event as YAML text
3663 .. container:: paragraph
3665 Supported *output* event protocols are:
3667 .. container:: ulist
3669 - JSON, the event as a JSON string
3671 - APEX, an APEX event
3673 - JMS object, the event as a JMS object,
3675 - JMS text, the event as a JMS text,
3677 - XML, the event as an XML string,
3679 - YAML, the event as YAML text
3681 .. container:: paragraph
3683 New event protocols can be added as plugins to APEX or
3684 developed outside APEX and added to an APEX deployment.
3689 .. container:: paragraph
3691 The event protocol for JSON encoding does not require a
3692 specific plugin, it is supported by default. Furthermore,
3693 there is no difference in the configuration for the input
3694 and output interface.
3696 .. container:: paragraph
3698 For an input, APEX requires a well-formed JSON string.
3699 Well-formed here means according to the definitions of a
3700 policy. Any JSON string that is not defined as a trigger
3701 event (consume) will not be consumed (errors will be
3702 thrown). For output JSON events, APEX will always produce
3703 valid JSON strings according to the definition in the
3706 .. container:: paragraph
3708 The following JSON shows the configuration.
3710 .. container:: listingblock
3712 .. container:: content
3716 "eventProtocolParameters":{
3717 "eventProtocol" : "JSON"
3720 .. container:: paragraph
3722 For JSON events, there are a few more optional
3723 parameters, which allow to define a mapping for standard
3724 event fields. An APEX event must have the fields
3725 ``name``, ``version``, ``source``, and ``target``
3726 defined. Sometimes it is not possible to configure a
3727 trigger or actioning system to use those fields. However,
3728 they might be in an event generated outside APEX (or used
3729 outside APEX) just with different names. To configure
3730 APEX to map between the different event names, simply add
3731 the following parameters to a JSON event:
3733 .. container:: listingblock
3735 .. container:: content
3739 "eventProtocolParameters":{
3740 "eventProtocol" : "JSON",
3741 "nameAlias" : "policyName", (1)
3742 "versionAlias" : "policyVersion", (2)
3743 "sourceAlias" : "from", (3)
3744 "targetAlias" : "to", (4)
3745 "nameSpaceAlias": "my.name.space" (5)
3748 .. container:: colist arabic
3750 +-----------------------------------+-----------------------------------+
3751 | **1** | mapping for the ``name`` field, |
3752 | | here from a field called |
3753 | | ``policyName`` |
3754 +-----------------------------------+-----------------------------------+
3755 | **2** | mapping for the ``version`` |
3756 | | field, here from a field called |
3757 | | ``policyVersion`` |
3758 +-----------------------------------+-----------------------------------+
3759 | **3** | mapping for the ``source`` field, |
3760 | | here from a field called ``from`` |
3761 | | (only for an input event) |
3762 +-----------------------------------+-----------------------------------+
3763 | **4** | mapping for the ``target`` field, |
3764 | | here from a field called ``to`` |
3765 | | (only for an output event) |
3766 +-----------------------------------+-----------------------------------+
3767 | **5** | mapping for the ``nameSpace`` |
3768 | | field, here from a field called |
3769 | | ``my.name.space`` |
3770 +-----------------------------------+-----------------------------------+
3774 .. container:: paragraph
3776 The event protocol for APEX events does not require a
3777 specific plugin, it is supported by default. Furthermore,
3778 there is no difference in the configuration for the input
3779 and output interface.
3781 .. container:: paragraph
3783 For input and output APEX uses APEX events.
3785 .. container:: paragraph
3787 The following JSON shows the configuration.
3789 .. container:: listingblock
3791 .. container:: content
3795 "eventProtocolParameters":{
3796 "eventProtocol" : "APEX"
3802 .. container:: paragraph
3804 The event protocol for JMS is provided by the APEX JMS
3805 plugin. The plugin supports encoding as JSON text or as
3806 object. There is no difference in the configuration for
3807 the input and output interface.
3811 .. container:: paragraph
3813 If used as input, APEX will take a JMS message and
3814 extract a JSON string, then proceed as if a JSON event
3815 was received. If used as output, APEX will take the
3816 event produced by a policy, create a JSON string, and
3817 then wrap it into a JMS message.
3819 .. container:: paragraph
3821 The configuration for JMS text is as follows:
3823 .. container:: listingblock
3825 .. container:: content
3829 "eventProtocolParameters":{
3830 "eventProtocol" : "JMSTEXT",
3831 "parameterClassName" :
3832 "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters"
3837 .. container:: paragraph
3839 If used as input, APEX will will take a JMS message,
3840 extract a Java Bean from the ``ObjectMessage``
3841 message, construct an APEX event and put the bean on
3842 the APEX event as a parameter. If used as output, APEX
3843 will take the event produced by a policy, create a
3844 Java Bean and send it as a JMS message.
3846 .. container:: paragraph
3848 The configuration for JMS object is as follows:
3850 .. container:: listingblock
3852 .. container:: content
3856 "eventProtocolParameters":{
3857 "eventProtocol" : "JMSOBJECT",
3858 "parameterClassName" :
3859 "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters"
3865 .. container:: paragraph
3867 The event protocol for YAML is provided by the APEX YAML
3868 plugin. There is no difference in the configuration for
3869 the input and output interface.
3871 .. container:: paragraph
3873 If used as input, APEX will consume events as YAML and
3874 map them to policy trigger events. Not well-formed YAML
3875 and not understood trigger events will be rejected. If
3876 used as output, APEX produce YAML encoded events from the
3877 event a policy produces. Those events will always be
3878 well-formed according to the definition in the policy
3881 .. container:: paragraph
3883 The following code shows the configuration.
3885 .. container:: listingblock
3887 .. container:: content
3891 "eventProtocolParameters":{
3892 "eventProtocol" : "XML",
3893 "parameterClassName" :
3894 "org.onap.policy.apex.plugins.event.protocol.yaml.YamlEventProtocolParameters"
3899 .. container:: paragraph
3901 The event protocol for XML is provided by the APEX XML
3902 plugin. There is no difference in the configuration for
3903 the input and output interface.
3905 .. container:: paragraph
3907 If used as input, APEX will consume events as XML and map
3908 them to policy trigger events. Not well-formed XML and
3909 not understood trigger events will be rejected. If used
3910 as output, APEX produce XML encoded events from the event
3911 a policy produces. Those events will always be
3912 well-formed according to the definition in the policy
3915 .. container:: paragraph
3917 The following code shows the configuration.
3919 .. container:: listingblock
3921 .. container:: content
3925 "eventProtocolParameters":{
3926 "eventProtocol" : "XML",
3927 "parameterClassName" :
3928 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3931 A configuration example
3932 -----------------------
3934 .. container:: paragraph
3936 The following example loads all available plug-ins.
3938 .. container:: paragraph
3940 Events are consumed from a Websocket, APEX as client.
3941 Consumed event format is JSON.
3943 .. container:: paragraph
3945 Events are produced to Kafka. Produced event format is XML.
3947 .. container:: listingblock
3949 .. container:: content
3954 "engineServiceParameters" : {
3955 "name" : "MyApexEngine",
3956 "version" : "0.0.1",
3958 "instanceCount" : 4,
3959 "deploymentPort" : 12345,
3960 "engineParameters" : {
3961 "executorParameters" : {
3963 "parameterClassName" :
3964 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
3967 "parameterClassName" :
3968 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
3971 "parameterClassName" :
3972 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
3975 "parameterClassName" :
3976 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
3979 "parameterClassName" :
3980 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
3983 "contextParameters" : {
3984 "parameterClassName" :
3985 "org.onap.policy.apex.context.parameters.ContextParameters",
3986 "schemaParameters" : {
3988 "parameterClassName" :
3989 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
3995 "producerCarrierTechnologyParameters" : {
3996 "carrierTechnology" : "KAFKA",
3997 "parameterClassName" :
3998 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
4000 "bootstrapServers" : "localhost:49092",
4003 "batchSize" : 16384,
4005 "bufferMemory" : 33554432,
4006 "producerTopic" : "apex-out",
4007 "keySerializer" : "org.apache.kafka.common.serialization.StringSerializer",
4008 "valueSerializer" : "org.apache.kafka.common.serialization.StringSerializer"
4011 "producerEventProtocolParameters" : {
4012 "eventProtocol" : "XML",
4013 "parameterClassName" :
4014 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
4016 "consumerCarrierTechnologyParameters" : {
4017 "carrierTechnology" : "WEBSOCKET",
4018 "parameterClassName" :
4019 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
4021 "host" : "localhost",
4025 "consumerEventProtocolParameters" : {
4026 "eventProtocol" : "JSON"
4030 Engine and Applications of the APEX System
4031 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4033 Introduction to APEX Engine and Applications
4034 --------------------------------------------
4036 .. container:: paragraph
4038 The core of APEX is the APEX Engine, also known as the APEX
4039 Policy Engine or the APEX PDP (since it is in fact a Policy
4040 Decision Point). Beside this engine, an APEX system comes
4041 with a few applications intended to help with policy
4042 authoring, deployment, and execution.
4044 .. container:: paragraph
4046 The engine itself and most applications are started from the
4047 command line with command line arguments. This is called a
4048 Command Line Interface (CLI). Some applications require an
4049 installation on a webserver, as for instance the REST
4050 Editor. Those applications can be accessed via a web
4053 .. container:: paragraph
4055 You can also use the available APEX APIs and applications to
4056 develop other applications as required. This includes policy
4057 languages (and associated parsers and compilers /
4058 interpreters), GUIs to access APEX or to define policies,
4059 clients to connect to APEX, etc.
4061 .. container:: paragraph
4063 For this documentation, we assume an installation of APEX as
4064 a full system based on a current ONAP release.
4066 CLI on Unix, Windows, and Cygwin
4067 --------------------------------
4069 .. container:: paragraph
4071 A note on APEX CLI applications: all applications and the
4072 engine itself have been deployed and tested on different
4073 operating systems: Red Hat, Ubuntu, Debian, Mac OSX,
4074 Windows, Cygwin. Each operating system comes with its own
4075 way of configuring and executing Java. The main items here
4078 .. container:: ulist
4080 - For UNIX systems (RHL, Ubuntu, Debian, Mac OSX), the
4081 provided bash scripts work as expected with absolute
4083 ``/opt/app/policy/apex-pdp/apex-pdp-2.0.0-SNAPSHOT/examples``),
4084 indirect and linked paths (e.g. ``../apex/apex``), and
4085 path substitutions using environment settings (e.g.
4086 ``$APEX_HOME/bin/``)
4088 - For Windows systems, the provided batch files (``.bat``)
4089 work as expected with with absolute paths (e.g.
4090 ``C:\apex\apex-2.0.0-SNAPSHOT\examples``), and path
4091 substitutions using environment settings (e.g.
4092 ``%APEX_HOME%\bin\``)
4094 - For Cygwin system we assume a standard Cygwin
4095 installation with standard tools (mainly bash) using a
4096 Windows Java installation. This means that the bash
4097 scripts can be used as in UNIX, however any argument
4098 pointing to files and directories need to use either a
4100 ``C:\apex\apex-2.0.0-SNAPSHOT\examples\config...``) or
4101 the command ``cygpath`` with a mixed option. The reason
4102 for that is: Cygwin executes Java using UNIX paths but
4103 then runs Java as a DOS/WINDOWS process, which requires
4104 DOS paths for file access.
4109 .. container:: paragraph
4111 The APEX engine can be started in different ways, depending
4112 your requirements. All scripts are located in the APEX *bin*
4115 .. container:: paragraph
4117 On UNIX and Cygwin systems use:
4119 .. container:: ulist
4121 - ``apexEngine.sh`` - this script will
4123 .. container:: ulist
4125 - Test if ``$APEX_USER`` is set and if the user
4126 exists, terminate with an error otherwise
4128 - Test if ``$APEX_HOME`` is set. If not set, it will
4129 use the default setting as
4130 ``/opt/app/policy/apex-pdp/apex-pdp``. Then the set
4131 directory is tested to exist, the script will
4134 - When all tests are passed successfully, the script
4135 will call ``apexApps.sh`` with arguments to start
4138 - ``apexApps.sh engine`` - this is the general APEX
4139 application launcher, which will
4141 .. container:: ulist
4143 - Start the engine with the argument ``engine``
4145 - Test if ``$APEX_HOME`` is set and points to an
4146 existing directory. If not set or directory does
4147 not exist, script terminates.
4149 - Not test for any settings of ``$APEX_USER``.
4151 .. container:: paragraph
4153 On Windows systems use ``apexEngine.bat`` and
4154 ``apexApps.bat engine`` respectively. Note: none of the
4155 windows batch files will test for ``%APEX_USER%``.
4157 .. container:: paragraph
4159 Summary of alternatives to start the APEX Engine:
4161 +--------------------------------------------------------+----------------------------------------------------------+
4162 | Unix, Cygwin | Windows |
4163 +========================================================+==========================================================+
4164 | .. container:: | .. container:: |
4166 | .. container:: listingblock | .. container:: listingblock |
4168 | .. container:: content | .. container:: content |
4170 | .. code:: | .. code:: |
4172 | # $APEX_HOME/bin/apexEngine.sh [args] | > %APEX_HOME%\bin\apexEngine.bat [args] |
4173 | # $APEX_HOME/bin/apexApps.sh engine [args] | > %APEX_HOME%\bin\apexApps.bat engine [args] |
4174 +--------------------------------------------------------+----------------------------------------------------------+
4176 .. container:: paragraph
4178 The APEX engine comes with a few CLI arguments, the main one is for setting
4179 the tosca policy file for execution. The tosca policy file is
4180 always required. The option ``-h`` prints a help screen.
4182 .. container:: listingblock
4184 .. container:: content
4188 usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]
4190 -p,--tosca-policy-file <TOSCA_POLICY_FILE> the full path to the ToscaPolicy file to use.
4191 -h,--help outputs the usage of this command
4192 -v,--version outputs the version of Apex
4197 .. container:: paragraph
4199 The CLI Editor allows to define policies from the command
4200 line. The application uses a simple language and supports
4201 all elements of an APEX policy. It can be used in to
4204 .. container:: ulist
4206 - non-interactive, specifying a file with the commands to
4209 - interactive, using the editors CLI to create a policy
4211 .. container:: paragraph
4213 When a policy is fully specified, the editor will generate
4214 the APEX core policy specification in JSON. This core
4215 specification is called the policy model in the APEX engine
4216 and can be used directly with the APEX engine.
4218 .. container:: paragraph
4220 On UNIX and Cygwin systems use:
4222 .. container:: ulist
4224 - ``apexCLIEditor.sh`` - simply starts the CLI editor,
4225 arguments to the script determine the mode of the editor
4227 - ``apexApps.sh cli-editor`` - simply starts the CLI
4228 editor, arguments to the script determine the mode of the
4231 .. container:: paragraph
4233 On Windows systems use:
4235 .. container:: ulist
4237 - ``apexCLIEditor.bat`` - simply starts the CLI editor,
4238 arguments to the script determine the mode of the editor
4240 - ``apexApps.bat cli-editor`` - simply starts the CLI
4241 editor, arguments to the script determine the mode of the
4244 .. container:: paragraph
4246 Summary of alternatives to start the APEX CLI Editor:
4248 +------------------------------------------------------------+--------------------------------------------------------------+
4249 | Unix, Cygwin | Windows |
4250 +============================================================+==============================================================+
4251 | .. container:: | .. container:: |
4253 | .. container:: listingblock | .. container:: listingblock |
4255 | .. container:: content | .. container:: content |
4257 | .. code:: | .. code:: |
4259 | # $APEX_HOME/bin/apexCLIEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIEditor.bat [args] |
4260 | # $APEX_HOME/bin/apexApps.sh cli-editor [args] | > %APEX_HOME%\bin\apexApps.bat cli-editor [args] |
4261 +------------------------------------------------------------+--------------------------------------------------------------+
4263 .. container:: paragraph
4265 The option ``-h`` provides a help screen with all command
4268 .. container:: listingblock
4270 .. container:: content
4274 usage: org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain [options...]
4276 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4277 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4278 -h,--help outputs the usage of this command
4279 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4280 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and continue
4281 executing the command file
4282 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will log
4283 to standard output if not specified or suppressed with "-nl" flag
4284 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4285 -nl,--no-log if specified, no logging or output of commands to standard output or log
4287 -nm,--no-model-output if specified, no output of a model to standard output or model output
4288 file is carried out, the user can use the "save" command in a script to
4290 -o,--output-model-file <OUTPUT_MODEL_FILE> name of a file that will contain the output model for the editor, will
4291 output model to standard output if not specified or suppressed with
4293 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4294 root from which to look for included macro files
4296 The APEX CLI Tosca Editor
4297 -------------------------
4299 .. container:: paragraph
4301 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.
4303 .. container:: paragraph
4305 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.
4307 .. container:: paragraph
4309 On UNIX and Cygwin systems use:
4311 .. container:: ulist
4313 - ``apexCLIToscaEditor.sh`` - starts the CLI Tosca editor,
4314 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4316 - ``apexApps.sh cli-tosca-editor`` - starts the CLI Tosca editor,
4317 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4319 .. container:: paragraph
4321 On Windows systems use:
4323 .. container:: ulist
4325 - ``apexCLIToscaEditor.bat`` - starts the CLI Tosca editor,
4326 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4328 - ``apexApps.bat cli-tosca-editor`` - starts the CLI Tosca
4329 editor, all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4331 .. container:: paragraph
4333 Summary of alternatives to start the APEX CLI Tosca Editor:
4335 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4336 | Unix, Cygwin | Windows |
4337 +=================================================================+====================================================================+
4338 | .. container:: | .. container:: |
4340 | .. container:: listingblock | .. container:: listingblock |
4342 | .. container:: content | .. container:: content |
4344 | .. code:: | .. code:: |
4346 | # $APEX_HOME/bin/apexCLIToscaEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIToscaEditor.bat [args] |
4347 | # $APEX_HOME/bin/apexApps.sh cli-tosca-editor [args]| > %APEX_HOME%\bin\apexApps.bat cli-tosca-editor [args] |
4348 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4350 .. container:: paragraph
4352 The option ``-h`` provides a help screen with all command
4355 .. container:: listingblock
4357 .. container:: content
4361 usage: org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain [options...]
4363 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4364 -ac,--apex-config-file <APEX_CONFIG_FILE> name of the file containing apex configuration details
4365 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4366 -h,--help outputs the usage of this command
4367 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4368 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and
4369 continue executing the command file
4370 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will
4371 log to standard output if not specified or suppressed with "-nl" flag
4372 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4373 -nl,--no-log if specified, no logging or output of commands to standard output or
4374 log file is carried out
4375 -ot,--output-tosca-file <OUTPUT_TOSCA_FILE> name of a file that will contain the output ToscaServiceTemplate
4376 -t,--tosca-template-file <TOSCA_TEMPLATE_FILE> name of the input file containing tosca template which needs to be
4378 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4379 root from which to look for included macro files
4381 .. container:: paragraph
4383 An example command to run the APEX CLI Tosca editor on windows machine is given below.
4385 .. container:: listingblock
4387 .. container:: content
4391 %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
4397 .. container:: paragraph
4399 The APEX Client combines the Policy Editor, the
4400 Monitoring Client, and the Deployment Client into a single
4401 application. The standard way to use the APEX Full Client is
4402 via an installation of the *war* file on a webserver.
4403 However, the Full Client can also be started via command
4404 line. This will start a Grizzly webserver with the *war*
4405 deployed. Access to the Full Client is then via the provided
4408 .. container:: paragraph
4410 On UNIX and Cygwin systems use:
4412 .. container:: ulist
4414 - ``apexApps.sh full-client`` - simply starts the webserver
4415 with the Full Client
4417 .. container:: paragraph
4419 On Windows systems use:
4421 .. container:: ulist
4423 - ``apexApps.bat full-client`` - simply starts the
4424 webserver with the Full Client
4426 .. container:: paragraph
4428 The option ``-h`` provides a help screen with all command
4431 .. container:: listingblock
4433 .. container:: content
4437 usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]
4438 -h,--help outputs the usage of this command
4439 -p,--port <PORT> port to use for the Apex Services REST calls
4440 -t,--time-to-live <TIME_TO_LIVE> the amount of time in seconds that the server will run for before terminating
4442 .. container:: paragraph
4444 If the Full Client is started without any arguments the
4445 final messages will look similar to this:
4447 .. container:: listingblock
4449 .. container:: content
4453 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
4454 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.NetworkListener start
4455 INFO: Started listener bound to [localhost:18989]
4456 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.HttpServer start
4457 INFO: [HttpServer] Started.
4458 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
4460 .. container:: paragraph
4462 The last line states the URL on which the Monitoring Client
4463 can be accessed. The example above stated
4464 ``http://localhost:18989/apexservices``. In a web browser
4465 use the URL ``http://localhost:18989``.
4467 The APEX Application Launcher
4468 -----------------------------
4470 .. container:: paragraph
4472 The standard applications (Engine and CLI Editor)
4473 come with dedicated start scripts. For all other APEX
4474 applications, we provide an application launcher.
4476 .. container:: paragraph
4478 On UNIX and Cygwin systems use:
4480 .. container:: ulist
4482 - apexApps.sh\` - simply starts the application launcher
4484 .. container:: paragraph
4486 On Windows systems use:
4488 .. container:: ulist
4490 - ``apexApps.bat`` - simply starts the application launcher
4492 .. container:: paragraph
4494 Summary of alternatives to start the APEX application
4497 +-------------------------------------------------+---------------------------------------------------+
4498 | Unix, Cygwin | Windows |
4499 +=================================================+===================================================+
4500 | .. container:: | .. container:: |
4502 | .. container:: listingblock | .. container:: listingblock |
4504 | .. container:: content | .. container:: content |
4506 | .. code:: | .. code:: |
4508 | # $APEX_HOME/bin/apexApps.sh [args] | > %APEX_HOME%\bin\apexApps.bat [args] |
4509 +-------------------------------------------------+---------------------------------------------------+
4511 .. container:: paragraph
4513 The option ``-h`` provides a help screen with all launcher
4514 command line arguments.
4516 .. container:: listingblock
4518 .. container:: content
4522 apexApps.sh - runs APEX applications
4524 Usage: apexApps.sh [options] | [<application> [<application options>]]
4527 -d <app> - describes an application
4528 -l - lists all applications supported by this script
4529 -h - this help screen
4531 .. container:: paragraph
4533 Using ``-l`` lists all known application the launcher can
4536 .. container:: listingblock
4538 .. container:: content
4542 apexApps.sh: supported applications:
4543 --> ws-echo engine eng-monitoring full-client eng-deployment tpl-event-json model-2-cli rest-editor cli-editor ws-console
4545 .. container:: paragraph
4547 Using the ``-d <name>`` option describes the named
4548 application, for instance for the ``ws-console``:
4550 .. container:: listingblock
4552 .. container:: content
4556 apexApps.sh: application 'ws-console'
4557 --> a simple console sending events to APEX, connect to APEX consumer port
4559 .. container:: paragraph
4561 Launching an application is done by calling the script with
4562 only the application name and any CLI arguments for the
4563 application. For instance, starting the ``ws-echo``
4564 application with port ``8888``:
4566 .. container:: listingblock
4568 .. container:: content
4572 apexApps.sh ws-echo -p 8888
4574 Application: Create Event Templates
4575 -----------------------------------
4577 .. container:: paragraph
4579 **Status: Experimental**
4581 .. container:: paragraph
4583 This application takes a policy model (JSON or XML encoded)
4584 and generates templates for events in JSON format. This can
4585 help when a policy defines rather complex trigger or action
4586 events or complex events between states. The application can
4587 produce events for the types: stimuli (policy trigger
4588 events), internal (events between policy states), and
4589 response (action events).
4591 +----------------------------------------------------------------+------------------------------------------------------------------+
4592 | Unix, Cygwin | Windows |
4593 +================================================================+==================================================================+
4594 | .. container:: | .. container:: |
4596 | .. container:: listingblock | .. container:: listingblock |
4598 | .. container:: content | .. container:: content |
4600 | .. code:: | .. code:: |
4602 | # $APEX_HOME/bin/apexApps.sh tpl-event-json [args] | > %APEX_HOME%\bin\apexApps.bat tpl-event-json [args] |
4603 +----------------------------------------------------------------+------------------------------------------------------------------+
4605 .. container:: paragraph
4607 The option ``-h`` provides a help screen.
4609 .. container:: listingblock
4611 .. container:: content
4615 gen-model2event v{release-version} - generates JSON templates for events generated from a policy model
4616 usage: gen-model2event
4617 -h,--help prints this help and usage screen
4618 -m,--model <MODEL-FILE> set the input policy model file
4619 -t,--type <TYPE> set the event type for generation, one of:
4620 stimuli (trigger events), response (action
4621 events), internal (events between states)
4622 -v,--version prints the application version
4624 .. container:: paragraph
4626 The created templates are not valid events, instead they use
4627 some markup for values one will need to change to actual
4628 values. For instance, running the tool with the *Sample
4629 Domain* policy model as:
4631 .. container:: listingblock
4633 .. container:: content
4637 apexApps.sh tpl-event-json -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json -t stimuli
4639 .. container:: paragraph
4641 will produce the following status messages:
4643 .. container:: listingblock
4645 .. container:: content
4649 gen-model2event: starting Event generator
4650 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4653 .. container:: paragraph
4655 and then run the generator application producing two event
4656 templates. The first template is called ``Event0000``.
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" : ###double: 0.0###,
4671 "TestTimestamp" : ###long: 0###,
4672 "TestMatchCase" : ###integer: 0###,
4673 "TestSlogan" : "###string###"
4676 .. container:: paragraph
4678 The values for the keys are marked with ``#`` and the
4679 expected type of the value. To create an actual stimuli
4680 event, all these markers need to be change to actual values,
4683 .. container:: listingblock
4685 .. container:: content
4690 "name" : "Event0000",
4691 "nameSpace" : "org.onap.policy.apex.sample.events",
4692 "version" : "0.0.1",
4693 "source" : "Outside",
4695 "TestTemperature" : 25,
4696 "TestTimestamp" : 123456789123456789,
4697 "TestMatchCase" : 1,
4698 "TestSlogan" : "Testing the Match Case with Temperature 25"
4701 Application: Convert a Policy Model to CLI Editor Commands
4702 ----------------------------------------------------------
4704 .. container:: paragraph
4706 **Status: Experimental**
4708 .. container:: paragraph
4710 This application takes a policy model (JSON or XML encoded)
4711 and generates commands for the APEX CLI Editor. This
4712 effectively reverses a policy specification realized with
4715 +-------------------------------------------------------------+---------------------------------------------------------------+
4716 | Unix, Cygwin | Windows |
4717 +=============================================================+===============================================================+
4718 | .. container:: | .. container:: |
4720 | .. container:: listingblock | .. container:: listingblock |
4722 | .. container:: content | .. container:: content |
4724 | .. code:: | .. code:: |
4726 | # $APEX_HOME/bin/apexApps.sh model-2-cli [args] | > %APEX_HOME%\bin\apexApps.bat model-2-cli [args] |
4727 +-------------------------------------------------------------+---------------------------------------------------------------+
4729 .. container:: paragraph
4731 The option ``-h`` provides a help screen.
4733 .. container:: listingblock
4735 .. container:: content
4739 usage: gen-model2cli
4740 -h,--help prints this help and usage screen
4741 -m,--model <MODEL-FILE> set the input policy model file
4742 -sv,--skip-validation switch of validation of the input file
4743 -v,--version prints the application version
4745 .. container:: paragraph
4747 For instance, running the tool with the *Sample Domain*
4750 .. container:: listingblock
4752 .. container:: content
4756 apexApps.sh model-2-cli -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json
4758 .. container:: paragraph
4760 will produce the following status messages:
4762 .. container:: listingblock
4764 .. container:: content
4768 gen-model2cli: starting CLI generator
4769 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4771 .. container:: paragraph
4773 and then run the generator application producing all CLI
4774 Editor commands and printing them to standard out.
4776 Application: Websocket Clients (Echo and Console)
4777 -------------------------------------------------
4779 .. container:: paragraph
4781 **Status: Production**
4783 .. container:: paragraph
4785 The application launcher also provides a Websocket echo
4786 client and a Websocket console client. The echo client
4787 connects to APEX and prints all events it receives from
4788 APEX. The console client connects to APEX, reads input from
4789 the command line, and sends this input as events to APEX.
4791 +------------------------------------------------------------+--------------------------------------------------------------+
4792 | Unix, Cygwin | Windows |
4793 +============================================================+==============================================================+
4794 | .. container:: | .. container:: |
4796 | .. container:: listingblock | .. container:: listingblock |
4798 | .. container:: content | .. container:: content |
4800 | .. code:: | .. code:: |
4802 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
4803 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
4804 +------------------------------------------------------------+--------------------------------------------------------------+
4806 .. container:: paragraph
4808 The arguments are the same for both applications:
4810 .. container:: ulist
4812 - ``-p`` defines the Websocket port to connect to (defaults
4815 - ``-s`` defines the host on which a Websocket server is
4816 running (defaults to ``localhost``)
4818 .. container:: paragraph
4820 A discussion on how to use these two applications to build
4821 an APEX system is detailed HowTo-Websockets.
4826 Introduction to APEX Logging
4827 ----------------------------
4829 .. container:: paragraph
4831 All APEX components make extensive use of logging using the
4832 logging façade `SLF4J <https://www.slf4j.org/>`__ with the
4833 backend `Logback <https://logback.qos.ch/>`__. Both are used
4834 off-the-shelve, so the standard documentation and
4835 configuration apply to APEX logging. For details on how to
4836 work with logback please see the `logback
4837 manual <https://logback.qos.ch/manual/index.html>`__.
4839 .. container:: paragraph
4841 The APEX applications is the logback configuration file
4842 ``$APEX_HOME/etc/logback.xml`` (Windows:
4843 ``%APEX_HOME%\etc\logback.xml``). The logging backend is set
4844 to no debug, i.e. logs from the logging framework should be
4847 .. container:: paragraph
4849 The configurable log levels work as expected:
4851 .. container:: ulist
4853 - *error* (or *ERROR*) is used for serious errors in the
4856 - *warn* (or *WARN*) is used for warnings, which in general
4857 can be ignored but might indicate some deeper problems
4859 - *info* (or *INFO*) is used to provide generally
4860 interesting messages for startup and policy execution
4862 - *debug* (or *DEBUG*) provides more details on startup and
4865 - *trace* (or *TRACE*) gives full details on every aspect
4866 of the APEX engine from start to end
4868 .. container:: paragraph
4870 The loggers can also be configured as expected. The standard
4871 configuration (after installing APEX) uses log level *info*
4872 on all APEX classes (components).
4874 .. container:: paragraph
4876 The applications and scripts in ``$APEX_HOME/bin`` (Windows:
4877 ``%APEX_HOME\bin``) are configured to use the logback
4878 configuration ``$APEX_HOME/etc/logback.xml`` (Windows:
4879 ``%APEX_HOME\etc\logback.xml``). There are multiple ways to
4880 use different logback configurations, for instance:
4882 .. container:: ulist
4884 - Maintain multiple configurations in ``etc``, for instance
4885 a ``logback-debug.xml`` for deep debugging and a
4886 ``logback-production.xml`` for APEX in production mode,
4887 then copy the required configuration file to the used
4888 ``logback.xml`` prior starting APEX
4890 - Edit the scripts in ``bin`` to use a different logback
4891 configuration file (only recommended if you are familiar
4892 with editing bash scripts or windows batch files)
4894 Standard Logging Configuration
4895 ------------------------------
4897 .. container:: paragraph
4899 The standard logging configuration defines a context *APEX*,
4900 which is used in the standard output pattern. The location
4901 for log files is defined in the property ``logDir`` and set
4902 to ``/var/log/onap/policy/apex-pdp``. The standard status
4903 listener is set to *NOP* and the overall logback
4904 configuration is set to no debug.
4906 .. container:: listingblock
4908 .. container:: content
4913 <configuration debug="false">
4914 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
4916 <contextName>Apex</contextName>
4917 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
4923 .. container:: paragraph
4925 The first appender defined is called ``STDOUT`` for logs to standard
4928 .. container:: listingblock
4930 .. container:: content
4935 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4937 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
4941 .. container:: paragraph
4943 The root level logger then is set to the level *info* using the
4944 standard out appender.
4946 .. container:: listingblock
4948 .. container:: content
4954 <appender-ref ref="STDOUT" />
4957 .. container:: paragraph
4959 The second appender is called ``FILE``. It writes logs to a file
4962 .. container:: listingblock
4964 .. container:: content
4969 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
4970 <file>${logDir}/apex.log</file>
4972 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4976 .. container:: paragraph
4978 The third appender is called ``CTXT_FILE``. It writes logs to a file
4981 .. container:: listingblock
4983 .. container:: content
4988 <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
4989 <file>${logDir}/apex_ctxt.log</file>
4991 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4995 .. container:: paragraph
4997 The last definitions are for specific loggers. The first logger
4998 captures all standard APEX classes. It is configured for log level
4999 *info* and uses the standard output and file appenders. The second
5000 logger captures APEX context classes responsible for context
5001 monitoring. It is configured for log level *trace* and uses the
5002 context file appender.
5004 .. container:: listingblock
5006 .. container:: content
5012 <logger name="org.onap.policy.apex" level="info" additivity="false">
5013 <appender-ref ref="STDOUT" />
5014 <appender-ref ref="FILE" />
5017 <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
5018 <appender-ref ref="CTXT_FILE" />
5021 Adding Logback Status and Debug
5022 -------------------------------
5024 .. container:: paragraph
5026 To activate logback status messages change the status listener
5027 from 'NOP' to for instance console.
5029 .. container:: listingblock
5031 .. container:: content
5035 <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
5037 .. container:: paragraph
5039 To activate all logback debugging, for instance to debug a new
5040 logback configuration, activate the debug attribute in the
5043 .. container:: listingblock
5045 .. container:: content
5049 <configuration debug="true">
5053 Logging External Components
5054 ---------------------------
5056 .. container:: paragraph
5058 Logback can also be configured to log any other, external
5059 components APEX is using, if they are using the common logging
5062 .. container:: paragraph
5064 For instance, the context component of APEX is using *Infinispan*
5065 and one can add a logger for this external component. The
5066 following example adds a logger for *Infinispan* using the
5067 standard output appender.
5069 .. container:: listingblock
5071 .. container:: content
5075 <logger name="org.infinispan" level="INFO" additivity="false">
5076 <appender-ref ref="STDOUT" />
5079 .. container:: paragraph
5081 Another example is Apache Zookeeper. The following example adds a
5082 logger for Zookeeper using the standard outout appender.
5084 .. container:: listingblock
5086 .. container:: content
5090 <logger name="org.apache.zookeeper.ClientCnxn" level="INFO" additivity="false">
5091 <appender-ref ref="STDOUT" />
5094 Configuring loggers for Policy Logic
5095 ------------------------------------
5097 .. container:: paragraph
5099 The logging for the logic inside a policy (task logic, task
5100 selection logic, state finalizer logic) can be configured separate
5101 from standard logging. The logger for policy logic is
5102 ``org.onap.policy.apex.executionlogging``. The following example
5105 .. container:: ulist
5107 - a new appender for standard out using a very simple pattern
5108 (simply the actual message)
5110 - a logger for policy logic to standard out using the new
5111 appender and the already described file appender.
5113 .. container:: listingblock
5115 .. container:: content
5119 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5121 <pattern>policy: %msg\n</pattern>
5125 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5126 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5127 <appender-ref ref="FILE" />
5130 .. container:: paragraph
5132 It is also possible to use specific logging for parts of policy
5133 logic. The following example defines a logger for task logic.
5135 .. container:: listingblock
5137 .. container:: content
5141 <logger name="org.onap.policy.apex.executionlogging.TaskExecutionLogging" level="TRACE" additivity="false">
5142 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5145 Rolling File Appenders
5146 ----------------------
5148 .. container:: paragraph
5150 Rolling file appenders are a good option for more complex logging
5151 of a production or complex testing APEX installation. The standard
5152 logback configuration can be used for these use cases. This
5153 section gives two examples for the standard logging and for
5156 .. container:: paragraph
5158 First the standard logging. The following example defines a
5159 rolling file appender. The appender rolls over on a daily basis.
5160 It allows for a file size of 100 MB.
5162 .. container:: listingblock
5164 .. container:: content
5168 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
5169 <file>${logDir}/apex.log</file>
5170 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5171 <!-- rollover daily -->
5172 <!-- <fileNamePattern>xstream-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> -->
5173 <fileNamePattern>${logDir}/apex_%d{yyyy-MM-dd}.%i.log.gz
5175 <maxHistory>4</maxHistory>
5176 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5177 <!-- or whenever the file size reaches 100MB -->
5178 <maxFileSize>100MB</maxFileSize>
5179 </timeBasedFileNamingAndTriggeringPolicy>
5183 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5188 .. container:: paragraph
5190 A very similar configuration can be used for a rolling file
5191 appender logging APEX context.
5193 .. container:: listingblock
5195 .. container:: content
5199 <appender name="CTXT-FILE"
5200 class="ch.qos.logback.core.rolling.RollingFileAppender">
5201 <file>${logDir}/apex_ctxt.log</file>
5202 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5203 <fileNamePattern>${logDir}/apex_ctxt_%d{yyyy-MM-dd}.%i.log.gz
5205 <maxHistory>4</maxHistory>
5206 <timeBasedFileNamingAndTriggeringPolicy
5207 class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5208 <maxFileSize>100MB</maxFileSize>
5209 </timeBasedFileNamingAndTriggeringPolicy>
5213 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5218 Example Configuration for Logging Logic
5219 ---------------------------------------
5221 .. container:: paragraph
5223 The following example shows a configuration that logs policy logic
5224 to standard out and a file (*info*). All other APEX components are
5225 logging to a file (*debug*).. This configuration an be used in a
5226 pre-production phase with the APEX engine still running in a
5227 separate terminal to monitor policy execution. This logback
5228 configuration is in the APEX installation as
5229 ``etc/logback-logic.xml``.
5231 .. container:: listingblock
5233 .. container:: content
5237 <configuration debug="false">
5238 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5240 <contextName>Apex</contextName>
5241 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5243 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5245 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
5249 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5250 <file>${logDir}/apex.log</file>
5253 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5258 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5260 <pattern>policy: %msg\n</pattern>
5264 <root level="error">
5265 <appender-ref ref="STDOUT" />
5268 <logger name="org.onap.policy.apex" level="debug" additivity="false">
5269 <appender-ref ref="FILE" />
5272 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5273 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5274 <appender-ref ref="FILE" />
5278 Example Configuration for a Production Server
5279 ---------------------------------------------
5281 .. container:: paragraph
5283 The following example shows a configuration that logs all APEX
5284 components, including policy logic, to a file (*debug*). This
5285 configuration an be used in a production phase with the APEX
5286 engine being executed as a service on a system without console
5287 output. This logback configuration is in the APEX installation as
5288 ``logback-server.xml``
5290 .. container:: listingblock
5292 .. container:: content
5296 <configuration debug="false">
5297 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5299 <contextName>Apex</contextName>
5300 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5302 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5303 <file>${logDir}/apex.log</file>
5306 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5311 <root level="debug">
5312 <appender-ref ref="FILE" />
5315 <logger name="org.onap.policy.apex.executionlogging" level="debug" additivity="false">
5316 <appender-ref ref="FILE" />
5320 Unsupported Features
5321 ^^^^^^^^^^^^^^^^^^^^
5323 .. container:: paragraph
5325 This section documents some legacy and unsupported features
5326 in apex-pdp. The documentation here has not been updated for
5327 recent versions of apex-pdp. For example, the apex-pdp models
5328 specified in this example should now be in TOSCA format.
5330 Building a System with Websocket Backend
5331 ----------------------------------------
5336 .. container:: paragraph
5338 Websocket is a protocol to run sockets of HTTP. Since it in
5339 essence a socket, the connection is realized between a
5340 server (waiting for connections) and a client (connecting to
5341 a server). Server/client separation is only important for
5342 connection establishment, once connected, everyone can
5343 send/receive on the same socket (as any standard socket
5346 .. container:: paragraph
5348 Standard Websocket implementations are simple, no
5349 publish/subscribe and no special event handling. Most
5350 servers simply send all incoming messages to all
5351 connections. There is a PubSub definition on top of
5352 Websocket called `WAMP <http://wamp-proto.org/>`__. APEX
5353 does not support WAMP at the moment.
5358 .. container:: paragraph
5361 356 <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5362 defines the standard Websocket API. This JSR is part of Jave
5363 EE 7 standard. For Java SE, several implementations exist in
5364 open source. Since Websockets are a stable standard and
5365 simple, most implementations are stable and ready to use. A
5366 lot of products support Websockets, like Spring, JBoss,
5367 Netty, … there are also Kafka extensions for Websockets.
5369 Websocket Example Code for Websocket clients (FOSS)
5370 ###################################################
5372 .. container:: paragraph
5374 There are a lot of implementations and examples available on
5375 Github for Websocket clients. If one is using Java EE 7,
5376 then one can also use the native Websocket implementation.
5377 Good examples for clients using simply Java SE are here:
5379 .. container:: ulist
5382 implementation <https://github.com/TooTallNate/Java-WebSocket>`__
5384 - `Websocket sending client example, using
5385 AWT <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ChatClient.java>`__
5387 - `Websocket receiving client example (simple echo
5388 client) <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ExampleClient.java>`__
5390 .. container:: paragraph
5392 For Java EE, the native Websocket API is explained here:
5394 .. container:: ulist
5397 docs <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5400 example <http://www.programmingforliving.com/2013/08/jsr-356-java-api-for-websocket-client-api.html>`__
5402 BCP: Websocket Configuration
5403 ############################
5405 .. container:: paragraph
5407 The probably best is to configure APEX for Websocket servers
5408 for input (ingress, consume) and output (egress, produce)
5409 interfaces. This means that APEX will start Websocket
5410 servers on named ports and wait for clients to connect.
5411 Advantage: once APEX is running all connectivity
5412 infrastructure is running as well. Consequence: if APEX is
5413 not running, everyone else is in the dark, too.
5415 .. container:: paragraph
5417 The best protocol to be used is JSON string. Each event on
5418 any interface is then a string with a JSON encoding. JSON
5419 string is a little bit slower than byte code, but we doubt
5420 that this will be noticeable. A further advantage of JSON
5421 strings over Websockets with APEX starting the servers: it
5422 is very easy to connect web browsers to such a system.
5423 Simple connect the web browser to the APEX sockets and
5424 send/read JSON strings.
5426 .. container:: paragraph
5428 Once APEX is started you simply connect Websocket clients to
5429 it, and send/receive event. When APEX is terminated, the
5430 Websocket servers go down, and the clients will be
5431 disconnected. APEX does not (yet) support auto-client
5432 reconnect nor WAMP, so clients might need to be restarted or
5433 reconnected manually after an APEX boot.
5435 Demo with VPN Policy Model
5436 ##########################
5438 .. container:: paragraph
5440 We assume that you have an APEX installation using the full
5441 package, i.e. APEX with all examples, of version ``0.5.6``
5442 or higher. We will use the VPN policy from the APEX examples
5445 .. container:: paragraph
5447 Now, have the following ready to start the demo:
5449 .. container:: ulist
5451 - 3 terminals on the host where APEX is running (we need 1
5452 for APEX and 1 for each client)
5454 - the events in the file
5455 ``$APEX_HOME/examples/events/VPN/SetupEvents.json`` open
5456 in an editor (we need to send those events to APEX)
5458 - the events in the file
5459 ``$APEX_HOME/examples/events/VPN/Link09Events.json`` open
5460 in an editor (we need to send those events to APEX)
5462 A Websocket Configuration for the VPN Domain
5463 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5465 .. container:: paragraph
5467 Create a new APEX configuration using the VPN policy
5468 model and configuring APEX as discussed above for
5469 Websockets. Copy the following configuration into
5470 ``$APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json``
5472 ``%APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json``):
5474 .. container:: listingblock
5476 .. container:: content
5482 "engineServiceParameters" : {
5483 "name" : "VPNApexEngine",
5484 "version" : "0.0.1",
5486 "instanceCount" : 1,
5487 "deploymentPort" : 12345,
5488 "policyModelFileName" : "examples/models/VPN/VPNPolicyModelAvro.json",
5489 "engineParameters" : {
5490 "executorParameters" : {
5492 "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
5495 "contextParameters" : {
5496 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
5497 "schemaParameters":{
5499 "parameterClassName" : "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
5505 "producerCarrierTechnologyParameters" : {
5506 "carrierTechnology" : "WEBSOCKET",
5507 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5513 "producerEventProtocolParameters" : {
5514 "eventProtocol" : "JSON"
5516 "consumerCarrierTechnologyParameters" : {
5517 "carrierTechnology" : "WEBSOCKET",
5518 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5524 "consumerEventProtocolParameters" : {
5525 "eventProtocol" : "JSON"
5532 .. container:: paragraph
5534 In a new terminal, start APEX with the new configuration for
5535 Websocket-Server ingress/egress:
5537 .. container:: listingblock
5539 .. container:: content
5544 #: $APEX_HOME/bin/apexApps.sh engine -c $APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json
5546 .. container:: listingblock
5548 .. container:: content
5553 #: %APEX_HOME%\bin\apexApps.bat engine -c %APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json
5555 .. container:: paragraph
5557 Wait for APEX to start, it takes a while to create all Websocket
5558 servers (about 8 seconds on a standard laptop without cached
5559 binaries). depending on your log messages, you will see no (some, a
5560 lot) log messages. If APEX starts correctly, the last few messages
5563 .. container:: listingblock
5565 .. container:: content
5570 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)
5571 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 ...
5572 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
5573 Started Apex service
5575 .. container:: paragraph
5577 APEX is running in the new terminal and will produce output when the
5578 policy is triggered/executed.
5580 Run the Websocket Echo Client
5581 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5583 .. container:: paragraph
5585 The echo client is included in an APEX full installation. To run
5586 the client, open a new shell (Unix, Cygwin) or command prompt
5587 (``cmd`` on Windows). Then use the APEX application launcher to
5591 APEX engine needs to run first
5592 The example assumes that an APEX engine configured for *produce* carrier technology Websocket and *JSON* event protocol is executed first.
5594 +---------------------------------------------------------+-----------------------------------------------------------+
5595 | Unix, Cygwin | Windows |
5596 +=========================================================+===========================================================+
5597 | .. container:: | .. container:: |
5599 | .. container:: listingblock | .. container:: listingblock |
5601 | .. container:: content | .. container:: content |
5603 | .. code:: | .. code:: |
5605 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
5606 +---------------------------------------------------------+-----------------------------------------------------------+
5608 .. container:: paragraph
5610 Use the following command line arguments for server and port of
5611 the Websocket server. The port should be the same as configured in
5612 the APEX engine. The server host should be the host on which the
5613 APEX engine is running
5615 .. container:: ulist
5617 - ``-p`` defines the Websocket port to connect to (defaults to
5620 - ``-s`` defines the host on which a Websocket server is running
5621 (defaults to ``localhost``)
5623 .. container:: paragraph
5625 Let’s assume that there is an APEX engine running, configured for
5626 produce Websocket carrier technology, as server, for port 42452,
5627 with produce event protocol JSON,. If we start the console client
5628 on the same host, we can omit the ``-s`` options. We start the
5631 .. container:: listingblock
5633 .. container:: content
5637 # $APEX_HOME/bin/apexApps.sh ws-echo -p 42452 (1)
5638 > %APEX_HOME%\bin\apexApps.bat ws-echo -p 42452 (2)
5640 .. container:: colist arabic
5642 +-------+--------------------------------+
5643 | **1** | Start client on Unix or Cygwin |
5644 +-------+--------------------------------+
5645 | **2** | Start client on Windows |
5646 +-------+--------------------------------+
5648 .. container:: paragraph
5650 Once started successfully, the client will produce the following
5651 messages (assuming we used ``-p 42452`` and an APEX engine is
5652 running on ``localhost`` with the same port:
5654 .. container:: listingblock
5656 .. container:: content
5660 ws-simple-echo: starting simple event echo
5661 --> server: localhost
5664 Once started, the application will simply print out all received events to standard out.
5665 Each received event will be prefixed by '---' and suffixed by '===='
5668 ws-simple-echo: opened connection to APEX (Web Socket Protocol Handshake)
5670 Run the Websocket Console Client
5671 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5673 .. container:: paragraph
5675 The console client is included in an APEX full installation. To
5676 run the client, open a new shell (Unix, Cygwin) or command prompt
5677 (``cmd`` on Windows). Then use the APEX application launcher to
5681 APEX engine needs to run first
5682 The example assumes that an APEX engine configured for *consume* carrier technology Websocket and *JSON* event
5683 protocol is executed first.
5685 +------------------------------------------------------------+--------------------------------------------------------------+
5686 | Unix, Cygwin | Windows |
5687 +============================================================+==============================================================+
5688 | .. container:: | .. container:: |
5690 | .. container:: listingblock | .. container:: listingblock |
5692 | .. container:: content | .. container:: content |
5694 | .. code:: | .. code:: |
5696 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
5697 +------------------------------------------------------------+--------------------------------------------------------------+
5699 .. container:: paragraph
5701 Use the following command line arguments for server and port of
5702 the Websocket server. The port should be the same as configured in
5703 the APEX engine. The server host should be the host on which the
5704 APEX engine is running
5706 .. container:: ulist
5708 - ``-p`` defines the Websocket port to connect to (defaults to
5711 - ``-s`` defines the host on which a Websocket server is running
5712 (defaults to ``localhost``)
5714 .. container:: paragraph
5716 Let’s assume that there is an APEX engine running, configured for
5717 consume Websocket carrier technology, as server, for port 42450,
5718 with consume event protocol JSON,. If we start the console client
5719 on the same host, we can omit the ``-s`` options. We start the
5722 .. container:: listingblock
5724 .. container:: content
5728 # $APEX_HOME/bin/apexApps.sh ws-console -p 42450 (1)
5729 > %APEX_HOME%\bin\apexApps.sh ws-console -p 42450 (2)
5731 .. container:: colist arabic
5733 +-------+--------------------------------+
5734 | **1** | Start client on Unix or Cygwin |
5735 +-------+--------------------------------+
5736 | **2** | Start client on Windows |
5737 +-------+--------------------------------+
5739 .. container:: paragraph
5741 Once started successfully, the client will produce the following
5742 messages (assuming we used ``-p 42450`` and an APEX engine is
5743 running on ``localhost`` with the same port:
5745 .. container:: listingblock
5747 .. container:: content
5751 ws-simple-console: starting simple event console
5752 --> server: localhost
5755 - terminate the application typing 'exit<enter>' or using 'CTRL+C'
5756 - events are created by a non-blank starting line and terminated by a blank line
5759 ws-simple-console: opened connection to APEX (Web Socket Protocol Handshake)
5764 .. container:: paragraph
5766 Now you have the full system up and running:
5768 .. container:: ulist
5770 - Terminal 1: APEX ready and loaded
5772 - Terminal 2: an echo client, printing received messages produced
5775 - Terminal 2: a console client, waiting for input on the console
5776 (standard in) and sending text to APEX
5778 .. container:: paragraph
5780 We started the engine with the VPN policy example. So all the
5781 events we are using now are located in files in the following
5784 .. container:: listingblock
5786 .. container:: content
5791 #: $APEX_HOME/examples/events/VPN
5792 > %APEX_HOME%\examples\events\VPN
5794 .. container:: paragraph
5796 To sends events, simply copy the content of the event files into
5797 Terminal 3 (the console client). It will read multi-line JSON text
5798 and send the events. So copy the content of ``SetupEvents.json`` into
5799 the client. APEX will trigger a policy and produce some output, the
5800 echo client will also print some events created in the policy. In
5801 Terminal 1 (APEX) you’ll see some status messages from the policy as:
5803 .. container:: listingblock
5805 .. container:: content
5810 {Link=L09, LinkUp=true}
5812 outFields: {Link=L09, LinkUp=true}
5813 {Link=L10, LinkUp=true}
5816 outFields: {Link=L10, LinkUp=true}
5817 {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5819 C 300 300 [L09, L10]
5820 outFields: {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5821 {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5824 C 300 300 [L09, L10]
5825 outFields: {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5826 {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5829 C 300 300 [L09, L10]
5830 D 300 400 [L09, L10]
5831 outFields: {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5832 {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5835 B 300 299 [L09, L10]
5836 C 300 300 [L09, L10]
5837 D 300 400 [L09, L10]
5838 outFields: {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5840 .. container:: paragraph
5842 In Terminal 2 (echo-client) you see the received events, the last two
5845 .. container:: listingblock
5847 .. container:: content
5852 ws-simple-echo: received
5853 ---------------------------------
5855 "name": "VPNCustomerCtxtActEvent",
5857 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5860 "CustomerName": "C",
5861 "LinkList": "L09 L10",
5865 =================================
5867 ws-simple-echo: received
5868 ---------------------------------
5870 "name": "VPNCustomerCtxtActEvent",
5872 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5875 "CustomerName": "D",
5876 "LinkList": "L09 L10",
5880 =================================
5882 .. container:: paragraph
5884 Congratulations, you have triggered a policy in APEX using
5885 Websockets, the policy did run through, created events, picked up by
5888 .. container:: paragraph
5890 Now you can send the Link 09 and Link 10 events, they will trigger
5891 the actual VPN policy and some calculations are made. Let’s take the
5892 Link 09 events from ``Link09Events.json``, copy them all into
5893 Terminal 3 (the console). APEX will run the policy (with some status
5894 output), and the echo client will receive and print events.
5896 .. container:: paragraph
5898 To terminate the applications, simply press ``CTRL+C`` in Terminal 1
5899 (APEX). This will also terminate the echo-client in Terminal 2. Then
5900 type ``exit<enter>`` in Terminal 3 (or ``CTRL+C``) to terminate the