9
9
# Usage: <script_suffix> <execute:true|false> [workload flags]
10
10
# Requires: CLUSTER, WORKLOAD_CLUSTER, WORKLOAD_NODES env vars
11
11
# Optional: TOTAL_PARTITIONS (defaults to WORKLOAD_NODES if WORKLOAD_NODES>1)
12
+ # Optional: PARTITION_TYPE (defaults to client-partitions)
12
13
if [ " $# " -lt 2 ]; then
13
14
echo " Usage: $0 <script_suffix> <execute:true|false> <flags to init:--warehouses,--db>"
14
15
exit 1
@@ -40,6 +41,12 @@ if [ -z "${WORKLOAD_NODES}" ]; then
40
41
exit 1
41
42
fi
42
43
44
+ if [ -z " ${CLUSTER_NODES} " ]; then
45
+ echo " environment CLUSTER_NODES is not set"
46
+ exit 1
47
+ fi
48
+
49
+
43
50
# Set TOTAL_PARTITIONS equal to WORKLOAD_NODES if not set
44
51
if [ -z " ${TOTAL_PARTITIONS} " ] && [ " ${WORKLOAD_NODES} " -gt 1 ]; then
45
52
TOTAL_PARTITIONS=$WORKLOAD_NODES
@@ -51,6 +58,11 @@ if [ -n "${TOTAL_PARTITIONS}" ] && [ "${TOTAL_PARTITIONS}" -lt "${WORKLOAD_NODES
51
58
echo " TOTAL_PARTITIONS ($TOTAL_PARTITIONS ) must be greater than or equal to WORKLOAD_NODES ($WORKLOAD_NODES )"
52
59
exit 1
53
60
fi
61
+
62
+ # If PARTITION_TYPE is not set default to client-partitions
63
+ if [ -z " ${PARTITION_TYPE} " ]; then
64
+ PARTITION_TYPE=" client-partitions"
65
+ fi
54
66
55
67
export ROACHPROD_DISABLED_PROVIDERS=IBM
56
68
@@ -79,6 +91,13 @@ absolute_path=$(drtprod run "${WORKLOAD_CLUSTER}":1 -- "realpath ./cockroach")
79
91
pwd=$( drtprod run " ${WORKLOAD_CLUSTER} " :1 -- " dirname ${absolute_path} " )
80
92
81
93
for (( NODE= 0 ; NODE< WORKLOAD_NODES; NODE++ )) ; do
94
+ # Calculate node range for this workload node (if PARTITION_TYPE is partitions, we use the selected_nodes)
95
+ NODES_PER_WORKLOAD=$(( CLUSTER_NODES / WORKLOAD_NODES))
96
+ NODES_REMAINDER=$(( CLUSTER_NODES % WORKLOAD_NODES))
97
+ NODE_START=$(( NODE * NODES_PER_WORKLOAD + (NODE < NODES_REMAINDER ? NODE : NODES_REMAINDER) + 1 ))
98
+ NODE_END=$(( NODE_START + NODES_PER_WORKLOAD + (NODE < NODES_REMAINDER ? 1 : 0 ) - 1 ))
99
+ selected_nodes=" ${NODE_START} -${NODE_END} "
100
+
82
101
# Handle partitioning if TOTAL_PARTITIONS is set
83
102
partition_args=" "
84
103
if [ -n " ${TOTAL_PARTITIONS} " ]; then
@@ -94,7 +113,7 @@ for ((NODE=0; NODE<WORKLOAD_NODES; NODE++)); do
94
113
exit 1
95
114
fi
96
115
echo " Partition assignment: $parts "
97
- partition_args=" --client-partitions =$TOTAL_PARTITIONS --partition-affinity=$parts "
116
+ partition_args=" --$PARTITION_TYPE =$TOTAL_PARTITIONS --partition-affinity=$parts "
98
117
fi
99
118
100
119
# Create the workload script
@@ -104,11 +123,15 @@ for ((NODE=0; NODE<WORKLOAD_NODES; NODE++)); do
104
123
export ROACHPROD_DISABLED_PROVIDERS=IBM
105
124
export ROACHPROD_GCE_DEFAULT_PROJECT=$ROACHPROD_GCE_DEFAULT_PROJECT
106
125
./drtprod sync
107
- $( [ " $execute_script " = " true " ] && [ " $NODE " -eq 0 ] && echo " ${pwd} /tpcc_init_ ${suffix} .sh " )
126
+
108
127
PGURLS=\$ (./drtprod load-balancer pgurl $CLUSTER | sed s/\'//g)
109
128
if [ -z "\$ PGURLS" ]; then
110
129
echo ">> No load-balancer configured; falling back to direct pgurl"
111
- PGURLS=\$ (./drtprod pgurl $CLUSTER | sed s/\'//g)
130
+ if [ "$PARTITION_TYPE " = "partitions" ]; then
131
+ PGURLS=\$ (./drtprod pgurl $CLUSTER :$selected_nodes | sed s/\'//g)
132
+ else
133
+ PGURLS=\$ (./drtprod pgurl $CLUSTER | sed s/\'//g)
134
+ fi
112
135
fi
113
136
read -r -a PGURLS_ARR <<< "\$ PGURLS"
114
137
j=0
0 commit comments