Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The CPS-core notification system only sends data-update events when a root data node is created or the anchor is updated. There is no support for delete change. And, the existing supported operations are also not differentiated in the event. To define the operation type, we need to change the existing event structure and the changes on both the cps-core and cps-temporal sides to have backward compatibilitysupport the new event version

...

Decision/Issues

...



DescriptionOperationDecisionScenario
CREATE
  • The root data node is created for the first time
UPDATE
  • update action on the root 'data node'
  • create, update and delete action on the non-root data nodes
DELETE
  • Either anchor or root data node is deleted

Event

Event Structure

The event V1 schema definition is strict and it is not possible to add any optional fields without breaking the old schema contract. To have the flexibility of adding optional fields in future, we are setting the value of 'additionalProperties' to true in both 'CpsDataUpdatedEvent' and 'Content' definitions. 

Code Block
languagejs
titleFlexible schema definition
{

  "definitions": {
    "CpsDataUpdatedEvent": {
      ...
      "additionalProperties": true
    },
    "Content": {
     ...
      "additionalProperties": true
    },
    ...
  }
}

The new 'operation' field is added to the event in the content section. The field can be marked as 

  • optional: It makes the event v2 backwards compatible and the user can upgrade cps-temporal before cps-core. As it is a field that should be mandatory, it should be set as mandatory in the v3 which gives the user a release to upgrade cps-core to v2.  
  • mandatory: No compatibility with the future change. Both cps-core and cps-temporal have to be updated at the same time. 

The team decided to mark it as 

The existing 'data' section in the content can be set as null for the delete event. As we are deleting a mandatory field, the change is still backwards compatible. 

1'operation' field in the event should be mandatory or optional?'optional' because Bell is deploying cps Istanbul in production soon
2

Multiple root data nodes can have an impact on notification services

Will be evaluated as part of the spike

Jira
serverONAP Jira
columnIdsissuekey,summary,issuetype,created,updated,duedate,assignee,reporter,priority,status,resolution
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-341
 

Proposal

Operation

OperationScenario
CREATE
  • The root data node is created
UPDATE
  • update action on the root 'data node'
  • create, update and delete action on the non-root data nodes
DELETE
  • The root data node is deleted

Event

Enable Full compatibility

The event V1 schema definition is strict and it is not possible to add any optional fields without breaking the old schema contract. To have the flexibility of adding optional fields in future with full compatibility, we are setting the value of 'additionalProperties' to true in both 'CpsDataUpdatedEvent' and 'Content' definitions. 

Code Block
languagejs
titleFlexible schema definition
{

  "definitions": {
    "CpsDataUpdatedEvent": {
      ...
      "additionalProperties": true
    },
    "Content
Code Block
languagejs
titleAdded operation property in content
{
  	"definitions": {
		...
    	"Content": {
			"properties": {
				"operation": {
     ...
      			"descriptionadditionalProperties": "Thetrue
 operation supported by the "},
          			"type": "string",
          			"enum": ["CREATE", "UPDATE", "DELETE"]
        			}
				...
			}
		}
	}
}
Code Block
...
  }
}
Add Operation field

The new 'operation' field is added to the event in the content section. The field can be marked as 

  • optional: It makes the event v2 backwards compatible and the user can upgrade cps-temporal before cps-core. As it is a field that should be mandatory, it should be set as mandatory in the v3 which gives the user a release to upgrade cps-core to v2.  
  • mandatory: no compatibility with the older version and both cps-core and cps-temporal have to be updated at the same time.
Code Block
languagejs
titleAdded operation property in content
{
  	"definitions": {
		...
    	"Content": {
			"properties": {
				"operation": {
          			
languagejs
titlecps-data-updated-event-schema-v2.json
linenumberstrue
collapsetrue
{

  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "$id": "urn:cps:org.onap.cps:data-updated-event-schema:v2",

  "$ref": "#/definitions/CpsDataUpdatedEvent",

  "definitions": {

    "CpsDataUpdatedEvent": {
      "description": "The payloadoperation forsupported CPSby datathe updated event.",
          			"type": "objectstring",
      "properties": {
        "schema			"enum": ["CREATE", "UPDATE", "DELETE"]
        			}
				...
			}
		}
	}
}
Optional Data field

The existing 'data' section in the content should not be provided in the delete event and it should be marked as optional. As we are deleting a mandatory field, the change is still backwards compatible. 

Event V2 JSON Schema
Code Block
languagejs
titlecps-data-updated-event-schema-v2.json
linenumberstrue
collapsetrue
{

  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "$id": "urn:cps:org.onap.cps:data-updated-event-schema:v2",

  "$ref": "#/definitions/CpsDataUpdatedEvent",

  "definitions": {

    "CpsDataUpdatedEvent": {
{
          "description": "The schema, including its version, that this event adheres to. E.g. 'urn:cps:org.onap.cps:data-updated-event-schema:v99'.",
          "type": "string",
          "format": "uri"
        },
        "id": {
          "description": "The uniquepayload for idCPS identifyingdata theupdated event.",
 for the specified source. Producer must ensure that source + id is unique for each distinct event."type": "object",
          "typeproperties": "string"{
        },
        "source"schema": {
          "description": "The sourceschema, ofincluding the event. Producer must ensure that source + id is unique for each distinct eventits version, that this event adheres to. E.g. 'urn:cps:org.onap.cps:data-updated-event-schema:v99'.",
          "type": "string",
          "format": "uri"
        },
        "typeid": {
          "description": "The unique typeid ofidentifying the event for the specified source. Producer must ensure that source + id is unique for each distinct event.",
          "type": "string"
        },
        "contentsource": {
          "$refdescription": "#/definitions/Content"
        }
      },
      "required": [
The source of the event. Producer must ensure that source + id is unique for each distinct event.",
          "type":  "schemastring",
          "format": "iduri",
        "source"},
        "type",: {
          "contentdescription"
: "The type of the  ]event.",
          "additionalPropertiestype": true"string"
        },

        "Contentcontent": {
      "description": "The event content.",
      "type$ref": "object#/definitions/Content",
       "properties": {}
      },
      "operationrequired": {[
        "schema",
  "description": "The operation supported by the "id",
          "type": "stringsource",
          "enum": ["CREATE", "UPDATE", "DELETE"]type",
        },"content"
      ],
      "observedTimestampadditionalProperties": {true
    },

    "Content": {
      "description": "The timestamp when the data has been observed. The expected format is 'yyyy-MM-dd'T'HH:mm:ss.SSSZ'. Ex: '2020-12-01T00:00:00.000+0000'  ", event content.",
      "type": "object",
      "properties": {
          "typeoperation": "string"{
        },
  "description": "The operation supported by the "dataspaceName": {,
          "descriptiontype": "The name of CPS Core dataspace the data belongs to.string",
          "typeenum": "string"["CREATE", "UPDATE", "DELETE"]
        },
        "schemaSetNameobservedTimestamp": {
          "description": "The nametimestamp ofwhen CPS Core schema set the data adheres to.the data has been observed. The expected format is 'yyyy-MM-dd'T'HH:mm:ss.SSSZ'. Ex: '2020-12-01T00:00:00.000+0000'  ",
          "type": "string"
        },
        "anchorNamedataspaceName": {
          "description": "The name of CPS Core anchordataspace the data is attachedbelongs to.",
          "type": "string"
        },
        "dataschemaSetName": {
          "$refdescription": "#/definitions/Data"
        }
  The name of CPS Core schema set the data adheres to.",
    },
      "requiredtype": ["string"
        "observedTimestamp"},
        "dataspaceNameanchorName",: {
          "schemaSetNamedescription",
: "The name of CPS Core anchor  "anchorNamethe data is attached to.",
          "type": "datastring"
        ]},
        "additionalPropertiesdata": true{
      },

    "Data$ref": {"#/definitions/Data"
      "description": "Data as json object."  }
      },
      "typerequired": "object"[
    }

  }

}
Code Block
languagejs
titleexample: data updated event v2
linenumberstrue
collapsetrue
{
  "schemaobservedTimestamp": "urn:cps:org.onap.cps:data-updated-event-schema:v1",
  "id": "77b8f114-4562-4069-8234-6d059ff742ac",
  "source": "urn:cps:org.onap.cps",
  "type": "org.onap.cps.data-updated-event",
  "content,
        "dataspaceName",
        "schemaSetName",
        "anchorName"
      ],
      "additionalProperties": true
    },

    "Data": {
      "observedTimestampdescription": "2020-12-01T00:00:00.000+0000Data as json object.",
    "dataspaceName": "my-dataspace",
    "schemaSetNametype": "bookstore-schemasetobject",
    "anchorName": "chapters",}

  }

}


Code Block
languagejs
titleexample: data updated event v2
linenumberstrue
collapsetrue
{
  "schema": "urn:cps:org.onap.cps:data-updated-event-schema:v2  "operation": "CREATE",
    "data": {
      "test:bookstore":{
        "bookstore-name": "Chapters",
      "id": "77b8f114-4562-4069-8234-6d059ff742ac",
  "categoriessource": ["urn:cps:org.onap.cps",
          {
       "type": "org.onap.cps.data-updated-event",
  "content": {
     "codeobservedTimestamp": "012020-12-01T00:00:00.000+0000",
            "name"dataspaceName": "SciFimy-dataspace",
       "schemaSetName": "bookstore-schemaset",
     "booksanchorName": ["chapters",
    "operation": "CREATE",
    "data": {
      "test:bookstore":{
        "bookstore-name": "Chapters",
        "authorscategories": [
          {
        "Iain M. Banks"
  "code": "01",
             ]"name": "SciFi",
                "langbooks": "en",[
                "price": 895,{
                "pub_yearauthors": "1994",[
                  "title": "Feersum EndjinnIain M. Banks"
              }  ],
            ]
    "lang": "en",
                }"price": 895,
        ]
      }
    }
  }
}

CPS-Core

cps core should send the event with the 'operation' information for all the events. The scenarios are defined in the Operation section of the proposal.

In the case of the 'delete' event, the 'data' section should be empty. 

"pub_year": "1994",
                "title": "Feersum Endjinn"
              }
            ]
          }
        ]
      }
    }
  }
}

Delete Event example
Code Block
languagejs
titleDelete event
Code Block
languagejs
titleDelete event
{
  "schema": "urn:cps:org.onap.cps:data-updated-event-schema:v1v2",
  "id": "77b8f114-4562-4069-8234-6d059ff742ac",
  "source": "urn:cps:org.onap.cps",
  "type": "org.onap.cps.data-updated-event",
  "content": {
    "observedTimestamp": "2020-12-01T00:00:00.000+0000",
    "dataspaceName": "my-dataspace",
    "schemaSetName": "bookstore-schemaset",
    "anchorName": "chapters",
    "operation": "DELETE",
  }
},
    "operation": "DELETE"
  }
}


CPS-Core

There is no specific operation to delete the root node and it gets deleted when Anchor is deleted. In cps-core, a 'DELETE' notification event should be sent

  • when an anchor is deleted or
  • delete Data Node is called with root XPath.

We are adding a new operation field in the event and the values for all the existing scenarios must be provided as per the Operation section of the proposal.

In the 'DELETE' notification, the 'data' field should not be provided as defined in the event.

CPS-Temporal

It will store the new 'operation' field in the newly added column in the network_data table. if If this field is optional in the event, the default value of UPDATE will be set on the temporal side.

...

The newly added field 'operation' should have a value of 'UPDATE' for the existing fielddata in the network_data table