72bd8b9d9f602e709cc003c0f10feec23084783c
[policy/apex-pdp.git] /
1 //
2 // ============LICENSE_START=======================================================
3 //  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 // ================================================================================
5 // This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE
6 // Full license text at https://creativecommons.org/licenses/by/4.0/legalcode
7 // 
8 // SPDX-License-Identifier: CC-BY-4.0
9 // ============LICENSE_END=========================================================
10 //
11 // @author Sven van der Meer (sven.van.der.meer@ericsson.com)
12 //
13
14 == Configure AVRO Schema Handler
15
16 The AVRO schema handler is added to the configuration as follows:
17
18 [source%nowrap,json]
19 ----
20 "engineServiceParameters":{
21   "engineParameters":{
22     "contextParameters":{
23       "parameterClassName" : "org.onap.policy.apex.context.parameters.ContextParameters",
24       "schemaParameters":{
25         "Avro":{
26           "parameterClassName" : 
27             "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
28         }
29       }
30     }
31   }
32 }
33 ----
34
35 Using the AVRO schema handler has one limitation: AVRO only supports field names that represent valid Java class names.
36 This means only letters and the character `_` are supported.
37 Characters commonly used in field names, such as `.` and `-`, are not supported by AVRO.
38 for more information see link:https://avro.apache.org/docs/1.8.1/spec.html#names[Avro Spec: Names].
39
40 To work with this limitation, the APEX Avro plugin will parse a given AVRO definition and replace _all_ occurrences of `.` and `-` with a `_`.
41 This means that
42
43 - In a policy model, if the AVRO schema defined a field as `my-name` the policy logic should access it as `my_name`
44 - In a policy model, if the AVRO schema defined a field as `my.name` the policy logic should access it as `my_name`
45 - There should be no field names that convert to the same internal name
46   ** For instance the simultaneous use of `my_name`, `my.name`, and `my-name` should be avoided
47   ** If not avoided, the event processing might create unwanted side effects
48 - If field names use any other not-supported character, the AVRO plugin will reject it
49   ** Since AVRO uses lazy initialization, this rejection might only become visible at runtime