1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
17 .. container:: paragraph
19 APEX is 100% written in Java and runs on any platform
20 that supports a JVM, e.g. Windows, Unix, Cygwin. Some
21 APEX applications (such as the monitoring application)
22 come as web archives, they do require a war-capable web
25 Installation Requirements
26 #########################
30 - Downloaded distribution: JAVA runtime environment
31 (JRE, Java 11 or later, APEX is tested with the
34 - Building from source: JAVA development kit (JDK,
35 Java 11 or later, APEX is tested with the OpenJDK
38 - A web archive capable webserver, for instance for
39 the monitoring application
43 - for instance `Apache
44 Tomcat <https://tomcat.apache.org/>`__
46 - Sufficient rights to install APEX on the system
48 - Installation tools depending on the installation
53 - ZIP to extract from a ZIP distribution
57 - Windows for instance
58 `7Zip <http://www.7-zip.org/>`__
60 - TAR and GZ to extract from that TAR.GZ
65 - Windows for instance
66 `7Zip <http://www.7-zip.org/>`__
68 - DPKG to install from the DEB distribution
72 - Install: ``sudo apt-get install dpkg``
77 .. container:: paragraph
79 APEX supports a number of features that require extra
80 software being installed.
84 - `Apache Kafka <https://kafka.apache.org/>`__ to
85 connect APEX to a Kafka message bus
87 - `Hazelcast <https://hazelcast.com/>`__ to use
88 distributed hash maps for context
90 - `Infinispan <http://infinispan.org/>`__ for
91 distributed context and persistence
93 - `Docker <https://www.docker.com/>`__ to run APEX
94 inside a Docker container
96 Build (Install from Source) Requirements
97 ########################################
99 .. container:: paragraph
101 Installation from source requires a few development
106 - GIT to retrieve the source code
108 - Java SDK, Java version 8 or later
110 - Apache Maven 3 (the APEX build environment)
112 Get the APEX Source Code
113 ------------------------
115 .. container:: paragraph
117 The first APEX source code was hosted on Github in
118 January 2018. By the end of 2018, APEX was added as a
119 project in the ONAP Policy Framework, released later in
120 the ONAP Casablanca release.
122 .. container:: paragraph
124 The APEX source code is hosted in ONAP as project APEX.
125 The current stable version is in the master branch.
126 Simply clone the master branch from ONAP using HTTPS.
128 .. container:: listingblock
130 .. container:: content
135 git clone https://gerrit.onap.org/r/policy/apex-pdp
140 .. container:: paragraph
142 The examples in this document assume that the APEX source
143 repositories are cloned to:
147 - Unix, Cygwin: ``/usr/local/src/apex-pdp``
149 - Windows: ``C:\dev\apex-pdp``
151 - Cygwin: ``/cygdrive/c/dev/apex-pdp``
154 A Build requires ONAP Nexus
155 APEX has a dependency to ONAP parent projects. You might need to adjust your Maven M2 settings. The most current
156 settings can be found in the ONAP oparent repo: `Settings <https://git.onap.org/oparent/plain/settings.xml>`__.
160 Building APEX requires approximately 2-3 GB of hard disc space, 1 GB for the actual build with full
161 distribution and 1-2 GB for the downloaded dependencies
164 A Build requires Internet (for first build)
165 During the build, several (a lot) of Maven dependencies will be downloaded and stored in the configured local Maven
166 repository. The first standard build (and any first specific build) requires Internet access to download those
169 .. container:: paragraph
171 Use Maven to for a standard build without any tests.
173 +-------------------------------------------------------+--------------------------------------------------------+
174 | Unix, Cygwin | Windows |
175 +=======================================================+========================================================+
176 | .. container:: | .. container:: |
178 | .. container:: content | .. container:: content |
180 | .. code:: | .. code:: |
181 | :number-lines: | :number-lines: |
183 | # cd /usr/local/src/apex-pdp | >c: |
184 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
185 | | >mvn clean install -Pdocker -DskipTests |
186 +-------------------------------------------------------+--------------------------------------------------------+
188 .. container:: paragraph
190 The build takes 2-3 minutes on a standard development laptop. It
191 should run through without errors, but with a lot of messages from
194 .. container:: paragraph
196 When Maven is finished with the build, the final screen should look
197 similar to this (omitting some ``success`` lines):
199 .. container:: listingblock
201 .. container:: content
206 [INFO] tools .............................................. SUCCESS [ 0.248 s]
207 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
208 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
209 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
210 [INFO] packages ........................................... SUCCESS [ 0.336 s]
211 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
212 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
213 [INFO] ------------------------------------------------------------------------
215 [INFO] ------------------------------------------------------------------------
216 [INFO] Total time: 03:43 min
217 [INFO] Finished at: 2018-09-03T11:56:01+01:00
218 [INFO] ------------------------------------------------------------------------
220 .. container:: paragraph
222 The build will have created all artifacts required for an APEX
223 installation. The following example show how to change to the target
224 directory and how it should look like.
226 +----------------------------------------------------------------------------------------------------------------+
228 +================================================================================================================+
229 | .. container:: content |
231 | .. container:: listingblock |
233 | .. 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 .. container:: imageblock
403 .. container:: content
405 |Extract the TAR archive|
407 .. container:: paragraph
409 The right-click on the new created TAR file and extract the actual
412 .. container:: imageblock
414 .. container:: content
416 |Extract the APEX distribution|
418 .. container:: paragraph
420 Inside the new APEX folder you see the main directories: ``bin``,
421 ``etc``, ``examples``, ``lib``, and ``war``
423 .. container:: paragraph
425 Once extracted, please rename the created folder to
426 ``apex-full-2.0.0-SNAPSHOT``. This will keep the directory name in
427 line with the rest of this documentation.
429 Install Manually from Archive (Windows, 7Zip, CMD)
430 ##################################################
432 .. container:: paragraph
434 You can download a ``tar.gz`` archive from the
435 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
437 Copy the ``tar.gz`` file into the install
438 folder (in this example ``C:\apex``). Start ``cmd``, for instance
439 typing ``Windows+R`` and then ``cmd`` in the dialog. Assuming
440 ``7Zip`` is installed in the standard folder, simply run the
441 following commands (for APEX version 2.0.0-SNAPSHOT full
444 .. container:: listingblock
446 .. container:: content
453 >"\Program Files\7-Zip\7z.exe" x apex-pdp-package-full-2.0.0-SNAPSHOT.tar.gz -so | "\Program Files\7-Zip\7z.exe" x -aoa -si -ttar -o"apex-full-2.0.0-SNAPSHOT"
455 .. container:: paragraph
457 APEX is now installed in the folder
458 ``C:\apex\apex-full-2.0.0-SNAPSHOT``.
463 Build and Install Manually (Unix, Windows, Cygwin)
464 ##################################################
466 .. container:: paragraph
468 Clone the APEX GIT repositories into a directory. Go to that
469 directory. Use Maven to build APEX (all details on building
470 APEX from source can be found in *APEX HowTo: Build*). Install
471 from the created artifacts (``rpm``, ``deb``, ``tar.gz``, or
474 .. container:: paragraph
476 The following example shows how to build the APEX system,
477 without tests (``-DskipTests``) to safe some time. It assumes
478 that the APX GIT repositories are cloned to:
482 - Unix, Cygwin: ``/usr/local/src/apex``
484 - Windows: ``C:\dev\apex``
486 +-------------------------------------------------------+--------------------------------------------------------+
487 | Unix, Cygwin | Windows |
488 +=======================================================+========================================================+
489 | .. container:: | .. container:: |
491 | .. container:: content | .. container:: content |
493 | .. code:: | .. code:: |
494 | :number-lines: | :number-lines: |
496 | # cd /usr/local/src/apex | >c: |
497 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
498 | | >mvn clean install -Pdocker -DskipTests |
499 +-------------------------------------------------------+--------------------------------------------------------+
501 .. container:: paragraph
503 The build takes about 2 minutes without test and about 4-5 minutes
504 with tests on a standard development laptop. It should run through
505 without errors, but with a lot of messages from the build process. If
506 build with tests (i.e. without ``-DskipTests``), there will be error
507 messages and stack trace prints from some tests. This is normal, as
508 long as the build finishes successful.
510 .. container:: paragraph
512 When Maven is finished with the build, the final screen should look
513 similar to this (omitting some ``success`` lines):
515 .. container:: listingblock
517 .. container:: content
522 [INFO] tools .............................................. SUCCESS [ 0.248 s]
523 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
524 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
525 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
526 [INFO] packages ........................................... SUCCESS [ 0.336 s]
527 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
528 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
529 [INFO] ------------------------------------------------------------------------
531 [INFO] ------------------------------------------------------------------------
532 [INFO] Total time: 03:43 min
533 [INFO] Finished at: 2018-09-03T11:56:01+01:00
534 [INFO] ------------------------------------------------------------------------
536 .. container:: paragraph
538 The build will have created all artifacts required for an APEX
539 installation. The following example show how to change to the target
540 directory and how it should look like.
542 +----------------------------------------------------------------------------------------------------------------+
544 +================================================================================================================+
547 | .. container:: listingblock |
552 | # cd packages/apex-pdp-package-full/target |
554 | -rwxrwx---+ 1 esvevan Domain Users 772 Sep 3 11:55 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes* |
555 | -rwxrwx---+ 1 esvevan Domain Users 146328082 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT.deb* |
556 | -rwxrwx---+ 1 esvevan Domain Users 15633 Sep 3 11:54 apex-pdp-package-full-2.0.0-SNAPSHOT.jar* |
557 | -rwxrwx---+ 1 esvevan Domain Users 146296819 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz* |
558 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 archive-tmp/ |
559 | -rwxrwx---+ 1 esvevan Domain Users 89 Sep 3 11:54 checkstyle-cachefile* |
560 | -rwxrwx---+ 1 esvevan Domain Users 10621 Sep 3 11:54 checkstyle-checker.xml* |
561 | -rwxrwx---+ 1 esvevan Domain Users 584 Sep 3 11:54 checkstyle-header.txt* |
562 | -rwxrwx---+ 1 esvevan Domain Users 86 Sep 3 11:54 checkstyle-result.xml* |
563 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 classes/ |
564 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 dependency-maven-plugin-markers/ |
565 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 etc/ |
566 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 examples/ |
567 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:55 install_hierarchy/ |
568 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 maven-archiver/ |
569 +----------------------------------------------------------------------------------------------------------------+
571 +-----------------------------------------------------------------------------------------+
573 +=========================================================================================+
576 | .. container:: listingblock |
581 | >cd packages\apex-pdp-package-full\target |
583 | 03/09/2018 11:55 <DIR> . |
584 | 03/09/2018 11:55 <DIR> .. |
585 | 03/09/2018 11:55 146,296,819 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz |
586 | 03/09/2018 11:55 146,328,082 apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
587 | 03/09/2018 11:54 15,633 apex-pdp-package-full-2.0.0-SNAPSHOT.jar |
588 | 03/09/2018 11:55 772 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes |
589 | 03/09/2018 11:54 <DIR> archive-tmp |
590 | 03/09/2018 11:54 89 checkstyle-cachefile |
591 | 03/09/2018 11:54 10,621 checkstyle-checker.xml |
592 | 03/09/2018 11:54 584 checkstyle-header.txt |
593 | 03/09/2018 11:54 86 checkstyle-result.xml |
594 | 03/09/2018 11:54 <DIR> classes |
595 | 03/09/2018 11:54 <DIR> dependency-maven-plugin-markers |
596 | 03/09/2018 11:54 <DIR> etc |
597 | 03/09/2018 11:54 <DIR> examples |
598 | 03/09/2018 11:55 <DIR> install_hierarchy |
599 | 03/09/2018 11:54 <DIR> maven-archiver |
600 | 8 File(s) 292,652,686 bytes |
601 | 9 Dir(s) 14,138,720,256 bytes free |
602 +-----------------------------------------------------------------------------------------+
604 .. container:: paragraph
606 Now, take the ``.deb`` or the ``.tar.gz`` file and install APEX.
607 Alternatively, copy the content of the folder ``install_hierarchy``
608 to your APEX directory.
613 .. container:: paragraph
615 A full installation of APEX comes with the following layout.
617 .. container:: listingblock
619 .. container:: content
638 │ └───applications (11)
641 .. container:: colist arabic
643 +-----------------------------------+-----------------------------------+
644 | **1** | binaries, mainly scripts (bash |
645 | | and bat) to start the APEX engine |
646 | | and applications |
647 +-----------------------------------+-----------------------------------+
648 | **2** | configuration files, such as |
649 | | logback (logging) and third party |
650 | | library configurations |
651 +-----------------------------------+-----------------------------------+
652 | **3** | example policy models to get |
654 +-----------------------------------+-----------------------------------+
655 | **4** | configurations for the examples |
656 | | (with sub directories for |
657 | | individual examples) |
658 +-----------------------------------+-----------------------------------+
659 | **5** | Docker files and additional |
660 | | Docker instructions for the |
662 +-----------------------------------+-----------------------------------+
663 | **6** | example events for the examples |
664 | | (with sub directories for |
665 | | individual examples) |
666 +-----------------------------------+-----------------------------------+
667 | **7** | HTML files for some examples, |
668 | | e.g. the Decisionmaker example |
669 +-----------------------------------+-----------------------------------+
670 | **8** | the policy models, generated for |
671 | | each example (with sub |
672 | | directories for individual |
674 +-----------------------------------+-----------------------------------+
675 | **9** | additional scripts for the |
676 | | examples (with sub directories |
677 | | for individual examples) |
678 +-----------------------------------+-----------------------------------+
679 | **10** | the library folder with all Java |
681 +-----------------------------------+-----------------------------------+
682 | **11** | applications, also known as jar |
683 | | with dependencies (or fat jars), |
684 | | individually deployable |
685 +-----------------------------------+-----------------------------------+
686 | **12** | WAR files for web applications |
687 +-----------------------------------+-----------------------------------+
692 .. container:: paragraph
694 Once APEX is installed, a few configurations need to be done:
698 - Create an APEX user and an APEX group (optional, if not
699 installed using RPM and DPKG)
701 - Create environment settings for ``APEX_HOME`` and
702 ``APEX_USER``, required by the start scripts
704 - Change settings of the logging framework (optional)
706 - Create directories for logging, required (execution might fail
707 if directories do not exist or cannot be created)
712 .. container:: paragraph
714 On smaller installations and test systems, APEX can run as any
717 .. container:: paragraph
719 However, if APEX is installed in production, we strongly
720 recommend you set up a dedicated user for running APEX. This
721 will isolate the execution of APEX to that user. We recommend
722 you use the userid ``apexuser`` but you may use any user you
725 .. container:: paragraph
727 The following example, for UNIX, creates a group called
728 ``apexuser``, an APEX user called ``apexuser``, adds the group
729 to the user, and changes ownership of the APEX installation to
730 the user. Substitute ``<apex-dir>`` with the directory where
733 .. container:: listingblock
735 .. container:: content
740 # sudo groupadd apexuser
741 # sudo useradd -g apexuser apexuser
742 # sudo chown -R apexuser:apexuser <apex-dir>
744 .. container:: paragraph
746 For other operating systems please consult your manual or system
749 Environment Settings: APEX_HOME and APEX_USER
750 #############################################
752 .. container:: paragraph
754 The provided start scripts for APEX require two environment
759 - ``APEX_USER`` with the user under whos name and permission APEX
760 should be started (Unix only)
762 - ``APEX_HOME`` with the directory where APEX is installed (Unix,
765 .. container:: paragraph
767 The first row in the following table shows how to set these
768 environment variables temporary (assuming the user is
769 ``apexuser``). The second row shows how to verify the settings.
770 The last row explains how to set those variables permanently.
772 +------------------------------------------------+---------------------------------------------------------+
773 | Unix, Cygwin (bash/tcsh) | Windows |
774 +================================================+=========================================================+
775 | .. container:: | .. container:: |
777 | .. container:: content | .. container:: content |
779 | .. code:: | .. code:: |
780 | :number-lines: | :number-lines: |
782 | # export APEX_USER=apexuser | >set APEX_HOME=C:\apex\apex-full-2.0.0-SNAPSHOT |
783 | # cd /opt/app/policy/apex-pdp | |
784 | # export APEX_HOME=`pwd` | |
786 +------------------------------------------------+ |
789 | .. container:: content | |
794 | # setenv APEX_USER apexuser | |
795 | # cd /opt/app/policy/apex-pdp | |
796 | # setenv APEX_HOME `pwd` | |
798 +------------------------------------------------+---------------------------------------------------------+
799 | .. container:: | .. container:: |
801 | .. container:: content | .. container:: content |
803 | .. code:: | .. code:: |
804 | :number-lines: | :number-lines: |
806 | # env | grep APEX | >set APEX_HOME |
807 | # APEX_USER=apexuser | APEX_HOME=\apex\apex-full-2.0.0-SNAPSHOT |
808 | # APEX_HOME=/opt/app/policy/apex-pdp | |
810 +------------------------------------------------+---------------------------------------------------------+
812 Making Environment Settings Permanent (Unix, Cygwin)
813 ====================================================
815 .. container:: paragraph
817 For a per-user setting, edit the a user’s ``bash`` or ``tcsh``
818 settings in ``~/.bashrc`` or ``~/.tcshrc``. For system-wide
819 settings, edit ``/etc/profiles`` (requires permissions).
821 Making Environment Settings Permanent (Windows)
822 ===============================================
824 .. container:: paragraph
830 - Click on the **Start** Menu
832 - Right click on **Computer**
834 - Select **Properties**
836 .. container:: paragraph
842 - Click on the **Start** Menu
846 .. container:: paragraph
848 Then do the following
852 - Select **Advanced System Settings**
854 - On the **Advanced** tab, click the **Environment Variables**
857 - Edit an existing variable, or create a new System variable:
858 'Variable name'="APEX_HOME", 'Variable
859 value'="C:\apex\apex-full-2.0.0-SNAPSHOT"
861 .. container:: paragraph
863 For the settings to take effect, an application needs to be
864 restarted (e.g. any open ``cmd`` window).
866 Edit the APEX Logging Settings
867 ##############################
869 .. container:: paragraph
871 Configure the APEX logging settings to your requirements, for
876 - change the directory where logs are written to, or
878 - change the log levels
880 .. container:: paragraph
882 Edit the file ``$APEX_HOME/etc/logback.xml`` for any required
883 changes. To change the log directory change the line
885 .. container:: paragraph
887 ``<property name="logDir" value="/var/log/onap/policy/apex-pdp/" />``
889 .. container:: paragraph
893 .. container:: paragraph
895 ``<property name="logDir" value="/PATH/TO/LOG/DIRECTORY/" />``
897 .. container:: paragraph
899 On Windows, it is recommended to change the log directory to:
901 .. container:: paragraph
903 ``<property name="logDir" value="C:/apex/apex-full-2.0.0-SNAPSHOT/logs" />``
905 .. container:: paragraph
907 Note: Be careful about when to use ``\`` vs. ``/`` as the path
910 Create Directories for Logging
911 ##############################
913 .. container:: paragraph
915 Make sure that the log directory exists. This is important when
916 APEX was installed manually or when the log directory was changed
917 in the settings (see above).
919 +-----------------------------------------------------------------------+-------------------------------------------------------+
920 | Unix, Cygwin | Windows |
921 +=======================================================================+=======================================================+
922 | .. container:: | .. container:: |
924 | .. container:: content | .. container:: content |
926 | .. code:: | .. code:: |
927 | :number-lines: | :number-lines: |
929 | sudo mkdir -p /var/log/onap/policy/apex-pdp | >mkdir C:\apex\apex-full-2.0.0-SNAPSHOT\logs |
930 | sudo chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp | |
931 +-----------------------------------------------------------------------+-------------------------------------------------------+
933 Verify the APEX Installation
934 ----------------------------
936 .. container:: paragraph
938 When APEX is installed and all settings are realized, the
939 installation can be verified.
941 Verify Installation - run Engine
942 ################################
944 .. container:: paragraph
946 A simple verification of an APEX installation can be done by
947 simply starting the APEX engine without specifying a tosca policy. On
948 Unix (or Cygwin) start the engine using
949 ``$APEX_HOME/bin/apexApps.sh engine``. On Windows start the engine
950 using ``%APEX_HOME%\bin\apexApps.bat engine``. The engine will fail
951 to fully start. However, if the output looks similar to the
952 following line, the APEX installation is realized.
954 .. container:: listingblock
956 .. container:: content
961 Starting Apex service with parameters [] . . .
962 start of Apex service failed.
963 org.onap.policy.apex.model.basicmodel.concepts.ApexException: Arguments validation failed.
964 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:238)
965 at org.onap.policy.apex.service.engine.main.ApexMain.<init>(ApexMain.java:86)
966 at org.onap.policy.apex.service.engine.main.ApexMain.main(ApexMain.java:351)
967 Caused by: org.onap.policy.apex.model.basicmodel.concepts.ApexException: Tosca Policy file was not specified as an argument
968 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validateReadableFile(ApexCommandLineArguments.java:242)
969 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validate(ApexCommandLineArguments.java:172)
970 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:235)
971 ... 2 common frames omitted
973 Verify Installation - run an Example
974 ####################################
976 .. container:: paragraph
978 A full APEX installation comes with several examples. Here, we can
979 fully verify the installation by running one of the examples.
981 .. container:: paragraph
983 We use the example called *SampleDomain* and configure the engine
984 to use standard in and standard out for events. Run the engine
985 with the provided configuration. Note: Cygwin executes scripts as
986 Unix scripts but runs Java as a Windows application, thus the
987 configuration file must be given as a Windows path.
989 .. container:: paragraph
991 On Unix/Linux flavoured platforms, give the commands below:
993 .. container:: listingblock
995 .. container:: content
1001 export APEX_HOME <path to apex installation>
1002 export APEX_USER apexuser
1004 .. container:: paragraph
1006 Create a Tosca Policy for the SampleDomain example using ApexCliToscaEditor
1007 as explained in the section "The APEX CLI Tosca Editor". Assume the tosca policy name is SampleDomain_tosca.json.
1008 You can then try to run apex using the ToscaPolicy.
1010 .. container:: listingblock
1012 .. container:: content
1017 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/examples/SampleDomain_tosca.json (1)
1018 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\examples\SampleDomain_tosca.json(2)
1020 .. container:: colist arabic
1028 .. container:: paragraph
1030 The engine should start successfully. Assuming the logging levels are set to ``info`` in the built system, the output
1031 should look similar to this (last few lines)
1033 .. container:: listingblock
1035 .. container:: content
1040 Starting Apex service with parameters [-p, /home/ubuntu/apex/SampleDomain_tosca.json] . . .
1041 2018-09-05 15:16:42,800 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-0:0.0.1 .
1042 2018-09-05 15:16:42,804 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-1:0.0.1 .
1043 2018-09-05 15:16:42,804 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-2:0.0.1 .
1044 2018-09-05 15:16:42,805 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-3:0.0.1 .
1045 2018-09-05 15:16:42,805 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - APEX service created.
1046 2018-09-05 15:16:43,962 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging starting . . .
1047 2018-09-05 15:16:43,963 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging started
1048 2018-09-05 15:16:44,987 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-0:0.0.1
1049 2018-09-05 15:16:45,112 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-1:0.0.1
1050 2018-09-05 15:16:45,113 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-2:0.0.1
1051 2018-09-05 15:16:45,113 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-3:0.0.1
1052 2018-09-05 15:16:45,120 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Added the action listener to the engine
1053 Started Apex service
1055 .. container:: paragraph
1057 Important are the last two line, stating that APEX has added the
1058 final action listener to the engine and that the engine is started.
1060 .. container:: paragraph
1062 The engine is configured to read events from standard input and write
1063 produced events to standard output. The policy model is a very simple
1066 .. container:: paragraph
1068 The following table shows an input event in the left column and an
1069 output event in the right column. Past the input event into the
1070 console where APEX is running, and the output event should appear in
1071 the console. Pasting the input event multiple times will produce
1072 output events with different values.
1074 +----------------------------------------------------+----------------------------------------------------+
1075 | Input Event | Example Output Event |
1076 +====================================================+====================================================+
1077 | .. container:: | .. container:: |
1079 | .. container:: content | .. container:: content |
1081 | .. code:: | .. code:: |
1082 | :number-lines: | :number-lines: |
1085 | "nameSpace": "org.onap.policy.apex.sample.events", | "name": "Event0004", |
1086 | "name": "Event0000", | "version": "0.0.1", |
1087 | "version": "0.0.1", | "nameSpace": "org.onap.policy.apex.sample.events", |
1088 | "source": "test", | "source": "Act", |
1089 | "target": "apex", | "target": "Outside", |
1090 | "TestSlogan": "Test slogan for External Event0", | "TestActCaseSelected": 2, |
1091 | "TestMatchCase": 0, | "TestActStateTime": 1536157104627, |
1092 | "TestTimestamp": 1469781869269, | "TestDecideCaseSelected": 0, |
1093 | "TestTemperature": 9080.866 | "TestDecideStateTime": 1536157104625, |
1094 | } | "TestEstablishCaseSelected": 0, |
1095 | | "TestEstablishStateTime": 1536157104623, |
1096 | | "TestMatchCase": 0, |
1097 | | "TestMatchCaseSelected": 1, |
1098 | | "TestMatchStateTime": 1536157104620, |
1099 | | "TestSlogan": "Test slogan for External Event0", |
1100 | | "TestTemperature": 9080.866, |
1101 | | "TestTimestamp": 1469781869269 |
1103 +----------------------------------------------------+----------------------------------------------------+
1105 .. container:: paragraph
1107 Terminate APEX by simply using ``CTRL+C`` in the console.
1109 Verify a Full Installation - REST Client
1110 ########################################
1112 .. container:: paragraph
1114 APEX has a REST application for deploying, monitoring, and viewing policy models. The
1115 application can also be used to create new policy models close to
1116 the engine native policy language. Start the REST client as
1119 .. container:: listingblock
1121 .. container:: content
1126 # $APEX_HOME/bin/apexApps.sh full-client
1128 .. container:: listingblock
1130 .. container:: content
1135 >%APEX_HOME%\bin\apexApps.bat full-client
1137 .. container:: paragraph
1139 The script will start a simple web server
1140 (`Grizzly <https://javaee.github.io/grizzly/>`__) and deploy a
1141 ``war`` web archive in it. Once the client is started, it will be
1142 available on ``localhost:18989``. The last few line of the messages
1145 .. container:: listingblock
1147 .. container:: content
1152 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
1153 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.NetworkListener start
1154 INFO: Started listener bound to [localhost:18989]
1155 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.HttpServer start
1156 INFO: [HttpServer] Started.
1157 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
1160 .. container:: paragraph
1162 Now open a browser (Firefox, Chrome, Opera, Internet Explorer) and
1163 use the URL ``http://localhost:18989/``. This will connect the
1164 browser to the started REST client. Click on the "Policy Editor" button and the Policy Editor start screen should be as
1167 .. container:: imageblock
1169 .. container:: content
1171 |Policy Editor Start Screen|
1173 .. container:: title
1175 Figure 1. Policy Editor Start Screen
1177 .. container:: paragraph
1179 Now load a policy model by clicking the menu ``File`` and then
1180 ``Open``. In the opened dialog, go to the directory where APEX is
1181 installed, then ``examples``, ``models``, ``SampleDomain``, and there
1182 select the file ``SamplePolicyModelJAVA.json``. This will load the
1183 policy model used to verify the policy engine (see above). Once
1184 loaded, the screen should look as follows.
1186 .. container:: imageblock
1188 .. container:: content
1190 |Policy Editor with loaded SampleDomain Policy Model|
1192 .. container:: title
1194 Figure 2. Policy Editor with loaded SampleDomain Policy Model
1196 .. container:: paragraph
1198 Now you can use the Policy editor. To finish this verification, simply
1199 terminate your browser (or the tab), and then use ``CTRL+C`` in the
1200 console where you started the Policy editor.
1202 Installing the WAR Application
1203 ------------------------------
1205 .. container:: paragraph
1207 The three APEX clients are packaged in a WAR file. This is a complete
1208 application that can be installed and run in an application
1209 server. The application is realized as a servlet. You
1210 can find the WAR application in the `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/client/apex-client-full/>`__.
1213 .. container:: paragraph
1215 Installing and using the WAR application requires a web server
1216 that can execute ``war`` web archives. We recommend to use `Apache
1217 Tomcat <https://tomcat.apache.org/>`__, however other web servers
1218 can be used as well.
1220 .. container:: paragraph
1222 Install Apache Tomcat including the ``Manager App``, see `V9.0
1223 Docs <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html#Configuring_Manager_Application_Access>`__
1224 for details. Start the Tomcat service, or make sure that Tomcat is
1227 .. container:: paragraph
1229 There are multiple ways to install the APEX WAR application:
1231 .. container:: ulist
1233 - copy the ``.war`` file into the Tomcat ``webapps`` folder
1235 - use the Tomcat ``Manager App`` to deploy via the web interface
1237 - deploy using a REST call to Tomcat
1239 .. container:: paragraph
1241 For details on how to install ``war`` files please consult the
1243 Documentation <https://tomcat.apache.org/tomcat-9.0-doc/index.html>`__
1245 HOW-TO <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html>`__.
1246 Once you installed an APEX WAR application (and wait for
1247 sufficient time for Tomcat to finalize the installation), open the
1248 ``Manager App`` in Tomcat. You should see the APEX WAR application
1249 being installed and running.
1251 .. container:: paragraph
1253 In case of errors, examine the log files in the Tomcat log
1254 directory. In a conventional install, those log files are in the
1255 logs directory where Tomcat is installed.
1257 .. container:: paragraph
1259 The WAR application file has a name similar to *apex-client-full-<VERSION>.war*.
1261 Running APEX in Docker
1262 ----------------------
1264 .. container:: paragraph
1266 Since APEX is in ONAP, we provide a full virtualization
1267 environment for the engine.
1272 .. container:: paragraph
1274 Running APEX from the ONAP docker repository only requires 2
1277 .. container:: olist arabic
1279 #. Log into the ONAP docker repo
1281 .. container:: listingblock
1283 .. container:: content
1287 docker login -u docker -p docker nexus3.onap.org:10003
1289 .. container:: olist arabic
1291 #. Run the APEX docker image
1293 .. container:: listingblock
1295 .. container:: content
1299 docker run -it --rm nexus3.onap.org:10003/onap/policy-apex-pdp:latest
1301 Build a Docker Image
1302 ####################
1304 .. container:: paragraph
1306 Alternatively, one can use the Dockerfile defined in the Docker
1307 package to build an image.
1309 .. container:: listingblock
1311 .. container:: title
1315 .. container:: content
1321 # Docker file to build an image that runs APEX on Java 8 in Ubuntu
1325 RUN apt-get update && \
1326 apt-get upgrade -y && \
1327 apt-get install -y software-properties-common && \
1328 add-apt-repository ppa:openjdk-r/ppa -y && \
1330 apt-get install -y openjdk-8-jdk
1332 # Create apex user and group
1333 RUN groupadd apexuser
1334 RUN useradd --create-home -g apexuser apexuser
1336 # Add Apex-specific directories and set ownership as the Apex admin user
1337 RUN mkdir -p /opt/app/policy/apex-pdp
1338 RUN mkdir -p /var/log/onap/policy/apex-pdp
1339 RUN chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp
1341 # Unpack the tarball
1343 COPY apex-pdp-package-full.tar.gz /packages
1344 RUN tar xvfz /packages/apex-pdp-package-full.tar.gz --directory /opt/app/policy/apex-pdp
1345 RUN rm /packages/apex-pdp-package-full.tar.gz
1347 # Ensure everything has the correct permissions
1348 RUN find /opt/app -type d -perm 755
1349 RUN find /opt/app -type f -perm 644
1350 RUN chmod a+x /opt/app/policy/apex-pdp/bin/*
1352 # Copy examples to Apex user area
1353 RUN cp -pr /opt/app/policy/apex-pdp/examples /home/apexuser
1357 RUN chown -R apexuser:apexuser /home/apexuser/*
1360 ENV PATH /opt/app/policy/apex-pdp/bin:$PATH
1361 WORKDIR /home/apexuser
1363 Running APEX in Standalone mode
1364 -------------------------------
1366 .. container:: paragraph
1368 APEX Engine can run in standalone mode by taking in a ToscaPolicy
1369 as an argument and executing it.
1370 Assume there is a tosca policy named ToscaPolicy.json in APEX_HOME directory
1371 This policy can be executed in standalone mode using any of the below methods.
1373 Run in an APEX installation
1374 ###########################
1376 .. container:: listingblock
1378 .. container:: content
1383 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/ToscaPolicy.json(1)
1384 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\ToscaPolicy.json(2)
1386 .. container:: colist arabic
1394 Run in a docker container
1395 #########################
1397 .. container:: listingblock
1399 .. container:: content
1404 # docker run -p 6969:6969 -v $APEX_HOME/ToscaPolicy.json:/tmp/policy/ToscaPolicy.json \
1405 --name apex -it nexus3.onap.org:10001/onap/policy-apex-pdp:latest \
1406 -c "/opt/app/policy/apex-pdp/bin/apexEngine.sh -p /tmp/policy/ToscaPolicy.json"
1408 APEX Configurations Explained
1409 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1411 Introduction to APEX Configuration
1412 ----------------------------------
1414 .. container:: paragraph
1416 An APEX engine can be configured to use various combinations
1417 of event input handlers, event output handlers, event
1418 protocols, context handlers, and logic executors. The system
1419 is build using a plugin architecture. Each configuration
1420 option is realized by a plugin, which can be loaded and
1421 configured when the engine is started. New plugins can be
1422 added to the system at any time, though to benefit from a
1423 new plugin an engine will need to be restarted.
1425 .. container:: imageblock
1427 .. container:: content
1429 |APEX Configuration Matrix|
1431 .. container:: title
1433 Figure 3. APEX Configuration Matrix
1435 .. container:: paragraph
1437 The APEX distribution already comes with a number of
1438 plugins. The figure above shows the provided plugins. Any
1439 combination of input, output, event protocol, context
1440 handlers, and executors is possible.
1442 General Configuration Format
1443 ----------------------------
1445 .. container:: paragraph
1447 The APEX configuration file is a JSON file containing a few
1448 main blocks for different parts of the configuration. Each
1449 block then holds the configuration details. The following
1450 code shows the main blocks:
1452 .. container:: listingblock
1454 .. container:: content
1459 "engineServiceParameters":{
1461 "engineParameters":{ (2)
1462 "executorParameters":{...}, (3)
1463 "contextParameters":{...} (4)
1464 "taskParameters":[...] (5)
1467 "eventInputParameters":{ (6)
1469 "carrierTechnologyParameters":{...},
1470 "eventProtocolParameters":{...}
1473 "carrierTechnologyParameters":{...},
1474 "eventProtocolParameters":{...}
1478 "eventOutputParameters":{ (10)
1480 "carrierTechnologyParameters":{...},
1481 "eventProtocolParameters":{...}
1484 "carrierTechnologyParameters":{...},
1485 "eventProtocolParameters":{...}
1491 .. container:: colist arabic
1493 +-----------------------------------+-----------------------------------+
1494 | **1** | main engine configuration |
1495 +-----------------------------------+-----------------------------------+
1496 | **2** | engine parameters for plugin |
1497 | | configurations (execution |
1498 | | environments and context |
1500 +-----------------------------------+-----------------------------------+
1501 | **3** | engine specific parameters, |
1502 | | mainly for executor plugins |
1503 +-----------------------------------+-----------------------------------+
1504 | **4** | context specific parameters, e.g. |
1505 | | for context schemas, persistence, |
1507 +-----------------------------------+-----------------------------------+
1508 | **5** | list of task parameters that |
1509 | | should be made available in task |
1510 | | logic (optional). |
1511 +-----------------------------------+-----------------------------------+
1512 | **6** | configuration of the input |
1514 +-----------------------------------+-----------------------------------+
1515 | **7** | an example input called |
1516 | | ``input1`` with carrier |
1517 | | technology and event protocol |
1518 +-----------------------------------+-----------------------------------+
1519 | **8** | an example input called |
1520 | | ``input2`` with carrier |
1521 | | technology and event protocol |
1522 +-----------------------------------+-----------------------------------+
1523 | **9** | any further input configuration |
1524 +-----------------------------------+-----------------------------------+
1525 | **10** | configuration of the output |
1527 +-----------------------------------+-----------------------------------+
1528 | **11** | an example output called |
1529 | | ``output1`` with carrier |
1530 | | technology and event protocol |
1531 +-----------------------------------+-----------------------------------+
1532 | **12** | an example output called |
1533 | | ``output2`` with carrier |
1534 | | technology and event protocol |
1535 +-----------------------------------+-----------------------------------+
1536 | **13** | any further output configuration |
1537 +-----------------------------------+-----------------------------------+
1539 Engine Service Parameters
1540 -------------------------
1542 .. container:: paragraph
1544 The configuration provides a number of parameters to
1545 configure the engine. An example configuration with
1546 explanations of all options is shown below.
1548 .. container:: listingblock
1550 .. container:: content
1554 "engineServiceParameters" : {
1555 "name" : "AADMApexEngine", (1)
1556 "version" : "0.0.1", (2)
1558 "instanceCount" : 4, (4)
1559 "deploymentPort" : 12345, (5)
1560 "policy_type_impl" : {...}, (6)
1561 "periodicEventPeriod": 1000, (7)
1562 "engineParameters":{ (8)
1563 "executorParameters":{...}, (9)
1564 "contextParameters":{...}, (10)
1565 "taskParameters":[...] (11)
1569 .. container:: colist arabic
1571 +-----------------------------------+-----------------------------------+
1572 | **1** | a name for the engine. The engine |
1573 | | name is used to create a key in a |
1574 | | runtime engine. An name matching |
1575 | | the following regular expression |
1576 | | can be used here: |
1577 | | ``[A-Za-z0-9\\-_\\.]+`` |
1578 +-----------------------------------+-----------------------------------+
1579 | **2** | a version of the engine, use |
1580 | | semantic versioning as explained |
1581 | | here: `Semantic |
1582 | | Versioning <http://semver.org/>`_ |
1584 | | This version is used in a runtime |
1585 | | engine to create a version of the |
1586 | | engine. For that reason, the |
1587 | | version must match the following |
1588 | | regular expression ``[A-Z0-9.]+`` |
1589 +-----------------------------------+-----------------------------------+
1590 | **3** | a numeric identifier for the |
1592 +-----------------------------------+-----------------------------------+
1593 | **4** | the number of threads (policy |
1594 | | instances executed in parallel) |
1595 | | the engine should use, use ``1`` |
1596 | | for single threaded engines |
1597 +-----------------------------------+-----------------------------------+
1598 | **5** | the port for the deployment |
1599 | | Websocket connection to the |
1601 +-----------------------------------+-----------------------------------+
1602 | **6** | the APEX policy model as a JSON |
1603 | | or YAML block to load into the |
1604 | | engine on startup when |
1605 | | APEX is running a policy that has |
1606 | | its logic and parameters |
1607 | | specified in TOSCA |
1609 +-----------------------------------+-----------------------------------+
1610 | **7** | an optional timer for periodic |
1611 | | policies, in milliseconds (a |
1612 | | defined periodic policy will be |
1613 | | executed every ``X`` |
1614 | | milliseconds), not used of not |
1616 +-----------------------------------+-----------------------------------+
1617 | **8** | engine parameters for plugin |
1618 | | configurations (execution |
1619 | | environments and context |
1621 +-----------------------------------+-----------------------------------+
1622 | **9** | engine specific parameters, |
1623 | | mainly for executor plugins |
1624 +-----------------------------------+-----------------------------------+
1625 | **10** | context specific parameters, e.g. |
1626 | | for context schemas, persistence, |
1628 +-----------------------------------+-----------------------------------+
1629 | **11** | list of task parameters that |
1630 | | should be made available in task |
1631 | | logic (optional). |
1632 +-----------------------------------+-----------------------------------+
1634 .. container:: paragraph
1636 The model file is optional, it can also be specified via
1637 command line. In any case, make sure all execution and other
1638 required plug-ins for the loaded model are loaded as
1641 Input and Output Interfaces
1642 ---------------------------
1644 .. container:: paragraph
1646 An APEX engine has two main interfaces:
1648 .. container:: ulist
1650 - An *input* interface to receive events: also known as
1651 ingress interface or consumer, receiving (consuming)
1652 events commonly named triggers, and
1654 - An *output* interface to publish produced events: also
1655 known as egress interface or producer, sending
1656 (publishing) events commonly named actions or action
1659 .. container:: paragraph
1661 The input and output interface is configured in terms of
1662 inputs and outputs, respectively. Each input and output is a
1663 combination of a carrier technology and an event protocol.
1664 Carrier technologies and event protocols are provided by
1665 plugins, each with its own specific configuration. Most
1666 carrier technologies can be configured for input as well as
1667 output. Most event protocols can be used for all carrier
1668 technologies. One exception is the JMS object event
1669 protocol, which can only be used for the JMS carrier
1670 technology. Some further restrictions apply (for instance
1671 for carrier technologies using bi- or uni-directional
1674 .. container:: paragraph
1676 Input and output interface can be configured separately, in
1677 isolation, with any number of carrier technologies. The
1678 resulting general configuration options are:
1680 .. container:: ulist
1682 - Input interface with one or more inputs
1684 .. container:: ulist
1686 - each input with a carrier technology and an event
1689 - some inputs with optional synchronous mode
1691 - some event protocols with additional parameters
1693 - Output interface with one or more outputs
1695 .. container:: ulist
1697 - each output with a carrier technology and an event
1700 - some outputs with optional synchronous mode
1702 - some event protocols with additional parameters
1704 .. container:: paragraph
1706 The configuration for input and output is contained in
1707 ``eventInputParameters`` and ``eventOutputParameters``,
1708 respectively. Inside here, one can configure any number of
1709 inputs and outputs. Each of them needs to have a unique
1710 identifier (name), the content of the name is free form. The
1711 example below shows a configuration for two inputs and two
1714 .. container:: listingblock
1716 .. container:: content
1720 "eventInputParameters": { (1)
1721 "FirstConsumer": { (2)
1722 "carrierTechnologyParameters" : {...}, (3)
1723 "eventProtocolParameters":{...}, (4)
1726 "SecondConsumer": { (6)
1727 "carrierTechnologyParameters" : {...}, (7)
1728 "eventProtocolParameters":{...}, (8)
1732 "eventOutputParameters": { (10)
1733 "FirstProducer": { (11)
1734 "carrierTechnologyParameters":{...}, (12)
1735 "eventProtocolParameters":{...}, (13)
1738 "SecondProducer": { (15)
1739 "carrierTechnologyParameters":{...}, (16)
1740 "eventProtocolParameters":{...}, (17)
1745 .. container:: colist arabic
1747 +--------+--------------------------------------------------------------------+
1748 | **1** | input interface configuration, APEX input plugins |
1749 +--------+--------------------------------------------------------------------+
1750 | **2** | first input called ``FirstConsumer`` |
1751 +--------+--------------------------------------------------------------------+
1752 | **3** | carrier technology for plugin |
1753 +--------+--------------------------------------------------------------------+
1754 | **4** | event protocol for plugin |
1755 +--------+--------------------------------------------------------------------+
1756 | **5** | any other input configuration (e.g. event name filter, see below) |
1757 +--------+--------------------------------------------------------------------+
1758 | **6** | second input called ``SecondConsumer`` |
1759 +--------+--------------------------------------------------------------------+
1760 | **7** | carrier technology for plugin |
1761 +--------+--------------------------------------------------------------------+
1762 | **8** | event protocol for plugin |
1763 +--------+--------------------------------------------------------------------+
1764 | **9** | any other plugin configuration |
1765 +--------+--------------------------------------------------------------------+
1766 | **10** | output interface configuration, APEX output plugins |
1767 +--------+--------------------------------------------------------------------+
1768 | **11** | first output called ``FirstProducer`` |
1769 +--------+--------------------------------------------------------------------+
1770 | **12** | carrier technology for plugin |
1771 +--------+--------------------------------------------------------------------+
1772 | **13** | event protocol for plugin |
1773 +--------+--------------------------------------------------------------------+
1774 | **14** | any other plugin configuration |
1775 +--------+--------------------------------------------------------------------+
1776 | **15** | second output called ``SecondProducer`` |
1777 +--------+--------------------------------------------------------------------+
1778 | **16** | carrier technology for plugin |
1779 +--------+--------------------------------------------------------------------+
1780 | **17** | event protocol for plugin |
1781 +--------+--------------------------------------------------------------------+
1782 | **18** | any other output configuration (e.g. event name filter, see below) |
1783 +--------+--------------------------------------------------------------------+
1788 .. container:: paragraph
1790 Any event defined in APEX has to be unique. The "name" of
1791 of an event is used as an identifier for an ApexEvent. Every
1792 event has to be tagged to an eventName. This can be done in different
1793 ways. Either the actual event can have a field called "name". Or, the
1794 event has some other field that can act as the identifier, which can be
1795 specified using "nameAlias". But in other cases, where a "name" or "nameAlias"
1796 cannot be specified, the incoming event coming over an endpoint can be
1797 manually tagged to an "eventName" before consuming it.
1799 .. container:: paragraph
1801 The "eventName" can have a single event's name if the event coming
1802 over the endpoint has to be always mapped to the specified eventName's
1803 definition. Otherwise, if different events can come over the endpoint,
1804 then "eventName" field can consist of multiple event names separated by
1805 "|" symbol. In this case, based on the received event's structure, it is
1806 mapped to any one of the event name specified in the "eventName" field.
1808 .. container:: paragraph
1810 The following code shows some examples on how to specify the eventName field:
1812 .. container:: listingblock
1814 .. container:: content
1818 "eventInputParameters": {
1820 "carrierTechnologyParameters" : {...},
1821 "eventProtocolParameters":{...},
1822 "eventName" : "VesEvent" (1)
1825 "carrierTechnologyParameters" : {...},
1826 "eventProtocolParameters":{...},
1827 "eventName" : "AAISuccessResponseEvent|AAIFailureResponseEvent" (2)
1834 .. container:: paragraph
1836 APEX will always send an event after a policy execution
1837 is finished. For a successful execution, the event sent
1838 is the output event created by the policy. In case the
1839 policy does not create an output event, APEX will create
1840 a new event with all input event fields plus an
1841 additional field ``exceptionMessage`` with an exception
1844 .. container:: paragraph
1846 There are situations in which this auto-generated error
1847 event might not be required or wanted:
1849 .. container:: ulist
1851 - when a policy failing should not result in an event
1852 send out via an output interface
1854 - when the auto-generated event goes back in an APEX
1855 engine (or the same APEX engine), this can create
1858 - the auto-generated event should go to a special output
1859 interface or channel
1861 .. container:: paragraph
1863 All of these situations are supported by a filter option
1864 using a wildecard (regular expression) configuration on
1865 APEX I/O interfaces. The parameter is called
1866 ``eventNameFilter`` and the value are `Java regular
1867 expressions <https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html>`__
1869 `tutorial <http://www.vogella.com/tutorials/JavaRegularExpressions/article.html>`__).
1870 The following code shows some examples:
1872 .. container:: listingblock
1874 .. container:: content
1878 "eventInputParameters": {
1880 "carrierTechnologyParameters" : {...},
1881 "eventProtocolParameters":{...},
1882 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]004$" (1)
1885 "eventOutputParameters": {
1887 "carrierTechnologyParameters":{...},
1888 "eventProtocolParameters":{...},
1889 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]104$" (2)
1896 .. container:: paragraph
1898 Executors are plugins that realize the execution of logic
1899 contained in a policy model. Logic can be in a task
1900 selector, a task, and a state finalizer. Using plugins for
1901 execution environments makes APEX very flexible to support
1902 virtually any executable logic expressions.
1904 .. container:: paragraph
1906 APEX 2.0.0-SNAPSHOT supports the following executors:
1908 .. container:: ulist
1910 - Java, for Java implemented logic
1912 .. container:: ulist
1914 - This executor requires logic implemented using the
1915 APEX Java interfaces.
1917 - Generated JAR files must be in the classpath of the
1918 APEX engine at start time.
1928 .. container:: ulist
1930 - This executor uses the latest version of the MVEL
1931 engine, which can be very hard to debug and can
1932 produce unwanted side effects during execution
1934 Configure the Javascript Executor
1935 #################################
1937 .. container:: paragraph
1939 The Javascript executor is added to the configuration as
1942 .. container:: listingblock
1944 .. container:: content
1948 "engineServiceParameters":{
1949 "engineParameters":{
1950 "executorParameters":{
1952 "parameterClassName" :
1953 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
1959 Configure the Jython Executor
1960 #############################
1962 .. container:: paragraph
1964 The Jython executor is added to the configuration as
1967 .. container:: listingblock
1969 .. container:: content
1973 "engineServiceParameters":{
1974 "engineParameters":{
1975 "executorParameters":{
1977 "parameterClassName" :
1978 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
1984 Configure the JRuby Executor
1985 ############################
1987 .. container:: paragraph
1989 The JRuby executor is added to the configuration as
1992 .. container:: listingblock
1994 .. container:: content
1998 "engineServiceParameters":{
1999 "engineParameters":{
2000 "executorParameters":{
2002 "parameterClassName" :
2003 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
2009 Configure the Java Executor
2010 ###########################
2012 .. container:: paragraph
2014 The Java executor is added to the configuration as
2017 .. container:: listingblock
2019 .. container:: content
2023 "engineServiceParameters":{
2024 "engineParameters":{
2025 "executorParameters":{
2027 "parameterClassName" :
2028 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
2034 Configure the MVEL Executor
2035 ###########################
2037 .. container:: paragraph
2039 The MVEL executor is added to the configuration as
2042 .. container:: listingblock
2044 .. container:: content
2048 "engineServiceParameters":{
2049 "engineParameters":{
2050 "executorParameters":{
2052 "parameterClassName" :
2053 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
2062 .. container:: paragraph
2064 Context handlers are responsible for all context processing.
2065 There are the following main areas:
2067 .. container:: ulist
2069 - Context schema: use schema handlers other than Java class
2070 (supported by default without configuration)
2072 - Context distribution: distribute context across multiple
2075 - Context locking: mechanisms to lock context elements for
2078 - Context persistence: mechanisms to persist context
2080 .. container:: paragraph
2082 APEX provides plugins for each of the main areas.
2084 Configure AVRO Schema Handler
2085 #############################
2087 .. container:: paragraph
2089 The AVRO schema handler is added to the configuration as
2092 .. container:: listingblock
2094 .. container:: content
2098 "engineServiceParameters":{
2099 "engineParameters":{
2100 "contextParameters":{
2101 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2102 "schemaParameters":{
2104 "parameterClassName" :
2105 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
2112 .. container:: paragraph
2114 Using the AVRO schema handler has one limitation: AVRO
2115 only supports field names that represent valid Java class
2116 names. This means only letters and the character ``_``
2117 are supported. Characters commonly used in field names,
2118 such as ``.`` and ``-``, are not supported by AVRO. for
2119 more information see `Avro Spec:
2120 Names <https://avro.apache.org/docs/1.8.1/spec.html#names>`__.
2122 .. container:: paragraph
2124 To work with this limitation, the APEX Avro plugin will
2125 parse a given AVRO definition and replace *all*
2126 occurrences of ``.`` and ``-`` with a ``_``. This means
2129 .. container:: ulist
2131 - In a policy model, if the AVRO schema defined a field
2132 as ``my-name`` the policy logic should access it as
2135 - In a policy model, if the AVRO schema defined a field
2136 as ``my.name`` the policy logic should access it as
2139 - There should be no field names that convert to the
2142 .. container:: ulist
2144 - For instance the simultaneous use of
2145 ``my_name``, ``my.name``, and ``my-name`` should
2148 - If not avoided, the event processing might
2149 create unwanted side effects
2151 - If field names use any other not-supported character,
2152 the AVRO plugin will reject it
2154 .. container:: ulist
2156 - Since AVRO uses lazy initialization, this
2157 rejection might only become visible at runtime
2159 Configure Task Parameters
2160 #########################
2162 .. container:: paragraph
2164 The Task Parameters are added to the configuration as
2167 .. container:: listingblock
2169 .. container:: content
2173 "engineServiceParameters": {
2174 "engineParameters": {
2177 "key": "ParameterKey1",
2178 "value": "ParameterValue1"
2181 "taskId": "Task_Act0",
2182 "key": "ParameterKey2",
2183 "value": "ParameterValue2"
2189 .. container:: paragraph
2191 TaskParameters can be used to pass parameters from ApexConfig
2192 to the policy logic. In the config, these are optional.
2193 The list of task parameters provided in the config may be added
2194 to the tasks or existing task parameters in the task will be overriden.
2196 .. container:: paragraph
2198 If taskId is provided in ApexConfig for an entry, then that
2199 parameter is updated only for that particular task. Otherwise,
2200 the task parameter is added to all tasks.
2202 Carrier Technologies
2203 --------------------
2205 .. container:: paragraph
2207 Carrier technologies define how APEX receives (input) and
2208 sends (output) events. They can be used in any combination,
2209 using asynchronous or synchronous mode. There can also be
2210 any number of carrier technologies for the input (consume)
2211 and the output (produce) interface.
2213 .. container:: paragraph
2215 Supported *input* technologies are:
2217 .. container:: ulist
2219 - Standard input, read events from the standard input
2220 (console), not suitable for APEX background servers
2222 - File input, read events from a file
2224 - Kafka, read events from a Kafka system
2226 - Websockets, read events from a Websocket
2230 - REST (synchronous and asynchronous), additionally as
2233 - Event Requestor, allows reading of events that have been
2234 looped back into APEX
2236 .. container:: paragraph
2238 Supported *output* technologies are:
2240 .. container:: ulist
2242 - Standard output, write events to the standard output
2243 (console), not suitable for APEX background servers
2245 - File output, write events to a file
2247 - Kafka, write events to a Kafka system
2249 - Websockets, write events to a Websocket
2253 - REST (synchronous and asynchronous), additionally as
2256 - Event Requestor, allows events to be looped back into
2259 .. container:: paragraph
2261 New carrier technologies can be added as plugins to APEX or
2262 developed outside APEX and added to an APEX deployment.
2267 .. container:: paragraph
2269 Standard IO does not require a specific plugin, it is
2270 supported be default.
2274 .. container:: paragraph
2276 APEX will take events from its standard input. This
2277 carrier is good for testing, but certainly not for a
2278 use case where APEX runs as a server. The
2279 configuration is as follows:
2281 .. container:: listingblock
2283 .. container:: content
2287 "carrierTechnologyParameters" : {
2288 "carrierTechnology" : "FILE", (1)
2290 "standardIO" : true (2)
2294 .. container:: colist arabic
2296 +-------+---------------------------------------+
2297 | **1** | standard input is considered a file |
2298 +-------+---------------------------------------+
2299 | **2** | file descriptor set to standard input |
2300 +-------+---------------------------------------+
2305 .. container:: paragraph
2307 APEX will send events to its standard output. This
2308 carrier is good for testing, but certainly not for a
2309 use case where APEX runs as a server. The
2310 configuration is as follows:
2312 .. container:: listingblock
2314 .. container:: content
2318 "carrierTechnologyParameters" : {
2319 "carrierTechnology" : "FILE", (1)
2321 "standardIO" : true (2)
2325 .. container:: colist arabic
2327 +-------+----------------------------------------+
2328 | **1** | standard output is considered a file |
2329 +-------+----------------------------------------+
2330 | **2** | file descriptor set to standard output |
2331 +-------+----------------------------------------+
2336 .. container:: paragraph
2338 File IO does not require a specific plugin, it is
2339 supported be default.
2344 .. container:: paragraph
2346 APEX will take events from a file. The same file
2347 should not be used as an output. The configuration is
2350 .. container:: listingblock
2352 .. container:: content
2356 "carrierTechnologyParameters" : {
2357 "carrierTechnology" : "FILE", (1)
2359 "fileName" : "examples/events/SampleDomain/EventsIn.xmlfile" (2)
2363 .. container:: colist arabic
2365 +-------+------------------------------------------+
2366 | **1** | set file input |
2367 +-------+------------------------------------------+
2368 | **2** | the name of the file to read events from |
2369 +-------+------------------------------------------+
2373 .. container:: paragraph
2375 APEX will write events to a file. The same file should
2376 not be used as an input. The configuration is as
2379 .. container:: listingblock
2381 .. container:: content
2385 "carrierTechnologyParameters" : {
2386 "carrierTechnology" : "FILE", (1)
2388 "fileName" : "examples/events/SampleDomain/EventsOut.xmlfile" (2)
2392 .. container:: colist arabic
2394 +-------+-----------------------------------------+
2395 | **1** | set file output |
2396 +-------+-----------------------------------------+
2397 | **2** | the name of the file to write events to |
2398 +-------+-----------------------------------------+
2403 .. container:: paragraph
2405 Event Requestor IO does not require a specific plugin, it
2406 is supported be default. It should only be used with the
2407 APEX event protocol.
2409 Event Requestor Input
2410 =====================
2412 .. container:: paragraph
2414 APEX will take events from APEX.
2416 .. container:: listingblock
2418 .. container:: content
2422 "carrierTechnologyParameters" : {
2423 "carrierTechnology": "EVENT_REQUESTOR" (1)
2426 .. container:: colist arabic
2428 +-------+---------------------------+
2429 | **1** | set event requestor input |
2430 +-------+---------------------------+
2432 Event Requestor Output
2433 ======================
2435 .. container:: paragraph
2437 APEX will write events to APEX.
2439 .. container:: listingblock
2441 .. container:: content
2445 "carrierTechnologyParameters" : {
2446 "carrierTechnology": "EVENT_REQUESTOR" (1)
2449 Peering Event Requestors
2450 ========================
2452 .. container:: paragraph
2454 When using event requestors, they need to be peered.
2455 This means an event requestor output needs to be
2456 peered (associated) with an event requestor input. The
2457 following example shows the use of an event requestor
2458 with the APEX event protocol and the peering of output
2461 .. container:: listingblock
2463 .. container:: content
2467 "eventInputParameters": {
2468 "EventRequestorConsumer": {
2469 "carrierTechnologyParameters": {
2470 "carrierTechnology": "EVENT_REQUESTOR" (1)
2472 "eventProtocolParameters": {
2473 "eventProtocol": "APEX" (2)
2475 "eventNameFilter": "InputEvent", (3)
2476 "requestorMode": true, (4)
2477 "requestorPeer": "EventRequestorProducer", (5)
2478 "requestorTimeout": 500 (6)
2481 "eventOutputParameters": {
2482 "EventRequestorProducer": {
2483 "carrierTechnologyParameters": {
2484 "carrierTechnology": "EVENT_REQUESTOR" (7)
2486 "eventProtocolParameters": {
2487 "eventProtocol": "APEX" (8)
2489 "eventNameFilter": "EventListEvent", (9)
2490 "requestorMode": true, (10)
2491 "requestorPeer": "EventRequestorConsumer", (11)
2492 "requestorTimeout": 500 (12)
2496 .. container:: colist arabic
2498 +-----------------------------------+-----------------------------------+
2499 | **1** | event requestor on a consumer |
2500 +-----------------------------------+-----------------------------------+
2501 | **2** | with APEX event protocol |
2502 +-----------------------------------+-----------------------------------+
2503 | **3** | optional filter (best to use a |
2504 | | filter to prevent unwanted events |
2505 | | on the consumer side) |
2506 +-----------------------------------+-----------------------------------+
2507 | **4** | activate requestor mode |
2508 +-----------------------------------+-----------------------------------+
2509 | **5** | the peer to the output (must |
2510 | | match the output carrier) |
2511 +-----------------------------------+-----------------------------------+
2512 | **6** | an optional timeout in |
2514 +-----------------------------------+-----------------------------------+
2515 | **7** | event requestor on a producer |
2516 +-----------------------------------+-----------------------------------+
2517 | **8** | with APEX event protocol |
2518 +-----------------------------------+-----------------------------------+
2519 | **9** | optional filter (best to use a |
2520 | | filter to prevent unwanted events |
2521 | | on the consumer side) |
2522 +-----------------------------------+-----------------------------------+
2523 | **10** | activate requestor mode |
2524 +-----------------------------------+-----------------------------------+
2525 | **11** | the peer to the output (must |
2526 | | match the input carrier) |
2527 +-----------------------------------+-----------------------------------+
2528 | **12** | an optional timeout in |
2530 +-----------------------------------+-----------------------------------+
2535 .. container:: paragraph
2537 Kafka IO is supported by the APEX Kafka plugin. The
2538 configurations below are examples. APEX will take any
2539 configuration inside the parameter object and forward it
2540 to Kafka. More information on Kafka specific
2541 configuration parameters can be found in the Kafka
2544 .. container:: ulist
2547 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html>`__
2550 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html>`__
2554 .. container:: paragraph
2556 APEX will receive events from the Apache Kafka
2557 messaging system. The input is uni-directional, an
2558 engine will only receive events from the input but not
2559 send any event to the input.
2561 .. container:: listingblock
2563 .. container:: content
2567 "carrierTechnologyParameters" : {
2568 "carrierTechnology" : "KAFKA", (1)
2569 "parameterClassName" :
2570 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2572 "bootstrapServers" : "localhost:49092", (2)
2573 "groupId" : "apex-group-id", (3)
2574 "enableAutoCommit" : true, (4)
2575 "autoCommitTime" : 1000, (5)
2576 "sessionTimeout" : 30000, (6)
2577 "consumerPollTime" : 100, (7)
2578 "consumerTopicList" : ["apex-in-0", "apex-in-1"], (8)
2580 "org.apache.kafka.common.serialization.StringDeserializer", (9)
2581 "valueDeserializer" :
2582 "org.apache.kafka.common.serialization.StringDeserializer" (10)
2583 "kafkaProperties": [ (11)
2585 "security.protocol",
2589 "ssl.truststore.type",
2593 "ssl.truststore.location",
2594 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2597 "ssl.truststore.password",
2606 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2609 "ssl.endpoint.identification.algorithm",
2616 .. container:: colist arabic
2618 +--------+-------------------------------------+
2619 | **1** | set Kafka as carrier technology |
2620 +--------+-------------------------------------+
2621 | **2** | bootstrap server and port |
2622 +--------+-------------------------------------+
2623 | **3** | a group identifier |
2624 +--------+-------------------------------------+
2625 | **4** | flag for auto-commit |
2626 +--------+-------------------------------------+
2627 | **5** | auto-commit timeout in milliseconds |
2628 +--------+-------------------------------------+
2629 | **6** | session timeout in milliseconds |
2630 +--------+-------------------------------------+
2631 | **7** | consumer poll time in milliseconds |
2632 +--------+-------------------------------------+
2633 | **8** | consumer topic list |
2634 +--------+-------------------------------------+
2635 | **9** | key for the Kafka de-serializer |
2636 +--------+-------------------------------------+
2637 | **10** | value for the Kafka de-serializer |
2638 +--------+-------------------------------------+
2639 | **11** | properties for Kafka connectivity |
2640 +--------+-------------------------------------+
2642 .. container:: paragraph
2644 Kindly note that the above Kafka properties is just a reference,
2645 and the actual properties required depends on the Kafka server installation.
2649 .. container:: paragraph
2651 APEX will send events to the Apache Kafka messaging
2652 system. The output is uni-directional, an engine will
2653 send events to the output but not receive any event
2656 .. container:: listingblock
2658 .. container:: content
2662 "carrierTechnologyParameters" : {
2663 "carrierTechnology" : "KAFKA", (1)
2664 "parameterClassName" :
2665 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2667 "bootstrapServers" : "localhost:49092", (2)
2670 "batchSize" : 16384, (5)
2671 "lingerTime" : 1, (6)
2672 "bufferMemory" : 33554432, (7)
2673 "producerTopic" : "apex-out", (8)
2675 "org.apache.kafka.common.serialization.StringSerializer", (9)
2677 "org.apache.kafka.common.serialization.StringSerializer" (10)
2678 "kafkaProperties": [ (11)
2680 "security.protocol",
2684 "ssl.truststore.type",
2688 "ssl.truststore.location",
2689 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2692 "ssl.truststore.password",
2701 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2704 "ssl.endpoint.identification.algorithm",
2711 .. container:: colist arabic
2713 +--------+-----------------------------------+
2714 | **1** | set Kafka as carrier technology |
2715 +--------+-----------------------------------+
2716 | **2** | bootstrap server and port |
2717 +--------+-----------------------------------+
2718 | **3** | acknowledgement strategy |
2719 +--------+-----------------------------------+
2720 | **4** | number of retries |
2721 +--------+-----------------------------------+
2722 | **5** | batch size |
2723 +--------+-----------------------------------+
2724 | **6** | time to linger in milliseconds |
2725 +--------+-----------------------------------+
2726 | **7** | buffer memory in byte |
2727 +--------+-----------------------------------+
2728 | **8** | producer topic |
2729 +--------+-----------------------------------+
2730 | **9** | key for the Kafka serializer |
2731 +--------+-----------------------------------+
2732 | **10** | value for the Kafka serializer |
2733 +--------+-----------------------------------+
2734 | **11** | properties for Kafka connectivity |
2735 +--------+-----------------------------------+
2737 .. container:: paragraph
2739 Kindly note that the above Kafka properties is just a reference,
2740 and the actual properties required depends on the Kafka server installation.
2745 .. container:: paragraph
2747 APEX supports the Java Messaging Service (JMS) as input
2748 as well as output. JMS IO is supported by the APEX JMS
2749 plugin. Input and output support an event encoding as
2750 text (JSON string) or object (serialized object). The
2751 input configuration is the same for both encodings, the
2752 output configuration differs.
2756 .. container:: paragraph
2758 APEX will receive events from a JMS messaging system.
2759 The input is uni-directional, an engine will only
2760 receive events from the input but not send any event
2763 .. container:: listingblock
2765 .. container:: content
2769 "carrierTechnologyParameters" : {
2770 "carrierTechnology" : "JMS", (1)
2771 "parameterClassName" :
2772 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2773 "parameters" : { (2)
2774 "initialContextFactory" :
2775 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2776 "connectionFactory" : "ConnectionFactory", (4)
2777 "providerURL" : "remote://localhost:5445", (5)
2778 "securityPrincipal" : "guest", (6)
2779 "securityCredentials" : "IAmAGuest", (7)
2780 "consumerTopic" : "jms/topic/apexIn" (8)
2784 .. container:: colist arabic
2786 +-----------------------------------+-----------------------------------+
2787 | **1** | set JMS as carrier technology |
2788 +-----------------------------------+-----------------------------------+
2789 | **2** | set all JMS specific parameters |
2790 +-----------------------------------+-----------------------------------+
2791 | **3** | the context factory, in this case |
2792 | | from JBOSS (it requires the |
2794 | | org.jboss:jboss-remote-naming:2.0 |
2796 | | or a different version to be in |
2797 | | the directory ``$APEX_HOME/lib`` |
2798 | | or ``%APEX_HOME%\lib`` |
2799 +-----------------------------------+-----------------------------------+
2800 | **4** | a connection factory for the JMS |
2802 +-----------------------------------+-----------------------------------+
2803 | **5** | URL with host and port of the JMS |
2805 +-----------------------------------+-----------------------------------+
2806 | **6** | access credentials, user name |
2807 +-----------------------------------+-----------------------------------+
2808 | **7** | access credentials, user password |
2809 +-----------------------------------+-----------------------------------+
2810 | **8** | the JMS topic to listen to |
2811 +-----------------------------------+-----------------------------------+
2813 JMS Output with Text
2814 ====================
2816 .. container:: paragraph
2818 APEX engine send events to a JMS messaging system. The
2819 output is uni-directional, an engine will send events
2820 to the output but not receive any event from output.
2822 .. container:: listingblock
2824 .. container:: content
2828 "carrierTechnologyParameters" : {
2829 "carrierTechnology" : "JMS", (1)
2830 "parameterClassName" :
2831 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2832 "parameters" : { (2)
2833 "initialContextFactory" :
2834 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2835 "connectionFactory" : "ConnectionFactory", (4)
2836 "providerURL" : "remote://localhost:5445", (5)
2837 "securityPrincipal" : "guest", (6)
2838 "securityCredentials" : "IAmAGuest", (7)
2839 "producerTopic" : "jms/topic/apexOut", (8)
2840 "objectMessageSending": "false" (9)
2844 .. container:: colist arabic
2846 +-----------------------------------+-----------------------------------+
2847 | **1** | set JMS as carrier technology |
2848 +-----------------------------------+-----------------------------------+
2849 | **2** | set all JMS specific parameters |
2850 +-----------------------------------+-----------------------------------+
2851 | **3** | the context factory, in this case |
2852 | | from JBOSS (it requires the |
2854 | | org.jboss:jboss-remote-naming:2.0 |
2856 | | or a different version to be in |
2857 | | the directory ``$APEX_HOME/lib`` |
2858 | | or ``%APEX_HOME%\lib`` |
2859 +-----------------------------------+-----------------------------------+
2860 | **4** | a connection factory for the JMS |
2862 +-----------------------------------+-----------------------------------+
2863 | **5** | URL with host and port of the JMS |
2865 +-----------------------------------+-----------------------------------+
2866 | **6** | access credentials, user name |
2867 +-----------------------------------+-----------------------------------+
2868 | **7** | access credentials, user password |
2869 +-----------------------------------+-----------------------------------+
2870 | **8** | the JMS topic to write to |
2871 +-----------------------------------+-----------------------------------+
2872 | **9** | set object messaging to ``false`` |
2873 | | means it sends JSON text |
2874 +-----------------------------------+-----------------------------------+
2876 JMS Output with Object
2877 ======================
2879 .. container:: paragraph
2881 To configure APEX for JMS objects on the output
2882 interface use the same configuration as above (for
2883 output). Simply change the ``objectMessageSending``
2884 parameter to ``true``.
2889 .. container:: paragraph
2891 APEX supports the Websockets as input as well as output.
2892 WS IO is supported by the APEX Websocket plugin. This
2893 carrier technology does only support uni-directional
2894 communication. APEX will not send events to a Websocket
2895 input and any event sent to a Websocket output will
2896 result in an error log.
2898 .. container:: paragraph
2900 The input can be configured as client (APEX connects to
2901 an existing Websocket server) or server (APEX starts a
2902 Websocket server). The same applies to the output. Input
2903 and output can both use a client or a server
2904 configuration, or separate configurations (input as
2905 client and output as server, input as server and output
2906 as client). Each configuration should use its own
2907 dedicated port to avoid any communication loops. The
2908 configuration of a Websocket client is the same for input
2909 and output. The configuration of a Websocket server is
2910 the same for input and output.
2915 .. container:: paragraph
2917 APEX will connect to a given Websocket server. As
2918 input, it will receive events from the server but not
2919 send any events. As output, it will send events to the
2920 server and any event received from the server will
2921 result in an error log.
2923 .. container:: listingblock
2925 .. container:: content
2929 "carrierTechnologyParameters" : {
2930 "carrierTechnology" : "WEBSOCKET", (1)
2931 "parameterClassName" :
2932 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2934 "host" : "localhost", (2)
2939 .. container:: colist arabic
2941 +-------+------------------------------------------------------+
2942 | **1** | set Websocket as carrier technology |
2943 +-------+------------------------------------------------------+
2944 | **2** | the host name on which a Websocket server is running |
2945 +-------+------------------------------------------------------+
2946 | **3** | the port of that Websocket server |
2947 +-------+------------------------------------------------------+
2952 .. container:: paragraph
2954 APEX will start a Websocket server, which will accept
2955 any Websocket clients to connect. As input, it will
2956 receive events from the server but not send any
2957 events. As output, it will send events to the server
2958 and any event received from the server will result in
2961 .. container:: listingblock
2963 .. container:: content
2967 "carrierTechnologyParameters" : {
2968 "carrierTechnology" : "WEBSOCKET", (1)
2969 "parameterClassName" :
2970 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2972 "wsClient" : false, (2)
2977 .. container:: colist arabic
2979 +-------+------------------------------------------------------------+
2980 | **1** | set Websocket as carrier technology |
2981 +-------+------------------------------------------------------------+
2982 | **2** | disable client, so that APEX will start a Websocket server |
2983 +-------+------------------------------------------------------------+
2984 | **3** | the port for the Websocket server APEX will start |
2985 +-------+------------------------------------------------------------+
2990 .. container:: paragraph
2992 APEX can act as REST client on the input as well as on
2993 the output interface. The media type is
2994 ``application/json``, so this plugin only works with
2995 the JSON Event protocol.
3000 .. container:: paragraph
3002 APEX will connect to a given URL to receive events,
3003 but not send any events. The server is polled, i.e.
3004 APEX will do an HTTP GET, take the result, and then do
3005 the next GET. Any required timing needs to be handled
3006 by the server configured via the URL. For instance,
3007 the server could support a wait timeout via the URL as
3009 The httpCodeFilter is used for filtering the status
3010 code, and it can be configured as a regular expression
3011 string. The default httpCodeFilter is "[2][0-9][0-9]"
3012 - for successful response codes.
3013 The response with HTTP status code that matches the
3014 given regular expression is forwarded to the task,
3015 otherwise it is logged as a failure.
3017 .. container:: listingblock
3019 .. container:: content
3023 "carrierTechnologyParameters" : {
3024 "carrierTechnology" : "RESTCLIENT", (1)
3025 "parameterClassName" :
3026 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3028 "url" : "http://example.org:8080/triggers/events", (2)
3029 "httpMethod": "GET", (3)
3030 "httpCodeFilter" : "[2][0-9][0-9]", (4)
3031 "httpHeaders" : [ (5)
3032 ["Keep-Alive", "300"],
3033 ["Cache-Control", "no-cache"]
3038 .. container:: colist arabic
3040 +-------+--------------------------------------------------+
3041 | **1** | set REST client as carrier technology |
3042 +-------+--------------------------------------------------+
3043 | **2** | the URL of the HTTP server for events |
3044 +-------+--------------------------------------------------+
3045 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3046 | | optional, defaults to GET |
3047 +-------+--------------------------------------------------+
3048 | **4** | use HTTP CODE FILTER for filtering status code, |
3049 | | optional, defaults to [2][0-9][0-9] |
3050 +-------+--------------------------------------------------+
3051 | **5** | HTTP headers to use on the REST request, |
3053 +-------+--------------------------------------------------+
3058 .. container:: paragraph
3060 APEX will connect to a given URL to send events, but
3061 not receive any events. The default HTTP operation is
3062 POST (no configuration required). To change it to PUT
3063 simply add the configuration parameter (as shown in
3065 The URL can be configured statically or tagged
3066 as ``?example.{site}.org:8080/{trig}/events``,
3067 all tags such as ``site`` and ``trig`` in the URL
3068 need to be set in the properties object available to
3069 the tasks. In addition, the keys should exactly match
3070 with the tags defined in url. The scope of the properties
3071 object is per HTTP call. Hence, key/value pairs set
3072 in the properties object by task are only available
3073 for that specific HTTP call.
3075 .. container:: listingblock
3077 .. container:: content
3081 "carrierTechnologyParameters" : {
3082 "carrierTechnology" : "RESTCLIENT", (1)
3083 "parameterClassName" :
3084 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3086 "url" : "http://example.com:8888/actions/events", (2)
3087 "url" : "http://example.{site}.com:8888/{trig}/events", (2')
3088 "httpMethod" : "PUT". (3)
3089 "httpHeaders" : [ (4)
3090 ["Keep-Alive", "300"],
3091 ["Cache-Control", "no-cache"]
3095 .. container:: colist arabic
3097 +-------+--------------------------------------------------+
3098 | **1** | set REST client as carrier technology |
3099 +-------+--------------------------------------------------+
3100 | **2** | the static URL of the HTTP server for events |
3101 +-------+--------------------------------------------------+
3102 | **2'**| the tagged URL of the HTTP server for events |
3103 +-------+--------------------------------------------------+
3104 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3105 | | optional, defaults to POST |
3106 +-------+--------------------------------------------------+
3107 | **4** | HTTP headers to use on the REST request, |
3109 +-------+--------------------------------------------------+
3114 .. container:: paragraph
3116 APEX supports a REST server for input and output.
3118 .. container:: paragraph
3120 The REST server plugin always uses a synchronous mode. A
3121 client does a HTTP GET on the APEX REST server with the
3122 input event and receives the generated output event in
3123 the server reply. This means that for the REST server
3124 there has to always to be an input with an associated
3125 output. Input or output only are not permitted.
3127 .. container:: paragraph
3129 The plugin will start a Grizzly server as REST server for
3130 a normal APEX engine. If the APEX engine is executed as a
3131 servlet, for instance inside Tomcat, then Tomcat will be
3132 used as REST server (this case requires configuration on
3135 .. container:: paragraph
3137 Some configuration restrictions apply for all scenarios:
3139 .. container:: ulist
3141 - Minimum port: 1024
3143 - Maximum port: 65535
3145 - The media type is ``application/json``, so this plugin
3146 only works with the JSON Event protocol.
3148 .. container:: paragraph
3150 The URL the client calls is created using
3152 .. container:: ulist
3154 - the configured host and port, e.g.
3155 ``http://localhost:12345``
3157 - the standard path, e.g. ``/apex/``
3159 - the name of the input/output, e.g. ``FirstConsumer/``
3161 - the input or output name, e.g. ``EventIn``.
3163 .. container:: paragraph
3165 The examples above lead to the URL
3166 ``http://localhost:12345/apex/FirstConsumer/EventIn``.
3168 .. container:: paragraph
3170 A client can also get status information of the REST
3171 server using ``/Status``, e.g.
3172 ``http://localhost:12345/apex/FirstConsumer/Status``.
3174 REST Server Stand-alone
3175 =======================
3177 .. container:: paragraph
3179 We need to configure a REST server input and a REST
3180 server output. Input and output are associated with
3181 each other via there name.
3183 .. container:: paragraph
3185 Timeouts for REST calls need to be set carefully. If
3186 they are too short, the call might timeout before a
3187 policy finished creating an event.
3189 .. container:: paragraph
3191 The following example configures the input named as
3192 ``MyConsumer`` and associates an output named
3193 ``MyProducer`` with it.
3195 .. container:: listingblock
3197 .. container:: content
3201 "eventInputParameters": {
3203 "carrierTechnologyParameters" : {
3204 "carrierTechnology" : "RESTSERVER", (1)
3205 "parameterClassName" :
3206 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters",
3208 "standalone" : true, (2)
3209 "host" : "localhost", (3)
3213 "eventProtocolParameters":{
3214 "eventProtocol" : "JSON" (5)
3216 "synchronousMode" : true, (6)
3217 "synchronousPeer" : "MyProducer", (7)
3218 "synchronousTimeout" : 500 (8)
3222 .. container:: colist arabic
3224 +-------+---------------------------------------+
3225 | **1** | set REST server as carrier technology |
3226 +-------+---------------------------------------+
3227 | **2** | set the server as stand-alone |
3228 +-------+---------------------------------------+
3229 | **3** | set the server host |
3230 +-------+---------------------------------------+
3231 | **4** | set the server listen port |
3232 +-------+---------------------------------------+
3233 | **5** | use JSON event protocol |
3234 +-------+---------------------------------------+
3235 | **6** | activate synchronous mode |
3236 +-------+---------------------------------------+
3237 | **7** | associate an output ``MyProducer`` |
3238 +-------+---------------------------------------+
3239 | **8** | set a timeout of 500 milliseconds |
3240 +-------+---------------------------------------+
3242 .. container:: paragraph
3244 The following example configures the output named as
3245 ``MyProducer`` and associates the input ``MyConsumer``
3246 with it. Note that for the output there are no more
3247 paramters (such as host or port), since they are
3248 already configured in the associated input
3250 .. container:: listingblock
3252 .. container:: content
3256 "eventOutputParameters": {
3258 "carrierTechnologyParameters":{
3259 "carrierTechnology" : "RESTSERVER",
3260 "parameterClassName" :
3261 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters"
3263 "eventProtocolParameters":{
3264 "eventProtocol" : "JSON"
3266 "synchronousMode" : true,
3267 "synchronousPeer" : "MyConsumer",
3268 "synchronousTimeout" : 500
3272 REST Server Stand-alone, multi input
3273 ====================================
3275 .. container:: paragraph
3277 Any number of input/output pairs for REST servers can
3278 be configured. For instance, we can configure an input
3279 ``FirstConsumer`` with output ``FirstProducer`` and an
3280 input ``SecondConsumer`` with output
3281 ``SecondProducer``. Important is that there is always
3282 one pair of input/output.
3284 REST Server Stand-alone in Servlet
3285 ==================================
3287 .. container:: paragraph
3289 If APEX is executed as a servlet, e.g. inside Tomcat,
3290 the configuration becomes easier since the plugin can
3291 now use Tomcat as the REST server. In this scenario,
3292 there are not parameters (port, host, etc.) and the
3293 key ``standalone`` must not be used (or set to false).
3295 .. container:: paragraph
3297 For the Tomcat configuration, we need to add the REST
3300 .. container:: listingblock
3302 .. container:: content
3310 <param-value>org.onap.policy.apex.plugins.event.carrier.restserver</param-value>
3318 .. container:: paragraph
3320 APEX can act as REST requestor on the input as well as on
3321 the output interface. The media type is
3322 ``application/json``, so this plugin only works with
3323 the JSON Event protocol. This plugin allows APEX to send REST requests
3324 and to receive the reply of that request without tying up APEX resources
3325 while the request is being processed. The REST Requestor pairs a REST
3326 requestor producer and consumer together to handle the REST request
3327 and response. The REST request is created from an APEX output event
3328 and the REST response is input into APEX as a new input event.
3330 REST Requestor Output (REST Request Producer)
3331 =============================================
3333 .. container:: paragraph
3335 APEX sends a REST request when events are output by APEX, the REST
3336 request configuration is specified on the REST Request Consumer (see
3339 .. container:: listingblock
3341 .. container:: content
3345 "carrierTechnologyParameters": {
3346 "carrierTechnology": "RESTREQUESTOR", (1)
3347 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
3350 .. container:: colist arabic
3352 +-------+------------------------------------------+
3353 | **1** | set REST requestor as carrier technology |
3354 +-------+------------------------------------------+
3356 .. container:: paragraph
3358 The settings below are required on the producer to
3359 define the event that triggers the REST request and
3360 to specify the peered consumer configuration for the
3361 REST request, for example:
3363 .. container:: listingblock
3365 .. container:: content
3369 "eventNameFilter": "GuardRequestEvent", (1)
3370 "requestorMode": true, (2)
3371 "requestorPeer": "GuardRequestorConsumer", (3)
3372 "requestorTimeout": 500 (4)
3374 .. container:: colist arabic
3376 +-------+-------------------------------------------+
3377 | **1** | a filter on the event |
3378 +-------+-------------------------------------------+
3379 | **2** | requestor mode must be set to *true* |
3380 +-------+-------------------------------------------+
3381 | **3** | the peered consumer for REST requests, |
3382 | | that consumer specifies the full |
3383 | | configuration for REST requests |
3384 +-------+-------------------------------------------+
3385 | **4** | the request timeout in milliseconds, |
3386 | | overridden by timeout on consumer if that |
3387 | | is set, optional defaults to 500 |
3389 +-------+-------------------------------------------+
3391 REST Requestor Input (REST Request Consumer)
3392 ============================================
3394 .. container:: paragraph
3396 APEX will connect to a given URL to issue a REST request and
3397 wait for a REST response.
3398 The URL can be configured statically or tagged
3399 as ``?example.{site}.org:8080/{trig}/events``,
3400 all tags such as ``site`` and ``trig`` in the URL
3401 need to be set in the properties object available to
3402 the tasks. In addition, the keys should exactly match
3403 with the tags defined in url. The scope of the properties
3404 object is per HTTP call. Hence, key/value pairs set
3405 in the properties object by task are only available
3406 for that specific HTTP call.
3407 The httpCodeFilter is used for filtering the status
3408 code, and it can be configured as a regular expression
3409 string. The default httpCodeFilter is "[2][0-9][0-9]"
3410 - for successful response codes.
3411 The response with HTTP status code that matches the
3412 given regular expression is forwarded to the task,
3413 otherwise it is logged as a failure.
3415 .. container:: listingblock
3417 .. container:: content
3421 "carrierTechnologyParameters": {
3422 "carrierTechnology": "RESTREQUESTOR", (1)
3423 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
3425 "url": "http://localhost:54321/some/path/to/rest/resource", (2)
3426 "url": "http://localhost:54321/{site}/path/to/rest/{resValue}", (2')
3427 "httpMethod": "POST", (3)
3428 "requestorMode": true, (4)
3429 "requestorPeer": "GuardRequestorProducer", (5)
3430 "restRequestTimeout": 2000, (6)
3431 "httpCodeFilter" : "[2][0-9][0-9]" (7)
3432 "httpHeaders" : [ (8)
3433 ["Keep-Alive", "300"],
3434 ["Cache-Control", "no-cache"]
3438 .. container:: colist arabic
3440 +-------+--------------------------------------------------+
3441 | **1** | set REST requestor as carrier technology |
3442 +-------+--------------------------------------------------+
3443 | **2** | the static URL of the HTTP server for events |
3444 +-------+--------------------------------------------------+
3445 | **2'**| the tagged URL of the HTTP server for events |
3446 +-------+--------------------------------------------------+
3447 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3448 | | optional, defaults to GET |
3449 +-------+--------------------------------------------------+
3450 | **4** | requestor mode must be set to *true* |
3451 +-------+--------------------------------------------------+
3452 | **5** | the peered producer for REST requests, that |
3453 | | producer specifies the APEX output event that |
3454 | | triggers the REST request |
3455 +-------+--------------------------------------------------+
3456 | **6** | request timeout in milliseconds, overrides any |
3457 | | value set in the REST Requestor Producer, |
3458 | | optional, defaults to 500 millisconds |
3459 +-------+--------------------------------------------------+
3460 | **7** | use HTTP CODE FILTER for filtering status code |
3461 | | optional, defaults to [2][0-9][0-9] |
3462 +-------+--------------------------------------------------+
3463 | **8** | HTTP headers to use on the REST request, |
3465 +-------+--------------------------------------------------+
3467 .. container:: paragraph
3469 Further settings may be required on the consumer to
3470 define the input event that is produced and forwarded into
3473 .. container:: listingblock
3475 .. container:: content
3479 "eventName": "GuardResponseEvent", (1)
3480 "eventNameFilter": "GuardResponseEvent" (2)
3482 .. container:: colist arabic
3484 +-------+---------------------------+
3485 | **1** | the event name |
3486 +-------+---------------------------+
3487 | **2** | a filter on the event |
3488 +-------+---------------------------+
3493 .. container:: paragraph
3495 APEX can send requests over gRPC at the output side, and get back
3496 response at the input side. This can be used to send requests to CDS
3497 over gRPC. The media type is ``application/json``, so this plugin
3498 only works with the JSON Event protocol.
3503 .. container:: paragraph
3505 APEX will connect to a given host to send a request over
3508 .. container:: listingblock
3510 .. container:: content
3514 "carrierTechnologyParameters": {
3515 "carrierTechnology": "GRPC", (1)
3516 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
3518 "host": "cds-blueprints-processor-grpc", (2)
3520 "username": "ccsdkapps", (3)
3521 "password": ccsdkapps, (4)
3526 .. container:: colist arabic
3528 +-------+--------------------------------------------------+
3529 | **1** | set GRPC as carrier technology |
3530 +-------+--------------------------------------------------+
3531 | **2** | the host to which request is sent |
3532 +-------+--------------------------------------------------+
3533 | **2'**| the value for port |
3534 +-------+--------------------------------------------------+
3535 | **3** | username required to initiate connection |
3536 +-------+--------------------------------------------------+
3537 | **4** | password required to initiate connection |
3538 +-------+--------------------------------------------------+
3539 | **5** | the timeout value for completing the request |
3540 +-------+--------------------------------------------------+
3542 .. container:: paragraph
3544 Further settings are required on the producer to
3545 define the event that is requested, for example:
3547 .. container:: listingblock
3549 .. container:: content
3553 "eventName": "GRPCRequestEvent", (1)
3554 "eventNameFilter": "GRPCRequestEvent", (2)
3555 "requestorMode": true, (3)
3556 "requestorPeer": "GRPCRequestConsumer", (4)
3557 "requestorTimeout": 500 (5)
3559 .. container:: colist arabic
3561 +-------+---------------------------+
3562 | **1** | the event name |
3563 +-------+---------------------------+
3564 | **2** | a filter on the event |
3565 +-------+---------------------------+
3566 | **3** | the mode of the requestor |
3567 +-------+---------------------------+
3568 | **4** | a peer for the requestor |
3569 +-------+---------------------------+
3570 | **5** | a general request timeout |
3571 +-------+---------------------------+
3576 .. container:: paragraph
3578 APEX will connect to the host specified in the producer
3579 side, anad take in response back at the consumer side.
3581 .. container:: listingblock
3583 .. container:: content
3587 "carrierTechnologyParameters": {
3588 "carrierTechnology": "GRPC", (1)
3589 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
3592 .. container:: colist arabic
3594 +-------+------------------------------------------+
3595 | **1** | set GRPC as carrier technology |
3596 +-------+------------------------------------------+
3598 .. container:: paragraph
3600 Further settings are required on the consumer to
3601 define the event that is requested, for example:
3603 .. container:: listingblock
3605 .. container:: content
3609 "eventNameFilter": "GRPCResponseEvent", (1)
3610 "requestorMode": true, (2)
3611 "requestorPeer": "GRPCRequestProducer", (3)
3612 "requestorTimeout": 500 (4)
3614 .. container:: colist arabic
3616 +-------+---------------------------+
3617 | **1** | a filter on the event |
3618 +-------+---------------------------+
3619 | **2** | the mode of the requestor |
3620 +-------+---------------------------+
3621 | **3** | a peer for the requestor |
3622 +-------+---------------------------+
3623 | **4** | a general request timeout |
3624 +-------+---------------------------+
3626 Event Protocols, Format and Encoding
3627 ------------------------------------
3629 .. container:: paragraph
3631 Event protocols define what event formats APEX can receive
3632 (input) and should send (output). They can be used in any
3633 combination for input and output, unless further restricted
3634 by a carrier technology plugin (for instance for JMS
3635 output). There can only be 1 event protocol per event
3638 .. container:: paragraph
3640 Supported *input* event protocols are:
3642 .. container:: ulist
3644 - JSON, the event as a JSON string
3646 - APEX, an APEX event
3648 - JMS object, the event as a JMS object,
3650 - JMS text, the event as a JMS text,
3652 - XML, the event as an XML string,
3654 - YAML, the event as YAML text
3656 .. container:: paragraph
3658 Supported *output* event protocols are:
3660 .. container:: ulist
3662 - JSON, the event as a JSON string
3664 - APEX, an APEX event
3666 - JMS object, the event as a JMS object,
3668 - JMS text, the event as a JMS text,
3670 - XML, the event as an XML string,
3672 - YAML, the event as YAML text
3674 .. container:: paragraph
3676 New event protocols can be added as plugins to APEX or
3677 developed outside APEX and added to an APEX deployment.
3682 .. container:: paragraph
3684 The event protocol for JSON encoding does not require a
3685 specific plugin, it is supported by default. Furthermore,
3686 there is no difference in the configuration for the input
3687 and output interface.
3689 .. container:: paragraph
3691 For an input, APEX requires a well-formed JSON string.
3692 Well-formed here means according to the definitions of a
3693 policy. Any JSON string that is not defined as a trigger
3694 event (consume) will not be consumed (errors will be
3695 thrown). For output JSON events, APEX will always produce
3696 valid JSON strings according to the definition in the
3699 .. container:: paragraph
3701 The following JSON shows the configuration.
3703 .. container:: listingblock
3705 .. container:: content
3709 "eventProtocolParameters":{
3710 "eventProtocol" : "JSON"
3713 .. container:: paragraph
3715 For JSON events, there are a few more optional
3716 parameters, which allow to define a mapping for standard
3717 event fields. An APEX event must have the fields
3718 ``name``, ``version``, ``source``, and ``target``
3719 defined. Sometimes it is not possible to configure a
3720 trigger or actioning system to use those fields. However,
3721 they might be in an event generated outside APEX (or used
3722 outside APEX) just with different names. To configure
3723 APEX to map between the different event names, simply add
3724 the following parameters to a JSON event:
3726 .. container:: listingblock
3728 .. container:: content
3732 "eventProtocolParameters":{
3733 "eventProtocol" : "JSON",
3734 "nameAlias" : "policyName", (1)
3735 "versionAlias" : "policyVersion", (2)
3736 "sourceAlias" : "from", (3)
3737 "targetAlias" : "to", (4)
3738 "nameSpaceAlias": "my.name.space" (5)
3741 .. container:: colist arabic
3743 +-----------------------------------+-----------------------------------+
3744 | **1** | mapping for the ``name`` field, |
3745 | | here from a field called |
3746 | | ``policyName`` |
3747 +-----------------------------------+-----------------------------------+
3748 | **2** | mapping for the ``version`` |
3749 | | field, here from a field called |
3750 | | ``policyVersion`` |
3751 +-----------------------------------+-----------------------------------+
3752 | **3** | mapping for the ``source`` field, |
3753 | | here from a field called ``from`` |
3754 | | (only for an input event) |
3755 +-----------------------------------+-----------------------------------+
3756 | **4** | mapping for the ``target`` field, |
3757 | | here from a field called ``to`` |
3758 | | (only for an output event) |
3759 +-----------------------------------+-----------------------------------+
3760 | **5** | mapping for the ``nameSpace`` |
3761 | | field, here from a field called |
3762 | | ``my.name.space`` |
3763 +-----------------------------------+-----------------------------------+
3767 .. container:: paragraph
3769 The event protocol for APEX events does not require a
3770 specific plugin, it is supported by default. Furthermore,
3771 there is no difference in the configuration for the input
3772 and output interface.
3774 .. container:: paragraph
3776 For input and output APEX uses APEX events.
3778 .. container:: paragraph
3780 The following JSON shows the configuration.
3782 .. container:: listingblock
3784 .. container:: content
3788 "eventProtocolParameters":{
3789 "eventProtocol" : "APEX"
3795 .. container:: paragraph
3797 The event protocol for JMS is provided by the APEX JMS
3798 plugin. The plugin supports encoding as JSON text or as
3799 object. There is no difference in the configuration for
3800 the input and output interface.
3804 .. container:: paragraph
3806 If used as input, APEX will take a JMS message and
3807 extract a JSON string, then proceed as if a JSON event
3808 was received. If used as output, APEX will take the
3809 event produced by a policy, create a JSON string, and
3810 then wrap it into a JMS message.
3812 .. container:: paragraph
3814 The configuration for JMS text is as follows:
3816 .. container:: listingblock
3818 .. container:: content
3822 "eventProtocolParameters":{
3823 "eventProtocol" : "JMSTEXT",
3824 "parameterClassName" :
3825 "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters"
3830 .. container:: paragraph
3832 If used as input, APEX will will take a JMS message,
3833 extract a Java Bean from the ``ObjectMessage``
3834 message, construct an APEX event and put the bean on
3835 the APEX event as a parameter. If used as output, APEX
3836 will take the event produced by a policy, create a
3837 Java Bean and send it as a JMS message.
3839 .. container:: paragraph
3841 The configuration for JMS object is as follows:
3843 .. container:: listingblock
3845 .. container:: content
3849 "eventProtocolParameters":{
3850 "eventProtocol" : "JMSOBJECT",
3851 "parameterClassName" :
3852 "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters"
3858 .. container:: paragraph
3860 The event protocol for YAML is provided by the APEX YAML
3861 plugin. There is no difference in the configuration for
3862 the input and output interface.
3864 .. container:: paragraph
3866 If used as input, APEX will consume events as YAML and
3867 map them to policy trigger events. Not well-formed YAML
3868 and not understood trigger events will be rejected. If
3869 used as output, APEX produce YAML encoded events from the
3870 event a policy produces. Those events will always be
3871 well-formed according to the definition in the policy
3874 .. container:: paragraph
3876 The following code shows the configuration.
3878 .. container:: listingblock
3880 .. container:: content
3884 "eventProtocolParameters":{
3885 "eventProtocol" : "XML",
3886 "parameterClassName" :
3887 "org.onap.policy.apex.plugins.event.protocol.yaml.YamlEventProtocolParameters"
3892 .. container:: paragraph
3894 The event protocol for XML is provided by the APEX XML
3895 plugin. There is no difference in the configuration for
3896 the input and output interface.
3898 .. container:: paragraph
3900 If used as input, APEX will consume events as XML and map
3901 them to policy trigger events. Not well-formed XML and
3902 not understood trigger events will be rejected. If used
3903 as output, APEX produce XML encoded events from the event
3904 a policy produces. Those events will always be
3905 well-formed according to the definition in the policy
3908 .. container:: paragraph
3910 The following code shows the configuration.
3912 .. container:: listingblock
3914 .. container:: content
3918 "eventProtocolParameters":{
3919 "eventProtocol" : "XML",
3920 "parameterClassName" :
3921 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3924 A configuration example
3925 -----------------------
3927 .. container:: paragraph
3929 The following example loads all available plug-ins.
3931 .. container:: paragraph
3933 Events are consumed from a Websocket, APEX as client.
3934 Consumed event format is JSON.
3936 .. container:: paragraph
3938 Events are produced to Kafka. Produced event format is XML.
3940 .. container:: listingblock
3942 .. container:: content
3947 "engineServiceParameters" : {
3948 "name" : "MyApexEngine",
3949 "version" : "0.0.1",
3951 "instanceCount" : 4,
3952 "deploymentPort" : 12345,
3953 "engineParameters" : {
3954 "executorParameters" : {
3956 "parameterClassName" :
3957 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
3960 "parameterClassName" :
3961 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
3964 "parameterClassName" :
3965 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
3968 "parameterClassName" :
3969 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
3972 "parameterClassName" :
3973 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
3976 "contextParameters" : {
3977 "parameterClassName" :
3978 "org.onap.policy.apex.context.parameters.ContextParameters",
3979 "schemaParameters" : {
3981 "parameterClassName" :
3982 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
3988 "producerCarrierTechnologyParameters" : {
3989 "carrierTechnology" : "KAFKA",
3990 "parameterClassName" :
3991 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
3993 "bootstrapServers" : "localhost:49092",
3996 "batchSize" : 16384,
3998 "bufferMemory" : 33554432,
3999 "producerTopic" : "apex-out",
4000 "keySerializer" : "org.apache.kafka.common.serialization.StringSerializer",
4001 "valueSerializer" : "org.apache.kafka.common.serialization.StringSerializer"
4004 "producerEventProtocolParameters" : {
4005 "eventProtocol" : "XML",
4006 "parameterClassName" :
4007 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
4009 "consumerCarrierTechnologyParameters" : {
4010 "carrierTechnology" : "WEBSOCKET",
4011 "parameterClassName" :
4012 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
4014 "host" : "localhost",
4018 "consumerEventProtocolParameters" : {
4019 "eventProtocol" : "JSON"
4023 Engine and Applications of the APEX System
4024 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4026 Introduction to APEX Engine and Applications
4027 --------------------------------------------
4029 .. container:: paragraph
4031 The core of APEX is the APEX Engine, also known as the APEX
4032 Policy Engine or the APEX PDP (since it is in fact a Policy
4033 Decision Point). Beside this engine, an APEX system comes
4034 with a few applications intended to help with policy
4035 authoring, deployment, and execution.
4037 .. container:: paragraph
4039 The engine itself and most applications are started from the
4040 command line with command line arguments. This is called a
4041 Command Line Interface (CLI). Some applications require an
4042 installation on a webserver, as for instance the REST
4043 Editor. Those applications can be accessed via a web
4046 .. container:: paragraph
4048 You can also use the available APEX APIs and applications to
4049 develop other applications as required. This includes policy
4050 languages (and associated parsers and compilers /
4051 interpreters), GUIs to access APEX or to define policies,
4052 clients to connect to APEX, etc.
4054 .. container:: paragraph
4056 For this documentation, we assume an installation of APEX as
4057 a full system based on a current ONAP release.
4059 CLI on Unix, Windows, and Cygwin
4060 --------------------------------
4062 .. container:: paragraph
4064 A note on APEX CLI applications: all applications and the
4065 engine itself have been deployed and tested on different
4066 operating systems: Red Hat, Ubuntu, Debian, Mac OSX,
4067 Windows, Cygwin. Each operating system comes with its own
4068 way of configuring and executing Java. The main items here
4071 .. container:: ulist
4073 - For UNIX systems (RHL, Ubuntu, Debian, Mac OSX), the
4074 provided bash scripts work as expected with absolute
4076 ``/opt/app/policy/apex-pdp/apex-pdp-2.0.0-SNAPSHOT/examples``),
4077 indirect and linked paths (e.g. ``../apex/apex``), and
4078 path substitutions using environment settings (e.g.
4079 ``$APEX_HOME/bin/``)
4081 - For Windows systems, the provided batch files (``.bat``)
4082 work as expected with with absolute paths (e.g.
4083 ``C:\apex\apex-2.0.0-SNAPSHOT\examples``), and path
4084 substitutions using environment settings (e.g.
4085 ``%APEX_HOME%\bin\``)
4087 - For Cygwin system we assume a standard Cygwin
4088 installation with standard tools (mainly bash) using a
4089 Windows Java installation. This means that the bash
4090 scripts can be used as in UNIX, however any argument
4091 pointing to files and directories need to use either a
4093 ``C:\apex\apex-2.0.0-SNAPSHOT\examples\config...``) or
4094 the command ``cygpath`` with a mixed option. The reason
4095 for that is: Cygwin executes Java using UNIX paths but
4096 then runs Java as a DOS/WINDOWS process, which requires
4097 DOS paths for file access.
4102 .. container:: paragraph
4104 The APEX engine can be started in different ways, depending
4105 your requirements. All scripts are located in the APEX *bin*
4108 .. container:: paragraph
4110 On UNIX and Cygwin systems use:
4112 .. container:: ulist
4114 - ``apexEngine.sh`` - this script will
4116 .. container:: ulist
4118 - Test if ``$APEX_USER`` is set and if the user
4119 exists, terminate with an error otherwise
4121 - Test if ``$APEX_HOME`` is set. If not set, it will
4122 use the default setting as
4123 ``/opt/app/policy/apex-pdp/apex-pdp``. Then the set
4124 directory is tested to exist, the script will
4127 - When all tests are passed successfully, the script
4128 will call ``apexApps.sh`` with arguments to start
4131 - ``apexApps.sh engine`` - this is the general APEX
4132 application launcher, which will
4134 .. container:: ulist
4136 - Start the engine with the argument ``engine``
4138 - Test if ``$APEX_HOME`` is set and points to an
4139 existing directory. If not set or directory does
4140 not exist, script terminates.
4142 - Not test for any settings of ``$APEX_USER``.
4144 .. container:: paragraph
4146 On Windows systems use ``apexEngine.bat`` and
4147 ``apexApps.bat engine`` respectively. Note: none of the
4148 windows batch files will test for ``%APEX_USER%``.
4150 .. container:: paragraph
4152 Summary of alternatives to start the APEX Engine:
4154 +--------------------------------------------------------+----------------------------------------------------------+
4155 | Unix, Cygwin | Windows |
4156 +========================================================+==========================================================+
4157 | .. container:: | .. container:: |
4159 | .. container:: listingblock | .. container:: listingblock |
4161 | .. container:: content | .. container:: content |
4163 | .. code:: | .. code:: |
4165 | # $APEX_HOME/bin/apexEngine.sh [args] | > %APEX_HOME%\bin\apexEngine.bat [args] |
4166 | # $APEX_HOME/bin/apexApps.sh engine [args] | > %APEX_HOME%\bin\apexApps.bat engine [args] |
4167 +--------------------------------------------------------+----------------------------------------------------------+
4169 .. container:: paragraph
4171 The APEX engine comes with a few CLI arguments, the main one is for setting
4172 the tosca policy file for execution. The tosca policy file is
4173 always required. The option ``-h`` prints a help screen.
4175 .. container:: listingblock
4177 .. container:: content
4181 usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]
4183 -p,--tosca-policy-file <TOSCA_POLICY_FILE> the full path to the ToscaPolicy file to use.
4184 -h,--help outputs the usage of this command
4185 -v,--version outputs the version of Apex
4190 .. container:: paragraph
4192 The CLI Editor allows to define policies from the command
4193 line. The application uses a simple language and supports
4194 all elements of an APEX policy. It can be used in to
4197 .. container:: ulist
4199 - non-interactive, specifying a file with the commands to
4202 - interactive, using the editors CLI to create a policy
4204 .. container:: paragraph
4206 When a policy is fully specified, the editor will generate
4207 the APEX core policy specification in JSON. This core
4208 specification is called the policy model in the APEX engine
4209 and can be used directly with the APEX engine.
4211 .. container:: paragraph
4213 On UNIX and Cygwin systems use:
4215 .. container:: ulist
4217 - ``apexCLIEditor.sh`` - simply starts the CLI editor,
4218 arguments to the script determine the mode of the editor
4220 - ``apexApps.sh cli-editor`` - simply starts the CLI
4221 editor, arguments to the script determine the mode of the
4224 .. container:: paragraph
4226 On Windows systems use:
4228 .. container:: ulist
4230 - ``apexCLIEditor.bat`` - simply starts the CLI editor,
4231 arguments to the script determine the mode of the editor
4233 - ``apexApps.bat cli-editor`` - simply starts the CLI
4234 editor, arguments to the script determine the mode of the
4237 .. container:: paragraph
4239 Summary of alternatives to start the APEX CLI Editor:
4241 +------------------------------------------------------------+--------------------------------------------------------------+
4242 | Unix, Cygwin | Windows |
4243 +============================================================+==============================================================+
4244 | .. container:: | .. container:: |
4246 | .. container:: listingblock | .. container:: listingblock |
4248 | .. container:: content | .. container:: content |
4250 | .. code:: | .. code:: |
4252 | # $APEX_HOME/bin/apexCLIEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIEditor.bat [args] |
4253 | # $APEX_HOME/bin/apexApps.sh cli-editor [args] | > %APEX_HOME%\bin\apexApps.bat cli-editor [args] |
4254 +------------------------------------------------------------+--------------------------------------------------------------+
4256 .. container:: paragraph
4258 The option ``-h`` provides a help screen with all command
4261 .. container:: listingblock
4263 .. container:: content
4267 usage: org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain [options...]
4269 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4270 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4271 -h,--help outputs the usage of this command
4272 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4273 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and continue
4274 executing the command file
4275 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will log
4276 to standard output if not specified or suppressed with "-nl" flag
4277 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4278 -nl,--no-log if specified, no logging or output of commands to standard output or log
4280 -nm,--no-model-output if specified, no output of a model to standard output or model output
4281 file is carried out, the user can use the "save" command in a script to
4283 -o,--output-model-file <OUTPUT_MODEL_FILE> name of a file that will contain the output model for the editor, will
4284 output model to standard output if not specified or suppressed with
4286 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4287 root from which to look for included macro files
4289 The APEX CLI Tosca Editor
4290 -------------------------
4292 .. container:: paragraph
4294 As per the new Policy LifeCycle API, the policies are expected to be defined as ToscaServiceTemplate. The CLI Tosca Editor is an extended version of the APEX CLI Editor which can generate the policies in ToscaServiceTemplate way.
4296 .. container:: paragraph
4298 The APEX config file(.json), command file(.apex) and the tosca template skeleton(.json) file paths need to be passed as input arguments to the CLI Tosca Editor. Policy in ToscaServiceTemplate format is generated as the output. This can be used as the input to Policy API for creating policies.
4300 .. container:: paragraph
4302 On UNIX and Cygwin systems use:
4304 .. container:: ulist
4306 - ``apexCLIToscaEditor.sh`` - starts the CLI Tosca editor,
4307 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4309 - ``apexApps.sh cli-tosca-editor`` - starts the CLI Tosca editor,
4310 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4312 .. container:: paragraph
4314 On Windows systems use:
4316 .. container:: ulist
4318 - ``apexCLIToscaEditor.bat`` - starts the CLI Tosca editor,
4319 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4321 - ``apexApps.bat cli-tosca-editor`` - starts the CLI Tosca
4322 editor, all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4324 .. container:: paragraph
4326 Summary of alternatives to start the APEX CLI Tosca Editor:
4328 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4329 | Unix, Cygwin | Windows |
4330 +=================================================================+====================================================================+
4331 | .. container:: | .. container:: |
4333 | .. container:: listingblock | .. container:: listingblock |
4335 | .. container:: content | .. container:: content |
4337 | .. code:: | .. code:: |
4339 | # $APEX_HOME/bin/apexCLIToscaEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIToscaEditor.bat [args] |
4340 | # $APEX_HOME/bin/apexApps.sh cli-tosca-editor [args]| > %APEX_HOME%\bin\apexApps.bat cli-tosca-editor [args] |
4341 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4343 .. container:: paragraph
4345 The option ``-h`` provides a help screen with all command
4348 .. container:: listingblock
4350 .. container:: content
4354 usage: org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain [options...]
4356 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4357 -ac,--apex-config-file <APEX_CONFIG_FILE> name of the file containing apex configuration details
4358 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4359 -h,--help outputs the usage of this command
4360 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4361 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and
4362 continue executing the command file
4363 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will
4364 log to standard output if not specified or suppressed with "-nl" flag
4365 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4366 -nl,--no-log if specified, no logging or output of commands to standard output or
4367 log file is carried out
4368 -ot,--output-tosca-file <OUTPUT_TOSCA_FILE> name of a file that will contain the output ToscaServiceTemplate
4369 -t,--tosca-template-file <TOSCA_TEMPLATE_FILE> name of the input file containing tosca template which needs to be
4371 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4372 root from which to look for included macro files
4374 .. container:: paragraph
4376 An example command to run the APEX CLI Tosca editor on windows machine is given below.
4378 .. container:: listingblock
4380 .. container:: content
4384 %APEX_HOME%/\bin/\apexCLIToscaEditor.bat -c %APEX_HOME%\examples\PolicyModel.apex -ot %APEX_HOME%\examples\test.json -l %APEX_HOME%\examples\test.log -ac %APEX_HOME%\examples\RESTServerStandaloneJsonEvent.json -t %APEX_HOME%\examples\ToscaTemplate.json
4390 .. container:: paragraph
4392 The APEX Client combines the Policy Editor, the
4393 Monitoring Client, and the Deployment Client into a single
4394 application. The standard way to use the APEX Full Client is
4395 via an installation of the *war* file on a webserver.
4396 However, the Full Client can also be started via command
4397 line. This will start a Grizzly webserver with the *war*
4398 deployed. Access to the Full Client is then via the provided
4401 .. container:: paragraph
4403 On UNIX and Cygwin systems use:
4405 .. container:: ulist
4407 - ``apexApps.sh full-client`` - simply starts the webserver
4408 with the Full Client
4410 .. container:: paragraph
4412 On Windows systems use:
4414 .. container:: ulist
4416 - ``apexApps.bat full-client`` - simply starts the
4417 webserver with the Full Client
4419 .. container:: paragraph
4421 The option ``-h`` provides a help screen with all command
4424 .. container:: listingblock
4426 .. container:: content
4430 usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]
4431 -h,--help outputs the usage of this command
4432 -p,--port <PORT> port to use for the Apex Services REST calls
4433 -t,--time-to-live <TIME_TO_LIVE> the amount of time in seconds that the server will run for before terminating
4435 .. container:: paragraph
4437 If the Full Client is started without any arguments the
4438 final messages will look similar to this:
4440 .. container:: listingblock
4442 .. container:: content
4446 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
4447 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.NetworkListener start
4448 INFO: Started listener bound to [localhost:18989]
4449 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.HttpServer start
4450 INFO: [HttpServer] Started.
4451 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
4453 .. container:: paragraph
4455 The last line states the URL on which the Monitoring Client
4456 can be accessed. The example above stated
4457 ``http://localhost:18989/apexservices``. In a web browser
4458 use the URL ``http://localhost:18989``.
4460 The APEX Application Launcher
4461 -----------------------------
4463 .. container:: paragraph
4465 The standard applications (Engine and CLI Editor)
4466 come with dedicated start scripts. For all other APEX
4467 applications, we provide an application launcher.
4469 .. container:: paragraph
4471 On UNIX and Cygwin systems use:
4473 .. container:: ulist
4475 - apexApps.sh\` - simply starts the application launcher
4477 .. container:: paragraph
4479 On Windows systems use:
4481 .. container:: ulist
4483 - ``apexApps.bat`` - simply starts the application launcher
4485 .. container:: paragraph
4487 Summary of alternatives to start the APEX application
4490 +-------------------------------------------------+---------------------------------------------------+
4491 | Unix, Cygwin | Windows |
4492 +=================================================+===================================================+
4493 | .. container:: | .. container:: |
4495 | .. container:: listingblock | .. container:: listingblock |
4497 | .. container:: content | .. container:: content |
4499 | .. code:: | .. code:: |
4501 | # $APEX_HOME/bin/apexApps.sh [args] | > %APEX_HOME%\bin\apexApps.bat [args] |
4502 +-------------------------------------------------+---------------------------------------------------+
4504 .. container:: paragraph
4506 The option ``-h`` provides a help screen with all launcher
4507 command line arguments.
4509 .. container:: listingblock
4511 .. container:: content
4515 apexApps.sh - runs APEX applications
4517 Usage: apexApps.sh [options] | [<application> [<application options>]]
4520 -d <app> - describes an application
4521 -l - lists all applications supported by this script
4522 -h - this help screen
4524 .. container:: paragraph
4526 Using ``-l`` lists all known application the launcher can
4529 .. container:: listingblock
4531 .. container:: content
4535 apexApps.sh: supported applications:
4536 --> ws-echo engine eng-monitoring full-client eng-deployment tpl-event-json model-2-cli rest-editor cli-editor ws-console
4538 .. container:: paragraph
4540 Using the ``-d <name>`` option describes the named
4541 application, for instance for the ``ws-console``:
4543 .. container:: listingblock
4545 .. container:: content
4549 apexApps.sh: application 'ws-console'
4550 --> a simple console sending events to APEX, connect to APEX consumer port
4552 .. container:: paragraph
4554 Launching an application is done by calling the script with
4555 only the application name and any CLI arguments for the
4556 application. For instance, starting the ``ws-echo``
4557 application with port ``8888``:
4559 .. container:: listingblock
4561 .. container:: content
4565 apexApps.sh ws-echo -p 8888
4567 Application: Create Event Templates
4568 -----------------------------------
4570 .. container:: paragraph
4572 **Status: Experimental**
4574 .. container:: paragraph
4576 This application takes a policy model (JSON or XML encoded)
4577 and generates templates for events in JSON format. This can
4578 help when a policy defines rather complex trigger or action
4579 events or complex events between states. The application can
4580 produce events for the types: stimuli (policy trigger
4581 events), internal (events between policy states), and
4582 response (action events).
4584 +----------------------------------------------------------------+------------------------------------------------------------------+
4585 | Unix, Cygwin | Windows |
4586 +================================================================+==================================================================+
4587 | .. container:: | .. container:: |
4589 | .. container:: listingblock | .. container:: listingblock |
4591 | .. container:: content | .. container:: content |
4593 | .. code:: | .. code:: |
4595 | # $APEX_HOME/bin/apexApps.sh tpl-event-json [args] | > %APEX_HOME%\bin\apexApps.bat tpl-event-json [args] |
4596 +----------------------------------------------------------------+------------------------------------------------------------------+
4598 .. container:: paragraph
4600 The option ``-h`` provides a help screen.
4602 .. container:: listingblock
4604 .. container:: content
4608 gen-model2event v{release-version} - generates JSON templates for events generated from a policy model
4609 usage: gen-model2event
4610 -h,--help prints this help and usage screen
4611 -m,--model <MODEL-FILE> set the input policy model file
4612 -t,--type <TYPE> set the event type for generation, one of:
4613 stimuli (trigger events), response (action
4614 events), internal (events between states)
4615 -v,--version prints the application version
4617 .. container:: paragraph
4619 The created templates are not valid events, instead they use
4620 some markup for values one will need to change to actual
4621 values. For instance, running the tool with the *Sample
4622 Domain* policy model as:
4624 .. container:: listingblock
4626 .. container:: content
4630 apexApps.sh tpl-event-json -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json -t stimuli
4632 .. container:: paragraph
4634 will produce the following status messages:
4636 .. container:: listingblock
4638 .. container:: content
4642 gen-model2event: starting Event generator
4643 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4646 .. container:: paragraph
4648 and then run the generator application producing two event
4649 templates. The first template is called ``Event0000``.
4651 .. container:: listingblock
4653 .. container:: content
4658 "name" : "Event0000",
4659 "nameSpace" : "org.onap.policy.apex.sample.events",
4660 "version" : "0.0.1",
4661 "source" : "Outside",
4663 "TestTemperature" : ###double: 0.0###,
4664 "TestTimestamp" : ###long: 0###,
4665 "TestMatchCase" : ###integer: 0###,
4666 "TestSlogan" : "###string###"
4669 .. container:: paragraph
4671 The values for the keys are marked with ``#`` and the
4672 expected type of the value. To create an actual stimuli
4673 event, all these markers need to be change to actual values,
4676 .. container:: listingblock
4678 .. container:: content
4683 "name" : "Event0000",
4684 "nameSpace" : "org.onap.policy.apex.sample.events",
4685 "version" : "0.0.1",
4686 "source" : "Outside",
4688 "TestTemperature" : 25,
4689 "TestTimestamp" : 123456789123456789,
4690 "TestMatchCase" : 1,
4691 "TestSlogan" : "Testing the Match Case with Temperature 25"
4694 Application: Convert a Policy Model to CLI Editor Commands
4695 ----------------------------------------------------------
4697 .. container:: paragraph
4699 **Status: Experimental**
4701 .. container:: paragraph
4703 This application takes a policy model (JSON or XML encoded)
4704 and generates commands for the APEX CLI Editor. This
4705 effectively reverses a policy specification realized with
4708 +-------------------------------------------------------------+---------------------------------------------------------------+
4709 | Unix, Cygwin | Windows |
4710 +=============================================================+===============================================================+
4711 | .. container:: | .. container:: |
4713 | .. container:: listingblock | .. container:: listingblock |
4715 | .. container:: content | .. container:: content |
4717 | .. code:: | .. code:: |
4719 | # $APEX_HOME/bin/apexApps.sh model-2-cli [args] | > %APEX_HOME%\bin\apexApps.bat model-2-cli [args] |
4720 +-------------------------------------------------------------+---------------------------------------------------------------+
4722 .. container:: paragraph
4724 The option ``-h`` provides a help screen.
4726 .. container:: listingblock
4728 .. container:: content
4732 usage: gen-model2cli
4733 -h,--help prints this help and usage screen
4734 -m,--model <MODEL-FILE> set the input policy model file
4735 -sv,--skip-validation switch of validation of the input file
4736 -v,--version prints the application version
4738 .. container:: paragraph
4740 For instance, running the tool with the *Sample Domain*
4743 .. container:: listingblock
4745 .. container:: content
4749 apexApps.sh model-2-cli -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json
4751 .. container:: paragraph
4753 will produce the following status messages:
4755 .. container:: listingblock
4757 .. container:: content
4761 gen-model2cli: starting CLI generator
4762 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4764 .. container:: paragraph
4766 and then run the generator application producing all CLI
4767 Editor commands and printing them to standard out.
4769 Application: Websocket Clients (Echo and Console)
4770 -------------------------------------------------
4772 .. container:: paragraph
4774 **Status: Production**
4776 .. container:: paragraph
4778 The application launcher also provides a Websocket echo
4779 client and a Websocket console client. The echo client
4780 connects to APEX and prints all events it receives from
4781 APEX. The console client connects to APEX, reads input from
4782 the command line, and sends this input as events to APEX.
4784 +------------------------------------------------------------+--------------------------------------------------------------+
4785 | Unix, Cygwin | Windows |
4786 +============================================================+==============================================================+
4787 | .. container:: | .. container:: |
4789 | .. container:: listingblock | .. container:: listingblock |
4791 | .. container:: content | .. container:: content |
4793 | .. code:: | .. code:: |
4795 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
4796 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
4797 +------------------------------------------------------------+--------------------------------------------------------------+
4799 .. container:: paragraph
4801 The arguments are the same for both applications:
4803 .. container:: ulist
4805 - ``-p`` defines the Websocket port to connect to (defaults
4808 - ``-s`` defines the host on which a Websocket server is
4809 running (defaults to ``localhost``)
4811 .. container:: paragraph
4813 A discussion on how to use these two applications to build
4814 an APEX system is detailed HowTo-Websockets.
4819 Introduction to APEX Logging
4820 ----------------------------
4822 .. container:: paragraph
4824 All APEX components make extensive use of logging using the
4825 logging façade `SLF4J <https://www.slf4j.org/>`__ with the
4826 backend `Logback <https://logback.qos.ch/>`__. Both are used
4827 off-the-shelve, so the standard documentation and
4828 configuration apply to APEX logging. For details on how to
4829 work with logback please see the `logback
4830 manual <https://logback.qos.ch/manual/index.html>`__.
4832 .. container:: paragraph
4834 The APEX applications is the logback configuration file
4835 ``$APEX_HOME/etc/logback.xml`` (Windows:
4836 ``%APEX_HOME%\etc\logback.xml``). The logging backend is set
4837 to no debug, i.e. logs from the logging framework should be
4840 .. container:: paragraph
4842 The configurable log levels work as expected:
4844 .. container:: ulist
4846 - *error* (or *ERROR*) is used for serious errors in the
4849 - *warn* (or *WARN*) is used for warnings, which in general
4850 can be ignored but might indicate some deeper problems
4852 - *info* (or *INFO*) is used to provide generally
4853 interesting messages for startup and policy execution
4855 - *debug* (or *DEBUG*) provides more details on startup and
4858 - *trace* (or *TRACE*) gives full details on every aspect
4859 of the APEX engine from start to end
4861 .. container:: paragraph
4863 The loggers can also be configured as expected. The standard
4864 configuration (after installing APEX) uses log level *info*
4865 on all APEX classes (components).
4867 .. container:: paragraph
4869 The applications and scripts in ``$APEX_HOME/bin`` (Windows:
4870 ``%APEX_HOME\bin``) are configured to use the logback
4871 configuration ``$APEX_HOME/etc/logback.xml`` (Windows:
4872 ``%APEX_HOME\etc\logback.xml``). There are multiple ways to
4873 use different logback configurations, for instance:
4875 .. container:: ulist
4877 - Maintain multiple configurations in ``etc``, for instance
4878 a ``logback-debug.xml`` for deep debugging and a
4879 ``logback-production.xml`` for APEX in production mode,
4880 then copy the required configuration file to the used
4881 ``logback.xml`` prior starting APEX
4883 - Edit the scripts in ``bin`` to use a different logback
4884 configuration file (only recommended if you are familiar
4885 with editing bash scripts or windows batch files)
4887 Standard Logging Configuration
4888 ------------------------------
4890 .. container:: paragraph
4892 The standard logging configuration defines a context *APEX*,
4893 which is used in the standard output pattern. The location
4894 for log files is defined in the property ``logDir`` and set
4895 to ``/var/log/onap/policy/apex-pdp``. The standard status
4896 listener is set to *NOP* and the overall logback
4897 configuration is set to no debug.
4899 .. container:: listingblock
4901 .. container:: content
4906 <configuration debug="false">
4907 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
4909 <contextName>Apex</contextName>
4910 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
4916 .. container:: paragraph
4918 The first appender defined is called ``STDOUT`` for logs to standard
4921 .. container:: listingblock
4923 .. container:: content
4928 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4930 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
4934 .. container:: paragraph
4936 The root level logger then is set to the level *info* using the
4937 standard out appender.
4939 .. container:: listingblock
4941 .. container:: content
4947 <appender-ref ref="STDOUT" />
4950 .. container:: paragraph
4952 The second appender is called ``FILE``. It writes logs to a file
4955 .. container:: listingblock
4957 .. container:: content
4962 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
4963 <file>${logDir}/apex.log</file>
4965 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4969 .. container:: paragraph
4971 The third appender is called ``CTXT_FILE``. It writes logs to a file
4974 .. container:: listingblock
4976 .. container:: content
4981 <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
4982 <file>${logDir}/apex_ctxt.log</file>
4984 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4988 .. container:: paragraph
4990 The last definitions are for specific loggers. The first logger
4991 captures all standard APEX classes. It is configured for log level
4992 *info* and uses the standard output and file appenders. The second
4993 logger captures APEX context classes responsible for context
4994 monitoring. It is configured for log level *trace* and uses the
4995 context file appender.
4997 .. container:: listingblock
4999 .. container:: content
5005 <logger name="org.onap.policy.apex" level="info" additivity="false">
5006 <appender-ref ref="STDOUT" />
5007 <appender-ref ref="FILE" />
5010 <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
5011 <appender-ref ref="CTXT_FILE" />
5014 Adding Logback Status and Debug
5015 -------------------------------
5017 .. container:: paragraph
5019 To activate logback status messages change the status listener
5020 from 'NOP' to for instance console.
5022 .. container:: listingblock
5024 .. container:: content
5028 <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
5030 .. container:: paragraph
5032 To activate all logback debugging, for instance to debug a new
5033 logback configuration, activate the debug attribute in the
5036 .. container:: listingblock
5038 .. container:: content
5042 <configuration debug="true">
5046 Logging External Components
5047 ---------------------------
5049 .. container:: paragraph
5051 Logback can also be configured to log any other, external
5052 components APEX is using, if they are using the common logging
5055 .. container:: paragraph
5057 For instance, the context component of APEX is using *Infinispan*
5058 and one can add a logger for this external component. The
5059 following example adds a logger for *Infinispan* using the
5060 standard output appender.
5062 .. container:: listingblock
5064 .. container:: content
5068 <logger name="org.infinispan" level="INFO" additivity="false">
5069 <appender-ref ref="STDOUT" />
5072 .. container:: paragraph
5074 Another example is Apache Zookeeper. The following example adds a
5075 logger for Zookeeper using the standard outout appender.
5077 .. container:: listingblock
5079 .. container:: content
5083 <logger name="org.apache.zookeeper.ClientCnxn" level="INFO" additivity="false">
5084 <appender-ref ref="STDOUT" />
5087 Configuring loggers for Policy Logic
5088 ------------------------------------
5090 .. container:: paragraph
5092 The logging for the logic inside a policy (task logic, task
5093 selection logic, state finalizer logic) can be configured separate
5094 from standard logging. The logger for policy logic is
5095 ``org.onap.policy.apex.executionlogging``. The following example
5098 .. container:: ulist
5100 - a new appender for standard out using a very simple pattern
5101 (simply the actual message)
5103 - a logger for policy logic to standard out using the new
5104 appender and the already described file appender.
5106 .. container:: listingblock
5108 .. container:: content
5112 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5114 <pattern>policy: %msg\n</pattern>
5118 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5119 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5120 <appender-ref ref="FILE" />
5123 .. container:: paragraph
5125 It is also possible to use specific logging for parts of policy
5126 logic. The following example defines a logger for task logic.
5128 .. container:: listingblock
5130 .. container:: content
5134 <logger name="org.onap.policy.apex.executionlogging.TaskExecutionLogging" level="TRACE" additivity="false">
5135 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5138 Rolling File Appenders
5139 ----------------------
5141 .. container:: paragraph
5143 Rolling file appenders are a good option for more complex logging
5144 of a production or complex testing APEX installation. The standard
5145 logback configuration can be used for these use cases. This
5146 section gives two examples for the standard logging and for
5149 .. container:: paragraph
5151 First the standard logging. The following example defines a
5152 rolling file appender. The appender rolls over on a daily basis.
5153 It allows for a file size of 100 MB.
5155 .. container:: listingblock
5157 .. container:: content
5161 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
5162 <file>${logDir}/apex.log</file>
5163 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5164 <!-- rollover daily -->
5165 <!-- <fileNamePattern>xstream-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> -->
5166 <fileNamePattern>${logDir}/apex_%d{yyyy-MM-dd}.%i.log.gz
5168 <maxHistory>4</maxHistory>
5169 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5170 <!-- or whenever the file size reaches 100MB -->
5171 <maxFileSize>100MB</maxFileSize>
5172 </timeBasedFileNamingAndTriggeringPolicy>
5176 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5181 .. container:: paragraph
5183 A very similar configuration can be used for a rolling file
5184 appender logging APEX context.
5186 .. container:: listingblock
5188 .. container:: content
5192 <appender name="CTXT-FILE"
5193 class="ch.qos.logback.core.rolling.RollingFileAppender">
5194 <file>${logDir}/apex_ctxt.log</file>
5195 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5196 <fileNamePattern>${logDir}/apex_ctxt_%d{yyyy-MM-dd}.%i.log.gz
5198 <maxHistory>4</maxHistory>
5199 <timeBasedFileNamingAndTriggeringPolicy
5200 class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5201 <maxFileSize>100MB</maxFileSize>
5202 </timeBasedFileNamingAndTriggeringPolicy>
5206 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5211 Example Configuration for Logging Logic
5212 ---------------------------------------
5214 .. container:: paragraph
5216 The following example shows a configuration that logs policy logic
5217 to standard out and a file (*info*). All other APEX components are
5218 logging to a file (*debug*).. This configuration an be used in a
5219 pre-production phase with the APEX engine still running in a
5220 separate terminal to monitor policy execution. This logback
5221 configuration is in the APEX installation as
5222 ``etc/logback-logic.xml``.
5224 .. container:: listingblock
5226 .. container:: content
5230 <configuration debug="false">
5231 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5233 <contextName>Apex</contextName>
5234 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5236 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5238 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
5242 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5243 <file>${logDir}/apex.log</file>
5246 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5251 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5253 <pattern>policy: %msg\n</pattern>
5257 <root level="error">
5258 <appender-ref ref="STDOUT" />
5261 <logger name="org.onap.policy.apex" level="debug" additivity="false">
5262 <appender-ref ref="FILE" />
5265 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5266 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5267 <appender-ref ref="FILE" />
5271 Example Configuration for a Production Server
5272 ---------------------------------------------
5274 .. container:: paragraph
5276 The following example shows a configuration that logs all APEX
5277 components, including policy logic, to a file (*debug*). This
5278 configuration an be used in a production phase with the APEX
5279 engine being executed as a service on a system without console
5280 output. This logback configuration is in the APEX installation as
5281 ``logback-server.xml``
5283 .. container:: listingblock
5285 .. container:: content
5289 <configuration debug="false">
5290 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5292 <contextName>Apex</contextName>
5293 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5295 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5296 <file>${logDir}/apex.log</file>
5299 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5304 <root level="debug">
5305 <appender-ref ref="FILE" />
5308 <logger name="org.onap.policy.apex.executionlogging" level="debug" additivity="false">
5309 <appender-ref ref="FILE" />
5313 Unsupported Features
5314 ^^^^^^^^^^^^^^^^^^^^
5316 .. container:: paragraph
5318 This section documents some legacy and unsupported features
5319 in apex-pdp. The documentation here has not been updated for
5320 recent versions of apex-pdp. For example, the apex-pdp models
5321 specified in this example should now be in TOSCA format.
5323 Building a System with Websocket Backend
5324 ----------------------------------------
5329 .. container:: paragraph
5331 Websocket is a protocol to run sockets of HTTP. Since it in
5332 essence a socket, the connection is realized between a
5333 server (waiting for connections) and a client (connecting to
5334 a server). Server/client separation is only important for
5335 connection establishment, once connected, everyone can
5336 send/receive on the same socket (as any standard socket
5339 .. container:: paragraph
5341 Standard Websocket implementations are simple, no
5342 publish/subscribe and no special event handling. Most
5343 servers simply send all incoming messages to all
5344 connections. There is a PubSub definition on top of
5345 Websocket called `WAMP <http://wamp-proto.org/>`__. APEX
5346 does not support WAMP at the moment.
5351 .. container:: paragraph
5354 356 <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5355 defines the standard Websocket API. This JSR is part of Jave
5356 EE 7 standard. For Java SE, several implementations exist in
5357 open source. Since Websockets are a stable standard and
5358 simple, most implementations are stable and ready to use. A
5359 lot of products support Websockets, like Spring, JBoss,
5360 Netty, … there are also Kafka extensions for Websockets.
5362 Websocket Example Code for Websocket clients (FOSS)
5363 ###################################################
5365 .. container:: paragraph
5367 There are a lot of implementations and examples available on
5368 Github for Websocket clients. If one is using Java EE 7,
5369 then one can also use the native Websocket implementation.
5370 Good examples for clients using simply Java SE are here:
5372 .. container:: ulist
5375 implementation <https://github.com/TooTallNate/Java-WebSocket>`__
5377 - `Websocket sending client example, using
5378 AWT <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ChatClient.java>`__
5380 - `Websocket receiving client example (simple echo
5381 client) <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ExampleClient.java>`__
5383 .. container:: paragraph
5385 For Java EE, the native Websocket API is explained here:
5387 .. container:: ulist
5390 docs <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5393 example <http://www.programmingforliving.com/2013/08/jsr-356-java-api-for-websocket-client-api.html>`__
5395 BCP: Websocket Configuration
5396 ############################
5398 .. container:: paragraph
5400 The probably best is to configure APEX for Websocket servers
5401 for input (ingress, consume) and output (egress, produce)
5402 interfaces. This means that APEX will start Websocket
5403 servers on named ports and wait for clients to connect.
5404 Advantage: once APEX is running all connectivity
5405 infrastructure is running as well. Consequence: if APEX is
5406 not running, everyone else is in the dark, too.
5408 .. container:: paragraph
5410 The best protocol to be used is JSON string. Each event on
5411 any interface is then a string with a JSON encoding. JSON
5412 string is a little bit slower than byte code, but we doubt
5413 that this will be noticeable. A further advantage of JSON
5414 strings over Websockets with APEX starting the servers: it
5415 is very easy to connect web browsers to such a system.
5416 Simple connect the web browser to the APEX sockets and
5417 send/read JSON strings.
5419 .. container:: paragraph
5421 Once APEX is started you simply connect Websocket clients to
5422 it, and send/receive event. When APEX is terminated, the
5423 Websocket servers go down, and the clients will be
5424 disconnected. APEX does not (yet) support auto-client
5425 reconnect nor WAMP, so clients might need to be restarted or
5426 reconnected manually after an APEX boot.
5428 Demo with VPN Policy Model
5429 ##########################
5431 .. container:: paragraph
5433 We assume that you have an APEX installation using the full
5434 package, i.e. APEX with all examples, of version ``0.5.6``
5435 or higher. We will use the VPN policy from the APEX examples
5438 .. container:: paragraph
5440 Now, have the following ready to start the demo:
5442 .. container:: ulist
5444 - 3 terminals on the host where APEX is running (we need 1
5445 for APEX and 1 for each client)
5447 - the events in the file
5448 ``$APEX_HOME/examples/events/VPN/SetupEvents.json`` open
5449 in an editor (we need to send those events to APEX)
5451 - the events in the file
5452 ``$APEX_HOME/examples/events/VPN/Link09Events.json`` open
5453 in an editor (we need to send those events to APEX)
5455 A Websocket Configuration for the VPN Domain
5456 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5458 .. container:: paragraph
5460 Create a new APEX configuration using the VPN policy
5461 model and configuring APEX as discussed above for
5462 Websockets. Copy the following configuration into
5463 ``$APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json``
5465 ``%APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json``):
5467 .. container:: listingblock
5469 .. container:: content
5475 "engineServiceParameters" : {
5476 "name" : "VPNApexEngine",
5477 "version" : "0.0.1",
5479 "instanceCount" : 1,
5480 "deploymentPort" : 12345,
5481 "policyModelFileName" : "examples/models/VPN/VPNPolicyModelAvro.json",
5482 "engineParameters" : {
5483 "executorParameters" : {
5485 "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
5488 "contextParameters" : {
5489 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
5490 "schemaParameters":{
5492 "parameterClassName" : "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
5498 "producerCarrierTechnologyParameters" : {
5499 "carrierTechnology" : "WEBSOCKET",
5500 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5506 "producerEventProtocolParameters" : {
5507 "eventProtocol" : "JSON"
5509 "consumerCarrierTechnologyParameters" : {
5510 "carrierTechnology" : "WEBSOCKET",
5511 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5517 "consumerEventProtocolParameters" : {
5518 "eventProtocol" : "JSON"
5525 .. container:: paragraph
5527 In a new terminal, start APEX with the new configuration for
5528 Websocket-Server ingress/egress:
5530 .. container:: listingblock
5532 .. container:: content
5537 #: $APEX_HOME/bin/apexApps.sh engine -c $APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json
5539 .. container:: listingblock
5541 .. container:: content
5546 #: %APEX_HOME%\bin\apexApps.bat engine -c %APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json
5548 .. container:: paragraph
5550 Wait for APEX to start, it takes a while to create all Websocket
5551 servers (about 8 seconds on a standard laptop without cached
5552 binaries). depending on your log messages, you will see no (some, a
5553 lot) log messages. If APEX starts correctly, the last few messages
5556 .. container:: listingblock
5558 .. container:: content
5563 2017-07-28 13:17:20,834 Apex [main] INFO c.e.a.s.engine.runtime.EngineService - engine model VPNPolicyModelAvro:0.0.1 added to the engine-AxArtifactKey:(name=VPNApexEngine-0,version=0.0.1)
5564 2017-07-28 13:17:21,057 Apex [Apex-apex-engine-service-0:0] INFO c.e.a.s.engine.runtime.EngineService - Engine AxArtifactKey:(name=VPNApexEngine-0,version=0.0.1) processing ...
5565 2017-07-28 13:17:21,296 Apex [main] INFO c.e.a.s.e.r.impl.EngineServiceImpl - Added the action listener to the engine
5566 Started Apex service
5568 .. container:: paragraph
5570 APEX is running in the new terminal and will produce output when the
5571 policy is triggered/executed.
5573 Run the Websocket Echo Client
5574 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5576 .. container:: paragraph
5578 The echo client is included in an APEX full installation. To run
5579 the client, open a new shell (Unix, Cygwin) or command prompt
5580 (``cmd`` on Windows). Then use the APEX application launcher to
5584 APEX engine needs to run first
5585 The example assumes that an APEX engine configured for *produce* carrier technology Websocket and *JSON* event protocol is executed first.
5587 +---------------------------------------------------------+-----------------------------------------------------------+
5588 | Unix, Cygwin | Windows |
5589 +=========================================================+===========================================================+
5590 | .. container:: | .. container:: |
5592 | .. container:: listingblock | .. container:: listingblock |
5594 | .. container:: content | .. container:: content |
5596 | .. code:: | .. code:: |
5598 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
5599 +---------------------------------------------------------+-----------------------------------------------------------+
5601 .. container:: paragraph
5603 Use the following command line arguments for server and port of
5604 the Websocket server. The port should be the same as configured in
5605 the APEX engine. The server host should be the host on which the
5606 APEX engine is running
5608 .. container:: ulist
5610 - ``-p`` defines the Websocket port to connect to (defaults to
5613 - ``-s`` defines the host on which a Websocket server is running
5614 (defaults to ``localhost``)
5616 .. container:: paragraph
5618 Let’s assume that there is an APEX engine running, configured for
5619 produce Websocket carrier technology, as server, for port 42452,
5620 with produce event protocol JSON,. If we start the console client
5621 on the same host, we can omit the ``-s`` options. We start the
5624 .. container:: listingblock
5626 .. container:: content
5630 # $APEX_HOME/bin/apexApps.sh ws-echo -p 42452 (1)
5631 > %APEX_HOME%\bin\apexApps.bat ws-echo -p 42452 (2)
5633 .. container:: colist arabic
5635 +-------+--------------------------------+
5636 | **1** | Start client on Unix or Cygwin |
5637 +-------+--------------------------------+
5638 | **2** | Start client on Windows |
5639 +-------+--------------------------------+
5641 .. container:: paragraph
5643 Once started successfully, the client will produce the following
5644 messages (assuming we used ``-p 42452`` and an APEX engine is
5645 running on ``localhost`` with the same port:
5647 .. container:: listingblock
5649 .. container:: content
5653 ws-simple-echo: starting simple event echo
5654 --> server: localhost
5657 Once started, the application will simply print out all received events to standard out.
5658 Each received event will be prefixed by '---' and suffixed by '===='
5661 ws-simple-echo: opened connection to APEX (Web Socket Protocol Handshake)
5663 Run the Websocket Console Client
5664 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5666 .. container:: paragraph
5668 The console client is included in an APEX full installation. To
5669 run the client, open a new shell (Unix, Cygwin) or command prompt
5670 (``cmd`` on Windows). Then use the APEX application launcher to
5674 APEX engine needs to run first
5675 The example assumes that an APEX engine configured for *consume* carrier technology Websocket and *JSON* event
5676 protocol is executed first.
5678 +------------------------------------------------------------+--------------------------------------------------------------+
5679 | Unix, Cygwin | Windows |
5680 +============================================================+==============================================================+
5681 | .. container:: | .. container:: |
5683 | .. container:: listingblock | .. container:: listingblock |
5685 | .. container:: content | .. container:: content |
5687 | .. code:: | .. code:: |
5689 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
5690 +------------------------------------------------------------+--------------------------------------------------------------+
5692 .. container:: paragraph
5694 Use the following command line arguments for server and port of
5695 the Websocket server. The port should be the same as configured in
5696 the APEX engine. The server host should be the host on which the
5697 APEX engine is running
5699 .. container:: ulist
5701 - ``-p`` defines the Websocket port to connect to (defaults to
5704 - ``-s`` defines the host on which a Websocket server is running
5705 (defaults to ``localhost``)
5707 .. container:: paragraph
5709 Let’s assume that there is an APEX engine running, configured for
5710 consume Websocket carrier technology, as server, for port 42450,
5711 with consume event protocol JSON,. If we start the console client
5712 on the same host, we can omit the ``-s`` options. We start the
5715 .. container:: listingblock
5717 .. container:: content
5721 # $APEX_HOME/bin/apexApps.sh ws-console -p 42450 (1)
5722 > %APEX_HOME%\bin\apexApps.sh ws-console -p 42450 (2)
5724 .. container:: colist arabic
5726 +-------+--------------------------------+
5727 | **1** | Start client on Unix or Cygwin |
5728 +-------+--------------------------------+
5729 | **2** | Start client on Windows |
5730 +-------+--------------------------------+
5732 .. container:: paragraph
5734 Once started successfully, the client will produce the following
5735 messages (assuming we used ``-p 42450`` and an APEX engine is
5736 running on ``localhost`` with the same port:
5738 .. container:: listingblock
5740 .. container:: content
5744 ws-simple-console: starting simple event console
5745 --> server: localhost
5748 - terminate the application typing 'exit<enter>' or using 'CTRL+C'
5749 - events are created by a non-blank starting line and terminated by a blank line
5752 ws-simple-console: opened connection to APEX (Web Socket Protocol Handshake)
5757 .. container:: paragraph
5759 Now you have the full system up and running:
5761 .. container:: ulist
5763 - Terminal 1: APEX ready and loaded
5765 - Terminal 2: an echo client, printing received messages produced
5768 - Terminal 2: a console client, waiting for input on the console
5769 (standard in) and sending text to APEX
5771 .. container:: paragraph
5773 We started the engine with the VPN policy example. So all the
5774 events we are using now are located in files in the following
5777 .. container:: listingblock
5779 .. container:: content
5784 #: $APEX_HOME/examples/events/VPN
5785 > %APEX_HOME%\examples\events\VPN
5787 .. container:: paragraph
5789 To sends events, simply copy the content of the event files into
5790 Terminal 3 (the console client). It will read multi-line JSON text
5791 and send the events. So copy the content of ``SetupEvents.json`` into
5792 the client. APEX will trigger a policy and produce some output, the
5793 echo client will also print some events created in the policy. In
5794 Terminal 1 (APEX) you’ll see some status messages from the policy as:
5796 .. container:: listingblock
5798 .. container:: content
5803 {Link=L09, LinkUp=true}
5805 outFields: {Link=L09, LinkUp=true}
5806 {Link=L10, LinkUp=true}
5809 outFields: {Link=L10, LinkUp=true}
5810 {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5812 C 300 300 [L09, L10]
5813 outFields: {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5814 {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5817 C 300 300 [L09, L10]
5818 outFields: {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5819 {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5822 C 300 300 [L09, L10]
5823 D 300 400 [L09, L10]
5824 outFields: {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5825 {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5828 B 300 299 [L09, L10]
5829 C 300 300 [L09, L10]
5830 D 300 400 [L09, L10]
5831 outFields: {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5833 .. container:: paragraph
5835 In Terminal 2 (echo-client) you see the received events, the last two
5838 .. container:: listingblock
5840 .. container:: content
5845 ws-simple-echo: received
5846 ---------------------------------
5848 "name": "VPNCustomerCtxtActEvent",
5850 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5853 "CustomerName": "C",
5854 "LinkList": "L09 L10",
5858 =================================
5860 ws-simple-echo: received
5861 ---------------------------------
5863 "name": "VPNCustomerCtxtActEvent",
5865 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5868 "CustomerName": "D",
5869 "LinkList": "L09 L10",
5873 =================================
5875 .. container:: paragraph
5877 Congratulations, you have triggered a policy in APEX using
5878 Websockets, the policy did run through, created events, picked up by
5881 .. container:: paragraph
5883 Now you can send the Link 09 and Link 10 events, they will trigger
5884 the actual VPN policy and some calculations are made. Let’s take the
5885 Link 09 events from ``Link09Events.json``, copy them all into
5886 Terminal 3 (the console). APEX will run the policy (with some status
5887 output), and the echo client will receive and print events.
5889 .. container:: paragraph
5891 To terminate the applications, simply press ``CTRL+C`` in Terminal 1
5892 (APEX). This will also terminate the echo-client in Terminal 2. Then
5893 type ``exit<enter>`` in Terminal 3 (or ``CTRL+C``) to terminate the