From 06fab149a3dd72880c7e67bdd80e86010e48d745 Mon Sep 17 00:00:00 2001 From: Vinayak Date: Tue, 15 Dec 2020 19:31:04 -0800 Subject: [PATCH 1/2] Added new event response for custom checkpointing --- .../runtime/events/StreamsEventResponse.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/StreamsEventResponse.java diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/StreamsEventResponse.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/StreamsEventResponse.java new file mode 100644 index 00000000..a1c87e1a --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/StreamsEventResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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. + */ + +package com.amazonaws.services.lambda.runtime.events; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(setterPrefix = "with") +public class StreamsEventResponse implements Serializable { + private static final long serialVersionUID = 3232053116472095907L; + + private List batchItemFailures; + + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder(setterPrefix = "with") + public static class BatchItemFailure implements Serializable { + private static final long serialVersionUID = 1473983466096085881L; + + String itemIdentifier; + } +} From 838b64a2211fea61603a47064ea6353234a3ff7a Mon Sep 17 00:00:00 2001 From: Vinayak Date: Tue, 15 Dec 2020 19:31:27 -0800 Subject: [PATCH 2/2] Added new event structures for stream analytics --- .../events/DynamodbTimeWindowEvent.java | 57 +++++++++++++++++++ .../events/KinesisTimeWindowEvent.java | 57 +++++++++++++++++++ .../events/TimeWindowEventResponse.java | 44 ++++++++++++++ .../runtime/events/models/TimeWindow.java | 28 +++++++++ 4 files changed, 186 insertions(+) create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbTimeWindowEvent.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisTimeWindowEvent.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/TimeWindowEventResponse.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/TimeWindow.java diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbTimeWindowEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbTimeWindowEvent.java new file mode 100644 index 00000000..9ced57bb --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbTimeWindowEvent.java @@ -0,0 +1,57 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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. + */ + +package com.amazonaws.services.lambda.runtime.events; + +import com.amazonaws.services.lambda.runtime.events.models.TimeWindow; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class DynamodbTimeWindowEvent extends DynamodbEvent implements Serializable, Cloneable { + + private static final long serialVersionUID = -5449871161108629510L; + + private TimeWindow window; + private Map state; + private String shardId; + private String eventSourceArn; + private Boolean isFinalInvokeForWindow; + private Boolean isWindowTerminatedEarly; + + @Builder(setterPrefix = "with") + public DynamodbTimeWindowEvent( + final List records, + final TimeWindow window, + final Map state, + final String shardId, + final String eventSourceArn, + final Boolean isFinalInvokeForWindow, + final Boolean isWindowTerminatedEarly) { + this.setRecords(records); + this.window = window; + this.state = state; + this.shardId = shardId; + this.eventSourceArn = eventSourceArn; + this.isFinalInvokeForWindow = isFinalInvokeForWindow; + this.isWindowTerminatedEarly = isWindowTerminatedEarly; + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisTimeWindowEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisTimeWindowEvent.java new file mode 100644 index 00000000..0b047cad --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisTimeWindowEvent.java @@ -0,0 +1,57 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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. + */ + +package com.amazonaws.services.lambda.runtime.events; + +import com.amazonaws.services.lambda.runtime.events.models.TimeWindow; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class KinesisTimeWindowEvent extends KinesisEvent implements Serializable, Cloneable { + + private static final long serialVersionUID = 8926430039233062266L; + + private TimeWindow window; + private Map state; + private String shardId; + private String eventSourceArn; + private Boolean isFinalInvokeForWindow; + private Boolean isWindowTerminatedEarly; + + @Builder(setterPrefix = "with") + public KinesisTimeWindowEvent( + final List records, + final TimeWindow window, + final Map state, + final String shardId, + final String eventSourceArn, + final Boolean isFinalInvokeForWindow, + final Boolean isWindowTerminatedEarly) { + this.setRecords(records); + this.window = window; + this.state = state; + this.shardId = shardId; + this.eventSourceArn = eventSourceArn; + this.isFinalInvokeForWindow = isFinalInvokeForWindow; + this.isWindowTerminatedEarly = isWindowTerminatedEarly; + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/TimeWindowEventResponse.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/TimeWindowEventResponse.java new file mode 100644 index 00000000..c4f162d1 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/TimeWindowEventResponse.java @@ -0,0 +1,44 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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. + */ + +package com.amazonaws.services.lambda.runtime.events; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder(setterPrefix = "with") +public class TimeWindowEventResponse implements Serializable { + private static final long serialVersionUID = 2259096191791166028L; + + private Map state; + private List batchItemFailures; + + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder(setterPrefix = "with") + public static class BatchItemFailure implements Serializable { + private static final long serialVersionUID = 5224634072234167773L; + + String itemIdentifier; + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/TimeWindow.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/TimeWindow.java new file mode 100644 index 00000000..e0d2036e --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/TimeWindow.java @@ -0,0 +1,28 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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. + */ + +package com.amazonaws.services.lambda.runtime.events.models; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder(setterPrefix = "with") +@NoArgsConstructor +@AllArgsConstructor +public class TimeWindow { + private String start; + private String end; +}