FrankChen021 commented on a change in pull request #11240:
URL: https://github.com/apache/druid/pull/11240#discussion_r659146121



##########
File path: docs/development/extensions-contrib/rocketmq-ingestion.md
##########
@@ -0,0 +1,414 @@
+---
+id: rocketmq-ingestion
+title: "Apache RocketMQ ingestion"
+sidebar_label: "Apache RocketMQ"
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+
+The `RocketMQ` indexing service enables the configuration of *supervisors* on 
the Overlord, which facilitate ingestion from
+`RocketMQ` by managing the creation and lifetime of `RocketMQ` indexing tasks. 
These indexing tasks read events using `RocketMQ's` own
+message queue and offset mechanism and are therefore able to provide 
guarantees of exactly-once ingestion. Message queue is defined unique by 
+broker name and `queueID`, and message is in ordered stored in one message 
queue.
+The supervisor oversees the state of the indexing tasks to coordinate handoffs,
+manage failures, and ensure that the scalability and replication requirements 
are maintained.
+
+This service is provided in the `druid-rocketmq-indexing-service` contrib 
Apache Druid extension (see
+[Including Extensions](../../development/extensions.md#loading-extensions)).
+
+## Tutorial
+
+This page contains reference documentation for `Apache RocketMQ-based` 
ingestion.
+
+## Submitting a Supervisor Spec
+
+The `RocketMQ` indexing service requires that the 
`druid-rocketmq-indexing-service` extension be loaded on both the Overlord and 
the
+MiddleManagers. A supervisor for a dataSource is started by submitting a 
supervisor spec via HTTP POST to
+`http://<OVERLORD_IP>:<OVERLORD_PORT>/druid/indexer/v1/supervisor`, for 
example:
+
+```
+curl -X POST -H 'Content-Type: application/json' -d @supervisor-spec.json 
http://localhost:8090/druid/indexer/v1/supervisor
+```
+
+A sample supervisor spec is shown below:
+
+```json
+{
+  "type": "rocketmq",
+  "dataSchema": {
+    "dataSource": "metrics-rocketmq",
+    "timestampSpec": {
+      "column": "timestamp",
+      "format": "auto"
+    },
+    "dimensionsSpec": {
+      "dimensions": [],
+      "dimensionExclusions": [
+        "timestamp",
+        "value"
+      ]
+    },
+    "metricsSpec": [
+      {
+        "name": "count",
+        "type": "count"
+      },
+      {
+        "name": "value_sum",
+        "fieldName": "value",
+        "type": "doubleSum"
+      },
+      {
+        "name": "value_min",
+        "fieldName": "value",
+        "type": "doubleMin"
+      },
+      {
+        "name": "value_max",
+        "fieldName": "value",
+        "type": "doubleMax"
+      }
+    ],
+    "granularitySpec": {
+      "type": "uniform",
+      "segmentGranularity": "HOUR",
+      "queryGranularity": "NONE"
+    }
+  },
+  "ioConfig": {
+    "topic": "metrics",
+    "inputFormat": {
+      "type": "json"
+    },
+    "consumerProperties": {
+      "nameserver.url": "localhost:9876"
+    },
+    "taskCount": 1,
+    "replicas": 1,
+    "taskDuration": "PT1H"
+  },
+  "tuningConfig": {
+    "type": "rocketmq",
+    "maxRowsPerSegment": 5000000
+  }
+}
+```
+
+## Supervisor Configuration
+
+|Field|Description|Required|
+|--------|-----------|---------|
+|`type`|The supervisor type, this should always be `rocketmq`.|yes|
+|`dataSchema`|The schema that will be used by the `RocketMQ` indexing task 
during ingestion. See [`dataSchema`](../../ingestion/index.md#dataschema) for 
details.|yes|
+|`ioConfig`|A `RocketMQSupervisorIOConfig` object for configuring `RocketMQ` 
connection and I/O-related settings for the supervisor and indexing task. See 
[`RocketMQSupervisorIOConfig`](#rocketmqsupervisorioconfig) below.|yes|
+|`tuningConfig`|A `RocketMQSupervisorTuningConfig` object for configuring 
performance-related settings for the supervisor and indexing tasks. See 
[`RocketMQSupervisorTuningConfig`](#rocketmqsupervisortuningconfig) below.|no|
+
+### `RocketMQSupervisorIOConfig`
+
+|Field|Type|Description|Required|
+|-----|----|-----------|--------|
+|`topic`|String|The `RocketMQ` topic to read from. This must be a specific 
topic as topic patterns are not supported.|yes|
+|`inputFormat`|Object|[`inputFormat`](../../ingestion/data-formats.md#input-format)
 to specify how to parse input data. See [the below 
section](#specifying-data-format) for details about specifying the input 
format.|yes|
+|`consumerProperties`|Map<String, Object>|A map of properties to be passed to 
the `RocketMQ` consumer. See [next section](#more-on-consumerproperties) for 
more information.|yes|
+|`pollTimeout`|Long|The length of time to wait for the `RocketMQ` consumer to 
poll records, in milliseconds|no (default == 100)|
+|`replicas`|Integer|The number of replica sets, where 1 means a single set of 
tasks (no replication). Replica tasks will always be assigned to different 
workers to provide resiliency against process failure.|no (default == 1)|
+|`taskCount`|Integer|The maximum number of *reading* tasks in a *replica set*. 
This means that the maximum number of reading tasks will be `taskCount * 
replicas` and the total number of tasks (*reading* + *publishing*) will be 
higher than this. See [Capacity Planning](#capacity-planning) below for more 
details. The number of reading tasks will be less than `taskCount` if 
`taskCount > {numRocketMQMessageQueues}`.|no (default == 1)|
+|`taskDuration`|ISO8601 Period|The length of time before tasks stop reading 
and begin publishing their segment.|no (default == `PT1H`)|
+|`startDelay`|ISO8601 Period|The period to wait before the supervisor starts 
managing tasks.|no (default == `PT5S`)|
+|`period`|ISO8601 Period|How often the supervisor will execute its management 
logic. Note that the supervisor will also run in response to certain events 
(such as tasks succeeding, failing, and reaching their `taskDuration`) so this 
value specifies the maximum time between iterations.|no (default == `PT30S`)|
+|`useEarliestOffset`|Boolean|If a supervisor is managing a dataSource for the 
first time, it will obtain a set of starting offsets from `RocketMQ`. This flag 
determines whether it retrieves the earliest or latest offsets in `RocketMQ`. 
Under normal circumstances, subsequent tasks will start from where the previous 
segments ended so this flag will only be used on first run.|no (default == 
false)|
+|`completionTimeout`|ISO8601 Period|The length of time to wait before 
declaring a publishing task as failed and terminating it. If this is set too 
low, your tasks may never publish. The publishing clock for a task begins 
roughly after `taskDuration` elapses.|no (default == `PT30M`)|
+|`lateMessageRejectionStartDateTime`|ISO8601 DateTime|Configure tasks to 
reject messages with timestamps earlier than this date time; for example if 
this is set to `2016-01-01T11:00Z` and the supervisor creates a task at 
*`2016-01-01T12:00Z`*, messages with timestamps earlier than 
*`2016-01-01T11:00Z`* will be dropped. This may help prevent concurrency issues 
if your data stream has late messages and you have multiple pipelines that need 
to operate on the same segments (e.g. a realtime and a nightly batch ingestion 
pipeline).|no (default == none)|
+|`lateMessageRejectionPeriod`|ISO8601 Period|Configure tasks to reject 
messages with timestamps earlier than this period before the task was created; 
for example if this is set to `PT1H` and the supervisor creates a task at 
*`2016-01-01T12:00Z`*, messages with timestamps earlier than 
*`2016-01-01T11:00Z`* will be dropped. This may help prevent concurrency issues 
if your data stream has late messages and you have multiple pipelines that need 
to operate on the same segments (e.g. a realtime and a nightly batch ingestion 
pipeline). Please note that only one of `lateMessageRejectionPeriod` or 
`lateMessageRejectionStartDateTime` can be specified.|no (default == none)|
+|`earlyMessageRejectionPeriod`|ISO8601 Period|Configure tasks to reject 
messages with timestamps later than this period after the task reached its 
`taskDuration`; for example if this is set to `PT1H`, the `taskDuration` is set 
to `PT1H` and the supervisor creates a task at *`2016-01-01T12:00Z`*, messages 
with timestamps later than *`2016-01-01T14:00Z`* will be dropped. **Note:** 
Tasks sometimes run past their task duration, for example, in cases of 
supervisor failover. Setting `earlyMessageRejectionPeriod` too low may cause 
messages to be dropped unexpectedly whenever a task runs past its originally 
configured task duration.|no (default == none)|
+
+#### More on consumerProperties
+
+Now `consumerProperties` only support one property. This must contain a 
property `nameserver.url` with a list of `RocketMQ` name servers in the form: 
`<NAMESREV_1>:<PORT_1>;<NAMESREV_2>:<PORT_2>;...`.
+
+#### Specifying data format
+
+`RocketMQ` indexing service supports both 
[`inputFormat`](../../ingestion/data-formats.md#input-format) and 
[`parser`](../../ingestion/data-formats.md#parser) to specify the data format.
+The `inputFormat` is a new and recommended way to specify the data format for 
`RocketMQ` indexing service,
+but unfortunately, it doesn't support all data formats supported by the legacy 
`parser`.
+(They will be supported in the future.)
+
+The supported `inputFormat`s include 
[`csv`](../../ingestion/data-formats.md#csv),
+[`delimited`](../../ingestion/data-formats.md#tsv-delimited), and 
[`json`](../../ingestion/data-formats.md#json).
+You can also read 
[`avro_stream`](../../ingestion/data-formats.md#avro-stream-parser),
+[`protobuf`](../../ingestion/data-formats.md#protobuf-parser),
+and [`thrift`](../extensions-contrib/thrift.md) formats using `parser`.
+
+<a name="tuningconfig"></a>
+
+### `RocketMQSupervisorTuningConfig`
+
+The tuningConfig is optional and default parameters will be used if no 
tuningConfig is specified.
+
+| Field                             | Type           | Description             
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                            | Required                          
                                                                           |
+|-----------------------------------|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
+| `type`                            | String         | The indexing task type, 
this should always be `rocketmq`.                                               
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                               | yes                            
                                                                              |
+| `maxRowsInMemory`                 | Integer        | The number of rows to 
aggregate before persisting. This number is the post-aggregation rows, so it is 
not equivalent to the number of input events, but the number of aggregated rows 
that those events result in. This is used to manage the required JVM heap size. 
Maximum heap memory usage for indexing scales with `maxRowsInMemory` * (2 + 
`maxPendingPersists`). Normally user does not need to set this, but depending 
on the nature of data, if rows are short in terms of bytes, user may not want 
to store a million rows in memory and this value should be set.                 
                                                          | no (default == 
1000000)                                                                        
              |
+| `maxBytesInMemory`                | Long           | The number of bytes to 
aggregate in heap memory before persisting. This is based on a rough estimate 
of memory usage and not actual usage. Normally this is computed internally and 
user does not need to set it. The maximum heap memory usage for indexing is 
`maxBytesInMemory` * (2 + `maxPendingPersists`).                                
                                                                                
                                                                                
                                                                                
                                                        | no (default == 
One-sixth of max JVM memory)                                                    
              |
+| `maxRowsPerSegment`               | Integer        | The number of rows to 
aggregate into a segment; this number is post-aggregation rows. Handoff will 
happen either if `maxRowsPerSegment` or `maxTotalRows` is hit or every 
`intermediateHandoffPeriod`, whichever happens earlier.                         
                                                                                
                                                                                
                                                                                
                                                                                
                                                          | no (default == 
5000000)                                                                        
              |
+| `maxTotalRows`                    | Long           | The number of rows to 
aggregate across all segments; this number is post-aggregation rows. Handoff 
will happen either if `maxRowsPerSegment` or `maxTotalRows` is hit or every 
`intermediateHandoffPeriod`, whichever happens earlier.                         
                                                                                
                                                                                
                                                                                
                                                                                
                                                     | no (default == 
unlimited)                                                                      
              |
+| `intermediatePersistPeriod`       | ISO8601 Period | The period that 
determines the rate at which intermediate persists occur.                       
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                    | no (default == `PT10M`)   
                                                                                
     |
+| `maxPendingPersists`              | Integer        | Maximum number of 
persists that can be pending but not started. If this limit would be exceeded 
by a new intermediate persist, ingestion will block until the currently-running 
persist finishes. Maximum heap memory usage for indexing scales with 
`maxRowsInMemory` * (2 + `maxPendingPersists`).                                 
                                                                                
                                                                                
                                                                                
                                                                   | no 
(default == 0, meaning one persist can be running concurrently with ingestion, 
and none can be queued up) |
+| `indexSpec`                       | Object         | Tune how data is 
indexed. See [IndexSpec](#indexspec) for more information.                      
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                   | no                         
                                                                                
  |
+| `indexSpecForIntermediatePersists`|                | Defines segment storage 
format options to be used at indexing time for intermediate persisted temporary 
segments. This can be used to disable dimension/metric compression on 
intermediate segments to reduce memory required for final merging. However, 
disabling compression on intermediate segments might increase page cache use 
while they are used before getting merged into final segment published, see 
[IndexSpec](#indexspec) for possible values.                                    
                                                                                
                                                                 | no (default 
= same as `indexSpec`)                                                          
                   |
+| `reportParseExceptions`           | Boolean        | *DEPRECATED*. If true, 
exceptions encountered during parsing will be thrown and will halt ingestion; 
if false, unparseable rows and fields will be skipped. Setting 
`reportParseExceptions` to true will override existing configurations for 
`maxParseExceptions` and `maxSavedParseExceptions`, setting 
`maxParseExceptions` to 0 and limiting `maxSavedParseExceptions` to no more 
than 1.                                                                         
                                                                                
                                                                                
              | no (default == false)                                           
                                             |
+| `handoffConditionTimeout`         | Long           | Milliseconds to wait 
for segment handoff. It must be >= 0, where 0 means to wait forever.            
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                               | no (default == 0)              
                                                                              |
+| `resetOffsetAutomatically`        | Boolean        | Controls behavior when 
Druid needs to read `RocketMQ` messages that are no longer available (i.e. when 
`OffsetOutOfRangeException` is encountered).<br/><br/>If false, the exception 
will bubble up, which will cause your tasks to fail and ingestion to halt. If 
this occurs, manual intervention is required to correct the situation; 
potentially using the [Reset Supervisor 
API](../../operations/api-reference.md#supervisors). This mode is useful for 
production, since it will make you aware of issues with ingestion.<br/><br/>If 
true, Druid will automatically reset to the earlier or latest offset available 
in `RocketMQ`, based on the value of the `useEarliestOffset` property (earliest 
if true, latest if false). Please note that this can lead to data being 
_DROPPED_ (if `useEarliestOffset` is false) or _DUPLICATED_ (if 
`useEarliestOffset` is true) without your knowledge. Messages will be logged 
indicating that a reset has occurred, but in
 gestion will continue. This mode is useful for non-production situations, 
since it will make Druid attempt to recover from problems automatically, even 
if they lead to quiet dropping or duplicating of data. | no (default == false) |

Review comment:
       I don't see TaskRunner of this extension resets offset automatically.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to