Skip to content

Commit

Permalink
Add REPLICATION parameter to Cassandra schema script (#6582)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
Resoles #2618

## Description of the changes
- The addition of the REPLICATION variable allows users to directly
specify a custom replication configuration for Cassandra, overriding the
default behavior.

## How was this change tested?
- i used the make test command provided by the jaeger

## Checklist
- [*] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [X] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [X] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

---------

Signed-off-by: asim <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
  • Loading branch information
asimchoudhary and yurishkuro authored Jan 22, 2025
1 parent b689a86 commit 3222e01
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions plugin/storage/cassandra/schema/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 (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 ""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3222e01

Please sign in to comment.