aws-kclrb 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e606b4662cdbb79ec9bc55dfc314c311fbffaa332d203cf84c386095173a3aea
4
- data.tar.gz: 4c21857b56f8e596bcb3072ee706611b145a43214a87e12a349e870395bc5b0e
3
+ metadata.gz: 3beff85e7553d852f6c1dfadd44ee7279fdb29256f2ed40fd98358b51751ae72
4
+ data.tar.gz: 3c63d7db385a48655dfde264d574859084d71aa7eb5dd3f4642673e8076fca53
5
5
  SHA512:
6
- metadata.gz: 30a46ab76ecaafa685cc156aaa036bda590717a4d47ec82b96683eadb3f8a9ca893d76a73d361006450b5c44bee54356281459e3a764bf76929167c30798d14d
7
- data.tar.gz: 416dcfc937ead185262d3ffe77f4d27fc90bb0c190865b98c323774074b925b0a8177746be39a7c1ca5ef6a46876ca460e23d45ce3971dd629ac597e902fc15b
6
+ metadata.gz: 8c6979336047673a21d5012c4ecd7afb23e51c51aa510b359b5520af40911ceff6a32db68f496fa6c55d2d9112ff9b754607e7a1d2badd47f8a4b943c84ad983
7
+ data.tar.gz: b180e3db5cf893c5104cd2522eb5d997015f241be081d974f0f5deb317177d2934a95dc7ef6d805c4cc64d6d98c28581d9c21e0199bc32c7c6ccd3e66171d8cf
data/README.md CHANGED
@@ -11,38 +11,38 @@ This package wraps and manages the interaction with the [MultiLangDaemon][multi-
11
11
  executable. A record processor in Ruby typically looks something like:
12
12
 
13
13
  ```ruby
14
- #! /usr/bin/env ruby
15
-
16
- require 'aws/kclrb'
17
-
18
- class SampleRecordProcessor < Aws::KCLrb::V2::RecordProcessorBase
19
- def init_processor(initialize_input)
20
- # initialize
21
- end
22
-
23
- def process_records(process_records_input)
24
- # process batch of records
25
- end
26
-
27
- def lease_lost(lease_lost_input)
28
- # lease was lost, cleanup
29
- end
30
-
31
- def shard_ended(shard_ended_input)
32
- # shard has ended, cleanup
33
- end
34
-
35
- def shutdown_requested(shutdown_requested_input)
36
- # shutdown has been requested
37
- end
38
- end
39
-
40
- if __FILE__ == $0
41
- # Start the main processing loop
42
- record_processor = SampleRecordProcessor.new
43
- driver = Aws::KCLrb::KCLProcess.new(record_processor)
44
- driver.run
45
- end
14
+ #! /usr/bin/env ruby
15
+
16
+ require 'aws/kclrb'
17
+
18
+ class SampleRecordProcessor < Aws::KCLrb::V2::RecordProcessorBase
19
+ def init_processor(initialize_input)
20
+ # initialize
21
+ end
22
+
23
+ def process_records(process_records_input)
24
+ # process batch of records
25
+ end
26
+
27
+ def lease_lost(lease_lost_input)
28
+ # lease was lost, cleanup
29
+ end
30
+
31
+ def shard_ended(shard_ended_input)
32
+ # shard has ended, cleanup
33
+ end
34
+
35
+ def shutdown_requested(shutdown_requested_input)
36
+ # shutdown has been requested
37
+ end
38
+ end
39
+
40
+ if __FILE__ == $0
41
+ # Start the main processing loop
42
+ record_processor = SampleRecordProcessor.new
43
+ driver = Aws::KCLrb::KCLProcess.new(record_processor)
44
+ driver.run
45
+ end
46
46
  ```
47
47
 
48
48
  ## Before You Get Started
@@ -51,7 +51,7 @@ Before running the samples, you'll want to make sure that your environment is
51
51
  configured to allow the samples to use your
52
52
  [AWS Security Credentials](http://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html).
53
53
 
54
- By default the samples use the [DefaultAWSCredentialsProviderChain][DefaultAWSCredentialsProviderChain]
54
+ By default the samples use the [DefaultCredentialsProvider][DefaultCredentialsProvider]
55
55
  so you'll want to make your credentials available to one of the credentials providers in that
56
56
  provider chain. There are several ways to do this such as providing a `~/.aws/credentials` file,
57
57
  or if you're running on Amazon EC2, you can associate an IAM role with your instance with appropriate
@@ -94,11 +94,11 @@ To run the data producer, run the following commands:
94
94
 
95
95
  #### Notes
96
96
 
97
- * The [AWS Ruby SDK gem][aws-ruby-sdk-gem] needs to be installed as a pre-requisite. To install,
97
+ * The [AWS Ruby SDK gem][aws-ruby-sdk-gem] for Kinesis needs to be installed as a pre-requisite. To install,
98
98
  run:
99
99
 
100
100
  ```sh
101
- sudo gem install aws-sdk
101
+ sudo gem install aws-sdk-kinesis
102
102
  ```
103
103
 
104
104
  * The script `samples/sample_kcl_producer.rb` takes several parameters that you can use
@@ -187,6 +187,43 @@ all languages.
187
187
 
188
188
  ## Release Notes
189
189
 
190
+ ### Release 3.0.0 (November 6, 2024)
191
+ * New lease assignment / load balancing algorithm
192
+ * KCL 3.x introduces a new lease assignment and load balancing algorithm. It assigns leases among workers based on worker utilization metrics and throughput on each lease, replacing the previous lease count-based lease assignment algorithm.
193
+ * When KCL detects higher variance in CPU utilization among workers, it proactively reassigns leases from over-utilized workers to under-utilized workers for even load balancing. This ensures even CPU utilization across workers and removes the need to over-provision the stream processing compute hosts.
194
+ * Optimized DynamoDB RCU usage
195
+ * KCL 3.x optimizes DynamoDB read capacity unit (RCU) usage on the lease table by implementing a global secondary index with leaseOwner as the partition key. This index mirrors the leaseKey attribute from the base lease table, allowing workers to efficiently discover their assigned leases by querying the index instead of scanning the entire table.
196
+ * This approach significantly reduces read operations compared to earlier KCL versions, where workers performed full table scans, resulting in higher RCU consumption.
197
+ * Graceful lease handoff
198
+ * KCL 3.x introduces a feature called "graceful lease handoff" to minimize data reprocessing during lease reassignments. Graceful lease handoff allows the current worker to complete checkpointing of processed records before transferring the lease to another worker. For graceful lease handoff, you should implement checkpointing logic within the existing `shutdownRequested()` method.
199
+ * This feature is enabled by default in KCL 3.x, but you can turn off this feature by adjusting the configuration property `isGracefulLeaseHandoffEnabled`.
200
+ * While this approach significantly reduces the probability of data reprocessing during lease transfers, it doesn't completely eliminate the possibility. To maintain data integrity and consistency, it's crucial to design your downstream consumer applications to be idempotent. This ensures that the application can handle potential duplicate record processing without adverse effects.
201
+ * New DynamoDB metadata management artifacts
202
+ * KCL 3.x introduces two new DynamoDB tables for improved lease management:
203
+ * Worker metrics table: Records CPU utilization metrics from each worker. KCL uses these metrics for optimal lease assignments, balancing resource utilization across workers. If CPU utilization metric is not available, KCL assigns leases to balance the total sum of shard throughput per worker instead.
204
+ * Coordinator state table: Stores internal state information for workers. Used to coordinate in-place migration from KCL 2.x to KCL 3.x and leader election among workers.
205
+ * Follow this [documentation](https://docs.aws.amazon.com/streams/latest/dev/kcl-migration-from-2-3.html#kcl-migration-from-2-3-IAM-permissions) to add required IAM permissions for your KCL application.
206
+ * Other improvements and changes
207
+ * Dependency on the AWS SDK for Java 1.x has been fully removed.
208
+ * The Glue Schema Registry integration functionality no longer depends on AWS SDK for Java 1.x. Previously, it required this as a transient dependency.
209
+ * Multilangdaemon has been upgraded to use AWS SDK for Java 2.x. It no longer depends on AWS SDK for Java 1.x.
210
+ * `idleTimeBetweenReadsInMillis` (PollingConfig) now has a minimum default value of 200.
211
+ * This polling configuration property determines the [publishers](https://github.com/awslabs/amazon-kinesis-client/blob/master/amazon-kinesis-client/src/main/java/software/amazon/kinesis/retrieval/polling/PrefetchRecordsPublisher.java) wait time between GetRecords calls in both success and failure cases. Previously, setting this value below 200 caused unnecessary throttling. This is because Amazon Kinesis Data Streams supports up to five read transactions per second per shard for shared-throughput consumers.
212
+ * Shard lifecycle management is improved to deal with edge cases around shard splits and merges to ensure records continue being processed as expected.
213
+ * Migration
214
+ * The programming interfaces of KCL 3.x remain identical with KCL 2.x for an easier migration. For detailed migration instructions, please refer to the [Migrate consumers from KCL 2.x to KCL 3.x](https://docs.aws.amazon.com/streams/latest/dev/kcl-migration-from-2-3.html) page in the Amazon Kinesis Data Streams developer guide.
215
+ * Configuration properties
216
+ * New configuration properties introduced in KCL 3.x are listed in this [doc](https://github.com/awslabs/amazon-kinesis-client/blob/master/docs/kcl-configurations.md#new-configurations-in-kcl-3x).
217
+ * Deprecated configuration properties in KCL 3.x are listed in this [doc](https://github.com/awslabs/amazon-kinesis-client/blob/master/docs/kcl-configurations.md#discontinued-configuration-properties-in-kcl-3x). You need to keep the deprecated configuration properties during the migration from any previous KCL version to KCL 3.x.
218
+ * Metrics
219
+ * New CloudWatch metrics introduced in KCL 3.x are explained in the [Monitor the Kinesis Client Library with Amazon CloudWatch](https://docs.aws.amazon.com/streams/latest/dev/monitoring-with-kcl.html) in the Amazon Kinesis Data Streams developer guide. The following operations are newly added in KCL 3.x:
220
+ * `LeaseAssignmentManager`
221
+ * `WorkerMetricStatsReporter`
222
+ * `LeaseDiscovery`
223
+
224
+ ### Release 2.1.1 (February 21, 2023)
225
+ * [#69](https://github.com/awslabs/amazon-kinesis-client-ruby/pull/69) Include `pom.xml` in the gemspec
226
+
190
227
  ### Release 2.1.0 (January 12, 2023)
191
228
  * Upgraded to use version 2.4.4 of the [Amazon Kinesis Client library][amazon-kcl-github]
192
229
 
@@ -229,8 +266,8 @@ all languages.
229
266
  [amazon-kcl]: http://docs.aws.amazon.com/kinesis/latest/dev/kinesis-record-processor-app.html
230
267
  [amazon-kcl-github]: https://github.com/awslabs/amazon-kinesis-client
231
268
  [amazon-kinesis-python-github]: https://github.com/awslabs/amazon-kinesis-client-python
232
- [multi-lang-daemon]: https://github.com/awslabs/amazon-kinesis-client/blob/master/src/main/java/com/amazonaws/services/kinesis/multilang/package-info.java
233
- [DefaultAWSCredentialsProviderChain]: http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html
269
+ [multi-lang-daemon]: https://github.com/awslabs/amazon-kinesis-client/blob/master/amazon-kinesis-client-multilang/src/main/java/software/amazon/kinesis/multilang/package-info.java
270
+ [DefaultCredentialsProvider]: https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/auth/credentials/DefaultCredentialsProvider.html
234
271
  [kinesis-forum]: http://developer.amazonwebservices.com/connect/forum.jspa?forumID=169
235
272
  [aws-ruby-sdk-gem]: https://rubygems.org/gems/aws-sdk
236
273
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 3.0.0
@@ -52,8 +52,8 @@ module Aws
52
52
  # @param action [Hash] A hash that represents an action to take with
53
53
  # appropriate attributes, as retrieved from {IOProxy#read_action}, e.g.
54
54
  #
55
- # - `{"action":"initialize","shardId":"shardId-123"}`
56
- # - `{"action":"processRecords","records":[{"data":"bWVvdw==","partitionKey":"cat","sequenceNumber":"456"}]}`
55
+ # - `{"action":"initialize","shardId":"shardId-123","sequenceNumber":123}`
56
+ # - `{"action":"processRecords","records":[{"data":"bWVvdw==","partitionKey":"cat","sequenceNumber":"456"}],"millisBehindLatest":"0"}`
57
57
  # - `{"action":"shutdown","reason":"TERMINATE"}`
58
58
  # @raise [MalformedAction] if the action is missing expected attributes.
59
59
  def process_action(action)
data/pom.xml ADDED
@@ -0,0 +1,402 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3
+ <modelVersion>4.0.0</modelVersion>
4
+ <properties>
5
+ <awssdk.version>2.25.64</awssdk.version>
6
+ <kcl.version>3.0.0</kcl.version>
7
+ <netty.version>4.1.108.Final</netty.version>
8
+ <netty-reactive.version>2.0.6</netty-reactive.version>
9
+ <fasterxml-jackson.version>2.13.5</fasterxml-jackson.version>
10
+ <logback.version>1.3.14</logback.version>
11
+ </properties>
12
+ <dependencies>
13
+ <dependency>
14
+ <groupId>software.amazon.kinesis</groupId>
15
+ <artifactId>amazon-kinesis-client-multilang</artifactId>
16
+ <version>${kcl.version}</version>
17
+ </dependency>
18
+ <dependency>
19
+ <groupId>software.amazon.kinesis</groupId>
20
+ <artifactId>amazon-kinesis-client</artifactId>
21
+ <version>${kcl.version}</version>
22
+ </dependency>
23
+ <dependency>
24
+ <groupId>software.amazon.awssdk</groupId>
25
+ <artifactId>kinesis</artifactId>
26
+ <version>${awssdk.version}</version>
27
+ </dependency>
28
+ <dependency>
29
+ <groupId>software.amazon.awssdk</groupId>
30
+ <artifactId>dynamodb</artifactId>
31
+ <version>${awssdk.version}</version>
32
+ </dependency>
33
+ <!-- https://mvnrepository.com/artifact/software.amazon.awssdk/dynamodb-enhanced -->
34
+ <dependency>
35
+ <groupId>software.amazon.awssdk</groupId>
36
+ <artifactId>dynamodb-enhanced</artifactId>
37
+ <version>${awssdk.version}</version>
38
+ </dependency>
39
+ <!-- https://mvnrepository.com/artifact/com.amazonaws/dynamodb-lock-client -->
40
+ <dependency>
41
+ <groupId>com.amazonaws</groupId>
42
+ <artifactId>dynamodb-lock-client</artifactId>
43
+ <version>1.3.0</version>
44
+ </dependency>
45
+ <dependency>
46
+ <groupId>software.amazon.awssdk</groupId>
47
+ <artifactId>cloudwatch</artifactId>
48
+ <version>${awssdk.version}</version>
49
+ </dependency>
50
+ <dependency>
51
+ <groupId>software.amazon.awssdk</groupId>
52
+ <artifactId>netty-nio-client</artifactId>
53
+ <version>${awssdk.version}</version>
54
+ </dependency>
55
+ <dependency>
56
+ <groupId>software.amazon.awssdk</groupId>
57
+ <artifactId>metrics-spi</artifactId>
58
+ <version>${awssdk.version}</version>
59
+ </dependency>
60
+ <dependency>
61
+ <groupId>software.amazon.awssdk</groupId>
62
+ <artifactId>sts</artifactId>
63
+ <version>${awssdk.version}</version>
64
+ </dependency>
65
+ <dependency>
66
+ <groupId>software.amazon.awssdk</groupId>
67
+ <artifactId>protocol-core</artifactId>
68
+ <version>${awssdk.version}</version>
69
+ </dependency>
70
+ <dependency>
71
+ <groupId>software.amazon.awssdk</groupId>
72
+ <artifactId>aws-query-protocol</artifactId>
73
+ <version>${awssdk.version}</version>
74
+ </dependency>
75
+ <dependency>
76
+ <groupId>software.amazon.awssdk</groupId>
77
+ <artifactId>aws-cbor-protocol</artifactId>
78
+ <version>${awssdk.version}</version>
79
+ </dependency>
80
+ <dependency>
81
+ <groupId>software.amazon.awssdk</groupId>
82
+ <artifactId>aws-json-protocol</artifactId>
83
+ <version>${awssdk.version}</version>
84
+ </dependency>
85
+ <dependency>
86
+ <groupId>software.amazon.awssdk</groupId>
87
+ <artifactId>json-utils</artifactId>
88
+ <version>${awssdk.version}</version>
89
+ </dependency>
90
+ <dependency>
91
+ <groupId>software.amazon.awssdk</groupId>
92
+ <artifactId>third-party-jackson-core</artifactId>
93
+ <version>${awssdk.version}</version>
94
+ </dependency>
95
+ <dependency>
96
+ <groupId>software.amazon.awssdk</groupId>
97
+ <artifactId>third-party-jackson-dataformat-cbor</artifactId>
98
+ <version>${awssdk.version}</version>
99
+ </dependency>
100
+ <dependency>
101
+ <groupId>software.amazon.awssdk</groupId>
102
+ <artifactId>profiles</artifactId>
103
+ <version>${awssdk.version}</version>
104
+ </dependency>
105
+ <dependency>
106
+ <groupId>software.amazon.awssdk</groupId>
107
+ <artifactId>sdk-core</artifactId>
108
+ <version>${awssdk.version}</version>
109
+ </dependency>
110
+ <dependency>
111
+ <groupId>software.amazon.awssdk</groupId>
112
+ <artifactId>aws-core</artifactId>
113
+ <version>${awssdk.version}</version>
114
+ </dependency>
115
+ <dependency>
116
+ <groupId>software.amazon.awssdk</groupId>
117
+ <artifactId>endpoints-spi</artifactId>
118
+ <version>${awssdk.version}</version>
119
+ </dependency>
120
+ <dependency>
121
+ <groupId>software.amazon.awssdk</groupId>
122
+ <artifactId>auth</artifactId>
123
+ <version>${awssdk.version}</version>
124
+ </dependency>
125
+ <dependency>
126
+ <groupId>software.amazon.awssdk</groupId>
127
+ <artifactId>http-client-spi</artifactId>
128
+ <version>${awssdk.version}</version>
129
+ </dependency>
130
+ <dependency>
131
+ <groupId>software.amazon.awssdk</groupId>
132
+ <artifactId>regions</artifactId>
133
+ <version>${awssdk.version}</version>
134
+ </dependency>
135
+ <dependency>
136
+ <groupId>software.amazon.awssdk</groupId>
137
+ <artifactId>annotations</artifactId>
138
+ <version>${awssdk.version}</version>
139
+ </dependency>
140
+ <dependency>
141
+ <groupId>software.amazon.awssdk</groupId>
142
+ <artifactId>utils</artifactId>
143
+ <version>${awssdk.version}</version>
144
+ </dependency>
145
+ <dependency>
146
+ <groupId>software.amazon.awssdk</groupId>
147
+ <artifactId>apache-client</artifactId>
148
+ <version>${awssdk.version}</version>
149
+ </dependency>
150
+ <dependency>
151
+ <groupId>software.amazon.awssdk</groupId>
152
+ <artifactId>arns</artifactId>
153
+ <version>${awssdk.version}</version>
154
+ </dependency>
155
+ <dependency>
156
+ <groupId>software.amazon.awssdk</groupId>
157
+ <artifactId>http-auth-spi</artifactId>
158
+ <version>${awssdk.version}</version>
159
+ </dependency>
160
+ <dependency>
161
+ <groupId>software.amazon.awssdk</groupId>
162
+ <artifactId>http-auth</artifactId>
163
+ <version>${awssdk.version}</version>
164
+ </dependency>
165
+ <dependency>
166
+ <groupId>software.amazon.awssdk</groupId>
167
+ <artifactId>http-auth-aws</artifactId>
168
+ <version>${awssdk.version}</version>
169
+ </dependency>
170
+ <dependency>
171
+ <groupId>software.amazon.awssdk</groupId>
172
+ <artifactId>checksums-spi</artifactId>
173
+ <version>${awssdk.version}</version>
174
+ </dependency>
175
+ <dependency>
176
+ <groupId>software.amazon.awssdk</groupId>
177
+ <artifactId>checksums</artifactId>
178
+ <version>${awssdk.version}</version>
179
+ </dependency>
180
+ <dependency>
181
+ <groupId>software.amazon.awssdk</groupId>
182
+ <artifactId>identity-spi</artifactId>
183
+ <version>${awssdk.version}</version>
184
+ </dependency>
185
+ <dependency>
186
+ <groupId>io.netty</groupId>
187
+ <artifactId>netty-codec-http</artifactId>
188
+ <version>${netty.version}</version>
189
+ </dependency>
190
+ <dependency>
191
+ <groupId>io.netty</groupId>
192
+ <artifactId>netty-codec-http2</artifactId>
193
+ <version>${netty.version}</version>
194
+ </dependency>
195
+ <dependency>
196
+ <groupId>io.netty</groupId>
197
+ <artifactId>netty-codec</artifactId>
198
+ <version>${netty.version}</version>
199
+ </dependency>
200
+ <dependency>
201
+ <groupId>io.netty</groupId>
202
+ <artifactId>netty-transport</artifactId>
203
+ <version>${netty.version}</version>
204
+ </dependency>
205
+ <dependency>
206
+ <groupId>io.netty</groupId>
207
+ <artifactId>netty-resolver</artifactId>
208
+ <version>${netty.version}</version>
209
+ </dependency>
210
+ <dependency>
211
+ <groupId>io.netty</groupId>
212
+ <artifactId>netty-common</artifactId>
213
+ <version>${netty.version}</version>
214
+ </dependency>
215
+ <dependency>
216
+ <groupId>io.netty</groupId>
217
+ <artifactId>netty-buffer</artifactId>
218
+ <version>${netty.version}</version>
219
+ </dependency>
220
+ <dependency>
221
+ <groupId>io.netty</groupId>
222
+ <artifactId>netty-handler</artifactId>
223
+ <version>${netty.version}</version>
224
+ </dependency>
225
+ <dependency>
226
+ <groupId>io.netty</groupId>
227
+ <artifactId>netty-transport-native-epoll</artifactId>
228
+ <version>${netty.version}</version>
229
+ </dependency>
230
+ <dependency>
231
+ <groupId>io.netty</groupId>
232
+ <artifactId>netty-transport-native-unix-common</artifactId>
233
+ <version>${netty.version}</version>
234
+ </dependency>
235
+ <dependency>
236
+ <groupId>com.typesafe.netty</groupId>
237
+ <artifactId>netty-reactive-streams-http</artifactId>
238
+ <version>${netty-reactive.version}</version>
239
+ </dependency>
240
+ <dependency>
241
+ <groupId>com.typesafe.netty</groupId>
242
+ <artifactId>netty-reactive-streams</artifactId>
243
+ <version>${netty-reactive.version}</version>
244
+ </dependency>
245
+ <dependency>
246
+ <groupId>org.reactivestreams</groupId>
247
+ <artifactId>reactive-streams</artifactId>
248
+ <version>1.0.3</version>
249
+ </dependency>
250
+ <dependency>
251
+ <groupId>com.google.guava</groupId>
252
+ <artifactId>guava</artifactId>
253
+ <version>32.1.1-jre</version>
254
+ </dependency>
255
+ <dependency>
256
+ <groupId>com.google.code.findbugs</groupId>
257
+ <artifactId>jsr305</artifactId>
258
+ <version>3.0.2</version>
259
+ </dependency>
260
+ <dependency>
261
+ <groupId>org.checkerframework</groupId>
262
+ <artifactId>checker-qual</artifactId>
263
+ <version>2.5.2</version>
264
+ </dependency>
265
+ <dependency>
266
+ <groupId>com.google.errorprone</groupId>
267
+ <artifactId>error_prone_annotations</artifactId>
268
+ <version>2.7.1</version>
269
+ </dependency>
270
+ <dependency>
271
+ <groupId>com.google.j2objc</groupId>
272
+ <artifactId>j2objc-annotations</artifactId>
273
+ <version>1.3</version>
274
+ </dependency>
275
+ <dependency>
276
+ <groupId>org.codehaus.mojo</groupId>
277
+ <artifactId>animal-sniffer-annotations</artifactId>
278
+ <version>1.20</version>
279
+ </dependency>
280
+ <dependency>
281
+ <groupId>com.google.protobuf</groupId>
282
+ <artifactId>protobuf-java</artifactId>
283
+ <version>4.27.5</version>
284
+ </dependency>
285
+ <dependency>
286
+ <groupId>org.apache.commons</groupId>
287
+ <artifactId>commons-lang3</artifactId>
288
+ <version>3.14.0</version>
289
+ </dependency>
290
+ <dependency>
291
+ <groupId>org.slf4j</groupId>
292
+ <artifactId>slf4j-api</artifactId>
293
+ <version>2.0.13</version>
294
+ </dependency>
295
+ <dependency>
296
+ <groupId>io.reactivex.rxjava3</groupId>
297
+ <artifactId>rxjava</artifactId>
298
+ <version>3.1.8</version>
299
+ </dependency>
300
+ <dependency>
301
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
302
+ <artifactId>jackson-dataformat-cbor</artifactId>
303
+ <version>${fasterxml-jackson.version}</version>
304
+ </dependency>
305
+ <dependency>
306
+ <groupId>com.fasterxml.jackson.core</groupId>
307
+ <artifactId>jackson-core</artifactId>
308
+ <version>${fasterxml-jackson.version}</version>
309
+ </dependency>
310
+ <dependency>
311
+ <groupId>com.fasterxml.jackson.core</groupId>
312
+ <artifactId>jackson-databind</artifactId>
313
+ <version>${fasterxml-jackson.version}</version>
314
+ </dependency>
315
+ <dependency>
316
+ <groupId>com.fasterxml.jackson.core</groupId>
317
+ <artifactId>jackson-annotations</artifactId>
318
+ <version>${fasterxml-jackson.version}</version>
319
+ </dependency>
320
+ <dependency>
321
+ <groupId>software.amazon</groupId>
322
+ <artifactId>flow</artifactId>
323
+ <version>1.7</version>
324
+ </dependency>
325
+ <dependency>
326
+ <groupId>org.apache.httpcomponents</groupId>
327
+ <artifactId>httpclient</artifactId>
328
+ <version>4.5.13</version>
329
+ </dependency>
330
+ <dependency>
331
+ <groupId>commons-codec</groupId>
332
+ <artifactId>commons-codec</artifactId>
333
+ <version>1.15</version>
334
+ </dependency>
335
+ <dependency>
336
+ <groupId>org.apache.httpcomponents</groupId>
337
+ <artifactId>httpcore</artifactId>
338
+ <version>4.4.15</version>
339
+ </dependency>
340
+ <dependency>
341
+ <groupId>com.amazon.ion</groupId>
342
+ <artifactId>ion-java</artifactId>
343
+ <version>1.11.4</version>
344
+ </dependency>
345
+ <dependency>
346
+ <groupId>software.amazon.glue</groupId>
347
+ <artifactId>schema-registry-serde</artifactId>
348
+ <version>1.1.19</version>
349
+ <exclusions>
350
+ <exclusion>
351
+ <groupId>com.amazonaws</groupId>
352
+ <artifactId>aws-java-sdk-sts</artifactId>
353
+ </exclusion>
354
+ </exclusions>
355
+ </dependency>
356
+ <dependency>
357
+ <groupId>joda-time</groupId>
358
+ <artifactId>joda-time</artifactId>
359
+ <version>2.10.13</version>
360
+ </dependency>
361
+ <dependency>
362
+ <groupId>ch.qos.logback</groupId>
363
+ <artifactId>logback-classic</artifactId>
364
+ <version>${logback.version}</version>
365
+ </dependency>
366
+ <dependency>
367
+ <groupId>ch.qos.logback</groupId>
368
+ <artifactId>logback-core</artifactId>
369
+ <version>${logback.version}</version>
370
+ </dependency>
371
+ <dependency>
372
+ <groupId>com.beust</groupId>
373
+ <artifactId>jcommander</artifactId>
374
+ <version>1.82</version>
375
+ </dependency>
376
+ <dependency>
377
+ <groupId>commons-io</groupId>
378
+ <artifactId>commons-io</artifactId>
379
+ <version>2.16.1</version>
380
+ </dependency>
381
+ <dependency>
382
+ <groupId>commons-logging</groupId>
383
+ <artifactId>commons-logging</artifactId>
384
+ <version>1.1.3</version>
385
+ </dependency>
386
+ <dependency>
387
+ <groupId>org.apache.commons</groupId>
388
+ <artifactId>commons-collections4</artifactId>
389
+ <version>4.4</version>
390
+ </dependency>
391
+ <dependency>
392
+ <groupId>commons-beanutils</groupId>
393
+ <artifactId>commons-beanutils</artifactId>
394
+ <version>1.9.4</version>
395
+ </dependency>
396
+ <dependency>
397
+ <groupId>commons-collections</groupId>
398
+ <artifactId>commons-collections</artifactId>
399
+ <version>3.2.2</version>
400
+ </dependency>
401
+ </dependencies>
402
+ </project>
@@ -27,66 +27,124 @@ module Aws::KCLrb
27
27
  end
28
28
  end
29
29
 
30
- def shutdown(checkpointer, reason)
31
- checkpointer.checkpoint if reason == 'TERMINATE'
30
+ def shutdown_requested(checkpointer)
31
+ checkpointer.checkpoint
32
32
  end
33
33
  end
34
34
 
35
+ class TestRecordProcessorV2 < Aws::KCLrb::V2::RecordProcessorBase
36
+
37
+ def init_processor(shard_id)
38
+ # no-op
39
+ end
40
+
41
+ def shutdown_requested(shutdown_requested_input)
42
+ shutdown_requested_input.checkpointer.checkpoint
43
+ end
44
+
45
+ def process_records(process_records_input)
46
+ last_seq = nil
47
+ records = process_records_input.records
48
+ records.each do |record|
49
+ last_seq = record['sequenceNumber']
50
+ end
51
+
52
+ if last_seq
53
+ checkpointer = process_records_input.checkpointer
54
+ begin
55
+ checkpointer.checkpoint(last_seq)
56
+ rescue CheckpointError => cpe
57
+ if cpe.value == 'ThrottlingException'
58
+ checkpointer.checkpoint(last_seq)
59
+ else
60
+ raise
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ end
67
+
35
68
  describe KCLProcess do
36
- describe "#run" do
37
- it "should respond to each action by invoking the corresponding processor's method and write a status message to the output IO" do
38
- input_specs = [
39
- {:method => :init_processor, :action => 'initialize', :input => '{"action":"initialize","shardId":"shard-000001"}'},
40
- {:method => :process_records, :action => 'processRecords', :input => '{"action":"processRecords","records":[]}'},
41
- {:method => :shutdown, :action => 'shutdown', :input => '{"action":"shutdown","reason":"TERMINATE"}'},
42
- ]
43
- # pick any of the actions randomly to avoid writing a test for each
44
- input_spec = input_specs.sample
45
- processor = double(RecordProcessorBase)
46
- expect(processor).to receive(input_spec[:method]).once
47
- input = StringIO.new(input_spec[:input])
69
+
70
+ input_specs = [
71
+ {:method => :init_processor, :action => 'initialize', :input => '{"action":"initialize","shardId":"shard-000001","sequenceNumber":123456789}'},
72
+ {:method => :process_records, :action => 'processRecords', :input => '{"action":"processRecords","records":[],"millisBehindLatest":0}'},
73
+ {:method => :shutdown, :action => 'shutdownRequested', :input => '{"action":"shutdownRequested","reason":"TERMINATE"}'}
74
+ ]
75
+ versions = [1, 2]
76
+
77
+ describe "#action_response" do
78
+
79
+ before(:each) do
80
+ @processor = double(RecordProcessorBase)
81
+ end
82
+
83
+ input_specs.each do |input_spec|
84
+ versions.each do |version|
85
+ it "V#{version} should respond to #{input_spec[:method]} action by invoking the corresponding processor's method and write a status message to the output IO" do
86
+ allow(@processor).to receive(:version).and_return(version)
87
+ action_response_common_test(input_spec[:method], input_spec[:action], input_spec[:input], version)
88
+ end
89
+ end
90
+ end
91
+
92
+ def action_response_common_test(method, action, input, version)
93
+ if method == :shutdown
94
+ expected_shutdown_input = version == 1 ? Aws::KCLrb::CheckpointerImpl : Aws::KCLrb::V2::ShutdownRequestedInput
95
+ allow(@processor).to receive(:shutdown_requested).with(expected_shutdown_input).and_return(nil)
96
+ else
97
+ expect(@processor).to receive(method).once
98
+ end
99
+ input = StringIO.new(input)
48
100
  output = StringIO.new
49
101
  error = StringIO.new
50
- driver = KCLProcess.new(processor, input, output, error)
102
+ driver = KCLProcess.new(@processor, input, output, error)
51
103
  driver.run
52
104
 
53
- expected_output = %Q[{"action":"status","responseFor":"#{input_spec[:action]}"}]
54
- expect( output.string.gsub(/\s+/, "") ).to eq(expected_output.gsub(/\s+/, ""))
55
- expect( error.string ).to eq("")
56
- expect( input.eof? ).to eq(true)
105
+ expected_output = %Q[{"action":"status","responseFor":"#{action}"}]
106
+ expect(output.string.gsub(/\s+/, "")).to eq(expected_output.gsub(/\s+/, ""))
107
+ expect(error.string).to eq("")
108
+ expect(input.eof?).to eq(true)
57
109
  end
58
- it "should process a normal stream of actions and produce expected output" do
59
- input_string = <<-INPUT
60
- {"action":"initialize","shardId":"shardId-123"}
61
- {"action":"processRecords","records":[{"data":"bWVvdw==","partitionKey":"cat","sequenceNumber":"456"}]}
110
+
111
+ end
112
+
113
+ describe "#run" do
114
+ versions.each do |version|
115
+ it "V#{version} should process a normal stream of actions and produce expected output" do
116
+ input_string = <<-INPUT
117
+ {"action":"initialize","shardId":"shardId-123","sequenceNumber":123}
118
+ {"action":"processRecords","records":[{"data":"bWVvdw==","partitionKey":"cat","sequenceNumber":"456"}],"millisBehindLatest":"0"}
62
119
  {"action":"checkpoint","sequenceNumber":"456","error":"ThrottlingException"}
63
120
  {"action":"checkpoint","sequenceNumber":"456"}
64
- {"action":"shutdown","reason":"TERMINATE"}
121
+ {"action":"shutdownRequested","reason":"TERMINATE"}
65
122
  {"action":"checkpoint","sequenceNumber":"456"}
66
- INPUT
123
+ INPUT
67
124
 
68
- # NOTE: The first checkpoint is expected to fail
69
- # with a ThrottlingException and hence the
70
- # retry.
71
- expected_output_string = <<-OUTPUT
125
+ # NOTE: The first checkpoint is expected to fail
126
+ # with a ThrottlingException and hence the
127
+ # retry.
128
+ expected_output_string = <<-OUTPUT
72
129
  {"action":"status","responseFor":"initialize"}
73
130
  {"action":"checkpoint","sequenceNumber":"456"}
74
131
  {"action":"checkpoint","sequenceNumber":"456"}
75
132
  {"action":"status","responseFor":"processRecords"}
76
133
  {"action":"checkpoint","sequenceNumber":null}
77
- {"action":"status","responseFor":"shutdown"}
78
- OUTPUT
79
- processor = TestRecordProcessor.new
80
- input = StringIO.new(input_string)
81
- output = StringIO.new
82
- error = StringIO.new
83
- driver = KCLProcess.new(processor, input, output, error)
84
- driver.run
134
+ {"action":"status","responseFor":"shutdownRequested"}
135
+ OUTPUT
136
+ processor = version == 1 ? TestRecordProcessor.new : TestRecordProcessorV2.new
137
+ input = StringIO.new(input_string)
138
+ output = StringIO.new
139
+ error = StringIO.new
140
+ driver = KCLProcess.new(processor, input, output, error)
141
+ driver.run
85
142
 
86
- # outputs should be same modulo some whitespaces
87
- expect( output.string.gsub(/\s+/, "") ).to eq(expected_output_string.gsub(/\s+/, ""))
88
- expect( error.string ).to eq("")
89
- expect( input.eof? ).to eq(true)
143
+ # outputs should be same modulo some whitespaces
144
+ expect( output.string.gsub(/\s+/, "") ).to eq(expected_output_string.gsub(/\s+/, ""))
145
+ expect( error.string ).to eq("")
146
+ expect( input.eof? ).to eq(true)
147
+ end
90
148
  end
91
149
  end
92
150
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-kclrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-13 00:00:00.000000000 Z
11
+ date: 2024-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -24,8 +24,36 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description: A ruby interface for the Amazon Kinesis Client Library MultiLangDaemon
28
- email:
56
+ email:
29
57
  executables: []
30
58
  extensions: []
31
59
  extra_rdoc_files: []
@@ -42,6 +70,7 @@ files:
42
70
  - lib/aws/kclrb/kcl_process.rb
43
71
  - lib/aws/kclrb/messages.rb
44
72
  - lib/aws/kclrb/record_processor.rb
73
+ - pom.xml
45
74
  - spec/checkpointer_spec.rb
46
75
  - spec/io_proxy_spec.rb
47
76
  - spec/kcl_process_spec.rb
@@ -50,7 +79,7 @@ homepage: http://github.com/aws/amazon-kinesis-client-ruby
50
79
  licenses:
51
80
  - Apache-2.0
52
81
  metadata: {}
53
- post_install_message:
82
+ post_install_message:
54
83
  rdoc_options: []
55
84
  require_paths:
56
85
  - lib
@@ -65,8 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
94
  - !ruby/object:Gem::Version
66
95
  version: '0'
67
96
  requirements: []
68
- rubygems_version: 3.3.11
69
- signing_key:
97
+ rubygems_version: 3.0.3.1
98
+ signing_key:
70
99
  specification_version: 4
71
100
  summary: Amazon Kinesis Client Library for Ruby
72
101
  test_files: []