1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
17 .. container:: paragraph
19 APEX is 100% written in Java and runs on any platform
20 that supports a JVM, e.g. Windows, Unix, Cygwin. Some
21 APEX applications (such as the monitoring application)
22 come as web archives, they do require a war-capable web
25 Installation Requirements
26 #########################
30 - Downloaded distribution: JAVA runtime environment
31 (JRE, Java 11 or later, APEX is tested with the
34 - Building from source: JAVA development kit (JDK,
35 Java 11 or later, APEX is tested with the OpenJDK
38 - A web archive capable webserver, for instance for
39 the monitoring application
43 - for instance `Apache
44 Tomcat <https://tomcat.apache.org/>`__
46 - Sufficient rights to install APEX on the system
48 - Installation tools depending on the installation
53 - ZIP to extract from a ZIP distribution
57 - Windows for instance
58 `7Zip <http://www.7-zip.org/>`__
60 - TAR and GZ to extract from that TAR.GZ
65 - Windows for instance
66 `7Zip <http://www.7-zip.org/>`__
68 - DPKG to install from the DEB distribution
72 - Install: ``sudo apt-get install dpkg``
77 .. container:: paragraph
79 APEX supports a number of features that require extra
80 software being installed.
84 - `Apache Kafka <https://kafka.apache.org/>`__ to
85 connect APEX to a Kafka message bus
87 - `Hazelcast <https://hazelcast.com/>`__ to use
88 distributed hash maps for context
90 - `Infinispan <http://infinispan.org/>`__ for
91 distributed context and persistence
93 - `Docker <https://www.docker.com/>`__ to run APEX
94 inside a Docker container
96 Build (Install from Source) Requirements
97 ########################################
99 .. container:: paragraph
101 Installation from source requires a few development
106 - GIT to retrieve the source code
108 - Java SDK, Java version 8 or later
110 - Apache Maven 3 (the APEX build environment)
112 Get the APEX Source Code
113 ------------------------
115 .. container:: paragraph
117 The first APEX source code was hosted on Github in
118 January 2018. By the end of 2018, APEX was added as a
119 project in the ONAP Policy Framework, released later in
120 the ONAP Casablanca release.
122 .. container:: paragraph
124 The APEX source code is hosted in ONAP as project APEX.
125 The current stable version is in the master branch.
126 Simply clone the master branch from ONAP using HTTPS.
128 .. container:: listingblock
130 .. container:: content
135 git clone https://gerrit.onap.org/r/policy/apex-pdp
140 .. container:: paragraph
142 The examples in this document assume that the APEX source
143 repositories are cloned to:
147 - Unix, Cygwin: ``/usr/local/src/apex-pdp``
149 - Windows: ``C:\dev\apex-pdp``
151 - Cygwin: ``/cygdrive/c/dev/apex-pdp``
154 A Build requires ONAP Nexus
155 APEX has a dependency to ONAP parent projects. You might need to adjust your Maven M2 settings. The most current
156 settings can be found in the ONAP oparent repo: `Settings <https://git.onap.org/oparent/plain/settings.xml>`__.
160 Building APEX requires approximately 2-3 GB of hard disc space, 1 GB for the actual build with full
161 distribution and 1-2 GB for the downloaded dependencies
164 A Build requires Internet (for first build)
165 During the build, several (a lot) of Maven dependencies will be downloaded and stored in the configured local Maven
166 repository. The first standard build (and any first specific build) requires Internet access to download those
169 .. container:: paragraph
171 Use Maven to for a standard build without any tests.
173 +-------------------------------------------------------+--------------------------------------------------------+
174 | Unix, Cygwin | Windows |
175 +=======================================================+========================================================+
176 | .. container:: | .. container:: |
178 | .. container:: content | .. container:: content |
180 | .. code:: | .. code:: |
181 | :number-lines: | :number-lines: |
183 | # cd /usr/local/src/apex-pdp | >c: |
184 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
185 | | >mvn clean install -Pdocker -DskipTests |
186 +-------------------------------------------------------+--------------------------------------------------------+
188 .. container:: paragraph
190 The build takes 2-3 minutes on a standard development laptop. It
191 should run through without errors, but with a lot of messages from
194 .. container:: paragraph
196 When Maven is finished with the build, the final screen should look
197 similar to this (omitting some ``success`` lines):
199 .. container:: listingblock
201 .. container:: content
206 [INFO] tools .............................................. SUCCESS [ 0.248 s]
207 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
208 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
209 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
210 [INFO] packages ........................................... SUCCESS [ 0.336 s]
211 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
212 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
213 [INFO] ------------------------------------------------------------------------
215 [INFO] ------------------------------------------------------------------------
216 [INFO] Total time: 03:43 min
217 [INFO] Finished at: 2018-09-03T11:56:01+01:00
218 [INFO] ------------------------------------------------------------------------
220 .. container:: paragraph
222 The build will have created all artifacts required for an APEX
223 installation. The following example show how to change to the target
224 directory and how it should look like.
226 +----------------------------------------------------------------------------------------------------------------+
228 +================================================================================================================+
229 | .. container:: content |
231 | .. container:: listingblock |
233 | .. container:: content |
239 | -rwxrwx---+ 1 esvevan Domain Users 772 Sep 3 11:55 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes* |
240 | -rwxrwx---+ 1 esvevan Domain Users 146328082 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT.deb* |
241 | -rwxrwx---+ 1 esvevan Domain Users 15633 Sep 3 11:54 apex-pdp-package-full-2.0.0-SNAPSHOT.jar* |
242 | -rwxrwx---+ 1 esvevan Domain Users 146296819 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz* |
243 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 archive-tmp/ |
244 | -rwxrwx---+ 1 esvevan Domain Users 89 Sep 3 11:54 checkstyle-cachefile* |
245 | -rwxrwx---+ 1 esvevan Domain Users 10621 Sep 3 11:54 checkstyle-checker.xml* |
246 | -rwxrwx---+ 1 esvevan Domain Users 584 Sep 3 11:54 checkstyle-header.txt* |
247 | -rwxrwx---+ 1 esvevan Domain Users 86 Sep 3 11:54 checkstyle-result.xml* |
248 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 classes/ |
249 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 dependency-maven-plugin-markers/ |
250 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 etc/ |
251 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 examples/ |
252 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:55 install_hierarchy/ |
253 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 maven-archiver/ |
254 +----------------------------------------------------------------------------------------------------------------+
256 +-----------------------------------------------------------------------------------------+
258 +=========================================================================================+
261 | .. container:: listingblock |
263 | .. container:: content |
268 | 03/09/2018 11:55 <DIR> . |
269 | 03/09/2018 11:55 <DIR> .. |
270 | 03/09/2018 11:55 146,296,819 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz |
271 | 03/09/2018 11:55 146,328,082 apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
272 | 03/09/2018 11:54 15,633 apex-pdp-package-full-2.0.0-SNAPSHOT.jar |
273 | 03/09/2018 11:55 772 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes |
274 | 03/09/2018 11:54 <DIR> archive-tmp |
275 | 03/09/2018 11:54 89 checkstyle-cachefile |
276 | 03/09/2018 11:54 10,621 checkstyle-checker.xml |
277 | 03/09/2018 11:54 584 checkstyle-header.txt |
278 | 03/09/2018 11:54 86 checkstyle-result.xml |
279 | 03/09/2018 11:54 <DIR> classes |
280 | 03/09/2018 11:54 <DIR> dependency-maven-plugin-markers |
281 | 03/09/2018 11:54 <DIR> etc |
282 | 03/09/2018 11:54 <DIR> examples |
283 | 03/09/2018 11:55 <DIR> install_hierarchy |
284 | 03/09/2018 11:54 <DIR> maven-archiver |
285 | 8 File(s) 292,652,686 bytes |
286 | 9 Dir(s) 14,138,720,256 bytes free |
287 +-----------------------------------------------------------------------------------------+
292 .. container:: paragraph
294 APEX can be installed in different ways:
298 - Unix: automatically using ``dpkg`` from
301 - Windows, Unix, Cygwin: manually from a ``.tar.gz`` archive
303 - Windows, Unix, Cygwin: build from source using Maven, then
309 .. container:: paragraph
311 You can get the APEX debian package from the
312 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
314 The install distributions of APEX automatically install the
315 system. The installation directory is
316 ``/opt/app/policy/apex-pdp``. Log files are located in
317 ``/var/log/onap/policy/apex-pdp``. The latest APEX version will
318 be available as ``/opt/app/policy/apex-pdp/apex-pdp``.
320 .. container:: paragraph
322 For the installation, a new user ``apexuser`` and a new group
323 ``apexuser`` will be created. This user owns the installation
324 directories and the log file location. The user is also used by
325 the standard APEX start scripts to run APEX with this user’s
328 +--------------------------------------------------------------------------+
329 | DPKG Installation |
330 +==========================================================================+
333 | .. container:: listingblock |
335 | .. container:: content |
340 | # sudo dpkg -i apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
341 | Selecting previously unselected package apex-uservice. |
342 | (Reading database ... 288458 files and directories currently installed.) |
343 | Preparing to unpack apex-pdp-package-full-2.0.0-SNAPSHOT.deb ... |
344 | ********************preinst******************* |
345 | arguments install |
346 | ********************************************** |
347 | creating group apexuser . . . |
348 | creating user apexuser . . . |
349 | Unpacking apex-uservice (2.0.0-SNAPSHOT) ... |
350 | Setting up apex-uservice (2.0.0-SNAPSHOT) ... |
351 | ********************postinst**************** |
352 | arguments configure |
353 | *********************************************** |
354 +--------------------------------------------------------------------------+
356 .. container:: paragraph
358 Once the installation is finished, APEX is fully installed and ready
361 Install Manually from Archive (Unix, Cygwin)
362 ############################################
364 .. container:: paragraph
366 You can download a ``tar.gz`` archive from the
367 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
369 Create a directory where APEX
370 should be installed. Extract the ``tar`` archive. The following
371 example shows how to install APEX in ``/opt/apex`` and create a
372 link to ``/opt/apex/apex`` for the most recent installation.
374 .. container:: listingblock
376 .. container:: content
384 # mkdir apex-full-2.0.0-SNAPSHOT
385 # tar xvfz ~/Downloads/apex-pdp-package-full-2.0.0-SNAPSHOT.tar.gz -C apex-full-2.0.0-SNAPSHOT
386 # ln -s apex apex-pdp-package-full-2.0.0-SNAPSHOT
388 Install Manually from Archive (Windows, 7Zip, GUI)
389 ##################################################
391 .. container:: paragraph
393 You can download a ``tar.gz`` archive from the
394 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
396 Copy the ``tar.gz`` file into the install
397 folder (in this example ``C:\apex``). Assuming you are using 7Zip,
398 right click on the file and extract the ``tar`` archive. Note: the
399 screenshots might show an older version than you have.
401 .. container:: imageblock
403 .. container:: content
405 |Extract the TAR archive|
407 .. container:: paragraph
409 The right-click on the new created TAR file and extract the actual
412 .. container:: imageblock
414 .. container:: content
416 |Extract the APEX distribution|
418 .. container:: paragraph
420 Inside the new APEX folder you see the main directories: ``bin``,
421 ``etc``, ``examples``, ``lib``, and ``war``
423 .. container:: paragraph
425 Once extracted, please rename the created folder to
426 ``apex-full-2.0.0-SNAPSHOT``. This will keep the directory name in
427 line with the rest of this documentation.
429 Install Manually from Archive (Windows, 7Zip, CMD)
430 ##################################################
432 .. container:: paragraph
434 You can download a ``tar.gz`` archive from the
435 `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/packages/apex-pdp-package-full/>`__.
437 Copy the ``tar.gz`` file into the install
438 folder (in this example ``C:\apex``). Start ``cmd``, for instance
439 typing ``Windows+R`` and then ``cmd`` in the dialog. Assuming
440 ``7Zip`` is installed in the standard folder, simply run the
441 following commands (for APEX version 2.0.0-SNAPSHOT full
444 .. container:: listingblock
446 .. container:: content
453 >"\Program Files\7-Zip\7z.exe" x apex-pdp-package-full-2.0.0-SNAPSHOT.tar.gz -so | "\Program Files\7-Zip\7z.exe" x -aoa -si -ttar -o"apex-full-2.0.0-SNAPSHOT"
455 .. container:: paragraph
457 APEX is now installed in the folder
458 ``C:\apex\apex-full-2.0.0-SNAPSHOT``.
463 Build and Install Manually (Unix, Windows, Cygwin)
464 ##################################################
466 .. container:: paragraph
468 Clone the APEX GIT repositories into a directory. Go to that
469 directory. Use Maven to build APEX (all details on building
470 APEX from source can be found in *APEX HowTo: Build*). Install
471 from the created artifacts (``rpm``, ``deb``, ``tar.gz``, or
474 .. container:: paragraph
476 The following example shows how to build the APEX system,
477 without tests (``-DskipTests``) to safe some time. It assumes
478 that the APX GIT repositories are cloned to:
482 - Unix, Cygwin: ``/usr/local/src/apex``
484 - Windows: ``C:\dev\apex``
486 +-------------------------------------------------------+--------------------------------------------------------+
487 | Unix, Cygwin | Windows |
488 +=======================================================+========================================================+
489 | .. container:: | .. container:: |
491 | .. container:: content | .. container:: content |
493 | .. code:: | .. code:: |
494 | :number-lines: | :number-lines: |
496 | # cd /usr/local/src/apex | >c: |
497 | # mvn clean install -Pdocker -DskipTests | >cd \dev\apex |
498 | | >mvn clean install -Pdocker -DskipTests |
499 +-------------------------------------------------------+--------------------------------------------------------+
501 .. container:: paragraph
503 The build takes about 2 minutes without test and about 4-5 minutes
504 with tests on a standard development laptop. It should run through
505 without errors, but with a lot of messages from the build process. If
506 build with tests (i.e. without ``-DskipTests``), there will be error
507 messages and stack trace prints from some tests. This is normal, as
508 long as the build finishes successful.
510 .. container:: paragraph
512 When Maven is finished with the build, the final screen should look
513 similar to this (omitting some ``success`` lines):
515 .. container:: listingblock
517 .. container:: content
522 [INFO] tools .............................................. SUCCESS [ 0.248 s]
523 [INFO] tools-common ....................................... SUCCESS [ 0.784 s]
524 [INFO] simple-wsclient .................................... SUCCESS [ 3.303 s]
525 [INFO] model-generator .................................... SUCCESS [ 0.644 s]
526 [INFO] packages ........................................... SUCCESS [ 0.336 s]
527 [INFO] apex-pdp-package-full .............................. SUCCESS [01:10 min]
528 [INFO] Policy APEX PDP - Docker build 2.0.0-SNAPSHOT ...... SUCCESS [ 10.307 s]
529 [INFO] ------------------------------------------------------------------------
531 [INFO] ------------------------------------------------------------------------
532 [INFO] Total time: 03:43 min
533 [INFO] Finished at: 2018-09-03T11:56:01+01:00
534 [INFO] ------------------------------------------------------------------------
536 .. container:: paragraph
538 The build will have created all artifacts required for an APEX
539 installation. The following example show how to change to the target
540 directory and how it should look like.
542 +----------------------------------------------------------------------------------------------------------------+
544 +================================================================================================================+
547 | .. container:: listingblock |
552 | # cd packages/apex-pdp-package-full/target |
554 | -rwxrwx---+ 1 esvevan Domain Users 772 Sep 3 11:55 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes* |
555 | -rwxrwx---+ 1 esvevan Domain Users 146328082 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT.deb* |
556 | -rwxrwx---+ 1 esvevan Domain Users 15633 Sep 3 11:54 apex-pdp-package-full-2.0.0-SNAPSHOT.jar* |
557 | -rwxrwx---+ 1 esvevan Domain Users 146296819 Sep 3 11:55 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz* |
558 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 archive-tmp/ |
559 | -rwxrwx---+ 1 esvevan Domain Users 89 Sep 3 11:54 checkstyle-cachefile* |
560 | -rwxrwx---+ 1 esvevan Domain Users 10621 Sep 3 11:54 checkstyle-checker.xml* |
561 | -rwxrwx---+ 1 esvevan Domain Users 584 Sep 3 11:54 checkstyle-header.txt* |
562 | -rwxrwx---+ 1 esvevan Domain Users 86 Sep 3 11:54 checkstyle-result.xml* |
563 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 classes/ |
564 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 dependency-maven-plugin-markers/ |
565 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 etc/ |
566 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 examples/ |
567 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:55 install_hierarchy/ |
568 | drwxrwx---+ 1 esvevan Domain Users 0 Sep 3 11:54 maven-archiver/ |
569 +----------------------------------------------------------------------------------------------------------------+
571 +-----------------------------------------------------------------------------------------+
573 +=========================================================================================+
576 | .. container:: listingblock |
581 | >cd packages\apex-pdp-package-full\target |
583 | 03/09/2018 11:55 <DIR> . |
584 | 03/09/2018 11:55 <DIR> .. |
585 | 03/09/2018 11:55 146,296,819 apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz |
586 | 03/09/2018 11:55 146,328,082 apex-pdp-package-full-2.0.0-SNAPSHOT.deb |
587 | 03/09/2018 11:54 15,633 apex-pdp-package-full-2.0.0-SNAPSHOT.jar |
588 | 03/09/2018 11:55 772 apex-pdp-package-full_2.0.0~SNAPSHOT_all.changes |
589 | 03/09/2018 11:54 <DIR> archive-tmp |
590 | 03/09/2018 11:54 89 checkstyle-cachefile |
591 | 03/09/2018 11:54 10,621 checkstyle-checker.xml |
592 | 03/09/2018 11:54 584 checkstyle-header.txt |
593 | 03/09/2018 11:54 86 checkstyle-result.xml |
594 | 03/09/2018 11:54 <DIR> classes |
595 | 03/09/2018 11:54 <DIR> dependency-maven-plugin-markers |
596 | 03/09/2018 11:54 <DIR> etc |
597 | 03/09/2018 11:54 <DIR> examples |
598 | 03/09/2018 11:55 <DIR> install_hierarchy |
599 | 03/09/2018 11:54 <DIR> maven-archiver |
600 | 8 File(s) 292,652,686 bytes |
601 | 9 Dir(s) 14,138,720,256 bytes free |
602 +-----------------------------------------------------------------------------------------+
604 .. container:: paragraph
606 Now, take the ``.deb`` or the ``.tar.gz`` file and install APEX.
607 Alternatively, copy the content of the folder ``install_hierarchy``
608 to your APEX directory.
613 .. container:: paragraph
615 A full installation of APEX comes with the following layout.
617 .. container:: listingblock
619 .. container:: content
638 │ └───applications (11)
641 .. container:: colist arabic
643 +-----------------------------------+-----------------------------------+
644 | **1** | binaries, mainly scripts (bash |
645 | | and bat) to start the APEX engine |
646 | | and applications |
647 +-----------------------------------+-----------------------------------+
648 | **2** | configuration files, such as |
649 | | logback (logging) and third party |
650 | | library configurations |
651 +-----------------------------------+-----------------------------------+
652 | **3** | example policy models to get |
654 +-----------------------------------+-----------------------------------+
655 | **4** | configurations for the examples |
656 | | (with sub directories for |
657 | | individual examples) |
658 +-----------------------------------+-----------------------------------+
659 | **5** | Docker files and additional |
660 | | Docker instructions for the |
662 +-----------------------------------+-----------------------------------+
663 | **6** | example events for the examples |
664 | | (with sub directories for |
665 | | individual examples) |
666 +-----------------------------------+-----------------------------------+
667 | **7** | HTML files for some examples, |
668 | | e.g. the Decisionmaker example |
669 +-----------------------------------+-----------------------------------+
670 | **8** | the policy models, generated for |
671 | | each example (with sub |
672 | | directories for individual |
674 +-----------------------------------+-----------------------------------+
675 | **9** | additional scripts for the |
676 | | examples (with sub directories |
677 | | for individual examples) |
678 +-----------------------------------+-----------------------------------+
679 | **10** | the library folder with all Java |
681 +-----------------------------------+-----------------------------------+
682 | **11** | applications, also known as jar |
683 | | with dependencies (or fat jars), |
684 | | individually deployable |
685 +-----------------------------------+-----------------------------------+
686 | **12** | WAR files for web applications |
687 +-----------------------------------+-----------------------------------+
692 .. container:: paragraph
694 Once APEX is installed, a few configurations need to be done:
698 - Create an APEX user and an APEX group (optional, if not
699 installed using RPM and DPKG)
701 - Create environment settings for ``APEX_HOME`` and
702 ``APEX_USER``, required by the start scripts
704 - Change settings of the logging framework (optional)
706 - Create directories for logging, required (execution might fail
707 if directories do not exist or cannot be created)
712 .. container:: paragraph
714 On smaller installations and test systems, APEX can run as any
717 .. container:: paragraph
719 However, if APEX is installed in production, we strongly
720 recommend you set up a dedicated user for running APEX. This
721 will isolate the execution of APEX to that user. We recommend
722 you use the userid ``apexuser`` but you may use any user you
725 .. container:: paragraph
727 The following example, for UNIX, creates a group called
728 ``apexuser``, an APEX user called ``apexuser``, adds the group
729 to the user, and changes ownership of the APEX installation to
730 the user. Substitute ``<apex-dir>`` with the directory where
733 .. container:: listingblock
735 .. container:: content
740 # sudo groupadd apexuser
741 # sudo useradd -g apexuser apexuser
742 # sudo chown -R apexuser:apexuser <apex-dir>
744 .. container:: paragraph
746 For other operating systems please consult your manual or system
749 Environment Settings: APEX_HOME and APEX_USER
750 #############################################
752 .. container:: paragraph
754 The provided start scripts for APEX require two environment
759 - ``APEX_USER`` with the user under whos name and permission APEX
760 should be started (Unix only)
762 - ``APEX_HOME`` with the directory where APEX is installed (Unix,
765 .. container:: paragraph
767 The first row in the following table shows how to set these
768 environment variables temporary (assuming the user is
769 ``apexuser``). The second row shows how to verify the settings.
770 The last row explains how to set those variables permanently.
772 +------------------------------------------------+---------------------------------------------------------+
773 | Unix, Cygwin (bash/tcsh) | Windows |
774 +================================================+=========================================================+
775 | .. container:: | .. container:: |
777 | .. container:: content | .. container:: content |
779 | .. code:: | .. code:: |
780 | :number-lines: | :number-lines: |
782 | # export APEX_USER=apexuser | >set APEX_HOME=C:\apex\apex-full-2.0.0-SNAPSHOT |
783 | # cd /opt/app/policy/apex-pdp | |
784 | # export APEX_HOME=`pwd` | |
786 +------------------------------------------------+ |
789 | .. container:: content | |
794 | # setenv APEX_USER apexuser | |
795 | # cd /opt/app/policy/apex-pdp | |
796 | # setenv APEX_HOME `pwd` | |
798 +------------------------------------------------+---------------------------------------------------------+
799 | .. container:: | .. container:: |
801 | .. container:: content | .. container:: content |
803 | .. code:: | .. code:: |
804 | :number-lines: | :number-lines: |
806 | # env | grep APEX | >set APEX_HOME |
807 | # APEX_USER=apexuser | APEX_HOME=\apex\apex-full-2.0.0-SNAPSHOT |
808 | # APEX_HOME=/opt/app/policy/apex-pdp | |
810 +------------------------------------------------+---------------------------------------------------------+
812 Making Environment Settings Permanent (Unix, Cygwin)
813 ====================================================
815 .. container:: paragraph
817 For a per-user setting, edit the a user’s ``bash`` or ``tcsh``
818 settings in ``~/.bashrc`` or ``~/.tcshrc``. For system-wide
819 settings, edit ``/etc/profiles`` (requires permissions).
821 Making Environment Settings Permanent (Windows)
822 ===============================================
824 .. container:: paragraph
830 - Click on the **Start** Menu
832 - Right click on **Computer**
834 - Select **Properties**
836 .. container:: paragraph
842 - Click on the **Start** Menu
846 .. container:: paragraph
848 Then do the following
852 - Select **Advanced System Settings**
854 - On the **Advanced** tab, click the **Environment Variables**
857 - Edit an existing variable, or create a new System variable:
858 'Variable name'="APEX_HOME", 'Variable
859 value'="C:\apex\apex-full-2.0.0-SNAPSHOT"
861 .. container:: paragraph
863 For the settings to take effect, an application needs to be
864 restarted (e.g. any open ``cmd`` window).
866 Edit the APEX Logging Settings
867 ##############################
869 .. container:: paragraph
871 Configure the APEX logging settings to your requirements, for
876 - change the directory where logs are written to, or
878 - change the log levels
880 .. container:: paragraph
882 Edit the file ``$APEX_HOME/etc/logback.xml`` for any required
883 changes. To change the log directory change the line
885 .. container:: paragraph
887 ``<property name="logDir" value="/var/log/onap/policy/apex-pdp/" />``
889 .. container:: paragraph
893 .. container:: paragraph
895 ``<property name="logDir" value="/PATH/TO/LOG/DIRECTORY/" />``
897 .. container:: paragraph
899 On Windows, it is recommended to change the log directory to:
901 .. container:: paragraph
903 ``<property name="logDir" value="C:/apex/apex-full-2.0.0-SNAPSHOT/logs" />``
905 .. container:: paragraph
907 Note: Be careful about when to use ``\`` vs. ``/`` as the path
910 Create Directories for Logging
911 ##############################
913 .. container:: paragraph
915 Make sure that the log directory exists. This is important when
916 APEX was installed manually or when the log directory was changed
917 in the settings (see above).
919 +-----------------------------------------------------------------------+-------------------------------------------------------+
920 | Unix, Cygwin | Windows |
921 +=======================================================================+=======================================================+
922 | .. container:: | .. container:: |
924 | .. container:: content | .. container:: content |
926 | .. code:: | .. code:: |
927 | :number-lines: | :number-lines: |
929 | sudo mkdir -p /var/log/onap/policy/apex-pdp | >mkdir C:\apex\apex-full-2.0.0-SNAPSHOT\logs |
930 | sudo chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp | |
931 +-----------------------------------------------------------------------+-------------------------------------------------------+
933 Verify the APEX Installation
934 ----------------------------
936 .. container:: paragraph
938 When APEX is installed and all settings are realized, the
939 installation can be verified.
941 Verify Installation - run Engine
942 ################################
944 .. container:: paragraph
946 A simple verification of an APEX installation can be done by
947 simply starting the APEX engine without specifying a tosca policy. On
948 Unix (or Cygwin) start the engine using
949 ``$APEX_HOME/bin/apexApps.sh engine``. On Windows start the engine
950 using ``%APEX_HOME%\bin\apexApps.bat engine``. The engine will fail
951 to fully start. However, if the output looks similar to the
952 following line, the APEX installation is realized.
954 .. container:: listingblock
956 .. container:: content
961 Starting Apex service with parameters [] . . .
962 start of Apex service failed.
963 org.onap.policy.apex.model.basicmodel.concepts.ApexException: Arguments validation failed.
964 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:238)
965 at org.onap.policy.apex.service.engine.main.ApexMain.<init>(ApexMain.java:86)
966 at org.onap.policy.apex.service.engine.main.ApexMain.main(ApexMain.java:351)
967 Caused by: org.onap.policy.apex.model.basicmodel.concepts.ApexException: Tosca Policy file was not specified as an argument
968 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validateReadableFile(ApexCommandLineArguments.java:242)
969 at org.onap.policy.apex.service.engine.main.ApexCommandLineArguments.validate(ApexCommandLineArguments.java:172)
970 at org.onap.policy.apex.service.engine.main.ApexMain.populateApexParameters(ApexMain.java:235)
971 ... 2 common frames omitted
973 Verify Installation - run an Example
974 ####################################
976 .. container:: paragraph
978 A full APEX installation comes with several examples. Here, we can
979 fully verify the installation by running one of the examples.
981 .. container:: paragraph
983 We use the example called *SampleDomain* and configure the engine
984 to use standard in and standard out for events. Run the engine
985 with the provided configuration. Note: Cygwin executes scripts as
986 Unix scripts but runs Java as a Windows application, thus the
987 configuration file must be given as a Windows path.
989 .. container:: paragraph
991 On Unix/Linux flavoured platforms, give the commands below:
993 .. container:: listingblock
995 .. container:: content
1001 export APEX_HOME <path to apex installation>
1002 export APEX_USER apexuser
1004 .. container:: paragraph
1006 Create a Tosca Policy for the SampleDomain example using ApexCliToscaEditor
1007 as explained in the section "The APEX CLI Tosca Editor". Assume the tosca policy name is SampleDomain_tosca.json.
1008 You can then try to run apex using the ToscaPolicy.
1010 .. container:: listingblock
1012 .. container:: content
1017 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/examples/SampleDomain_tosca.json (1)
1018 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\examples\SampleDomain_tosca.json(2)
1020 .. container:: colist arabic
1028 .. container:: paragraph
1030 The engine should start successfully. Assuming the logging levels are set to ``info`` in the built system, the output
1031 should look similar to this (last few lines)
1033 .. container:: listingblock
1035 .. container:: content
1040 Starting Apex service with parameters [-p, /home/ubuntu/apex/SampleDomain_tosca.json] . . .
1041 2018-09-05 15:16:42,800 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-0:0.0.1 .
1042 2018-09-05 15:16:42,804 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-1:0.0.1 .
1043 2018-09-05 15:16:42,804 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-2:0.0.1 .
1044 2018-09-05 15:16:42,805 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Created apex engine MyApexEngine-3:0.0.1 .
1045 2018-09-05 15:16:42,805 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - APEX service created.
1046 2018-09-05 15:16:43,962 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging starting . . .
1047 2018-09-05 15:16:43,963 Apex [main] INFO o.o.p.a.s.e.e.EngDepMessagingService - engine<-->deployment messaging started
1048 2018-09-05 15:16:44,987 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-0:0.0.1
1049 2018-09-05 15:16:45,112 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-1:0.0.1
1050 2018-09-05 15:16:45,113 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-2:0.0.1
1051 2018-09-05 15:16:45,113 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Registering apex model on engine MyApexEngine-3:0.0.1
1052 2018-09-05 15:16:45,120 Apex [main] INFO o.o.p.a.s.e.r.impl.EngineServiceImpl - Added the action listener to the engine
1053 Started Apex service
1055 .. container:: paragraph
1057 Important are the last two line, stating that APEX has added the
1058 final action listener to the engine and that the engine is started.
1060 .. container:: paragraph
1062 The engine is configured to read events from standard input and write
1063 produced events to standard output. The policy model is a very simple
1066 .. container:: paragraph
1068 The following table shows an input event in the left column and an
1069 output event in the right column. Past the input event into the
1070 console where APEX is running, and the output event should appear in
1071 the console. Pasting the input event multiple times will produce
1072 output events with different values.
1074 +----------------------------------------------------+----------------------------------------------------+
1075 | Input Event | Example Output Event |
1076 +====================================================+====================================================+
1077 | .. container:: | .. container:: |
1079 | .. container:: content | .. container:: content |
1081 | .. code:: | .. code:: |
1082 | :number-lines: | :number-lines: |
1085 | "nameSpace": "org.onap.policy.apex.sample.events", | "name": "Event0004", |
1086 | "name": "Event0000", | "version": "0.0.1", |
1087 | "version": "0.0.1", | "nameSpace": "org.onap.policy.apex.sample.events", |
1088 | "source": "test", | "source": "Act", |
1089 | "target": "apex", | "target": "Outside", |
1090 | "TestSlogan": "Test slogan for External Event0", | "TestActCaseSelected": 2, |
1091 | "TestMatchCase": 0, | "TestActStateTime": 1536157104627, |
1092 | "TestTimestamp": 1469781869269, | "TestDecideCaseSelected": 0, |
1093 | "TestTemperature": 9080.866 | "TestDecideStateTime": 1536157104625, |
1094 | } | "TestEstablishCaseSelected": 0, |
1095 | | "TestEstablishStateTime": 1536157104623, |
1096 | | "TestMatchCase": 0, |
1097 | | "TestMatchCaseSelected": 1, |
1098 | | "TestMatchStateTime": 1536157104620, |
1099 | | "TestSlogan": "Test slogan for External Event0", |
1100 | | "TestTemperature": 9080.866, |
1101 | | "TestTimestamp": 1469781869269 |
1103 +----------------------------------------------------+----------------------------------------------------+
1105 .. container:: paragraph
1107 Terminate APEX by simply using ``CTRL+C`` in the console.
1109 Verify a Full Installation - REST Client
1110 ########################################
1112 .. container:: paragraph
1114 APEX has a REST application for deploying, monitoring, and viewing policy models. The
1115 application can also be used to create new policy models close to
1116 the engine native policy language. Start the REST client as
1119 .. container:: listingblock
1121 .. container:: content
1126 # $APEX_HOME/bin/apexApps.sh full-client
1128 .. container:: listingblock
1130 .. container:: content
1135 >%APEX_HOME%\bin\apexApps.bat full-client
1137 .. container:: paragraph
1139 The script will start a simple web server
1140 (`Grizzly <https://javaee.github.io/grizzly/>`__) and deploy a
1141 ``war`` web archive in it. Once the client is started, it will be
1142 available on ``localhost:18989``. The last few line of the messages
1145 .. container:: listingblock
1147 .. container:: content
1152 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
1153 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.NetworkListener start
1154 INFO: Started listener bound to [localhost:18989]
1155 Jul 02, 2020 2:57:39 PM org.glassfish.grizzly.http.server.HttpServer start
1156 INFO: [HttpServer] Started.
1157 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
1160 .. container:: paragraph
1162 Now open a browser (Firefox, Chrome, Opera, Internet Explorer) and
1163 use the URL ``http://localhost:18989/``. This will connect the
1164 browser to the started REST client. Click on the "Policy Editor" button and the Policy Editor start screen should be as
1167 .. container:: imageblock
1169 .. container:: content
1171 |Policy Editor Start Screen|
1173 .. container:: title
1175 Figure 1. Policy Editor Start Screen
1177 .. container:: paragraph
1179 Now load a policy model by clicking the menu ``File`` and then
1180 ``Open``. In the opened dialog, go to the directory where APEX is
1181 installed, then ``examples``, ``models``, ``SampleDomain``, and there
1182 select the file ``SamplePolicyModelJAVA.json``. This will load the
1183 policy model used to verify the policy engine (see above). Once
1184 loaded, the screen should look as follows.
1186 .. container:: imageblock
1188 .. container:: content
1190 |Policy Editor with loaded SampleDomain Policy Model|
1192 .. container:: title
1194 Figure 2. Policy Editor with loaded SampleDomain Policy Model
1196 .. container:: paragraph
1198 Now you can use the Policy editor. To finish this verification, simply
1199 terminate your browser (or the tab), and then use ``CTRL+C`` in the
1200 console where you started the Policy editor.
1202 Installing the WAR Application
1203 ------------------------------
1205 .. container:: paragraph
1207 The three APEX clients are packaged in a WAR file. This is a complete
1208 application that can be installed and run in an application
1209 server. The application is realized as a servlet. You
1210 can find the WAR application in the `ONAP Nexus Repository <https://nexus.onap.org/content/groups/public/org/onap/policy/apex-pdp/client/apex-client-full/>`__.
1213 .. container:: paragraph
1215 Installing and using the WAR application requires a web server
1216 that can execute ``war`` web archives. We recommend to use `Apache
1217 Tomcat <https://tomcat.apache.org/>`__, however other web servers
1218 can be used as well.
1220 .. container:: paragraph
1222 Install Apache Tomcat including the ``Manager App``, see `V9.0
1223 Docs <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html#Configuring_Manager_Application_Access>`__
1224 for details. Start the Tomcat service, or make sure that Tomcat is
1227 .. container:: paragraph
1229 There are multiple ways to install the APEX WAR application:
1231 .. container:: ulist
1233 - copy the ``.war`` file into the Tomcat ``webapps`` folder
1235 - use the Tomcat ``Manager App`` to deploy via the web interface
1237 - deploy using a REST call to Tomcat
1239 .. container:: paragraph
1241 For details on how to install ``war`` files please consult the
1243 Documentation <https://tomcat.apache.org/tomcat-9.0-doc/index.html>`__
1245 HOW-TO <https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html>`__.
1246 Once you installed an APEX WAR application (and wait for
1247 sufficient time for Tomcat to finalize the installation), open the
1248 ``Manager App`` in Tomcat. You should see the APEX WAR application
1249 being installed and running.
1251 .. container:: paragraph
1253 In case of errors, examine the log files in the Tomcat log
1254 directory. In a conventional install, those log files are in the
1255 logs directory where Tomcat is installed.
1257 .. container:: paragraph
1259 The WAR application file has a name similar to *apex-client-full-<VERSION>.war*.
1261 Running APEX in Docker
1262 ----------------------
1264 .. container:: paragraph
1266 Since APEX is in ONAP, we provide a full virtualization
1267 environment for the engine.
1272 .. container:: paragraph
1274 Running APEX from the ONAP docker repository only requires 2
1277 .. container:: olist arabic
1279 #. Log into the ONAP docker repo
1281 .. container:: listingblock
1283 .. container:: content
1287 docker login -u docker -p docker nexus3.onap.org:10003
1289 .. container:: olist arabic
1291 #. Run the APEX docker image
1293 .. container:: listingblock
1295 .. container:: content
1299 docker run -it --rm nexus3.onap.org:10003/onap/policy-apex-pdp:latest
1301 Build a Docker Image
1302 ####################
1304 .. container:: paragraph
1306 Alternatively, one can use the Dockerfile defined in the Docker
1307 package to build an image.
1309 .. container:: listingblock
1311 .. container:: title
1315 .. container:: content
1321 # Docker file to build an image that runs APEX on Java 8 in Ubuntu
1325 RUN apt-get update && \
1326 apt-get upgrade -y && \
1327 apt-get install -y software-properties-common && \
1328 add-apt-repository ppa:openjdk-r/ppa -y && \
1330 apt-get install -y openjdk-8-jdk
1332 # Create apex user and group
1333 RUN groupadd apexuser
1334 RUN useradd --create-home -g apexuser apexuser
1336 # Add Apex-specific directories and set ownership as the Apex admin user
1337 RUN mkdir -p /opt/app/policy/apex-pdp
1338 RUN mkdir -p /var/log/onap/policy/apex-pdp
1339 RUN chown -R apexuser:apexuser /var/log/onap/policy/apex-pdp
1341 # Unpack the tarball
1343 COPY apex-pdp-package-full.tar.gz /packages
1344 RUN tar xvfz /packages/apex-pdp-package-full.tar.gz --directory /opt/app/policy/apex-pdp
1345 RUN rm /packages/apex-pdp-package-full.tar.gz
1347 # Ensure everything has the correct permissions
1348 RUN find /opt/app -type d -perm 755
1349 RUN find /opt/app -type f -perm 644
1350 RUN chmod a+x /opt/app/policy/apex-pdp/bin/*
1352 # Copy examples to Apex user area
1353 RUN cp -pr /opt/app/policy/apex-pdp/examples /home/apexuser
1357 RUN chown -R apexuser:apexuser /home/apexuser/*
1360 ENV PATH /opt/app/policy/apex-pdp/bin:$PATH
1361 WORKDIR /home/apexuser
1363 Running APEX in Standalone mode
1364 -------------------------------
1366 .. container:: paragraph
1368 APEX Engine can run in standalone mode by taking in a ToscaPolicy
1369 as an argument and executing it.
1370 Assume there is a tosca policy named ToscaPolicy.json in APEX_HOME directory
1371 This policy can be executed in standalone mode using any of the below methods.
1373 Run in an APEX installation
1374 ###########################
1376 .. container:: listingblock
1378 .. container:: content
1383 # $APEX_HOME/bin/apexApps.sh engine -p $APEX_HOME/ToscaPolicy.json(1)
1384 >%APEX_HOME%\bin\apexApps.bat engine -p %APEX_HOME%\ToscaPolicy.json(2)
1386 .. container:: colist arabic
1394 Run in a docker container
1395 #########################
1397 .. container:: listingblock
1399 .. container:: content
1404 # docker run -p 6969:6969 -v $APEX_HOME/ToscaPolicy.json:/tmp/policy/ToscaPolicy.json \
1405 --name apex -it nexus3.onap.org:10001/onap/policy-apex-pdp:latest \
1406 -c "/opt/app/policy/apex-pdp/bin/apexEngine.sh -p /tmp/policy/ToscaPolicy.json"
1408 APEX Configurations Explained
1409 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1411 Introduction to APEX Configuration
1412 ----------------------------------
1414 .. container:: paragraph
1416 An APEX engine can be configured to use various combinations
1417 of event input handlers, event output handlers, event
1418 protocols, context handlers, and logic executors. The system
1419 is build using a plugin architecture. Each configuration
1420 option is realized by a plugin, which can be loaded and
1421 configured when the engine is started. New plugins can be
1422 added to the system at any time, though to benefit from a
1423 new plugin an engine will need to be restarted.
1425 .. container:: imageblock
1427 .. container:: content
1429 |APEX Configuration Matrix|
1431 .. container:: title
1433 Figure 3. APEX Configuration Matrix
1435 .. container:: paragraph
1437 The APEX distribution already comes with a number of
1438 plugins. The figure above shows the provided plugins. Any
1439 combination of input, output, event protocol, context
1440 handlers, and executors is possible.
1442 General Configuration Format
1443 ----------------------------
1445 .. container:: paragraph
1447 The APEX configuration file is a JSON file containing a few
1448 main blocks for different parts of the configuration. Each
1449 block then holds the configuration details. The following
1450 code shows the main blocks:
1452 .. container:: listingblock
1454 .. container:: content
1459 "engineServiceParameters":{
1461 "engineParameters":{ (2)
1462 "executorParameters":{...}, (3)
1463 "contextParameters":{...} (4)
1464 "taskParameters":[...] (5)
1467 "eventInputParameters":{ (6)
1469 "carrierTechnologyParameters":{...},
1470 "eventProtocolParameters":{...}
1473 "carrierTechnologyParameters":{...},
1474 "eventProtocolParameters":{...}
1478 "eventOutputParameters":{ (10)
1480 "carrierTechnologyParameters":{...},
1481 "eventProtocolParameters":{...}
1484 "carrierTechnologyParameters":{...},
1485 "eventProtocolParameters":{...}
1491 .. container:: colist arabic
1493 +-----------------------------------+-----------------------------------+
1494 | **1** | main engine configuration |
1495 +-----------------------------------+-----------------------------------+
1496 | **2** | engine parameters for plugin |
1497 | | configurations (execution |
1498 | | environments and context |
1500 +-----------------------------------+-----------------------------------+
1501 | **3** | engine specific parameters, |
1502 | | mainly for executor plugins |
1503 +-----------------------------------+-----------------------------------+
1504 | **4** | context specific parameters, e.g. |
1505 | | for context schemas, persistence, |
1507 +-----------------------------------+-----------------------------------+
1508 | **5** | list of task parameters that |
1509 | | should be made available in task |
1510 | | logic (optional). |
1511 +-----------------------------------+-----------------------------------+
1512 | **6** | configuration of the input |
1514 +-----------------------------------+-----------------------------------+
1515 | **7** | an example input called |
1516 | | ``input1`` with carrier |
1517 | | technology and event protocol |
1518 +-----------------------------------+-----------------------------------+
1519 | **8** | an example input called |
1520 | | ``input2`` with carrier |
1521 | | technology and event protocol |
1522 +-----------------------------------+-----------------------------------+
1523 | **9** | any further input configuration |
1524 +-----------------------------------+-----------------------------------+
1525 | **10** | configuration of the output |
1527 +-----------------------------------+-----------------------------------+
1528 | **11** | an example output called |
1529 | | ``output1`` with carrier |
1530 | | technology and event protocol |
1531 +-----------------------------------+-----------------------------------+
1532 | **12** | an example output called |
1533 | | ``output2`` with carrier |
1534 | | technology and event protocol |
1535 +-----------------------------------+-----------------------------------+
1536 | **13** | any further output configuration |
1537 +-----------------------------------+-----------------------------------+
1539 Engine Service Parameters
1540 -------------------------
1542 .. container:: paragraph
1544 The configuration provides a number of parameters to
1545 configure the engine. An example configuration with
1546 explanations of all options is shown below.
1548 .. container:: listingblock
1550 .. container:: content
1554 "engineServiceParameters" : {
1555 "name" : "AADMApexEngine", (1)
1556 "version" : "0.0.1", (2)
1558 "instanceCount" : 4, (4)
1559 "deploymentPort" : 12345, (5)
1560 "policy_type_impl" : {...}, (6)
1561 "periodicEventPeriod": 1000, (7)
1562 "engineParameters":{ (8)
1563 "executorParameters":{...}, (9)
1564 "contextParameters":{...}, (10)
1565 "taskParameters":[...] (11)
1569 .. container:: colist arabic
1571 +-----------------------------------+-----------------------------------+
1572 | **1** | a name for the engine. The engine |
1573 | | name is used to create a key in a |
1574 | | runtime engine. An name matching |
1575 | | the following regular expression |
1576 | | can be used here: |
1577 | | ``[A-Za-z0-9\\-_\\.]+`` |
1578 +-----------------------------------+-----------------------------------+
1579 | **2** | a version of the engine, use |
1580 | | semantic versioning as explained |
1581 | | here: `Semantic |
1582 | | Versioning <http://semver.org/>`_ |
1584 | | This version is used in a runtime |
1585 | | engine to create a version of the |
1586 | | engine. For that reason, the |
1587 | | version must match the following |
1588 | | regular expression ``[A-Z0-9.]+`` |
1589 +-----------------------------------+-----------------------------------+
1590 | **3** | a numeric identifier for the |
1592 +-----------------------------------+-----------------------------------+
1593 | **4** | the number of threads (policy |
1594 | | instances executed in parallel) |
1595 | | the engine should use, use ``1`` |
1596 | | for single threaded engines |
1597 +-----------------------------------+-----------------------------------+
1598 | **5** | the port for the deployment |
1599 | | Websocket connection to the |
1601 +-----------------------------------+-----------------------------------+
1602 | **6** | the APEX policy model as a JSON |
1603 | | or YAML block to load into the |
1604 | | engine on startup when |
1605 | | APEX is running a policy that has |
1606 | | its logic and parameters |
1607 | | specified in TOSCA |
1609 +-----------------------------------+-----------------------------------+
1610 | **7** | an optional timer for periodic |
1611 | | policies, in milliseconds (a |
1612 | | defined periodic policy will be |
1613 | | executed every ``X`` |
1614 | | milliseconds), not used of not |
1616 +-----------------------------------+-----------------------------------+
1617 | **8** | engine parameters for plugin |
1618 | | configurations (execution |
1619 | | environments and context |
1621 +-----------------------------------+-----------------------------------+
1622 | **9** | engine specific parameters, |
1623 | | mainly for executor plugins |
1624 +-----------------------------------+-----------------------------------+
1625 | **10** | context specific parameters, e.g. |
1626 | | for context schemas, persistence, |
1628 +-----------------------------------+-----------------------------------+
1629 | **11** | list of task parameters that |
1630 | | should be made available in task |
1631 | | logic (optional). |
1632 +-----------------------------------+-----------------------------------+
1634 .. container:: paragraph
1636 The model file is optional, it can also be specified via
1637 command line. In any case, make sure all execution and other
1638 required plug-ins for the loaded model are loaded as
1641 Input and Output Interfaces
1642 ---------------------------
1644 .. container:: paragraph
1646 An APEX engine has two main interfaces:
1648 .. container:: ulist
1650 - An *input* interface to receive events: also known as
1651 ingress interface or consumer, receiving (consuming)
1652 events commonly named triggers, and
1654 - An *output* interface to publish produced events: also
1655 known as egress interface or producer, sending
1656 (publishing) events commonly named actions or action
1659 .. container:: paragraph
1661 The input and output interface is configured in terms of
1662 inputs and outputs, respectively. Each input and output is a
1663 combination of a carrier technology and an event protocol.
1664 Carrier technologies and event protocols are provided by
1665 plugins, each with its own specific configuration. Most
1666 carrier technologies can be configured for input as well as
1667 output. Most event protocols can be used for all carrier
1668 technologies. One exception is the JMS object event
1669 protocol, which can only be used for the JMS carrier
1670 technology. Some further restrictions apply (for instance
1671 for carrier technologies using bi- or uni-directional
1674 .. container:: paragraph
1676 Input and output interface can be configured separately, in
1677 isolation, with any number of carrier technologies. The
1678 resulting general configuration options are:
1680 .. container:: ulist
1682 - Input interface with one or more inputs
1684 .. container:: ulist
1686 - each input with a carrier technology and an event
1689 - some inputs with optional synchronous mode
1691 - some event protocols with additional parameters
1693 - Output interface with one or more outputs
1695 .. container:: ulist
1697 - each output with a carrier technology and an event
1700 - some outputs with optional synchronous mode
1702 - some event protocols with additional parameters
1704 .. container:: paragraph
1706 The configuration for input and output is contained in
1707 ``eventInputParameters`` and ``eventOutputParameters``,
1708 respectively. Inside here, one can configure any number of
1709 inputs and outputs. Each of them needs to have a unique
1710 identifier (name), the content of the name is free form. The
1711 example below shows a configuration for two inputs and two
1714 .. container:: listingblock
1716 .. container:: content
1720 "eventInputParameters": { (1)
1721 "FirstConsumer": { (2)
1722 "carrierTechnologyParameters" : {...}, (3)
1723 "eventProtocolParameters":{...}, (4)
1726 "SecondConsumer": { (6)
1727 "carrierTechnologyParameters" : {...}, (7)
1728 "eventProtocolParameters":{...}, (8)
1732 "eventOutputParameters": { (10)
1733 "FirstProducer": { (11)
1734 "carrierTechnologyParameters":{...}, (12)
1735 "eventProtocolParameters":{...}, (13)
1738 "SecondProducer": { (15)
1739 "carrierTechnologyParameters":{...}, (16)
1740 "eventProtocolParameters":{...}, (17)
1745 .. container:: colist arabic
1747 +--------+--------------------------------------------------------------------+
1748 | **1** | input interface configuration, APEX input plugins |
1749 +--------+--------------------------------------------------------------------+
1750 | **2** | first input called ``FirstConsumer`` |
1751 +--------+--------------------------------------------------------------------+
1752 | **3** | carrier technology for plugin |
1753 +--------+--------------------------------------------------------------------+
1754 | **4** | event protocol for plugin |
1755 +--------+--------------------------------------------------------------------+
1756 | **5** | any other input configuration (e.g. event name filter, see below) |
1757 +--------+--------------------------------------------------------------------+
1758 | **6** | second input called ``SecondConsumer`` |
1759 +--------+--------------------------------------------------------------------+
1760 | **7** | carrier technology for plugin |
1761 +--------+--------------------------------------------------------------------+
1762 | **8** | event protocol for plugin |
1763 +--------+--------------------------------------------------------------------+
1764 | **9** | any other plugin configuration |
1765 +--------+--------------------------------------------------------------------+
1766 | **10** | output interface configuration, APEX output plugins |
1767 +--------+--------------------------------------------------------------------+
1768 | **11** | first output called ``FirstProducer`` |
1769 +--------+--------------------------------------------------------------------+
1770 | **12** | carrier technology for plugin |
1771 +--------+--------------------------------------------------------------------+
1772 | **13** | event protocol for plugin |
1773 +--------+--------------------------------------------------------------------+
1774 | **14** | any other plugin configuration |
1775 +--------+--------------------------------------------------------------------+
1776 | **15** | second output called ``SecondProducer`` |
1777 +--------+--------------------------------------------------------------------+
1778 | **16** | carrier technology for plugin |
1779 +--------+--------------------------------------------------------------------+
1780 | **17** | event protocol for plugin |
1781 +--------+--------------------------------------------------------------------+
1782 | **18** | any other output configuration (e.g. event name filter, see below) |
1783 +--------+--------------------------------------------------------------------+
1788 .. container:: paragraph
1790 Any event defined in APEX has to be unique. The "name" of
1791 of an event is used as an identifier for an ApexEvent. Every
1792 event has to be tagged to an eventName. This can be done in different
1793 ways. Either the actual event can have a field called "name". Or, the
1794 event has some other field that can act as the identifier, which can be
1795 specified using "nameAlias". But in other cases, where a "name" or "nameAlias"
1796 cannot be specified, the incoming event coming over an endpoint can be
1797 manually tagged to an "eventName" before consuming it.
1799 .. container:: paragraph
1801 The "eventName" can have a single event's name if the event coming
1802 over the endpoint has to be always mapped to the specified eventName's
1803 definition. Otherwise, if different events can come over the endpoint,
1804 then "eventName" field can consist of multiple event names separated by
1805 "|" symbol. In this case, based on the received event's structure, it is
1806 mapped to any one of the event name specified in the "eventName" field.
1808 .. container:: paragraph
1810 The following code shows some examples on how to specify the eventName field:
1812 .. container:: listingblock
1814 .. container:: content
1818 "eventInputParameters": {
1820 "carrierTechnologyParameters" : {...},
1821 "eventProtocolParameters":{...},
1822 "eventName" : "VesEvent" (1)
1825 "carrierTechnologyParameters" : {...},
1826 "eventProtocolParameters":{...},
1827 "eventName" : "AAISuccessResponseEvent|AAIFailureResponseEvent" (2)
1834 .. container:: paragraph
1836 APEX will always send an event after a policy execution
1837 is finished. For a successful execution, the event sent
1838 is the output event created by the policy. In case the
1839 policy does not create an output event, APEX will create
1840 a new event with all input event fields plus an
1841 additional field ``exceptionMessage`` with an exception
1844 .. container:: paragraph
1846 There are situations in which this auto-generated error
1847 event might not be required or wanted:
1849 .. container:: ulist
1851 - when a policy failing should not result in an event
1852 send out via an output interface
1854 - when the auto-generated event goes back in an APEX
1855 engine (or the same APEX engine), this can create
1858 - the auto-generated event should go to a special output
1859 interface or channel
1861 .. container:: paragraph
1863 All of these situations are supported by a filter option
1864 using a wildecard (regular expression) configuration on
1865 APEX I/O interfaces. The parameter is called
1866 ``eventNameFilter`` and the value are `Java regular
1867 expressions <https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html>`__
1869 `tutorial <http://www.vogella.com/tutorials/JavaRegularExpressions/article.html>`__).
1870 The following code shows some examples:
1872 .. container:: listingblock
1874 .. container:: content
1878 "eventInputParameters": {
1880 "carrierTechnologyParameters" : {...},
1881 "eventProtocolParameters":{...},
1882 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]004$" (1)
1885 "eventOutputParameters": {
1887 "carrierTechnologyParameters":{...},
1888 "eventProtocolParameters":{...},
1889 "eventNameFilter" : "^E[Vv][Ee][Nn][Tt][0-9]104$" (2)
1896 .. container:: paragraph
1898 Executors are plugins that realize the execution of logic
1899 contained in a policy model. Logic can be in a task
1900 selector, a task, and a state finalizer. Using plugins for
1901 execution environments makes APEX very flexible to support
1902 virtually any executable logic expressions.
1904 .. container:: paragraph
1906 APEX 2.0.0-SNAPSHOT supports the following executors:
1908 .. container:: ulist
1910 - Java, for Java implemented logic
1912 .. container:: ulist
1914 - This executor requires logic implemented using the
1915 APEX Java interfaces.
1917 - Generated JAR files must be in the classpath of the
1918 APEX engine at start time.
1928 .. container:: ulist
1930 - This executor uses the latest version of the MVEL
1931 engine, which can be very hard to debug and can
1932 produce unwanted side effects during execution
1934 Configure the Javascript Executor
1935 #################################
1937 .. container:: paragraph
1939 The Javascript executor is added to the configuration as
1942 .. container:: listingblock
1944 .. container:: content
1948 "engineServiceParameters":{
1949 "engineParameters":{
1950 "executorParameters":{
1952 "parameterClassName" :
1953 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
1959 Configure the Jython Executor
1960 #############################
1962 .. container:: paragraph
1964 The Jython executor is added to the configuration as
1967 .. container:: listingblock
1969 .. container:: content
1973 "engineServiceParameters":{
1974 "engineParameters":{
1975 "executorParameters":{
1977 "parameterClassName" :
1978 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
1984 Configure the JRuby Executor
1985 ############################
1987 .. container:: paragraph
1989 The JRuby executor is added to the configuration as
1992 .. container:: listingblock
1994 .. container:: content
1998 "engineServiceParameters":{
1999 "engineParameters":{
2000 "executorParameters":{
2002 "parameterClassName" :
2003 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
2009 Configure the Java Executor
2010 ###########################
2012 .. container:: paragraph
2014 The Java executor is added to the configuration as
2017 .. container:: listingblock
2019 .. container:: content
2023 "engineServiceParameters":{
2024 "engineParameters":{
2025 "executorParameters":{
2027 "parameterClassName" :
2028 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
2034 Configure the MVEL Executor
2035 ###########################
2037 .. container:: paragraph
2039 The MVEL executor is added to the configuration as
2042 .. container:: listingblock
2044 .. container:: content
2048 "engineServiceParameters":{
2049 "engineParameters":{
2050 "executorParameters":{
2052 "parameterClassName" :
2053 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
2062 .. container:: paragraph
2064 Context handlers are responsible for all context processing.
2065 There are the following main areas:
2067 .. container:: ulist
2069 - Context schema: use schema handlers other than Java class
2070 (supported by default without configuration)
2072 - Context distribution: distribute context across multiple
2075 - Context locking: mechanisms to lock context elements for
2078 - Context persistence: mechanisms to persist context
2080 .. container:: paragraph
2082 APEX provides plugins for each of the main areas.
2084 Configure AVRO Schema Handler
2085 #############################
2087 .. container:: paragraph
2089 The AVRO schema handler is added to the configuration as
2092 .. container:: listingblock
2094 .. container:: content
2098 "engineServiceParameters":{
2099 "engineParameters":{
2100 "contextParameters":{
2101 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
2102 "schemaParameters":{
2104 "parameterClassName" :
2105 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
2112 .. container:: paragraph
2114 Using the AVRO schema handler has one limitation: AVRO
2115 only supports field names that represent valid Java class
2116 names. This means only letters and the character ``_``
2117 are supported. Characters commonly used in field names,
2118 such as ``.`` and ``-``, are not supported by AVRO. for
2119 more information see `Avro Spec:
2120 Names <https://avro.apache.org/docs/1.8.1/spec.html#names>`__.
2122 .. container:: paragraph
2124 To work with this limitation, the APEX Avro plugin will
2125 parse a given AVRO definition and replace *all*
2126 occurrences of ``.`` and ``-`` with a ``_``. This means
2129 .. container:: ulist
2131 - In a policy model, if the AVRO schema defined a field
2132 as ``my-name`` the policy logic should access it as
2135 - In a policy model, if the AVRO schema defined a field
2136 as ``my.name`` the policy logic should access it as
2139 - There should be no field names that convert to the
2142 .. container:: ulist
2144 - For instance the simultaneous use of
2145 ``my_name``, ``my.name``, and ``my-name`` should
2148 - If not avoided, the event processing might
2149 create unwanted side effects
2151 - If field names use any other not-supported character,
2152 the AVRO plugin will reject it
2154 .. container:: ulist
2156 - Since AVRO uses lazy initialization, this
2157 rejection might only become visible at runtime
2159 Configure Task Parameters
2160 #########################
2162 .. container:: paragraph
2164 The Task Parameters are added to the configuration as
2167 .. container:: listingblock
2169 .. container:: content
2173 "engineServiceParameters": {
2174 "engineParameters": {
2177 "key": "ParameterKey1",
2178 "value": "ParameterValue1"
2181 "taskId": "Task_Act0",
2182 "key": "ParameterKey2",
2183 "value": "ParameterValue2"
2189 .. container:: paragraph
2191 TaskParameters can be used to pass parameters from ApexConfig
2192 to the policy logic. In the config, these are optional.
2193 The list of task parameters provided in the config may be added
2194 to the tasks or existing task parameters in the task will be overriden.
2196 .. container:: paragraph
2198 If taskId is provided in ApexConfig for an entry, then that
2199 parameter is updated only for that particular task. Otherwise,
2200 the task parameter is added to all tasks.
2202 Carrier Technologies
2203 --------------------
2205 .. container:: paragraph
2207 Carrier technologies define how APEX receives (input) and
2208 sends (output) events. They can be used in any combination,
2209 using asynchronous or synchronous mode. There can also be
2210 any number of carrier technologies for the input (consume)
2211 and the output (produce) interface.
2213 .. container:: paragraph
2215 Supported *input* technologies are:
2217 .. container:: ulist
2219 - Standard input, read events from the standard input
2220 (console), not suitable for APEX background servers
2222 - File input, read events from a file
2224 - Kafka, read events from a Kafka system
2226 - Websockets, read events from a Websocket
2230 - REST (synchronous and asynchronous), additionally as
2233 - Event Requestor, allows reading of events that have been
2234 looped back into APEX
2236 .. container:: paragraph
2238 Supported *output* technologies are:
2240 .. container:: ulist
2242 - Standard output, write events to the standard output
2243 (console), not suitable for APEX background servers
2245 - File output, write events to a file
2247 - Kafka, write events to a Kafka system
2249 - Websockets, write events to a Websocket
2253 - REST (synchronous and asynchronous), additionally as
2256 - Event Requestor, allows events to be looped back into
2259 .. container:: paragraph
2261 New carrier technologies can be added as plugins to APEX or
2262 developed outside APEX and added to an APEX deployment.
2267 .. container:: paragraph
2269 Standard IO does not require a specific plugin, it is
2270 supported be default.
2274 .. container:: paragraph
2276 APEX will take events from its standard input. This
2277 carrier is good for testing, but certainly not for a
2278 use case where APEX runs as a server. The
2279 configuration is as follows:
2281 .. container:: listingblock
2283 .. container:: content
2287 "carrierTechnologyParameters" : {
2288 "carrierTechnology" : "FILE", (1)
2290 "standardIO" : true (2)
2294 .. container:: colist arabic
2296 +-------+---------------------------------------+
2297 | **1** | standard input is considered a file |
2298 +-------+---------------------------------------+
2299 | **2** | file descriptor set to standard input |
2300 +-------+---------------------------------------+
2305 .. container:: paragraph
2307 APEX will send events to its standard output. This
2308 carrier is good for testing, but certainly not for a
2309 use case where APEX runs as a server. The
2310 configuration is as follows:
2312 .. container:: listingblock
2314 .. container:: content
2318 "carrierTechnologyParameters" : {
2319 "carrierTechnology" : "FILE", (1)
2321 "standardIO" : true (2)
2325 .. container:: colist arabic
2327 +-------+----------------------------------------+
2328 | **1** | standard output is considered a file |
2329 +-------+----------------------------------------+
2330 | **2** | file descriptor set to standard output |
2331 +-------+----------------------------------------+
2336 .. container:: paragraph
2338 File IO does not require a specific plugin, it is
2339 supported be default.
2344 .. container:: paragraph
2346 APEX will take events from a file. The same file
2347 should not be used as an output. The configuration is
2350 .. container:: listingblock
2352 .. container:: content
2356 "carrierTechnologyParameters" : {
2357 "carrierTechnology" : "FILE", (1)
2359 "fileName" : "examples/events/SampleDomain/EventsIn.xmlfile" (2)
2363 .. container:: colist arabic
2365 +-------+------------------------------------------+
2366 | **1** | set file input |
2367 +-------+------------------------------------------+
2368 | **2** | the name of the file to read events from |
2369 +-------+------------------------------------------+
2373 .. container:: paragraph
2375 APEX will write events to a file. The same file should
2376 not be used as an input. The configuration is as
2379 .. container:: listingblock
2381 .. container:: content
2385 "carrierTechnologyParameters" : {
2386 "carrierTechnology" : "FILE", (1)
2388 "fileName" : "examples/events/SampleDomain/EventsOut.xmlfile" (2)
2392 .. container:: colist arabic
2394 +-------+-----------------------------------------+
2395 | **1** | set file output |
2396 +-------+-----------------------------------------+
2397 | **2** | the name of the file to write events to |
2398 +-------+-----------------------------------------+
2403 .. container:: paragraph
2405 Event Requestor IO does not require a specific plugin, it
2406 is supported be default. It should only be used with the
2407 APEX event protocol.
2409 Event Requestor Input
2410 =====================
2412 .. container:: paragraph
2414 APEX will take events from APEX.
2416 .. container:: listingblock
2418 .. container:: content
2422 "carrierTechnologyParameters" : {
2423 "carrierTechnology": "EVENT_REQUESTOR" (1)
2426 .. container:: colist arabic
2428 +-------+---------------------------+
2429 | **1** | set event requestor input |
2430 +-------+---------------------------+
2432 Event Requestor Output
2433 ======================
2435 .. container:: paragraph
2437 APEX will write events to APEX.
2439 .. container:: listingblock
2441 .. container:: content
2445 "carrierTechnologyParameters" : {
2446 "carrierTechnology": "EVENT_REQUESTOR" (1)
2449 Peering Event Requestors
2450 ========================
2452 .. container:: paragraph
2454 When using event requestors, they need to be peered.
2455 This means an event requestor output needs to be
2456 peered (associated) with an event requestor input. The
2457 following example shows the use of an event requestor
2458 with the APEX event protocol and the peering of output
2461 .. container:: listingblock
2463 .. container:: content
2467 "eventInputParameters": {
2468 "EventRequestorConsumer": {
2469 "carrierTechnologyParameters": {
2470 "carrierTechnology": "EVENT_REQUESTOR" (1)
2472 "eventProtocolParameters": {
2473 "eventProtocol": "APEX" (2)
2475 "eventNameFilter": "InputEvent", (3)
2476 "requestorMode": true, (4)
2477 "requestorPeer": "EventRequestorProducer", (5)
2478 "requestorTimeout": 500 (6)
2481 "eventOutputParameters": {
2482 "EventRequestorProducer": {
2483 "carrierTechnologyParameters": {
2484 "carrierTechnology": "EVENT_REQUESTOR" (7)
2486 "eventProtocolParameters": {
2487 "eventProtocol": "APEX" (8)
2489 "eventNameFilter": "EventListEvent", (9)
2490 "requestorMode": true, (10)
2491 "requestorPeer": "EventRequestorConsumer", (11)
2492 "requestorTimeout": 500 (12)
2496 .. container:: colist arabic
2498 +-----------------------------------+-----------------------------------+
2499 | **1** | event requestor on a consumer |
2500 +-----------------------------------+-----------------------------------+
2501 | **2** | with APEX event protocol |
2502 +-----------------------------------+-----------------------------------+
2503 | **3** | optional filter (best to use a |
2504 | | filter to prevent unwanted events |
2505 | | on the consumer side) |
2506 +-----------------------------------+-----------------------------------+
2507 | **4** | activate requestor mode |
2508 +-----------------------------------+-----------------------------------+
2509 | **5** | the peer to the output (must |
2510 | | match the output carrier) |
2511 +-----------------------------------+-----------------------------------+
2512 | **6** | an optional timeout in |
2514 +-----------------------------------+-----------------------------------+
2515 | **7** | event requestor on a producer |
2516 +-----------------------------------+-----------------------------------+
2517 | **8** | with APEX event protocol |
2518 +-----------------------------------+-----------------------------------+
2519 | **9** | optional filter (best to use a |
2520 | | filter to prevent unwanted events |
2521 | | on the consumer side) |
2522 +-----------------------------------+-----------------------------------+
2523 | **10** | activate requestor mode |
2524 +-----------------------------------+-----------------------------------+
2525 | **11** | the peer to the output (must |
2526 | | match the input carrier) |
2527 +-----------------------------------+-----------------------------------+
2528 | **12** | an optional timeout in |
2530 +-----------------------------------+-----------------------------------+
2535 .. container:: paragraph
2537 Kafka IO is supported by the APEX Kafka plugin. The
2538 configurations below are examples. APEX will take any
2539 configuration inside the parameter object and forward it
2540 to Kafka. More information on Kafka specific
2541 configuration parameters can be found in the Kafka
2544 .. container:: ulist
2547 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html>`__
2550 Class <https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html>`__
2554 .. container:: paragraph
2556 APEX will receive events from the Apache Kafka
2557 messaging system. The input is uni-directional, an
2558 engine will only receive events from the input but not
2559 send any event to the input.
2561 .. container:: listingblock
2563 .. container:: content
2567 "carrierTechnologyParameters" : {
2568 "carrierTechnology" : "KAFKA", (1)
2569 "parameterClassName" :
2570 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2572 "bootstrapServers" : "localhost:49092", (2)
2573 "groupId" : "apex-group-id", (3)
2574 "enableAutoCommit" : true, (4)
2575 "autoCommitTime" : 1000, (5)
2576 "sessionTimeout" : 30000, (6)
2577 "consumerPollTime" : 100, (7)
2578 "consumerTopicList" : ["apex-in-0", "apex-in-1"], (8)
2580 "org.apache.kafka.common.serialization.StringDeserializer", (9)
2581 "valueDeserializer" :
2582 "org.apache.kafka.common.serialization.StringDeserializer" (10)
2586 .. container:: colist arabic
2588 +--------+-------------------------------------+
2589 | **1** | set Kafka as carrier technology |
2590 +--------+-------------------------------------+
2591 | **2** | bootstrap server and port |
2592 +--------+-------------------------------------+
2593 | **3** | a group identifier |
2594 +--------+-------------------------------------+
2595 | **4** | flag for auto-commit |
2596 +--------+-------------------------------------+
2597 | **5** | auto-commit timeout in milliseconds |
2598 +--------+-------------------------------------+
2599 | **6** | session timeout in milliseconds |
2600 +--------+-------------------------------------+
2601 | **7** | consumer poll time in milliseconds |
2602 +--------+-------------------------------------+
2603 | **8** | consumer topic list |
2604 +--------+-------------------------------------+
2605 | **9** | key for the Kafka de-serializer |
2606 +--------+-------------------------------------+
2607 | **10** | value for the Kafka de-serializer |
2608 +--------+-------------------------------------+
2612 .. container:: paragraph
2614 APEX will send events to the Apache Kafka messaging
2615 system. The output is uni-directional, an engine will
2616 send events to the output but not receive any event
2619 .. container:: listingblock
2621 .. container:: content
2625 "carrierTechnologyParameters" : {
2626 "carrierTechnology" : "KAFKA", (1)
2627 "parameterClassName" :
2628 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
2630 "bootstrapServers" : "localhost:49092", (2)
2633 "batchSize" : 16384, (5)
2634 "lingerTime" : 1, (6)
2635 "bufferMemory" : 33554432, (7)
2636 "producerTopic" : "apex-out", (8)
2638 "org.apache.kafka.common.serialization.StringSerializer", (9)
2640 "org.apache.kafka.common.serialization.StringSerializer" (10)
2644 .. container:: colist arabic
2646 +--------+---------------------------------+
2647 | **1** | set Kafka as carrier technology |
2648 +--------+---------------------------------+
2649 | **2** | bootstrap server and port |
2650 +--------+---------------------------------+
2651 | **3** | acknowledgement strategy |
2652 +--------+---------------------------------+
2653 | **4** | number of retries |
2654 +--------+---------------------------------+
2655 | **5** | batch size |
2656 +--------+---------------------------------+
2657 | **6** | time to linger in milliseconds |
2658 +--------+---------------------------------+
2659 | **7** | buffer memory in byte |
2660 +--------+---------------------------------+
2661 | **8** | producer topic |
2662 +--------+---------------------------------+
2663 | **9** | key for the Kafka serializer |
2664 +--------+---------------------------------+
2665 | **10** | value for the Kafka serializer |
2666 +--------+---------------------------------+
2671 .. container:: paragraph
2673 APEX supports the Java Messaging Service (JMS) as input
2674 as well as output. JMS IO is supported by the APEX JMS
2675 plugin. Input and output support an event encoding as
2676 text (JSON string) or object (serialized object). The
2677 input configuration is the same for both encodings, the
2678 output configuration differs.
2682 .. container:: paragraph
2684 APEX will receive events from a JMS messaging system.
2685 The input is uni-directional, an engine will only
2686 receive events from the input but not send any event
2689 .. container:: listingblock
2691 .. container:: content
2695 "carrierTechnologyParameters" : {
2696 "carrierTechnology" : "JMS", (1)
2697 "parameterClassName" :
2698 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2699 "parameters" : { (2)
2700 "initialContextFactory" :
2701 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2702 "connectionFactory" : "ConnectionFactory", (4)
2703 "providerURL" : "remote://localhost:5445", (5)
2704 "securityPrincipal" : "guest", (6)
2705 "securityCredentials" : "IAmAGuest", (7)
2706 "consumerTopic" : "jms/topic/apexIn" (8)
2710 .. container:: colist arabic
2712 +-----------------------------------+-----------------------------------+
2713 | **1** | set JMS as carrier technology |
2714 +-----------------------------------+-----------------------------------+
2715 | **2** | set all JMS specific parameters |
2716 +-----------------------------------+-----------------------------------+
2717 | **3** | the context factory, in this case |
2718 | | from JBOSS (it requires the |
2720 | | org.jboss:jboss-remote-naming:2.0 |
2722 | | or a different version to be in |
2723 | | the directory ``$APEX_HOME/lib`` |
2724 | | or ``%APEX_HOME%\lib`` |
2725 +-----------------------------------+-----------------------------------+
2726 | **4** | a connection factory for the JMS |
2728 +-----------------------------------+-----------------------------------+
2729 | **5** | URL with host and port of the JMS |
2731 +-----------------------------------+-----------------------------------+
2732 | **6** | access credentials, user name |
2733 +-----------------------------------+-----------------------------------+
2734 | **7** | access credentials, user password |
2735 +-----------------------------------+-----------------------------------+
2736 | **8** | the JMS topic to listen to |
2737 +-----------------------------------+-----------------------------------+
2739 JMS Output with Text
2740 ====================
2742 .. container:: paragraph
2744 APEX engine send events to a JMS messaging system. The
2745 output is uni-directional, an engine will send events
2746 to the output but not receive any event from output.
2748 .. container:: listingblock
2750 .. container:: content
2754 "carrierTechnologyParameters" : {
2755 "carrierTechnology" : "JMS", (1)
2756 "parameterClassName" :
2757 "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters",
2758 "parameters" : { (2)
2759 "initialContextFactory" :
2760 "org.jboss.naming.remote.client.InitialContextFactory", (3)
2761 "connectionFactory" : "ConnectionFactory", (4)
2762 "providerURL" : "remote://localhost:5445", (5)
2763 "securityPrincipal" : "guest", (6)
2764 "securityCredentials" : "IAmAGuest", (7)
2765 "producerTopic" : "jms/topic/apexOut", (8)
2766 "objectMessageSending": "false" (9)
2770 .. container:: colist arabic
2772 +-----------------------------------+-----------------------------------+
2773 | **1** | set JMS as carrier technology |
2774 +-----------------------------------+-----------------------------------+
2775 | **2** | set all JMS specific parameters |
2776 +-----------------------------------+-----------------------------------+
2777 | **3** | the context factory, in this case |
2778 | | from JBOSS (it requires the |
2780 | | org.jboss:jboss-remote-naming:2.0 |
2782 | | or a different version to be in |
2783 | | the directory ``$APEX_HOME/lib`` |
2784 | | or ``%APEX_HOME%\lib`` |
2785 +-----------------------------------+-----------------------------------+
2786 | **4** | a connection factory for the JMS |
2788 +-----------------------------------+-----------------------------------+
2789 | **5** | URL with host and port of the JMS |
2791 +-----------------------------------+-----------------------------------+
2792 | **6** | access credentials, user name |
2793 +-----------------------------------+-----------------------------------+
2794 | **7** | access credentials, user password |
2795 +-----------------------------------+-----------------------------------+
2796 | **8** | the JMS topic to write to |
2797 +-----------------------------------+-----------------------------------+
2798 | **9** | set object messaging to ``false`` |
2799 | | means it sends JSON text |
2800 +-----------------------------------+-----------------------------------+
2802 JMS Output with Object
2803 ======================
2805 .. container:: paragraph
2807 To configure APEX for JMS objects on the output
2808 interface use the same configuration as above (for
2809 output). Simply change the ``objectMessageSending``
2810 parameter to ``true``.
2815 .. container:: paragraph
2817 APEX supports the Websockets as input as well as output.
2818 WS IO is supported by the APEX Websocket plugin. This
2819 carrier technology does only support uni-directional
2820 communication. APEX will not send events to a Websocket
2821 input and any event sent to a Websocket output will
2822 result in an error log.
2824 .. container:: paragraph
2826 The input can be configured as client (APEX connects to
2827 an existing Websocket server) or server (APEX starts a
2828 Websocket server). The same applies to the output. Input
2829 and output can both use a client or a server
2830 configuration, or separate configurations (input as
2831 client and output as server, input as server and output
2832 as client). Each configuration should use its own
2833 dedicated port to avoid any communication loops. The
2834 configuration of a Websocket client is the same for input
2835 and output. The configuration of a Websocket server is
2836 the same for input and output.
2841 .. container:: paragraph
2843 APEX will connect to a given Websocket server. As
2844 input, it will receive events from the server but not
2845 send any events. As output, it will send events to the
2846 server and any event received from the server will
2847 result in an error log.
2849 .. container:: listingblock
2851 .. container:: content
2855 "carrierTechnologyParameters" : {
2856 "carrierTechnology" : "WEBSOCKET", (1)
2857 "parameterClassName" :
2858 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2860 "host" : "localhost", (2)
2865 .. container:: colist arabic
2867 +-------+------------------------------------------------------+
2868 | **1** | set Websocket as carrier technology |
2869 +-------+------------------------------------------------------+
2870 | **2** | the host name on which a Websocket server is running |
2871 +-------+------------------------------------------------------+
2872 | **3** | the port of that Websocket server |
2873 +-------+------------------------------------------------------+
2878 .. container:: paragraph
2880 APEX will start a Websocket server, which will accept
2881 any Websocket clients to connect. As input, it will
2882 receive events from the server but not send any
2883 events. As output, it will send events to the server
2884 and any event received from the server will result in
2887 .. container:: listingblock
2889 .. container:: content
2893 "carrierTechnologyParameters" : {
2894 "carrierTechnology" : "WEBSOCKET", (1)
2895 "parameterClassName" :
2896 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
2898 "wsClient" : false, (2)
2903 .. container:: colist arabic
2905 +-------+------------------------------------------------------------+
2906 | **1** | set Websocket as carrier technology |
2907 +-------+------------------------------------------------------------+
2908 | **2** | disable client, so that APEX will start a Websocket server |
2909 +-------+------------------------------------------------------------+
2910 | **3** | the port for the Websocket server APEX will start |
2911 +-------+------------------------------------------------------------+
2916 .. container:: paragraph
2918 APEX can act as REST client on the input as well as on
2919 the output interface. The media type is
2920 ``application/json``, so this plugin only works with
2921 the JSON Event protocol.
2926 .. container:: paragraph
2928 APEX will connect to a given URL to receive events,
2929 but not send any events. The server is polled, i.e.
2930 APEX will do an HTTP GET, take the result, and then do
2931 the next GET. Any required timing needs to be handled
2932 by the server configured via the URL. For instance,
2933 the server could support a wait timeout via the URL as
2935 The httpCodeFilter is used for filtering the status
2936 code, and it can be configured as a regular expression
2937 string. The default httpCodeFilter is "[2][0-9][0-9]"
2938 - for successful response codes.
2939 The response with HTTP status code that matches the
2940 given regular expression is forwarded to the task,
2941 otherwise it is logged as a failure.
2943 .. container:: listingblock
2945 .. container:: content
2949 "carrierTechnologyParameters" : {
2950 "carrierTechnology" : "RESTCLIENT", (1)
2951 "parameterClassName" :
2952 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
2954 "url" : "http://example.org:8080/triggers/events", (2)
2955 "httpMethod": "GET", (3)
2956 "httpCodeFilter" : "[2][0-9][0-9]", (4)
2957 "httpHeaders" : [ (5)
2958 ["Keep-Alive", "300"],
2959 ["Cache-Control", "no-cache"]
2964 .. container:: colist arabic
2966 +-------+--------------------------------------------------+
2967 | **1** | set REST client as carrier technology |
2968 +-------+--------------------------------------------------+
2969 | **2** | the URL of the HTTP server for events |
2970 +-------+--------------------------------------------------+
2971 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
2972 | | optional, defaults to GET |
2973 +-------+--------------------------------------------------+
2974 | **4** | use HTTP CODE FILTER for filtering status code, |
2975 | | optional, defaults to [2][0-9][0-9] |
2976 +-------+--------------------------------------------------+
2977 | **5** | HTTP headers to use on the REST request, |
2979 +-------+--------------------------------------------------+
2984 .. container:: paragraph
2986 APEX will connect to a given URL to send events, but
2987 not receive any events. The default HTTP operation is
2988 POST (no configuration required). To change it to PUT
2989 simply add the configuration parameter (as shown in
2991 The URL can be configured statically or tagged
2992 as ``?example.{site}.org:8080/{trig}/events``,
2993 all tags such as ``site`` and ``trig`` in the URL
2994 need to be set in the properties object available to
2995 the tasks. In addition, the keys should exactly match
2996 with the tags defined in url. The scope of the properties
2997 object is per HTTP call. Hence, key/value pairs set
2998 in the properties object by task are only available
2999 for that specific HTTP call.
3001 .. container:: listingblock
3003 .. container:: content
3007 "carrierTechnologyParameters" : {
3008 "carrierTechnology" : "RESTCLIENT", (1)
3009 "parameterClassName" :
3010 "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
3012 "url" : "http://example.com:8888/actions/events", (2)
3013 "url" : "http://example.{site}.com:8888/{trig}/events", (2')
3014 "httpMethod" : "PUT". (3)
3015 "httpHeaders" : [ (4)
3016 ["Keep-Alive", "300"],
3017 ["Cache-Control", "no-cache"]
3021 .. container:: colist arabic
3023 +-------+--------------------------------------------------+
3024 | **1** | set REST client as carrier technology |
3025 +-------+--------------------------------------------------+
3026 | **2** | the static URL of the HTTP server for events |
3027 +-------+--------------------------------------------------+
3028 | **2'**| the tagged URL of the HTTP server for events |
3029 +-------+--------------------------------------------------+
3030 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3031 | | optional, defaults to POST |
3032 +-------+--------------------------------------------------+
3033 | **4** | HTTP headers to use on the REST request, |
3035 +-------+--------------------------------------------------+
3040 .. container:: paragraph
3042 APEX supports a REST server for input and output.
3044 .. container:: paragraph
3046 The REST server plugin always uses a synchronous mode. A
3047 client does a HTTP GET on the APEX REST server with the
3048 input event and receives the generated output event in
3049 the server reply. This means that for the REST server
3050 there has to always to be an input with an associated
3051 output. Input or output only are not permitted.
3053 .. container:: paragraph
3055 The plugin will start a Grizzly server as REST server for
3056 a normal APEX engine. If the APEX engine is executed as a
3057 servlet, for instance inside Tomcat, then Tomcat will be
3058 used as REST server (this case requires configuration on
3061 .. container:: paragraph
3063 Some configuration restrictions apply for all scenarios:
3065 .. container:: ulist
3067 - Minimum port: 1024
3069 - Maximum port: 65535
3071 - The media type is ``application/json``, so this plugin
3072 only works with the JSON Event protocol.
3074 .. container:: paragraph
3076 The URL the client calls is created using
3078 .. container:: ulist
3080 - the configured host and port, e.g.
3081 ``http://localhost:12345``
3083 - the standard path, e.g. ``/apex/``
3085 - the name of the input/output, e.g. ``FirstConsumer/``
3087 - the input or output name, e.g. ``EventIn``.
3089 .. container:: paragraph
3091 The examples above lead to the URL
3092 ``http://localhost:12345/apex/FirstConsumer/EventIn``.
3094 .. container:: paragraph
3096 A client can also get status information of the REST
3097 server using ``/Status``, e.g.
3098 ``http://localhost:12345/apex/FirstConsumer/Status``.
3100 REST Server Stand-alone
3101 =======================
3103 .. container:: paragraph
3105 We need to configure a REST server input and a REST
3106 server output. Input and output are associated with
3107 each other via there name.
3109 .. container:: paragraph
3111 Timeouts for REST calls need to be set carefully. If
3112 they are too short, the call might timeout before a
3113 policy finished creating an event.
3115 .. container:: paragraph
3117 The following example configures the input named as
3118 ``MyConsumer`` and associates an output named
3119 ``MyProducer`` with it.
3121 .. container:: listingblock
3123 .. container:: content
3127 "eventInputParameters": {
3129 "carrierTechnologyParameters" : {
3130 "carrierTechnology" : "RESTSERVER", (1)
3131 "parameterClassName" :
3132 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters",
3134 "standalone" : true, (2)
3135 "host" : "localhost", (3)
3139 "eventProtocolParameters":{
3140 "eventProtocol" : "JSON" (5)
3142 "synchronousMode" : true, (6)
3143 "synchronousPeer" : "MyProducer", (7)
3144 "synchronousTimeout" : 500 (8)
3148 .. container:: colist arabic
3150 +-------+---------------------------------------+
3151 | **1** | set REST server as carrier technology |
3152 +-------+---------------------------------------+
3153 | **2** | set the server as stand-alone |
3154 +-------+---------------------------------------+
3155 | **3** | set the server host |
3156 +-------+---------------------------------------+
3157 | **4** | set the server listen port |
3158 +-------+---------------------------------------+
3159 | **5** | use JSON event protocol |
3160 +-------+---------------------------------------+
3161 | **6** | activate synchronous mode |
3162 +-------+---------------------------------------+
3163 | **7** | associate an output ``MyProducer`` |
3164 +-------+---------------------------------------+
3165 | **8** | set a timeout of 500 milliseconds |
3166 +-------+---------------------------------------+
3168 .. container:: paragraph
3170 The following example configures the output named as
3171 ``MyProducer`` and associates the input ``MyConsumer``
3172 with it. Note that for the output there are no more
3173 paramters (such as host or port), since they are
3174 already configured in the associated input
3176 .. container:: listingblock
3178 .. container:: content
3182 "eventOutputParameters": {
3184 "carrierTechnologyParameters":{
3185 "carrierTechnology" : "RESTSERVER",
3186 "parameterClassName" :
3187 "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters"
3189 "eventProtocolParameters":{
3190 "eventProtocol" : "JSON"
3192 "synchronousMode" : true,
3193 "synchronousPeer" : "MyConsumer",
3194 "synchronousTimeout" : 500
3198 REST Server Stand-alone, multi input
3199 ====================================
3201 .. container:: paragraph
3203 Any number of input/output pairs for REST servers can
3204 be configured. For instance, we can configure an input
3205 ``FirstConsumer`` with output ``FirstProducer`` and an
3206 input ``SecondConsumer`` with output
3207 ``SecondProducer``. Important is that there is always
3208 one pair of input/output.
3210 REST Server Stand-alone in Servlet
3211 ==================================
3213 .. container:: paragraph
3215 If APEX is executed as a servlet, e.g. inside Tomcat,
3216 the configuration becomes easier since the plugin can
3217 now use Tomcat as the REST server. In this scenario,
3218 there are not parameters (port, host, etc.) and the
3219 key ``standalone`` must not be used (or set to false).
3221 .. container:: paragraph
3223 For the Tomcat configuration, we need to add the REST
3226 .. container:: listingblock
3228 .. container:: content
3236 <param-value>org.onap.policy.apex.plugins.event.carrier.restserver</param-value>
3244 .. container:: paragraph
3246 APEX can act as REST requestor on the input as well as on
3247 the output interface. The media type is
3248 ``application/json``, so this plugin only works with
3249 the JSON Event protocol. This plugin allows APEX to send REST requests
3250 and to receive the reply of that request without tying up APEX resources
3251 while the request is being processed. The REST Requestor pairs a REST
3252 requestor producer and consumer together to handle the REST request
3253 and response. The REST request is created from an APEX output event
3254 and the REST response is input into APEX as a new input event.
3256 REST Requestor Output (REST Request Producer)
3257 =============================================
3259 .. container:: paragraph
3261 APEX sends a REST request when events are output by APEX, the REST
3262 request configuration is specified on the REST Request Consumer (see
3265 .. container:: listingblock
3267 .. container:: content
3271 "carrierTechnologyParameters": {
3272 "carrierTechnology": "RESTREQUESTOR", (1)
3273 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters"
3276 .. container:: colist arabic
3278 +-------+------------------------------------------+
3279 | **1** | set REST requestor as carrier technology |
3280 +-------+------------------------------------------+
3282 .. container:: paragraph
3284 The settings below are required on the producer to
3285 define the event that triggers the REST request and
3286 to specify the peered consumer configuration for the
3287 REST request, for example:
3289 .. container:: listingblock
3291 .. container:: content
3295 "eventNameFilter": "GuardRequestEvent", (1)
3296 "requestorMode": true, (2)
3297 "requestorPeer": "GuardRequestorConsumer", (3)
3298 "requestorTimeout": 500 (4)
3300 .. container:: colist arabic
3302 +-------+-------------------------------------------+
3303 | **1** | a filter on the event |
3304 +-------+-------------------------------------------+
3305 | **2** | requestor mode must be set to *true* |
3306 +-------+-------------------------------------------+
3307 | **3** | the peered consumer for REST requests, |
3308 | | that consumer specifies the full |
3309 | | configuration for REST requests |
3310 +-------+-------------------------------------------+
3311 | **4** | the request timeout in milliseconds, |
3312 | | overridden by timeout on consumer if that |
3313 | | is set, optional defaults to 500 |
3315 +-------+-------------------------------------------+
3317 REST Requestor Input (REST Request Consumer)
3318 ============================================
3320 .. container:: paragraph
3322 APEX will connect to a given URL to issue a REST request and
3323 wait for a REST response.
3324 The URL can be configured statically or tagged
3325 as ``?example.{site}.org:8080/{trig}/events``,
3326 all tags such as ``site`` and ``trig`` in the URL
3327 need to be set in the properties object available to
3328 the tasks. In addition, the keys should exactly match
3329 with the tags defined in url. The scope of the properties
3330 object is per HTTP call. Hence, key/value pairs set
3331 in the properties object by task are only available
3332 for that specific HTTP call.
3333 The httpCodeFilter is used for filtering the status
3334 code, and it can be configured as a regular expression
3335 string. The default httpCodeFilter is "[2][0-9][0-9]"
3336 - for successful response codes.
3337 The response with HTTP status code that matches the
3338 given regular expression is forwarded to the task,
3339 otherwise it is logged as a failure.
3341 .. container:: listingblock
3343 .. container:: content
3347 "carrierTechnologyParameters": {
3348 "carrierTechnology": "RESTREQUESTOR", (1)
3349 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters",
3351 "url": "http://localhost:54321/some/path/to/rest/resource", (2)
3352 "url": "http://localhost:54321/{site}/path/to/rest/{resValue}", (2')
3353 "httpMethod": "POST", (3)
3354 "requestorMode": true, (4)
3355 "requestorPeer": "GuardRequestorProducer", (5)
3356 "restRequestTimeout": 2000, (6)
3357 "httpCodeFilter" : "[2][0-9][0-9]" (7)
3358 "httpHeaders" : [ (8)
3359 ["Keep-Alive", "300"],
3360 ["Cache-Control", "no-cache"]
3364 .. container:: colist arabic
3366 +-------+--------------------------------------------------+
3367 | **1** | set REST requestor as carrier technology |
3368 +-------+--------------------------------------------------+
3369 | **2** | the static URL of the HTTP server for events |
3370 +-------+--------------------------------------------------+
3371 | **2'**| the tagged URL of the HTTP server for events |
3372 +-------+--------------------------------------------------+
3373 | **3** | the HTTP method to use (GET/PUT/POST/DELETE), |
3374 | | optional, defaults to GET |
3375 +-------+--------------------------------------------------+
3376 | **4** | requestor mode must be set to *true* |
3377 +-------+--------------------------------------------------+
3378 | **5** | the peered producer for REST requests, that |
3379 | | producer specifies the APEX output event that |
3380 | | triggers the REST request |
3381 +-------+--------------------------------------------------+
3382 | **6** | request timeout in milliseconds, overrides any |
3383 | | value set in the REST Requestor Producer, |
3384 | | optional, defaults to 500 millisconds |
3385 +-------+--------------------------------------------------+
3386 | **7** | use HTTP CODE FILTER for filtering status code |
3387 | | optional, defaults to [2][0-9][0-9] |
3388 +-------+--------------------------------------------------+
3389 | **8** | HTTP headers to use on the REST request, |
3391 +-------+--------------------------------------------------+
3393 .. container:: paragraph
3395 Further settings may be required on the consumer to
3396 define the input event that is produced and forwarded into
3399 .. container:: listingblock
3401 .. container:: content
3405 "eventName": "GuardResponseEvent", (1)
3406 "eventNameFilter": "GuardResponseEvent" (2)
3408 .. container:: colist arabic
3410 +-------+---------------------------+
3411 | **1** | the event name |
3412 +-------+---------------------------+
3413 | **2** | a filter on the event |
3414 +-------+---------------------------+
3419 .. container:: paragraph
3421 APEX can send requests over gRPC at the output side, and get back
3422 response at the input side. This can be used to send requests to CDS
3423 over gRPC. The media type is ``application/json``, so this plugin
3424 only works with the JSON Event protocol.
3429 .. container:: paragraph
3431 APEX will connect to a given host to send a request over
3434 .. container:: listingblock
3436 .. container:: content
3440 "carrierTechnologyParameters": {
3441 "carrierTechnology": "GRPC", (1)
3442 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
3444 "host": "cds-blueprints-processor-grpc", (2)
3446 "username": "ccsdkapps", (3)
3447 "password": ccsdkapps, (4)
3452 .. container:: colist arabic
3454 +-------+--------------------------------------------------+
3455 | **1** | set GRPC as carrier technology |
3456 +-------+--------------------------------------------------+
3457 | **2** | the host to which request is sent |
3458 +-------+--------------------------------------------------+
3459 | **2'**| the value for port |
3460 +-------+--------------------------------------------------+
3461 | **3** | username required to initiate connection |
3462 +-------+--------------------------------------------------+
3463 | **4** | password required to initiate connection |
3464 +-------+--------------------------------------------------+
3465 | **5** | the timeout value for completing the request |
3466 +-------+--------------------------------------------------+
3468 .. container:: paragraph
3470 Further settings are required on the producer to
3471 define the event that is requested, for example:
3473 .. container:: listingblock
3475 .. container:: content
3479 "eventName": "GRPCRequestEvent", (1)
3480 "eventNameFilter": "GRPCRequestEvent", (2)
3481 "requestorMode": true, (3)
3482 "requestorPeer": "GRPCRequestConsumer", (4)
3483 "requestorTimeout": 500 (5)
3485 .. container:: colist arabic
3487 +-------+---------------------------+
3488 | **1** | the event name |
3489 +-------+---------------------------+
3490 | **2** | a filter on the event |
3491 +-------+---------------------------+
3492 | **3** | the mode of the requestor |
3493 +-------+---------------------------+
3494 | **4** | a peer for the requestor |
3495 +-------+---------------------------+
3496 | **5** | a general request timeout |
3497 +-------+---------------------------+
3502 .. container:: paragraph
3504 APEX will connect to the host specified in the producer
3505 side, anad take in response back at the consumer side.
3507 .. container:: listingblock
3509 .. container:: content
3513 "carrierTechnologyParameters": {
3514 "carrierTechnology": "GRPC", (1)
3515 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
3518 .. container:: colist arabic
3520 +-------+------------------------------------------+
3521 | **1** | set GRPC as carrier technology |
3522 +-------+------------------------------------------+
3524 .. container:: paragraph
3526 Further settings are required on the consumer to
3527 define the event that is requested, for example:
3529 .. container:: listingblock
3531 .. container:: content
3535 "eventNameFilter": "GRPCResponseEvent", (1)
3536 "requestorMode": true, (2)
3537 "requestorPeer": "GRPCRequestProducer", (3)
3538 "requestorTimeout": 500 (4)
3540 .. container:: colist arabic
3542 +-------+---------------------------+
3543 | **1** | a filter on the event |
3544 +-------+---------------------------+
3545 | **2** | the mode of the requestor |
3546 +-------+---------------------------+
3547 | **3** | a peer for the requestor |
3548 +-------+---------------------------+
3549 | **4** | a general request timeout |
3550 +-------+---------------------------+
3552 Event Protocols, Format and Encoding
3553 ------------------------------------
3555 .. container:: paragraph
3557 Event protocols define what event formats APEX can receive
3558 (input) and should send (output). They can be used in any
3559 combination for input and output, unless further restricted
3560 by a carrier technology plugin (for instance for JMS
3561 output). There can only be 1 event protocol per event
3564 .. container:: paragraph
3566 Supported *input* event protocols are:
3568 .. container:: ulist
3570 - JSON, the event as a JSON string
3572 - APEX, an APEX event
3574 - JMS object, the event as a JMS object,
3576 - JMS text, the event as a JMS text,
3578 - XML, the event as an XML string,
3580 - YAML, the event as YAML text
3582 .. container:: paragraph
3584 Supported *output* event protocols are:
3586 .. container:: ulist
3588 - JSON, the event as a JSON string
3590 - APEX, an APEX event
3592 - JMS object, the event as a JMS object,
3594 - JMS text, the event as a JMS text,
3596 - XML, the event as an XML string,
3598 - YAML, the event as YAML text
3600 .. container:: paragraph
3602 New event protocols can be added as plugins to APEX or
3603 developed outside APEX and added to an APEX deployment.
3608 .. container:: paragraph
3610 The event protocol for JSON encoding does not require a
3611 specific plugin, it is supported by default. Furthermore,
3612 there is no difference in the configuration for the input
3613 and output interface.
3615 .. container:: paragraph
3617 For an input, APEX requires a well-formed JSON string.
3618 Well-formed here means according to the definitions of a
3619 policy. Any JSON string that is not defined as a trigger
3620 event (consume) will not be consumed (errors will be
3621 thrown). For output JSON events, APEX will always produce
3622 valid JSON strings according to the definition in the
3625 .. container:: paragraph
3627 The following JSON shows the configuration.
3629 .. container:: listingblock
3631 .. container:: content
3635 "eventProtocolParameters":{
3636 "eventProtocol" : "JSON"
3639 .. container:: paragraph
3641 For JSON events, there are a few more optional
3642 parameters, which allow to define a mapping for standard
3643 event fields. An APEX event must have the fields
3644 ``name``, ``version``, ``source``, and ``target``
3645 defined. Sometimes it is not possible to configure a
3646 trigger or actioning system to use those fields. However,
3647 they might be in an event generated outside APEX (or used
3648 outside APEX) just with different names. To configure
3649 APEX to map between the different event names, simply add
3650 the following parameters to a JSON event:
3652 .. container:: listingblock
3654 .. container:: content
3658 "eventProtocolParameters":{
3659 "eventProtocol" : "JSON",
3660 "nameAlias" : "policyName", (1)
3661 "versionAlias" : "policyVersion", (2)
3662 "sourceAlias" : "from", (3)
3663 "targetAlias" : "to", (4)
3664 "nameSpaceAlias": "my.name.space" (5)
3667 .. container:: colist arabic
3669 +-----------------------------------+-----------------------------------+
3670 | **1** | mapping for the ``name`` field, |
3671 | | here from a field called |
3672 | | ``policyName`` |
3673 +-----------------------------------+-----------------------------------+
3674 | **2** | mapping for the ``version`` |
3675 | | field, here from a field called |
3676 | | ``policyVersion`` |
3677 +-----------------------------------+-----------------------------------+
3678 | **3** | mapping for the ``source`` field, |
3679 | | here from a field called ``from`` |
3680 | | (only for an input event) |
3681 +-----------------------------------+-----------------------------------+
3682 | **4** | mapping for the ``target`` field, |
3683 | | here from a field called ``to`` |
3684 | | (only for an output event) |
3685 +-----------------------------------+-----------------------------------+
3686 | **5** | mapping for the ``nameSpace`` |
3687 | | field, here from a field called |
3688 | | ``my.name.space`` |
3689 +-----------------------------------+-----------------------------------+
3693 .. container:: paragraph
3695 The event protocol for APEX events does not require a
3696 specific plugin, it is supported by default. Furthermore,
3697 there is no difference in the configuration for the input
3698 and output interface.
3700 .. container:: paragraph
3702 For input and output APEX uses APEX events.
3704 .. container:: paragraph
3706 The following JSON shows the configuration.
3708 .. container:: listingblock
3710 .. container:: content
3714 "eventProtocolParameters":{
3715 "eventProtocol" : "APEX"
3721 .. container:: paragraph
3723 The event protocol for JMS is provided by the APEX JMS
3724 plugin. The plugin supports encoding as JSON text or as
3725 object. There is no difference in the configuration for
3726 the input and output interface.
3730 .. container:: paragraph
3732 If used as input, APEX will take a JMS message and
3733 extract a JSON string, then proceed as if a JSON event
3734 was received. If used as output, APEX will take the
3735 event produced by a policy, create a JSON string, and
3736 then wrap it into a JMS message.
3738 .. container:: paragraph
3740 The configuration for JMS text is as follows:
3742 .. container:: listingblock
3744 .. container:: content
3748 "eventProtocolParameters":{
3749 "eventProtocol" : "JMSTEXT",
3750 "parameterClassName" :
3751 "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters"
3756 .. container:: paragraph
3758 If used as input, APEX will will take a JMS message,
3759 extract a Java Bean from the ``ObjectMessage``
3760 message, construct an APEX event and put the bean on
3761 the APEX event as a parameter. If used as output, APEX
3762 will take the event produced by a policy, create a
3763 Java Bean and send it as a JMS message.
3765 .. container:: paragraph
3767 The configuration for JMS object is as follows:
3769 .. container:: listingblock
3771 .. container:: content
3775 "eventProtocolParameters":{
3776 "eventProtocol" : "JMSOBJECT",
3777 "parameterClassName" :
3778 "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters"
3784 .. container:: paragraph
3786 The event protocol for YAML is provided by the APEX YAML
3787 plugin. There is no difference in the configuration for
3788 the input and output interface.
3790 .. container:: paragraph
3792 If used as input, APEX will consume events as YAML and
3793 map them to policy trigger events. Not well-formed YAML
3794 and not understood trigger events will be rejected. If
3795 used as output, APEX produce YAML encoded events from the
3796 event a policy produces. Those events will always be
3797 well-formed according to the definition in the policy
3800 .. container:: paragraph
3802 The following code shows the configuration.
3804 .. container:: listingblock
3806 .. container:: content
3810 "eventProtocolParameters":{
3811 "eventProtocol" : "XML",
3812 "parameterClassName" :
3813 "org.onap.policy.apex.plugins.event.protocol.yaml.YamlEventProtocolParameters"
3818 .. container:: paragraph
3820 The event protocol for XML is provided by the APEX XML
3821 plugin. There is no difference in the configuration for
3822 the input and output interface.
3824 .. container:: paragraph
3826 If used as input, APEX will consume events as XML and map
3827 them to policy trigger events. Not well-formed XML and
3828 not understood trigger events will be rejected. If used
3829 as output, APEX produce XML encoded events from the event
3830 a policy produces. Those events will always be
3831 well-formed according to the definition in the policy
3834 .. container:: paragraph
3836 The following code shows the configuration.
3838 .. container:: listingblock
3840 .. container:: content
3844 "eventProtocolParameters":{
3845 "eventProtocol" : "XML",
3846 "parameterClassName" :
3847 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3850 A configuration example
3851 -----------------------
3853 .. container:: paragraph
3855 The following example loads all available plug-ins.
3857 .. container:: paragraph
3859 Events are consumed from a Websocket, APEX as client.
3860 Consumed event format is JSON.
3862 .. container:: paragraph
3864 Events are produced to Kafka. Produced event format is XML.
3866 .. container:: listingblock
3868 .. container:: content
3873 "engineServiceParameters" : {
3874 "name" : "MyApexEngine",
3875 "version" : "0.0.1",
3877 "instanceCount" : 4,
3878 "deploymentPort" : 12345,
3879 "engineParameters" : {
3880 "executorParameters" : {
3882 "parameterClassName" :
3883 "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
3886 "parameterClassName" :
3887 "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
3890 "parameterClassName" :
3891 "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
3894 "parameterClassName" :
3895 "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
3898 "parameterClassName" :
3899 "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
3902 "contextParameters" : {
3903 "parameterClassName" :
3904 "org.onap.policy.apex.context.parameters.ContextParameters",
3905 "schemaParameters" : {
3907 "parameterClassName" :
3908 "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
3914 "producerCarrierTechnologyParameters" : {
3915 "carrierTechnology" : "KAFKA",
3916 "parameterClassName" :
3917 "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters",
3919 "bootstrapServers" : "localhost:49092",
3922 "batchSize" : 16384,
3924 "bufferMemory" : 33554432,
3925 "producerTopic" : "apex-out",
3926 "keySerializer" : "org.apache.kafka.common.serialization.StringSerializer",
3927 "valueSerializer" : "org.apache.kafka.common.serialization.StringSerializer"
3930 "producerEventProtocolParameters" : {
3931 "eventProtocol" : "XML",
3932 "parameterClassName" :
3933 "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters"
3935 "consumerCarrierTechnologyParameters" : {
3936 "carrierTechnology" : "WEBSOCKET",
3937 "parameterClassName" :
3938 "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
3940 "host" : "localhost",
3944 "consumerEventProtocolParameters" : {
3945 "eventProtocol" : "JSON"
3949 Engine and Applications of the APEX System
3950 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3952 Introduction to APEX Engine and Applications
3953 --------------------------------------------
3955 .. container:: paragraph
3957 The core of APEX is the APEX Engine, also known as the APEX
3958 Policy Engine or the APEX PDP (since it is in fact a Policy
3959 Decision Point). Beside this engine, an APEX system comes
3960 with a few applications intended to help with policy
3961 authoring, deployment, and execution.
3963 .. container:: paragraph
3965 The engine itself and most applications are started from the
3966 command line with command line arguments. This is called a
3967 Command Line Interface (CLI). Some applications require an
3968 installation on a webserver, as for instance the REST
3969 Editor. Those applications can be accessed via a web
3972 .. container:: paragraph
3974 You can also use the available APEX APIs and applications to
3975 develop other applications as required. This includes policy
3976 languages (and associated parsers and compilers /
3977 interpreters), GUIs to access APEX or to define policies,
3978 clients to connect to APEX, etc.
3980 .. container:: paragraph
3982 For this documentation, we assume an installation of APEX as
3983 a full system based on a current ONAP release.
3985 CLI on Unix, Windows, and Cygwin
3986 --------------------------------
3988 .. container:: paragraph
3990 A note on APEX CLI applications: all applications and the
3991 engine itself have been deployed and tested on different
3992 operating systems: Red Hat, Ubuntu, Debian, Mac OSX,
3993 Windows, Cygwin. Each operating system comes with its own
3994 way of configuring and executing Java. The main items here
3997 .. container:: ulist
3999 - For UNIX systems (RHL, Ubuntu, Debian, Mac OSX), the
4000 provided bash scripts work as expected with absolute
4002 ``/opt/app/policy/apex-pdp/apex-pdp-2.0.0-SNAPSHOT/examples``),
4003 indirect and linked paths (e.g. ``../apex/apex``), and
4004 path substitutions using environment settings (e.g.
4005 ``$APEX_HOME/bin/``)
4007 - For Windows systems, the provided batch files (``.bat``)
4008 work as expected with with absolute paths (e.g.
4009 ``C:\apex\apex-2.0.0-SNAPSHOT\examples``), and path
4010 substitutions using environment settings (e.g.
4011 ``%APEX_HOME%\bin\``)
4013 - For Cygwin system we assume a standard Cygwin
4014 installation with standard tools (mainly bash) using a
4015 Windows Java installation. This means that the bash
4016 scripts can be used as in UNIX, however any argument
4017 pointing to files and directories need to use either a
4019 ``C:\apex\apex-2.0.0-SNAPSHOT\examples\config...``) or
4020 the command ``cygpath`` with a mixed option. The reason
4021 for that is: Cygwin executes Java using UNIX paths but
4022 then runs Java as a DOS/WINDOWS process, which requires
4023 DOS paths for file access.
4028 .. container:: paragraph
4030 The APEX engine can be started in different ways, depending
4031 your requirements. All scripts are located in the APEX *bin*
4034 .. container:: paragraph
4036 On UNIX and Cygwin systems use:
4038 .. container:: ulist
4040 - ``apexEngine.sh`` - this script will
4042 .. container:: ulist
4044 - Test if ``$APEX_USER`` is set and if the user
4045 exists, terminate with an error otherwise
4047 - Test if ``$APEX_HOME`` is set. If not set, it will
4048 use the default setting as
4049 ``/opt/app/policy/apex-pdp/apex-pdp``. Then the set
4050 directory is tested to exist, the script will
4053 - When all tests are passed successfully, the script
4054 will call ``apexApps.sh`` with arguments to start
4057 - ``apexApps.sh engine`` - this is the general APEX
4058 application launcher, which will
4060 .. container:: ulist
4062 - Start the engine with the argument ``engine``
4064 - Test if ``$APEX_HOME`` is set and points to an
4065 existing directory. If not set or directory does
4066 not exist, script terminates.
4068 - Not test for any settings of ``$APEX_USER``.
4070 .. container:: paragraph
4072 On Windows systems use ``apexEngine.bat`` and
4073 ``apexApps.bat engine`` respectively. Note: none of the
4074 windows batch files will test for ``%APEX_USER%``.
4076 .. container:: paragraph
4078 Summary of alternatives to start the APEX Engine:
4080 +--------------------------------------------------------+----------------------------------------------------------+
4081 | Unix, Cygwin | Windows |
4082 +========================================================+==========================================================+
4083 | .. container:: | .. container:: |
4085 | .. container:: listingblock | .. container:: listingblock |
4087 | .. container:: content | .. container:: content |
4089 | .. code:: | .. code:: |
4091 | # $APEX_HOME/bin/apexEngine.sh [args] | > %APEX_HOME%\bin\apexEngine.bat [args] |
4092 | # $APEX_HOME/bin/apexApps.sh engine [args] | > %APEX_HOME%\bin\apexApps.bat engine [args] |
4093 +--------------------------------------------------------+----------------------------------------------------------+
4095 .. container:: paragraph
4097 The APEX engine comes with a few CLI arguments, the main one is for setting
4098 the tosca policy file for execution. The tosca policy file is
4099 always required. The option ``-h`` prints a help screen.
4101 .. container:: listingblock
4103 .. container:: content
4107 usage: org.onap.policy.apex.service.engine.main.ApexMain [options...]
4109 -p,--tosca-policy-file <TOSCA_POLICY_FILE> the full path to the ToscaPolicy file to use.
4110 -h,--help outputs the usage of this command
4111 -v,--version outputs the version of Apex
4116 .. container:: paragraph
4118 The CLI Editor allows to define policies from the command
4119 line. The application uses a simple language and supports
4120 all elements of an APEX policy. It can be used in to
4123 .. container:: ulist
4125 - non-interactive, specifying a file with the commands to
4128 - interactive, using the editors CLI to create a policy
4130 .. container:: paragraph
4132 When a policy is fully specified, the editor will generate
4133 the APEX core policy specification in JSON. This core
4134 specification is called the policy model in the APEX engine
4135 and can be used directly with the APEX engine.
4137 .. container:: paragraph
4139 On UNIX and Cygwin systems use:
4141 .. container:: ulist
4143 - ``apexCLIEditor.sh`` - simply starts the CLI editor,
4144 arguments to the script determine the mode of the editor
4146 - ``apexApps.sh cli-editor`` - simply starts the CLI
4147 editor, arguments to the script determine the mode of the
4150 .. container:: paragraph
4152 On Windows systems use:
4154 .. container:: ulist
4156 - ``apexCLIEditor.bat`` - simply starts the CLI editor,
4157 arguments to the script determine the mode of the editor
4159 - ``apexApps.bat cli-editor`` - simply starts the CLI
4160 editor, arguments to the script determine the mode of the
4163 .. container:: paragraph
4165 Summary of alternatives to start the APEX CLI Editor:
4167 +------------------------------------------------------------+--------------------------------------------------------------+
4168 | Unix, Cygwin | Windows |
4169 +============================================================+==============================================================+
4170 | .. container:: | .. container:: |
4172 | .. container:: listingblock | .. container:: listingblock |
4174 | .. container:: content | .. container:: content |
4176 | .. code:: | .. code:: |
4178 | # $APEX_HOME/bin/apexCLIEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIEditor.bat [args] |
4179 | # $APEX_HOME/bin/apexApps.sh cli-editor [args] | > %APEX_HOME%\bin\apexApps.bat cli-editor [args] |
4180 +------------------------------------------------------------+--------------------------------------------------------------+
4182 .. container:: paragraph
4184 The option ``-h`` provides a help screen with all command
4187 .. container:: listingblock
4189 .. container:: content
4193 usage: org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain [options...]
4195 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4196 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4197 -h,--help outputs the usage of this command
4198 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4199 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and continue
4200 executing the command file
4201 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will log
4202 to standard output if not specified or suppressed with "-nl" flag
4203 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4204 -nl,--no-log if specified, no logging or output of commands to standard output or log
4206 -nm,--no-model-output if specified, no output of a model to standard output or model output
4207 file is carried out, the user can use the "save" command in a script to
4209 -o,--output-model-file <OUTPUT_MODEL_FILE> name of a file that will contain the output model for the editor, will
4210 output model to standard output if not specified or suppressed with
4212 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4213 root from which to look for included macro files
4215 The APEX CLI Tosca Editor
4216 -------------------------
4218 .. container:: paragraph
4220 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.
4222 .. container:: paragraph
4224 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.
4226 .. container:: paragraph
4228 On UNIX and Cygwin systems use:
4230 .. container:: ulist
4232 - ``apexCLIToscaEditor.sh`` - starts the CLI Tosca editor,
4233 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4235 - ``apexApps.sh cli-tosca-editor`` - starts the CLI Tosca editor,
4236 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4238 .. container:: paragraph
4240 On Windows systems use:
4242 .. container:: ulist
4244 - ``apexCLIToscaEditor.bat`` - starts the CLI Tosca editor,
4245 all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4247 - ``apexApps.bat cli-tosca-editor`` - starts the CLI Tosca
4248 editor, all the arguments supported by the basic CLI Editor are supported in addition to the mandatory arguments needed to generate ToscaServiceTemplate.
4250 .. container:: paragraph
4252 Summary of alternatives to start the APEX CLI Tosca Editor:
4254 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4255 | Unix, Cygwin | Windows |
4256 +=================================================================+====================================================================+
4257 | .. container:: | .. container:: |
4259 | .. container:: listingblock | .. container:: listingblock |
4261 | .. container:: content | .. container:: content |
4263 | .. code:: | .. code:: |
4265 | # $APEX_HOME/bin/apexCLIToscaEditor.sh.sh [args] | > %APEX_HOME%\bin\apexCLIToscaEditor.bat [args] |
4266 | # $APEX_HOME/bin/apexApps.sh cli-tosca-editor [args]| > %APEX_HOME%\bin\apexApps.bat cli-tosca-editor [args] |
4267 +-----------------------------------------------------------------+--------------------------------------------------------------------+
4269 .. container:: paragraph
4271 The option ``-h`` provides a help screen with all command
4274 .. container:: listingblock
4276 .. container:: content
4280 usage: org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain [options...]
4282 -a,--model-props-file <MODEL_PROPS_FILE> name of the apex model properties file to use
4283 -ac,--apex-config-file <APEX_CONFIG_FILE> name of the file containing apex configuration details
4284 -c,--command-file <COMMAND_FILE> name of a file containing editor commands to run into the editor
4285 -h,--help outputs the usage of this command
4286 -i,--input-model-file <INPUT_MODEL_FILE> name of a file that contains an input model for the editor
4287 -if,--ignore-failures <IGNORE_FAILURES_FLAG> true or false, ignore failures of commands in command files and
4288 continue executing the command file
4289 -l,--log-file <LOG_FILE> name of a file that will contain command logs from the editor, will
4290 log to standard output if not specified or suppressed with "-nl" flag
4291 -m,--metadata-file <CMD_METADATA_FILE> name of the command metadata file to use
4292 -nl,--no-log if specified, no logging or output of commands to standard output or
4293 log file is carried out
4294 -ot,--output-tosca-file <OUTPUT_TOSCA_FILE> name of a file that will contain the output ToscaServiceTemplate
4295 -t,--tosca-template-file <TOSCA_TEMPLATE_FILE> name of the input file containing tosca template which needs to be
4297 -wd,--working-directory <WORKING_DIRECTORY> the working directory that is the root for the CLI editor and is the
4298 root from which to look for included macro files
4300 .. container:: paragraph
4302 An example command to run the APEX CLI Tosca editor on windows machine is given below.
4304 .. container:: listingblock
4306 .. container:: content
4310 %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
4316 .. container:: paragraph
4318 The APEX Client combines the Policy Editor, the
4319 Monitoring Client, and the Deployment Client into a single
4320 application. The standard way to use the APEX Full Client is
4321 via an installation of the *war* file on a webserver.
4322 However, the Full Client can also be started via command
4323 line. This will start a Grizzly webserver with the *war*
4324 deployed. Access to the Full Client is then via the provided
4327 .. container:: paragraph
4329 On UNIX and Cygwin systems use:
4331 .. container:: ulist
4333 - ``apexApps.sh full-client`` - simply starts the webserver
4334 with the Full Client
4336 .. container:: paragraph
4338 On Windows systems use:
4340 .. container:: ulist
4342 - ``apexApps.bat full-client`` - simply starts the
4343 webserver with the Full Client
4345 .. container:: paragraph
4347 The option ``-h`` provides a help screen with all command
4350 .. container:: listingblock
4352 .. container:: content
4356 usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]
4357 -h,--help outputs the usage of this command
4358 -p,--port <PORT> port to use for the Apex Services REST calls
4359 -t,--time-to-live <TIME_TO_LIVE> the amount of time in seconds that the server will run for before terminating
4361 .. container:: paragraph
4363 If the Full Client is started without any arguments the
4364 final messages will look similar to this:
4366 .. container:: listingblock
4368 .. container:: content
4372 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=READY) starting at http://localhost:18989/apexservices/ . . .
4373 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.NetworkListener start
4374 INFO: Started listener bound to [localhost:18989]
4375 Sep 05, 2018 11:28:28 PM org.glassfish.grizzly.http.server.HttpServer start
4376 INFO: [HttpServer] Started.
4377 Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: URI=http://localhost:18989/apexservices/, TTL=-1sec], State=RUNNING) started at http://localhost:18989/apexservices/
4379 .. container:: paragraph
4381 The last line states the URL on which the Monitoring Client
4382 can be accessed. The example above stated
4383 ``http://localhost:18989/apexservices``. In a web browser
4384 use the URL ``http://localhost:18989``.
4386 The APEX Application Launcher
4387 -----------------------------
4389 .. container:: paragraph
4391 The standard applications (Engine and CLI Editor)
4392 come with dedicated start scripts. For all other APEX
4393 applications, we provide an application launcher.
4395 .. container:: paragraph
4397 On UNIX and Cygwin systems use:
4399 .. container:: ulist
4401 - apexApps.sh\` - simply starts the application launcher
4403 .. container:: paragraph
4405 On Windows systems use:
4407 .. container:: ulist
4409 - ``apexApps.bat`` - simply starts the application launcher
4411 .. container:: paragraph
4413 Summary of alternatives to start the APEX application
4416 +-------------------------------------------------+---------------------------------------------------+
4417 | Unix, Cygwin | Windows |
4418 +=================================================+===================================================+
4419 | .. container:: | .. container:: |
4421 | .. container:: listingblock | .. container:: listingblock |
4423 | .. container:: content | .. container:: content |
4425 | .. code:: | .. code:: |
4427 | # $APEX_HOME/bin/apexApps.sh [args] | > %APEX_HOME%\bin\apexApps.bat [args] |
4428 +-------------------------------------------------+---------------------------------------------------+
4430 .. container:: paragraph
4432 The option ``-h`` provides a help screen with all launcher
4433 command line arguments.
4435 .. container:: listingblock
4437 .. container:: content
4441 apexApps.sh - runs APEX applications
4443 Usage: apexApps.sh [options] | [<application> [<application options>]]
4446 -d <app> - describes an application
4447 -l - lists all applications supported by this script
4448 -h - this help screen
4450 .. container:: paragraph
4452 Using ``-l`` lists all known application the launcher can
4455 .. container:: listingblock
4457 .. container:: content
4461 apexApps.sh: supported applications:
4462 --> ws-echo engine eng-monitoring full-client eng-deployment tpl-event-json model-2-cli rest-editor cli-editor ws-console
4464 .. container:: paragraph
4466 Using the ``-d <name>`` option describes the named
4467 application, for instance for the ``ws-console``:
4469 .. container:: listingblock
4471 .. container:: content
4475 apexApps.sh: application 'ws-console'
4476 --> a simple console sending events to APEX, connect to APEX consumer port
4478 .. container:: paragraph
4480 Launching an application is done by calling the script with
4481 only the application name and any CLI arguments for the
4482 application. For instance, starting the ``ws-echo``
4483 application with port ``8888``:
4485 .. container:: listingblock
4487 .. container:: content
4491 apexApps.sh ws-echo -p 8888
4493 Application: Create Event Templates
4494 -----------------------------------
4496 .. container:: paragraph
4498 **Status: Experimental**
4500 .. container:: paragraph
4502 This application takes a policy model (JSON or XML encoded)
4503 and generates templates for events in JSON format. This can
4504 help when a policy defines rather complex trigger or action
4505 events or complex events between states. The application can
4506 produce events for the types: stimuli (policy trigger
4507 events), internal (events between policy states), and
4508 response (action events).
4510 +----------------------------------------------------------------+------------------------------------------------------------------+
4511 | Unix, Cygwin | Windows |
4512 +================================================================+==================================================================+
4513 | .. container:: | .. container:: |
4515 | .. container:: listingblock | .. container:: listingblock |
4517 | .. container:: content | .. container:: content |
4519 | .. code:: | .. code:: |
4521 | # $APEX_HOME/bin/apexApps.sh tpl-event-json [args] | > %APEX_HOME%\bin\apexApps.bat tpl-event-json [args] |
4522 +----------------------------------------------------------------+------------------------------------------------------------------+
4524 .. container:: paragraph
4526 The option ``-h`` provides a help screen.
4528 .. container:: listingblock
4530 .. container:: content
4534 gen-model2event v{release-version} - generates JSON templates for events generated from a policy model
4535 usage: gen-model2event
4536 -h,--help prints this help and usage screen
4537 -m,--model <MODEL-FILE> set the input policy model file
4538 -t,--type <TYPE> set the event type for generation, one of:
4539 stimuli (trigger events), response (action
4540 events), internal (events between states)
4541 -v,--version prints the application version
4543 .. container:: paragraph
4545 The created templates are not valid events, instead they use
4546 some markup for values one will need to change to actual
4547 values. For instance, running the tool with the *Sample
4548 Domain* policy model as:
4550 .. container:: listingblock
4552 .. container:: content
4556 apexApps.sh tpl-event-json -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json -t stimuli
4558 .. container:: paragraph
4560 will produce the following status messages:
4562 .. container:: listingblock
4564 .. container:: content
4568 gen-model2event: starting Event generator
4569 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4572 .. container:: paragraph
4574 and then run the generator application producing two event
4575 templates. The first template is called ``Event0000``.
4577 .. container:: listingblock
4579 .. container:: content
4584 "name" : "Event0000",
4585 "nameSpace" : "org.onap.policy.apex.sample.events",
4586 "version" : "0.0.1",
4587 "source" : "Outside",
4589 "TestTemperature" : ###double: 0.0###,
4590 "TestTimestamp" : ###long: 0###,
4591 "TestMatchCase" : ###integer: 0###,
4592 "TestSlogan" : "###string###"
4595 .. container:: paragraph
4597 The values for the keys are marked with ``#`` and the
4598 expected type of the value. To create an actual stimuli
4599 event, all these markers need to be change to actual values,
4602 .. container:: listingblock
4604 .. container:: content
4609 "name" : "Event0000",
4610 "nameSpace" : "org.onap.policy.apex.sample.events",
4611 "version" : "0.0.1",
4612 "source" : "Outside",
4614 "TestTemperature" : 25,
4615 "TestTimestamp" : 123456789123456789,
4616 "TestMatchCase" : 1,
4617 "TestSlogan" : "Testing the Match Case with Temperature 25"
4620 Application: Convert a Policy Model to CLI Editor Commands
4621 ----------------------------------------------------------
4623 .. container:: paragraph
4625 **Status: Experimental**
4627 .. container:: paragraph
4629 This application takes a policy model (JSON or XML encoded)
4630 and generates commands for the APEX CLI Editor. This
4631 effectively reverses a policy specification realized with
4634 +-------------------------------------------------------------+---------------------------------------------------------------+
4635 | Unix, Cygwin | Windows |
4636 +=============================================================+===============================================================+
4637 | .. container:: | .. container:: |
4639 | .. container:: listingblock | .. container:: listingblock |
4641 | .. container:: content | .. container:: content |
4643 | .. code:: | .. code:: |
4645 | # $APEX_HOME/bin/apexApps.sh model-2-cli [args] | > %APEX_HOME%\bin\apexApps.bat model-2-cli [args] |
4646 +-------------------------------------------------------------+---------------------------------------------------------------+
4648 .. container:: paragraph
4650 The option ``-h`` provides a help screen.
4652 .. container:: listingblock
4654 .. container:: content
4658 usage: gen-model2cli
4659 -h,--help prints this help and usage screen
4660 -m,--model <MODEL-FILE> set the input policy model file
4661 -sv,--skip-validation switch of validation of the input file
4662 -v,--version prints the application version
4664 .. container:: paragraph
4666 For instance, running the tool with the *Sample Domain*
4669 .. container:: listingblock
4671 .. container:: content
4675 apexApps.sh model-2-cli -m $APEX_HOME/examples/models/SampleDomain/SamplePolicyModelJAVA.json
4677 .. container:: paragraph
4679 will produce the following status messages:
4681 .. container:: listingblock
4683 .. container:: content
4687 gen-model2cli: starting CLI generator
4688 --> model file: examples/models/SampleDomain/SamplePolicyModelJAVA.json
4690 .. container:: paragraph
4692 and then run the generator application producing all CLI
4693 Editor commands and printing them to standard out.
4695 Application: Websocket Clients (Echo and Console)
4696 -------------------------------------------------
4698 .. container:: paragraph
4700 **Status: Production**
4702 .. container:: paragraph
4704 The application launcher also provides a Websocket echo
4705 client and a Websocket console client. The echo client
4706 connects to APEX and prints all events it receives from
4707 APEX. The console client connects to APEX, reads input from
4708 the command line, and sends this input as events to APEX.
4710 +------------------------------------------------------------+--------------------------------------------------------------+
4711 | Unix, Cygwin | Windows |
4712 +============================================================+==============================================================+
4713 | .. container:: | .. container:: |
4715 | .. container:: listingblock | .. container:: listingblock |
4717 | .. container:: content | .. container:: content |
4719 | .. code:: | .. code:: |
4721 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
4722 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
4723 +------------------------------------------------------------+--------------------------------------------------------------+
4725 .. container:: paragraph
4727 The arguments are the same for both applications:
4729 .. container:: ulist
4731 - ``-p`` defines the Websocket port to connect to (defaults
4734 - ``-s`` defines the host on which a Websocket server is
4735 running (defaults to ``localhost``)
4737 .. container:: paragraph
4739 A discussion on how to use these two applications to build
4740 an APEX system is detailed HowTo-Websockets.
4745 Introduction to APEX Logging
4746 ----------------------------
4748 .. container:: paragraph
4750 All APEX components make extensive use of logging using the
4751 logging façade `SLF4J <https://www.slf4j.org/>`__ with the
4752 backend `Logback <https://logback.qos.ch/>`__. Both are used
4753 off-the-shelve, so the standard documentation and
4754 configuration apply to APEX logging. For details on how to
4755 work with logback please see the `logback
4756 manual <https://logback.qos.ch/manual/index.html>`__.
4758 .. container:: paragraph
4760 The APEX applications is the logback configuration file
4761 ``$APEX_HOME/etc/logback.xml`` (Windows:
4762 ``%APEX_HOME%\etc\logback.xml``). The logging backend is set
4763 to no debug, i.e. logs from the logging framework should be
4766 .. container:: paragraph
4768 The configurable log levels work as expected:
4770 .. container:: ulist
4772 - *error* (or *ERROR*) is used for serious errors in the
4775 - *warn* (or *WARN*) is used for warnings, which in general
4776 can be ignored but might indicate some deeper problems
4778 - *info* (or *INFO*) is used to provide generally
4779 interesting messages for startup and policy execution
4781 - *debug* (or *DEBUG*) provides more details on startup and
4784 - *trace* (or *TRACE*) gives full details on every aspect
4785 of the APEX engine from start to end
4787 .. container:: paragraph
4789 The loggers can also be configured as expected. The standard
4790 configuration (after installing APEX) uses log level *info*
4791 on all APEX classes (components).
4793 .. container:: paragraph
4795 The applications and scripts in ``$APEX_HOME/bin`` (Windows:
4796 ``%APEX_HOME\bin``) are configured to use the logback
4797 configuration ``$APEX_HOME/etc/logback.xml`` (Windows:
4798 ``%APEX_HOME\etc\logback.xml``). There are multiple ways to
4799 use different logback configurations, for instance:
4801 .. container:: ulist
4803 - Maintain multiple configurations in ``etc``, for instance
4804 a ``logback-debug.xml`` for deep debugging and a
4805 ``logback-production.xml`` for APEX in production mode,
4806 then copy the required configuration file to the used
4807 ``logback.xml`` prior starting APEX
4809 - Edit the scripts in ``bin`` to use a different logback
4810 configuration file (only recommended if you are familiar
4811 with editing bash scripts or windows batch files)
4813 Standard Logging Configuration
4814 ------------------------------
4816 .. container:: paragraph
4818 The standard logging configuration defines a context *APEX*,
4819 which is used in the standard output pattern. The location
4820 for log files is defined in the property ``logDir`` and set
4821 to ``/var/log/onap/policy/apex-pdp``. The standard status
4822 listener is set to *NOP* and the overall logback
4823 configuration is set to no debug.
4825 .. container:: listingblock
4827 .. container:: content
4832 <configuration debug="false">
4833 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
4835 <contextName>Apex</contextName>
4836 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
4842 .. container:: paragraph
4844 The first appender defined is called ``STDOUT`` for logs to standard
4847 .. container:: listingblock
4849 .. container:: content
4854 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4856 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
4860 .. container:: paragraph
4862 The root level logger then is set to the level *info* using the
4863 standard out appender.
4865 .. container:: listingblock
4867 .. container:: content
4873 <appender-ref ref="STDOUT" />
4876 .. container:: paragraph
4878 The second appender is called ``FILE``. It writes logs to a file
4881 .. container:: listingblock
4883 .. container:: content
4888 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
4889 <file>${logDir}/apex.log</file>
4891 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4895 .. container:: paragraph
4897 The third appender is called ``CTXT_FILE``. It writes logs to a file
4900 .. container:: listingblock
4902 .. container:: content
4907 <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
4908 <file>${logDir}/apex_ctxt.log</file>
4910 <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
4914 .. container:: paragraph
4916 The last definitions are for specific loggers. The first logger
4917 captures all standard APEX classes. It is configured for log level
4918 *info* and uses the standard output and file appenders. The second
4919 logger captures APEX context classes responsible for context
4920 monitoring. It is configured for log level *trace* and uses the
4921 context file appender.
4923 .. container:: listingblock
4925 .. container:: content
4931 <logger name="org.onap.policy.apex" level="info" additivity="false">
4932 <appender-ref ref="STDOUT" />
4933 <appender-ref ref="FILE" />
4936 <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
4937 <appender-ref ref="CTXT_FILE" />
4940 Adding Logback Status and Debug
4941 -------------------------------
4943 .. container:: paragraph
4945 To activate logback status messages change the status listener
4946 from 'NOP' to for instance console.
4948 .. container:: listingblock
4950 .. container:: content
4954 <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
4956 .. container:: paragraph
4958 To activate all logback debugging, for instance to debug a new
4959 logback configuration, activate the debug attribute in the
4962 .. container:: listingblock
4964 .. container:: content
4968 <configuration debug="true">
4972 Logging External Components
4973 ---------------------------
4975 .. container:: paragraph
4977 Logback can also be configured to log any other, external
4978 components APEX is using, if they are using the common logging
4981 .. container:: paragraph
4983 For instance, the context component of APEX is using *Infinispan*
4984 and one can add a logger for this external component. The
4985 following example adds a logger for *Infinispan* using the
4986 standard output appender.
4988 .. container:: listingblock
4990 .. container:: content
4994 <logger name="org.infinispan" level="INFO" additivity="false">
4995 <appender-ref ref="STDOUT" />
4998 .. container:: paragraph
5000 Another example is Apache Zookeeper. The following example adds a
5001 logger for Zookeeper using the standard outout appender.
5003 .. container:: listingblock
5005 .. container:: content
5009 <logger name="org.apache.zookeeper.ClientCnxn" level="INFO" additivity="false">
5010 <appender-ref ref="STDOUT" />
5013 Configuring loggers for Policy Logic
5014 ------------------------------------
5016 .. container:: paragraph
5018 The logging for the logic inside a policy (task logic, task
5019 selection logic, state finalizer logic) can be configured separate
5020 from standard logging. The logger for policy logic is
5021 ``org.onap.policy.apex.executionlogging``. The following example
5024 .. container:: ulist
5026 - a new appender for standard out using a very simple pattern
5027 (simply the actual message)
5029 - a logger for policy logic to standard out using the new
5030 appender and the already described file appender.
5032 .. container:: listingblock
5034 .. container:: content
5038 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5040 <pattern>policy: %msg\n</pattern>
5044 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5045 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5046 <appender-ref ref="FILE" />
5049 .. container:: paragraph
5051 It is also possible to use specific logging for parts of policy
5052 logic. The following example defines a logger for task logic.
5054 .. container:: listingblock
5056 .. container:: content
5060 <logger name="org.onap.policy.apex.executionlogging.TaskExecutionLogging" level="TRACE" additivity="false">
5061 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5064 Rolling File Appenders
5065 ----------------------
5067 .. container:: paragraph
5069 Rolling file appenders are a good option for more complex logging
5070 of a production or complex testing APEX installation. The standard
5071 logback configuration can be used for these use cases. This
5072 section gives two examples for the standard logging and for
5075 .. container:: paragraph
5077 First the standard logging. The following example defines a
5078 rolling file appender. The appender rolls over on a daily basis.
5079 It allows for a file size of 100 MB.
5081 .. container:: listingblock
5083 .. container:: content
5087 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
5088 <file>${logDir}/apex.log</file>
5089 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5090 <!-- rollover daily -->
5091 <!-- <fileNamePattern>xstream-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> -->
5092 <fileNamePattern>${logDir}/apex_%d{yyyy-MM-dd}.%i.log.gz
5094 <maxHistory>4</maxHistory>
5095 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5096 <!-- or whenever the file size reaches 100MB -->
5097 <maxFileSize>100MB</maxFileSize>
5098 </timeBasedFileNamingAndTriggeringPolicy>
5102 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5107 .. container:: paragraph
5109 A very similar configuration can be used for a rolling file
5110 appender logging APEX context.
5112 .. container:: listingblock
5114 .. container:: content
5118 <appender name="CTXT-FILE"
5119 class="ch.qos.logback.core.rolling.RollingFileAppender">
5120 <file>${logDir}/apex_ctxt.log</file>
5121 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
5122 <fileNamePattern>${logDir}/apex_ctxt_%d{yyyy-MM-dd}.%i.log.gz
5124 <maxHistory>4</maxHistory>
5125 <timeBasedFileNamingAndTriggeringPolicy
5126 class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
5127 <maxFileSize>100MB</maxFileSize>
5128 </timeBasedFileNamingAndTriggeringPolicy>
5132 %d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %ex{full} %n
5137 Example Configuration for Logging Logic
5138 ---------------------------------------
5140 .. container:: paragraph
5142 The following example shows a configuration that logs policy logic
5143 to standard out and a file (*info*). All other APEX components are
5144 logging to a file (*debug*).. This configuration an be used in a
5145 pre-production phase with the APEX engine still running in a
5146 separate terminal to monitor policy execution. This logback
5147 configuration is in the APEX installation as
5148 ``etc/logback-logic.xml``.
5150 .. container:: listingblock
5152 .. container:: content
5156 <configuration debug="false">
5157 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5159 <contextName>Apex</contextName>
5160 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5162 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5164 <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
5168 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5169 <file>${logDir}/apex.log</file>
5172 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5177 <appender name="POLICY_APPENDER_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5179 <pattern>policy: %msg\n</pattern>
5183 <root level="error">
5184 <appender-ref ref="STDOUT" />
5187 <logger name="org.onap.policy.apex" level="debug" additivity="false">
5188 <appender-ref ref="FILE" />
5191 <logger name="org.onap.policy.apex.executionlogging" level="info" additivity="false">
5192 <appender-ref ref="POLICY_APPENDER_STDOUT" />
5193 <appender-ref ref="FILE" />
5197 Example Configuration for a Production Server
5198 ---------------------------------------------
5200 .. container:: paragraph
5202 The following example shows a configuration that logs all APEX
5203 components, including policy logic, to a file (*debug*). This
5204 configuration an be used in a production phase with the APEX
5205 engine being executed as a service on a system without console
5206 output. This logback configuration is in the APEX installation as
5207 ``logback-server.xml``
5209 .. container:: listingblock
5211 .. container:: content
5215 <configuration debug="false">
5216 <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
5218 <contextName>Apex</contextName>
5219 <property name="logDir" value="/var/log/onap/policy/apex-pdp/" />
5221 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
5222 <file>${logDir}/apex.log</file>
5225 %d %-5relative [procId=${processId}] [%thread] %-5level%logger{26} - %msg %n %ex{full}
5230 <root level="debug">
5231 <appender-ref ref="FILE" />
5234 <logger name="org.onap.policy.apex.executionlogging" level="debug" additivity="false">
5235 <appender-ref ref="FILE" />
5239 Unsupported Features
5240 ^^^^^^^^^^^^^^^^^^^^
5242 .. container:: paragraph
5244 This section documents some legacy and unsupported features
5245 in apex-pdp. The documentation here has not been updated for
5246 recent versions of apex-pdp. For example, the apex-pdp models
5247 specified in this example should now be in TOSCA format.
5249 Building a System with Websocket Backend
5250 ----------------------------------------
5255 .. container:: paragraph
5257 Websocket is a protocol to run sockets of HTTP. Since it in
5258 essence a socket, the connection is realized between a
5259 server (waiting for connections) and a client (connecting to
5260 a server). Server/client separation is only important for
5261 connection establishment, once connected, everyone can
5262 send/receive on the same socket (as any standard socket
5265 .. container:: paragraph
5267 Standard Websocket implementations are simple, no
5268 publish/subscribe and no special event handling. Most
5269 servers simply send all incoming messages to all
5270 connections. There is a PubSub definition on top of
5271 Websocket called `WAMP <http://wamp-proto.org/>`__. APEX
5272 does not support WAMP at the moment.
5277 .. container:: paragraph
5280 356 <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5281 defines the standard Websocket API. This JSR is part of Jave
5282 EE 7 standard. For Java SE, several implementations exist in
5283 open source. Since Websockets are a stable standard and
5284 simple, most implementations are stable and ready to use. A
5285 lot of products support Websockets, like Spring, JBoss,
5286 Netty, … there are also Kafka extensions for Websockets.
5288 Websocket Example Code for Websocket clients (FOSS)
5289 ###################################################
5291 .. container:: paragraph
5293 There are a lot of implementations and examples available on
5294 Github for Websocket clients. If one is using Java EE 7,
5295 then one can also use the native Websocket implementation.
5296 Good examples for clients using simply Java SE are here:
5298 .. container:: ulist
5301 implementation <https://github.com/TooTallNate/Java-WebSocket>`__
5303 - `Websocket sending client example, using
5304 AWT <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ChatClient.java>`__
5306 - `Websocket receiving client example (simple echo
5307 client) <https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/example/ExampleClient.java>`__
5309 .. container:: paragraph
5311 For Java EE, the native Websocket API is explained here:
5313 .. container:: ulist
5316 docs <http://www.oracle.com/technetwork/articles/java/jsr356-1937161.html>`__
5319 example <http://www.programmingforliving.com/2013/08/jsr-356-java-api-for-websocket-client-api.html>`__
5321 BCP: Websocket Configuration
5322 ############################
5324 .. container:: paragraph
5326 The probably best is to configure APEX for Websocket servers
5327 for input (ingress, consume) and output (egress, produce)
5328 interfaces. This means that APEX will start Websocket
5329 servers on named ports and wait for clients to connect.
5330 Advantage: once APEX is running all connectivity
5331 infrastructure is running as well. Consequence: if APEX is
5332 not running, everyone else is in the dark, too.
5334 .. container:: paragraph
5336 The best protocol to be used is JSON string. Each event on
5337 any interface is then a string with a JSON encoding. JSON
5338 string is a little bit slower than byte code, but we doubt
5339 that this will be noticeable. A further advantage of JSON
5340 strings over Websockets with APEX starting the servers: it
5341 is very easy to connect web browsers to such a system.
5342 Simple connect the web browser to the APEX sockets and
5343 send/read JSON strings.
5345 .. container:: paragraph
5347 Once APEX is started you simply connect Websocket clients to
5348 it, and send/receive event. When APEX is terminated, the
5349 Websocket servers go down, and the clients will be
5350 disconnected. APEX does not (yet) support auto-client
5351 reconnect nor WAMP, so clients might need to be restarted or
5352 reconnected manually after an APEX boot.
5354 Demo with VPN Policy Model
5355 ##########################
5357 .. container:: paragraph
5359 We assume that you have an APEX installation using the full
5360 package, i.e. APEX with all examples, of version ``0.5.6``
5361 or higher. We will use the VPN policy from the APEX examples
5364 .. container:: paragraph
5366 Now, have the following ready to start the demo:
5368 .. container:: ulist
5370 - 3 terminals on the host where APEX is running (we need 1
5371 for APEX and 1 for each client)
5373 - the events in the file
5374 ``$APEX_HOME/examples/events/VPN/SetupEvents.json`` open
5375 in an editor (we need to send those events to APEX)
5377 - the events in the file
5378 ``$APEX_HOME/examples/events/VPN/Link09Events.json`` open
5379 in an editor (we need to send those events to APEX)
5381 A Websocket Configuration for the VPN Domain
5382 ********************************************
5384 .. container:: paragraph
5386 Create a new APEX configuration using the VPN policy
5387 model and configuring APEX as discussed above for
5388 Websockets. Copy the following configuration into
5389 ``$APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json``
5391 ``%APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json``):
5393 .. container:: listingblock
5395 .. container:: content
5401 "engineServiceParameters" : {
5402 "name" : "VPNApexEngine",
5403 "version" : "0.0.1",
5405 "instanceCount" : 1,
5406 "deploymentPort" : 12345,
5407 "policyModelFileName" : "examples/models/VPN/VPNPolicyModelAvro.json",
5408 "engineParameters" : {
5409 "executorParameters" : {
5411 "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
5414 "contextParameters" : {
5415 "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
5416 "schemaParameters":{
5418 "parameterClassName" : "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
5424 "producerCarrierTechnologyParameters" : {
5425 "carrierTechnology" : "WEBSOCKET",
5426 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5432 "producerEventProtocolParameters" : {
5433 "eventProtocol" : "JSON"
5435 "consumerCarrierTechnologyParameters" : {
5436 "carrierTechnology" : "WEBSOCKET",
5437 "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
5443 "consumerEventProtocolParameters" : {
5444 "eventProtocol" : "JSON"
5451 .. container:: paragraph
5453 In a new terminal, start APEX with the new configuration for
5454 Websocket-Server ingress/egress:
5456 .. container:: listingblock
5458 .. container:: content
5463 #: $APEX_HOME/bin/apexApps.sh engine -c $APEX_HOME/examples/config/VPN/Ws2WsServerAvroContextJsonEvent.json
5465 .. container:: listingblock
5467 .. container:: content
5472 #: %APEX_HOME%\bin\apexApps.bat engine -c %APEX_HOME%\examples\config\VPN\Ws2WsServerAvroContextJsonEvent.json
5474 .. container:: paragraph
5476 Wait for APEX to start, it takes a while to create all Websocket
5477 servers (about 8 seconds on a standard laptop without cached
5478 binaries). depending on your log messages, you will see no (some, a
5479 lot) log messages. If APEX starts correctly, the last few messages
5482 .. container:: listingblock
5484 .. container:: content
5489 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)
5490 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 ...
5491 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
5492 Started Apex service
5494 .. container:: paragraph
5496 APEX is running in the new terminal and will produce output when the
5497 policy is triggered/executed.
5499 Run the Websocket Echo Client
5500 *****************************
5502 .. container:: paragraph
5504 The echo client is included in an APEX full installation. To run
5505 the client, open a new shell (Unix, Cygwin) or command prompt
5506 (``cmd`` on Windows). Then use the APEX application launcher to
5510 APEX engine needs to run first
5511 The example assumes that an APEX engine configured for *produce* carrier technology Websocket and *JSON* event protocol is executed first.
5513 +---------------------------------------------------------+-----------------------------------------------------------+
5514 | Unix, Cygwin | Windows |
5515 +=========================================================+===========================================================+
5516 | .. container:: | .. container:: |
5518 | .. container:: listingblock | .. container:: listingblock |
5520 | .. container:: content | .. container:: content |
5522 | .. code:: | .. code:: |
5524 | # $APEX_HOME/bin/apexApps.sh ws-echo [args] | > %APEX_HOME%\bin\apexApps.bat ws-echo [args] |
5525 +---------------------------------------------------------+-----------------------------------------------------------+
5527 .. container:: paragraph
5529 Use the following command line arguments for server and port of
5530 the Websocket server. The port should be the same as configured in
5531 the APEX engine. The server host should be the host on which the
5532 APEX engine is running
5534 .. container:: ulist
5536 - ``-p`` defines the Websocket port to connect to (defaults to
5539 - ``-s`` defines the host on which a Websocket server is running
5540 (defaults to ``localhost``)
5542 .. container:: paragraph
5544 Let’s assume that there is an APEX engine running, configured for
5545 produce Websocket carrier technology, as server, for port 42452,
5546 with produce event protocol JSON,. If we start the console client
5547 on the same host, we can omit the ``-s`` options. We start the
5550 .. container:: listingblock
5552 .. container:: content
5556 # $APEX_HOME/bin/apexApps.sh ws-echo -p 42452 (1)
5557 > %APEX_HOME%\bin\apexApps.bat ws-echo -p 42452 (2)
5559 .. container:: colist arabic
5561 +-------+--------------------------------+
5562 | **1** | Start client on Unix or Cygwin |
5563 +-------+--------------------------------+
5564 | **2** | Start client on Windows |
5565 +-------+--------------------------------+
5567 .. container:: paragraph
5569 Once started successfully, the client will produce the following
5570 messages (assuming we used ``-p 42452`` and an APEX engine is
5571 running on ``localhost`` with the same port:
5573 .. container:: listingblock
5575 .. container:: content
5579 ws-simple-echo: starting simple event echo
5580 --> server: localhost
5583 Once started, the application will simply print out all received events to standard out.
5584 Each received event will be prefixed by '---' and suffixed by '===='
5587 ws-simple-echo: opened connection to APEX (Web Socket Protocol Handshake)
5589 Run the Websocket Console Client
5590 ********************************
5592 .. container:: paragraph
5594 The console client is included in an APEX full installation. To
5595 run the client, open a new shell (Unix, Cygwin) or command prompt
5596 (``cmd`` on Windows). Then use the APEX application launcher to
5600 APEX engine needs to run first
5601 The example assumes that an APEX engine configured for *consume* carrier technology Websocket and *JSON* event
5602 protocol is executed first.
5604 +------------------------------------------------------------+--------------------------------------------------------------+
5605 | Unix, Cygwin | Windows |
5606 +============================================================+==============================================================+
5607 | .. container:: | .. container:: |
5609 | .. container:: listingblock | .. container:: listingblock |
5611 | .. container:: content | .. container:: content |
5613 | .. code:: | .. code:: |
5615 | # $APEX_HOME/bin/apexApps.sh ws-console [args] | > %APEX_HOME%\bin\apexApps.bat ws-console [args] |
5616 +------------------------------------------------------------+--------------------------------------------------------------+
5618 .. container:: paragraph
5620 Use the following command line arguments for server and port of
5621 the Websocket server. The port should be the same as configured in
5622 the APEX engine. The server host should be the host on which the
5623 APEX engine is running
5625 .. container:: ulist
5627 - ``-p`` defines the Websocket port to connect to (defaults to
5630 - ``-s`` defines the host on which a Websocket server is running
5631 (defaults to ``localhost``)
5633 .. container:: paragraph
5635 Let’s assume that there is an APEX engine running, configured for
5636 consume Websocket carrier technology, as server, for port 42450,
5637 with consume event protocol JSON,. If we start the console client
5638 on the same host, we can omit the ``-s`` options. We start the
5641 .. container:: listingblock
5643 .. container:: content
5647 # $APEX_HOME/bin/apexApps.sh ws-console -p 42450 (1)
5648 > %APEX_HOME%\bin\apexApps.sh ws-console -p 42450 (2)
5650 .. container:: colist arabic
5652 +-------+--------------------------------+
5653 | **1** | Start client on Unix or Cygwin |
5654 +-------+--------------------------------+
5655 | **2** | Start client on Windows |
5656 +-------+--------------------------------+
5658 .. container:: paragraph
5660 Once started successfully, the client will produce the following
5661 messages (assuming we used ``-p 42450`` and an APEX engine is
5662 running on ``localhost`` with the same port:
5664 .. container:: listingblock
5666 .. container:: content
5670 ws-simple-console: starting simple event console
5671 --> server: localhost
5674 - terminate the application typing 'exit<enter>' or using 'CTRL+C'
5675 - events are created by a non-blank starting line and terminated by a blank line
5678 ws-simple-console: opened connection to APEX (Web Socket Protocol Handshake)
5683 .. container:: paragraph
5685 Now you have the full system up and running:
5687 .. container:: ulist
5689 - Terminal 1: APEX ready and loaded
5691 - Terminal 2: an echo client, printing received messages produced
5694 - Terminal 2: a console client, waiting for input on the console
5695 (standard in) and sending text to APEX
5697 .. container:: paragraph
5699 We started the engine with the VPN policy example. So all the
5700 events we are using now are located in files in the following
5703 .. container:: listingblock
5705 .. container:: content
5710 #: $APEX_HOME/examples/events/VPN
5711 > %APEX_HOME%\examples\events\VPN
5713 .. container:: paragraph
5715 To sends events, simply copy the content of the event files into
5716 Terminal 3 (the console client). It will read multi-line JSON text
5717 and send the events. So copy the content of ``SetupEvents.json`` into
5718 the client. APEX will trigger a policy and produce some output, the
5719 echo client will also print some events created in the policy. In
5720 Terminal 1 (APEX) you’ll see some status messages from the policy as:
5722 .. container:: listingblock
5724 .. container:: content
5729 {Link=L09, LinkUp=true}
5731 outFields: {Link=L09, LinkUp=true}
5732 {Link=L10, LinkUp=true}
5735 outFields: {Link=L10, LinkUp=true}
5736 {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5738 C 300 300 [L09, L10]
5739 outFields: {CustomerName=C, LinkList=L09 L10, SlaDT=300, YtdDT=300}
5740 {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5743 C 300 300 [L09, L10]
5744 outFields: {CustomerName=A, LinkList=L09 L10, SlaDT=300, YtdDT=50}
5745 {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5748 C 300 300 [L09, L10]
5749 D 300 400 [L09, L10]
5750 outFields: {CustomerName=D, LinkList=L09 L10, SlaDT=300, YtdDT=400}
5751 {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5754 B 300 299 [L09, L10]
5755 C 300 300 [L09, L10]
5756 D 300 400 [L09, L10]
5757 outFields: {CustomerName=B, LinkList=L09 L10, SlaDT=300, YtdDT=299}
5759 .. container:: paragraph
5761 In Terminal 2 (echo-client) you see the received events, the last two
5764 .. container:: listingblock
5766 .. container:: content
5771 ws-simple-echo: received
5772 ---------------------------------
5774 "name": "VPNCustomerCtxtActEvent",
5776 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5779 "CustomerName": "C",
5780 "LinkList": "L09 L10",
5784 =================================
5786 ws-simple-echo: received
5787 ---------------------------------
5789 "name": "VPNCustomerCtxtActEvent",
5791 "nameSpace": "org.onap.policy.apex.domains.vpn.events",
5794 "CustomerName": "D",
5795 "LinkList": "L09 L10",
5799 =================================
5801 .. container:: paragraph
5803 Congratulations, you have triggered a policy in APEX using
5804 Websockets, the policy did run through, created events, picked up by
5807 .. container:: paragraph
5809 Now you can send the Link 09 and Link 10 events, they will trigger
5810 the actual VPN policy and some calculations are made. Let’s take the
5811 Link 09 events from ``Link09Events.json``, copy them all into
5812 Terminal 3 (the console). APEX will run the policy (with some status
5813 output), and the echo client will receive and print events.
5815 .. container:: paragraph
5817 To terminate the applications, simply press ``CTRL+C`` in Terminal 1
5818 (APEX). This will also terminate the echo-client in Terminal 2. Then
5819 type ``exit<enter>`` in Terminal 3 (or ``CTRL+C``) to terminate the