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 AVRO Schema Handler
2040 #############################
2042 .. container:: paragraph
2044 The AVRO schema handler is added to the configuration as
2047 .. container:: listingblock
2049 .. container:: content
2053 "engineServiceParameters":{
2054 "engineParameters":{
2055 "contextParameters":{
2056 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2057 "schemaParameters":{
2059 "parameterClassName" :
2060 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
2067 .. container:: paragraph
2069 Using the AVRO schema handler has one limitation: AVRO
2070 only supports field names that represent valid Java class
2071 names. This means only letters and the character ``_``
2072 are supported. Characters commonly used in field names,
2073 such as ``.`` and ``-``, are not supported by AVRO. for
2074 more information see `Avro Spec:
2075 Names <https://avro.apache.org/docs/1.8.1/spec.html#names>`__.
2077 .. container:: paragraph
2079 To work with this limitation, the APEX Avro plugin will
2080 parse a given AVRO definition and replace *all*
2081 occurrences of ``.`` and ``-`` with a ``_``. This means
2084 .. container:: ulist
2086 - In a policy model, if the AVRO schema defined a field
2087 as ``my-name`` the policy logic should access it as
2090 - In a policy model, if the AVRO schema defined a field
2091 as ``my.name`` the policy logic should access it as
2094 - There should be no field names that convert to the
2097 .. container:: ulist
2099 - For instance the simultaneous use of
2100 ``my_name``, ``my.name``, and ``my-name`` should
2103 - If not avoided, the event processing might
2104 create unwanted side effects
2106 - If field names use any other not-supported character,
2107 the AVRO plugin will reject it
2109 .. container:: ulist
2111 - Since AVRO uses lazy initialization, this
2112 rejection might only become visible at runtime
2114 Configure Task Parameters
2115 #########################
2117 .. container:: paragraph
2119 The Task Parameters are added to the configuration as
2122 .. container:: listingblock
2124 .. container:: content
2128 "engineServiceParameters": {
2129 "engineParameters": {
2132 "key": "ParameterKey1",
2133 "value": "ParameterValue1"
2136 "taskId": "Task_Act0",
2137 "key": "ParameterKey2",
2138 "value": "ParameterValue2"
2144 .. container:: paragraph
2146 TaskParameters can be used to pass parameters from ApexConfig
2147 to the policy logic. In the config, these are optional.
2148 The list of task parameters provided in the config may be added
2149 to the tasks or existing task parameters in the task will be overriden.
2151 .. container:: paragraph
2153 If taskId is provided in ApexConfig for an entry, then that
2154 parameter is updated only for that particular task. Otherwise,
2155 the task parameter is added to all tasks.
2157 Carrier Technologies
2158 --------------------
2160 .. container:: paragraph
2162 Carrier technologies define how APEX receives (input) and
2163 sends (output) events. They can be used in any combination,
2164 using asynchronous or synchronous mode. There can also be
2165 any number of carrier technologies for the input (consume)
2166 and the output (produce) interface.
2168 .. container:: paragraph
2170 Supported *input* technologies are:
2172 .. container:: ulist
2174 - Standard input, read events from the standard input
2175 (console), not suitable for APEX background servers
2177 - File input, read events from a file
2179 - Kafka, read events from a Kafka system
2181 - Websockets, read events from a Websocket
2185 - REST (synchronous and asynchronous), additionally as
2188 - Event Requestor, allows reading of events that have been
2189 looped back into APEX
2191 .. container:: paragraph
2193 Supported *output* technologies are:
2195 .. container:: ulist
2197 - Standard output, write events to the standard output
2198 (console), not suitable for APEX background servers
2200 - File output, write events to a file
2202 - Kafka, write events to a Kafka system
2204 - Websockets, write events to a Websocket
2208 - REST (synchronous and asynchronous), additionally as
2211 - Event Requestor, allows events to be looped back into
2214 .. container:: paragraph
2216 New carrier technologies can be added as plugins to APEX or
2217 developed outside APEX and added to an APEX deployment.
2222 .. container:: paragraph
2224 Standard IO does not require a specific plugin, it is
2225 supported be default.
2229 .. container:: paragraph
2231 APEX will take events from its standard input. This
2232 carrier is good for testing, but certainly not for a
2233 use case where APEX runs as a server. The
2234 configuration is as follows:
2236 .. container:: listingblock
2238 .. container:: content
2242 "carrierTechnologyParameters" : {
2243 "carrierTechnology" : "FILE", (1)
2245 "standardIO" : true (2)
2249 .. container:: colist arabic
2251 +-------+---------------------------------------+
2252 | **1** | standard input is considered a file |
2253 +-------+---------------------------------------+
2254 | **2** | file descriptor set to standard input |
2255 +-------+---------------------------------------+
2260 .. container:: paragraph
2262 APEX will send events to its standard output. This
2263 carrier is good for testing, but certainly not for a
2264 use case where APEX runs as a server. The
2265 configuration is as follows:
2267 .. container:: listingblock
2269 .. container:: content
2273 "carrierTechnologyParameters" : {
2274 "carrierTechnology" : "FILE", (1)
2276 "standardIO" : true (2)
2280 .. container:: colist arabic
2282 +-------+----------------------------------------+
2283 | **1** | standard output is considered a file |
2284 +-------+----------------------------------------+
2285 | **2** | file descriptor set to standard output |
2286 +-------+----------------------------------------+
2291 .. container:: paragraph
2293 File IO does not require a specific plugin, it is
2294 supported be default.
2299 .. container:: paragraph
2301 APEX will take events from a file. The same file
2302 should not be used as an output. The configuration is
2305 .. container:: listingblock
2307 .. container:: content
2311 "carrierTechnologyParameters" : {
2312 "carrierTechnology" : "FILE", (1)
2314 "fileName" : "examples/events/SampleDomain/EventsIn.xmlfile" (2)
2318 .. container:: colist arabic
2320 +-------+------------------------------------------+
2321 | **1** | set file input |
2322 +-------+------------------------------------------+
2323 | **2** | the name of the file to read events from |
2324 +-------+------------------------------------------+
2328 .. container:: paragraph
2330 APEX will write events to a file. The same file should
2331 not be used as an input. The configuration is as
2334 .. container:: listingblock
2336 .. container:: content
2340 "carrierTechnologyParameters" : {
2341 "carrierTechnology" : "FILE", (1)
2343 "fileName" : "examples/events/SampleDomain/EventsOut.xmlfile" (2)
2347 .. container:: colist arabic
2349 +-------+-----------------------------------------+
2350 | **1** | set file output |
2351 +-------+-----------------------------------------+
2352 | **2** | the name of the file to write events to |
2353 +-------+-----------------------------------------+
2358 .. container:: paragraph
2360 Event Requestor IO does not require a specific plugin, it
2361 is supported be default. It should only be used with the
2362 APEX event protocol.
2364 Event Requestor Input
2365 =====================
2367 .. container:: paragraph
2369 APEX will take events from APEX.
2371 .. container:: listingblock
2373 .. container:: content
2377 "carrierTechnologyParameters" : {
2378 "carrierTechnology": "EVENT_REQUESTOR" (1)
2381 .. container:: colist arabic
2383 +-------+---------------------------+
2384 | **1** | set event requestor input |
2385 +-------+---------------------------+
2387 Event Requestor Output
2388 ======================
2390 .. container:: paragraph
2392 APEX will write events to APEX.
2394 .. container:: listingblock
2396 .. container:: content
2400 "carrierTechnologyParameters" : {
2401 "carrierTechnology": "EVENT_REQUESTOR" (1)
2404 Peering Event Requestors
2405 ========================
2407 .. container:: paragraph
2409 When using event requestors, they need to be peered.
2410 This means an event requestor output needs to be
2411 peered (associated) with an event requestor input. The
2412 following example shows the use of an event requestor
2413 with the APEX event protocol and the peering of output
2416 .. container:: listingblock
2418 .. container:: content
2422 "eventInputParameters": {
2423 "EventRequestorConsumer": {
2424 "carrierTechnologyParameters": {
2425 "carrierTechnology": "EVENT_REQUESTOR" (1)
2427 "eventProtocolParameters": {
2428 "eventProtocol": "APEX" (2)
2430 "eventNameFilter": "InputEvent", (3)
2431 "requestorMode": true, (4)
2432 "requestorPeer": "EventRequestorProducer", (5)
2433 "requestorTimeout": 500 (6)
2436 "eventOutputParameters": {
2437 "EventRequestorProducer": {
2438 "carrierTechnologyParameters": {
2439 "carrierTechnology": "EVENT_REQUESTOR" (7)
2441 "eventProtocolParameters": {
2442 "eventProtocol": "APEX" (8)
2444 "eventNameFilter": "EventListEvent", (9)
2445 "requestorMode": true, (10)
2446 "requestorPeer": "EventRequestorConsumer", (11)
2447 "requestorTimeout": 500 (12)
2451 .. container:: colist arabic
2453 +-----------------------------------+-----------------------------------+
2454 | **1** | event requestor on a consumer |
2455 +-----------------------------------+-----------------------------------+
2456 | **2** | with APEX event protocol |
2457 +-----------------------------------+-----------------------------------+
2458 | **3** | optional filter (best to use a |
2459 | | filter to prevent unwanted events |
2460 | | on the consumer side) |
2461 +-----------------------------------+-----------------------------------+
2462 | **4** | activate requestor mode |
2463 +-----------------------------------+-----------------------------------+
2464 | **5** | the peer to the output (must |
2465 | | match the output carrier) |
2466 +-----------------------------------+-----------------------------------+
2467 | **6** | an optional timeout in |
2469 +-----------------------------------+-----------------------------------+
2470 | **7** | event requestor on a producer |
2471 +-----------------------------------+-----------------------------------+
2472 | **8** | with APEX event protocol |
2473 +-----------------------------------+-----------------------------------+
2474 | **9** | optional filter (best to use a |
2475 | | filter to prevent unwanted events |
2476 | | on the consumer side) |
2477 +-----------------------------------+-----------------------------------+
2478 | **10** | activate requestor mode |
2479 +-----------------------------------+-----------------------------------+
2480 | **11** | the peer to the output (must |
2481 | | match the input carrier) |
2482 +-----------------------------------+-----------------------------------+
2483 | **12** | an optional timeout in |
2485 +-----------------------------------+-----------------------------------+
2490 .. container:: paragraph
2492 Kafka IO is supported by the APEX Kafka plugin. The
2493 configurations below are examples. APEX will take any
2494 configuration inside the parameter object and forward it
2495 to Kafka. More information on Kafka specific
2496 configuration parameters can be found in the Kafka
2499 .. container:: ulist
2502 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html>`__
2505 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html>`__
2509 .. container:: paragraph
2511 APEX will receive events from the Apache Kafka
2512 messaging system. The input is uni-directional, an
2513 engine will only receive events from the input but not
2514 send any event to the input.
2516 .. container:: listingblock
2518 .. container:: content
2522 "carrierTechnologyParameters" : {
2523 "carrierTechnology" : "KAFKA", (1)
2524 "parameterClassName" :
2525 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2527 "bootstrapServers" : "localhost:49092", (2)
2528 "groupId" : "apex-group-id", (3)
2529 "enableAutoCommit" : true, (4)
2530 "autoCommitTime" : 1000, (5)
2531 "sessionTimeout" : 30000, (6)
2532 "consumerPollTime" : 100, (7)
2533 "consumerTopicList" : ["apex-in-0", "apex-in-1"], (8)
2535 "org.apache.kafka.common.serialization.StringDeserializer", (9)
2536 "valueDeserializer" :
2537 "org.apache.kafka.common.serialization.StringDeserializer" (10)
2538 "kafkaProperties": [ (11)
2540 "security.protocol",
2544 "ssl.truststore.type",
2548 "ssl.truststore.location",
2549 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2552 "ssl.truststore.password",
2561 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2564 "ssl.endpoint.identification.algorithm",
2571 .. container:: colist arabic
2573 +--------+-------------------------------------+
2574 | **1** | set Kafka as carrier technology |
2575 +--------+-------------------------------------+
2576 | **2** | bootstrap server and port |
2577 +--------+-------------------------------------+
2578 | **3** | a group identifier |
2579 +--------+-------------------------------------+
2580 | **4** | flag for auto-commit |
2581 +--------+-------------------------------------+
2582 | **5** | auto-commit timeout in milliseconds |
2583 +--------+-------------------------------------+
2584 | **6** | session timeout in milliseconds |
2585 +--------+-------------------------------------+
2586 | **7** | consumer poll time in milliseconds |
2587 +--------+-------------------------------------+
2588 | **8** | consumer topic list |
2589 +--------+-------------------------------------+
2590 | **9** | key for the Kafka de-serializer |
2591 +--------+-------------------------------------+
2592 | **10** | value for the Kafka de-serializer |
2593 +--------+-------------------------------------+
2594 | **11** | properties for Kafka connectivity |
2595 +--------+-------------------------------------+
2597 .. container:: paragraph
2599 Kindly note that the above Kafka properties is just a reference,
2600 and the actual properties required depends on the Kafka server installation.
2604 .. container:: paragraph
2606 APEX will send events to the Apache Kafka messaging
2607 system. The output is uni-directional, an engine will
2608 send events to the output but not receive any event
2611 .. container:: listingblock
2613 .. container:: content
2617 "carrierTechnologyParameters" : {
2618 "carrierTechnology" : "KAFKA", (1)
2619 "parameterClassName" :
2620 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2622 "bootstrapServers" : "localhost:49092", (2)
2625 "batchSize" : 16384, (5)
2626 "lingerTime" : 1, (6)
2627 "bufferMemory" : 33554432, (7)
2628 "producerTopic" : "apex-out", (8)
2630 "org.apache.kafka.common.serialization.StringSerializer", (9)
2632 "org.apache.kafka.common.serialization.StringSerializer" (10)
2633 "kafkaProperties": [ (11)
2635 "security.protocol",
2639 "ssl.truststore.type",
2643 "ssl.truststore.location",
2644 "/opt/app/policy/apex-pdp/etc/ssl/test.jks"
2647 "ssl.truststore.password",
2656 "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"policy\" password=\"policy\";"
2659 "ssl.endpoint.identification.algorithm",
2666 .. container:: colist arabic
2668 +--------+-----------------------------------+
2669 | **1** | set Kafka as carrier technology |
2670 +--------+-----------------------------------+
2671 | **2** | bootstrap server and port |
2672 +--------+-----------------------------------+
2673 | **3** | acknowledgement strategy |
2674 +--------+-----------------------------------+
2675 | **4** | number of retries |
2676 +--------+-----------------------------------+
2677 | **5** | batch size |
2678 +--------+-----------------------------------+
2679 | **6** | time to linger in milliseconds |
2680 +--------+-----------------------------------+
2681 | **7** | buffer memory in byte |
2682 +--------+-----------------------------------+
2683 | **8** | producer topic |
2684 +--------+-----------------------------------+
2685 | **9** | key for the Kafka serializer |
2686 +--------+-----------------------------------+
2687 | **10** | value for the Kafka serializer |
2688 +--------+-----------------------------------+
2689 | **11** | properties for Kafka connectivity |
2690 +--------+-----------------------------------+
2692 .. container:: paragraph
2694 Kindly note that the above Kafka properties is just a reference,
2695 and the actual properties required depends on the Kafka server installation.
2700 .. container:: paragraph
2702 APEX supports the Java Messaging Service (JMS) as input
2703 as well as output. JMS IO is supported by the APEX JMS
2704 plugin. Input and output support an event encoding as
2705 text (JSON string) or object (serialized object). The
2706 input configuration is the same for both encodings, the
2707 output configuration differs.
2711 .. container:: paragraph
2713 APEX will receive events from a JMS messaging system.
2714 The input is uni-directional, an engine will only
2715 receive events from the input but not send any event
2718 .. container:: listingblock
2720 .. container:: content
2724 "carrierTechnologyParameters" : {
2725 "carrierTechnology" : "JMS", (1)
2726 "parameterClassName" :
2727 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2728 "parameters" : { (2)
2729 "initialContextFactory" :
2730 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2731 "connectionFactory" : "ConnectionFactory", (4)
2732 "providerURL" : "remote://localhost:5445", (5)
2733 "securityPrincipal" : "guest", (6)
2734 "securityCredentials" : "IAmAGuest", (7)
2735 "consumerTopic" : "jms/topic/apexIn" (8)
2739 .. container:: colist arabic
2741 +-----------------------------------+-----------------------------------+
2742 | **1** | set JMS as carrier technology |
2743 +-----------------------------------+-----------------------------------+
2744 | **2** | set all JMS specific parameters |
2745 +-----------------------------------+-----------------------------------+
2746 | **3** | the context factory, in this case |
2747 | | from JBOSS (it requires the |
2749 | | org.jboss:jboss-remote-naming:2.0 |
2751 | | or a different version to be in |
2752 | | the directory ``$APEX_HOME/lib`` |
2753 | | or ``%APEX_HOME%\lib`` |
2754 +-----------------------------------+-----------------------------------+
2755 | **4** | a connection factory for the JMS |
2757 +-----------------------------------+-----------------------------------+
2758 | **5** | URL with host and port of the JMS |
2760 +-----------------------------------+-----------------------------------+
2761 | **6** | access credentials, user name |
2762 +-----------------------------------+-----------------------------------+
2763 | **7** | access credentials, user password |
2764 +-----------------------------------+-----------------------------------+
2765 | **8** | the JMS topic to listen to |
2766 +-----------------------------------+-----------------------------------+
2768 JMS Output with Text
2769 ====================
2771 .. container:: paragraph
2773 APEX engine send events to a JMS messaging system. The
2774 output is uni-directional, an engine will send events
2775 to the output but not receive any event from output.
2777 .. container:: listingblock
2779 .. container:: content
2783 "carrierTechnologyParameters" : {
2784 "carrierTechnology" : "JMS", (1)
2785 "parameterClassName" :
2786 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2787 "parameters" : { (2)
2788 "initialContextFactory" :
2789 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2790 "connectionFactory" : "ConnectionFactory", (4)
2791 "providerURL" : "remote://localhost:5445", (5)
2792 "securityPrincipal" : "guest", (6)
2793 "securityCredentials" : "IAmAGuest", (7)
2794 "producerTopic" : "jms/topic/apexOut", (8)
2795 "objectMessageSending": "false" (9)
2799 .. container:: colist arabic
2801 +-----------------------------------+-----------------------------------+
2802 | **1** | set JMS as carrier technology |
2803 +-----------------------------------+-----------------------------------+
2804 | **2** | set all JMS specific parameters |
2805 +-----------------------------------+-----------------------------------+
2806 | **3** | the context factory, in this case |
2807 | | from JBOSS (it requires the |
2809 | | org.jboss:jboss-remote-naming:2.0 |
2811 | | or a different version to be in |
2812 | | the directory ``$APEX_HOME/lib`` |
2813 | | or ``%APEX_HOME%\lib`` |
2814 +-----------------------------------+-----------------------------------+
2815 | **4** | a connection factory for the JMS |
2817 +-----------------------------------+-----------------------------------+
2818 | **5** | URL with host and port of the JMS |
2820 +-----------------------------------+-----------------------------------+
2821 | **6** | access credentials, user name |
2822 +-----------------------------------+-----------------------------------+
2823 | **7** | access credentials, user password |
2824 +-----------------------------------+-----------------------------------+
2825 | **8** | the JMS topic to write to |
2826 +-----------------------------------+-----------------------------------+
2827 | **9** | set object messaging to ``false`` |
2828 | | means it sends JSON text |
2829 +-----------------------------------+-----------------------------------+
2831 JMS Output with Object
2832 ======================
2834 .. container:: paragraph
2836 To configure APEX for JMS objects on the output
2837 interface use the same configuration as above (for
2838 output). Simply change the ``objectMessageSending``
2839 parameter to ``true``.
2844 .. container:: paragraph
2846 APEX supports the Websockets as input as well as output.
2847 WS IO is supported by the APEX Websocket plugin. This
2848 carrier technology does only support uni-directional
2849 communication. APEX will not send events to a Websocket
2850 input and any event sent to a Websocket output will
2851 result in an error log.
2853 .. container:: paragraph
2855 The input can be configured as client (APEX connects to
2856 an existing Websocket server) or server (APEX starts a
2857 Websocket server). The same applies to the output. Input
2858 and output can both use a client or a server
2859 configuration, or separate configurations (input as
2860 client and output as server, input as server and output
2861 as client). Each configuration should use its own
2862 dedicated port to avoid any communication loops. The
2863 configuration of a Websocket client is the same for input
2864 and output. The configuration of a Websocket server is
2865 the same for input and output.
2870 .. container:: paragraph
2872 APEX will connect to a given Websocket server. As
2873 input, it will receive events from the server but not
2874 send any events. As output, it will send events to the
2875 server and any event received from the server will
2876 result in an error log.
2878 .. container:: listingblock
2880 .. container:: content
2884 "carrierTechnologyParameters" : {
2885 "carrierTechnology" : "WEBSOCKET", (1)
2886 "parameterClassName" :
2887 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2889 "host" : "localhost", (2)
2894 .. container:: colist arabic
2896 +-------+------------------------------------------------------+
2897 | **1** | set Websocket as carrier technology |
2898 +-------+------------------------------------------------------+
2899 | **2** | the host name on which a Websocket server is running |
2900 +-------+------------------------------------------------------+
2901 | **3** | the port of that Websocket server |
2902 +-------+------------------------------------------------------+
2907 .. container:: paragraph
2909 APEX will start a Websocket server, which will accept
2910 any Websocket clients to connect. As input, it will
2911 receive events from the server but not send any
2912 events. As output, it will send events to the server
2913 and any event received from the server will result in
2916 .. container:: listingblock
2918 .. container:: content
2922 "carrierTechnologyParameters" : {
2923 "carrierTechnology" : "WEBSOCKET", (1)
2924 "parameterClassName" :
2925 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2927 "wsClient" : false, (2)
2932 .. container:: colist arabic
2934 +-------+------------------------------------------------------------+
2935 | **1** | set Websocket as carrier technology |
2936 +-------+------------------------------------------------------------+
2937 | **2** | disable client, so that APEX will start a Websocket server |
2938 +-------+------------------------------------------------------------+
2939 | **3** | the port for the Websocket server APEX will start |
2940 +-------+------------------------------------------------------------+
2945 .. container:: paragraph
2947 APEX can act as REST client on the input as well as on
2948 the output interface. The media type is
2949 ``application/json``, so this plugin only works with
2950 the JSON Event protocol.
2955 .. container:: paragraph
2957 APEX will connect to a given URL to receive events,
2958 but not send any events. The server is polled, i.e.
2959 APEX will do an HTTP GET, take the result, and then do
2960 the next GET. Any required timing needs to be handled
2961 by the server configured via the URL. For instance,
2962 the server could support a wait timeout via the URL as
2964 The httpCodeFilter is used for filtering the status
2965 code, and it can be configured as a regular expression
2966 string. The default httpCodeFilter is "[2][0-9][0-9]"
2967 - for successful response codes.
2968 The response with HTTP status code that matches the
2969 given regular expression is forwarded to the task,
2970 otherwise it is logged as a failure.
2972 .. container:: listingblock
2974 .. container:: content
2978 "carrierTechnologyParameters" : {
2979 "carrierTechnology" : "RESTCLIENT", (1)
2980 "parameterClassName" :
2981 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
2983 "url" : "http://example.org:8080/triggers/events", (2)
2984 "httpMethod": "GET", (3)
2985 "httpCodeFilter" : "[2][0-9][0-9]", (4)
2986 "httpHeaders" : [ (5)
2987 ["Keep-Alive", "300"],
2988 ["Cache-Control", "no-cache"]
2993 .. container:: colist arabic
2995 +-------+--------------------------------------------------+
2996 | **1** | set REST client as carrier technology |
2997 +-------+--------------------------------------------------+
2998 | **2** | the URL of the HTTP server for events |
2999 +-------+--------------------------------------------------+
3000 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3001 | | optional, defaults to GET |
3002 +-------+--------------------------------------------------+
3003 | **4** | use HTTP CODE FILTER for filtering status code, |
3004 | | optional, defaults to [2][0-9][0-9] |
3005 +-------+--------------------------------------------------+
3006 | **5** | HTTP headers to use on the REST request, |
3008 +-------+--------------------------------------------------+
3013 .. container:: paragraph
3015 APEX will connect to a given URL to send events, but
3016 not receive any events. The default HTTP operation is
3017 POST (no configuration required). To change it to PUT
3018 simply add the configuration parameter (as shown in
3020 The URL can be configured statically or tagged
3021 as ``?example.{site}.org:8080/{trig}/events``,
3022 all tags such as ``site`` and ``trig`` in the URL
3023 need to be set in the properties object available to
3024 the tasks. In addition, the keys should exactly match
3025 with the tags defined in url. The scope of the properties
3026 object is per HTTP call. Hence, key/value pairs set
3027 in the properties object by task are only available
3028 for that specific HTTP call.
3030 .. container:: listingblock
3032 .. container:: content
3036 "carrierTechnologyParameters" : {
3037 "carrierTechnology" : "RESTCLIENT", (1)
3038 "parameterClassName" :
3039 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3041 "url" : "http://example.com:8888/actions/events", (2)
3042 "url" : "http://example.{site}.com:8888/{trig}/events", (2')
3043 "httpMethod" : "PUT". (3)
3044 "httpHeaders" : [ (4)
3045 ["Keep-Alive", "300"],
3046 ["Cache-Control", "no-cache"]
3050 .. container:: colist arabic
3052 +-------+--------------------------------------------------+
3053 | **1** | set REST client as carrier technology |
3054 +-------+--------------------------------------------------+
3055 | **2** | the static URL of the HTTP server for events |
3056 +-------+--------------------------------------------------+
3057 | **2'**| the tagged URL of the HTTP server for events |
3058 +-------+--------------------------------------------------+
3059 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3060 | | optional, defaults to POST |
3061 +-------+--------------------------------------------------+
3062 | **4** | HTTP headers to use on the REST request, |
3064 +-------+--------------------------------------------------+
3069 .. container:: paragraph
3071 APEX supports a REST server for input and output.
3073 .. container:: paragraph
3075 The REST server plugin always uses a synchronous mode. A
3076 client does a HTTP GET on the APEX REST server with the
3077 input event and receives the generated output event in
3078 the server reply. This means that for the REST server
3079 there has to always to be an input with an associated
3080 output. Input or output only are not permitted.
3082 .. container:: paragraph
3084 The plugin will start a Grizzly server as REST server for
3085 a normal APEX engine. If the APEX engine is executed as a
3086 servlet, for instance inside Tomcat, then Tomcat will be
3087 used as REST server (this case requires configuration on
3090 .. container:: paragraph
3092 Some configuration restrictions apply for all scenarios:
3094 .. container:: ulist
3096 - Minimum port: 1024
3098 - Maximum port: 65535
3100 - The media type is ``application/json``, so this plugin
3101 only works with the JSON Event protocol.
3103 .. container:: paragraph
3105 The URL the client calls is created using
3107 .. container:: ulist
3109 - the configured host and port, e.g.
3110 ``http://localhost:12345``
3112 - the standard path, e.g. ``/apex/``
3114 - the name of the input/output, e.g. ``FirstConsumer/``
3116 - the input or output name, e.g. ``EventIn``.
3118 .. container:: paragraph
3120 The examples above lead to the URL
3121 ``http://localhost:12345/apex/FirstConsumer/EventIn``.
3123 .. container:: paragraph
3125 A client can also get status information of the REST
3126 server using ``/Status``, e.g.
3127 ``http://localhost:12345/apex/FirstConsumer/Status``.
3129 REST Server Stand-alone
3130 =======================
3132 .. container:: paragraph
3134 We need to configure a REST server input and a REST
3135 server output. Input and output are associated with
3136 each other via there name.
3138 .. container:: paragraph
3140 Timeouts for REST calls need to be set carefully. If
3141 they are too short, the call might timeout before a
3142 policy finished creating an event.
3144 .. container:: paragraph
3146 The following example configures the input named as
3147 ``MyConsumer`` and associates an output named
3148 ``MyProducer`` with it.
3150 .. container:: listingblock
3152 .. container:: content
3156 "eventInputParameters": {
3158 "carrierTechnologyParameters" : {
3159 "carrierTechnology" : "RESTSERVER", (1)
3160 "parameterClassName" :
3161 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters",
3163 "standalone" : true, (2)
3164 "host" : "localhost", (3)
3168 "eventProtocolParameters":{
3169 "eventProtocol" : "JSON" (5)
3171 "synchronousMode" : true, (6)
3172 "synchronousPeer" : "MyProducer", (7)
3173 "synchronousTimeout" : 500 (8)
3177 .. container:: colist arabic
3179 +-------+---------------------------------------+
3180 | **1** | set REST server as carrier technology |
3181 +-------+---------------------------------------+
3182 | **2** | set the server as stand-alone |
3183 +-------+---------------------------------------+
3184 | **3** | set the server host |
3185 +-------+---------------------------------------+
3186 | **4** | set the server listen port |
3187 +-------+---------------------------------------+
3188 | **5** | use JSON event protocol |
3189 +-------+---------------------------------------+
3190 | **6** | activate synchronous mode |
3191 +-------+---------------------------------------+
3192 | **7** | associate an output ``MyProducer`` |
3193 +-------+---------------------------------------+
3194 | **8** | set a timeout of 500 milliseconds |
3195 +-------+---------------------------------------+
3197 .. container:: paragraph
3199 The following example configures the output named as
3200 ``MyProducer`` and associates the input ``MyConsumer``
3201 with it. Note that for the output there are no more
3202 paramters (such as host or port), since they are
3203 already configured in the associated input
3205 .. container:: listingblock
3207 .. container:: content
3211 "eventOutputParameters": {
3213 "carrierTechnologyParameters":{
3214 "carrierTechnology" : "RESTSERVER",
3215 "parameterClassName" :
3216 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters"
3218 "eventProtocolParameters":{
3219 "eventProtocol" : "JSON"
3221 "synchronousMode" : true,
3222 "synchronousPeer" : "MyConsumer",
3223 "synchronousTimeout" : 500
3227 REST Server Stand-alone, multi input
3228 ====================================
3230 .. container:: paragraph
3232 Any number of input/output pairs for REST servers can
3233 be configured. For instance, we can configure an input
3234 ``FirstConsumer`` with output ``FirstProducer`` and an
3235 input ``SecondConsumer`` with output
3236 ``SecondProducer``. Important is that there is always
3237 one pair of input/output.
3239 REST Server Stand-alone in Servlet
3240 ==================================
3242 .. container:: paragraph
3244 If APEX is executed as a servlet, e.g. inside Tomcat,
3245 the configuration becomes easier since the plugin can
3246 now use Tomcat as the REST server. In this scenario,
3247 there are not parameters (port, host, etc.) and the
3248 key ``standalone`` must not be used (or set to false).
3250 .. container:: paragraph
3252 For the Tomcat configuration, we need to add the REST
3255 .. container:: listingblock
3257 .. container:: content
3265 <param-value>org.onap.policy.apex.plugins.event.carrier.restserver</param-value>
3273 .. container:: paragraph
3275 APEX can act as REST requestor on the input as well as on
3276 the output interface. The media type is
3277 ``application/json``, so this plugin only works with
3278 the JSON Event protocol. This plugin allows APEX to send REST requests
3279 and to receive the reply of that request without tying up APEX resources
3280 while the request is being processed. The REST Requestor pairs a REST
3281 requestor producer and consumer together to handle the REST request
3282 and response. The REST request is created from an APEX output event
3283 and the REST response is input into APEX as a new input event.
3285 REST Requestor Output (REST Request Producer)
3286 =============================================
3288 .. container:: paragraph
3290 APEX sends a REST request when events are output by APEX, the REST
3291 request configuration is specified on the REST Request Consumer (see
3294 .. container:: listingblock
3296 .. container:: content
3300 "carrierTechnologyParameters": {
3301 "carrierTechnology": "RESTREQUESTOR", (1)
3302 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
3305 .. container:: colist arabic
3307 +-------+------------------------------------------+
3308 | **1** | set REST requestor as carrier technology |
3309 +-------+------------------------------------------+
3311 .. container:: paragraph
3313 The settings below are required on the producer to
3314 define the event that triggers the REST request and
3315 to specify the peered consumer configuration for the
3316 REST request, for example:
3318 .. container:: listingblock
3320 .. container:: content
3324 "eventNameFilter": "GuardRequestEvent", (1)
3325 "requestorMode": true, (2)
3326 "requestorPeer": "GuardRequestorConsumer", (3)
3327 "requestorTimeout": 500 (4)
3329 .. container:: colist arabic
3331 +-------+-------------------------------------------+
3332 | **1** | a filter on the event |
3333 +-------+-------------------------------------------+
3334 | **2** | requestor mode must be set to *true* |
3335 +-------+-------------------------------------------+
3336 | **3** | the peered consumer for REST requests, |
3337 | | that consumer specifies the full |
3338 | | configuration for REST requests |
3339 +-------+-------------------------------------------+
3340 | **4** | the request timeout in milliseconds, |
3341 | | overridden by timeout on consumer if that |
3342 | | is set, optional defaults to 500 |
3344 +-------+-------------------------------------------+
3346 REST Requestor Input (REST Request Consumer)
3347 ============================================
3349 .. container:: paragraph
3351 APEX will connect to a given URL to issue a REST request and
3352 wait for a REST response.
3353 The URL can be configured statically or tagged
3354 as ``?example.{site}.org:8080/{trig}/events``,
3355 all tags such as ``site`` and ``trig`` in the URL
3356 need to be set in the properties object available to
3357 the tasks. In addition, the keys should exactly match
3358 with the tags defined in url. The scope of the properties
3359 object is per HTTP call. Hence, key/value pairs set
3360 in the properties object by task are only available
3361 for that specific HTTP call.
3362 The httpCodeFilter is used for filtering the status
3363 code, and it can be configured as a regular expression
3364 string. The default httpCodeFilter is "[2][0-9][0-9]"
3365 - for successful response codes.
3366 The response with HTTP status code that matches the
3367 given regular expression is forwarded to the task,
3368 otherwise it is logged as a failure.
3370 .. container:: listingblock
3372 .. container:: content
3376 "carrierTechnologyParameters": {
3377 "carrierTechnology": "RESTREQUESTOR", (1)
3378 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
3380 "url": "http://localhost:54321/some/path/to/rest/resource", (2)
3381 "url": "http://localhost:54321/{site}/path/to/rest/{resValue}", (2')
3382 "httpMethod": "POST", (3)
3383 "requestorMode": true, (4)
3384 "requestorPeer": "GuardRequestorProducer", (5)
3385 "restRequestTimeout": 2000, (6)
3386 "httpCodeFilter" : "[2][0-9][0-9]" (7)
3387 "httpHeaders" : [ (8)
3388 ["Keep-Alive", "300"],
3389 ["Cache-Control", "no-cache"]
3393 .. container:: colist arabic
3395 +-------+--------------------------------------------------+
3396 | **1** | set REST requestor as carrier technology |
3397 +-------+--------------------------------------------------+
3398 | **2** | the static URL of the HTTP server for events |
3399 +-------+--------------------------------------------------+
3400 | **2'**| the tagged URL of the HTTP server for events |
3401 +-------+--------------------------------------------------+
3402 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3403 | | optional, defaults to GET |
3404 +-------+--------------------------------------------------+
3405 | **4** | requestor mode must be set to *true* |
3406 +-------+--------------------------------------------------+
3407 | **5** | the peered producer for REST requests, that |
3408 | | producer specifies the APEX output event that |
3409 | | triggers the REST request |
3410 +-------+--------------------------------------------------+
3411 | **6** | request timeout in milliseconds, overrides any |
3412 | | value set in the REST Requestor Producer, |
3413 | | optional, defaults to 500 millisconds |
3414 +-------+--------------------------------------------------+
3415 | **7** | use HTTP CODE FILTER for filtering status code |
3416 | | optional, defaults to [2][0-9][0-9] |
3417 +-------+--------------------------------------------------+
3418 | **8** | HTTP headers to use on the REST request, |
3420 +-------+--------------------------------------------------+
3422 .. container:: paragraph
3424 Further settings may be required on the consumer to
3425 define the input event that is produced and forwarded into
3428 .. container:: listingblock
3430 .. container:: content
3434 "eventName": "GuardResponseEvent", (1)
3435 "eventNameFilter": "GuardResponseEvent" (2)
3437 .. container:: colist arabic
3439 +-------+---------------------------+
3440 | **1** | the event name |
3441 +-------+---------------------------+
3442 | **2** | a filter on the event |
3443 +-------+---------------------------+
3448 .. container:: paragraph
3450 APEX can send requests over gRPC at the output side, and get back
3451 response at the input side. This can be used to send requests to CDS
3452 over gRPC. The media type is ``application/json``, so this plugin
3453 only works with the JSON Event protocol.
3458 .. container:: paragraph
3460 APEX will connect to a given host to send a request over
3463 .. container:: listingblock
3465 .. container:: content
3469 "carrierTechnologyParameters": {
3470 "carrierTechnology": "GRPC", (1)
3471 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
3473 "host": "cds-blueprints-processor-grpc", (2)
3475 "username": "ccsdkapps", (3)
3476 "password": ccsdkapps, (4)
3481 .. container:: colist arabic
3483 +-------+--------------------------------------------------+
3484 | **1** | set GRPC as carrier technology |
3485 +-------+--------------------------------------------------+
3486 | **2** | the host to which request is sent |
3487 +-------+--------------------------------------------------+
3488 | **2'**| the value for port |
3489 +-------+--------------------------------------------------+
3490 | **3** | username required to initiate connection |
3491 +-------+--------------------------------------------------+
3492 | **4** | password required to initiate connection |
3493 +-------+--------------------------------------------------+
3494 | **5** | the timeout value for completing the request |
3495 +-------+--------------------------------------------------+
3497 .. container:: paragraph
3499 Further settings are required on the producer to
3500 define the event that is requested, for example:
3502 .. container:: listingblock
3504 .. container:: content
3508 "eventName": "GRPCRequestEvent", (1)
3509 "eventNameFilter": "GRPCRequestEvent", (2)
3510 "requestorMode": true, (3)
3511 "requestorPeer": "GRPCRequestConsumer", (4)
3512 "requestorTimeout": 500 (5)
3514 .. container:: colist arabic
3516 +-------+---------------------------+
3517 | **1** | the event name |
3518 +-------+---------------------------+
3519 | **2** | a filter on the event |
3520 +-------+---------------------------+
3521 | **3** | the mode of the requestor |
3522 +-------+---------------------------+
3523 | **4** | a peer for the requestor |
3524 +-------+---------------------------+
3525 | **5** | a general request timeout |
3526 +-------+---------------------------+
3531 .. container:: paragraph
3533 APEX will connect to the host specified in the producer
3534 side, anad take in response back at the consumer side.
3536 .. container:: listingblock
3538 .. container:: content
3542 "carrierTechnologyParameters": {
3543 "carrierTechnology": "GRPC", (1)
3544 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
3547 .. container:: colist arabic
3549 +-------+------------------------------------------+
3550 | **1** | set GRPC as carrier technology |
3551 +-------+------------------------------------------+
3553 .. container:: paragraph
3555 Further settings are required on the consumer to
3556 define the event that is requested, for example:
3558 .. container:: listingblock
3560 .. container:: content
3564 "eventNameFilter": "GRPCResponseEvent", (1)
3565 "requestorMode": true, (2)
3566 "requestorPeer": "GRPCRequestProducer", (3)
3567 "requestorTimeout": 500 (4)
3569 .. container:: colist arabic
3571 +-------+---------------------------+
3572 | **1** | a filter on the event |
3573 +-------+---------------------------+
3574 | **2** | the mode of the requestor |
3575 +-------+---------------------------+
3576 | **3** | a peer for the requestor |
3577 +-------+---------------------------+
3578 | **4** | a general request timeout |
3579 +-------+---------------------------+
3581 Event Protocols, Format and Encoding
3582 ------------------------------------
3584 .. container:: paragraph
3586 Event protocols define what event formats APEX can receive
3587 (input) and should send (output). They can be used in any
3588 combination for input and output, unless further restricted
3589 by a carrier technology plugin (for instance for JMS
3590 output). There can only be 1 event protocol per event
3593 .. container:: paragraph
3595 Supported *input* event protocols are:
3597 .. container:: ulist
3599 - JSON, the event as a JSON string
3601 - APEX, an APEX event
3603 - JMS object, the event as a JMS object,
3605 - JMS text, the event as a JMS text,
3607 - XML, the event as an XML string,
3609 - YAML, the event as YAML text
3611 .. container:: paragraph
3613 Supported *output* event protocols are:
3615 .. container:: ulist
3617 - JSON, the event as a JSON string
3619 - APEX, an APEX event
3621 - JMS object, the event as a JMS object,
3623 - JMS text, the event as a JMS text,
3625 - XML, the event as an XML string,
3627 - YAML, the event as YAML text
3629 .. container:: paragraph
3631 New event protocols can be added as plugins to APEX or
3632 developed outside APEX and added to an APEX deployment.
3637 .. container:: paragraph
3639 The event protocol for JSON encoding does not require a
3640 specific plugin, it is supported by default. Furthermore,
3641 there is no difference in the configuration for the input
3642 and output interface.
3644 .. container:: paragraph
3646 For an input, APEX requires a well-formed JSON string.
3647 Well-formed here means according to the definitions of a
3648 policy. Any JSON string that is not defined as a trigger
3649 event (consume) will not be consumed (errors will be
3650 thrown). For output JSON events, APEX will always produce
3651 valid JSON strings according to the definition in the
3654 .. container:: paragraph
3656 The following JSON shows the configuration.
3658 .. container:: listingblock
3660 .. container:: content
3664 "eventProtocolParameters":{
3665 "eventProtocol" : "JSON"
3668 .. container:: paragraph
3670 For JSON events, there are a few more optional
3671 parameters, which allow to define a mapping for standard
3672 event fields. An APEX event must have the fields
3673 ``name``, ``version``, ``source``, and ``target``
3674 defined. Sometimes it is not possible to configure a
3675 trigger or actioning system to use those fields. However,
3676 they might be in an event generated outside APEX (or used
3677 outside APEX) just with different names. To configure
3678 APEX to map between the different event names, simply add
3679 the following parameters to a JSON event:
3681 .. container:: listingblock
3683 .. container:: content
3687 "eventProtocolParameters":{
3688 "eventProtocol" : "JSON",
3689 "nameAlias" : "policyName", (1)
3690 "versionAlias" : "policyVersion", (2)
3691 "sourceAlias" : "from", (3)
3692 "targetAlias" : "to", (4)
3693 "nameSpaceAlias": "my.name.space" (5)
3696 .. container:: colist arabic
3698 +-----------------------------------+-----------------------------------+
3699 | **1** | mapping for the ``name`` field, |
3700 | | here from a field called |
3701 | | ``policyName`` |
3702 +-----------------------------------+-----------------------------------+
3703 | **2** | mapping for the ``version`` |
3704 | | field, here from a field called |
3705 | | ``policyVersion`` |
3706 +-----------------------------------+-----------------------------------+
3707 | **3** | mapping for the ``source`` field, |
3708 | | here from a field called ``from`` |
3709 | | (only for an input event) |
3710 +-----------------------------------+-----------------------------------+
3711 | **4** | mapping for the ``target`` field, |
3712 | | here from a field called ``to`` |
3713 | | (only for an output event) |
3714 +-----------------------------------+-----------------------------------+
3715 | **5** | mapping for the ``nameSpace`` |
3716 | | field, here from a field called |
3717 | | ``my.name.space`` |
3718 +-----------------------------------+-----------------------------------+
3722 .. container:: paragraph
3724 The event protocol for APEX events does not require a
3725 specific plugin, it is supported by default. Furthermore,
3726 there is no difference in the configuration for the input
3727 and output interface.
3729 .. container:: paragraph
3731 For input and output APEX uses APEX events.
3733 .. container:: paragraph
3735 The following JSON shows the configuration.
3737 .. container:: listingblock
3739 .. container:: content
3743 "eventProtocolParameters":{
3744 "eventProtocol" : "APEX"
3750 .. container:: paragraph
3752 The event protocol for JMS is provided by the APEX JMS
3753 plugin. The plugin supports encoding as JSON text or as
3754 object. There is no difference in the configuration for
3755 the input and output interface.
3759 .. container:: paragraph
3761 If used as input, APEX will take a JMS message and
3762 extract a JSON string, then proceed as if a JSON event
3763 was received. If used as output, APEX will take the
3764 event produced by a policy, create a JSON string, and
3765 then wrap it into a JMS message.
3767 .. container:: paragraph
3769 The configuration for JMS text is as follows:
3771 .. container:: listingblock
3773 .. container:: content
3777 "eventProtocolParameters":{
3778 "eventProtocol" : "JMSTEXT",
3779 "parameterClassName" :
3780 "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters"
3785 .. container:: paragraph
3787 If used as input, APEX will will take a JMS message,
3788 extract a Java Bean from the ``ObjectMessage``
3789 message, construct an APEX event and put the bean on
3790 the APEX event as a parameter. If used as output, APEX
3791 will take the event produced by a policy, create a
3792 Java Bean and send it as a JMS message.
3794 .. container:: paragraph
3796 The configuration for JMS object is as follows:
3798 .. container:: listingblock
3800 .. container:: content
3804 "eventProtocolParameters":{
3805 "eventProtocol" : "JMSOBJECT",
3806 "parameterClassName" :
3807 "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters"
3813 .. container:: paragraph
3815 The event protocol for YAML is provided by the APEX YAML
3816 plugin. There is no difference in the configuration for
3817 the input and output interface.
3819 .. container:: paragraph
3821 If used as input, APEX will consume events as YAML and
3822 map them to policy trigger events. Not well-formed YAML
3823 and not understood trigger events will be rejected. If
3824 used as output, APEX produce YAML encoded events from the
3825 event a policy produces. Those events will always be
3826 well-formed according to the definition in the policy
3829 .. container:: paragraph
3831 The following code shows the configuration.
3833 .. container:: listingblock
3835 .. container:: content
3839 "eventProtocolParameters":{
3840 "eventProtocol" : "XML",
3841 "parameterClassName" :
3842 "org.onap.policy.apex.plugins.event.protocol.yaml.YamlEventProtocolParameters"
3847 .. container:: paragraph
3849 The event protocol for XML is provided by the APEX XML
3850 plugin. There is no difference in the configuration for
3851 the input and output interface.
3853 .. container:: paragraph
3855 If used as input, APEX will consume events as XML and map
3856 them to policy trigger events. Not well-formed XML and
3857 not understood trigger events will be rejected. If used
3858 as output, APEX produce XML encoded events from the event
3859 a policy produces. Those events will always be
3860 well-formed according to the definition in the policy
3863 .. container:: paragraph
3865 The following code shows the configuration.
3867 .. container:: listingblock
3869 .. container:: content
3873 "eventProtocolParameters":{
3874 "eventProtocol" : "XML",
3875 "parameterClassName" :
3876 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3879 A configuration example
3880 -----------------------
3882 .. container:: paragraph
3884 The following example loads all available plug-ins.
3886 .. container:: paragraph
3888 Events are consumed from a Websocket, APEX as client.
3889 Consumed event format is JSON.
3891 .. container:: paragraph
3893 Events are produced to Kafka. Produced event format is XML.
3895 .. container:: listingblock
3897 .. container:: content
3902 "engineServiceParameters" : {
3903 "name" : "MyApexEngine",
3904 "version" : "0.0.1",
3906 "instanceCount" : 4,
3907 "deploymentPort" : 12345,
3908 "engineParameters" : {
3909 "executorParameters" : {
3911 "parameterClassName" :
3912 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
3915 "parameterClassName" :
3916 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
3919 "parameterClassName" :
3920 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
3923 "parameterClassName" :
3924 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
3927 "parameterClassName" :
3928 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
3931 "contextParameters" : {
3932 "parameterClassName" :
3933 "org.onap.policy.apex.context.parameters.ContextParameters",
3934 "schemaParameters" : {
3936 "parameterClassName" :
3937 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
3943 "producerCarrierTechnologyParameters" : {
3944 "carrierTechnology" : "KAFKA",
3945 "parameterClassName" :
3946 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
3948 "bootstrapServers" : "localhost:49092",
3951 "batchSize" : 16384,
3953 "bufferMemory" : 33554432,
3954 "producerTopic" : "apex-out",
3955 "keySerializer" : "org.apache.kafka.common.serialization.StringSerializer",
3956 "valueSerializer" : "org.apache.kafka.common.serialization.StringSerializer"
3959 "producerEventProtocolParameters" : {
3960 "eventProtocol" : "XML",
3961 "parameterClassName" :
3962 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3964 "consumerCarrierTechnologyParameters" : {
3965 "carrierTechnology" : "WEBSOCKET",
3966 "parameterClassName" :
3967 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
3969 "host" : "localhost",
3973 "consumerEventProtocolParameters" : {
3974 "eventProtocol" : "JSON"
3978 Engine and Applications of the APEX System
3979 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3981 Introduction to APEX Engine and Applications
3982 --------------------------------------------
3984 .. container:: paragraph
3986 The core of APEX is the APEX Engine, also known as the APEX
3987 Policy Engine or the APEX PDP (since it is in fact a Policy
3988 Decision Point). Beside this engine, an APEX system comes
3989 with a few applications intended to help with policy
3990 authoring, deployment, and execution.
3992 .. container:: paragraph
3994 The engine itself and most applications are started from the
3995 command line with command line arguments. This is called a
3996 Command Line Interface (CLI). Some applications require an
3997 installation on a webserver, as for instance the REST
3998 Editor. Those applications can be accessed via a web
4001 .. container:: paragraph
4003 You can also use the available APEX APIs and applications to
4004 develop other applications as required. This includes policy
4005 languages (and associated parsers and compilers /
4006 interpreters), GUIs to access APEX or to define policies,
4007 clients to connect to APEX, etc.
4009 .. container:: paragraph
4011 For this documentation, we assume an installation of APEX as
4012 a full system based on a current ONAP release.
4014 CLI on Unix, Windows, and Cygwin
4015 --------------------------------
4017 .. container:: paragraph
4019 A note on APEX CLI applications: all applications and the
4020 engine itself have been deployed and tested on different
4021 operating systems: Red Hat, Ubuntu, Debian, Mac OSX,
4022 Windows, Cygwin. Each operating system comes with its own
4023 way of configuring and executing Java. The main items here
4026 .. container:: ulist
4028 - For UNIX systems (RHL, Ubuntu, Debian, Mac OSX), the
4029 provided bash scripts work as expected with absolute
4031 ``/opt/app/policy/apex-pdp/apex-pdp-2.0.0-SNAPSHOT/examples``),
4032 indirect and linked paths (e.g. ``../apex/apex``), and
4033 path substitutions using environment settings (e.g.
4034 ``$APEX_HOME/bin/``)
4036 - For Windows systems, the provided batch files (``.bat``)
4037 work as expected with with absolute paths (e.g.
4038 ``C:\apex\apex-2.0.0-SNAPSHOT\examples``), and path
4039 substitutions using environment settings (e.g.
4040 ``%APEX_HOME%\bin\``)
4042 - For Cygwin system we assume a standard Cygwin
4043 installation with standard tools (mainly bash) using a
4044 Windows Java installation. This means that the bash
4045 scripts can be used as in UNIX, however any argument
4046 pointing to files and directories need to use either a
4048 ``C:\apex\apex-2.0.0-SNAPSHOT\examples\config...``) or
4049 the command ``cygpath`` with a mixed option. The reason
4050 for that is: Cygwin executes Java using UNIX paths but
4051 then runs Java as a DOS/WINDOWS process, which requires
4052 DOS paths for file access.
4057 .. container:: paragraph
4059 The APEX engine can be started in different ways, depending
4060 your requirements. All scripts are located in the APEX *bin*
4063 .. container:: paragraph
4065 On UNIX and Cygwin systems use:
4067 .. container:: ulist
4069 - ``apexEngine.sh`` - this script will
4071 .. container:: ulist
4073 - Test if ``$APEX_USER`` is set and if the user
4074 exists, terminate with an error otherwise
4076 - Test if ``$APEX_HOME`` is set. If not set, it will
4077 use the default setting as
4078 ``/opt/app/policy/apex-pdp/apex-pdp``. Then the set
4079 directory is tested to exist, the script will
4082 - When all tests are passed successfully, the script
4083 will call ``apexApps.sh`` with arguments to start
4086 - ``apexApps.sh engine`` - this is the general APEX
4087 application launcher, which will
4089 .. container:: ulist
4091 - Start the engine with the argument ``engine``
4093 - Test if ``$APEX_HOME`` is set and points to an
4094 existing directory. If not set or directory does
4095 not exist, script terminates.
4097 - Not test for any settings of ``$APEX_USER``.
4099 .. container:: paragraph
4101 On Windows systems use ``apexEngine.bat`` and
4102 ``apexApps.bat engine`` respectively. Note: none of the
4103 windows batch files will test for ``%APEX_USER%``.
4105 .. container:: paragraph
4107 Summary of alternatives to start the APEX Engine:
4109 +--------------------------------------------------------+----------------------------------------------------------+
4110 | Unix, Cygwin | Windows |
4111 +========================================================+==========================================================+
4112 | .. container:: | .. container:: |
4114 | .. container:: listingblock | .. container:: listingblock |
4116 | .. container:: content | .. container:: content |
4118 | .. code:: | .. code:: |
4120 | # $APEX_HOME/bin/apexEngine.sh [args] | > %APEX_HOME%\bin\apexEngine.bat [args] |
4121 | # $APEX_HOME/bin/apexApps.sh engine [args] | > %APEX_HOME%\bin\apexApps.bat engine [args] |
4122 +--------------------------------------------------------+----------------------------------------------------------+
4124 .. container:: paragraph
4126 The APEX engine comes with a few CLI arguments, the main one is for setting
4127 the tosca policy file for execution. The tosca policy file is
4128 always required. The option ``-h`` prints a help screen.
4130 .. container:: listingblock
4132 .. container:: content
4136 usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]
4138 -p,--tosca-policy-file <TOSCA_POLICY_FILE> the full path to the ToscaPolicy file to use.
4139 -h,--help outputs the usage of this command
4140 -v,--version outputs the version of Apex
4145 .. container:: paragraph
4147 The CLI Editor allows to define policies from the command
4148 line. The application uses a simple language and supports
4149 all elements of an APEX policy. It can be used in to
4152 .. container:: ulist
4154 - non-interactive, specifying a file with the commands to
4157 - interactive, using the editors CLI to create a policy
4159 .. container:: paragraph
4161 When a policy is fully specified, the editor will generate
4162 the APEX core policy specification in JSON. This core
4163 specification is called the policy model in the APEX engine
4164 and can be used directly with the APEX engine.
4166 .. container:: paragraph
4168 On UNIX and Cygwin systems use:
4170 .. container:: ulist
4172 - ``apexCLIEditor.sh`` - simply starts the CLI editor,
4173 arguments to the script determine the mode of the editor
4175 - ``apexApps.sh cli-editor`` - simply starts the CLI
4176 editor, arguments to the script determine the mode of the
4179 .. container:: paragraph
4181 On Windows systems use:
4183 .. container:: ulist
4185 - ``apexCLIEditor.bat`` - simply starts the CLI editor,
4186 arguments to the script determine the mode of the editor
4188 - ``apexApps.bat cli-editor`` - simply starts the CLI
4189 editor, arguments to the script determine the mode of the
4192 .. container:: paragraph
4194 Summary of alternatives to start the APEX CLI Editor:
4196 +------------------------------------------------------------+--------------------------------------------------------------+
4197 | Unix, Cygwin | Windows |
4198 +============================================================+==============================================================+
4199 | .. container:: | .. container:: |
4201 | .. container:: listingblock | .. container:: listingblock |
4203 | .. container:: content | .. container:: content |
4205 | .. code:: | .. code:: |
4207 | # $APEX_HOME/bin/apexCLIEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIEditor.bat [args] |
4208 | # $APEX_HOME/bin/apexApps.sh cli-editor [args] | > %APEX_HOME%\bin\apexApps.bat cli-editor [args] |
4209 +------------------------------------------------------------+--------------------------------------------------------------+
4211 .. container:: paragraph
4213 The option ``-h`` provides a help screen with all command
4216 .. container:: listingblock
4218 .. container:: content
4222 usage: org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain [options...]
4224 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4225 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4226 -h,--help outputs the usage of this command
4227 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4228 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and continue
4229 executing the command file
4230 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will log
4231 to standard output if not specified or suppressed with "-nl" flag
4232 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4233 -nl,--no-log if specified, no logging or output of commands to standard output or log
4235 -nm,--no-model-output if specified, no output of a model to standard output or model output
4236 file is carried out, the user can use the "save" command in a script to
4238 -o,--output-model-file <OUTPUT_MODEL_FILE> name of a file that will contain the output model for the editor, will
4239 output model to standard output if not specified or suppressed with
4241 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4242 root from which to look for included macro files
4244 The APEX CLI Tosca Editor
4245 -------------------------
4247 .. container:: paragraph
4249 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.
4251 .. container:: paragraph
4253 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.
4255 .. container:: paragraph
4257 On UNIX and Cygwin systems use:
4259 .. container:: ulist
4261 - ``apexCLIToscaEditor.sh`` - starts the CLI Tosca editor,
4262 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4264 - ``apexApps.sh cli-tosca-editor`` - starts the CLI Tosca editor,
4265 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4267 .. container:: paragraph
4269 On Windows systems use:
4271 .. container:: ulist
4273 - ``apexCLIToscaEditor.bat`` - starts the CLI Tosca editor,
4274 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4276 - ``apexApps.bat cli-tosca-editor`` - starts the CLI Tosca
4277 editor, all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4279 .. container:: paragraph
4281 Summary of alternatives to start the APEX CLI Tosca Editor:
4283 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4284 | Unix, Cygwin | Windows |
4285 +=================================================================+====================================================================+
4286 | .. container:: | .. container:: |
4288 | .. container:: listingblock | .. container:: listingblock |
4290 | .. container:: content | .. container:: content |
4292 | .. code:: | .. code:: |
4294 | # $APEX_HOME/bin/apexCLIToscaEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIToscaEditor.bat [args] |
4295 | # $APEX_HOME/bin/apexApps.sh cli-tosca-editor [args]| > %APEX_HOME%\bin\apexApps.bat cli-tosca-editor [args] |
4296 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4298 .. container:: paragraph
4300 The option ``-h`` provides a help screen with all command
4303 .. container:: listingblock
4305 .. container:: content
4309 usage: org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain [options...]
4311 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4312 -ac,--apex-config-file <APEX_CONFIG_FILE> name of the file containing apex configuration details
4313 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4314 -h,--help outputs the usage of this command
4315 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4316 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and
4317 continue executing the command file
4318 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will
4319 log to standard output if not specified or suppressed with "-nl" flag
4320 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4321 -nl,--no-log if specified, no logging or output of commands to standard output or
4322 log file is carried out
4323 -ot,--output-tosca-file <OUTPUT_TOSCA_FILE> name of a file that will contain the output ToscaServiceTemplate
4324 -t,--tosca-template-file <TOSCA_TEMPLATE_FILE> name of the input file containing tosca template which needs to be
4326 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4327 root from which to look for included macro files
4329 .. container:: paragraph
4331 An example command to run the APEX CLI Tosca editor on windows machine is given below.
4333 .. container:: listingblock
4335 .. container:: content
4339 %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
4345 .. container:: paragraph
4347 The APEX Client combines the Policy Editor, the
4348 Monitoring Client, and the Deployment Client into a single
4349 application. The standard way to use the APEX Full Client is
4350 via an installation of the *war* file on a webserver.
4351 However, the Full Client can also be started via command
4352 line. This will start a Grizzly webserver with the *war*
4353 deployed. Access to the Full Client is then via the provided
4356 .. container:: paragraph
4358 On UNIX and Cygwin systems use:
4360 .. container:: ulist
4362 - ``apexApps.sh full-client`` - simply starts the webserver
4363 with the Full Client
4365 .. container:: paragraph
4367 On Windows systems use:
4369 .. container:: ulist
4371 - ``apexApps.bat full-client`` - simply starts the
4372 webserver with the Full Client
4374 .. container:: paragraph
4376 The option ``-h`` provides a help screen with all command
4379 .. container:: listingblock
4381 .. container:: content
4385 usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]
4386 -h,--help outputs the usage of this command
4387 -p,--port <PORT> port to use for the Apex Services REST calls
4388 -t,--time-to-live <TIME_TO_LIVE> the amount of time in seconds that the server will run for before terminating
4390 .. container:: paragraph
4392 If the Full Client is started without any arguments the
4393 final messages will look similar to this:
4395 .. container:: listingblock
4397 .. container:: content
4401 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
4402 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.NetworkListener start
4403 INFO: Started listener bound to [localhost:18989]
4404 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.HttpServer start
4405 INFO: [HttpServer] Started.
4406 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
4408 .. container:: paragraph
4410 The last line states the URL on which the Monitoring Client
4411 can be accessed. The example above stated
4412 ``http://localhost:18989/apexservices``. In a web browser
4413 use the URL ``http://localhost:18989``.
4415 The APEX Application Launcher
4416 -----------------------------
4418 .. container:: paragraph
4420 The standard applications (Engine and CLI Editor)
4421 come with dedicated start scripts. For all other APEX
4422 applications, we provide an application launcher.
4424 .. container:: paragraph
4426 On UNIX and Cygwin systems use:
4428 .. container:: ulist
4430 - apexApps.sh\` - simply starts the application launcher
4432 .. container:: paragraph
4434 On Windows systems use:
4436 .. container:: ulist
4438 - ``apexApps.bat`` - simply starts the application launcher
4440 .. container:: paragraph
4442 Summary of alternatives to start the APEX application
4445 +-------------------------------------------------+---------------------------------------------------+
4446 | Unix, Cygwin | Windows |
4447 +=================================================+===================================================+
4448 | .. container:: | .. container:: |
4450 | .. container:: listingblock | .. container:: listingblock |
4452 | .. container:: content | .. container:: content |
4454 | .. code:: | .. code:: |
4456 | # $APEX_HOME/bin/apexApps.sh [args] | > %APEX_HOME%\bin\apexApps.bat [args] |
4457 +-------------------------------------------------+---------------------------------------------------+
4459 .. container:: paragraph
4461 The option ``-h`` provides a help screen with all launcher
4462 command line arguments.
4464 .. container:: listingblock
4466 .. container:: content
4470 apexApps.sh - runs APEX applications
4472 Usage: apexApps.sh [options] | [<application> [<application options>]]
4475 -d <app> - describes an application
4476 -l - lists all applications supported by this script
4477 -h - this help screen
4479 .. container:: paragraph
4481 Using ``-l`` lists all known application the launcher can
4484 .. container:: listingblock
4486 .. container:: content
4490 apexApps.sh: supported applications:
4491 --> ws-echo engine eng-monitoring full-client eng-deployment tpl-event-json model-2-cli rest-editor cli-editor ws-console
4493 .. container:: paragraph
4495 Using the ``-d <name>`` option describes the named
4496 application, for instance for the ``ws-console``:
4498 .. container:: listingblock
4500 .. container:: content
4504 apexApps.sh: application 'ws-console'
4505 --> a simple console sending events to APEX, connect to APEX consumer port
4507 .. container:: paragraph
4509 Launching an application is done by calling the script with
4510 only the application name and any CLI arguments for the
4511 application. For instance, starting the ``ws-echo``
4512 application with port ``8888``:
4514 .. container:: listingblock
4516 .. container:: content
4520 apexApps.sh ws-echo -p 8888
4522 Application: Create Event Templates
4523 -----------------------------------
4525 .. container:: paragraph
4527 **Status: Experimental**
4529 .. container:: paragraph
4531 This application takes a policy model (JSON or XML encoded)
4532 and generates templates for events in JSON format. This can
4533 help when a policy defines rather complex trigger or action
4534 events or complex events between states. The application can
4535 produce events for the types: stimuli (policy trigger
4536 events), internal (events between policy states), and
4537 response (action events).
4539 +----------------------------------------------------------------+------------------------------------------------------------------+
4540 | Unix, Cygwin | Windows |
4541 +================================================================+==================================================================+
4542 | .. container:: | .. container:: |
4544 | .. container:: listingblock | .. container:: listingblock |
4546 | .. container:: content | .. container:: content |
4548 | .. code:: | .. code:: |
4550 | # $APEX_HOME/bin/apexApps.sh tpl-event-json [args] | > %APEX_HOME%\bin\apexApps.bat tpl-event-json [args] |
4551 +----------------------------------------------------------------+------------------------------------------------------------------+
4553 .. container:: paragraph
4555 The option ``-h`` provides a help screen.
4557 .. container:: listingblock
4559 .. container:: content
4563 gen-model2event v{release-version} - generates JSON templates for events generated from a policy model
4564 usage: gen-model2event
4565 -h,--help prints this help and usage screen
4566 -m,--model <MODEL-FILE> set the input policy model file
4567 -t,--type <TYPE> set the event type for generation, one of:
4568 stimuli (trigger events), response (action
4569 events), internal (events between states)
4570 -v,--version prints the application version
4572 .. container:: paragraph
4574 The created templates are not valid events, instead they use
4575 some markup for values one will need to change to actual
4576 values. For instance, running the tool with the *Sample
4577 Domain* policy model as:
4579 .. container:: listingblock
4581 .. container:: content
4585 apexApps.sh tpl-event-json -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json -t stimuli
4587 .. container:: paragraph
4589 will produce the following status messages:
4591 .. container:: listingblock
4593 .. container:: content
4597 gen-model2event: starting Event generator
4598 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4601 .. container:: paragraph
4603 and then run the generator application producing two event
4604 templates. The first template is called ``Event0000``.
4606 .. container:: listingblock
4608 .. container:: content
4613 "name" : "Event0000",
4614 "nameSpace" : "org.onap.policy.apex.sample.events",
4615 "version" : "0.0.1",
4616 "source" : "Outside",
4618 "TestTemperature" : ###double: 0.0###,
4619 "TestTimestamp" : ###long: 0###,
4620 "TestMatchCase" : ###integer: 0###,
4621 "TestSlogan" : "###string###"
4624 .. container:: paragraph
4626 The values for the keys are marked with ``#`` and the
4627 expected type of the value. To create an actual stimuli
4628 event, all these markers need to be change to actual values,
4631 .. container:: listingblock
4633 .. container:: content
4638 "name" : "Event0000",
4639 "nameSpace" : "org.onap.policy.apex.sample.events",
4640 "version" : "0.0.1",
4641 "source" : "Outside",
4643 "TestTemperature" : 25,
4644 "TestTimestamp" : 123456789123456789,
4645 "TestMatchCase" : 1,
4646 "TestSlogan" : "Testing the Match Case with Temperature 25"
4649 Application: Convert a Policy Model to CLI Editor Commands
4650 ----------------------------------------------------------
4652 .. container:: paragraph
4654 **Status: Experimental**
4656 .. container:: paragraph
4658 This application takes a policy model (JSON or XML encoded)
4659 and generates commands for the APEX CLI Editor. This
4660 effectively reverses a policy specification realized with
4663 +-------------------------------------------------------------+---------------------------------------------------------------+
4664 | Unix, Cygwin | Windows |
4665 +=============================================================+===============================================================+
4666 | .. container:: | .. container:: |
4668 | .. container:: listingblock | .. container:: listingblock |
4670 | .. container:: content | .. container:: content |
4672 | .. code:: | .. code:: |
4674 | # $APEX_HOME/bin/apexApps.sh model-2-cli [args] | > %APEX_HOME%\bin\apexApps.bat model-2-cli [args] |
4675 +-------------------------------------------------------------+---------------------------------------------------------------+
4677 .. container:: paragraph
4679 The option ``-h`` provides a help screen.
4681 .. container:: listingblock
4683 .. container:: content
4687 usage: gen-model2cli
4688 -h,--help prints this help and usage screen
4689 -m,--model <MODEL-FILE> set the input policy model file
4690 -sv,--skip-validation switch of validation of the input file
4691 -v,--version prints the application version
4693 .. container:: paragraph
4695 For instance, running the tool with the *Sample Domain*
4698 .. container:: listingblock
4700 .. container:: content
4704 apexApps.sh model-2-cli -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json
4706 .. container:: paragraph
4708 will produce the following status messages:
4710 .. container:: listingblock
4712 .. container:: content
4716 gen-model2cli: starting CLI generator
4717 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4719 .. container:: paragraph
4721 and then run the generator application producing all CLI
4722 Editor commands and printing them to standard out.
4724 Application: Websocket Clients (Echo and Console)
4725 -------------------------------------------------
4727 .. container:: paragraph
4729 **Status: Production**
4731 .. container:: paragraph
4733 The application launcher also provides a Websocket echo
4734 client and a Websocket console client. The echo client
4735 connects to APEX and prints all events it receives from
4736 APEX. The console client connects to APEX, reads input from
4737 the command line, and sends this input as events to APEX.
4739 +------------------------------------------------------------+--------------------------------------------------------------+
4740 | Unix, Cygwin | Windows |
4741 +============================================================+==============================================================+
4742 | .. container:: | .. container:: |
4744 | .. container:: listingblock | .. container:: listingblock |
4746 | .. container:: content | .. container:: content |
4748 | .. code:: | .. code:: |
4750 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
4751 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
4752 +------------------------------------------------------------+--------------------------------------------------------------+
4754 .. container:: paragraph
4756 The arguments are the same for both applications:
4758 .. container:: ulist
4760 - ``-p`` defines the Websocket port to connect to (defaults
4763 - ``-s`` defines the host on which a Websocket server is
4764 running (defaults to ``localhost``)
4766 .. container:: paragraph
4768 A discussion on how to use these two applications to build
4769 an APEX system is detailed HowTo-Websockets.
4774 Introduction to APEX Logging
4775 ----------------------------
4777 .. container:: paragraph
4779 All APEX components make extensive use of logging using the
4780 logging façade `SLF4J <https://www.slf4j.org/>`__ with the
4781 backend `Logback <https://logback.qos.ch/>`__. Both are used
4782 off-the-shelve, so the standard documentation and
4783 configuration apply to APEX logging. For details on how to
4784 work with logback please see the `logback
4785 manual <https://logback.qos.ch/manual/index.html>`__.
4787 .. container:: paragraph
4789 The APEX applications is the logback configuration file
4790 ``$APEX_HOME/etc/logback.xml`` (Windows:
4791 ``%APEX_HOME%\etc\logback.xml``). The logging backend is set
4792 to no debug, i.e. logs from the logging framework should be
4795 .. container:: paragraph
4797 The configurable log levels work as expected:
4799 .. container:: ulist
4801 - *error* (or *ERROR*) is used for serious errors in the
4804 - *warn* (or *WARN*) is used for warnings, which in general
4805 can be ignored but might indicate some deeper problems
4807 - *info* (or *INFO*) is used to provide generally
4808 interesting messages for startup and policy execution
4810 - *debug* (or *DEBUG*) provides more details on startup and
4813 - *trace* (or *TRACE*) gives full details on every aspect
4814 of the APEX engine from start to end
4816 .. container:: paragraph
4818 The loggers can also be configured as expected. The standard
4819 configuration (after installing APEX) uses log level *info*
4820 on all APEX classes (components).
4822 .. container:: paragraph
4824 The applications and scripts in ``$APEX_HOME/bin`` (Windows:
4825 ``%APEX_HOME\bin``) are configured to use the logback
4826 configuration ``$APEX_HOME/etc/logback.xml`` (Windows:
4827 ``%APEX_HOME\etc\logback.xml``). There are multiple ways to
4828 use different logback configurations, for instance:
4830 .. container:: ulist
4832 - Maintain multiple configurations in ``etc``, for instance
4833 a ``logback-debug.xml`` for deep debugging and a
4834 ``logback-production.xml`` for APEX in production mode,
4835 then copy the required configuration file to the used
4836 ``logback.xml`` prior starting APEX
4838 - Edit the scripts in ``bin`` to use a different logback
4839 configuration file (only recommended if you are familiar
4840 with editing bash scripts or windows batch files)
4842 Standard Logging Configuration
4843 ------------------------------
4845 .. container:: paragraph
4847 The standard logging configuration defines a context *APEX*,
4848 which is used in the standard output pattern. The location
4849 for log files is defined in the property ``logDir`` and set
4850 to ``/var/log/onap/policy/apex-pdp``. The standard status
4851 listener is set to *NOP* and the overall logback
4852 configuration is set to no debug.
4854 .. container:: listingblock
4856 .. container:: content
4861 <configuration debug="false">
4862 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
4864 <contextName>Apex</contextName>
4865 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
4871 .. container:: paragraph
4873 The first appender defined is called ``STDOUT`` for logs to standard
4876 .. container:: listingblock
4878 .. container:: content
4883 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4885 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
4889 .. container:: paragraph
4891 The root level logger then is set to the level *info* using the
4892 standard out appender.
4894 .. container:: listingblock
4896 .. container:: content
4902 <appender-ref ref="STDOUT" />
4905 .. container:: paragraph
4907 The second appender is called ``FILE``. It writes logs to a file
4910 .. container:: listingblock
4912 .. container:: content
4917 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
4918 <file>${logDir}/apex.log</file>
4920 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4924 .. container:: paragraph
4926 The third appender is called ``CTXT_FILE``. It writes logs to a file
4929 .. container:: listingblock
4931 .. container:: content
4936 <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
4937 <file>${logDir}/apex_ctxt.log</file>
4939 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4943 .. container:: paragraph
4945 The last definitions are for specific loggers. The first logger
4946 captures all standard APEX classes. It is configured for log level
4947 *info* and uses the standard output and file appenders. The second
4948 logger captures APEX context classes responsible for context
4949 monitoring. It is configured for log level *trace* and uses the
4950 context file appender.
4952 .. container:: listingblock
4954 .. container:: content
4960 <logger name="org.onap.policy.apex" level="info" additivity="false">
4961 <appender-ref ref="STDOUT" />
4962 <appender-ref ref="FILE" />
4965 <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
4966 <appender-ref ref="CTXT_FILE" />
4969 Adding Logback Status and Debug
4970 -------------------------------
4972 .. container:: paragraph
4974 To activate logback status messages change the status listener
4975 from 'NOP' to for instance console.
4977 .. container:: listingblock
4979 .. container:: content
4983 <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
4985 .. container:: paragraph
4987 To activate all logback debugging, for instance to debug a new
4988 logback configuration, activate the debug attribute in the
4991 .. container:: listingblock
4993 .. container:: content
4997 <configuration debug="true">
5001 Logging External Components
5002 ---------------------------
5004 .. container:: paragraph
5006 Logback can also be configured to log any other, external
5007 components APEX is using, if they are using the common logging
5010 .. container:: paragraph
5012 For instance, the context component of APEX is using *Infinispan*
5013 and one can add a logger for this external component. The
5014 following example adds a logger for *Infinispan* using the
5015 standard output appender.
5017 .. container:: listingblock
5019 .. container:: content
5023 <logger name="org.infinispan" level="INFO" additivity="false">
5024 <appender-ref ref="STDOUT" />
5027 .. container:: paragraph
5029 Another example is Apache Zookeeper. The following example adds a
5030 logger for Zookeeper using the standard outout appender.
5032 .. container:: listingblock
5034 .. container:: content
5038 <logger name="org.apache.zookeeper.ClientCnxn" level="INFO" additivity="false">
5039 <appender-ref ref="STDOUT" />
5042 Configuring loggers for Policy Logic
5043 ------------------------------------
5045 .. container:: paragraph
5047 The logging for the logic inside a policy (task logic, task
5048 selection logic, state finalizer logic) can be configured separate
5049 from standard logging. The logger for policy logic is
5050 ``org.onap.policy.apex.executionlogging``. The following example
5053 .. container:: ulist
5055 - a new appender for standard out using a very simple pattern
5056 (simply the actual message)
5058 - a logger for policy logic to standard out using the new
5059 appender and the already described file appender.
5061 .. container:: listingblock
5063 .. container:: content
5067 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5069 <pattern>policy: %msg\n</pattern>
5073 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5074 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5075 <appender-ref ref="FILE" />
5078 .. container:: paragraph
5080 It is also possible to use specific logging for parts of policy
5081 logic. The following example defines a logger for task logic.
5083 .. container:: listingblock
5085 .. container:: content
5089 <logger name="org.onap.policy.apex.executionlogging.TaskExecutionLogging" level="TRACE" additivity="false">
5090 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5093 Rolling File Appenders
5094 ----------------------
5096 .. container:: paragraph
5098 Rolling file appenders are a good option for more complex logging
5099 of a production or complex testing APEX installation. The standard
5100 logback configuration can be used for these use cases. This
5101 section gives two examples for the standard logging and for
5104 .. container:: paragraph
5106 First the standard logging. The following example defines a
5107 rolling file appender. The appender rolls over on a daily basis.
5108 It allows for a file size of 100 MB.
5110 .. container:: listingblock
5112 .. container:: content
5116 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
5117 <file>${logDir}/apex.log</file>
5118 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5119 <!-- rollover daily -->
5120 <!-- <fileNamePattern>xstream-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> -->
5121 <fileNamePattern>${logDir}/apex_%d{yyyy-MM-dd}.%i.log.gz
5123 <maxHistory>4</maxHistory>
5124 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5125 <!-- or whenever the file size reaches 100MB -->
5126 <maxFileSize>100MB</maxFileSize>
5127 </timeBasedFileNamingAndTriggeringPolicy>
5131 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5136 .. container:: paragraph
5138 A very similar configuration can be used for a rolling file
5139 appender logging APEX context.
5141 .. container:: listingblock
5143 .. container:: content
5147 <appender name="CTXT-FILE"
5148 class="ch.qos.logback.core.rolling.RollingFileAppender">
5149 <file>${logDir}/apex_ctxt.log</file>
5150 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5151 <fileNamePattern>${logDir}/apex_ctxt_%d{yyyy-MM-dd}.%i.log.gz
5153 <maxHistory>4</maxHistory>
5154 <timeBasedFileNamingAndTriggeringPolicy
5155 class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5156 <maxFileSize>100MB</maxFileSize>
5157 </timeBasedFileNamingAndTriggeringPolicy>
5161 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5166 Example Configuration for Logging Logic
5167 ---------------------------------------
5169 .. container:: paragraph
5171 The following example shows a configuration that logs policy logic
5172 to standard out and a file (*info*). All other APEX components are
5173 logging to a file (*debug*).. This configuration an be used in a
5174 pre-production phase with the APEX engine still running in a
5175 separate terminal to monitor policy execution. This logback
5176 configuration is in the APEX installation as
5177 ``etc/logback-logic.xml``.
5179 .. container:: listingblock
5181 .. container:: content
5185 <configuration debug="false">
5186 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5188 <contextName>Apex</contextName>
5189 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5191 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5193 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
5197 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5198 <file>${logDir}/apex.log</file>
5201 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5206 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5208 <pattern>policy: %msg\n</pattern>
5212 <root level="error">
5213 <appender-ref ref="STDOUT" />
5216 <logger name="org.onap.policy.apex" level="debug" additivity="false">
5217 <appender-ref ref="FILE" />
5220 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5221 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5222 <appender-ref ref="FILE" />
5226 Example Configuration for a Production Server
5227 ---------------------------------------------
5229 .. container:: paragraph
5231 The following example shows a configuration that logs all APEX
5232 components, including policy logic, to a file (*debug*). This
5233 configuration an be used in a production phase with the APEX
5234 engine being executed as a service on a system without console
5235 output. This logback configuration is in the APEX installation as
5236 ``logback-server.xml``
5238 .. container:: listingblock
5240 .. container:: content
5244 <configuration debug="false">
5245 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5247 <contextName>Apex</contextName>
5248 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5250 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5251 <file>${logDir}/apex.log</file>
5254 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5259 <root level="debug">
5260 <appender-ref ref="FILE" />
5263 <logger name="org.onap.policy.apex.executionlogging" level="debug" additivity="false">
5264 <appender-ref ref="FILE" />
5268 Unsupported Features
5269 ^^^^^^^^^^^^^^^^^^^^
5271 .. container:: paragraph
5273 This section documents some legacy and unsupported features
5274 in apex-pdp. The documentation here has not been updated for
5275 recent versions of apex-pdp. For example, the apex-pdp models
5276 specified in this example should now be in TOSCA format.
5278 Building a System with Websocket Backend
5279 ----------------------------------------
5284 .. container:: paragraph
5286 Websocket is a protocol to run sockets of HTTP. Since it in
5287 essence a socket, the connection is realized between a
5288 server (waiting for connections) and a client (connecting to
5289 a server). Server/client separation is only important for
5290 connection establishment, once connected, everyone can
5291 send/receive on the same socket (as any standard socket
5294 .. container:: paragraph
5296 Standard Websocket implementations are simple, no
5297 publish/subscribe and no special event handling. Most
5298 servers simply send all incoming messages to all
5299 connections. There is a PubSub definition on top of
5300 Websocket called `WAMP <http://wamp-proto.org/>`__. APEX
5301 does not support WAMP at the moment.
5306 .. container:: paragraph
5309 356 <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5310 defines the standard Websocket API. This JSR is part of Jave
5311 EE 7 standard. For Java SE, several implementations exist in
5312 open source. Since Websockets are a stable standard and
5313 simple, most implementations are stable and ready to use. A
5314 lot of products support Websockets, like Spring, JBoss,
5315 Netty, … there are also Kafka extensions for Websockets.
5317 Websocket Example Code for Websocket clients (FOSS)
5318 ###################################################
5320 .. container:: paragraph
5322 There are a lot of implementations and examples available on
5323 Github for Websocket clients. If one is using Java EE 7,
5324 then one can also use the native Websocket implementation.
5325 Good examples for clients using simply Java SE are here:
5327 .. container:: ulist
5330 implementation <https://github.com/TooTallNate/Java-WebSocket>`__
5332 - `Websocket sending client example, using
5333 AWT <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ChatClient.java>`__
5335 - `Websocket receiving client example (simple echo
5336 client) <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ExampleClient.java>`__
5338 .. container:: paragraph
5340 For Java EE, the native Websocket API is explained here:
5342 .. container:: ulist
5345 docs <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5348 example <http://www.programmingforliving.com/2013/08/jsr-356-java-api-for-websocket-client-api.html>`__
5350 BCP: Websocket Configuration
5351 ############################
5353 .. container:: paragraph
5355 The probably best is to configure APEX for Websocket servers
5356 for input (ingress, consume) and output (egress, produce)
5357 interfaces. This means that APEX will start Websocket
5358 servers on named ports and wait for clients to connect.
5359 Advantage: once APEX is running all connectivity
5360 infrastructure is running as well. Consequence: if APEX is
5361 not running, everyone else is in the dark, too.
5363 .. container:: paragraph
5365 The best protocol to be used is JSON string. Each event on
5366 any interface is then a string with a JSON encoding. JSON
5367 string is a little bit slower than byte code, but we doubt
5368 that this will be noticeable. A further advantage of JSON
5369 strings over Websockets with APEX starting the servers: it
5370 is very easy to connect web browsers to such a system.
5371 Simple connect the web browser to the APEX sockets and
5372 send/read JSON strings.
5374 .. container:: paragraph
5376 Once APEX is started you simply connect Websocket clients to
5377 it, and send/receive event. When APEX is terminated, the
5378 Websocket servers go down, and the clients will be
5379 disconnected. APEX does not (yet) support auto-client
5380 reconnect nor WAMP, so clients might need to be restarted or
5381 reconnected manually after an APEX boot.
5383 Demo with VPN Policy Model
5384 ##########################
5386 .. container:: paragraph
5388 We assume that you have an APEX installation using the full
5389 package, i.e. APEX with all examples, of version ``0.5.6``
5390 or higher. We will use the VPN policy from the APEX examples
5393 .. container:: paragraph
5395 Now, have the following ready to start the demo:
5397 .. container:: ulist
5399 - 3 terminals on the host where APEX is running (we need 1
5400 for APEX and 1 for each client)
5402 - the events in the file
5403 ``$APEX_HOME/examples/events/VPN/SetupEvents.json`` open
5404 in an editor (we need to send those events to APEX)
5406 - the events in the file
5407 ``$APEX_HOME/examples/events/VPN/Link09Events.json`` open
5408 in an editor (we need to send those events to APEX)
5410 A Websocket Configuration for the VPN Domain
5411 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5413 .. container:: paragraph
5415 Create a new APEX configuration using the VPN policy
5416 model and configuring APEX as discussed above for
5417 Websockets. Copy the following configuration into
5418 ``$APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json``
5420 ``%APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json``):
5422 .. container:: listingblock
5424 .. container:: content
5430 "engineServiceParameters" : {
5431 "name" : "VPNApexEngine",
5432 "version" : "0.0.1",
5434 "instanceCount" : 1,
5435 "deploymentPort" : 12345,
5436 "policyModelFileName" : "examples/models/VPN/VPNPolicyModelAvro.json",
5437 "engineParameters" : {
5438 "executorParameters" : {
5440 "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
5443 "contextParameters" : {
5444 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
5445 "schemaParameters":{
5447 "parameterClassName" : "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
5453 "producerCarrierTechnologyParameters" : {
5454 "carrierTechnology" : "WEBSOCKET",
5455 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5461 "producerEventProtocolParameters" : {
5462 "eventProtocol" : "JSON"
5464 "consumerCarrierTechnologyParameters" : {
5465 "carrierTechnology" : "WEBSOCKET",
5466 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5472 "consumerEventProtocolParameters" : {
5473 "eventProtocol" : "JSON"
5480 .. container:: paragraph
5482 In a new terminal, start APEX with the new configuration for
5483 Websocket-Server ingress/egress:
5485 .. container:: listingblock
5487 .. container:: content
5492 #: $APEX_HOME/bin/apexApps.sh engine -c $APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json
5494 .. container:: listingblock
5496 .. container:: content
5501 #: %APEX_HOME%\bin\apexApps.bat engine -c %APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json
5503 .. container:: paragraph
5505 Wait for APEX to start, it takes a while to create all Websocket
5506 servers (about 8 seconds on a standard laptop without cached
5507 binaries). depending on your log messages, you will see no (some, a
5508 lot) log messages. If APEX starts correctly, the last few messages
5511 .. container:: listingblock
5513 .. container:: content
5518 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)
5519 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 ...
5520 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
5521 Started Apex service
5523 .. container:: paragraph
5525 APEX is running in the new terminal and will produce output when the
5526 policy is triggered/executed.
5528 Run the Websocket Echo Client
5529 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5531 .. container:: paragraph
5533 The echo client is included in an APEX full installation. To run
5534 the client, open a new shell (Unix, Cygwin) or command prompt
5535 (``cmd`` on Windows). Then use the APEX application launcher to
5539 APEX engine needs to run first
5540 The example assumes that an APEX engine configured for *produce* carrier technology Websocket and *JSON* event protocol is executed first.
5542 +---------------------------------------------------------+-----------------------------------------------------------+
5543 | Unix, Cygwin | Windows |
5544 +=========================================================+===========================================================+
5545 | .. container:: | .. container:: |
5547 | .. container:: listingblock | .. container:: listingblock |
5549 | .. container:: content | .. container:: content |
5551 | .. code:: | .. code:: |
5553 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
5554 +---------------------------------------------------------+-----------------------------------------------------------+
5556 .. container:: paragraph
5558 Use the following command line arguments for server and port of
5559 the Websocket server. The port should be the same as configured in
5560 the APEX engine. The server host should be the host on which the
5561 APEX engine is running
5563 .. container:: ulist
5565 - ``-p`` defines the Websocket port to connect to (defaults to
5568 - ``-s`` defines the host on which a Websocket server is running
5569 (defaults to ``localhost``)
5571 .. container:: paragraph
5573 Let’s assume that there is an APEX engine running, configured for
5574 produce Websocket carrier technology, as server, for port 42452,
5575 with produce event protocol JSON,. If we start the console client
5576 on the same host, we can omit the ``-s`` options. We start the
5579 .. container:: listingblock
5581 .. container:: content
5585 # $APEX_HOME/bin/apexApps.sh ws-echo -p 42452 (1)
5586 > %APEX_HOME%\bin\apexApps.bat ws-echo -p 42452 (2)
5588 .. container:: colist arabic
5590 +-------+--------------------------------+
5591 | **1** | Start client on Unix or Cygwin |
5592 +-------+--------------------------------+
5593 | **2** | Start client on Windows |
5594 +-------+--------------------------------+
5596 .. container:: paragraph
5598 Once started successfully, the client will produce the following
5599 messages (assuming we used ``-p 42452`` and an APEX engine is
5600 running on ``localhost`` with the same port:
5602 .. container:: listingblock
5604 .. container:: content
5608 ws-simple-echo: starting simple event echo
5609 --> server: localhost
5612 Once started, the application will simply print out all received events to standard out.
5613 Each received event will be prefixed by '---' and suffixed by '===='
5616 ws-simple-echo: opened connection to APEX (Web Socket Protocol Handshake)
5618 Run the Websocket Console Client
5619 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5621 .. container:: paragraph
5623 The console client is included in an APEX full installation. To
5624 run the client, open a new shell (Unix, Cygwin) or command prompt
5625 (``cmd`` on Windows). Then use the APEX application launcher to
5629 APEX engine needs to run first
5630 The example assumes that an APEX engine configured for *consume* carrier technology Websocket and *JSON* event
5631 protocol is executed first.
5633 +------------------------------------------------------------+--------------------------------------------------------------+
5634 | Unix, Cygwin | Windows |
5635 +============================================================+==============================================================+
5636 | .. container:: | .. container:: |
5638 | .. container:: listingblock | .. container:: listingblock |
5640 | .. container:: content | .. container:: content |
5642 | .. code:: | .. code:: |
5644 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
5645 +------------------------------------------------------------+--------------------------------------------------------------+
5647 .. container:: paragraph
5649 Use the following command line arguments for server and port of
5650 the Websocket server. The port should be the same as configured in
5651 the APEX engine. The server host should be the host on which the
5652 APEX engine is running
5654 .. container:: ulist
5656 - ``-p`` defines the Websocket port to connect to (defaults to
5659 - ``-s`` defines the host on which a Websocket server is running
5660 (defaults to ``localhost``)
5662 .. container:: paragraph
5664 Let’s assume that there is an APEX engine running, configured for
5665 consume Websocket carrier technology, as server, for port 42450,
5666 with consume event protocol JSON,. If we start the console client
5667 on the same host, we can omit the ``-s`` options. We start the
5670 .. container:: listingblock
5672 .. container:: content
5676 # $APEX_HOME/bin/apexApps.sh ws-console -p 42450 (1)
5677 > %APEX_HOME%\bin\apexApps.sh ws-console -p 42450 (2)
5679 .. container:: colist arabic
5681 +-------+--------------------------------+
5682 | **1** | Start client on Unix or Cygwin |
5683 +-------+--------------------------------+
5684 | **2** | Start client on Windows |
5685 +-------+--------------------------------+
5687 .. container:: paragraph
5689 Once started successfully, the client will produce the following
5690 messages (assuming we used ``-p 42450`` and an APEX engine is
5691 running on ``localhost`` with the same port:
5693 .. container:: listingblock
5695 .. container:: content
5699 ws-simple-console: starting simple event console
5700 --> server: localhost
5703 - terminate the application typing 'exit<enter>' or using 'CTRL+C'
5704 - events are created by a non-blank starting line and terminated by a blank line
5707 ws-simple-console: opened connection to APEX (Web Socket Protocol Handshake)
5712 .. container:: paragraph
5714 Now you have the full system up and running:
5716 .. container:: ulist
5718 - Terminal 1: APEX ready and loaded
5720 - Terminal 2: an echo client, printing received messages produced
5723 - Terminal 2: a console client, waiting for input on the console
5724 (standard in) and sending text to APEX
5726 .. container:: paragraph
5728 We started the engine with the VPN policy example. So all the
5729 events we are using now are located in files in the following
5732 .. container:: listingblock
5734 .. container:: content
5739 #: $APEX_HOME/examples/events/VPN
5740 > %APEX_HOME%\examples\events\VPN
5742 .. container:: paragraph
5744 To sends events, simply copy the content of the event files into
5745 Terminal 3 (the console client). It will read multi-line JSON text
5746 and send the events. So copy the content of ``SetupEvents.json`` into
5747 the client. APEX will trigger a policy and produce some output, the
5748 echo client will also print some events created in the policy. In
5749 Terminal 1 (APEX) you’ll see some status messages from the policy as:
5751 .. container:: listingblock
5753 .. container:: content
5758 {Link=L09, LinkUp=true}
5760 outFields: {Link=L09, LinkUp=true}
5761 {Link=L10, LinkUp=true}
5764 outFields: {Link=L10, LinkUp=true}
5765 {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5767 C 300 300 [L09, L10]
5768 outFields: {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5769 {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5772 C 300 300 [L09, L10]
5773 outFields: {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5774 {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5777 C 300 300 [L09, L10]
5778 D 300 400 [L09, L10]
5779 outFields: {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5780 {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5783 B 300 299 [L09, L10]
5784 C 300 300 [L09, L10]
5785 D 300 400 [L09, L10]
5786 outFields: {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5788 .. container:: paragraph
5790 In Terminal 2 (echo-client) you see the received events, the last two
5793 .. container:: listingblock
5795 .. container:: content
5800 ws-simple-echo: received
5801 ---------------------------------
5803 "name": "VPNCustomerCtxtActEvent",
5805 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5808 "CustomerName": "C",
5809 "LinkList": "L09 L10",
5813 =================================
5815 ws-simple-echo: received
5816 ---------------------------------
5818 "name": "VPNCustomerCtxtActEvent",
5820 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5823 "CustomerName": "D",
5824 "LinkList": "L09 L10",
5828 =================================
5830 .. container:: paragraph
5832 Congratulations, you have triggered a policy in APEX using
5833 Websockets, the policy did run through, created events, picked up by
5836 .. container:: paragraph
5838 Now you can send the Link 09 and Link 10 events, they will trigger
5839 the actual VPN policy and some calculations are made. Let’s take the
5840 Link 09 events from ``Link09Events.json``, copy them all into
5841 Terminal 3 (the console). APEX will run the policy (with some status
5842 output), and the echo client will receive and print events.
5844 .. container:: paragraph
5846 To terminate the applications, simply press ``CTRL+C`` in Terminal 1
5847 (APEX). This will also terminate the echo-client in Terminal 2. Then
5848 type ``exit<enter>`` in Terminal 3 (or ``CTRL+C``) to terminate the