commit 9554c558608741ec0bc400744b8d25b82a46f275 Author: iwakeh iwakeh@torproject.org Date: Mon Dec 4 11:14:27 2017 +0000
Add ant task for legacy run.
Move related sources to main src tree, delete old build.xml and shell script. Update .gitignore to ignore legacy.config. The psql executions can contain all command line parameters of psql, i.e., it is also possible to add username and more. Currently, only the db name is set. This situation could be made easier/more consistent, but this is a new task not part of the current. --- .gitignore | 2 +- build.xml | 46 ++++++++++++++++++++++ modules/legacy/build.xml | 24 ----------- shared/bin/50-run-legacy-stats.sh | 9 ----- .../org/torproject/ernie/cron/Configuration.java | 0 .../java/org/torproject/ernie/cron/LockFile.java | 0 .../ernie/cron/LoggingConfiguration.java | 0 .../main/java/org/torproject/ernie/cron/Main.java | 0 .../cron/RelayDescriptorDatabaseImporter.java | 0 .../cron/network/ConsensusStatsFileHandler.java | 0 .../main/resources/legacy.config.template | 0 .../legacy/db => src/main/sql/legacy}/tordir.sql | 0 12 files changed, 47 insertions(+), 34 deletions(-)
diff --git a/.gitignore b/.gitignore index 8234621..b546cef 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ cobertura.ser /lib/
# Copied and possibly modified config file -config +legacy.config
# other *~ diff --git a/build.xml b/build.xml index b793a10..09857ba 100644 --- a/build.xml +++ b/build.xml @@ -96,6 +96,52 @@ <antcall target="run-java" /> </target>
+ <!-- Provides legacy.config file from template. --> + <target name="legacy-create-config" > + <copy file="${resources}/legacy.config.template" + tofile="${basedir}/legacy.config"/> + </target> + + <!-- Expects legacy.config file in the base directory. --> + <target name="legacy" > + <property name="module.name" value="legacy" /> + <property name="localmoddir" value="${modulebase}/${module.name}" /> + <property name="statsdir" + value="${localmoddir}/stats" /> + <mkdir dir="${statsdir}" /> + + <copy file="${basedir}/legacy.config" + tofile="${localmoddir}/config"/> + + <antcall target="run-java"> + <param name="module.main" + value="org.torproject.ernie.cron.Main" /> + </antcall> + + <exec executable="psql" + dir="${localmoddir}" + failonerror="true" > + <arg value="--dbname=tordir"/> + <arg value="-c SELECT * FROM refresh_all();" /> + </exec> + + <exec executable="psql" + dir="${localmoddir}" + failonerror="true" > + <arg value="-c COPY (SELECT * FROM stats_servers) TO STDOUT WITH CSV HEADER;" /> + <arg value="--dbname=tordir"/> + <arg value="--output=${statsdir}/servers.csv" /> + </exec> + + <exec executable="psql" + dir="${localmoddir}" + failonerror="true" > + <arg value="-c COPY (SELECT * FROM stats_bandwidth) TO STDOUT WITH CSV HEADER;" /> + <arg value="--dbname=tordir"/> + <arg value="--output=${statsdir}/bandwidth.csv" /> + </exec> + </target> + <target name="advbwdist"> <property name="module.name" value="advbwdist" /> <antcall target="run-java" /> diff --git a/modules/legacy/build.xml b/modules/legacy/build.xml deleted file mode 100644 index bc2b674..0000000 --- a/modules/legacy/build.xml +++ /dev/null @@ -1,24 +0,0 @@ -<project default="run" name="metrics-web" basedir="."> - - <property name="mainclass" value="org.torproject.ernie.cron.Main"/> - - <include file="../../shared/build-base.xml" as="basetask"/> - <target name="clean" depends="basetask.clean"/> - <target name="compile" depends="basetask.compile"/> - <target name="run" depends="initrun,basetask.run"/> - - <path id="classpath"> - <pathelement path="${classes}"/> - <path refid="base.classpath" /> - <fileset dir="${libs}"> - <include name="postgresql-jdbc3-9.2.jar"/> - </fileset> - </path> - - <!-- Prepare run. --> - <target name="initrun" > - <copy file="config.template" tofile="config"/> - </target> - -</project> - diff --git a/shared/bin/50-run-legacy-stats.sh b/shared/bin/50-run-legacy-stats.sh deleted file mode 100755 index 0fd5699..0000000 --- a/shared/bin/50-run-legacy-stats.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -cd modules/legacy/ -ant | grep "[java]" -psql -U metrics tordir -c 'SELECT * FROM refresh_all();' -mkdir -p stats -psql -c 'COPY (SELECT * FROM stats_servers) TO STDOUT WITH CSV HEADER;' tordir > stats/servers.csv -psql -c 'COPY (SELECT * FROM stats_bandwidth) TO STDOUT WITH CSV HEADER;' tordir > stats/bandwidth.csv -cd ../../ - diff --git a/modules/legacy/src/main/java/org/torproject/ernie/cron/Configuration.java b/src/main/java/org/torproject/ernie/cron/Configuration.java similarity index 100% rename from modules/legacy/src/main/java/org/torproject/ernie/cron/Configuration.java rename to src/main/java/org/torproject/ernie/cron/Configuration.java diff --git a/modules/legacy/src/main/java/org/torproject/ernie/cron/LockFile.java b/src/main/java/org/torproject/ernie/cron/LockFile.java similarity index 100% rename from modules/legacy/src/main/java/org/torproject/ernie/cron/LockFile.java rename to src/main/java/org/torproject/ernie/cron/LockFile.java diff --git a/modules/legacy/src/main/java/org/torproject/ernie/cron/LoggingConfiguration.java b/src/main/java/org/torproject/ernie/cron/LoggingConfiguration.java similarity index 100% rename from modules/legacy/src/main/java/org/torproject/ernie/cron/LoggingConfiguration.java rename to src/main/java/org/torproject/ernie/cron/LoggingConfiguration.java diff --git a/modules/legacy/src/main/java/org/torproject/ernie/cron/Main.java b/src/main/java/org/torproject/ernie/cron/Main.java similarity index 100% rename from modules/legacy/src/main/java/org/torproject/ernie/cron/Main.java rename to src/main/java/org/torproject/ernie/cron/Main.java diff --git a/modules/legacy/src/main/java/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java b/src/main/java/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java similarity index 100% rename from modules/legacy/src/main/java/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java rename to src/main/java/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java diff --git a/modules/legacy/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java b/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java similarity index 100% rename from modules/legacy/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java rename to src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java diff --git a/modules/legacy/config.template b/src/main/resources/legacy.config.template similarity index 100% rename from modules/legacy/config.template rename to src/main/resources/legacy.config.template diff --git a/modules/legacy/db/tordir.sql b/src/main/sql/legacy/tordir.sql similarity index 100% rename from modules/legacy/db/tordir.sql rename to src/main/sql/legacy/tordir.sql