Migrate Spike code to ONAP
[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 ---
6
7 ## Public Interfaces
8
9 ### Stream output
10
11 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.
12
13 The messages are in a similar format to Gizmo's async pipeline. Here are some examples:
14
15 #### Vertex
16 ##### Create Vertex
17
18     {
19       "transaction-id": "38fe6bb0-6b3b-4c1d-95ea-7a9f5a29d857",
20       "vertex": {
21         "schema-version": "v11",
22         "type": "vserver",
23         "key": "a7cbd3fb-a7ee-4fec-91fb-d94793b4c641",
24         "properties": {
25           "in-maint": false,
26           "vserver-name": "dan",
27           "vserver-id": "dan-vserv",
28           "last-mod-source-of-truth": "Dan-laptop",
29           "source-of-truth": "Dan-laptop",
30           "vserver-selflink": "something",
31           "is-closed-loop-disabled": false
32         }
33       },
34       "operation": "CREATE",
35       "timestamp": 1515524454947
36     }
37     
38 ##### Update Vertex
39
40     {
41       "transaction-id": "cf0ef29b-3f38-42d9-8e65-2e03a8c97aae",
42       "vertex": {
43         "schema-version": "v11",
44         "type": "vserver",
45         "key": "a7cbd3fb-a7ee-4fec-91fb-d94793b4c641",
46         "properties": {
47           "in-maint": false,
48           "vserver-name": "dan-updated",
49           "vserver-id": "dan-vserv",
50           "last-mod-source-of-truth": "Dan-laptop",
51           "vserver-selflink": "something",
52           "is-closed-loop-disabled": false
53         }
54       },
55       "operation": "UPDATE",
56       "timestamp": 1515525164176
57     }
58     
59 ##### Delete Vertex
60
61     {
62       "transaction-id": "3962b400-f5b2-4159-a0eb-cb7aa4e48580",
63       "vertex": {
64         "schema-version": "v11",
65         "type": "vserver",
66         "key": "a7cbd3fb-a7ee-4fec-91fb-d94793b4c641",
67         "properties": {
68           "in-maint": false,
69           "vserver-name": "dan-updated",
70           "vserver-id": "dan-vserv",
71           "last-mod-source-of-truth": "Dan-laptop",
72           "vserver-selflink": "something",
73           "is-closed-loop-disabled": false
74         }
75       },
76       "operation": "DELETE",
77       "timestamp": 1515525766057
78     }
79     
80 #### Relationship
81 ##### Create Relationship
82
83     {
84       "transaction-id": "e654eee5-d8fc-445e-b09d-7dba20029a78",
85       "relationship": {
86         "source": {
87           "type": "vserver",
88           "key": "2223dc8b-9e26-4c90-b767-7d1f61e8fa8d"
89         },
90         "schema-version": "v12",
91         "type": "tosca.relationships.HostedOn",
92         "key": "6a443848-21bb-4801-ab00-53ee286c290d",
93         "properties": {
94           "prevent-delete": "java.lang.String",
95           "SVC-INFRA": "java.lang.String",
96           "delete-other-v": "java.lang.String",
97           "contains-other-v": "java.lang.String"
98         },
99         "target": {
100           "type": "pserver",
101           "key": "32ed5257-a6ac-4d63-8635-ae1d3a615960"
102         }
103       },
104       "operation": "CREATE",
105       "timestamp": 1515526740371
106     }
107     
108 ##### Update Relationship
109
110     {
111       "transaction-id": "db8d1626-346d-4f04-8856-f5a5e0e54313",
112       "relationship": {
113         "source": {
114           "type": "vserver",
115           "key": "2223dc8b-9e26-4c90-b767-7d1f61e8fa8d"
116         },
117         "schema-version": "v12",
118         "type": "tosca.relationships.HostedOn",
119         "key": "6a443848-21bb-4801-ab00-53ee286c290d",
120         "properties": {
121           "prevent-delete": "java.lang.String",
122           "SVC-INFRA": "java.lang.String",
123           "delete-other-v": "updated",
124           "contains-other-v": "java.lang.String"
125         },
126         "target": {
127           "type": "pserver",
128           "key": "32ed5257-a6ac-4d63-8635-ae1d3a615960"
129         }
130       },
131       "operation": "UPDATE",
132       "timestamp": 1515526920973
133     }
134     
135 ##### Delete Relationship
136
137     {
138       "transaction-id": "e7dbd137-cc07-41c4-8ba4-694334f4b2e4",
139       "relationship": {
140         "source": {
141           "type": "vserver",
142           "key": "2223dc8b-9e26-4c90-b767-7d1f61e8fa8d"
143         },
144         "schema-version": "v12",
145         "type": "tosca.relationships.HostedOn",
146         "key": "6a443848-21bb-4801-ab00-53ee286c290d",
147         "properties": {
148           "prevent-delete": "java.lang.String",
149           "SVC-INFRA": "java.lang.String",
150           "delete-other-v": "updated",
151           "contains-other-v": "java.lang.String"
152         },
153         "target": {
154           "type": "pserver",
155           "key": "32ed5257-a6ac-4d63-8635-ae1d3a615960"
156         }
157       },
158       "operation": "DELETE",
159       "timestamp": 1515527840630
160     }
161     
162 #### Transactions
163
164 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.
165
166 ##### Transaction example
167
168 The following three events were created in a single bulk request from Gizmo. Note the database-transaction-id.
169
170     {
171       "transaction-id": "7397ce4c-70ed-4b32-b8d0-24b6496e1791",
172       "vertex": {
173         "schema-version": "v11",
174         "type": "vserver",
175         "key": "b7c80b13-3b32-4007-83c6-553617d64cfa",
176         "properties": {
177           "in-maint": false,
178           "vserver-name": "dan-vserver-1",
179           "prov-status": "Provisioned",
180           "vserver-id": "Vserver-AMT-002-HSGW",
181           "last-mod-source-of-truth": "Dan-laptop",
182           "vserver-name2": "Vs2-HSGW-OTT",
183           "source-of-truth": "Dan-laptop",
184           "vserver-selflink": "AMT VserverLink",
185           "is-closed-loop-disabled": false
186         }
187       },
188       "database-transaction-id": "52eb5657-0d43-4e4b-a4d5-042acc9bc574",
189       "operation": "CREATE",
190       "timestamp": 1515528272536
191     }
192     
193     {
194       "transaction-id": "ec3d0552-e20b-4fc1-aa8e-634ddd2a9d76",
195       "vertex": {
196         "schema-version": "v11",
197         "type": "pserver",
198         "key": "ae43af1c-8479-4358-9325-416d3a854d69",
199         "properties": {
200           "ptnii-equip-name": "amdocs199snd9",
201           "hostname": "dan-bulk-1",
202           "equip-type": "server",
203           "equip-vendor": "HP",
204           "equip-model": "DL380p-nd",
205           "in-maint": false,
206           "fqdn": "amdocs199snd9.amdocs.lab.com",
207           "purpose": "",
208           "resource-version": "1477013499",
209           "ipv4-oam-address": "135.182.138.60",
210           "last-mod-source-of-truth": "Dan-laptop",
211           "source-of-truth": "Dan-laptop"
212         }
213       },
214       "database-transaction-id": "52eb5657-0d43-4e4b-a4d5-042acc9bc574",
215       "operation": "CREATE",
216       "timestamp": 1515528272841
217     }
218     
219     {
220       "transaction-id": "81b6a5bc-bf82-4043-92a7-f3bafe647f8e",
221       "database-transaction-id": "52eb5657-0d43-4e4b-a4d5-042acc9bc574",
222       "relationship": {
223         "source": {
224           "type": "vserver",
225           "key": "b7c80b13-3b32-4007-83c6-553617d64cfa"
226         },
227         "schema-version": "v12",
228         "type": "tosca.relationships.HostedOn",
229         "key": "592d93d5-a17d-4dfd-83f2-68b777da0481",
230         "properties": {
231           "prevent-delete": "asdf",
232           "SVC-INFRA": "fdsa",
233           "delete-other-v": "asdf",
234           "contains-other-v": "fdsa"
235         },
236         "target": {
237           "type": "pserver",
238           "key": "ae43af1c-8479-4358-9325-416d3a854d69"
239         }
240       },
241       "operation": "CREATE",
242       "timestamp": 1515528273738
243     }
244
245 ### Echo Service
246 The Spike micro service supports the standard echo service to allow it to be 'pinged' to verify that the service is up and responding.
247
248 The echo service is reachable via the following REST end point:
249
250     https://<host>:9518/services/spike/v1/echo-service/echo