-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·260 lines (233 loc) · 10 KB
/
start.sh
File metadata and controls
executable file
·260 lines (233 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/bin/bash
# TradeStreamEE Quick Start Script
set -e
echo "================================================"
echo " TradeStreamEE - Performance Matrix"
echo "================================================"
echo ""
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed"
echo "Please install Docker Desktop from: https://www.docker.com/products/docker-desktop"
exit 1
fi
# Check if Docker Compose is available
if ! docker compose version &> /dev/null && ! docker-compose --version &> /dev/null; then
echo "❌ Docker Compose is not installed"
echo "Please install Docker Compose from: https://docs.docker.com/compose/install/"
exit 1
fi
# Use docker compose (v2) or docker-compose (v1)
run_compose() {
if docker compose version &> /dev/null; then
docker compose "$@"
else
docker-compose "$@"
fi
}
echo "✅ Docker is installed"
echo "✅ Docker Compose is installed"
echo ""
# Parse command line arguments
ACTION="${1:-up}"
case "$ACTION" in
# --- Azul Platform Prime (C4 GC) Scenarios ---
up|start|azul-aeron)
echo "🚀 [Azul Prime] Starting with AERON Architecture (Optimized)..."
echo " > Dockerfile (Azul) + MODE=AERON"
echo ""
MODE=AERON run_compose -f docker-compose.yml up -d --build --force-recreate
echo ""
echo "🌐 Access: http://localhost:8080/trader-stream-ee/"
;;
azul-direct)
echo "🚀 [Azul Prime] Starting with DIRECT Architecture (Legacy Mode)..."
echo " > Dockerfile (Azul) + MODE=DIRECT"
echo " ℹ️ Observe how C4 handles high-allocation legacy code."
echo ""
MODE=DIRECT run_compose -f docker-compose.yml up -d --build --force-recreate
echo ""
echo "🌐 Access: http://localhost:8080/trader-stream-ee/"
;;
# --- Standard OpenJDK (G1 GC) Scenarios ---
standard|standard-direct)
echo "🚀 [Standard JDK] Starting with DIRECT Architecture (Legacy Mode)..."
echo " > Dockerfile.standard (Temurin) + MODE=DIRECT"
echo " ℹ️ Baseline performance: High allocation on G1GC."
echo ""
MODE=DIRECT run_compose -f docker-compose-standard.yml up -d --build --force-recreate
echo ""
echo "🌐 Access: http://localhost:8080/trader-stream-ee/"
;;
standard-aeron)
echo "🚀 [Standard JDK] Starting with AERON Architecture (Optimized)..."
echo " > Dockerfile.standard (Temurin) + MODE=AERON"
echo " ℹ️ Observe if off-heap transport helps G1GC."
echo ""
MODE=AERON run_compose -f docker-compose-standard.yml up -d --build --force-recreate
echo ""
echo "🌐 Access: http://localhost:8080/trader-stream-ee/"
;;
# --- Clustered Scenarios ---
cluster|cluster-azul)
echo "🚀 [Azul Prime Cluster] Starting 3-instance cluster with AERON..."
echo " > Dockerfile.scale (Azul) + MODE=AERON + Traefik LB"
echo " ℹ️ Demonstrates horizontal scalability with Hazelcast clustering."
echo ""
MODE=AERON DOCKERFILE=Dockerfile.scale run_compose -f docker-compose-scale.yml up -d --build --force-recreate
echo ""
echo "✅ Cluster started. Waiting for instances to be ready..."
sleep 10
echo ""
echo "📊 Cluster Status:"
curl -s http://localhost:8080/trader-stream-ee/api/status/cluster 2>/dev/null | jq . || echo "Cluster info endpoint not available yet"
echo ""
echo "🌐 Access: http://localhost:8080/trader-stream-ee/"
;;
cluster-standard)
echo "🚀 [Standard JDK Cluster] Starting 3-instance cluster with AERON..."
echo " > Dockerfile.scale.standard (Temurin) + MODE=AERON + Traefik LB"
echo " ℹ️ Compare cluster performance with G1GC."
echo ""
MODE=AERON DOCKERFILE=Dockerfile.scale.standard run_compose -f docker-compose-scale.yml up -d --build --force-recreate
echo ""
echo "✅ Cluster started. Waiting for instances to be ready..."
sleep 10
echo ""
echo "📊 Cluster Status:"
curl -s http://localhost:8080/trader-stream-ee/api/status/cluster 2>/dev/null | jq . || echo "Cluster info endpoint not available yet"
echo ""
echo "🌐 Access: http://localhost:8080/trader-stream-ee/"
;;
cluster-direct)
echo "🚀 [Azul Prime Cluster] Starting 3-instance cluster with DIRECT mode..."
echo " > Dockerfile.scale (Azul) + MODE=DIRECT + Traefik LB"
echo " ℹ️ Test cluster with high-allocation legacy mode."
echo ""
MODE=DIRECT DOCKERFILE=Dockerfile.scale run_compose -f docker-compose-scale.yml up -d --build --force-recreate
echo ""
echo "🌐 Access: http://localhost:8080/trader-stream-ee/"
;;
cluster-dynamic)
echo "🚀 [Dynamic Cluster] Starting scalable cluster..."
if [ -z "$2" ]; then
INSTANCES=3
echo " > No instance count specified, defaulting to 3"
else
INSTANCES=$2
fi
echo " > Dockerfile.scale (Azul) + MODE=AERON + $INSTANCES scalable instances"
echo " ℹ️ Uses generic service for true dynamic scaling."
echo ""
MODE=AERON DOCKERFILE=Dockerfile.scale run_compose -f docker-compose-scale.yml build trader-stream
run_compose -f docker-compose-scale.yml up -d traefik
run_compose -f docker-compose-scale.yml up -d --scale trader-stream=$INSTANCES --no-recreate trader-stream
echo ""
echo "✅ Cluster started. Waiting for instances to be ready..."
sleep 15
echo ""
echo "📊 Cluster Status:"
curl -s http://localhost:8080/trader-stream-ee/api/status/cluster 2>/dev/null | jq . || echo "Cluster info endpoint not available yet"
echo ""
echo "🌐 Access: http://localhost:8080/trader-stream-ee/"
;;
scale)
echo "🚀 Scaling cluster..."
if [ -z "$2" ]; then
echo "Usage: ./start.sh scale <number-of-instances>"
echo "Example: ./start.sh scale 5"
exit 1
fi
INSTANCES=$2
echo " > Scaling to $INSTANCES instances (using generic trader-stream service)"
echo " > Note: This uses the scalable service, not the named instances (trader-stream-1/2/3)"
run_compose -f docker-compose-scale.yml up -d --scale trader-stream=$INSTANCES --no-recreate
echo ""
echo "✅ Scaled to $INSTANCES instances"
sleep 10
echo ""
echo "📊 Checking cluster status..."
curl -s http://localhost:8080/trader-stream-ee/api/status/cluster 2>/dev/null | jq . || echo "Cluster info not available yet"
;;
# --- Utilities ---
down|stop)
echo "🛑 Stopping TradeStreamEE..."
run_compose -f docker-compose.yml down
run_compose -f docker-compose-standard.yml down
run_compose -f docker-compose-scale.yml down
echo "✅ Stopped"
;;
restart)
echo "🔄 Restarting..."
./start.sh stop
./start.sh start
;;
logs)
echo "📋 Showing logs..."
# Try to find which container is running
if docker ps | grep -q "trader-stream"; then
if docker ps | grep -q "trader-stream-1"; then
# Cluster mode - show all instances
echo "Cluster mode detected - showing logs from all instances..."
run_compose -f docker-compose-scale.yml logs -f
else
# Single instance mode
docker logs -f trader-stream-ee
fi
else
echo "❌ No running container found."
fi
;;
status)
echo "📊 Checking status..."
echo ""
if curl -f http://localhost:8080/trader-stream-ee/api/status 2>/dev/null | jq .; then
echo ""
echo "✅ Application is running"
echo ""
# Check if cluster mode
if curl -s http://localhost:8080/trader-stream-ee/api/status/cluster 2>/dev/null | grep -q "clustered"; then
echo "📡 Cluster Status:"
curl -s http://localhost:8080/trader-stream-ee/api/status/cluster 2>/dev/null | jq .
fi
else
echo "❌ Application is not responding"
echo "Try: ./start.sh logs"
fi
;;
clean)
echo "🧹 Cleaning up..."
run_compose -f docker-compose.yml down -v
run_compose -f docker-compose-standard.yml down -v
run_compose -f docker-compose-scale.yml down -v
docker system prune -f
echo "✅ Cleaned"
;;
*)
echo "Usage: ./start.sh [command]"
echo ""
echo "Single Instance Modes:"
echo " azul-aeron - Azul Prime (C4) + Aeron (Optimized) [Default]"
echo " azul-direct - Azul Prime (C4) + Direct (Legacy)"
echo " standard-direct - Standard JDK (G1) + Direct (Legacy) [Baseline]"
echo " standard-aeron - Standard JDK (G1) + Aeron (Optimized)"
echo ""
echo "Clustered Modes (Fixed 3 instances + Traefik LB):"
echo " cluster - Azul Prime (C4) + Aeron + Hazelcast Cluster"
echo " cluster-azul - Same as 'cluster'"
echo " cluster-standard - Standard JDK (G1) + Aeron + Hazelcast Cluster"
echo " cluster-direct - Azul Prime (C4) + Direct + Hazelcast Cluster"
echo ""
echo "Dynamic Scaling (Generic service + Traefik LB):"
echo " cluster-dynamic [N] - Start N scalable instances (default: 3)"
echo " scale N - Scale existing dynamic cluster to N instances"
echo ""
echo "Utilities:"
echo " logs - Show application logs"
echo " status - Check if application is running"
echo " stop - Stop the application"
echo " clean - Stop and clean all containers/volumes"
echo ""
exit 1
;;
esac