-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Update cloudEventExample and add QoL changes"
- Loading branch information
Showing
9 changed files
with
1,976 additions
and
1,228 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
docker-compose/cloudEventProducer/cloudEventProducerForDockerCompose.sh
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,44 @@ | ||
#! /bin/bash | ||
# | ||
# ============LICENSE_START======================================================= | ||
# Copyright (C) 2024 Ericsson | ||
# Modifications Copyright (C) 2024 OpenInfra Foundation Europe | ||
# ================================================================================ | ||
# Licensed 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. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# ============LICENSE_END========================================================= | ||
# | ||
KAFKA_NAMESPACE="${1:-teiv}" | ||
KAFKA_TOPIC="${2:-topology-inventory-ingestion}" | ||
KAFKA_POD_NAME="${3:-kafka-0}" | ||
FILE_DUPLICATION_FACTOR="${4:-1}" # How many times to use the same CloudEvent file | ||
FOLDER_OF_CLOUDEVENTS="${5:-/events}" # All files in this folder are written to kafka | ||
# number of generated files == number of files in the $FOLDER_OF_CLOUDEVENTS * $FILE_DUPLICATION_FACTOR | ||
|
||
echo "Producing messages to Kafka topic '$KAFKA_TOPIC'..." | ||
|
||
# Loop to produce multiple messages | ||
for ((i=0; i<$FILE_DUPLICATION_FACTOR; i++)); do | ||
for file in "$FOLDER_OF_CLOUDEVENTS"/*; do | ||
if [ -f "$file" ]; then | ||
# Replace the new line characters with a space and write to kafka | ||
sed ':a;N;$!ba;s/\n/ /g' "$file" | \ | ||
kafka-console-producer --broker-list kafka:9092 --topic "$KAFKA_TOPIC" \ | ||
--property parse.headers=true --property headers.key.separator=::: --property headers.delimiter=,,, --property parse.key=false | ||
fi | ||
done | ||
echo "$((i+1))/$FILE_DUPLICATION_FACTOR rounds completed" | ||
done | ||
|
||
echo "Message production completed." |
Oops, something went wrong.