Tools & Console #
Proxima includes a powerful Groovy-based interactive console (Console) and non-interactive script runner (ProximaShell) for inspecting, querying, debugging, and backfilling data across any storage in your Repository.
Two modules power this tooling:
cz.o2.proxima:proxima-tools: Core Groovy REPL (groovysh), dynamicEnvironmentcode generation from your HOCON model, random-access CLI helpers, andProximaShellscript runner.cz.o2.proxima:proxima-beam-tools:BeamStreamProvider(discovered viaServiceLoader), which compiles your Groovy stream closures into live Apache Beam pipelines—allowing ad-hoc queries to execute locally viaDirectRunneror at cluster scale on Flink, Spark, or Dataflow!
Launching the Interactive Console #
Package proxima-tools, proxima-beam-tools, your desired Beam runner (e.g., beam-runners-direct-java or beam-runners-flink-1.20), your model/scheme JARs, IO modules, and application.conf/reference.conf on the classpath, then run cz.o2.proxima.tools.groovy.Console:
# Run locally with Beam DirectRunner
java -cp my-proxima-tools.jar \
cz.o2.proxima.tools.groovy.Console \
--runner=DirectRunner
# Run distributed queries on an Apache Flink cluster
RUNNER=org.apache.beam.runners.flink.FlinkRunner \
java -cp my-proxima-tools.jar \
cz.o2.proxima.tools.groovy.Console \
--flinkMaster=flink-jobmanager:8081 \
--parallelism=8
Passing Runner Arguments #
- Any CLI arguments passed to
ConsoleorProximaShellare forwarded to Beam’sPipelineOptionsFactory.fromArgs(args). - You can set the
RUNNERenvironment variable to the fully qualifiedPipelineRunnerclass name, or pass--runner=<RunnerName>. - Custom
BeamStreamProvider.RunnerRegistrarimplementations can be attached via--runnerRegistrar=<FQCN>to programmatically configurePipelineOptions(e.g., staging jars or authentication).
The env DSL
#
At startup, Console inspects your Repository and dynamically generates a Groovy Environment class bound to the variable env. Every entity and attribute in your HOCON model becomes a first-class property:
env.<entityName>.<attributeName>.<operation>(...)
Note: Attribute field names on
env.<entity>are lowercased and have any trailing.*stripped (e.g.,user.event.*is accessed asenv.user.event).
Random-Access Operations #
| Operation | Scalar Attribute | Wildcard Attribute |
|---|---|---|
| Read single value | env.user.details.get("user-1") | env.user.event.get("user-1", "1700000000") |
| List wildcard values | — | env.user.event.list("user-1")env.user.event.list("user-1", start, limit)env.user.event.listPrefix("user-1", "2026") |
| Write (upsert) | env.user.details.put("user-1", value) | env.user.event.put("user-1", "suffix", value) |
| Delete single | env.user.details.delete("user-1") | env.user.event.delete("user-1", "suffix") |
| Delete wildcard | — | env.user.event.deleteAll("user-1") |
| List entity keys | env.user.listKeys("", 100) | env.user.listKeys { pair -> println pair.second } |
Stream & Batch Sources #
Every attribute exposes streaming and batch entry points that return a fluent
Stream or
WindowedStream:
stream()/stream(boolean eventTime)— observe live commit log starting fromPosition.NEWEST(pressqto interrupt an unboundedprint()stream!).streamFromOldest()/streamFromOldest(boolean stopAtCurrent)— observe commit log fromPosition.OLDEST(bounded by default whenstopAtCurrent = true).batchUpdates()/batchUpdates(startStamp)/batchUpdates(startStamp, endStamp)— read historical updates frombatch-updatesstorage.batchSnapshot()/batchSnapshot(startStamp, endStamp)— read compacted snapshot frombatch-snapshot(or auto-reduced frombatch-updates).
Fluent Stream & Windowed Transformations #
Both Stream<T> and WindowedStream<T> provide concise functional operators backed by Apache Beam transforms:
- Element-wise:
map { ... },flatMap { ... },filter { ... },assignEventTime { ... },withTimestamp(),withWindow() - Windowing:
windowAll(),timeWindow(millis),timeSlidingWindow(sizeMs, slideMs),sessionWindow(gapMs),calendarWindow(...) - Aggregations (on
WindowedStream):reduce(keyFn, valFn, init, reducer),reduceToLatest(),groupReduce(keyFn, listFn),combine(...),count(),countByKey(keyFn),distinct(),average(...),sum(...),sorted(...) - Combining:
union(otherStream) - Sinks / Outputs:
print()— stream results directly to the console terminalcollect()— materialize a bounded stream into a GroovyListpersistIntoTargetFamily(env, "family-name")— writeStreamElements directly into a specific attribute family (ideal for backfills or migrations!)persistIntoTargetReplica(env, "replication-name", "target")— persist into a configured multi-cluster replication target
Interactive Session Examples #
// 1. Inspect a user's profile and recent events
println env.user.details.get("alice")?.parsed
env.user.event.list("alice").each { println "${it.attribute}: ${it.parsed}" }
// 2. Tail live events in real time (press 'q' to stop)
env.event.data.stream()
.map { "${it.key} -> ${it.parsed.get()}" }
.print()
// 3. Count events per user over the last 24 hours from batch storage
long now = System.currentTimeMillis()
long dayAgo = now - 24 * 3600 * 1000L
env.event.data.batchUpdates(dayAgo, now)
.filter { !it.delete }
.map { it.parsed.get().userId }
.windowAll()
.countByKey { it }
.print()
// 4. Backfill a newly added Cassandra replica family from historical batch updates
env.user.details.batchSnapshot()
.persistIntoTargetFamily(env, "user-random-access")
// 5. Query a remote IngestServer directly via gRPC from the console
console = cz.o2.proxima.tools.groovy.Console.get([] as String[])
println console.rpcGet(env.user.desc, "alice", "details", "localhost", 4001)
Running Standalone Scripts (ProximaShell)
#
For repeatable operational tasks, migrations, or scheduled batch queries, save your Groovy code to a .groovy file and run it non-interactively with
ProximaShell:
#!/usr/bin/env proxima-shell
// count_products.groovy
long count = env.product.details.batchSnapshot()
.filter { !it.delete }
.count()
.collect()
.first()
"Total active products: ${count}"
Execute the script with optional Beam runner arguments after the script path:
java -cp my-proxima-tools.jar \
cz.o2.proxima.tools.groovy.ProximaShell \
count_products.groovy \
--runner=DirectRunner
ProximaShell strips leading # comment/shebang lines, binds env automatically, runs the script, and prints the final expression result to standard output.