Add Spike documentation
[aai/spike.git] / README.md
1 # Spike  Microservice
2
3 The Spike microservice consumes and processes the Champ graph data event stream from which it generates events to be consumed by other components.
4  
5 ## Public Interfaces
6
7 ### Stream output
8
9 Spike receives events from the Champ microservice regarding changes to the graph database. Spike will buffer these events in an attempt to ensure proper chronological ordering, and then output them onto a configurable kafka or DMaaP queue.
10
11 The messages are in a similar format to Gizmo's async pipeline. Here are some examples:
12
13 #### Vertex
14 ##### Create Vertex
15
16    {  
17       "header":{  
18          "event-type":"update-notification",
19          "request-id":"8f9931a2-8002-4cb4-917b-a8c984932021",
20          "source-name":"SPIKE",
21          "timestamp":"20180807T153514Z"
22       },
23       "body":{  
24          "transaction-id":"8f9931a2-8002-4cb4-917b-a8c984932021",
25          "vertex":{  
26             "schema-version":"V14",
27             "type":"vserver",
28             "key":"541cf447-09f5-4484-a765-845e71aab1f2",
29             "properties":{  
30                "aai-last-mod-ts":1533656090789,
31                "in-maint":false,
32                "aai-uuid":"541cf447-09f5-4484-a765-845e71aab1f2",
33                "vserver-name":"test-vserver",
34                "aai-created-ts":1533656090789,
35                "vserver-id":"VSER1",
36                "last-mod-source-of-truth":"Gizmo-Creator",
37                "vserver-name2":"alt-test-vserver",
38                "source-of-truth":"Gizmo-Creator",
39                "vserver-selflink":"http://1.2.3.4/moreInfo",
40                "is-closed-loop-disabled":false,
41                "aai-node-type":"vserver"
42             }
43          },
44          "operation":"CREATE",
45          "timestamp":1533656091474
46       }
47    }
48     
49 ##### Update Vertex
50
51    {  
52       "header":{  
53          "event-type":"update-notification",
54          "request-id":"8f9931a2-8002-4cb4-917b-a8c984932021",
55          "source-name":"SPIKE",
56          "timestamp":"20180807T153514Z"
57       },
58       "body":{  
59          "transaction-id":"8f9931a2-8002-4cb4-917b-a8c984932021",
60          "vertex":{  
61             "schema-version":"V14",
62             "type":"vserver",
63             "key":"541cf447-09f5-4484-a765-845e71aab1f2",
64             "properties":{  
65                "aai-last-mod-ts":1533656090789,
66                "in-maint":false,
67                "aai-uuid":"541cf447-09f5-4484-a765-845e71aab1f2",
68                "vserver-name":"test-vserver",
69                "aai-created-ts":1533656090789,
70                "vserver-id":"VSER1",
71                "last-mod-source-of-truth":"Gizmo-Creator",
72                "vserver-name2":"alt-test-vserver",
73                "source-of-truth":"Gizmo-Creator",
74                "vserver-selflink":"http://1.2.3.4/moreInfo",
75                "is-closed-loop-disabled":false,
76                "aai-node-type":"vserver"
77             }
78          },
79          "operation":"UPDATE",
80          "timestamp":1533656091474
81       }
82    }
83     
84 ##### Delete Vertex
85
86    {  
87       "header":{  
88          "event-type":"update-notification",
89          "request-id":"8f9931a2-8002-4cb4-917b-a8c984932021",
90          "source-name":"SPIKE",
91          "timestamp":"20180807T153514Z"
92       },
93       "body":{  
94          "transaction-id":"8f9931a2-8002-4cb4-917b-a8c984932021",
95          "vertex":{  
96             "schema-version":"V14",
97             "type":"vserver",
98             "key":"541cf447-09f5-4484-a765-845e71aab1f2",
99             "properties":{  
100                "aai-last-mod-ts":1533656090789,
101                "in-maint":false,
102                "aai-uuid":"541cf447-09f5-4484-a765-845e71aab1f2",
103                "vserver-name":"test-vserver",
104                "aai-created-ts":1533656090789,
105                "vserver-id":"VSER1",
106                "last-mod-source-of-truth":"Gizmo-Creator",
107                "vserver-name2":"alt-test-vserver",
108                "source-of-truth":"Gizmo-Creator",
109                "vserver-selflink":"http://1.2.3.4/moreInfo",
110                "is-closed-loop-disabled":false,
111                "aai-node-type":"vserver"
112             }
113          },
114          "operation":"DELETE",
115          "timestamp":1533656091474
116       }
117    }
118     
119 #### Relationship
120 ##### Create Relationship
121
122    {  
123       "header":{  
124          "event-type":"update-notification",
125          "request-id":"1f2eced7-8300-4e72-966d-f345027c987a",
126          "source-name":"SPIKE",
127          "timestamp":"20180807T153514Z"
128       },
129       "body":{  
130          "transaction-id":"1f2eced7-8300-4e72-966d-f345027c987a",
131          "relationship":{  
132             "source":{  
133                "type":"vserver",
134                "key":"ed76551f-f47f-47f9-a23d-052634446e76"
135             },
136             "schema-version":"v14",
137             "type":"tosca.relationships.HostedOn",
138             "key":"cd5b98fd-9028-4211-af02-0bc839f9a47b",
139             "properties":{  
140                "prevent-delete":"IN",
141                "SVC-INFRA":"OUT",
142                "delete-other-v":"NONE",
143                "contains-other-v":"NONE"
144             },
145             "target":{  
146                "type":"pserver",
147                "key":"981c0494-c742-4d75-851c-8194bbbd8a96"
148             }
149          },
150          "operation":"CREATE",
151          "timestamp":1533656086207
152       }
153    }
154     
155 ##### Update Relationship
156
157    {  
158       "header":{  
159          "event-type":"update-notification",
160          "request-id":"1f2eced7-8300-4e72-966d-f345027c987a",
161          "source-name":"SPIKE",
162          "timestamp":"20180807T153514Z"
163       },
164       "body":{  
165          "transaction-id":"1f2eced7-8300-4e72-966d-f345027c987a",
166          "relationship":{  
167             "source":{  
168                "type":"vserver",
169                "key":"ed76551f-f47f-47f9-a23d-052634446e76"
170             },
171             "schema-version":"v14",
172             "type":"tosca.relationships.HostedOn",
173             "key":"cd5b98fd-9028-4211-af02-0bc839f9a47b",
174             "properties":{  
175                "prevent-delete":"IN",
176                "SVC-INFRA":"OUT",
177                "delete-other-v":"NONE",
178                "contains-other-v":"NONE"
179             },
180             "target":{  
181                "type":"pserver",
182                "key":"981c0494-c742-4d75-851c-8194bbbd8a96"
183             }
184          },
185          "operation":"UPDATE",
186          "timestamp":1533656086207
187       }
188    }
189     
190 ##### Delete Relationship
191
192    {  
193       "header":{  
194          "event-type":"update-notification",
195          "request-id":"1f2eced7-8300-4e72-966d-f345027c987a",
196          "source-name":"SPIKE",
197          "timestamp":"20180807T153514Z"
198       },
199       "body":{  
200          "transaction-id":"1f2eced7-8300-4e72-966d-f345027c987a",
201          "relationship":{  
202             "source":{  
203                "type":"vserver",
204                "key":"ed76551f-f47f-47f9-a23d-052634446e76"
205             },
206             "schema-version":"v14",
207             "type":"tosca.relationships.HostedOn",
208             "key":"cd5b98fd-9028-4211-af02-0bc839f9a47b",
209             "properties":{  
210                "prevent-delete":"IN",
211                "SVC-INFRA":"OUT",
212                "delete-other-v":"NONE",
213                "contains-other-v":"NONE"
214             },
215             "target":{  
216                "type":"pserver",
217                "key":"981c0494-c742-4d75-851c-8194bbbd8a96"
218             }
219          },
220          "operation":"DELETE",
221          "timestamp":1533656086207
222       }
223    }
224     
225 #### Transactions
226
227 Champ, and therefore Spike, will publish separate events for each operation done within a transaction. Operations from the same transaction can be identified via the database-transaction-id field.
228
229 ##### Transaction example
230
231 The following three events were created in a single bulk request from Gizmo. Note the database-transaction-id.
232
233 [  
234    {  
235       "header":{  
236          "event-type":"update-notification",
237          "request-id":"9fc953af-bb41-4cfe-b522-dc6a9d1b5830",
238          "source-name":"SPIKE",
239          "timestamp":"20180807T162714Z"
240       },
241       "body":{  
242          "transaction-id":"9fc953af-bb41-4cfe-b522-dc6a9d1b5830",
243          "vertex":{  
244             "schema-version":"V14",
245             "type":"vserver",
246             "key":"9c649f2b-7500-4b35-abb8-d51008fb28fe",
247             "properties":{  
248                "aai-last-mod-ts":1533659209321,
249                "in-maint":false,
250                "aai-uuid":"9c649f2b-7500-4b35-abb8-d51008fb28fe",
251                "vserver-name":"test-vserver",
252                "aai-created-ts":1533659209321,
253                "vserver-id":"VSER1",
254                "last-mod-source-of-truth":"test1",
255                "vserver-name2":"alt-test-vserver",
256                "source-of-truth":"test1",
257                "vserver-selflink":"http://1.2.3.4/moreInfo",
258                "is-closed-loop-disabled":false
259             }
260          },
261          "database-transaction-id":"d8607c70-e5d6-44d4-bc6e-d8f7af419378",
262          "operation":"CREATE",
263          "timestamp":1533659209324
264       }
265    },
266    {  
267       "header":{  
268          "event-type":"update-notification",
269          "request-id":"6f7db331-a0b9-4194-917c-7f24124b5d46",
270          "source-name":"SPIKE",
271          "timestamp":"20180807T162714Z"
272       },
273       "body":{  
274          "transaction-id":"6f7db331-a0b9-4194-917c-7f24124b5d46",
275          "vertex":{  
276             "schema-version":"V14",
277             "type":"pserver",
278             "key":"ecec281a-c0c0-47af-8ec8-019753edc28c",
279             "properties":{  
280                "ptnii-equip-name":"e-name",
281                "aai-last-mod-ts":1533659209637,
282                "equip-type":"server",
283                "equip-vendor":"HP",
284                "fqdn":"myhost.onap.net",
285                "purpose":"my-purpose",
286                "aai-created-ts":1533659209637,
287                "ipv4-oam-address":"1.2.3.4",
288                "source-of-truth":"test1",
289                "hostname":"steve-host2",
290                "equip-model":"DL380p-nd",
291                "in-maint":false,
292                "aai-uuid":"ecec281a-c0c0-47af-8ec8-019753edc28c",
293                "last-mod-source-of-truth":"test1"
294             }
295          },
296          "database-transaction-id":"d8607c70-e5d6-44d4-bc6e-d8f7af419378",
297          "operation":"CREATE",
298          "timestamp":1533659209645
299       }
300    },
301    {  
302       "header":{  
303          "event-type":"update-notification",
304          "request-id":"54f0f573-eb22-4ce2-b51b-4af0904c9782",
305          "source-name":"SPIKE",
306          "timestamp":"20180807T162714Z"
307       },
308       "body":{  
309          "transaction-id":"54f0f573-eb22-4ce2-b51b-4af0904c9782",
310          "database-transaction-id":"d8607c70-e5d6-44d4-bc6e-d8f7af419378",
311          "relationship":{  
312             "source":{  
313                "type":"vserver",
314                "key":"9c649f2b-7500-4b35-abb8-d51008fb28fe"
315             },
316             "schema-version":"v14",
317             "type":"tosca.relationships.HostedOn",
318             "key":"410cb65a-1b46-4d23-a5b4-9f57bdc918c1",
319             "properties":{  
320                "prevent-delete":"IN",
321                "SVC-INFRA":"OUT",
322                "delete-other-v":"NONE",
323                "contains-other-v":"NONE"
324             },
325             "target":{  
326                "type":"pserver",
327                "key":"ecec281a-c0c0-47af-8ec8-019753edc28c"
328             }
329          },
330          "operation":"CREATE",
331          "timestamp":1533659210721
332       }
333    }
334 ]
335
336 ### Echo Service
337 The Spike micro service supports the standard echo service to allow it to be 'pinged' to verify that the service is up and responding.
338
339 The echo service is reachable via the following REST end point:
340
341     https://<host>:9518/services/spike/v1/echo-service/echo