Versions Compared

Key

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

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

...

Table of Contents

Assumptions

  • Temporal database stores full information in the payload ( CPS-192: Design data store for Temporal Service). 
  • It is a possibility that data stored for the different timestamps is the same, especially if the payload is used to filter data.

Query APIs 

Filtering Data

Overview

CPS temporal data query allows the user to fetch data based on multiple filtering criteria. This data can be used by an analytical system to take decisions.

Filtering Criteria

As it is time-series data, it In CPS temporal, the data can be filtered based on three main criteria:

Datetime
  • Data in last X hours
  • Data after a particular Data after specified DateTime ( epoch time in nanoseconds )
  • Data before a particular DateTime ( epoch time in nanoseconds )
  • Data at a particular time
  • To be supported in Istanbul Release)
  • Data before specified DateTime 
  • Last X recordsLast X network data
DataTypes in CPS Core
  • Dataspace & schema-

    set

    set (To be supported in Istanbul Release)

  • Dataspace & anchoranchor (To be supported in Istanbul Release)
  • Dataspace & multiple anchors - To improve performance, if there is a need to fetch data for multiple anchors.
  • Dataspace
  • Payload
Payload (To be partially supported in Istanbul Release)
  • Based on a

    subsection or

    field in the payload. These criteria

    do

    need schema-set to be fixed to search in the same set of anchors

    . The details of the format are defined here

We will implement only Adding payload filtering with DateTime criteria can make the query APIs complicated. Hence, we will implement the basic APIs first and will add complex ones when required.

...

 

Other Parameters 

There are other parameters, listed below, that can have an impact on the response. 

NoNameTypeDefaultPurposeExample
1pageNumberint0

The query output can have many rows so it is important to limit the fetched data. To limit

...

  • index 
  • maxSize

the number of records and to provide pagination, these two parameters can be used. 

pageNumber starts from "0"

pageLimit can't be greater than the maximum value configured  in the application 


2pageLimitint1000
3pointInTimeTimestamp (ISO Format)CurrentDateTime

When a user uses the APIs with pagination (by running several stateless requests), the result set can be impacted by new states stored while navigating. This can be a challenge to retrieve a consistent result set. 

This parameter must be used to avoid this issue. However, It will not provide a consistent result set if data, that meet search criteria, get deleted because of the cleanup triggered by the retention policy.


4

sort

string timestamp:desc

Data is by default returned sorted by the timestamp in descending order. It can be overridden and data can be sorted by multiple fields.

sort=timestamp:asc,anchor:desc

Assumptions

Payload Filter Format 
Anchor
payloadFilterFormat
payloadFilterFormat

The data can be filtered, using JSON format, on one  field at any level, but it is important to provide the entire path from the root. The below JSON is used as an example to explain the filtering format

Code Block
collapsetrue
{
  "idNearRTRIC": "1",
  "labels" : [ "cps", "ran"],
  "nestedObject": {
    "id": "4",
    "attributes": {
      "gNBDUId": 4.0,
      "gNBDUName": "gnduserver4",
      "gNBIdLength": 32.0
    }
  },
  "GNBDUFunction": [
    {
      "idGNBDUFunction": "5",
      "NRCellDU": [
        {
          "idNRCellDU": "13905",
          "attributes": {
            "nRPCI": 12.0,
            "nRTAC": 310.0,
            "cellLocalId": 13905.0
          }
        },
        {
          "idNRCellDU": "14655",
          "attributes": {
            "nRPCI": 12.0,
            "nRTAC": 310.0,
            "cellLocalId": 14655.0
          }
        }
      ],
      "attributes": {
        "gNBDUId": 5.0,
        "gNBDUName": "gnduserver5",
        "gNBIdLength": 32.0
      }
    }
  ]
}

The filtering scenarios and the format are defined below:

NoFilter ConditionTo be searchFormat
1Top-level FieldidNearRTRIC

{ "idNearRTRIC": "1"}

2Nested FieldnestedObject → id{ "nestedObject" : {"attributes" :  {"gNBDUId": 4.0 }} }
3Value(s) in a collectionlabels

{ "labels": ["cps"] }

4Field of an object inside a collectionGNBDUFunction → idGNBDUFunction

{ "GNBDUFunction" : [ {"idGNBDUFunction" : 5 }]  }

Proposed APIs

The GET Endpoints contains information about the anchors and the rest of the filtering criteria are passed as query parameter. The below-mentioned query parameters are supported by all endpoints.

  1. after - timestamp ( ISO Format) to consider data created after the specified Timestamp
  2. simplePayloadFilter - to define payload filtering criteria
  3. pageNumber - to define the page number (required for pagination)
  4. pageLimit - to limit the response size
  5. pointInTime - to consider data changed or added before this time.
  6. sort - to define the order of data in the result set

The response format for endpoints is the same and defined here

By Dataspace and Anchor
Proposed APIs

...

URL: 

GET /dataspaces/{dataspace-name}​/anchors/{anchor-name}​/history

Example: GET /dataspaces/{dataspace-name}​/anchors/{anchor-name}​/history?after=

...

2021-03-21T00:00:00-0:00&simplePayloadFilter={"idNearRTRIC":"1"}&pageLimit=500

By Dataspace and Schema-set

...

URL: 

​GET /dataspaces/{dataspace-name}/

...

anchors/history?schemaSet={schemaset-name}

Example: GET /dataspaces/{dataspace-name}/anchors?schemaSet={schemaset-name}&after=2021-03-21T00:00:00-0:00&simplePayloadFilter={"idNearRTRIC":"1"}

Response 
Anchor
responseBody
responseBody
nametype
nextRecordsLinkstringadded only if there are remaining records to be fetched for the query.
previousRecordsLinkstringadded only if it is not the first set of records.
recordslist

contains one record for each timestamp that meets filtering criteria. It contains header information along with data. 

...


Code Block
{
  "headernextRecordsLink": {
    "next": "cps-temporal/api/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/history?after=<epoch-time>&maxSize=1000&before=<epoch-time>",
    "dataspace" : "abcd",
    "schema-set": "ijkl"
  },
  "data2021-03-21T00:00:00-0:00&simplePayloadFilter={"idNearRTRIC":"1"}&pageLimit=500&pointInTime=2021-04-21T00:00:00-0:00&pageNumber=2",
  "previousRecordsLink": "cps-temporal/api/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/history?after=2021-03-21T00:00:00-0:00&simplePayloadFilter={"idNearRTRIC":"1"}&pageLimit=500&pointInTime=2021-04-21T00:00:00-0:00&pageNumber=0",
  "records": [
    {
      "timestamp": "12345677888892021-03-21T00:00:00-0:00",
      "anchor-iddataspace": "pnfmy-namedataspace",
      "payloadschemaSet": {
        "status" : "UP"my-schema-set",
        "key1anchor" : "value1my-anchor",
        "more-infodata": {
          "key2status" : "valueUP"
        }
      }
    }
  ]
}

Open Items

  1. Datetime format 

...