blob: 2b26442a8df820fed0ea1b1c9f652441a60a669a [file] [log] [blame]
Ralph Knag1fca6ac2017-12-05 12:05:57 -05001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3
4.. _cdap-specification:
5
6Component specification (CDAP)
7==============================
8
9The CDAP component specification contains the following groups of
10information. Many of these are common to both CDAP and Docker components
11and are therefore described in the common specification.
12
13- :any:`Metadata <metadata>`
14- :any:`Interfaces <interfaces>` including the
15 associated :any:`Data Formats <data-formats>`
16- :any:`Parameters <parameters>` - for specifying parameters in your
17 AppConfig, AppPreferences, and ProgramPreferences to the Designer and
18 Policy. This of course is CDAP-specific and is described below.
19- :any:`Auxiliary Details <auxiliary-details>`
20- :any:`List of artifacts <artifacts>`
21
22Current Limitations and TODOs
23-----------------------------
24
25- The integration of DMD is likely to significantly change the
Ralph Knagd2cd31b2018-04-02 16:27:46 -040026 :any:`Interfaces <interfaces>` section in this specification.
Ralph Knag1fca6ac2017-12-05 12:05:57 -050027
28.. _parameters:
29
30Parameters
31----------
32
33There is a ``parameters`` section in your component specification. This
34section contains three optional keys: `app_config <#appconfig>`__,
35`app_preferences <#apppreferences>`__, and
Ralph Knagd2cd31b2018-04-02 16:27:46 -040036`program_preferences <#programpreferences>`__:
Ralph Knag1fca6ac2017-12-05 12:05:57 -050037
38::
39
40 "parameters" : {
41 "app_config" : [ ...],
42 "app_preferences" : [ ...],
43 "program_preferences" : [...]
44 // any additional keys are ignored
45 }
46
47- Each section details the parameters that are a part of each of these
48 CDAP constructs (see below).
49- All such parameters will be exposed to the designer and to policy for
50 override.
51- These parameters should have default values specified by the
52 component developer where necessary, i.e., parameters that *must*
53 come from the designer/policy should not have defaults.
54- All of these keys are optional because not every CDAP application
55 uses preferences and not every application uses the AppConfig.
56 However, you should specify at least one, or else your application
57 will have no parameters exposed to policy or to the DCAE designer,
58 which means it would be non-configurable.
59- Despite the AppConfig being optional to *specify* in the case that
60 you have no parameters in your AppConfig, it is *required for
61 processing* in your application. That is because the DCAE platform
62 will place important information into your AppConfig as discussed
63 below.
64
65Parameter
66~~~~~~~~~
67
68The following CDAP specific definitions use ``param1`` to refer to the
69common parameter layout in
70:any:`Parameter <parameters>`
71
72AppConfig
73~~~~~~~~~
74
75The ``app_config`` key refers to the `CDAP AppConfig <http://docs.cask.co/cdap/current/en/reference-manual/http-restful-api/configuration.html>`_.
76It is expected to be a JSON:
77
78::
79
80 "app_config" : [ // list of JSON
81 param1, // common parameter layout
82 ...
83 ]
84
85Unfortunately, at the time of writing, the AppConfig is a Java map of
86``string:string``, which means you cannot have more complex structures
87(than string) as any value in your AppConfig. However, there is a way to
88bypass this constraint: you can pass a JSON by encoding the JSON as a
89string. E.g., the ``json.dumps()`` and its converse ``loads`` methods
90in Python:
91
92::
93
94 >>> import json
95 >>> json.dumps({"foo" : "bar"}) # This is a real JSON
96 '{"foo": "bar"}' # It is now a string: pass this in as your parameter value
97 >>> json.loads('{"foo": "bar"}') # Do the equivelent of this in your application
98 {u'foo': u'bar'} # ...and you'll get back a real JSON
99 >>>
100
101The final AppConfig (after the designer and policy override parameter
102values) is passed into CDAPs AppConfig API when starting the
103application.
104
105
106AppPreferences
107~~~~~~~~~~~~~~
108
109In addition to the CDAP AppConfig, the platform supports `Application Preferences <http://docs.cask.co/cdap/current/en/reference-manual/http-restful-api/preferences.html#set-preferences>`_.
110The format of the ``app_preferences`` value is the same as the above:
111
112::
113
114 "app_preferences" : [ // list of JSON
115 param1, // common parameter layout
116 ...
117 ]
118
119The final Application Preferences JSON (after the designer and policy
120override parameter values) is passed into CDAPs Preferences API when
121starting your application.
122
123
124ProgramPreferences
125~~~~~~~~~~~~~~~~~~
126
127Preferences can also be specified `per program <http://docs.cask.co/cdap/current/en/reference-manual/http-restful-api/lifecycle.html#program-lifecycle>`_
128in CDAP. This keys value is a list of JSON with the following format:
129
130::
131
132 "program_preferences" : [ // note: this is a list of JSON
133 {
134 "program_id" : "program name 1", // the name of this CDAP program
135 "program_type" : "e.g., flows", // "must be one of flows, mapreduce, schedules, spark, workflows, workers, or services",
136 "program_pref" : [ // list of JSON
137 param1, // common parameter layout
138 ...
139 ]
140 },
141 // repeat for each program that receives a program_preferences JSON
142 ]
143
144Each ``program_pref`` JSON is passed into the CDAP API as the preference
145for ``program_id``.
146
147NOTE: for CDAP, this section is very likely to change when DMD is
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400148available. The *future* vision is
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500149that you would publish your data as a series of files on HDFS, and DMD
150will pick them up and send them to the appropriate DMaaP feeds or
151directly when needed.
152
153.. _auxiliary-details:
154
155Auxiliary Details
156-----------------
157
158*auxiliary* contains details about CDAP specific parameters.
159
160+----------------------+----------------------+----------------------+
161| Property Name | Type | Description |
162+======================+======================+======================+
163| streamname | string | *Required*. |
164+----------------------+----------------------+----------------------+
165| artifact_name | string | |
166+----------------------+----------------------+----------------------+
167| artifact_version | string | the version of your |
168| | | CDAP JAR artifact |
169+----------------------+----------------------+----------------------+
170| namespace | string | the CDAP namespace |
171| | | to deploy into, |
172| | | default is default |
173+----------------------+----------------------+----------------------+
174| programs | array | contains each CDAP |
175| | | entity represented |
176| | | in the artifact |
177+----------------------+----------------------+----------------------+
178| program_type | string | CDAP entity (eg |
179| | | flows”) |
180+----------------------+----------------------+----------------------+
181| program_id | string | name of CDAP entity |
182| | | (eg WhoFlow”) |
183+----------------------+----------------------+----------------------+
184
185Example:
186
187.. code:: json
188
189 "auxiliary": {
190 "streamname" : "who",
191 "artifact_name" : "HelloWorld",
192 "artifact_version" : "3.4.3",
193 "namespace" : "hw",
194 "programs" : [
195 {"program_type" : "flows", "program_id" : "WhoFlow"},
196 {"program_type" : "services", "program_id" : "Greeting"},
197 ...
198 ],
199 }
200
201The ``programs`` key is identical to the ``program_preferences`` key
202discussed `above <#programpreferences>`__ except:
203
204- each JSON in the list does not contain ``program_pref``
205- this is required! You must include all of your programs in this, as
206 it is used to start each program as well as for DCAE to perform
207 periodic healthchecks on your application. Dont forget about your
208 services; they are programs too.