{
  "$schema" : "https://json-schema.org/draft/2020-12/schema",
  "$id" : "https://voltdb.com/voltsp/schemas/emitter/volt-tumbling-count-window",
  "title" : "Volt-tumbling-count-window Emitter Configuration",
  "description" : "The `volt-tumbling-count-window` creates a partitioned, distributed tumbling count window. In this implementation VoltDB acts as a storage for the window aggregate.\n The aggregate is emitted using VoltDB stream feature - so this implementation expects a topic to be defined in Volt's deployment file.\n\nThe `volt-tumbling-count-window`, during configuration phase, generates code for VoltSP side to extract fields necessary for aggregate update.\n It also automatically generates and loads schema and procedures into VoltDB. For now, only deployment file needs to be manually updated.\n\nBased on `VoltAggregateBuilder` each event is transformed into a request.\n Lastly a partition key is extracted, and payload is routed to the right partition in VoltDB.\n\nIn case of downstream system error this `volt-tumbling-count-window` will re-process events.\n",
  "type" : "object",
  "properties" : {
    "volt-tumbling-count-window" : {
      "type" : "object",
      "properties" : {
        "maxEventsPerWindow" : {
          "type" : "integer",
          "description" : "Defines how many events this window can accumulate before it gets closed. Must be greater than 0",
          "minimum" : -2147483648,
          "maximum" : 2147483647
        },
        "partitionKeyExtractor" : {
          "description" : "The partition is determined by hashing the value extracted from the message using this class.",
          "anyOf" : [ {
            "type" : "string",
            "description" : "Java method reference or JavaScript code"
          }, {
            "type" : "object",
            "properties" : {
              "implementation" : {
                "type" : "string",
                "description" : "Java method reference or JavaScript code"
              },
              "type" : {
                "type" : "string",
                "description" : "The return type of the extractor"
              }
            },
            "required" : [ "implementation" ]
          } ]
        },
        "aggregateDefinition" : {
          "type" : "object",
          "description" : "The aggregate is defined by the provided builder",
          "properties" : {
            "builder" : {
              "type" : "array",
              "items" : {
                "type" : "object",
                "properties" : {
                  "type" : {
                    "type" : "string",
                    "description" : "The aggregation operation (e.g., count, sum, min, max, first, last, distinct)"
                  }
                },
                "required" : [ "type" ]
              }
            },
            "from" : {
              "type" : "string",
              "description" : "The fully qualified name of the class that contains the aggregate functions"
            }
          },
          "required" : [ "from", "builder" ]
        },
        "voltClientResource" : {
          "description" : "Client resource reference to be used when connecting to VoltDb cluster",
          "anyOf" : [ {
            "type" : "string"
          }, {
            "$ref" : "resource-voltdb-client.schema.json#/properties/voltdb-client"
          } ]
        },
        "servers" : {
          "description" : "A set of host and port addresses for connecting to the VoltDB cluster. Only one address is sufficient for cluster topology discovery.",
          "anyOf" : [ {
            "type" : "array",
            "uniqueItems" : true,
            "items" : {
              "type" : "string",
              "anyOf" : [ {
                "type" : "string",
                "format" : "hostname"
              }, {
                "type" : "string",
                "format" : "ipv4"
              }, {
                "type" : "string",
                "format" : "ipv6"
              } ]
            }
          }, {
            "type" : "string"
          } ]
        },
        "batchSize" : {
          "type" : "integer",
          "description" : "The maximum number of records to include in a single batch before inserting data into VoltDB. Higher values can improve throughput but will increase memory usage.",
          "default" : "100000",
          "minimum" : -2147483648,
          "maximum" : 2147483647
        },
        "flushInterval" : {
          "type" : "string",
          "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
          "description" : "The time interval after which batch is flushed to VoltDB, even if the desired batch size is not reached.",
          "default" : "1s"
        },
        "client" : {
          "type" : "object",
          "description" : "Configuration settings for the VoltDB client, including authentication, retry policies, and performance limits.",
          "properties" : {
            "retry" : {
              "type" : "object",
              "description" : "Configuration for retrying failed operations, including the number of retries and backoff delays.",
              "properties" : {
                "retries" : {
                  "type" : "integer",
                  "description" : "Number of retry attempts after a request failure.",
                  "default" : "3",
                  "minimum" : -2147483648,
                  "maximum" : 2147483647
                },
                "backoffDelay" : {
                  "type" : "string",
                  "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
                  "description" : "Initial delay before the first retry attempt.",
                  "default" : "PT0.2S"
                },
                "maxBackoffDelay" : {
                  "type" : "string",
                  "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
                  "description" : "Maximum delay between consecutive retry attempts.",
                  "default" : "PT3S"
                }
              },
              "additionalProperties" : false
            },
            "maxTransactionsPerSecond" : {
              "type" : "integer",
              "description" : "The maximum number of transactions allowed per second to control the rate of operations.",
              "minimum" : -2147483648,
              "maximum" : 2147483647
            },
            "maxOutstandingTransactions" : {
              "type" : "integer",
              "description" : "The maximum number of outstanding transactions allowed, limiting concurrent operations.",
              "minimum" : -2147483648,
              "maximum" : 2147483647
            },
            "requestTimeout" : {
              "type" : "string",
              "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
              "description" : "The timeout duration for client requests to VoltDB, after which a request is considered failed."
            },
            "responseThreadCount" : {
              "type" : "integer",
              "description" : "Size of the thread pool that dispatches procedure-call responses.\n",
              "default" : "4",
              "minimum" : -2147483648,
              "maximum" : 2147483647
            },
            "auth" : {
              "type" : "object",
              "description" : "Client credentials for authenticating to the VoltDB cluster.",
              "properties" : {
                "username" : {
                  "type" : "string",
                  "description" : "Username used for authentication."
                },
                "password" : {
                  "type" : "string",
                  "description" : "Password used for authentication."
                }
              },
              "additionalProperties" : false
            },
            "ssl" : {
              "type" : "object",
              "description" : "Client configuration for secure transport to the VoltDB cluster.",
              "properties" : {
                "trustStoreFile" : {
                  "type" : "string",
                  "description" : "Truststore file or trusted CA certificate; supported formats include JKS, PKCS#12, or PEM."
                },
                "trustStorePassword" : {
                  "type" : "string",
                  "description" : "Truststore password."
                },
                "keyStoreFile" : {
                  "type" : "string",
                  "description" : "Keystore file; supported formats include JKS, PKCS#12, or PEM"
                },
                "keyStorePassword" : {
                  "type" : "string",
                  "description" : "Keystore password."
                },
                "keyPassword" : {
                  "type" : "string",
                  "description" : "Private key password. Optional — if not set, the key store password will be used."
                },
                "insecure" : {
                  "type" : "boolean",
                  "description" : "If set to true, disables SSL certificate and hostname validation.\nIntended for debugging purposes only. Doesn't work with mTLS.\n"
                },
                "hostnameVerifier" : {
                  "type" : "string",
                  "description" : "Custom hostname verifier for SSL connections.\nIf not specified and 'insecure' is true, hostname verification will be disabled.\n"
                }
              },
              "additionalProperties" : false
            }
          },
          "additionalProperties" : false
        },
        "exceptionHandler" : {
          "type" : "string",
          "description" : "Custom exception handler enabling interception of all errors related to this emitter."
        },
        "triggers" : {
          "type" : "array",
          "description" : "List of trigger configurations that create sub-pipelines",
          "items" : {
            "type" : "object",
            "properties" : {
              "trigger" : {
                "type" : "string",
                "enum" : [ "org.voltdb.stream.plugin.window.api.WindowTrigger#atWindowEnd", "org.voltdb.stream.plugin.window.api.WindowTrigger#atAggregate" ],
                "description" : "The trigger point that activates this sub-pipeline"
              },
              "processors" : {
                "type" : "array",
                "description" : "Optional list of processors to apply before the sink or emitter",
                "items" : {
                  "$ref" : "#/$defs/processor"
                }
              },
              "sink" : {
                "$ref" : "#/$defs/sink"
              },
              "emitter" : {
                "$ref" : "#/$defs/emitter"
              }
            },
            "oneOf" : [ {
              "required" : [ "trigger", "sink" ]
            }, {
              "required" : [ "trigger", "emitter" ]
            } ]
          }
        }
      },
      "required" : [ "partitionKeyExtractor", "aggregateDefinition", "voltClientResource", "triggers" ],
      "additionalProperties" : false
    }
  },
  "required" : [ "volt-tumbling-count-window" ],
  "additionalProperties" : false
}
