-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address race condition in lambda processor and threading issues in la…
…mbda sink Signed-off-by: Srikanth Govindarajan <[email protected]>
- Loading branch information
1 parent
62110de
commit 430af31
Showing
14 changed files
with
380 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
236 changes: 141 additions & 95 deletions
236
...da/src/main/java/org/opensearch/dataprepper/plugins/lambda/processor/LambdaProcessor.java
Large diffs are not rendered by default.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
...a/src/main/java/org/opensearch/dataprepper/plugins/lambda/processor/PayloadValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.opensearch.dataprepper.plugins.lambda.processor; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import software.amazon.awssdk.core.SdkBytes; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public class PayloadValidator { | ||
private static final ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
public static InputStream validateAndGetInputStream(SdkBytes payload) throws IOException { | ||
JsonNode jsonNode = objectMapper.readTree(payload.asByteArray()); | ||
|
||
if (!jsonNode.isArray()) { | ||
throw new IllegalArgumentException("Payload must be a JSON array"); | ||
} | ||
|
||
return new ByteArrayInputStream(payload.asByteArray()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.