Using briefcase on localhost/same server as Aggregate?

Hi,

I am just wondering if it is possible to user briefcase (command line) on the same server on which ODK aggregate is installed? Will it make the pull of data faster, since there is no network involved now? How would this actually work, if it does?

Thanks,
Saad

Yes it's possible. Yes it's faster. I do this frequently and it works great.

Great. How does it work? I mean, briefcase is calling the public IP/domain name, right? Can i change it to localhost? Would tomcat still be involved, or any other method?

Here's a quick and very lightly tested Bash script that you can put on a cron job that downloads all forms and exports the one that are available to enumerators as a CSV.

#!/bin/bash

BRIEFCASE_RUNNING=$(ps aux | grep java | grep briefcase | grep -v grep)
if [ -n "$BRIEFCASE_RUNNING" ]; then
	echo "Briefcase is already running..."
	exit
fi

JAVA_BIN="/usr/bin/java"

BRIEFCASE_JAR="/root/briefcase/ODK-Briefcase-v1.17.0.jar"
BRIEFCASE_STORAGE_DIR="/root/briefcase"
BRIEFCASE_EXPORT_DIR="/root/briefcase/output"

AGGREGATE_URL="https://server.appspot.com"
AGGREGATE_USERNAME="username"
AGGREGATE_PASSWORD="password"

cd "$BRIEFCASE_STORAGE_DIR"

$JAVA_BIN -jar "$BRIEFCASE_JAR" --pull_aggregate --storage_directory "$BRIEFCASE_STORAGE_DIR" \
--odk_url "$AGGREGATE_URL" --odk_username "$AGGREGATE_USERNAME" --odk_password "$AGGREGATE_PASSWORD"

rm "$BRIEFCASE_EXPORT_DIR"/*
FORM_IDS=($(curl --digest --user "$AGGREGATE_USERNAME":"$AGGREGATE_PASSWORD" --silent "X-OpenRosa-Version:1.0" "$AGGREGATE_URL"/formList 2>&1 | awk -F "=|\"" '{print $4}'))
for FORM_ID in "${FORM_IDS[@]}"; do
        $JAVA_BIN -jar "$BRIEFCASE_JAR" --export --form_id "$FORM_ID" --storage_directory "$BRIEFCASE_STORAGE_DIR" \
        --export_directory "$BRIEFCASE_EXPORT_DIR" --export_filename "$FORM_ID".csv \
        --exclude_media_export --overwrite_csv_export
done

Tomcat will always be involved. What you are saving by using Briefcase is network traffic and the memory requirements of Tomcat (because Briefcase downloads one submission at time).

Unless you have some crazy proxy setup, doesn't really matter if you use the public IP or localhost. The network stack will do a DNS lookup and realize the machine is localhost.