-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Agent extensions library, plus data pre-processing extension support (#…
…11) * Add amazon-kinesis-agent-extension dependency. Add gitignore file. * Add data conversion functionality to parser classes. * Implement converter test. * Fix example converter class name. * Fix build scripts (setup and ant). * Add script to manually run Kinesis Agent on older Linux versions. Add script to read N records from the stream, basically simplification for aws cli kinesis commands. Update Agent config with "initialPosition" options. * Fix K Stream reader script. * Better output for K Stream reader script * Fix K Agent manual runner: remove JAVA library directory from classpath.
- Loading branch information
Showing
14 changed files
with
348 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
amazon-kinesis-agent.iml | ||
target |
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,21 @@ | ||
#!/bin/bash | ||
|
||
# Log files are in /var/log/aws-kinesis-agent/ | ||
|
||
JAVA_START_HEAP="256m" | ||
JAVA_MAX_HEAP="512m" | ||
|
||
JAVA_DIR="/usr/share/java" | ||
LIB_DIR="/usr/share/aws-kinesis-agent/lib" | ||
#CLASSPATH="$JAVA_DIR"/*:"$LIB_DIR":$(find "$LIB_DIR" -type f -name \*.jar | paste -s -d:):"$CLASSPATH" | ||
CLASSPATH="$LIB_DIR":$(find "$LIB_DIR" -type f -name \*.jar | paste -s -d:):"$CLASSPATH" | ||
|
||
JAVACMD="java" | ||
JVM_ARGS="-server -Xms${JAVA_START_HEAP} -Xmx${JAVA_MAX_HEAP} $JVM_ARGS" | ||
|
||
MAIN_CLASS="com.amazon.kinesis.streaming.agent.Agent" | ||
|
||
exec $JAVACMD $JVM_ARGS \ | ||
-cp "$CLASSPATH" \ | ||
$MAIN_CLASS "$@" | ||
|
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,54 @@ | ||
#!/bin/bash | ||
|
||
# Stream name parameter (mandatory) | ||
streamName="$1" | ||
if [ -z "$streamName" ]; then | ||
echo "Usage: $0 <stream-name> [latest records number to display]" | ||
exit 1 | ||
fi | ||
|
||
# Records number to return parameter (optional, default 10) | ||
recordsNumber=$2 | ||
if [ -z $recordsNumber ]; then | ||
recordsNumber=10 | ||
fi | ||
recordsNumber=$(( recordsNumber )) | ||
|
||
iteratorType="LATEST" | ||
iteratorType="TRIM_HORIZON" | ||
|
||
# Get shard ID, first shard in the list | ||
shardId=$(aws kinesis describe-stream \ | ||
--stream-name $streamName | grep SHARDS | awk '{print $2}') | ||
if [ -z "$shardId" ]; then | ||
echo "Shard not found: [$shardId]" | ||
exit 2 | ||
fi | ||
|
||
# Get shard iterator for latest entries | ||
shardIter=$(aws kinesis get-shard-iterator \ | ||
--stream-name "$streamName" \ | ||
--shard-id "$shardId" \ | ||
--shard-iterator-type "$iteratorType") | ||
|
||
# Read latest records | ||
tmpFile=$(mktemp) | ||
kMaxReadDepth=1 | ||
kRecordsRead=0 | ||
while [ $kRecordsRead -lt $recordsNumber ] && [ $kMaxReadDepth -gt 0 ]; do | ||
aws kinesis get-records --shard-iterator "$shardIter" --limit $recordsNumber > "$tmpFile" | ||
foundRowsNum=$(cat "$tmpFile" | awk 'NR==1{print $1; exit}') | ||
shardIter=$(cat "$tmpFile" | awk 'NR==1{print $2; exit}') | ||
cat "$tmpFile" | awk '{print $3}' | while read line; do | ||
echo "" | ||
echo -n ">> $kRecordsRead: " | ||
echo $line | base64 --decode | ||
kRecordsRead=$(( kRecordsRead + 1 )) | ||
done | ||
kMaxReadDepth=$(( kMaxReadDepth - 1 )) | ||
done | ||
|
||
rm -f "$tmpFile" | ||
|
||
echo "" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"checkpointFile": "/tmp/aws-kinesis-agent-checkpoints/main.log", | ||
"cloudwatch.emitMetrics": true, | ||
"cloudwatch.endpoint": "https://monitoring.us-west-2.amazonaws.com", | ||
"kinesis.endpoint": "https://kinesis.us-west-2.amazonaws.com", | ||
"awsAccessKeyId": "ACCESSKEY", | ||
"awsSecretAccessKey": "SECRETKEY", | ||
"flows": [ | ||
{ | ||
"filePattern": "/tmp/aws-kinesis-agent-test1.log*", | ||
"initialPosition": "END_OF_FILE", | ||
"kinesisStream": "aws-kinesis-agent-test1", | ||
"converterClass": "com.amazon.kinesis.streaming.agent.extension.BracketsDataConverter" | ||
}, | ||
{ | ||
"filePattern": "/tmp/aws-kinesis-agent-test2.log*", | ||
"initialPosition": "START_OF_FILE", | ||
"kinesisStream": "aws-kinesis-agent-test2" | ||
} | ||
] | ||
} |
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
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.