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 |
238 | -rwxrwx---+ 1 esvevan Domain Users 772 Sep 3 11:55 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes* |
239 | -rwxrwx---+ 1 esvevan Domain Users 146328082 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT.deb* |
240 | -rwxrwx---+ 1 esvevan Domain Users 15633 Sep 3 11:54 apex-pdp-package-full-2.0.0-SNAPSHOT.jar* |
241 | -rwxrwx---+ 1 esvevan Domain Users 146296819 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz* |
242 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 archive-tmp/ |
243 | -rwxrwx---+ 1 esvevan Domain Users 89 Sep 3 11:54 checkstyle-cachefile* |
244 | -rwxrwx---+ 1 esvevan Domain Users 10621 Sep 3 11:54 checkstyle-checker.xml* |
245 | -rwxrwx---+ 1 esvevan Domain Users 584 Sep 3 11:54 checkstyle-header.txt* |
246 | -rwxrwx---+ 1 esvevan Domain Users 86 Sep 3 11:54 checkstyle-result.xml* |
247 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 classes/ |
248 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 dependency-maven-plugin-markers/ |
249 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 etc/ |
250 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 examples/ |
251 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:55 install_hierarchy/ |
252 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 maven-archiver/ |
253 +---------------------------------------------------------------------------------------------------------------------+
255 +----------------------------------------------------------------------------------------------+
257 +==============================================================================================+
260 | .. container:: listingblock |
262 | .. container:: content |
267 | 03/09/2018 11:55 <DIR> . |
268 | 03/09/2018 11:55 <DIR> .. |
269 | 03/09/2018 11:55 146,296,819 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz |
270 | 03/09/2018 11:55 146,328,082 apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
271 | 03/09/2018 11:54 15,633 apex-pdp-package-full-2.0.0-SNAPSHOT.jar |
272 | 03/09/2018 11:55 772 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes |
273 | 03/09/2018 11:54 <DIR> archive-tmp |
274 | 03/09/2018 11:54 89 checkstyle-cachefile |
275 | 03/09/2018 11:54 10,621 checkstyle-checker.xml |
276 | 03/09/2018 11:54 584 checkstyle-header.txt |
277 | 03/09/2018 11:54 86 checkstyle-result.xml |
278 | 03/09/2018 11:54 <DIR> classes |
279 | 03/09/2018 11:54 <DIR> dependency-maven-plugin-markers |
280 | 03/09/2018 11:54 <DIR> etc |
281 | 03/09/2018 11:54 <DIR> examples |
282 | 03/09/2018 11:55 <DIR> install_hierarchy |
283 | 03/09/2018 11:54 <DIR> maven-archiver |
284 | 8 File(s) 292,652,686 bytes |
285 | 9 Dir(s) 14,138,720,256 bytes free |
286 +----------------------------------------------------------------------------------------------+
291 .. container:: paragraph
293 APEX can be installed in different ways:
297 - Unix: automatically using ``dpkg`` from
300 - Windows, Unix, Cygwin: manually from a ``.tar.gz`` archive
302 - Windows, Unix, Cygwin: build from source using Maven, then
308 .. container:: paragraph
310 You can get the APEX debian package from the
311 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
313 The install distributions of APEX automatically install the
314 system. The installation directory is
315 ``/opt/app/policy/apex-pdp``. Log files are located in
316 ``/var/log/onap/policy/apex-pdp``. The latest APEX version will
317 be available as ``/opt/app/policy/apex-pdp/apex-pdp``.
319 .. container:: paragraph
321 For the installation, a new user ``apexuser`` and a new group
322 ``apexuser`` will be created. This user owns the installation
323 directories and the log file location. The user is also used by
324 the standard APEX start scripts to run APEX with this user’s
327 +-------------------------------------------------------------------------------+
328 | DPKG Installation |
329 +===============================================================================+
332 | .. container:: listingblock |
334 | .. container:: content |
339 | # sudo dpkg -i apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
340 | Selecting previously unselected package apex-uservice. |
341 | (Reading database ... 288458 files and directories currently installed.) |
342 | Preparing to unpack apex-pdp-package-full-2.0.0-SNAPSHOT.deb ... |
343 | ********************preinst******************* |
344 | arguments install |
345 | ********************************************** |
346 | creating group apexuser . . . |
347 | creating user apexuser . . . |
348 | Unpacking apex-uservice (2.0.0-SNAPSHOT) ... |
349 | Setting up apex-uservice (2.0.0-SNAPSHOT) ... |
350 | ********************postinst**************** |
351 | arguments configure |
352 | *********************************************** |
353 +-------------------------------------------------------------------------------+
355 .. container:: paragraph
357 Once the installation is finished, APEX is fully installed and ready
360 Install Manually from Archive (Unix, Cygwin)
361 ############################################
363 .. container:: paragraph
365 You can download a ``tar.gz`` archive from the
366 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
368 Create a directory where APEX
369 should be installed. Extract the ``tar`` archive. The following
370 example shows how to install APEX in ``/opt/apex`` and create a
371 link to ``/opt/apex/apex`` for the most recent installation.
373 .. container:: listingblock
375 .. container:: content
383 # mkdir apex-full-2.0.0-SNAPSHOT
384 # tar xvfz ~/Downloads/apex-pdp-package-full-2.0.0-SNAPSHOT.tar.gz -C apex-full-2.0.0-SNAPSHOT
385 # ln -s apex apex-pdp-package-full-2.0.0-SNAPSHOT
387 Install Manually from Archive (Windows, 7Zip, GUI)
388 ##################################################
390 .. container:: paragraph
392 You can download a ``tar.gz`` archive from the
393 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
395 Copy the ``tar.gz`` file into the install
396 folder (in this example ``C:\apex``). Assuming you are using 7Zip,
397 right click on the file and extract the ``tar`` archive. Note: the
398 screenshots might show an older version than you have.
400 Now, right-click on the new created TAR file and extract the actual
401 APEX distribution. Inside the new APEX folder you will see the main directories: ``bin``,
402 ``etc``, ``examples``, ``lib``, and ``war``
404 .. container:: paragraph
406 Once extracted, please rename the created folder to
407 ``apex-full-2.0.0-SNAPSHOT``. This will keep the directory name in
408 line with the rest of this documentation.
410 Install Manually from Archive (Windows, 7Zip, CMD)
411 ##################################################
413 .. container:: paragraph
415 You can download a ``tar.gz`` archive from the
416 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
418 Copy the ``tar.gz`` file into the install
419 folder (in this example ``C:\apex``). Start ``cmd``, for instance
420 typing ``Windows+R`` and then ``cmd`` in the dialog. Assuming
421 ``7Zip`` is installed in the standard folder, simply run the
422 following commands (for APEX version 2.0.0-SNAPSHOT full
425 .. container:: listingblock
427 .. container:: content
434 >"\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"
436 .. container:: paragraph
438 APEX is now installed in the folder
439 ``C:\apex\apex-full-2.0.0-SNAPSHOT``.
444 Build and Install Manually (Unix, Windows, Cygwin)
445 ##################################################
447 .. container:: paragraph
449 Clone the APEX GIT repositories into a directory. Go to that
450 directory. Use Maven to build APEX (all details on building
451 APEX from source can be found in *APEX HowTo: Build*). Install
452 from the created artifacts (``rpm``, ``deb``, ``tar.gz``, or
455 .. container:: paragraph
457 The following example shows how to build the APEX system,
458 without tests (``-DskipTests``) to safe some time. It assumes
459 that the APX GIT repositories are cloned to:
463 - Unix, Cygwin: ``/usr/local/src/apex``
465 - Windows: ``C:\dev\apex``
467 +-------------------------------------------------------+--------------------------------------------------------+
468 | Unix, Cygwin | Windows |
469 +=======================================================+========================================================+
470 | .. container:: | .. container:: |
472 | .. container:: content | .. container:: content |
474 | .. code:: | .. code:: |
475 | :number-lines: | :number-lines: |
477 | # cd /usr/local/src/apex | >c: |
478 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
479 | | >mvn clean install -Pdocker -DskipTests |
480 +-------------------------------------------------------+--------------------------------------------------------+
482 .. container:: paragraph
484 The build takes about 2 minutes without test and about 4-5 minutes
485 with tests on a standard development laptop. It should run through
486 without errors, but with a lot of messages from the build process. If
487 build with tests (i.e. without ``-DskipTests``), there will be error
488 messages and stack trace prints from some tests. This is normal, as
489 long as the build finishes successful.
491 .. container:: paragraph
493 When Maven is finished with the build, the final screen should look
494 similar to this (omitting some ``success`` lines):
496 .. container:: listingblock
498 .. container:: content
503 [INFO] tools .............................................. SUCCESS [ 0.248 s]
504 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
505 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
506 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
507 [INFO] packages ........................................... SUCCESS [ 0.336 s]
508 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
509 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
510 [INFO] ------------------------------------------------------------------------
512 [INFO] ------------------------------------------------------------------------
513 [INFO] Total time: 03:43 min
514 [INFO] Finished at: 2018-09-03T11:56:01+01:00
515 [INFO] ------------------------------------------------------------------------
517 .. container:: paragraph
519 The build will have created all artifacts required for an APEX
520 installation. The following example show how to change to the target
521 directory and how it should look like.
523 +--------------------------------------------------------------------------------------------------------------------+
525 +====================================================================================================================+
528 | .. container:: listingblock |
533 | # cd packages/apex-pdp-package-full/target |
535 | -rwxrwx---+ 1 esvevan Domain Users 772 Sep 3 11:55 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes* |
536 | -rwxrwx---+ 1 esvevan Domain Users 146328082 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT.deb* |
537 | -rwxrwx---+ 1 esvevan Domain Users 15633 Sep 3 11:54 apex-pdp-package-full-2.0.0-SNAPSHOT.jar* |
538 | -rwxrwx---+ 1 esvevan Domain Users 146296819 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz* |
539 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 archive-tmp/ |
540 | -rwxrwx---+ 1 esvevan Domain Users 89 Sep 3 11:54 checkstyle-cachefile* |
541 | -rwxrwx---+ 1 esvevan Domain Users 10621 Sep 3 11:54 checkstyle-checker.xml* |
542 | -rwxrwx---+ 1 esvevan Domain Users 584 Sep 3 11:54 checkstyle-header.txt* |
543 | -rwxrwx---+ 1 esvevan Domain Users 86 Sep 3 11:54 checkstyle-result.xml* |
544 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 classes/ |
545 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 dependency-maven-plugin-markers/ |
546 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 etc/ |
547 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 examples/ |
548 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:55 install_hierarchy/ |
549 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 maven-archiver/ |
550 +--------------------------------------------------------------------------------------------------------------------+
552 +---------------------------------------------------------------------------------------------+
554 +=============================================================================================+
557 | .. container:: listingblock |
562 | >cd packages\apex-pdp-package-full\target |
564 | 03/09/2018 11:55 <DIR> . |
565 | 03/09/2018 11:55 <DIR> .. |
566 | 03/09/2018 11:55 146,296,819 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz |
567 | 03/09/2018 11:55 146,328,082 apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
568 | 03/09/2018 11:54 15,633 apex-pdp-package-full-2.0.0-SNAPSHOT.jar |
569 | 03/09/2018 11:55 772 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes |
570 | 03/09/2018 11:54 <DIR> archive-tmp |
571 | 03/09/2018 11:54 89 checkstyle-cachefile |
572 | 03/09/2018 11:54 10,621 checkstyle-checker.xml |
573 | 03/09/2018 11:54 584 checkstyle-header.txt |
574 | 03/09/2018 11:54 86 checkstyle-result.xml |
575 | 03/09/2018 11:54 <DIR> classes |
576 | 03/09/2018 11:54 <DIR> dependency-maven-plugin-markers |
577 | 03/09/2018 11:54 <DIR> etc |
578 | 03/09/2018 11:54 <DIR> examples |
579 | 03/09/2018 11:55 <DIR> install_hierarchy |
580 | 03/09/2018 11:54 <DIR> maven-archiver |
581 | 8 File(s) 292,652,686 bytes |
582 | 9 Dir(s) 14,138,720,256 bytes free |
583 +---------------------------------------------------------------------------------------------+
585 .. container:: paragraph
587 Now, take the ``.deb`` or the ``.tar.gz`` file and install APEX.
588 Alternatively, copy the content of the folder ``install_hierarchy``
589 to your APEX directory.
594 .. container:: paragraph
596 A full installation of APEX comes with the following layout.
598 .. container:: listingblock
600 .. container:: content
619 │ └───applications (11)
622 .. container:: colist arabic
624 +-----------------------------------+-----------------------------------+
625 | **1** | binaries, mainly scripts (bash |
626 | | and bat) to start the APEX engine |
627 | | and applications |
628 +-----------------------------------+-----------------------------------+
629 | **2** | configuration files, such as |
630 | | logback (logging) and third party |
631 | | library configurations |
632 +-----------------------------------+-----------------------------------+
633 | **3** | example policy models to get |
635 +-----------------------------------+-----------------------------------+
636 | **4** | configurations for the examples |
637 | | (with sub directories for |
638 | | individual examples) |
639 +-----------------------------------+-----------------------------------+
640 | **5** | Docker files and additional |
641 | | Docker instructions for the |
643 +-----------------------------------+-----------------------------------+
644 | **6** | example events for the examples |
645 | | (with sub directories for |
646 | | individual examples) |
647 +-----------------------------------+-----------------------------------+
648 | **7** | HTML files for some examples, |
649 | | e.g. the Decisionmaker example |
650 +-----------------------------------+-----------------------------------+
651 | **8** | the policy models, generated for |
652 | | each example (with sub |
653 | | directories for individual |
655 +-----------------------------------+-----------------------------------+
656 | **9** | additional scripts for the |
657 | | examples (with sub directories |
658 | | for individual examples) |
659 +-----------------------------------+-----------------------------------+
660 | **10** | the library folder with all Java |
662 +-----------------------------------+-----------------------------------+
663 | **11** | applications, also known as jar |
664 | | with dependencies (or fat jars), |
665 | | individually deployable |
666 +-----------------------------------+-----------------------------------+
667 | **12** | WAR files for web applications |
668 +-----------------------------------+-----------------------------------+
673 .. container:: paragraph
675 Once APEX is installed, a few configurations need to be done:
679 - Create an APEX user and an APEX group (optional, if not
680 installed using RPM and DPKG)
682 - Create environment settings for ``APEX_HOME`` and
683 ``APEX_USER``, required by the start scripts
685 - Change settings of the logging framework (optional)
687 - Create directories for logging, required (execution might fail
688 if directories do not exist or cannot be created)
693 .. container:: paragraph
695 On smaller installations and test systems, APEX can run as any
698 .. container:: paragraph
700 However, if APEX is installed in production, we strongly
701 recommend you set up a dedicated user for running APEX. This
702 will isolate the execution of APEX to that user. We recommend
703 you use the userid ``apexuser`` but you may use any user you
706 .. container:: paragraph
708 The following example, for UNIX, creates a group called
709 ``apexuser``, an APEX user called ``apexuser``, adds the group
710 to the user, and changes ownership of the APEX installation to
711 the user. Substitute ``<apex-dir>`` with the directory where
714 .. container:: listingblock
716 .. container:: content
721 # sudo groupadd apexuser
722 # sudo useradd -g apexuser apexuser
723 # sudo chown -R apexuser:apexuser <apex-dir>
725 .. container:: paragraph
727 For other operating systems please consult your manual or system
730 Environment Settings: APEX_HOME and APEX_USER
731 #############################################
733 .. container:: paragraph
735 The provided start scripts for APEX require two environment
740 - ``APEX_USER`` with the user under whos name and permission APEX
741 should be started (Unix only)
743 - ``APEX_HOME`` with the directory where APEX is installed (Unix,
746 .. container:: paragraph
748 The first row in the following table shows how to set these
749 environment variables temporary (assuming the user is
750 ``apexuser``). The second row shows how to verify the settings.
751 The last row explains how to set those variables permanently.
753 +------------------------------------------------+---------------------------------------------------------+
754 | Unix, Cygwin (bash/tcsh) | Windows |
755 +================================================+=========================================================+
756 | .. container:: | .. container:: |
758 | .. container:: content | .. container:: content |
760 | .. code:: | .. code:: |
761 | :number-lines: | :number-lines: |
763 | # export APEX_USER=apexuser | >set APEX_HOME=C:\apex\apex-full-2.0.0-SNAPSHOT |
764 | # cd /opt/app/policy/apex-pdp | |
765 | # export APEX_HOME=`pwd` | |
767 +------------------------------------------------+ |
770 | .. container:: content | |
775 | # setenv APEX_USER apexuser | |
776 | # cd /opt/app/policy/apex-pdp | |
777 | # setenv APEX_HOME `pwd` | |
779 +------------------------------------------------+---------------------------------------------------------+
780 | .. container:: | .. container:: |
782 | .. container:: content | .. container:: content |
784 | .. code:: | .. code:: |
785 | :number-lines: | :number-lines: |
787 | # env | grep APEX | >set APEX_HOME |
788 | # APEX_USER=apexuser | APEX_HOME=\apex\apex-full-2.0.0-SNAPSHOT |
789 | # APEX_HOME=/opt/app/policy/apex-pdp | |
791 +------------------------------------------------+---------------------------------------------------------+
793 Making Environment Settings Permanent (Unix, Cygwin)
794 ====================================================
796 .. container:: paragraph
798 For a per-user setting, edit the a user’s ``bash`` or ``tcsh``
799 settings in ``~/.bashrc`` or ``~/.tcshrc``. For system-wide
800 settings, edit ``/etc/profiles`` (requires permissions).
802 Making Environment Settings Permanent (Windows)
803 ===============================================
805 .. container:: paragraph
811 - Click on the **Start** Menu
813 - Right click on **Computer**
815 - Select **Properties**
817 .. container:: paragraph
823 - Click on the **Start** Menu
827 .. container:: paragraph
829 Then do the following
833 - Select **Advanced System Settings**
835 - On the **Advanced** tab, click the **Environment Variables**
838 - Edit an existing variable, or create a new System variable:
839 'Variable name'="APEX_HOME", 'Variable
840 value'="C:\apex\apex-full-2.0.0-SNAPSHOT"
842 .. container:: paragraph
844 For the settings to take effect, an application needs to be
845 restarted (e.g. any open ``cmd`` window).
847 Edit the APEX Logging Settings
848 ##############################
850 .. container:: paragraph
852 Configure the APEX logging settings to your requirements, for
857 - change the directory where logs are written to, or
859 - change the log levels
861 .. container:: paragraph
863 Edit the file ``$APEX_HOME/etc/logback.xml`` for any required
864 changes. To change the log directory change the line
866 .. container:: paragraph
868 ``<property name="logDir" value="/var/log/onap/policy/apex-pdp/" />``
870 .. container:: paragraph
874 .. container:: paragraph
876 ``<property name="logDir" value="/PATH/TO/LOG/DIRECTORY/" />``
878 .. container:: paragraph
880 On Windows, it is recommended to change the log directory to:
882 .. container:: paragraph
884 ``<property name="logDir" value="C:/apex/apex-full-2.0.0-SNAPSHOT/logs" />``
886 .. container:: paragraph
888 Note: Be careful about when to use ``\`` vs. ``/`` as the path
891 Create Directories for Logging
892 ##############################
894 .. container:: paragraph
896 Make sure that the log directory exists. This is important when
897 APEX was installed manually or when the log directory was changed
898 in the settings (see above).
900 +-----------------------------------------------------------------------+-------------------------------------------------------+
901 | Unix, Cygwin | Windows |
902 +=======================================================================+=======================================================+
903 | .. container:: | .. container:: |
905 | .. container:: content | .. container:: content |
907 | .. code:: | .. code:: |
908 | :number-lines: | :number-lines: |
910 | sudo mkdir -p /var/log/onap/policy/apex-pdp | >mkdir C:\apex\apex-full-2.0.0-SNAPSHOT\logs |
911 | sudo chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp | |
912 +-----------------------------------------------------------------------+-------------------------------------------------------+
914 Verify the APEX Installation
915 ----------------------------
917 .. container:: paragraph
919 When APEX is installed and all settings are realized, the
920 installation can be verified.
922 Verify Installation - run Engine
923 ################################
925 .. container:: paragraph
927 A simple verification of an APEX installation can be done by
928 simply starting the APEX engine without specifying a tosca policy. On
929 Unix (or Cygwin) start the engine using
930 ``$APEX_HOME/bin/apexApps.sh engine``. On Windows start the engine
931 using ``%APEX_HOME%\bin\apexApps.bat engine``. The engine will fail
932 to fully start. However, if the output looks similar to the
933 following line, the APEX installation is realized.
935 .. container:: listingblock
937 .. container:: content
942 Starting Apex service with parameters [] . . .
943 start of Apex service failed.
944 org.onap.policy.apex.model.basicmodel.concepts.ApexException: Arguments validation failed.
945 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:238)
946 at org.onap.policy.apex.service.engine.main.ApexMain.<init>(ApexMain.java:86)
947 at org.onap.policy.apex.service.engine.main.ApexMain.main(ApexMain.java:351)
948 Caused by: org.onap.policy.apex.model.basicmodel.concepts.ApexException: Tosca Policy file was not specified as an argument
949 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validateReadableFile(ApexCommandLineArguments.java:242)
950 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validate(ApexCommandLineArguments.java:172)
951 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:235)
952 ... 2 common frames omitted
954 Verify Installation - run an Example
955 ####################################
957 .. container:: paragraph
959 A full APEX installation comes with several examples. Here, we can
960 fully verify the installation by running one of the examples.
962 .. container:: paragraph
964 We use the example called *SampleDomain* and configure the engine
965 to use standard in and standard out for events. Run the engine
966 with the provided configuration. Note: Cygwin executes scripts as
967 Unix scripts but runs Java as a Windows application, thus the
968 configuration file must be given as a Windows path.
970 .. container:: paragraph
972 On Unix/Linux flavoured platforms, give the commands below:
974 .. container:: listingblock
976 .. container:: content
982 export APEX_HOME <path to apex installation>
983 export APEX_USER apexuser
985 .. container:: paragraph
987 Create a Tosca Policy for the SampleDomain example using ApexCliToscaEditor
988 as explained in the section "The APEX CLI Tosca Editor". Assume the tosca policy name is SampleDomain_tosca.json.
989 You can then try to run apex using the ToscaPolicy.
991 .. container:: listingblock
993 .. container:: content
998 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/examples/SampleDomain_tosca.json (1)
999 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\examples\SampleDomain_tosca.json(2)
1001 .. container:: colist arabic
1009 .. container:: paragraph
1011 The engine should start successfully. Assuming the logging levels are set to ``info`` in the built system, the output
1012 should look similar to this (last few lines)
1014 .. container:: listingblock
1016 .. container:: content
1021 Starting Apex service with parameters [-p, /home/ubuntu/apex/SampleDomain_tosca.json] . . .
1022 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 .
1023 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 .
1024 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 .
1025 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 .
1026 2018-09-05 15:16:42,805 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - APEX service created.
1027 2018-09-05 15:16:43,962 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging starting . . .
1028 2018-09-05 15:16:43,963 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging started
1029 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
1030 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
1031 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
1032 2018-09-05 15:16:45,113 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-3:0.0.1
1033 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
1034 Started Apex service
1036 .. container:: paragraph
1038 Important are the last two line, stating that APEX has added the
1039 final action listener to the engine and that the engine is started.
1041 .. container:: paragraph
1043 The engine is configured to read events from standard input and write
1044 produced events to standard output. The policy model is a very simple
1047 .. container:: paragraph
1049 The following table shows an input event in the left column and an
1050 output event in the right column. Past the input event into the
1051 console where APEX is running, and the output event should appear in
1052 the console. Pasting the input event multiple times will produce
1053 output events with different values.
1055 +----------------------------------------------------------+----------------------------------------------------------+
1056 | Input Event | Example Output Event |
1057 +==========================================================+==========================================================+
1058 | .. container:: | .. container:: |
1060 | .. container:: content | .. container:: content |
1062 | .. code:: | .. code:: |
1063 | :number-lines: | :number-lines: |
1066 | "nameSpace": "org.onap.policy.apex.sample.events", | "name": "Event0004", |
1067 | "name": "Event0000", | "version": "0.0.1", |
1068 | "version": "0.0.1", | "nameSpace": "org.onap.policy.apex.sample.events", |
1069 | "source": "test", | "source": "Act", |
1070 | "target": "apex", | "target": "Outside", |
1071 | "TestSlogan": "Test slogan for External Event0", | "TestActCaseSelected": 2, |
1072 | "TestMatchCase": 0, | "TestActStateTime": 1536157104627, |
1073 | "TestTimestamp": 1469781869269, | "TestDecideCaseSelected": 0, |
1074 | "TestTemperature": 9080.866 | "TestDecideStateTime": 1536157104625, |
1075 | } | "TestEstablishCaseSelected": 0, |
1076 | | "TestEstablishStateTime": 1536157104623, |
1077 | | "TestMatchCase": 0, |
1078 | | "TestMatchCaseSelected": 1, |
1079 | | "TestMatchStateTime": 1536157104620, |
1080 | | "TestSlogan": "Test slogan for External Event0", |
1081 | | "TestTemperature": 9080.866, |
1082 | | "TestTimestamp": 1469781869269 |
1084 +----------------------------------------------------------+----------------------------------------------------------+
1086 .. container:: paragraph
1088 Terminate APEX by simply using ``CTRL+C`` in the console.
1090 Verify a Full Installation - REST Client
1091 ########################################
1093 .. container:: paragraph
1095 APEX has a REST application for deploying, monitoring, and viewing policy models. The
1096 application can also be used to create new policy models close to
1097 the engine native policy language. Start the REST client as
1100 .. container:: listingblock
1102 .. container:: content
1107 # $APEX_HOME/bin/apexApps.sh full-client
1109 .. container:: listingblock
1111 .. container:: content
1116 >%APEX_HOME%\bin\apexApps.bat full-client
1118 .. container:: paragraph
1120 The script will start a simple web server
1121 (`Grizzly <https://javaee.github.io/grizzly/>`__) and deploy a
1122 ``war`` web archive in it. Once the client is started, it will be
1123 available on ``localhost:18989``. The last few line of the messages
1126 .. container:: listingblock
1128 .. container:: content
1133 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
1134 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.NetworkListener start
1135 INFO: Started listener bound to [localhost:18989]
1136 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.HttpServer start
1137 INFO: [HttpServer] Started.
1138 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
1141 .. container:: paragraph
1143 Now open a browser (Firefox, Chrome, Opera, Internet Explorer) and
1144 use the URL ``http://localhost:18989/``. This will connect the
1145 browser to the started REST client. Click on the "Policy Editor" button and the Policy Editor start screen should appear.
1147 .. container:: paragraph
1149 Now load a policy model by clicking the menu ``File`` and then
1150 ``Open``. In the opened dialog, go to the directory where APEX is
1151 installed, then ``examples``, ``models``, ``SampleDomain``, and there
1152 select the file ``SamplePolicyModelJAVA.json``. This will load the
1153 policy model used to verify the policy engine (see above).
1155 .. container:: paragraph
1157 Now you can use the Policy editor. To finish this verification, simply
1158 terminate your browser (or the tab), and then use ``CTRL+C`` in the
1159 console where you started the Policy editor.
1161 Installing the WAR Application
1162 ------------------------------
1164 .. container:: paragraph
1166 The three APEX clients are packaged in a WAR file. This is a complete
1167 application that can be installed and run in an application
1168 server. The application is realized as a servlet. You
1169 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/>`__.
1172 .. container:: paragraph
1174 Installing and using the WAR application requires a web server
1175 that can execute ``war`` web archives. We recommend to use `Apache
1176 Tomcat <https://tomcat.apache.org/>`__, however other web servers
1177 can be used as well.
1179 .. container:: paragraph
1181 Install Apache Tomcat including the ``Manager App``, see `V9.0
1182 Docs <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html#Configuring_Manager_Application_Access>`__
1183 for details. Start the Tomcat service, or make sure that Tomcat is
1186 .. container:: paragraph
1188 There are multiple ways to install the APEX WAR application:
1190 .. container:: ulist
1192 - copy the ``.war`` file into the Tomcat ``webapps`` folder
1194 - use the Tomcat ``Manager App`` to deploy via the web interface
1196 - deploy using a REST call to Tomcat
1198 .. container:: paragraph
1200 For details on how to install ``war`` files please consult the
1202 Documentation <https://tomcat.apache.org/tomcat-9.0-doc/index.html>`__
1204 HOW-TO <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html>`__.
1205 Once you installed an APEX WAR application (and wait for
1206 sufficient time for Tomcat to finalize the installation), open the
1207 ``Manager App`` in Tomcat. You should see the APEX WAR application
1208 being installed and running.
1210 .. container:: paragraph
1212 In case of errors, examine the log files in the Tomcat log
1213 directory. In a conventional install, those log files are in the
1214 logs directory where Tomcat is installed.
1216 .. container:: paragraph
1218 The WAR application file has a name similar to *apex-client-full-<VERSION>.war*.
1220 Running APEX in Docker
1221 ----------------------
1223 .. container:: paragraph
1225 Since APEX is in ONAP, we provide a full virtualization
1226 environment for the engine.
1231 .. container:: paragraph
1233 Running APEX from the ONAP docker repository only requires 2
1236 1. Log into the ONAP docker repo
1238 .. container:: listingblock
1240 .. container:: content
1244 docker login -u docker -p docker nexus3.onap.org:10003
1246 2. Run the APEX docker image
1248 .. container:: listingblock
1250 .. container:: content
1254 docker run -it --rm nexus3.onap.org:10003/onap/policy-apex-pdp:latest
1256 Build a Docker Image
1257 ####################
1259 .. container:: paragraph
1261 Alternatively, one can use the Dockerfile defined in the Docker
1262 package to build an image.
1264 .. container:: listingblock
1266 .. container:: title
1270 .. container:: content
1276 # Docker file to build an image that runs APEX on Java 8 in Ubuntu
1280 RUN apt-get update && \
1281 apt-get upgrade -y && \
1282 apt-get install -y software-properties-common && \
1283 add-apt-repository ppa:openjdk-r/ppa -y && \
1285 apt-get install -y openjdk-8-jdk
1287 # Create apex user and group
1288 RUN groupadd apexuser
1289 RUN useradd --create-home -g apexuser apexuser
1291 # Add Apex-specific directories and set ownership as the Apex admin user
1292 RUN mkdir -p /opt/app/policy/apex-pdp
1293 RUN mkdir -p /var/log/onap/policy/apex-pdp
1294 RUN chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp
1296 # Unpack the tarball
1298 COPY apex-pdp-package-full.tar.gz /packages
1299 RUN tar xvfz /packages/apex-pdp-package-full.tar.gz --directory /opt/app/policy/apex-pdp
1300 RUN rm /packages/apex-pdp-package-full.tar.gz
1302 # Ensure everything has the correct permissions
1303 RUN find /opt/app -type d -perm 755
1304 RUN find /opt/app -type f -perm 644
1305 RUN chmod a+x /opt/app/policy/apex-pdp/bin/*
1307 # Copy examples to Apex user area
1308 RUN cp -pr /opt/app/policy/apex-pdp/examples /home/apexuser
1312 RUN chown -R apexuser:apexuser /home/apexuser/*
1315 ENV PATH /opt/app/policy/apex-pdp/bin:$PATH
1316 WORKDIR /home/apexuser
1318 Running APEX in Standalone mode
1319 -------------------------------
1321 .. container:: paragraph
1323 APEX Engine can run in standalone mode by taking in a ToscaPolicy
1324 as an argument and executing it.
1325 Assume there is a tosca policy named ToscaPolicy.json in APEX_HOME directory
1326 This policy can be executed in standalone mode using any of the below methods.
1328 Run in an APEX installation
1329 ###########################
1331 .. container:: listingblock
1333 .. container:: content
1338 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/ToscaPolicy.json(1)
1339 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\ToscaPolicy.json(2)
1341 .. container:: colist arabic
1349 Run in a docker container
1350 #########################
1352 .. container:: listingblock
1354 .. container:: content
1359 # docker run -p 6969:6969 -v $APEX_HOME/ToscaPolicy.json:/tmp/policy/ToscaPolicy.json \
1360 --name apex -it nexus3.onap.org:10001/onap/policy-apex-pdp:latest \
1361 -c "/opt/app/policy/apex-pdp/bin/apexEngine.sh -p /tmp/policy/ToscaPolicy.json"
1363 APEX Configurations Explained
1364 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1366 Introduction to APEX Configuration
1367 ----------------------------------
1369 .. container:: paragraph
1371 An APEX engine can be configured to use various combinations
1372 of event input handlers, event output handlers, event
1373 protocols, context handlers, and logic executors. The system
1374 is build using a plugin architecture. Each configuration
1375 option is realized by a plugin, which can be loaded and
1376 configured when the engine is started. New plugins can be
1377 added to the system at any time, though to benefit from a
1378 new plugin an engine will need to be restarted.
1380 .. container:: imageblock
1382 .. container:: content
1384 .. image:: images/apex-intro/ApexEngineConfig.png
1386 .. container:: title
1388 Figure 3. APEX Configuration Matrix
1390 .. container:: paragraph
1392 The APEX distribution already comes with a number of
1393 plugins. The figure above shows the provided plugins. Any
1394 combination of input, output, event protocol, context
1395 handlers, and executors is possible.
1397 General Configuration Format
1398 ----------------------------
1400 .. container:: paragraph
1402 The APEX configuration file is a JSON file containing a few
1403 main blocks for different parts of the configuration. Each
1404 block then holds the configuration details. The following
1405 code shows the main blocks:
1407 .. container:: listingblock
1409 .. container:: content
1414 "engineServiceParameters":{
1416 "engineParameters":{ (2)
1417 "executorParameters":{...}, (3)
1418 "contextParameters":{...} (4)
1419 "taskParameters":[...] (5)
1422 "eventInputParameters":{ (6)
1424 "carrierTechnologyParameters":{...},
1425 "eventProtocolParameters":{...}
1428 "carrierTechnologyParameters":{...},
1429 "eventProtocolParameters":{...}
1433 "eventOutputParameters":{ (10)
1435 "carrierTechnologyParameters":{...},
1436 "eventProtocolParameters":{...}
1439 "carrierTechnologyParameters":{...},
1440 "eventProtocolParameters":{...}
1446 .. container:: colist arabic
1448 +-----------------------------------+-----------------------------------+
1449 | **1** | main engine configuration |
1450 +-----------------------------------+-----------------------------------+
1451 | **2** | engine parameters for plugin |
1452 | | configurations (execution |
1453 | | environments and context |
1455 +-----------------------------------+-----------------------------------+
1456 | **3** | engine specific parameters, |
1457 | | mainly for executor plugins |
1458 +-----------------------------------+-----------------------------------+
1459 | **4** | context specific parameters, e.g. |
1460 | | for context schemas, persistence, |
1462 +-----------------------------------+-----------------------------------+
1463 | **5** | list of task parameters that |
1464 | | should be made available in task |
1465 | | logic (optional). |
1466 +-----------------------------------+-----------------------------------+
1467 | **6** | configuration of the input |
1469 +-----------------------------------+-----------------------------------+
1470 | **7** | an example input called |
1471 | | ``input1`` with carrier |
1472 | | technology and event protocol |
1473 +-----------------------------------+-----------------------------------+
1474 | **8** | an example input called |
1475 | | ``input2`` with carrier |
1476 | | technology and event protocol |
1477 +-----------------------------------+-----------------------------------+
1478 | **9** | any further input configuration |
1479 +-----------------------------------+-----------------------------------+
1480 | **10** | configuration of the output |
1482 +-----------------------------------+-----------------------------------+
1483 | **11** | an example output called |
1484 | | ``output1`` with carrier |
1485 | | technology and event protocol |
1486 +-----------------------------------+-----------------------------------+
1487 | **12** | an example output called |
1488 | | ``output2`` with carrier |
1489 | | technology and event protocol |
1490 +-----------------------------------+-----------------------------------+
1491 | **13** | any further output configuration |
1492 +-----------------------------------+-----------------------------------+
1494 Engine Service Parameters
1495 -------------------------
1497 .. container:: paragraph
1499 The configuration provides a number of parameters to
1500 configure the engine. An example configuration with
1501 explanations of all options is shown below.
1503 .. container:: listingblock
1505 .. container:: content
1509 "engineServiceParameters" : {
1510 "name" : "AADMApexEngine", (1)
1511 "version" : "0.0.1", (2)
1513 "instanceCount" : 4, (4)
1514 "deploymentPort" : 12345, (5)
1515 "policy_type_impl" : {...}, (6)
1516 "periodicEventPeriod": 1000, (7)
1517 "engineParameters":{ (8)
1518 "executorParameters":{...}, (9)
1519 "contextParameters":{...}, (10)
1520 "taskParameters":[...] (11)
1524 .. container:: colist arabic
1526 +-----------------------------------+-----------------------------------+
1527 | **1** | a name for the engine. The engine |
1528 | | name is used to create a key in a |
1529 | | runtime engine. An name matching |
1530 | | the following regular expression |
1531 | | can be used here: |
1532 | | ``[A-Za-z0-9\\-_\\.]+`` |
1533 +-----------------------------------+-----------------------------------+
1534 | **2** | a version of the engine, use |
1535 | | semantic versioning as explained |
1536 | | here: `Semantic |
1537 | | Versioning <http://semver.org/>`_ |
1539 | | This version is used in a runtime |
1540 | | engine to create a version of the |
1541 | | engine. For that reason, the |
1542 | | version must match the following |
1543 | | regular expression ``[A-Z0-9.]+`` |
1544 +-----------------------------------+-----------------------------------+
1545 | **3** | a numeric identifier for the |
1547 +-----------------------------------+-----------------------------------+
1548 | **4** | the number of threads (policy |
1549 | | instances executed in parallel) |
1550 | | the engine should use, use ``1`` |
1551 | | for single threaded engines |
1552 +-----------------------------------+-----------------------------------+
1553 | **5** | the port for the deployment |
1554 | | Websocket connection to the |
1556 +-----------------------------------+-----------------------------------+
1557 | **6** | the APEX policy model as a JSON |
1558 | | or YAML block to load into the |
1559 | | engine on startup when |
1560 | | APEX is running a policy that has |
1561 | | its logic and parameters |
1562 | | specified in TOSCA |
1564 +-----------------------------------+-----------------------------------+
1565 | **7** | an optional timer for periodic |
1566 | | policies, in milliseconds (a |
1567 | | defined periodic policy will be |
1568 | | executed every ``X`` |
1569 | | milliseconds), not used of not |
1571 +-----------------------------------+-----------------------------------+
1572 | **8** | engine parameters for plugin |
1573 | | configurations (execution |
1574 | | environments and context |
1576 +-----------------------------------+-----------------------------------+
1577 | **9** | engine specific parameters, |
1578 | | mainly for executor plugins |
1579 +-----------------------------------+-----------------------------------+
1580 | **10** | context specific parameters, e.g. |
1581 | | for context schemas, persistence, |
1583 +-----------------------------------+-----------------------------------+
1584 | **11** | list of task parameters that |
1585 | | should be made available in task |
1586 | | logic (optional). |
1587 +-----------------------------------+-----------------------------------+
1589 .. container:: paragraph
1591 The model file is optional, it can also be specified via
1592 command line. In any case, make sure all execution and other
1593 required plug-ins for the loaded model are loaded as
1596 Input and Output Interfaces
1597 ---------------------------
1599 .. container:: paragraph
1601 An APEX engine has two main interfaces:
1603 .. container:: ulist
1605 - An *input* interface to receive events: also known as
1606 ingress interface or consumer, receiving (consuming)
1607 events commonly named triggers, and
1609 - An *output* interface to publish produced events: also
1610 known as egress interface or producer, sending
1611 (publishing) events commonly named actions or action
1614 .. container:: paragraph
1616 The input and output interface is configured in terms of
1617 inputs and outputs, respectively. Each input and output is a
1618 combination of a carrier technology and an event protocol.
1619 Carrier technologies and event protocols are provided by
1620 plugins, each with its own specific configuration. Most
1621 carrier technologies can be configured for input as well as
1622 output. Most event protocols can be used for all carrier
1623 technologies. One exception is the JMS object event
1624 protocol, which can only be used for the JMS carrier
1625 technology. Some further restrictions apply (for instance
1626 for carrier technologies using bi- or uni-directional
1629 .. container:: paragraph
1631 Input and output interface can be configured separately, in
1632 isolation, with any number of carrier technologies. The
1633 resulting general configuration options are:
1635 .. container:: ulist
1637 - Input interface with one or more inputs
1639 .. container:: ulist
1641 - each input with a carrier technology and an event
1644 - some inputs with optional synchronous mode
1646 - some event protocols with additional parameters
1648 - Output interface with one or more outputs
1650 .. container:: ulist
1652 - each output with a carrier technology and an event
1655 - some outputs with optional synchronous mode
1657 - some event protocols with additional parameters
1659 .. container:: paragraph
1661 The configuration for input and output is contained in
1662 ``eventInputParameters`` and ``eventOutputParameters``,
1663 respectively. Inside here, one can configure any number of
1664 inputs and outputs. Each of them needs to have a unique
1665 identifier (name), the content of the name is free form. The
1666 example below shows a configuration for two inputs and two
1669 .. container:: listingblock
1671 .. container:: content
1675 "eventInputParameters": { (1)
1676 "FirstConsumer": { (2)
1677 "carrierTechnologyParameters" : {...}, (3)
1678 "eventProtocolParameters":{...}, (4)
1681 "SecondConsumer": { (6)
1682 "carrierTechnologyParameters" : {...}, (7)
1683 "eventProtocolParameters":{...}, (8)
1687 "eventOutputParameters": { (10)
1688 "FirstProducer": { (11)
1689 "carrierTechnologyParameters":{...}, (12)
1690 "eventProtocolParameters":{...}, (13)
1693 "SecondProducer": { (15)
1694 "carrierTechnologyParameters":{...}, (16)
1695 "eventProtocolParameters":{...}, (17)
1700 .. container:: colist arabic
1702 +--------+--------------------------------------------------------------------+
1703 | **1** | input interface configuration, APEX input plugins |
1704 +--------+--------------------------------------------------------------------+
1705 | **2** | first input called ``FirstConsumer`` |
1706 +--------+--------------------------------------------------------------------+
1707 | **3** | carrier technology for plugin |
1708 +--------+--------------------------------------------------------------------+
1709 | **4** | event protocol for plugin |
1710 +--------+--------------------------------------------------------------------+
1711 | **5** | any other input configuration (e.g. event name filter, see below) |
1712 +--------+--------------------------------------------------------------------+
1713 | **6** | second input called ``SecondConsumer`` |
1714 +--------+--------------------------------------------------------------------+
1715 | **7** | carrier technology for plugin |
1716 +--------+--------------------------------------------------------------------+
1717 | **8** | event protocol for plugin |
1718 +--------+--------------------------------------------------------------------+
1719 | **9** | any other plugin configuration |
1720 +--------+--------------------------------------------------------------------+
1721 | **10** | output interface configuration, APEX output plugins |
1722 +--------+--------------------------------------------------------------------+
1723 | **11** | first output called ``FirstProducer`` |
1724 +--------+--------------------------------------------------------------------+
1725 | **12** | carrier technology for plugin |
1726 +--------+--------------------------------------------------------------------+
1727 | **13** | event protocol for plugin |
1728 +--------+--------------------------------------------------------------------+
1729 | **14** | any other plugin configuration |
1730 +--------+--------------------------------------------------------------------+
1731 | **15** | second output called ``SecondProducer`` |
1732 +--------+--------------------------------------------------------------------+
1733 | **16** | carrier technology for plugin |
1734 +--------+--------------------------------------------------------------------+
1735 | **17** | event protocol for plugin |
1736 +--------+--------------------------------------------------------------------+
1737 | **18** | any other output configuration (e.g. event name filter, see below) |
1738 +--------+--------------------------------------------------------------------+
1743 .. container:: paragraph
1745 Any event defined in APEX has to be unique. The "name" of
1746 of an event is used as an identifier for an ApexEvent. Every
1747 event has to be tagged to an eventName. This can be done in different
1748 ways. Either the actual event can have a field called "name". Or, the
1749 event has some other field that can act as the identifier, which can be
1750 specified using "nameAlias". But in other cases, where a "name" or "nameAlias"
1751 cannot be specified, the incoming event coming over an endpoint can be
1752 manually tagged to an "eventName" before consuming it.
1754 .. container:: paragraph
1756 The "eventName" can have a single event's name if the event coming
1757 over the endpoint has to be always mapped to the specified eventName's
1758 definition. Otherwise, if different events can come over the endpoint,
1759 then "eventName" field can consist of multiple event names separated by
1760 "|" symbol. In this case, based on the received event's structure, it is
1761 mapped to any one of the event name specified in the "eventName" field.
1763 .. container:: paragraph
1765 The following code shows some examples on how to specify the eventName field:
1767 .. container:: listingblock
1769 .. container:: content
1773 "eventInputParameters": {
1775 "carrierTechnologyParameters" : {...},
1776 "eventProtocolParameters":{...},
1777 "eventName" : "VesEvent" (1)
1780 "carrierTechnologyParameters" : {...},
1781 "eventProtocolParameters":{...},
1782 "eventName" : "AAISuccessResponseEvent|AAIFailureResponseEvent" (2)
1789 .. container:: paragraph
1791 APEX will always send an event after a policy execution
1792 is finished. For a successful execution, the event sent
1793 is the output event created by the policy. In case the
1794 policy does not create an output event, APEX will create
1795 a new event with all input event fields plus an
1796 additional field ``exceptionMessage`` with an exception
1799 .. container:: paragraph
1801 There are situations in which this auto-generated error
1802 event might not be required or wanted:
1804 .. container:: ulist
1806 - when a policy failing should not result in an event
1807 send out via an output interface
1809 - when the auto-generated event goes back in an APEX
1810 engine (or the same APEX engine), this can create
1813 - the auto-generated event should go to a special output
1814 interface or channel
1816 .. container:: paragraph
1818 All of these situations are supported by a filter option
1819 using a wildecard (regular expression) configuration on
1820 APEX I/O interfaces. The parameter is called
1821 ``eventNameFilter`` and the value are `Java regular
1822 expressions <https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html>`__
1824 `tutorial <http://www.vogella.com/tutorials/JavaRegularExpressions/article.html>`__).
1825 The following code shows some examples:
1827 .. container:: listingblock
1829 .. container:: content
1833 "eventInputParameters": {
1835 "carrierTechnologyParameters" : {...},
1836 "eventProtocolParameters":{...},
1837 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]004$" (1)
1840 "eventOutputParameters": {
1842 "carrierTechnologyParameters":{...},
1843 "eventProtocolParameters":{...},
1844 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]104$" (2)
1851 .. container:: paragraph
1853 Executors are plugins that realize the execution of logic
1854 contained in a policy model. Logic can be in a task
1855 selector, a task, and a state finalizer. Using plugins for
1856 execution environments makes APEX very flexible to support
1857 virtually any executable logic expressions.
1859 .. container:: paragraph
1861 APEX 2.0.0-SNAPSHOT supports the following executors:
1863 .. container:: ulist
1865 - Java, for Java implemented logic
1867 .. container:: ulist
1869 - This executor requires logic implemented using the
1870 APEX Java interfaces.
1872 - Generated JAR files must be in the classpath of the
1873 APEX engine at start time.
1883 .. container:: ulist
1885 - This executor uses the latest version of the MVEL
1886 engine, which can be very hard to debug and can
1887 produce unwanted side effects during execution
1889 Configure the Javascript Executor
1890 #################################
1892 .. container:: paragraph
1894 The Javascript executor is added to the configuration as
1897 .. container:: listingblock
1899 .. container:: content
1903 "engineServiceParameters":{
1904 "engineParameters":{
1905 "executorParameters":{
1907 "parameterClassName" :
1908 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
1914 Configure the Jython Executor
1915 #############################
1917 .. container:: paragraph
1919 The Jython executor is added to the configuration as
1922 .. container:: listingblock
1924 .. container:: content
1928 "engineServiceParameters":{
1929 "engineParameters":{
1930 "executorParameters":{
1932 "parameterClassName" :
1933 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
1939 Configure the JRuby Executor
1940 ############################
1942 .. container:: paragraph
1944 The JRuby executor is added to the configuration as
1947 .. container:: listingblock
1949 .. container:: content
1953 "engineServiceParameters":{
1954 "engineParameters":{
1955 "executorParameters":{
1957 "parameterClassName" :
1958 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
1964 Configure the Java Executor
1965 ###########################
1967 .. container:: paragraph
1969 The Java executor is added to the configuration as
1972 .. container:: listingblock
1974 .. container:: content
1978 "engineServiceParameters":{
1979 "engineParameters":{
1980 "executorParameters":{
1982 "parameterClassName" :
1983 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
1989 Configure the MVEL Executor
1990 ###########################
1992 .. container:: paragraph
1994 The MVEL executor is added to the configuration as
1997 .. container:: listingblock
1999 .. container:: content
2003 "engineServiceParameters":{
2004 "engineParameters":{
2005 "executorParameters":{
2007 "parameterClassName" :
2008 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
2017 .. container:: paragraph
2019 Context handlers are responsible for all context processing.
2020 There are the following main areas:
2022 .. container:: ulist
2024 - Context schema: use schema handlers other than Java class
2025 (supported by default without configuration)
2027 - Context distribution: distribute context across multiple
2030 - Context locking: mechanisms to lock context elements for
2033 - Context persistence: mechanisms to persist context
2035 .. container:: paragraph
2037 APEX provides plugins for each of the main areas.
2039 Configure Context Schema Handler
2040 ################################
2042 .. container:: paragraph
2044 There are 2 choices available for defining schema: JSON & AVRO.
2045 JSON based schemas are recommended because of the flexibility, better tooling & easier integration.
2047 The JSON schema handler is added to the configuration as
2050 .. container:: listingblock
2052 .. container:: content
2056 "engineServiceParameters":{
2057 "engineParameters":{
2058 "contextParameters":{
2059 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2060 "schemaParameters":{
2062 "parameterClassName" :
2063 "org.onap.policy.apex.plugins.context.schema.json.JsonSchemaHelperParameters"
2070 The AVRO schema handler is added to the configuration as
2073 .. container:: listingblock
2075 .. container:: content
2079 "engineServiceParameters":{
2080 "engineParameters":{
2081 "contextParameters":{
2082 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2083 "schemaParameters":{
2085 "parameterClassName" :
2086 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
2093 .. container:: paragraph
2095 Using the AVRO schema handler has one limitation: AVRO
2096 only supports field names that represent valid Java class
2097 names. This means only letters and the character ``_``
2098 are supported. Characters commonly used in field names,
2099 such as ``.`` and ``-``, are not supported by AVRO. for
2100 more information see `Avro Spec:
2101 Names <https://avro.apache.org/docs/1.8.1/spec.html#names>`__.
2103 .. container:: paragraph
2105 To work with this limitation, the APEX Avro plugin will
2106 parse a given AVRO definition and replace *all*
2107 occurrences of ``.`` and ``-`` with a ``_``. This means
2110 .. container:: ulist
2112 - In a policy model, if the AVRO schema defined a field
2113 as ``my-name`` the policy logic should access it as
2116 - In a policy model, if the AVRO schema defined a field
2117 as ``my.name`` the policy logic should access it as
2120 - There should be no field names that convert to the
2123 .. container:: ulist
2125 - For instance the simultaneous use of
2126 ``my_name``, ``my.name``, and ``my-name`` should
2129 - If not avoided, the event processing might
2130 create unwanted side effects
2132 - If field names use any other not-supported character,
2133 the AVRO plugin will reject it
2135 .. container:: ulist
2137 - Since AVRO uses lazy initialization, this
2138 rejection might only become visible at runtime
2140 Configure Task Parameters
2141 #########################
2143 .. container:: paragraph
2145 The Task Parameters are added to the configuration as
2148 .. container:: listingblock
2150 .. container:: content
2154 "engineServiceParameters": {
2155 "engineParameters": {
2158 "key": "ParameterKey1",
2159 "value": "ParameterValue1"
2162 "taskId": "Task_Act0",
2163 "key": "ParameterKey2",
2164 "value": "ParameterValue2"
2170 .. container:: paragraph
2172 TaskParameters can be used to pass parameters from ApexConfig
2173 to the policy logic. In the config, these are optional.
2174 The list of task parameters provided in the config may be added
2175 to the tasks or existing task parameters in the task will be overriden.
2177 .. container:: paragraph
2179 If taskId is provided in ApexConfig for an entry, then that
2180 parameter is updated only for that particular task. Otherwise,
2181 the task parameter is added to all tasks.
2183 Carrier Technologies
2184 --------------------
2186 .. container:: paragraph
2188 Carrier technologies define how APEX receives (input) and
2189 sends (output) events. They can be used in any combination,
2190 using asynchronous or synchronous mode. There can also be
2191 any number of carrier technologies for the input (consume)
2192 and the output (produce) interface.
2194 .. container:: paragraph
2196 Supported *input* technologies are:
2198 .. container:: ulist
2200 - Standard input, read events from the standard input
2201 (console), not suitable for APEX background servers
2203 - File input, read events from a file
2205 - Kafka, read events from a Kafka system
2207 - Websockets, read events from a Websocket
2211 - REST (synchronous and asynchronous), additionally as
2214 - Event Requestor, allows reading of events that have been
2215 looped back into APEX
2217 .. container:: paragraph
2219 Supported *output* technologies are:
2221 .. container:: ulist
2223 - Standard output, write events to the standard output
2224 (console), not suitable for APEX background servers
2226 - File output, write events to a file
2228 - Kafka, write events to a Kafka system
2230 - Websockets, write events to a Websocket
2234 - REST (synchronous and asynchronous), additionally as
2237 - Event Requestor, allows events to be looped back into
2240 .. container:: paragraph
2242 New carrier technologies can be added as plugins to APEX or
2243 developed outside APEX and added to an APEX deployment.
2248 .. container:: paragraph
2250 Standard IO does not require a specific plugin, it is
2251 supported be default.
2255 .. container:: paragraph
2257 APEX will take events from its standard input. This
2258 carrier is good for testing, but certainly not for a
2259 use case where APEX runs as a server. The
2260 configuration is as follows:
2262 .. container:: listingblock
2264 .. container:: content
2268 "carrierTechnologyParameters" : {
2269 "carrierTechnology" : "FILE", (1)
2271 "standardIO" : true (2)
2275 .. container:: colist arabic
2277 +-------+---------------------------------------+
2278 | **1** | standard input is considered a file |
2279 +-------+---------------------------------------+
2280 | **2** | file descriptor set to standard input |
2281 +-------+---------------------------------------+
2286 .. container:: paragraph
2288 APEX will send events to its standard output. This
2289 carrier is good for testing, but certainly not for a
2290 use case where APEX runs as a server. The
2291 configuration is as follows:
2293 .. container:: listingblock
2295 .. container:: content
2299 "carrierTechnologyParameters" : {
2300 "carrierTechnology" : "FILE", (1)
2302 "standardIO" : true (2)
2306 .. container:: colist arabic
2308 +-------+----------------------------------------+
2309 | **1** | standard output is considered a file |
2310 +-------+----------------------------------------+
2311 | **2** | file descriptor set to standard output |
2312 +-------+----------------------------------------+
2317 .. container:: paragraph
2319 File IO does not require a specific plugin, it is
2320 supported be default.
2325 .. container:: paragraph
2327 APEX will take events from a file. The same file
2328 should not be used as an output. The configuration is
2331 .. container:: listingblock
2333 .. container:: content
2337 "carrierTechnologyParameters" : {
2338 "carrierTechnology" : "FILE", (1)
2340 "fileName" : "examples/events/SampleDomain/EventsIn.xmlfile" (2)
2344 .. container:: colist arabic
2346 +-------+------------------------------------------+
2347 | **1** | set file input |
2348 +-------+------------------------------------------+
2349 | **2** | the name of the file to read events from |
2350 +-------+------------------------------------------+
2354 .. container:: paragraph
2356 APEX will write events to a file. The same file should
2357 not be used as an input. The configuration is as
2360 .. container:: listingblock
2362 .. container:: content
2366 "carrierTechnologyParameters" : {
2367 "carrierTechnology" : "FILE", (1)
2369 "fileName" : "examples/events/SampleDomain/EventsOut.xmlfile" (2)
2373 .. container:: colist arabic
2375 +-------+-----------------------------------------+
2376 | **1** | set file output |
2377 +-------+-----------------------------------------+
2378 | **2** | the name of the file to write events to |
2379 +-------+-----------------------------------------+
2384 .. container:: paragraph
2386 Event Requestor IO does not require a specific plugin, it
2387 is supported be default. It should only be used with the
2388 APEX event protocol.
2390 Event Requestor Input
2391 =====================
2393 .. container:: paragraph
2395 APEX will take events from APEX.
2397 .. container:: listingblock
2399 .. container:: content
2403 "carrierTechnologyParameters" : {
2404 "carrierTechnology": "EVENT_REQUESTOR" (1)
2407 .. container:: colist arabic
2409 +-------+---------------------------+
2410 | **1** | set event requestor input |
2411 +-------+---------------------------+
2413 Event Requestor Output
2414 ======================
2416 .. container:: paragraph
2418 APEX will write events to APEX.
2420 .. container:: listingblock
2422 .. container:: content
2426 "carrierTechnologyParameters" : {
2427 "carrierTechnology": "EVENT_REQUESTOR" (1)
2430 Peering Event Requestors
2431 ========================
2433 .. container:: paragraph
2435 When using event requestors, they need to be peered.
2436 This means an event requestor output needs to be
2437 peered (associated) with an event requestor input. The
2438 following example shows the use of an event requestor
2439 with the APEX event protocol and the peering of output
2442 .. container:: listingblock
2444 .. container:: content
2448 "eventInputParameters": {
2449 "EventRequestorConsumer": {
2450 "carrierTechnologyParameters": {
2451 "carrierTechnology": "EVENT_REQUESTOR" (1)
2453 "eventProtocolParameters": {
2454 "eventProtocol": "APEX" (2)
2456 "eventNameFilter": "InputEvent", (3)
2457 "requestorMode": true, (4)
2458 "requestorPeer": "EventRequestorProducer", (5)
2459 "requestorTimeout": 500 (6)
2462 "eventOutputParameters": {
2463 "EventRequestorProducer": {
2464 "carrierTechnologyParameters": {
2465 "carrierTechnology": "EVENT_REQUESTOR" (7)
2467 "eventProtocolParameters": {
2468 "eventProtocol": "APEX" (8)
2470 "eventNameFilter": "EventListEvent", (9)
2471 "requestorMode": true, (10)
2472 "requestorPeer": "EventRequestorConsumer", (11)
2473 "requestorTimeout": 500 (12)
2477 .. container:: colist arabic
2479 +-----------------------------------+-----------------------------------+
2480 | **1** | event requestor on a consumer |
2481 +-----------------------------------+-----------------------------------+
2482 | **2** | with APEX event protocol |
2483 +-----------------------------------+-----------------------------------+
2484 | **3** | optional filter (best to use a |
2485 | | filter to prevent unwanted events |
2486 | | on the consumer side) |
2487 +-----------------------------------+-----------------------------------+
2488 | **4** | activate requestor mode |
2489 +-----------------------------------+-----------------------------------+
2490 | **5** | the peer to the output (must |
2491 | | match the output carrier) |
2492 +-----------------------------------+-----------------------------------+
2493 | **6** | an optional timeout in |
2495 +-----------------------------------+-----------------------------------+
2496 | **7** | event requestor on a producer |
2497 +-----------------------------------+-----------------------------------+
2498 | **8** | with APEX event protocol |
2499 +-----------------------------------+-----------------------------------+
2500 | **9** | optional filter (best to use a |
2501 | | filter to prevent unwanted events |
2502 | | on the consumer side) |
2503 +-----------------------------------+-----------------------------------+
2504 | **10** | activate requestor mode |
2505 +-----------------------------------+-----------------------------------+
2506 | **11** | the peer to the output (must |
2507 | | match the input carrier) |
2508 +-----------------------------------+-----------------------------------+
2509 | **12** | an optional timeout in |
2511 +-----------------------------------+-----------------------------------+
2516 .. container:: paragraph
2518 Kafka IO is supported by the APEX Kafka plugin. The
2519 configurations below are examples. APEX will take any
2520 configuration inside the parameter object and forward it
2521 to Kafka. More information on Kafka specific
2522 configuration parameters can be found in the Kafka
2525 .. container:: ulist
2528 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html>`__
2531 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html>`__
2535 .. container:: paragraph
2537 APEX will receive events from the Apache Kafka
2538 messaging system. The input is uni-directional, an
2539 engine will only receive events from the input but not
2540 send any event to the input.
2542 .. container:: listingblock
2544 .. container:: content
2548 "carrierTechnologyParameters" : {
2549 "carrierTechnology" : "KAFKA", (1)
2550 "parameterClassName" :
2551 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2553 "bootstrapServers" : "localhost:49092", (2)
2554 "groupId" : "apex-group-id", (3)
2555 "enableAutoCommit" : true, (4)
2556 "autoCommitTime" : 1000, (5)
2557 "sessionTimeout" : 30000, (6)
2558 "consumerPollTime" : 100, (7)
2559 "consumerTopicList" : ["apex-in-0", "apex-in-1"], (8)
2561 "org.apache.kafka.common.serialization.StringDeserializer", (9)
2562 "valueDeserializer" :
2563 "org.apache.kafka.common.serialization.StringDeserializer" (10)
2564 "kafkaProperties": [ (11)
2566 "security.protocol",
2570 "ssl.truststore.type",
2574 "ssl.truststore.location",
2575 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2578 "ssl.truststore.password",
2587 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2590 "ssl.endpoint.identification.algorithm",
2597 .. container:: colist arabic
2599 +--------+-------------------------------------+
2600 | **1** | set Kafka as carrier technology |
2601 +--------+-------------------------------------+
2602 | **2** | bootstrap server and port |
2603 +--------+-------------------------------------+
2604 | **3** | a group identifier |
2605 +--------+-------------------------------------+
2606 | **4** | flag for auto-commit |
2607 +--------+-------------------------------------+
2608 | **5** | auto-commit timeout in milliseconds |
2609 +--------+-------------------------------------+
2610 | **6** | session timeout in milliseconds |
2611 +--------+-------------------------------------+
2612 | **7** | consumer poll time in milliseconds |
2613 +--------+-------------------------------------+
2614 | **8** | consumer topic list |
2615 +--------+-------------------------------------+
2616 | **9** | key for the Kafka de-serializer |
2617 +--------+-------------------------------------+
2618 | **10** | value for the Kafka de-serializer |
2619 +--------+-------------------------------------+
2620 | **11** | properties for Kafka connectivity |
2621 +--------+-------------------------------------+
2623 .. container:: paragraph
2625 Kindly note that the above Kafka properties is just a reference,
2626 and the actual properties required depends on the Kafka server installation.
2630 .. container:: paragraph
2632 APEX will send events to the Apache Kafka messaging
2633 system. The output is uni-directional, an engine will
2634 send events to the output but not receive any event
2637 .. container:: listingblock
2639 .. container:: content
2643 "carrierTechnologyParameters" : {
2644 "carrierTechnology" : "KAFKA", (1)
2645 "parameterClassName" :
2646 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2648 "bootstrapServers" : "localhost:49092", (2)
2651 "batchSize" : 16384, (5)
2652 "lingerTime" : 1, (6)
2653 "bufferMemory" : 33554432, (7)
2654 "producerTopic" : "apex-out", (8)
2656 "org.apache.kafka.common.serialization.StringSerializer", (9)
2658 "org.apache.kafka.common.serialization.StringSerializer" (10)
2659 "kafkaProperties": [ (11)
2661 "security.protocol",
2665 "ssl.truststore.type",
2669 "ssl.truststore.location",
2670 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2673 "ssl.truststore.password",
2682 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2685 "ssl.endpoint.identification.algorithm",
2692 .. container:: colist arabic
2694 +--------+-----------------------------------+
2695 | **1** | set Kafka as carrier technology |
2696 +--------+-----------------------------------+
2697 | **2** | bootstrap server and port |
2698 +--------+-----------------------------------+
2699 | **3** | acknowledgement strategy |
2700 +--------+-----------------------------------+
2701 | **4** | number of retries |
2702 +--------+-----------------------------------+
2703 | **5** | batch size |
2704 +--------+-----------------------------------+
2705 | **6** | time to linger in milliseconds |
2706 +--------+-----------------------------------+
2707 | **7** | buffer memory in byte |
2708 +--------+-----------------------------------+
2709 | **8** | producer topic |
2710 +--------+-----------------------------------+
2711 | **9** | key for the Kafka serializer |
2712 +--------+-----------------------------------+
2713 | **10** | value for the Kafka serializer |
2714 +--------+-----------------------------------+
2715 | **11** | properties for Kafka connectivity |
2716 +--------+-----------------------------------+
2718 .. container:: paragraph
2720 Kindly note that the above Kafka properties is just a reference,
2721 and the actual properties required depends on the Kafka server installation.
2726 .. container:: paragraph
2728 APEX supports the Java Messaging Service (JMS) as input
2729 as well as output. JMS IO is supported by the APEX JMS
2730 plugin. Input and output support an event encoding as
2731 text (JSON string) or object (serialized object). The
2732 input configuration is the same for both encodings, the
2733 output configuration differs.
2737 .. container:: paragraph
2739 APEX will receive events from a JMS messaging system.
2740 The input is uni-directional, an engine will only
2741 receive events from the input but not send any event
2744 .. container:: listingblock
2746 .. container:: content
2750 "carrierTechnologyParameters" : {
2751 "carrierTechnology" : "JMS", (1)
2752 "parameterClassName" :
2753 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2754 "parameters" : { (2)
2755 "initialContextFactory" :
2756 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2757 "connectionFactory" : "ConnectionFactory", (4)
2758 "providerURL" : "remote://localhost:5445", (5)
2759 "securityPrincipal" : "guest", (6)
2760 "securityCredentials" : "IAmAGuest", (7)
2761 "consumerTopic" : "jms/topic/apexIn" (8)
2765 .. container:: colist arabic
2767 +-----------------------------------+-----------------------------------+
2768 | **1** | set JMS as carrier technology |
2769 +-----------------------------------+-----------------------------------+
2770 | **2** | set all JMS specific parameters |
2771 +-----------------------------------+-----------------------------------+
2772 | **3** | the context factory, in this case |
2773 | | from JBOSS (it requires the |
2775 | | org.jboss:jboss-remote-naming:2.0 |
2777 | | or a different version to be in |
2778 | | the directory ``$APEX_HOME/lib`` |
2779 | | or ``%APEX_HOME%\lib`` |
2780 +-----------------------------------+-----------------------------------+
2781 | **4** | a connection factory for the JMS |
2783 +-----------------------------------+-----------------------------------+
2784 | **5** | URL with host and port of the JMS |
2786 +-----------------------------------+-----------------------------------+
2787 | **6** | access credentials, user name |
2788 +-----------------------------------+-----------------------------------+
2789 | **7** | access credentials, user password |
2790 +-----------------------------------+-----------------------------------+
2791 | **8** | the JMS topic to listen to |
2792 +-----------------------------------+-----------------------------------+
2794 JMS Output with Text
2795 ====================
2797 .. container:: paragraph
2799 APEX engine send events to a JMS messaging system. The
2800 output is uni-directional, an engine will send events
2801 to the output but not receive any event from output.
2803 .. container:: listingblock
2805 .. container:: content
2809 "carrierTechnologyParameters" : {
2810 "carrierTechnology" : "JMS", (1)
2811 "parameterClassName" :
2812 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2813 "parameters" : { (2)
2814 "initialContextFactory" :
2815 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2816 "connectionFactory" : "ConnectionFactory", (4)
2817 "providerURL" : "remote://localhost:5445", (5)
2818 "securityPrincipal" : "guest", (6)
2819 "securityCredentials" : "IAmAGuest", (7)
2820 "producerTopic" : "jms/topic/apexOut", (8)
2821 "objectMessageSending": "false" (9)
2825 .. container:: colist arabic
2827 +-----------------------------------+-----------------------------------+
2828 | **1** | set JMS as carrier technology |
2829 +-----------------------------------+-----------------------------------+
2830 | **2** | set all JMS specific parameters |
2831 +-----------------------------------+-----------------------------------+
2832 | **3** | the context factory, in this case |
2833 | | from JBOSS (it requires the |
2835 | | org.jboss:jboss-remote-naming:2.0 |
2837 | | or a different version to be in |
2838 | | the directory ``$APEX_HOME/lib`` |
2839 | | or ``%APEX_HOME%\lib`` |
2840 +-----------------------------------+-----------------------------------+
2841 | **4** | a connection factory for the JMS |
2843 +-----------------------------------+-----------------------------------+
2844 | **5** | URL with host and port of the JMS |
2846 +-----------------------------------+-----------------------------------+
2847 | **6** | access credentials, user name |
2848 +-----------------------------------+-----------------------------------+
2849 | **7** | access credentials, user password |
2850 +-----------------------------------+-----------------------------------+
2851 | **8** | the JMS topic to write to |
2852 +-----------------------------------+-----------------------------------+
2853 | **9** | set object messaging to ``false`` |
2854 | | means it sends JSON text |
2855 +-----------------------------------+-----------------------------------+
2857 JMS Output with Object
2858 ======================
2860 .. container:: paragraph
2862 To configure APEX for JMS objects on the output
2863 interface use the same configuration as above (for
2864 output). Simply change the ``objectMessageSending``
2865 parameter to ``true``.
2870 .. container:: paragraph
2872 APEX supports the Websockets as input as well as output.
2873 WS IO is supported by the APEX Websocket plugin. This
2874 carrier technology does only support uni-directional
2875 communication. APEX will not send events to a Websocket
2876 input and any event sent to a Websocket output will
2877 result in an error log.
2879 .. container:: paragraph
2881 The input can be configured as client (APEX connects to
2882 an existing Websocket server) or server (APEX starts a
2883 Websocket server). The same applies to the output. Input
2884 and output can both use a client or a server
2885 configuration, or separate configurations (input as
2886 client and output as server, input as server and output
2887 as client). Each configuration should use its own
2888 dedicated port to avoid any communication loops. The
2889 configuration of a Websocket client is the same for input
2890 and output. The configuration of a Websocket server is
2891 the same for input and output.
2896 .. container:: paragraph
2898 APEX will connect to a given Websocket server. As
2899 input, it will receive events from the server but not
2900 send any events. As output, it will send events to the
2901 server and any event received from the server will
2902 result in an error log.
2904 .. container:: listingblock
2906 .. container:: content
2910 "carrierTechnologyParameters" : {
2911 "carrierTechnology" : "WEBSOCKET", (1)
2912 "parameterClassName" :
2913 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2915 "host" : "localhost", (2)
2920 .. container:: colist arabic
2922 +-------+------------------------------------------------------+
2923 | **1** | set Websocket as carrier technology |
2924 +-------+------------------------------------------------------+
2925 | **2** | the host name on which a Websocket server is running |
2926 +-------+------------------------------------------------------+
2927 | **3** | the port of that Websocket server |
2928 +-------+------------------------------------------------------+
2933 .. container:: paragraph
2935 APEX will start a Websocket server, which will accept
2936 any Websocket clients to connect. As input, it will
2937 receive events from the server but not send any
2938 events. As output, it will send events to the server
2939 and any event received from the server will result in
2942 .. container:: listingblock
2944 .. container:: content
2948 "carrierTechnologyParameters" : {
2949 "carrierTechnology" : "WEBSOCKET", (1)
2950 "parameterClassName" :
2951 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2953 "wsClient" : false, (2)
2958 .. container:: colist arabic
2960 +-------+------------------------------------------------------------+
2961 | **1** | set Websocket as carrier technology |
2962 +-------+------------------------------------------------------------+
2963 | **2** | disable client, so that APEX will start a Websocket server |
2964 +-------+------------------------------------------------------------+
2965 | **3** | the port for the Websocket server APEX will start |
2966 +-------+------------------------------------------------------------+
2971 .. container:: paragraph
2973 APEX can act as REST client on the input as well as on
2974 the output interface. The media type is
2975 ``application/json``, so this plugin only works with
2976 the JSON Event protocol.
2981 .. container:: paragraph
2983 APEX will connect to a given URL to receive events,
2984 but not send any events. The server is polled, i.e.
2985 APEX will do an HTTP GET, take the result, and then do
2986 the next GET. Any required timing needs to be handled
2987 by the server configured via the URL. For instance,
2988 the server could support a wait timeout via the URL as
2990 The httpCodeFilter is used for filtering the status
2991 code, and it can be configured as a regular expression
2992 string. The default httpCodeFilter is "[2][0-9][0-9]"
2993 - for successful response codes.
2994 The response with HTTP status code that matches the
2995 given regular expression is forwarded to the task,
2996 otherwise it is logged as a failure.
2998 .. container:: listingblock
3000 .. container:: content
3004 "carrierTechnologyParameters" : {
3005 "carrierTechnology" : "RESTCLIENT", (1)
3006 "parameterClassName" :
3007 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3009 "url" : "http://example.org:8080/triggers/events", (2)
3010 "httpMethod": "GET", (3)
3011 "httpCodeFilter" : "[2][0-9][0-9]", (4)
3012 "httpHeaders" : [ (5)
3013 ["Keep-Alive", "300"],
3014 ["Cache-Control", "no-cache"]
3019 .. container:: colist arabic
3021 +-------+--------------------------------------------------+
3022 | **1** | set REST client as carrier technology |
3023 +-------+--------------------------------------------------+
3024 | **2** | the URL of the HTTP server for events |
3025 +-------+--------------------------------------------------+
3026 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3027 | | optional, defaults to GET |
3028 +-------+--------------------------------------------------+
3029 | **4** | use HTTP CODE FILTER for filtering status code, |
3030 | | optional, defaults to [2][0-9][0-9] |
3031 +-------+--------------------------------------------------+
3032 | **5** | HTTP headers to use on the REST request, |
3034 +-------+--------------------------------------------------+
3039 .. container:: paragraph
3041 APEX will connect to a given URL to send events, but
3042 not receive any events. The default HTTP operation is
3043 POST (no configuration required). To change it to PUT
3044 simply add the configuration parameter (as shown in
3046 The URL can be configured statically or tagged
3047 as ``?example.{site}.org:8080/{trig}/events``,
3048 all tags such as ``site`` and ``trig`` in the URL
3049 need to be set in the properties object available to
3050 the tasks. In addition, the keys should exactly match
3051 with the tags defined in url. The scope of the properties
3052 object is per HTTP call. Hence, key/value pairs set
3053 in the properties object by task are only available
3054 for that specific HTTP call.
3056 .. container:: listingblock
3058 .. container:: content
3062 "carrierTechnologyParameters" : {
3063 "carrierTechnology" : "RESTCLIENT", (1)
3064 "parameterClassName" :
3065 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3067 "url" : "http://example.com:8888/actions/events", (2)
3068 "url" : "http://example.{site}.com:8888/{trig}/events", (2')
3069 "httpMethod" : "PUT". (3)
3070 "httpHeaders" : [ (4)
3071 ["Keep-Alive", "300"],
3072 ["Cache-Control", "no-cache"]
3076 .. container:: colist arabic
3078 +-------+--------------------------------------------------+
3079 | **1** | set REST client as carrier technology |
3080 +-------+--------------------------------------------------+
3081 | **2** | the static URL of the HTTP server for events |
3082 +-------+--------------------------------------------------+
3083 | **2'**| the tagged URL of the HTTP server for events |
3084 +-------+--------------------------------------------------+
3085 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3086 | | optional, defaults to POST |
3087 +-------+--------------------------------------------------+
3088 | **4** | HTTP headers to use on the REST request, |
3090 +-------+--------------------------------------------------+
3095 .. container:: paragraph
3097 APEX supports a REST server for input and output.
3099 .. container:: paragraph
3101 The REST server plugin always uses a synchronous mode. A
3102 client does a HTTP GET on the APEX REST server with the
3103 input event and receives the generated output event in
3104 the server reply. This means that for the REST server
3105 there has to always to be an input with an associated
3106 output. Input or output only are not permitted.
3108 .. container:: paragraph
3110 The plugin will start a Grizzly server as REST server for
3111 a normal APEX engine. If the APEX engine is executed as a
3112 servlet, for instance inside Tomcat, then Tomcat will be
3113 used as REST server (this case requires configuration on
3116 .. container:: paragraph
3118 Some configuration restrictions apply for all scenarios:
3120 .. container:: ulist
3122 - Minimum port: 1024
3124 - Maximum port: 65535
3126 - The media type is ``application/json``, so this plugin
3127 only works with the JSON Event protocol.
3129 .. container:: paragraph
3131 The URL the client calls is created using
3133 .. container:: ulist
3135 - the configured host and port, e.g.
3136 ``http://localhost:12345``
3138 - the standard path, e.g. ``/apex/``
3140 - the name of the input/output, e.g. ``FirstConsumer/``
3142 - the input or output name, e.g. ``EventIn``.
3144 .. container:: paragraph
3146 The examples above lead to the URL
3147 ``http://localhost:12345/apex/FirstConsumer/EventIn``.
3149 .. container:: paragraph
3151 A client can also get status information of the REST
3152 server using ``/Status``, e.g.
3153 ``http://localhost:12345/apex/FirstConsumer/Status``.
3155 REST Server Stand-alone
3156 =======================
3158 .. container:: paragraph
3160 We need to configure a REST server input and a REST
3161 server output. Input and output are associated with
3162 each other via there name.
3164 .. container:: paragraph
3166 Timeouts for REST calls need to be set carefully. If
3167 they are too short, the call might timeout before a
3168 policy finished creating an event.
3170 .. container:: paragraph
3172 The following example configures the input named as
3173 ``MyConsumer`` and associates an output named
3174 ``MyProducer`` with it.
3176 .. container:: listingblock
3178 .. container:: content
3182 "eventInputParameters": {
3184 "carrierTechnologyParameters" : {
3185 "carrierTechnology" : "RESTSERVER", (1)
3186 "parameterClassName" :
3187 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters",
3189 "standalone" : true, (2)
3190 "host" : "localhost", (3)
3194 "eventProtocolParameters":{
3195 "eventProtocol" : "JSON" (5)
3197 "synchronousMode" : true, (6)
3198 "synchronousPeer" : "MyProducer", (7)
3199 "synchronousTimeout" : 500 (8)
3203 .. container:: colist arabic
3205 +-------+---------------------------------------+
3206 | **1** | set REST server as carrier technology |
3207 +-------+---------------------------------------+
3208 | **2** | set the server as stand-alone |
3209 +-------+---------------------------------------+
3210 | **3** | set the server host |
3211 +-------+---------------------------------------+
3212 | **4** | set the server listen port |
3213 +-------+---------------------------------------+
3214 | **5** | use JSON event protocol |
3215 +-------+---------------------------------------+
3216 | **6** | activate synchronous mode |
3217 +-------+---------------------------------------+
3218 | **7** | associate an output ``MyProducer`` |
3219 +-------+---------------------------------------+
3220 | **8** | set a timeout of 500 milliseconds |
3221 +-------+---------------------------------------+
3223 .. container:: paragraph
3225 The following example configures the output named as
3226 ``MyProducer`` and associates the input ``MyConsumer``
3227 with it. Note that for the output there are no more
3228 paramters (such as host or port), since they are
3229 already configured in the associated input
3231 .. container:: listingblock
3233 .. container:: content
3237 "eventOutputParameters": {
3239 "carrierTechnologyParameters":{
3240 "carrierTechnology" : "RESTSERVER",
3241 "parameterClassName" :
3242 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters"
3244 "eventProtocolParameters":{
3245 "eventProtocol" : "JSON"
3247 "synchronousMode" : true,
3248 "synchronousPeer" : "MyConsumer",
3249 "synchronousTimeout" : 500
3253 REST Server Stand-alone, multi input
3254 ====================================
3256 .. container:: paragraph
3258 Any number of input/output pairs for REST servers can
3259 be configured. For instance, we can configure an input
3260 ``FirstConsumer`` with output ``FirstProducer`` and an
3261 input ``SecondConsumer`` with output
3262 ``SecondProducer``. Important is that there is always
3263 one pair of input/output.
3265 REST Server Stand-alone in Servlet
3266 ==================================
3268 .. container:: paragraph
3270 If APEX is executed as a servlet, e.g. inside Tomcat,
3271 the configuration becomes easier since the plugin can
3272 now use Tomcat as the REST server. In this scenario,
3273 there are not parameters (port, host, etc.) and the
3274 key ``standalone`` must not be used (or set to false).
3276 .. container:: paragraph
3278 For the Tomcat configuration, we need to add the REST
3281 .. container:: listingblock
3283 .. container:: content
3291 <param-value>org.onap.policy.apex.plugins.event.carrier.restserver</param-value>
3299 .. container:: paragraph
3301 APEX can act as REST requestor on the input as well as on
3302 the output interface. The media type is
3303 ``application/json``, so this plugin only works with
3304 the JSON Event protocol. This plugin allows APEX to send REST requests
3305 and to receive the reply of that request without tying up APEX resources
3306 while the request is being processed. The REST Requestor pairs a REST
3307 requestor producer and consumer together to handle the REST request
3308 and response. The REST request is created from an APEX output event
3309 and the REST response is input into APEX as a new input event.
3311 REST Requestor Output (REST Request Producer)
3312 =============================================
3314 .. container:: paragraph
3316 APEX sends a REST request when events are output by APEX, the REST
3317 request configuration is specified on the REST Request Consumer (see
3320 .. container:: listingblock
3322 .. container:: content
3326 "carrierTechnologyParameters": {
3327 "carrierTechnology": "RESTREQUESTOR", (1)
3328 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
3331 .. container:: colist arabic
3333 +-------+------------------------------------------+
3334 | **1** | set REST requestor as carrier technology |
3335 +-------+------------------------------------------+
3337 .. container:: paragraph
3339 The settings below are required on the producer to
3340 define the event that triggers the REST request and
3341 to specify the peered consumer configuration for the
3342 REST request, for example:
3344 .. container:: listingblock
3346 .. container:: content
3350 "eventNameFilter": "GuardRequestEvent", (1)
3351 "requestorMode": true, (2)
3352 "requestorPeer": "GuardRequestorConsumer", (3)
3353 "requestorTimeout": 500 (4)
3355 .. container:: colist arabic
3357 +-------+-------------------------------------------+
3358 | **1** | a filter on the event |
3359 +-------+-------------------------------------------+
3360 | **2** | requestor mode must be set to *true* |
3361 +-------+-------------------------------------------+
3362 | **3** | the peered consumer for REST requests, |
3363 | | that consumer specifies the full |
3364 | | configuration for REST requests |
3365 +-------+-------------------------------------------+
3366 | **4** | the request timeout in milliseconds, |
3367 | | overridden by timeout on consumer if that |
3368 | | is set, optional defaults to 500 |
3370 +-------+-------------------------------------------+
3372 REST Requestor Input (REST Request Consumer)
3373 ============================================
3375 .. container:: paragraph
3377 APEX will connect to a given URL to issue a REST request and
3378 wait for a REST response.
3379 The URL can be configured statically or tagged
3380 as ``?example.{site}.org:8080/{trig}/events``,
3381 all tags such as ``site`` and ``trig`` in the URL
3382 need to be set in the properties object available to
3383 the tasks. In addition, the keys should exactly match
3384 with the tags defined in url. The scope of the properties
3385 object is per HTTP call. Hence, key/value pairs set
3386 in the properties object by task are only available
3387 for that specific HTTP call.
3388 The httpCodeFilter is used for filtering the status
3389 code, and it can be configured as a regular expression
3390 string. The default httpCodeFilter is "[2][0-9][0-9]"
3391 - for successful response codes.
3392 The response with HTTP status code that matches the
3393 given regular expression is forwarded to the task,
3394 otherwise it is logged as a failure.
3396 .. container:: listingblock
3398 .. container:: content
3402 "carrierTechnologyParameters": {
3403 "carrierTechnology": "RESTREQUESTOR", (1)
3404 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
3406 "url": "http://localhost:54321/some/path/to/rest/resource", (2)
3407 "url": "http://localhost:54321/{site}/path/to/rest/{resValue}", (2')
3408 "httpMethod": "POST", (3)
3409 "requestorMode": true, (4)
3410 "requestorPeer": "GuardRequestorProducer", (5)
3411 "restRequestTimeout": 2000, (6)
3412 "httpCodeFilter" : "[2][0-9][0-9]" (7)
3413 "httpHeaders" : [ (8)
3414 ["Keep-Alive", "300"],
3415 ["Cache-Control", "no-cache"]
3419 .. container:: colist arabic
3421 +-------+--------------------------------------------------+
3422 | **1** | set REST requestor as carrier technology |
3423 +-------+--------------------------------------------------+
3424 | **2** | the static URL of the HTTP server for events |
3425 +-------+--------------------------------------------------+
3426 | **2'**| the tagged URL of the HTTP server for events |
3427 +-------+--------------------------------------------------+
3428 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3429 | | optional, defaults to GET |
3430 +-------+--------------------------------------------------+
3431 | **4** | requestor mode must be set to *true* |
3432 +-------+--------------------------------------------------+
3433 | **5** | the peered producer for REST requests, that |
3434 | | producer specifies the APEX output event that |
3435 | | triggers the REST request |
3436 +-------+--------------------------------------------------+
3437 | **6** | request timeout in milliseconds, overrides any |
3438 | | value set in the REST Requestor Producer, |
3439 | | optional, defaults to 500 millisconds |
3440 +-------+--------------------------------------------------+
3441 | **7** | use HTTP CODE FILTER for filtering status code |
3442 | | optional, defaults to [2][0-9][0-9] |
3443 +-------+--------------------------------------------------+
3444 | **8** | HTTP headers to use on the REST request, |
3446 +-------+--------------------------------------------------+
3448 .. container:: paragraph
3450 Further settings may be required on the consumer to
3451 define the input event that is produced and forwarded into
3454 .. container:: listingblock
3456 .. container:: content
3460 "eventName": "GuardResponseEvent", (1)
3461 "eventNameFilter": "GuardResponseEvent" (2)
3463 .. container:: colist arabic
3465 +-------+---------------------------+
3466 | **1** | the event name |
3467 +-------+---------------------------+
3468 | **2** | a filter on the event |
3469 +-------+---------------------------+
3474 .. container:: paragraph
3476 APEX can send requests over gRPC at the output side, and get back
3477 response at the input side. This can be used to send requests to CDS
3478 over gRPC. The media type is ``application/json``, so this plugin
3479 only works with the JSON Event protocol.
3484 .. container:: paragraph
3486 APEX will connect to a given host to send a request over
3489 .. container:: listingblock
3491 .. container:: content
3495 "carrierTechnologyParameters": {
3496 "carrierTechnology": "GRPC", (1)
3497 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
3499 "host": "cds-blueprints-processor-grpc", (2)
3501 "username": "ccsdkapps", (3)
3502 "password": ccsdkapps, (4)
3507 .. container:: colist arabic
3509 +-------+--------------------------------------------------+
3510 | **1** | set GRPC as carrier technology |
3511 +-------+--------------------------------------------------+
3512 | **2** | the host to which request is sent |
3513 +-------+--------------------------------------------------+
3514 | **2'**| the value for port |
3515 +-------+--------------------------------------------------+
3516 | **3** | username required to initiate connection |
3517 +-------+--------------------------------------------------+
3518 | **4** | password required to initiate connection |
3519 +-------+--------------------------------------------------+
3520 | **5** | the timeout value for completing the request |
3521 +-------+--------------------------------------------------+
3523 .. container:: paragraph
3525 Further settings are required on the producer to
3526 define the event that is requested, for example:
3528 .. container:: listingblock
3530 .. container:: content
3534 "eventName": "GRPCRequestEvent", (1)
3535 "eventNameFilter": "GRPCRequestEvent", (2)
3536 "requestorMode": true, (3)
3537 "requestorPeer": "GRPCRequestConsumer", (4)
3538 "requestorTimeout": 500 (5)
3540 .. container:: colist arabic
3542 +-------+---------------------------+
3543 | **1** | the event name |
3544 +-------+---------------------------+
3545 | **2** | a filter on the event |
3546 +-------+---------------------------+
3547 | **3** | the mode of the requestor |
3548 +-------+---------------------------+
3549 | **4** | a peer for the requestor |
3550 +-------+---------------------------+
3551 | **5** | a general request timeout |
3552 +-------+---------------------------+
3557 .. container:: paragraph
3559 APEX will connect to the host specified in the producer
3560 side, anad take in response back at the consumer side.
3562 .. container:: listingblock
3564 .. container:: content
3568 "carrierTechnologyParameters": {
3569 "carrierTechnology": "GRPC", (1)
3570 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
3573 .. container:: colist arabic
3575 +-------+------------------------------------------+
3576 | **1** | set GRPC as carrier technology |
3577 +-------+------------------------------------------+
3579 .. container:: paragraph
3581 Further settings are required on the consumer to
3582 define the event that is requested, for example:
3584 .. container:: listingblock
3586 .. container:: content
3590 "eventNameFilter": "GRPCResponseEvent", (1)
3591 "requestorMode": true, (2)
3592 "requestorPeer": "GRPCRequestProducer", (3)
3593 "requestorTimeout": 500 (4)
3595 .. container:: colist arabic
3597 +-------+---------------------------+
3598 | **1** | a filter on the event |
3599 +-------+---------------------------+
3600 | **2** | the mode of the requestor |
3601 +-------+---------------------------+
3602 | **3** | a peer for the requestor |
3603 +-------+---------------------------+
3604 | **4** | a general request timeout |
3605 +-------+---------------------------+
3607 Event Protocols, Format and Encoding
3608 ------------------------------------
3610 .. container:: paragraph
3612 Event protocols define what event formats APEX can receive
3613 (input) and should send (output). They can be used in any
3614 combination for input and output, unless further restricted
3615 by a carrier technology plugin (for instance for JMS
3616 output). There can only be 1 event protocol per event
3619 .. container:: paragraph
3621 Supported *input* event protocols are:
3623 .. container:: ulist
3625 - JSON, the event as a JSON string
3627 - APEX, an APEX event
3629 - JMS object, the event as a JMS object,
3631 - JMS text, the event as a JMS text,
3633 - XML, the event as an XML string,
3635 - YAML, the event as YAML text
3637 .. container:: paragraph
3639 Supported *output* event protocols are:
3641 .. container:: ulist
3643 - JSON, the event as a JSON string
3645 - APEX, an APEX event
3647 - JMS object, the event as a JMS object,
3649 - JMS text, the event as a JMS text,
3651 - XML, the event as an XML string,
3653 - YAML, the event as YAML text
3655 .. container:: paragraph
3657 New event protocols can be added as plugins to APEX or
3658 developed outside APEX and added to an APEX deployment.
3663 .. container:: paragraph
3665 The event protocol for JSON encoding does not require a
3666 specific plugin, it is supported by default. Furthermore,
3667 there is no difference in the configuration for the input
3668 and output interface.
3670 .. container:: paragraph
3672 For an input, APEX requires a well-formed JSON string.
3673 Well-formed here means according to the definitions of a
3674 policy. Any JSON string that is not defined as a trigger
3675 event (consume) will not be consumed (errors will be
3676 thrown). For output JSON events, APEX will always produce
3677 valid JSON strings according to the definition in the
3680 .. container:: paragraph
3682 The following JSON shows the configuration.
3684 .. container:: listingblock
3686 .. container:: content
3690 "eventProtocolParameters":{
3691 "eventProtocol" : "JSON"
3694 .. container:: paragraph
3696 For JSON events, there are a few more optional
3697 parameters, which allow to define a mapping for standard
3698 event fields. An APEX event must have the fields
3699 ``name``, ``version``, ``source``, and ``target``
3700 defined. Sometimes it is not possible to configure a
3701 trigger or actioning system to use those fields. However,
3702 they might be in an event generated outside APEX (or used
3703 outside APEX) just with different names. To configure
3704 APEX to map between the different event names, simply add
3705 the following parameters to a JSON event:
3707 .. container:: listingblock
3709 .. container:: content
3713 "eventProtocolParameters":{
3714 "eventProtocol" : "JSON",
3715 "nameAlias" : "policyName", (1)
3716 "versionAlias" : "policyVersion", (2)
3717 "sourceAlias" : "from", (3)
3718 "targetAlias" : "to", (4)
3719 "nameSpaceAlias": "my.name.space" (5)
3722 .. container:: colist arabic
3724 +-----------------------------------+-----------------------------------+
3725 | **1** | mapping for the ``name`` field, |
3726 | | here from a field called |
3727 | | ``policyName`` |
3728 +-----------------------------------+-----------------------------------+
3729 | **2** | mapping for the ``version`` |
3730 | | field, here from a field called |
3731 | | ``policyVersion`` |
3732 +-----------------------------------+-----------------------------------+
3733 | **3** | mapping for the ``source`` field, |
3734 | | here from a field called ``from`` |
3735 | | (only for an input event) |
3736 +-----------------------------------+-----------------------------------+
3737 | **4** | mapping for the ``target`` field, |
3738 | | here from a field called ``to`` |
3739 | | (only for an output event) |
3740 +-----------------------------------+-----------------------------------+
3741 | **5** | mapping for the ``nameSpace`` |
3742 | | field, here from a field called |
3743 | | ``my.name.space`` |
3744 +-----------------------------------+-----------------------------------+
3748 .. container:: paragraph
3750 The event protocol for APEX events does not require a
3751 specific plugin, it is supported by default. Furthermore,
3752 there is no difference in the configuration for the input
3753 and output interface.
3755 .. container:: paragraph
3757 For input and output APEX uses APEX events.
3759 .. container:: paragraph
3761 The following JSON shows the configuration.
3763 .. container:: listingblock
3765 .. container:: content
3769 "eventProtocolParameters":{
3770 "eventProtocol" : "APEX"
3776 .. container:: paragraph
3778 The event protocol for JMS is provided by the APEX JMS
3779 plugin. The plugin supports encoding as JSON text or as
3780 object. There is no difference in the configuration for
3781 the input and output interface.
3785 .. container:: paragraph
3787 If used as input, APEX will take a JMS message and
3788 extract a JSON string, then proceed as if a JSON event
3789 was received. If used as output, APEX will take the
3790 event produced by a policy, create a JSON string, and
3791 then wrap it into a JMS message.
3793 .. container:: paragraph
3795 The configuration for JMS text is as follows:
3797 .. container:: listingblock
3799 .. container:: content
3803 "eventProtocolParameters":{
3804 "eventProtocol" : "JMSTEXT",
3805 "parameterClassName" :
3806 "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters"
3811 .. container:: paragraph
3813 If used as input, APEX will will take a JMS message,
3814 extract a Java Bean from the ``ObjectMessage``
3815 message, construct an APEX event and put the bean on
3816 the APEX event as a parameter. If used as output, APEX
3817 will take the event produced by a policy, create a
3818 Java Bean and send it as a JMS message.
3820 .. container:: paragraph
3822 The configuration for JMS object is as follows:
3824 .. container:: listingblock
3826 .. container:: content
3830 "eventProtocolParameters":{
3831 "eventProtocol" : "JMSOBJECT",
3832 "parameterClassName" :
3833 "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters"
3839 .. container:: paragraph
3841 The event protocol for YAML is provided by the APEX YAML
3842 plugin. There is no difference in the configuration for
3843 the input and output interface.
3845 .. container:: paragraph
3847 If used as input, APEX will consume events as YAML and
3848 map them to policy trigger events. Not well-formed YAML
3849 and not understood trigger events will be rejected. If
3850 used as output, APEX produce YAML encoded events from the
3851 event a policy produces. Those events will always be
3852 well-formed according to the definition in the policy
3855 .. container:: paragraph
3857 The following code shows the configuration.
3859 .. container:: listingblock
3861 .. container:: content
3865 "eventProtocolParameters":{
3866 "eventProtocol" : "XML",
3867 "parameterClassName" :
3868 "org.onap.policy.apex.plugins.event.protocol.yaml.YamlEventProtocolParameters"
3873 .. container:: paragraph
3875 The event protocol for XML is provided by the APEX XML
3876 plugin. There is no difference in the configuration for
3877 the input and output interface.
3879 .. container:: paragraph
3881 If used as input, APEX will consume events as XML and map
3882 them to policy trigger events. Not well-formed XML and
3883 not understood trigger events will be rejected. If used
3884 as output, APEX produce XML encoded events from the event
3885 a policy produces. Those events will always be
3886 well-formed according to the definition in the policy
3889 .. container:: paragraph
3891 The following code shows the configuration.
3893 .. container:: listingblock
3895 .. container:: content
3899 "eventProtocolParameters":{
3900 "eventProtocol" : "XML",
3901 "parameterClassName" :
3902 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3905 A configuration example
3906 -----------------------
3908 .. container:: paragraph
3910 The following example loads all available plug-ins.
3912 .. container:: paragraph
3914 Events are consumed from a Websocket, APEX as client.
3915 Consumed event format is JSON.
3917 .. container:: paragraph
3919 Events are produced to Kafka. Produced event format is XML.
3921 .. container:: listingblock
3923 .. container:: content
3928 "engineServiceParameters" : {
3929 "name" : "MyApexEngine",
3930 "version" : "0.0.1",
3932 "instanceCount" : 4,
3933 "deploymentPort" : 12345,
3934 "engineParameters" : {
3935 "executorParameters" : {
3937 "parameterClassName" :
3938 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
3941 "parameterClassName" :
3942 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
3945 "parameterClassName" :
3946 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
3949 "parameterClassName" :
3950 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
3953 "parameterClassName" :
3954 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
3957 "contextParameters" : {
3958 "parameterClassName" :
3959 "org.onap.policy.apex.context.parameters.ContextParameters",
3960 "schemaParameters" : {
3962 "parameterClassName" :
3963 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
3969 "producerCarrierTechnologyParameters" : {
3970 "carrierTechnology" : "KAFKA",
3971 "parameterClassName" :
3972 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
3974 "bootstrapServers" : "localhost:49092",
3977 "batchSize" : 16384,
3979 "bufferMemory" : 33554432,
3980 "producerTopic" : "apex-out",
3981 "keySerializer" : "org.apache.kafka.common.serialization.StringSerializer",
3982 "valueSerializer" : "org.apache.kafka.common.serialization.StringSerializer"
3985 "producerEventProtocolParameters" : {
3986 "eventProtocol" : "XML",
3987 "parameterClassName" :
3988 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3990 "consumerCarrierTechnologyParameters" : {
3991 "carrierTechnology" : "WEBSOCKET",
3992 "parameterClassName" :
3993 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
3995 "host" : "localhost",
3999 "consumerEventProtocolParameters" : {
4000 "eventProtocol" : "JSON"
4004 Engine and Applications of the APEX System
4005 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4007 Introduction to APEX Engine and Applications
4008 --------------------------------------------
4010 .. container:: paragraph
4012 The core of APEX is the APEX Engine, also known as the APEX
4013 Policy Engine or the APEX PDP (since it is in fact a Policy
4014 Decision Point). Beside this engine, an APEX system comes
4015 with a few applications intended to help with policy
4016 authoring, deployment, and execution.
4018 .. container:: paragraph
4020 The engine itself and most applications are started from the
4021 command line with command line arguments. This is called a
4022 Command Line Interface (CLI). Some applications require an
4023 installation on a webserver, as for instance the REST
4024 Editor. Those applications can be accessed via a web
4027 .. container:: paragraph
4029 You can also use the available APEX APIs and applications to
4030 develop other applications as required. This includes policy
4031 languages (and associated parsers and compilers /
4032 interpreters), GUIs to access APEX or to define policies,
4033 clients to connect to APEX, etc.
4035 .. container:: paragraph
4037 For this documentation, we assume an installation of APEX as
4038 a full system based on a current ONAP release.
4040 CLI on Unix, Windows, and Cygwin
4041 --------------------------------
4043 .. container:: paragraph
4045 A note on APEX CLI applications: all applications and the
4046 engine itself have been deployed and tested on different
4047 operating systems: Red Hat, Ubuntu, Debian, Mac OSX,
4048 Windows, Cygwin. Each operating system comes with its own
4049 way of configuring and executing Java. The main items here
4052 .. container:: ulist
4054 - For UNIX systems (RHL, Ubuntu, Debian, Mac OSX), the
4055 provided bash scripts work as expected with absolute
4057 ``/opt/app/policy/apex-pdp/apex-pdp-2.0.0-SNAPSHOT/examples``),
4058 indirect and linked paths (e.g. ``../apex/apex``), and
4059 path substitutions using environment settings (e.g.
4060 ``$APEX_HOME/bin/``)
4062 - For Windows systems, the provided batch files (``.bat``)
4063 work as expected with with absolute paths (e.g.
4064 ``C:\apex\apex-2.0.0-SNAPSHOT\examples``), and path
4065 substitutions using environment settings (e.g.
4066 ``%APEX_HOME%\bin\``)
4068 - For Cygwin system we assume a standard Cygwin
4069 installation with standard tools (mainly bash) using a
4070 Windows Java installation. This means that the bash
4071 scripts can be used as in UNIX, however any argument
4072 pointing to files and directories need to use either a
4074 ``C:\apex\apex-2.0.0-SNAPSHOT\examples\config...``) or
4075 the command ``cygpath`` with a mixed option. The reason
4076 for that is: Cygwin executes Java using UNIX paths but
4077 then runs Java as a DOS/WINDOWS process, which requires
4078 DOS paths for file access.
4083 .. container:: paragraph
4085 The APEX engine can be started in different ways, depending
4086 your requirements. All scripts are located in the APEX *bin*
4089 .. container:: paragraph
4091 On UNIX and Cygwin systems use:
4093 .. container:: ulist
4095 - ``apexEngine.sh`` - this script will
4097 .. container:: ulist
4099 - Test if ``$APEX_USER`` is set and if the user
4100 exists, terminate with an error otherwise
4102 - Test if ``$APEX_HOME`` is set. If not set, it will
4103 use the default setting as
4104 ``/opt/app/policy/apex-pdp/apex-pdp``. Then the set
4105 directory is tested to exist, the script will
4108 - When all tests are passed successfully, the script
4109 will call ``apexApps.sh`` with arguments to start
4112 - ``apexApps.sh engine`` - this is the general APEX
4113 application launcher, which will
4115 .. container:: ulist
4117 - Start the engine with the argument ``engine``
4119 - Test if ``$APEX_HOME`` is set and points to an
4120 existing directory. If not set or directory does
4121 not exist, script terminates.
4123 - Not test for any settings of ``$APEX_USER``.
4125 .. container:: paragraph
4127 On Windows systems use ``apexEngine.bat`` and
4128 ``apexApps.bat engine`` respectively. Note: none of the
4129 windows batch files will test for ``%APEX_USER%``.
4131 .. container:: paragraph
4133 Summary of alternatives to start the APEX Engine:
4135 +--------------------------------------------------------+----------------------------------------------------------+
4136 | Unix, Cygwin | Windows |
4137 +========================================================+==========================================================+
4138 | .. container:: | .. container:: |
4140 | .. container:: listingblock | .. container:: listingblock |
4142 | .. container:: content | .. container:: content |
4144 | .. code:: | .. code:: |
4146 | # $APEX_HOME/bin/apexEngine.sh [args] | > %APEX_HOME%\bin\apexEngine.bat [args] |
4147 | # $APEX_HOME/bin/apexApps.sh engine [args] | > %APEX_HOME%\bin\apexApps.bat engine [args] |
4148 +--------------------------------------------------------+----------------------------------------------------------+
4150 .. container:: paragraph
4152 The APEX engine comes with a few CLI arguments, the main one is for setting
4153 the tosca policy file for execution. The tosca policy file is
4154 always required. The option ``-h`` prints a help screen.
4156 .. container:: listingblock
4158 .. container:: content
4162 usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]
4164 -p,--tosca-policy-file <TOSCA_POLICY_FILE> the full path to the ToscaPolicy file to use.
4165 -h,--help outputs the usage of this command
4166 -v,--version outputs the version of Apex
4171 .. container:: paragraph
4173 The CLI Editor allows to define policies from the command
4174 line. The application uses a simple language and supports
4175 all elements of an APEX policy. It can be used in to
4178 .. container:: ulist
4180 - non-interactive, specifying a file with the commands to
4183 - interactive, using the editors CLI to create a policy
4185 .. container:: paragraph
4187 When a policy is fully specified, the editor will generate
4188 the APEX core policy specification in JSON. This core
4189 specification is called the policy model in the APEX engine
4190 and can be used directly with the APEX engine.
4192 .. container:: paragraph
4194 On UNIX and Cygwin systems use:
4196 .. container:: ulist
4198 - ``apexCLIEditor.sh`` - simply starts the CLI editor,
4199 arguments to the script determine the mode of the editor
4201 - ``apexApps.sh cli-editor`` - simply starts the CLI
4202 editor, arguments to the script determine the mode of the
4205 .. container:: paragraph
4207 On Windows systems use:
4209 .. container:: ulist
4211 - ``apexCLIEditor.bat`` - simply starts the CLI editor,
4212 arguments to the script determine the mode of the editor
4214 - ``apexApps.bat cli-editor`` - simply starts the CLI
4215 editor, arguments to the script determine the mode of the
4218 .. container:: paragraph
4220 Summary of alternatives to start the APEX CLI Editor:
4222 +------------------------------------------------------------+--------------------------------------------------------------+
4223 | Unix, Cygwin | Windows |
4224 +============================================================+==============================================================+
4225 | .. container:: | .. container:: |
4227 | .. container:: listingblock | .. container:: listingblock |
4229 | .. container:: content | .. container:: content |
4231 | .. code:: | .. code:: |
4233 | # $APEX_HOME/bin/apexCLIEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIEditor.bat [args] |
4234 | # $APEX_HOME/bin/apexApps.sh cli-editor [args] | > %APEX_HOME%\bin\apexApps.bat cli-editor [args] |
4235 +------------------------------------------------------------+--------------------------------------------------------------+
4237 .. container:: paragraph
4239 The option ``-h`` provides a help screen with all command
4242 .. container:: listingblock
4244 .. container:: content
4248 usage: org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain [options...]
4250 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4251 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4252 -h,--help outputs the usage of this command
4253 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4254 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and continue
4255 executing the command file
4256 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will log
4257 to standard output if not specified or suppressed with "-nl" flag
4258 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4259 -nl,--no-log if specified, no logging or output of commands to standard output or log
4261 -nm,--no-model-output if specified, no output of a model to standard output or model output
4262 file is carried out, the user can use the "save" command in a script to
4264 -o,--output-model-file <OUTPUT_MODEL_FILE> name of a file that will contain the output model for the editor, will
4265 output model to standard output if not specified or suppressed with
4267 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4268 root from which to look for included macro files
4270 The APEX CLI Tosca Editor
4271 -------------------------
4273 .. container:: paragraph
4275 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.
4277 .. container:: paragraph
4279 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.
4281 .. container:: paragraph
4283 On UNIX and Cygwin systems use:
4285 .. container:: ulist
4287 - ``apexCLIToscaEditor.sh`` - starts the CLI Tosca editor,
4288 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4290 - ``apexApps.sh cli-tosca-editor`` - starts the CLI Tosca editor,
4291 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4293 .. container:: paragraph
4295 On Windows systems use:
4297 .. container:: ulist
4299 - ``apexCLIToscaEditor.bat`` - starts the CLI Tosca editor,
4300 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4302 - ``apexApps.bat cli-tosca-editor`` - starts the CLI Tosca
4303 editor, all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4305 .. container:: paragraph
4307 Summary of alternatives to start the APEX CLI Tosca Editor:
4309 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4310 | Unix, Cygwin | Windows |
4311 +=================================================================+====================================================================+
4312 | .. container:: | .. container:: |
4314 | .. container:: listingblock | .. container:: listingblock |
4316 | .. container:: content | .. container:: content |
4318 | .. code:: | .. code:: |
4320 | # $APEX_HOME/bin/apexCLIToscaEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIToscaEditor.bat [args] |
4321 | # $APEX_HOME/bin/apexApps.sh cli-tosca-editor [args]| > %APEX_HOME%\bin\apexApps.bat cli-tosca-editor [args] |
4322 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4324 .. container:: paragraph
4326 The option ``-h`` provides a help screen with all command
4329 .. container:: listingblock
4331 .. container:: content
4335 usage: org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain [options...]
4337 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4338 -ac,--apex-config-file <APEX_CONFIG_FILE> name of the file containing apex configuration details
4339 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4340 -h,--help outputs the usage of this command
4341 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4342 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and
4343 continue executing the command file
4344 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will
4345 log to standard output if not specified or suppressed with "-nl" flag
4346 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4347 -nl,--no-log if specified, no logging or output of commands to standard output or
4348 log file is carried out
4349 -ot,--output-tosca-file <OUTPUT_TOSCA_FILE> name of a file that will contain the output ToscaServiceTemplate
4350 -t,--tosca-template-file <TOSCA_TEMPLATE_FILE> name of the input file containing tosca template which needs to be
4352 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4353 root from which to look for included macro files
4355 .. container:: paragraph
4357 An example command to run the APEX CLI Tosca editor on windows machine is given below.
4359 .. container:: listingblock
4361 .. container:: content
4365 %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
4371 .. container:: paragraph
4373 The APEX Client combines the Policy Editor, the
4374 Monitoring Client, and the Deployment Client into a single
4375 application. The standard way to use the APEX Full Client is
4376 via an installation of the *war* file on a webserver.
4377 However, the Full Client can also be started via command
4378 line. This will start a Grizzly webserver with the *war*
4379 deployed. Access to the Full Client is then via the provided
4382 .. container:: paragraph
4384 On UNIX and Cygwin systems use:
4386 .. container:: ulist
4388 - ``apexApps.sh full-client`` - simply starts the webserver
4389 with the Full Client
4391 .. container:: paragraph
4393 On Windows systems use:
4395 .. container:: ulist
4397 - ``apexApps.bat full-client`` - simply starts the
4398 webserver with the Full Client
4400 .. container:: paragraph
4402 The option ``-h`` provides a help screen with all command
4405 .. container:: listingblock
4407 .. container:: content
4411 usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]
4412 -h,--help outputs the usage of this command
4413 -p,--port <PORT> port to use for the Apex Services REST calls
4414 -t,--time-to-live <TIME_TO_LIVE> the amount of time in seconds that the server will run for before terminating
4416 .. container:: paragraph
4418 If the Full Client is started without any arguments the
4419 final messages will look similar to this:
4421 .. container:: listingblock
4423 .. container:: content
4427 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
4428 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.NetworkListener start
4429 INFO: Started listener bound to [localhost:18989]
4430 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.HttpServer start
4431 INFO: [HttpServer] Started.
4432 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
4434 .. container:: paragraph
4436 The last line states the URL on which the Monitoring Client
4437 can be accessed. The example above stated
4438 ``http://localhost:18989/apexservices``. In a web browser
4439 use the URL ``http://localhost:18989``.
4441 The APEX Application Launcher
4442 -----------------------------
4444 .. container:: paragraph
4446 The standard applications (Engine and CLI Editor)
4447 come with dedicated start scripts. For all other APEX
4448 applications, we provide an application launcher.
4450 .. container:: paragraph
4452 On UNIX and Cygwin systems use:
4454 .. container:: ulist
4456 - apexApps.sh\` - simply starts the application launcher
4458 .. container:: paragraph
4460 On Windows systems use:
4462 .. container:: ulist
4464 - ``apexApps.bat`` - simply starts the application launcher
4466 .. container:: paragraph
4468 Summary of alternatives to start the APEX application
4471 +-------------------------------------------------+---------------------------------------------------+
4472 | Unix, Cygwin | Windows |
4473 +=================================================+===================================================+
4474 | .. container:: | .. container:: |
4476 | .. container:: listingblock | .. container:: listingblock |
4478 | .. container:: content | .. container:: content |
4480 | .. code:: | .. code:: |
4482 | # $APEX_HOME/bin/apexApps.sh [args] | > %APEX_HOME%\bin\apexApps.bat [args] |
4483 +-------------------------------------------------+---------------------------------------------------+
4485 .. container:: paragraph
4487 The option ``-h`` provides a help screen with all launcher
4488 command line arguments.
4490 .. container:: listingblock
4492 .. container:: content
4496 apexApps.sh - runs APEX applications
4498 Usage: apexApps.sh [options] | [<application> [<application options>]]
4501 -d <app> - describes an application
4502 -l - lists all applications supported by this script
4503 -h - this help screen
4505 .. container:: paragraph
4507 Using ``-l`` lists all known application the launcher can
4510 .. container:: listingblock
4512 .. container:: content
4516 apexApps.sh: supported applications:
4517 --> ws-echo engine eng-monitoring full-client eng-deployment tpl-event-json model-2-cli rest-editor cli-editor ws-console
4519 .. container:: paragraph
4521 Using the ``-d <name>`` option describes the named
4522 application, for instance for the ``ws-console``:
4524 .. container:: listingblock
4526 .. container:: content
4530 apexApps.sh: application 'ws-console'
4531 --> a simple console sending events to APEX, connect to APEX consumer port
4533 .. container:: paragraph
4535 Launching an application is done by calling the script with
4536 only the application name and any CLI arguments for the
4537 application. For instance, starting the ``ws-echo``
4538 application with port ``8888``:
4540 .. container:: listingblock
4542 .. container:: content
4546 apexApps.sh ws-echo -p 8888
4548 Application: Create Event Templates
4549 -----------------------------------
4551 .. container:: paragraph
4553 **Status: Experimental**
4555 .. container:: paragraph
4557 This application takes a policy model (JSON or XML encoded)
4558 and generates templates for events in JSON format. This can
4559 help when a policy defines rather complex trigger or action
4560 events or complex events between states. The application can
4561 produce events for the types: stimuli (policy trigger
4562 events), internal (events between policy states), and
4563 response (action events).
4565 +----------------------------------------------------------------+------------------------------------------------------------------+
4566 | Unix, Cygwin | Windows |
4567 +================================================================+==================================================================+
4568 | .. container:: | .. container:: |
4570 | .. container:: listingblock | .. container:: listingblock |
4572 | .. container:: content | .. container:: content |
4574 | .. code:: | .. code:: |
4576 | # $APEX_HOME/bin/apexApps.sh tpl-event-json [args] | > %APEX_HOME%\bin\apexApps.bat tpl-event-json [args] |
4577 +----------------------------------------------------------------+------------------------------------------------------------------+
4579 .. container:: paragraph
4581 The option ``-h`` provides a help screen.
4583 .. container:: listingblock
4585 .. container:: content
4589 gen-model2event v{release-version} - generates JSON templates for events generated from a policy model
4590 usage: gen-model2event
4591 -h,--help prints this help and usage screen
4592 -m,--model <MODEL-FILE> set the input policy model file
4593 -t,--type <TYPE> set the event type for generation, one of:
4594 stimuli (trigger events), response (action
4595 events), internal (events between states)
4596 -v,--version prints the application version
4598 .. container:: paragraph
4600 The created templates are not valid events, instead they use
4601 some markup for values one will need to change to actual
4602 values. For instance, running the tool with the *Sample
4603 Domain* policy model as:
4605 .. container:: listingblock
4607 .. container:: content
4611 apexApps.sh tpl-event-json -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json -t stimuli
4613 .. container:: paragraph
4615 will produce the following status messages:
4617 .. container:: listingblock
4619 .. container:: content
4623 gen-model2event: starting Event generator
4624 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4627 .. container:: paragraph
4629 and then run the generator application producing two event
4630 templates. The first template is called ``Event0000``.
4632 .. container:: listingblock
4634 .. container:: content
4639 "name" : "Event0000",
4640 "nameSpace" : "org.onap.policy.apex.sample.events",
4641 "version" : "0.0.1",
4642 "source" : "Outside",
4644 "TestTemperature" : ###double: 0.0###,
4645 "TestTimestamp" : ###long: 0###,
4646 "TestMatchCase" : ###integer: 0###,
4647 "TestSlogan" : "###string###"
4650 .. container:: paragraph
4652 The values for the keys are marked with ``#`` and the
4653 expected type of the value. To create an actual stimuli
4654 event, all these markers need to be change to actual values,
4657 .. container:: listingblock
4659 .. container:: content
4664 "name" : "Event0000",
4665 "nameSpace" : "org.onap.policy.apex.sample.events",
4666 "version" : "0.0.1",
4667 "source" : "Outside",
4669 "TestTemperature" : 25,
4670 "TestTimestamp" : 123456789123456789,
4671 "TestMatchCase" : 1,
4672 "TestSlogan" : "Testing the Match Case with Temperature 25"
4675 Application: Convert a Policy Model to CLI Editor Commands
4676 ----------------------------------------------------------
4678 .. container:: paragraph
4680 **Status: Experimental**
4682 .. container:: paragraph
4684 This application takes a policy model (JSON or XML encoded)
4685 and generates commands for the APEX CLI Editor. This
4686 effectively reverses a policy specification realized with
4689 +-------------------------------------------------------------+---------------------------------------------------------------+
4690 | Unix, Cygwin | Windows |
4691 +=============================================================+===============================================================+
4692 | .. container:: | .. container:: |
4694 | .. container:: listingblock | .. container:: listingblock |
4696 | .. container:: content | .. container:: content |
4698 | .. code:: | .. code:: |
4700 | # $APEX_HOME/bin/apexApps.sh model-2-cli [args] | > %APEX_HOME%\bin\apexApps.bat model-2-cli [args] |
4701 +-------------------------------------------------------------+---------------------------------------------------------------+
4703 .. container:: paragraph
4705 The option ``-h`` provides a help screen.
4707 .. container:: listingblock
4709 .. container:: content
4713 usage: gen-model2cli
4714 -h,--help prints this help and usage screen
4715 -m,--model <MODEL-FILE> set the input policy model file
4716 -sv,--skip-validation switch of validation of the input file
4717 -v,--version prints the application version
4719 .. container:: paragraph
4721 For instance, running the tool with the *Sample Domain*
4724 .. container:: listingblock
4726 .. container:: content
4730 apexApps.sh model-2-cli -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json
4732 .. container:: paragraph
4734 will produce the following status messages:
4736 .. container:: listingblock
4738 .. container:: content
4742 gen-model2cli: starting CLI generator
4743 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4745 .. container:: paragraph
4747 and then run the generator application producing all CLI
4748 Editor commands and printing them to standard out.
4750 Application: Websocket Clients (Echo and Console)
4751 -------------------------------------------------
4753 .. container:: paragraph
4755 **Status: Production**
4757 .. container:: paragraph
4759 The application launcher also provides a Websocket echo
4760 client and a Websocket console client. The echo client
4761 connects to APEX and prints all events it receives from
4762 APEX. The console client connects to APEX, reads input from
4763 the command line, and sends this input as events to APEX.
4765 +------------------------------------------------------------+--------------------------------------------------------------+
4766 | Unix, Cygwin | Windows |
4767 +============================================================+==============================================================+
4768 | .. container:: | .. container:: |
4770 | .. container:: listingblock | .. container:: listingblock |
4772 | .. container:: content | .. container:: content |
4774 | .. code:: | .. code:: |
4776 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
4777 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
4778 +------------------------------------------------------------+--------------------------------------------------------------+
4780 .. container:: paragraph
4782 The arguments are the same for both applications:
4784 .. container:: ulist
4786 - ``-p`` defines the Websocket port to connect to (defaults
4789 - ``-s`` defines the host on which a Websocket server is
4790 running (defaults to ``localhost``)
4792 .. container:: paragraph
4794 A discussion on how to use these two applications to build
4795 an APEX system is detailed HowTo-Websockets.
4800 Introduction to APEX Logging
4801 ----------------------------
4803 .. container:: paragraph
4805 All APEX components make extensive use of logging using the
4806 logging façade `SLF4J <https://www.slf4j.org/>`__ with the
4807 backend `Logback <https://logback.qos.ch/>`__. Both are used
4808 off-the-shelve, so the standard documentation and
4809 configuration apply to APEX logging. For details on how to
4810 work with logback please see the `logback
4811 manual <https://logback.qos.ch/manual/index.html>`__.
4813 .. container:: paragraph
4815 The APEX applications is the logback configuration file
4816 ``$APEX_HOME/etc/logback.xml`` (Windows:
4817 ``%APEX_HOME%\etc\logback.xml``). The logging backend is set
4818 to no debug, i.e. logs from the logging framework should be
4821 .. container:: paragraph
4823 The configurable log levels work as expected:
4825 .. container:: ulist
4827 - *error* (or *ERROR*) is used for serious errors in the
4830 - *warn* (or *WARN*) is used for warnings, which in general
4831 can be ignored but might indicate some deeper problems
4833 - *info* (or *INFO*) is used to provide generally
4834 interesting messages for startup and policy execution
4836 - *debug* (or *DEBUG*) provides more details on startup and
4839 - *trace* (or *TRACE*) gives full details on every aspect
4840 of the APEX engine from start to end
4842 .. container:: paragraph
4844 The loggers can also be configured as expected. The standard
4845 configuration (after installing APEX) uses log level *info*
4846 on all APEX classes (components).
4848 .. container:: paragraph
4850 The applications and scripts in ``$APEX_HOME/bin`` (Windows:
4851 ``%APEX_HOME\bin``) are configured to use the logback
4852 configuration ``$APEX_HOME/etc/logback.xml`` (Windows:
4853 ``%APEX_HOME\etc\logback.xml``). There are multiple ways to
4854 use different logback configurations, for instance:
4856 .. container:: ulist
4858 - Maintain multiple configurations in ``etc``, for instance
4859 a ``logback-debug.xml`` for deep debugging and a
4860 ``logback-production.xml`` for APEX in production mode,
4861 then copy the required configuration file to the used
4862 ``logback.xml`` prior starting APEX
4864 - Edit the scripts in ``bin`` to use a different logback
4865 configuration file (only recommended if you are familiar
4866 with editing bash scripts or windows batch files)
4868 Standard Logging Configuration
4869 ------------------------------
4871 .. container:: paragraph
4873 The standard logging configuration defines a context *APEX*,
4874 which is used in the standard output pattern. The location
4875 for log files is defined in the property ``logDir`` and set
4876 to ``/var/log/onap/policy/apex-pdp``. The standard status
4877 listener is set to *NOP* and the overall logback
4878 configuration is set to no debug.
4880 .. container:: listingblock
4882 .. container:: content
4887 <configuration debug="false">
4888 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
4890 <contextName>Apex</contextName>
4891 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
4897 .. container:: paragraph
4899 The first appender defined is called ``STDOUT`` for logs to standard
4902 .. container:: listingblock
4904 .. container:: content
4909 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4911 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
4915 .. container:: paragraph
4917 The root level logger then is set to the level *info* using the
4918 standard out appender.
4920 .. container:: listingblock
4922 .. container:: content
4928 <appender-ref ref="STDOUT" />
4931 .. container:: paragraph
4933 The second appender is called ``FILE``. It writes logs to a file
4936 .. container:: listingblock
4938 .. container:: content
4943 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
4944 <file>${logDir}/apex.log</file>
4946 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4950 .. container:: paragraph
4952 The third appender is called ``CTXT_FILE``. It writes logs to a file
4955 .. container:: listingblock
4957 .. container:: content
4962 <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
4963 <file>${logDir}/apex_ctxt.log</file>
4965 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4969 .. container:: paragraph
4971 The last definitions are for specific loggers. The first logger
4972 captures all standard APEX classes. It is configured for log level
4973 *info* and uses the standard output and file appenders. The second
4974 logger captures APEX context classes responsible for context
4975 monitoring. It is configured for log level *trace* and uses the
4976 context file appender.
4978 .. container:: listingblock
4980 .. container:: content
4986 <logger name="org.onap.policy.apex" level="info" additivity="false">
4987 <appender-ref ref="STDOUT" />
4988 <appender-ref ref="FILE" />
4991 <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
4992 <appender-ref ref="CTXT_FILE" />
4995 Adding Logback Status and Debug
4996 -------------------------------
4998 .. container:: paragraph
5000 To activate logback status messages change the status listener
5001 from 'NOP' to for instance console.
5003 .. container:: listingblock
5005 .. container:: content
5009 <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
5011 .. container:: paragraph
5013 To activate all logback debugging, for instance to debug a new
5014 logback configuration, activate the debug attribute in the
5017 .. container:: listingblock
5019 .. container:: content
5023 <configuration debug="true">
5027 Logging External Components
5028 ---------------------------
5030 .. container:: paragraph
5032 Logback can also be configured to log any other, external
5033 components APEX is using, if they are using the common logging
5036 .. container:: paragraph
5038 For instance, the context component of APEX is using *Infinispan*
5039 and one can add a logger for this external component. The
5040 following example adds a logger for *Infinispan* using the
5041 standard output appender.
5043 .. container:: listingblock
5045 .. container:: content
5049 <logger name="org.infinispan" level="INFO" additivity="false">
5050 <appender-ref ref="STDOUT" />
5053 .. container:: paragraph
5055 Another example is Apache Zookeeper. The following example adds a
5056 logger for Zookeeper using the standard outout appender.
5058 .. container:: listingblock
5060 .. container:: content
5064 <logger name="org.apache.zookeeper.ClientCnxn" level="INFO" additivity="false">
5065 <appender-ref ref="STDOUT" />
5068 Configuring loggers for Policy Logic
5069 ------------------------------------
5071 .. container:: paragraph
5073 The logging for the logic inside a policy (task logic, task
5074 selection logic, state finalizer logic) can be configured separate
5075 from standard logging. The logger for policy logic is
5076 ``org.onap.policy.apex.executionlogging``. The following example
5079 .. container:: ulist
5081 - a new appender for standard out using a very simple pattern
5082 (simply the actual message)
5084 - a logger for policy logic to standard out using the new
5085 appender and the already described file appender.
5087 .. container:: listingblock
5089 .. container:: content
5093 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5095 <pattern>policy: %msg\n</pattern>
5099 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5100 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5101 <appender-ref ref="FILE" />
5104 .. container:: paragraph
5106 It is also possible to use specific logging for parts of policy
5107 logic. The following example defines a logger for task logic.
5109 .. container:: listingblock
5111 .. container:: content
5115 <logger name="org.onap.policy.apex.executionlogging.TaskExecutionLogging" level="TRACE" additivity="false">
5116 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5119 Rolling File Appenders
5120 ----------------------
5122 .. container:: paragraph
5124 Rolling file appenders are a good option for more complex logging
5125 of a production or complex testing APEX installation. The standard
5126 logback configuration can be used for these use cases. This
5127 section gives two examples for the standard logging and for
5130 .. container:: paragraph
5132 First the standard logging. The following example defines a
5133 rolling file appender. The appender rolls over on a daily basis.
5134 It allows for a file size of 100 MB.
5136 .. container:: listingblock
5138 .. container:: content
5142 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
5143 <file>${logDir}/apex.log</file>
5144 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5145 <!-- rollover daily -->
5146 <!-- <fileNamePattern>xstream-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> -->
5147 <fileNamePattern>${logDir}/apex_%d{yyyy-MM-dd}.%i.log.gz
5149 <maxHistory>4</maxHistory>
5150 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5151 <!-- or whenever the file size reaches 100MB -->
5152 <maxFileSize>100MB</maxFileSize>
5153 </timeBasedFileNamingAndTriggeringPolicy>
5157 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5162 .. container:: paragraph
5164 A very similar configuration can be used for a rolling file
5165 appender logging APEX context.
5167 .. container:: listingblock
5169 .. container:: content
5173 <appender name="CTXT-FILE"
5174 class="ch.qos.logback.core.rolling.RollingFileAppender">
5175 <file>${logDir}/apex_ctxt.log</file>
5176 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5177 <fileNamePattern>${logDir}/apex_ctxt_%d{yyyy-MM-dd}.%i.log.gz
5179 <maxHistory>4</maxHistory>
5180 <timeBasedFileNamingAndTriggeringPolicy
5181 class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5182 <maxFileSize>100MB</maxFileSize>
5183 </timeBasedFileNamingAndTriggeringPolicy>
5187 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5192 Example Configuration for Logging Logic
5193 ---------------------------------------
5195 .. container:: paragraph
5197 The following example shows a configuration that logs policy logic
5198 to standard out and a file (*info*). All other APEX components are
5199 logging to a file (*debug*).. This configuration an be used in a
5200 pre-production phase with the APEX engine still running in a
5201 separate terminal to monitor policy execution. This logback
5202 configuration is in the APEX installation as
5203 ``etc/logback-logic.xml``.
5205 .. container:: listingblock
5207 .. container:: content
5211 <configuration debug="false">
5212 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5214 <contextName>Apex</contextName>
5215 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5217 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5219 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
5223 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5224 <file>${logDir}/apex.log</file>
5227 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5232 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5234 <pattern>policy: %msg\n</pattern>
5238 <root level="error">
5239 <appender-ref ref="STDOUT" />
5242 <logger name="org.onap.policy.apex" level="debug" additivity="false">
5243 <appender-ref ref="FILE" />
5246 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5247 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5248 <appender-ref ref="FILE" />
5252 Example Configuration for a Production Server
5253 ---------------------------------------------
5255 .. container:: paragraph
5257 The following example shows a configuration that logs all APEX
5258 components, including policy logic, to a file (*debug*). This
5259 configuration an be used in a production phase with the APEX
5260 engine being executed as a service on a system without console
5261 output. This logback configuration is in the APEX installation as
5262 ``logback-server.xml``
5264 .. container:: listingblock
5266 .. container:: content
5270 <configuration debug="false">
5271 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5273 <contextName>Apex</contextName>
5274 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5276 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5277 <file>${logDir}/apex.log</file>
5280 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5285 <root level="debug">
5286 <appender-ref ref="FILE" />
5289 <logger name="org.onap.policy.apex.executionlogging" level="debug" additivity="false">
5290 <appender-ref ref="FILE" />
5294 Unsupported Features
5295 ^^^^^^^^^^^^^^^^^^^^
5297 .. container:: paragraph
5299 This section documents some legacy and unsupported features
5300 in apex-pdp. The documentation here has not been updated for
5301 recent versions of apex-pdp. For example, the apex-pdp models
5302 specified in this example should now be in TOSCA format.
5304 Building a System with Websocket Backend
5305 ----------------------------------------
5310 .. container:: paragraph
5312 Websocket is a protocol to run sockets of HTTP. Since it in
5313 essence a socket, the connection is realized between a
5314 server (waiting for connections) and a client (connecting to
5315 a server). Server/client separation is only important for
5316 connection establishment, once connected, everyone can
5317 send/receive on the same socket (as any standard socket
5320 .. container:: paragraph
5322 Standard Websocket implementations are simple, no
5323 publish/subscribe and no special event handling. Most
5324 servers simply send all incoming messages to all
5325 connections. There is a PubSub definition on top of
5326 Websocket called `WAMP <http://wamp-proto.org/>`__. APEX
5327 does not support WAMP at the moment.
5332 .. container:: paragraph
5335 356 <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5336 defines the standard Websocket API. This JSR is part of Jave
5337 EE 7 standard. For Java SE, several implementations exist in
5338 open source. Since Websockets are a stable standard and
5339 simple, most implementations are stable and ready to use. A
5340 lot of products support Websockets, like Spring, JBoss,
5341 Netty, … there are also Kafka extensions for Websockets.
5343 Websocket Example Code for Websocket clients (FOSS)
5344 ###################################################
5346 .. container:: paragraph
5348 There are a lot of implementations and examples available on
5349 Github for Websocket clients. If one is using Java EE 7,
5350 then one can also use the native Websocket implementation.
5351 Good examples for clients using simply Java SE are here:
5353 .. container:: ulist
5356 implementation <https://github.com/TooTallNate/Java-WebSocket>`__
5358 - `Websocket sending client example, using
5359 AWT <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ChatClient.java>`__
5361 - `Websocket receiving client example (simple echo
5362 client) <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ExampleClient.java>`__
5364 .. container:: paragraph
5366 For Java EE, the native Websocket API is explained here:
5368 .. container:: ulist
5371 docs <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5374 example <http://www.programmingforliving.com/2013/08/jsr-356-java-api-for-websocket-client-api.html>`__
5376 BCP: Websocket Configuration
5377 ############################
5379 .. container:: paragraph
5381 The probably best is to configure APEX for Websocket servers
5382 for input (ingress, consume) and output (egress, produce)
5383 interfaces. This means that APEX will start Websocket
5384 servers on named ports and wait for clients to connect.
5385 Advantage: once APEX is running all connectivity
5386 infrastructure is running as well. Consequence: if APEX is
5387 not running, everyone else is in the dark, too.
5389 .. container:: paragraph
5391 The best protocol to be used is JSON string. Each event on
5392 any interface is then a string with a JSON encoding. JSON
5393 string is a little bit slower than byte code, but we doubt
5394 that this will be noticeable. A further advantage of JSON
5395 strings over Websockets with APEX starting the servers: it
5396 is very easy to connect web browsers to such a system.
5397 Simple connect the web browser to the APEX sockets and
5398 send/read JSON strings.
5400 .. container:: paragraph
5402 Once APEX is started you simply connect Websocket clients to
5403 it, and send/receive event. When APEX is terminated, the
5404 Websocket servers go down, and the clients will be
5405 disconnected. APEX does not (yet) support auto-client
5406 reconnect nor WAMP, so clients might need to be restarted or
5407 reconnected manually after an APEX boot.
5409 Demo with VPN Policy Model
5410 ##########################
5412 .. container:: paragraph
5414 We assume that you have an APEX installation using the full
5415 package, i.e. APEX with all examples, of version ``0.5.6``
5416 or higher. We will use the VPN policy from the APEX examples
5419 .. container:: paragraph
5421 Now, have the following ready to start the demo:
5423 .. container:: ulist
5425 - 3 terminals on the host where APEX is running (we need 1
5426 for APEX and 1 for each client)
5428 - the events in the file
5429 ``$APEX_HOME/examples/events/VPN/SetupEvents.json`` open
5430 in an editor (we need to send those events to APEX)
5432 - the events in the file
5433 ``$APEX_HOME/examples/events/VPN/Link09Events.json`` open
5434 in an editor (we need to send those events to APEX)
5436 A Websocket Configuration for the VPN Domain
5437 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5439 .. container:: paragraph
5441 Create a new APEX configuration using the VPN policy
5442 model and configuring APEX as discussed above for
5443 Websockets. Copy the following configuration into
5444 ``$APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json``
5446 ``%APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json``):
5448 .. container:: listingblock
5450 .. container:: content
5456 "engineServiceParameters" : {
5457 "name" : "VPNApexEngine",
5458 "version" : "0.0.1",
5460 "instanceCount" : 1,
5461 "deploymentPort" : 12345,
5462 "policyModelFileName" : "examples/models/VPN/VPNPolicyModelAvro.json",
5463 "engineParameters" : {
5464 "executorParameters" : {
5466 "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
5469 "contextParameters" : {
5470 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
5471 "schemaParameters":{
5473 "parameterClassName" : "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
5479 "producerCarrierTechnologyParameters" : {
5480 "carrierTechnology" : "WEBSOCKET",
5481 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5487 "producerEventProtocolParameters" : {
5488 "eventProtocol" : "JSON"
5490 "consumerCarrierTechnologyParameters" : {
5491 "carrierTechnology" : "WEBSOCKET",
5492 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5498 "consumerEventProtocolParameters" : {
5499 "eventProtocol" : "JSON"
5506 .. container:: paragraph
5508 In a new terminal, start APEX with the new configuration for
5509 Websocket-Server ingress/egress:
5511 .. container:: listingblock
5513 .. container:: content
5518 #: $APEX_HOME/bin/apexApps.sh engine -c $APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json
5520 .. container:: listingblock
5522 .. container:: content
5527 #: %APEX_HOME%\bin\apexApps.bat engine -c %APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json
5529 .. container:: paragraph
5531 Wait for APEX to start, it takes a while to create all Websocket
5532 servers (about 8 seconds on a standard laptop without cached
5533 binaries). depending on your log messages, you will see no (some, a
5534 lot) log messages. If APEX starts correctly, the last few messages
5537 .. container:: listingblock
5539 .. container:: content
5544 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)
5545 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 ...
5546 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
5547 Started Apex service
5549 .. container:: paragraph
5551 APEX is running in the new terminal and will produce output when the
5552 policy is triggered/executed.
5554 Run the Websocket Echo Client
5555 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5557 .. container:: paragraph
5559 The echo client is included in an APEX full installation. To run
5560 the client, open a new shell (Unix, Cygwin) or command prompt
5561 (``cmd`` on Windows). Then use the APEX application launcher to
5565 APEX engine needs to run first
5566 The example assumes that an APEX engine configured for *produce* carrier technology Websocket and *JSON* event protocol is executed first.
5568 +---------------------------------------------------------+-----------------------------------------------------------+
5569 | Unix, Cygwin | Windows |
5570 +=========================================================+===========================================================+
5571 | .. container:: | .. container:: |
5573 | .. container:: listingblock | .. container:: listingblock |
5575 | .. container:: content | .. container:: content |
5577 | .. code:: | .. code:: |
5579 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
5580 +---------------------------------------------------------+-----------------------------------------------------------+
5582 .. container:: paragraph
5584 Use the following command line arguments for server and port of
5585 the Websocket server. The port should be the same as configured in
5586 the APEX engine. The server host should be the host on which the
5587 APEX engine is running
5589 .. container:: ulist
5591 - ``-p`` defines the Websocket port to connect to (defaults to
5594 - ``-s`` defines the host on which a Websocket server is running
5595 (defaults to ``localhost``)
5597 .. container:: paragraph
5599 Let’s assume that there is an APEX engine running, configured for
5600 produce Websocket carrier technology, as server, for port 42452,
5601 with produce event protocol JSON,. If we start the console client
5602 on the same host, we can omit the ``-s`` options. We start the
5605 .. container:: listingblock
5607 .. container:: content
5611 # $APEX_HOME/bin/apexApps.sh ws-echo -p 42452 (1)
5612 > %APEX_HOME%\bin\apexApps.bat ws-echo -p 42452 (2)
5614 .. container:: colist arabic
5616 +-------+--------------------------------+
5617 | **1** | Start client on Unix or Cygwin |
5618 +-------+--------------------------------+
5619 | **2** | Start client on Windows |
5620 +-------+--------------------------------+
5622 .. container:: paragraph
5624 Once started successfully, the client will produce the following
5625 messages (assuming we used ``-p 42452`` and an APEX engine is
5626 running on ``localhost`` with the same port:
5628 .. container:: listingblock
5630 .. container:: content
5634 ws-simple-echo: starting simple event echo
5635 --> server: localhost
5638 Once started, the application will simply print out all received events to standard out.
5639 Each received event will be prefixed by '---' and suffixed by '===='
5642 ws-simple-echo: opened connection to APEX (Web Socket Protocol Handshake)
5644 Run the Websocket Console Client
5645 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5647 .. container:: paragraph
5649 The console client is included in an APEX full installation. To
5650 run the client, open a new shell (Unix, Cygwin) or command prompt
5651 (``cmd`` on Windows). Then use the APEX application launcher to
5655 APEX engine needs to run first
5656 The example assumes that an APEX engine configured for *consume* carrier technology Websocket and *JSON* event
5657 protocol is executed first.
5659 +------------------------------------------------------------+--------------------------------------------------------------+
5660 | Unix, Cygwin | Windows |
5661 +============================================================+==============================================================+
5662 | .. container:: | .. container:: |
5664 | .. container:: listingblock | .. container:: listingblock |
5666 | .. container:: content | .. container:: content |
5668 | .. code:: | .. code:: |
5670 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
5671 +------------------------------------------------------------+--------------------------------------------------------------+
5673 .. container:: paragraph
5675 Use the following command line arguments for server and port of
5676 the Websocket server. The port should be the same as configured in
5677 the APEX engine. The server host should be the host on which the
5678 APEX engine is running
5680 .. container:: ulist
5682 - ``-p`` defines the Websocket port to connect to (defaults to
5685 - ``-s`` defines the host on which a Websocket server is running
5686 (defaults to ``localhost``)
5688 .. container:: paragraph
5690 Let’s assume that there is an APEX engine running, configured for
5691 consume Websocket carrier technology, as server, for port 42450,
5692 with consume event protocol JSON,. If we start the console client
5693 on the same host, we can omit the ``-s`` options. We start the
5696 .. container:: listingblock
5698 .. container:: content
5702 # $APEX_HOME/bin/apexApps.sh ws-console -p 42450 (1)
5703 > %APEX_HOME%\bin\apexApps.sh ws-console -p 42450 (2)
5705 .. container:: colist arabic
5707 +-------+--------------------------------+
5708 | **1** | Start client on Unix or Cygwin |
5709 +-------+--------------------------------+
5710 | **2** | Start client on Windows |
5711 +-------+--------------------------------+
5713 .. container:: paragraph
5715 Once started successfully, the client will produce the following
5716 messages (assuming we used ``-p 42450`` and an APEX engine is
5717 running on ``localhost`` with the same port:
5719 .. container:: listingblock
5721 .. container:: content
5725 ws-simple-console: starting simple event console
5726 --> server: localhost
5729 - terminate the application typing 'exit<enter>' or using 'CTRL+C'
5730 - events are created by a non-blank starting line and terminated by a blank line
5733 ws-simple-console: opened connection to APEX (Web Socket Protocol Handshake)
5738 .. container:: paragraph
5740 Now you have the full system up and running:
5742 .. container:: ulist
5744 - Terminal 1: APEX ready and loaded
5746 - Terminal 2: an echo client, printing received messages produced
5749 - Terminal 2: a console client, waiting for input on the console
5750 (standard in) and sending text to APEX
5752 .. container:: paragraph
5754 We started the engine with the VPN policy example. So all the
5755 events we are using now are located in files in the following
5758 .. container:: listingblock
5760 .. container:: content
5765 #: $APEX_HOME/examples/events/VPN
5766 > %APEX_HOME%\examples\events\VPN
5768 .. container:: paragraph
5770 To sends events, simply copy the content of the event files into
5771 Terminal 3 (the console client). It will read multi-line JSON text
5772 and send the events. So copy the content of ``SetupEvents.json`` into
5773 the client. APEX will trigger a policy and produce some output, the
5774 echo client will also print some events created in the policy. In
5775 Terminal 1 (APEX) you’ll see some status messages from the policy as:
5777 .. container:: listingblock
5779 .. container:: content
5784 {Link=L09, LinkUp=true}
5786 outFields: {Link=L09, LinkUp=true}
5787 {Link=L10, LinkUp=true}
5790 outFields: {Link=L10, LinkUp=true}
5791 {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5793 C 300 300 [L09, L10]
5794 outFields: {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5795 {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5798 C 300 300 [L09, L10]
5799 outFields: {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5800 {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5803 C 300 300 [L09, L10]
5804 D 300 400 [L09, L10]
5805 outFields: {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5806 {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5809 B 300 299 [L09, L10]
5810 C 300 300 [L09, L10]
5811 D 300 400 [L09, L10]
5812 outFields: {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5814 .. container:: paragraph
5816 In Terminal 2 (echo-client) you see the received events, the last two
5819 .. container:: listingblock
5821 .. container:: content
5826 ws-simple-echo: received
5827 ---------------------------------
5829 "name": "VPNCustomerCtxtActEvent",
5831 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5834 "CustomerName": "C",
5835 "LinkList": "L09 L10",
5839 =================================
5841 ws-simple-echo: received
5842 ---------------------------------
5844 "name": "VPNCustomerCtxtActEvent",
5846 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5849 "CustomerName": "D",
5850 "LinkList": "L09 L10",
5854 =================================
5856 .. container:: paragraph
5858 Congratulations, you have triggered a policy in APEX using
5859 Websockets, the policy did run through, created events, picked up by
5862 .. container:: paragraph
5864 Now you can send the Link 09 and Link 10 events, they will trigger
5865 the actual VPN policy and some calculations are made. Let’s take the
5866 Link 09 events from ``Link09Events.json``, copy them all into
5867 Terminal 3 (the console). APEX will run the policy (with some status
5868 output), and the echo client will receive and print events.
5870 .. container:: paragraph
5872 To terminate the applications, simply press ``CTRL+C`` in Terminal 1
5873 (APEX). This will also terminate the echo-client in Terminal 2. Then
5874 type ``exit<enter>`` in Terminal 3 (or ``CTRL+C``) to terminate the