<commit_before>#!/bin/bash
if [ -z "$XTERM" ] ; then
    XTERM=x-terminal-emulator
fi
if [ -z "$XTERMOPTIONS" ] ; then
    XTERMOPTIONS="--geometry=80x43"
fi

if [ ! -d arangod ] || [ ! -d arangosh ] || [ ! -d UnitTests ] ; then
    echo Must be started in the main ArangoDB source directory.
    exit 1
fi

NRAGENTS=$1
if [ "$NRAGENTS" == "" ] ; then
    NRAGENTS=1
fi
if [[ $(( $NRAGENTS % 2 )) == 0 ]]; then
    echo Number of agents must be odd.
    exit 1
fi
echo Number of Agents: $NRAGENTS
NRDBSERVERS=$2
if [ "$NRDBSERVERS" == "" ] ; then
    NRDBSERVERS=2
fi
echo Number of DBServers: $NRDBSERVERS
NRCOORDINATORS=$3
if [ "$NRCOORDINATORS" == "" ] ; then
    NRCOORDINATORS=1
fi
echo Number of Coordinators: $NRCOORDINATORS

if [ ! -z "$4" ] ; then
    if [ "$4" == "C" ] ; then
        COORDINATORCONSOLE=1
        echo Starting one coordinator in terminal with --console
    elif [ "$4" == "D" ] ; then
        CLUSTERDEBUGGER=1
        echo Running cluster in debugger.
    elif [ "$4" == "R" ] ; then
        RRDEBUGGER=1
        echo Running cluster in rr with --console.
    fi
fi

SECONDARIES="$5"

MINP=1.0
MAXP=2.0
SFRE=5.0
COMP=1000
BASE=4001
NATH=$(( $NRDBSERVERS + $NRCOORDINATORS + $NRAGENTS ))

rm -rf cluster
if [ -d cluster-init ];then
  cp -a cluster-init cluster
fi
mkdir -p cluster
echo Starting agency ... 
for aid in `seq 0 $(( $NRAGENTS - 1 ))`; do
    port=$(( $BASE + $aid ))
    build/bin/arangod \
        -c none \
        --agency.activate true \
        --agency.endpoint tcp://localhost:$BASE \
        --agency.size $NRAGENTS \
        --agency.pool-size $NRAGENTS \
        --agency.supervision true \
        --agency.supervision-frequency $SFRE \
        --agency.wait-for-sync false \
        --agency.election-timeout-min $MINP \
        --agency.election-timeout-max $MAXP \
        --database.directory cluster/data$port \
        --javascript.app-path ./js/apps \
        --javascript.startup-directory ./js \
        --javascript.v8-contexts 1 \
        --log.file cluster/$port.log \
        --server.authentication false \
        --server.endpoint tcp://0.0.0.0:$port \
        --server.statistics false \
        --server.threads 16 \
        --agency.compaction-step-size $COMP \
        --log.force-direct true \
        --log.level agency=debug \
        > cluster/$port.stdout 2>&1 &
done

start() {
    if [ "$1" == "dbserver" ]; then
      ROLE="PRIMARY"
    elif [ "$1" == "coordinator" ]; then
      ROLE="COORDINATOR"
    fi
    TYPE=$1
    PORT=$2
    mkdir cluster/data$PORT
    echo Starting $TYPE on port $PORT
    mkdir -p cluster/apps$PORT 
    build/bin/arangod -c none \<commit_msg>minor<commit_after>#!/bin/bash
if [ -z "$XTERM" ] ; then
    XTERM=x-terminal-emulator
fi
if [ -z "$XTERMOPTIONS" ] ; then
    XTERMOPTIONS="--geometry=80x43"
fi

if [ ! -d arangod ] || [ ! -d arangosh ] || [ ! -d UnitTests ] ; then
    echo Must be started in the main ArangoDB source directory.
    exit 1
fi

NRAGENTS=$1
if [ "$NRAGENTS" == "" ] ; then
    NRAGENTS=1
fi
if [[ $(( $NRAGENTS % 2 )) == 0 ]]; then
    echo Number of agents must be odd.
    exit 1
fi
echo Number of Agents: $NRAGENTS
NRDBSERVERS=$2
if [ "$NRDBSERVERS" == "" ] ; then
    NRDBSERVERS=2
fi
echo Number of DBServers: $NRDBSERVERS
NRCOORDINATORS=$3
if [ "$NRCOORDINATORS" == "" ] ; then
    NRCOORDINATORS=1
fi
echo Number of Coordinators: $NRCOORDINATORS

if [ ! -z "$4" ] ; then
    if [ "$4" == "C" ] ; then
        COORDINATORCONSOLE=1
        echo Starting one coordinator in terminal with --console
    elif [ "$4" == "D" ] ; then
        CLUSTERDEBUGGER=1
        echo Running cluster in debugger.
    elif [ "$4" == "R" ] ; then
        RRDEBUGGER=1
        echo Running cluster in rr with --console.
    fi
fi

SECONDARIES="$5"

MINP=1.0
MAXP=2.0
SFRE=5.0
COMP=1000
BASE=4001
NATH=$(( $NRDBSERVERS + $NRCOORDINATORS + $NRAGENTS ))

rm -rf cluster
if [ -d cluster-init ];then
  cp -a cluster-init cluster
fi
mkdir -p cluster
echo Starting agency ... 
for aid in `seq 0 $(( $NRAGENTS - 1 ))`; do
    port=$(( $BASE + $aid ))
    build/bin/arangod \
        -c none \
        --agency.activate true \
        --agency.endpoint tcp://localhost:$BASE \
        --agency.size $NRAGENTS \
        --agency.pool-size $NRAGENTS \
        --agency.supervision true \
        --agency.supervision-frequency $SFRE \
        --agency.wait-for-sync false \
        --agency.election-timeout-min $MINP \
        --agency.election-timeout-max $MAXP \
        --database.directory cluster/data$port \
        --javascript.app-path ./js/apps \
        --javascript.startup-directory ./js \
        --javascript.v8-contexts 1 \
        --log.file cluster/$port.log \
        --server.authentication false \
        --server.endpoint tcp://0.0.0.0:$port \
        --server.statistics false \
        --server.threads 16 \
        --agency.compaction-step-size $COMP \
        --log.force-direct true \
        > cluster/$port.stdout 2>&1 &
done

start() {
    if [ "$1" == "dbserver" ]; then
      ROLE="PRIMARY"
    elif [ "$1" == "coordinator" ]; then
      ROLE="COORDINATOR"
    fi
    TYPE=$1
    PORT=$2
    mkdir cluster/data$PORT
    echo Starting $TYPE on port $PORT
    mkdir -p cluster/apps$PORT 
    build/bin/arangod -c none \
{'fraction_non_alphanumeric': 0.1485073207834189, 'fraction_numerical': 0.019775622741966155, 'mean_word_length': 2.134684147794994, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6932483', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1855, 'n_words': 474}