Add batch-llm module: 100,000 synthetic tickets classified by a ChatClient in a Spring Batch 6 chunk step with Resilience4j rate limiting and retry, skip-and-record for malformed JSON, restart after kill -9 in a second JVM, and a per-chunk cost ledger. The model is a deterministic simulated ChatModel; prices are configurable placeholders. No provider called.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4VQVEJWetTT1dYzyJ
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# Two real JVMs. JVM 1 is killed with SIGKILL once it has committed KILL_AT chunks; JVM 2 starts the
|
||||
# same job (same run.id, same H2 file) and finishes it. Nothing is shut down gracefully.
|
||||
set -euo pipefail
|
||||
source "$(dirname "$0")/common.sh"
|
||||
[ -f "$JAR" ] || mvn -B -q -T1 package -DskipTests
|
||||
CHUNKS=$((TICKETS / CHUNK))
|
||||
KILL_AT=$(( (CHUNKS * 4 / 10 / 50) * 50 )); [ "$KILL_AT" -ge 50 ] || KILL_AT=50
|
||||
D=target/crash
|
||||
rm -rf $D && mkdir -p $D output
|
||||
OPTS=(--batch.llm.tickets="$TICKETS" --batch.llm.run-id=crash-demo
|
||||
--spring.datasource.url="jdbc:h2:file:./$D/batchdb;DB_CLOSE_ON_EXIT=FALSE"
|
||||
--sim.provider.meter-file=$D/provider-meter.bin)
|
||||
|
||||
java -jar "$JAR" "${OPTS[@]}" > $D/jvm1.log 2>&1 &
|
||||
PID=$!
|
||||
echo "JVM 1 started, pid $PID; waiting for $KILL_AT committed chunks"
|
||||
while kill -0 "$PID" 2>/dev/null; do
|
||||
if grep -q "committed-chunks-this-jvm=$KILL_AT " $D/jvm1.log; then
|
||||
kill -9 "$PID"; echo "kill -9 sent to JVM 1 (pid $PID)"; break
|
||||
fi
|
||||
sleep 0.2
|
||||
done
|
||||
wait "$PID" 2>/dev/null || true
|
||||
echo "JVM 1 exit code: $? (137 = SIGKILL)"
|
||||
echo "--- last lines JVM 1 printed:"; clean_log < $D/jvm1.log | tail -3
|
||||
|
||||
echo "--- JVM 2 (same run.id, same database file):"
|
||||
java -jar "$JAR" "${OPTS[@]}" 2>&1 | clean_log | grep -v '^PROGRESS' | tee $D/jvm2.log
|
||||
{ echo "# Crash and restart, $TICKETS tickets: JVM 1 killed with kill -9 after $KILL_AT committed chunks, JVM 2 resumes"; echo;
|
||||
echo "## JVM 1 (progress lines, then SIGKILL)"; clean_log < $D/jvm1.log | tail -4; echo "(process killed by SIGKILL; no shutdown hook ran)"; echo;
|
||||
echo "## JVM 2"; cat $D/jvm2.log; } > output/09-crash-restart.txt
|
||||
Reference in New Issue
Block a user