All Downloads are FREE. Search and download functionalities are using the official Maven repository.

activities.graphql-schema-first.http-graphql-timeseries.yaml Maven / Gradle / Ivy

Go to download

A HTTP nosqlbench ActivityType (AT) driver module; This provides the ability to generate HTTP requests with nosqlbench

The newest version!
# nb -v run driver=http yaml=http-graphql-timeseries tags=phase:schema host=my_stargate_host stargate_host=my_stargate_host auth_token=$AUTH_TOKEN

# TODO 
# - do we need a truncate schema / namespace at the end
# - support for a paging state?
# - infinity is not handled
# - compression and compaction not defined (limitation in the GQL schema-first API)

description: |
  This workload emulates a time-series data model and access patterns.
  This should be identical to the cql variant except for:
  - We can't specify the write timestamp to make the write idempotent like we can with cql.
  - The `time` binding has to have a StringDateWrapper to get the exact format that the REST API/GraphQL needs; See https://github.com/stargate/stargate/issues/532.
  - We need to URLEncode the `data` binding because newlines can't be sent in REST calls.
  - Schema creation GraphQL first, we don't use cql and thus can only create schema with limited options.
  - There is no instrumentation with the http driver.
  - There is no async mode with the http driver.
  Note that stargate_port should reflect the port where GraphQL API V2 is exposed (defaults to 8080). 

scenarios:
  default:
    - run driver=http tags==phase:schema threads==1 cycles==UNDEF
    - run driver=http tags==phase:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto
    - run driver=http tags==phase:main cycles===TEMPLATE(main-cycles,10000000) threads=auto
bindings:
  # To enable an optional weighted set of hosts in place of a load balancer
  # Examples
  #   single host: stargate_host=host1
  #   multiple hosts: stargate_host=host1,host2,host3
  #   multiple weighted hosts: stargate_host=host1:3,host2:7
  weighted_hosts: WeightedStrings('<>')
  # http request id
  request_id: ToHashedUUID(); ToString();

  machine_id: Mod(<>); ToHashedUUID() -> java.util.UUID
  sensor_name: HashedLineToString('data/variable_words.txt')
  time: Mul(<>L); Div(<>L); StringDateWrapper("yyyy-MM-dd'T'hh:mm:ss'Z");
  sensor_value: Normal(0.0,5.0); Add(100.0) -> double
  station_id: Div(<>);Mod(<>); ToHashedUUID() -> java.util.UUID
  data: HashedFileExtractToString('data/lorem_ipsum_full.txt',800,1200); URLEncode();
blocks:
  - tags:
      phase: schema
    statements:
      - create-keyspace: POST <>://{weighted_hosts}:<><>/graphql-schema
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        Content-Type: "application/json"
        body: |
            {
              "query":"mutation {\n  createKeyspace(name: \"<>\", replicas: <>, ifNotExists: true) \n}\n"
            }
        tags:
          name: create-keyspace
      - create-gql-schema : POST <>://{weighted_hosts}:<><>/graphql-admin
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        Content-Type: "application/json"
        body: |
            {
              "query":"mutation {\n  deploySchema(keyspace: \"<>\", schema: \"\"\"\n      type Iot @cql_input {\n        machine_id: Uuid! @cql_column(partitionKey: true)\n        sensor_name: String! @cql_column(partitionKey: true)\n        time: Timestamp! @cql_column(clusteringOrder: DESC)\n        sensor_value: Float!\n    \tstation_id: Uuid!\n        data: String!\n      }\n      type SelectIotResult @cql_payload {\n    \t\tdata: [Iot]\n    \t\tpagingState: String\n    }\n      type Query {\n        getIots(\n          machine_id: Uuid!,\n          sensor_name: String!,\n          pagingState: String @cql_pagingState\n        ): SelectIotResult @cql_select(pageSize: 10)\n      }\n      type Mutation {\n    \t\tinsertIot(iot: IotInput): Iot\n    }\n  \"\"\") {\n    version\n  }\n}\n"
            }
        tags:
          name: create-gql-schema
  - tags:
      phase: schema-astra
    statements:
      - create-gql-schema: POST <>://{weighted_hosts}:<><>/graphql-admin
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        Content-Type: "application/json"
        body: |
            {
              "query":"mutation {\n  deploySchema(namespace: \"<>\", schema: \"\"\"\n      type Iot @cql_input {\n        machine_id: Uuid! @cql_column(partitionKey: true)\n        sensor_name: String! @cql_column(partitionKey: true)\n        time: Timestamp! @cql_column(clusteringOrder: DESC)\n        sensor_value: Float!\n    \tstation_id: Uuid!\n        data: String!\n      }\n      type SelectIotResult @cql_payload {\n    \t\tdata: [Iot]\n    \t\tpagingState: String\n    }\n      type Query {\n        getIots(\n          machine_id: Uuid!,\n          sensor_name: String!,\n          pagingState: String @cql_pagingState\n        ): SelectIotResult @cql_select(pageSize: 10)\n      }\n      type Mutation {\n    \t\tinsertIot(iot: IotInput): Iot\n    }\n  \"\"\") {\n    version\n  }\n}\n"
            }
        tags:
          name: create-gql-schema
  - name: rampup
    tags:
      phase: rampup
    statements:
      - rampup-insert: POST <>://{weighted_hosts}:<><>/graphql/<>
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        Content-Type: "application/json"
        body: |
            {
              "query":"mutation {\n  insertIot(iot: {machine_id: \"{machine_id}\", sensor_name: \"{sensor_name}\", time: \"{time}\", sensor_value: {sensor_value}, station_id: \"{station_id}\", data: \"{data}\"}) {\n    machine_id\n    sensor_name\n    time\n    sensor_value\n    station_id\n    data\n  }\n}\n"
            }
        tags:
          name: rampup-insert

  - name: main-read
    tags:
      phase: main
      type: read
    params:
      ratio: <>
    statements:
      - main-select: POST <>://{weighted_hosts}:<><>/graphql/<>
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        Content-Type: "application/json"
        body: |
            {
              "query":"{\n  getIots(machine_id: \"{machine_id}\", sensor_name: \"{sensor_name}\") {\n    data {\n      machine_id\n      sensor_name\n      time\n      sensor_value\n      station_id\n      data\n    }\n  }\n}\n"
            }
        tags:
          name: main-select

  - name: main-write
    tags:
      phase: main
      type: write
    params:
      ratio: <>
    statements:
      - main-write: POST <>://{weighted_hosts}:<><>/graphql/<>
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        Content-Type: "application/json"
        body: |
            {
              "query":"mutation {\n  insertIot(iot: {machine_id: \"{machine_id}\", sensor_name: \"{sensor_name}\", time: \"{time}\", sensor_value: {sensor_value}, station_id: \"{station_id}\", data: \"{data}\"}) {\n    machine_id\n    sensor_name\n    time\n    sensor_value\n    station_id\n    data\n  }\n}\n"
            }
        tags:
          name: main-write




© 2015 - 2025 Weber Informatics LLC | Privacy Policy