7 Champ is an abstraction from underlying graph storage systems that A&AI would otherwise interface with.
12 To build Champ run the following maven command from the project's root level pom directory:
16 Deploying The Microservice
17 --------------------------
19 Push the Docker image that you have built to your Docker repository and pull it down to the location from which you will be running the service.
21 **Create the following directories on the host machine:**
28 You will be mounting these as data volumes when you start the Docker container.
30 #### Configuring the Microservice
32 Create beans file **../dynamic/conf/champ-beans.xml**
36 <beans xmlns="http://www.springframework.org/schema/beans"
37 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
38 xmlns:util="http://www.springframework.org/schema/util"
40 http://www.springframework.org/schema/beans
41 http://www.springframework.org/schema/beans/spring-beans.xsd
42 http://www.springframework.org/schema/util
43 http://www.springframework.org/schema/util/spring-util.xsd
46 <util:constant id="DEFAULT_BATCH_SIZE" static-field="com.att.ecomp.event.client.DMaaPEventPublisher.DEFAULT_BATCH_SIZE" />
47 <util:constant id="DEFAULT_BATCH_AGE" static-field="com.att.ecomp.event.client.DMaaPEventPublisher.DEFAULT_BATCH_AGE" />
48 <util:constant id="DEFAULT_BATCH_DELAY" static-field="com.att.ecomp.event.client.DMaaPEventPublisher.DEFAULT_BATCH_DELAY" />
51 <bean id="champEventPublisher" class="com.att.ecomp.event.client.DMaaPEventPublisher" >
52 <constructor-arg name="host" value="<%= @CHAMP_EVBUS_HOSTS %>" />
53 <constructor-arg name="topic" value="<%= @CHAMP_EVENT_TOPIC %>" />
54 <constructor-arg name="username" value="<%= @CHAMP_DMAAP_API_KEY %>" />
55 <constructor-arg name="password" value="<%= @CHAMP_DMAAP_API_SECRET %>" />
56 <constructor-arg name="maxBatchSize" ref="DEFAULT_BATCH_SIZE" />
57 <constructor-arg name="maxAgeMs" ref="DEFAULT_BATCH_AGE" />
58 <constructor-arg name="delayBetweenBatchesMs" ref="DEFAULT_BATCH_DELAY" />
59 <constructor-arg name="transportType" value="HTTPAUTH" />
62 <!-- Graph Implementation Configuration-->
63 <util:map id="props" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java.lang.Object">
64 <entry key="champcore.event.stream.buffer.capacity" value="50" value-type="java.lang.Integer"/>
65 <entry key="champcore.event.stream.publisher-pool-size" value="10" value-type="java.lang.Integer"/>
66 <entry key="champcore.event.stream.publisher" value-ref="champEventPublisher"/>
68 <entry key="graph.name" value="<%= @CHAMP_GRAPH_NAME %>"/>
69 <entry key="storage.backend" value="<%= @CHAMP_STORAGE_BACKEND_DB %>"/>
70 <entry key="storage.hostname" value="<%= @CHAMP_GRAPH_HOST %>"/>
73 <entry key="storage.hbase.ext.hbase.zookeeper.property.clientPort" value="<%= @CHAMP_GRAPH_PORT %>"/>
74 <entry key="storage.hbase.ext.zookeeper.znode.parent" value="/hbase-unsecure"/>
76 <!-- Cassandra Config -->
77 <entry key="storage.port" value="<%= @CHAMP_GRAPH_PORT %>"/>
80 <!-- Janus Implementation -->
81 <bean id="graphBuilder" class="org.onap.aai.champjanus.graph.impl.JanusChampGraphImpl$Builder">
82 <constructor-arg value="<%= @CHAMP_GRAPH_NAME %>"/>
83 <constructor-arg ref="props" />
85 <bean id="graphImpl" class="org.onap.aai.champjanus.graph.impl.JanusChampGraphImpl">
86 <constructor-arg ref="graphBuilder" />
88 <bean id="champRestService" class="org.onap.champ.ChampRESTAPI" >
89 <constructor-arg ref="graphImpl" />
90 <constructor-arg name="txTimeOutInSec" value="300" />
94 Create configuration file **../appconfig/auth/champ-policy.json**
96 This policy file defines which client certificates are authorized to use the service's APIs. An example policy file follows:
104 "name": "search", "methods": [ { "name": "GET" },{ "name": "DELETE" }, { "name": "PUT" }, { "name": "POST" } ]
109 "username": "CN=admin, OU=My Organization Unit, O=, L=Sometown, ST=SomeProvince, C=CA"
116 Create keystore file **../appconfig/auth/tomcat\_keystore**
119 Create a keystore with this name containing whatever CA certificates that you want your instance of the CHAMP service to accept for HTTPS traffic.
121 #### Start the service
123 You can now start the Docker container in the following manner:
127 -e CONFIG_HOME=/opt/app/champ-service/config/ \
128 -e KEY_STORE_PASSWORD={{obfuscated password}} \
129 -e KEY_MANAGER_PASSWORD=OBF:{{obfuscated password}} \
130 -v /<path>/logs:/opt/aai/logroot/AAI-CHAMP \
131 -v /<path>/appconfig:/opt/app/champ-service/config \
132 --name champ-service \
133 {{your docker repo}}/champ-service
137 {{your docker repo}} = The Docker repository you have published your CHAMP Service image to.
138 {{obfuscated password}} = The password for your key store/key manager after running it through the Jetty obfuscation tool.
143 Champ has methods for:
149 In the future we plan on adding in partitions, indicies, schemas, and traversals, but at the moment that is outside the scope of Champ. If you have suggestions on how this should be implemented, we look forward to your pull request.
154 Champ ships with both Titan and Janus implementations. These are switchable after deployment, but the champ-beans.xml file needs to be changed and the champ-service must be restarted.
159 Champ can be configured to generate a notification whenever it is used to modify data in the graph. The notification comes in the form of an event which is posted to the **champRawEvents** Event Bus topic. This event stream allows downstream clients to be notified about objects and relationships which are added/modified/deleted in the graph.
161 The following configuration parameters define the behaviour of the event generation feature:
163 - **champ.event.stream.publisher**: _EventClientPublisher_ instance to use for forwarding events to the event stream (see below).
164 - **champ.event.stream.publisher-pool-size**: Optional: number of worker threads to use for event publishing.
165 - **champ.event.stream.buffer.capacity**: Optional: maximum number of events which may be enqueued waiting to be published at any given time.
168 The following examples illustrate snippets of typical spring-beans configuration file which instantiate a producer (if your client is not spring enabled then you may just directly instantiate an _EventBusPublisher_ - refer to the _ECOMP Event Bus Client_ library for details):
170 _Instantiating an event producer backed by a native Kafka implementation:_
172 <!-- Event publisher to pass to the Champ library for logging raw graph events. -->
173 <bean id="champEventPublisher" class="com.att.ecomp.event.client.KafkaEventPublisher" >
174 <constructor-arg name="hosts" value="1.2.3.4:9092, 5.6.7.8:9092, 9.10.11.12:9092" />
175 <constructor-arg name="topic" value="champRawEvents" />
178 _Instantiating an event producer backed by a DMaaP Client implementation:_
180 <bean id="champEventPublisher" class="com.att.ecomp.event.client.DMaaPEventPublisher" >
181 <constructor-arg name="urlList" value="1.2.3.4, 5.6.7.8, 9.10.11.12" />
182 <constructor-arg name="topic" value="champRawEvents" />
183 <constructor-arg name="apiKey" value="OBF:1r2v1qc51i0r1l6n1m4q1jew1bpt1lkp1ll11bot1jee1m7o1l6n1i0z1qax1r53" />
184 <constructor-arg name="apiSecret" value="OBF:1ro81caa1myq1mzs1nx31kfl1d2q1zsp1yt81nz31f8h1hmd1hmx1fa51nxb1yte1zt11d3g1kct1nzb1mxi1myk1cb01rqe" />
194 URL: https://<host>:9522/services/echo-service/echo/<input>
196 Success Response: 200 OK
201 #### Create a new object
202 Inserts a new object into the graph with the type and properties from the body of the request. Returns the object that was created, along with its assigned key and timestamps.
204 URL: https://<host>:9522/services/champ-service/v1/objects
219 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
224 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
225 "aai-created-ts": 1516731449014,
226 "aai-last-mod-ts": 1516731449014
230 #### Retrieve an object
231 A GET request that returns the object with the given key
233 URL: https://<host>:9522/services/champ-service/v1/objects/<key>
239 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
244 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
245 "aai-created-ts": 1516731449014,
246 "aai-last-mod-ts": 1516731449014
250 #### Updating an object
251 Replace any of the properties with a PUT request, get the updated object back. Inclusion of timestamps is optional, but the request will be rejected if they do not match the DB.
253 URL: https://<host>:9522/services/champ-service/v1/objects/<key>
257 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
262 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
264 "aai-created-ts": 1516731449014
272 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
277 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
279 "aai-created-ts": 1516731449014,
280 "aai-last-mod-ts": 1516730919213
285 Deletes the object from the graph if there are no connected relationships
287 URL: https://<host>:9522/services/champ-service/v1/objects/<key>
294 #### Filtered object search
295 Get a list of objects filtered by key/value pairs
297 URL: https://<host>:9522/services/champ-service/v1/objects/filter?<key>=<val>
302 "key": "e0d3a253-4a1b-4ca4-a862-8a52b1e3fdfb",
308 Get a list of objects filtered by key/value pairs with specific properties
310 URL: https://<host>:9522/services/champ-service/v1/objects/filter?<key>=<val>&properties=<prop1>&properties=<prop2>
315 "key": "e0d3a253-4a1b-4ca4-a862-8a52b1e3fdfb",
319 "filter-sample": "yes"
324 Get a list of objects filtered by key/value pairs with all properties
326 URL: https://<host>:9522/services/champ-service/v1/objects/filter?<key>=<val>&properties=all
331 "key": "e0d3a253-4a1b-4ca4-a862-8a52b1e3fdfb",
335 "aai-uuid": "e0d3a253-4a1b-4ca4-a862-8a52b1e3fdfb",
336 "filter-sample": "yes"
342 Relationships are used to create a connection between two pre-existing objects.
344 #### Create a new relationship
345 Creates a new relationship with the specified properties. "source" and "target" must be objects that have already been created, specified by their keys. Returns the created relationship with its key and timestamps.
347 URL: https://<host>:9522/services/champ-service/v1/relationships
351 "type": "testOnTest2",
357 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
362 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
367 "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
372 "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
382 "key": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1",
383 "type": "testOnTest2",
387 "aai-uuid": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1"
388 "aai-last-mod-ts": 1516730919213,
389 "aai-created-ts": 1516730919213
392 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
397 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
402 "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
407 "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
413 #### Retrieving relationships
414 Returns the relationship, looked up by key.
416 URL: https://<host>:9522/services/champ-service/v1/relationships/<key>
422 "key": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1",
423 "type": "testOnTest2",
427 "aai-uuid": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1"
428 "aai-last-mod-ts": 1516730919213,
429 "aai-created-ts": 1516730919213
432 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
437 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
442 "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
447 "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
453 #### Get relationships for an object
454 Given an object, returns all connected relationships.
456 URL: https://<host>:9522/services/champ-service/v1/objects/relationships/<object-id>
463 "key": "4ba8dcc2-806d-4312-aecb-503435f355e5",
464 "type": "testOnTest2",
468 "aai-uuid": "4ba8dcc2-806d-4312-aecb-503435f355e5"
471 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
476 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
481 "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
486 "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
492 "key": "a3096bb8-dc66-4a9c-ab33-a1183f784fbb",
493 "type": "testOnTest2",
497 "aai-uuid": "a3096bb8-dc66-4a9c-ab33-a1183f784fbb"
500 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
505 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
510 "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
515 "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
522 #### Updating relationships
523 Update the relationship properties. Passing timestamps is optional, but the request will be rejected if they are incorrect.
525 URL: https://<host>:9522/services/champ-service/v1/relationships/<key>
529 "key": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1",
530 "type": "testOnTest2",
534 "aai-uuid": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1"
537 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
542 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
547 "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
552 "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
562 "key": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1",
563 "type": "testOnTest2",
567 "aai-uuid": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1",
568 "aai-last-mod-ts": 1516734987294,
569 "aai-created-ts": 1516730919213
572 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
577 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
582 "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
587 "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
593 #### Deleting relationships
594 Deletes the relationship specified by key.
596 URL: https://<host>:9522/services/champ-service/v1/relationships/<key>
600 #### Filtered Relationship
601 Returns a list of relationships that have key/value properties matching the filter
603 URL: https://<host>:9522/services/champ-service/v1/objects/filter?<key>=<val>
608 "key": "a4d51cd9-f271-4201-975d-168ec6bde501",
609 "type": "testOnTest2",
613 "aai-uuid": "a4d51cd9-f271-4201-975d-168ec6bde501"
616 "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
621 "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
626 "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
631 "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
639 Transactions allow multiple graph operations to be grouped into a logical, sandboxed context, so that the option exists to either persist ALL of the grouped changes together, or NONE of them.
641 Explicit use of transactions is entirely optional for the client. Calling the API methods described below without supplying a transaction
642 object results in a transaction being implicitly opened for the single operation, and then automatically committed.
644 However, all of the API calls described above related to persisting, retrieving, and deleting vertices, edges and graph partitions also
645 expose a version of the call which optionally accepts a transaction id (acquired by explicitly calling the /transaction API endpoint).
646 In this case, the supplied transaction is used for the operation, and no automatic commit occurs. It is the responsibility of
647 the client to explicitly commit or rollback the transaction at his or her discretion.
649 #### Open a new transaction
650 To use explicit transaction the client must request a transaction id from the Champ service by making a request to open a new transaction.
652 URL: https://<host>:9522/services/champ-service/v1/transaction/
656 Content: 5d90f5ae-1f1e-4c3e-b20b-2f7c45f822eb
658 #### Working within a transaction
659 Operations can be done within a transaction by putting the transactionId in the query string.
661 Query string: transactionId=<id>
663 Example object creation:
665 URL: https://<host>:9522/services/champ-service/v1/objects?transactionId=5d90f5ae-1f1e-4c3e-b20b-2f7c45f822eb
667 Example relationship update:
669 URL: https://<host>:9522/services/champ-service/v1/relationships/<key>?transactionId=5d90f5ae-1f1e-4c3e-b20b-2f7c45f822eb
671 #### Checking a transaction
672 If you wish to check the status of a transaction, you can do a get on it
674 URL: https://<host>:9522/services/champ-service/v1/transaction/<transaction-id>
676 If the transaction is currently open:
680 Content: "fa0890d9-6ac4-40aa-9838-745a25a61fa6 is OPEN"
681 If the transaction is not open:
688 #### Committing a transaction
689 Operations performed within the context of a transaction are not visible outside of that context
690 until the client explicitly commits the transaction. Up until that point, there is always the
691 option to just roll back the changes.
693 URL: https://<host>:9522/services/champ-service/v1/transaction/<transaction-id>
695 Content: {"method":"commit"}
701 ### Rolling back a transaction.
702 In the event that a sequence of graph operations which were performed within the same transactional context need to be aborted (for example one of the operations in the sequence encountered a failure of some kind) the entire transaction can be aborted by rolling back the transaction. This effectively undoes all of the operations which were performed within the open transaction.
704 Note, once a transaction has been committed, it is no longer possible to rollback the contents of the transaction.
706 URL: https://<host>:9522/services/champ-service/v1/transaction/<transaction-id>
708 Content: {"method":"rollback"}