examples/ has a script that runs a pool on one machine and leaves it up, scripts that run each workload against a pool, and a sample text. docs/multi-machine-test.md walks through a test on two or three real machines: what to run, what to break, what should happen, and what to report. The README gains a 'Trying it' section. A worker now ignores an invitation it has already used, so it can be restarted with the command that first started it.
26 lines
832 B
Bash
Executable File
26 lines
832 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Counts the words in a file, on the pool.
|
|
#
|
|
# examples/wordcount.sh [file] [how-many-words-to-show]
|
|
#
|
|
# Stores the file on the node, runs a wordcount job split across the pool's
|
|
# workers, and prints the most frequent words from the result.
|
|
source "$(dirname "$0")/common.sh"
|
|
|
|
file=${1:-$HERE/boulder.txt}
|
|
top=${2:-10}
|
|
|
|
echo "storing $file"
|
|
input=$(node blob put "$file")
|
|
echo " as $input"
|
|
|
|
echo "counting words"
|
|
out=$(node job submit --workload wordcount --params "{\"input\":\"$input\"}")
|
|
echo "$out" | sed -n 's/^job \([0-9a-f]*\) succeeded in \(.*\)/ job \1 took \2/p'
|
|
result=$(echo "$out" | tail -n 1)
|
|
output=$(echo "$result" | sed 's/.*"output":"\([^"]*\)".*/\1/')
|
|
echo " $result"
|
|
|
|
echo "the $top most frequent words, from the result $output"
|
|
node blob get "$output" | head -n "$top" | sed 's/^/ /'
|