From 94f144b65f2d4552e3500806da4abb5144a5bfdb Mon Sep 17 00:00:00 2001 From: asim Date: Tue, 21 Jan 2025 22:17:07 +0530 Subject: [PATCH 1/2] add REPLICATION parameter to Cassandra schema creation script for multi datacenter support Signed-off-by: asim --- plugin/storage/cassandra/schema/create.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plugin/storage/cassandra/schema/create.sh b/plugin/storage/cassandra/schema/create.sh index a8b67f34c02..a43a4d9af9c 100755 --- a/plugin/storage/cassandra/schema/create.sh +++ b/plugin/storage/cassandra/schema/create.sh @@ -14,6 +14,7 @@ function usage { >&2 echo " TRACE_TTL - time to live for trace data, in seconds (default: 172800, 2 days)" >&2 echo " DEPENDENCIES_TTL - time to live for dependencies data, in seconds (default: 0, no TTL)" >&2 echo " KEYSPACE - keyspace (default: jaeger_v1_{datacenter})" + >&2 echo " REPLICATION - complete replication configuration (overrides REPLICATION_FACTOR if set)" >&2 echo " REPLICATION_FACTOR - replication factor for prod (default: 2 for prod, 1 for test)" >&2 echo " VERSION - Cassandra backend version, 3 or 4 (default: 4). Ignored if template is provided." >&2 echo "" @@ -47,14 +48,22 @@ fi if [[ "$MODE" == "" ]]; then usage "missing MODE parameter" elif [[ "$MODE" == "prod" ]]; then - if [[ "$DATACENTER" == "" ]]; then usage "missing DATACENTER parameter for prod mode"; fi - datacenter=$DATACENTER - replication_factor=${REPLICATION_FACTOR:-2} - replication="{'class': 'NetworkTopologyStrategy', '$datacenter': '${replication_factor}' }" + if [[ -n "$REPLICATION" ]]; then + replication="$REPLICATION" + else + if [[ "$DATACENTER" == "" ]]; then usage "missing DATACENTER parameter for prod mode"; fi + datacenter=$DATACENTER + replication_factor=${REPLICATION_FACTOR:-2} + replication="{'class': 'NetworkTopologyStrategy', '$datacenter': '${replication_factor}' }" + fi elif [[ "$MODE" == "test" ]]; then - datacenter=${DATACENTER:-'test'} - replication_factor=${REPLICATION_FACTOR:-1} - replication="{'class': 'SimpleStrategy', 'replication_factor': '${replication_factor}'}" + if [[ -n "$REPLICATION" ]]; then + replication="$REPLICATION" + else + datacenter=${DATACENTER:-'test'} + replication_factor=${REPLICATION_FACTOR:-1} + replication="{'class': 'SimpleStrategy', 'replication_factor': '${replication_factor}'}" + fi else usage "invalid MODE=$MODE, expecting 'prod' or 'test'" fi From 560cca2c1e318418815d4eca1f8f2e1a1b8fddc2 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Wed, 22 Jan 2025 13:38:32 -0500 Subject: [PATCH 2/2] Update plugin/storage/cassandra/schema/create.sh Signed-off-by: Yuri Shkuro --- plugin/storage/cassandra/schema/create.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/storage/cassandra/schema/create.sh b/plugin/storage/cassandra/schema/create.sh index a43a4d9af9c..54b3f71b7d4 100755 --- a/plugin/storage/cassandra/schema/create.sh +++ b/plugin/storage/cassandra/schema/create.sh @@ -14,7 +14,7 @@ function usage { >&2 echo " TRACE_TTL - time to live for trace data, in seconds (default: 172800, 2 days)" >&2 echo " DEPENDENCIES_TTL - time to live for dependencies data, in seconds (default: 0, no TTL)" >&2 echo " KEYSPACE - keyspace (default: jaeger_v1_{datacenter})" - >&2 echo " REPLICATION - complete replication configuration (overrides REPLICATION_FACTOR if set)" + >&2 echo " REPLICATION - complete replication configuration (if set, overrides REPLICATION_FACTOR and DATACENTER)" >&2 echo " REPLICATION_FACTOR - replication factor for prod (default: 2 for prod, 1 for test)" >&2 echo " VERSION - Cassandra backend version, 3 or 4 (default: 4). Ignored if template is provided." >&2 echo ""