mirror of
https://github.com/torproject/metrics-web.git
synced 2024-11-27 11:40:34 +00:00
9c2bae83e5
The issue was that we didn't include required libraries for fetching and parsing CollecTor's index.json file. Fixes #24792.
487 lines
17 KiB
XML
487 lines
17 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<!DOCTYPE project [
|
|
<!ENTITY base SYSTEM "src/build/java/base.xml">
|
|
]>
|
|
|
|
<project default="usage" name="metrics-web" basedir=".">
|
|
|
|
<property name="javadoc-title" value="MetricsWeb API Documentation"/>
|
|
<property name="implementation-title" value="metrics-web" />
|
|
<property name="release.version" value="1.0.3-dev" />
|
|
<property name="metricslibversion" value="2.1.1" />
|
|
<property name="jetty.version" value="-9.2.21.v20170120" />
|
|
<property name="warfile"
|
|
value="metrics-web-${release.version}.war"/>
|
|
|
|
<property name="name" value="metrics-web"/>
|
|
|
|
<property name="project-main-class"
|
|
value="org.torproject.TBD" />
|
|
<property name="additional2sign" value="${warfile}" />
|
|
<property name="tardepends" value="war" />
|
|
|
|
<property name="Rsources" value="${basedir}/src/main/R" />
|
|
<property name="pysources" value="${basedir}/src/main/python" />
|
|
|
|
<!-- Deployment base folder.
|
|
Be aware that this is also set in R scripts and web.xml, currently! -->
|
|
<property name="metrics-web.deployment.base"
|
|
value="/srv/metrics.torproject.org/metrics" />
|
|
|
|
<!-- The coverage needs to be improved! -->
|
|
<target name="coverage-check">
|
|
<cobertura-check totallinerate="0" totalbranchrate="0" >
|
|
<!-- example regexes
|
|
<regex pattern="org.torproject.abc.xyz.*"
|
|
branchrate="87" linerate="73"/>
|
|
-->
|
|
</cobertura-check>
|
|
</target>
|
|
|
|
<patternset id="common" >
|
|
<include name="commons-codec-1.10.jar"/>
|
|
<include name="commons-lang3-3.5.jar"/>
|
|
<include name="commons-lang-2.6.jar"/>
|
|
<include name="gson-2.4.jar" />
|
|
<include name="logback-core-1.1.9.jar" />
|
|
<include name="logback-classic-1.1.9.jar" />
|
|
<include name="postgresql-9.4.1212.jar"/>
|
|
<include name="REngine.jar"/>
|
|
<include name="Rserve.jar"/>
|
|
<include name="slf4j-api-1.7.22.jar"/>
|
|
</patternset>
|
|
|
|
<patternset id="library" >
|
|
<patternset refid="common" />
|
|
<include name="metrics-lib-${metricslibversion}.jar"/>
|
|
<include name="commons-compress-1.13.jar"/>
|
|
<include name="servlet-api-3.1.jar"/>
|
|
<include name="xz-1.6.jar"/>
|
|
</patternset>
|
|
|
|
<patternset id="web" >
|
|
<include name="jetty9-annotations${jetty.version}.jar"/>
|
|
<include name="jetty9-server${jetty.version}.jar"/>
|
|
<include name="jetty9-servlet${jetty.version}.jar"/>
|
|
<include name="jetty9-util${jetty.version}.jar"/>
|
|
<include name="jetty9-http${jetty.version}.jar"/>
|
|
<include name="jetty9-io${jetty.version}.jar"/>
|
|
<include name="jetty9-xml${jetty.version}.jar"/>
|
|
<include name="jetty9-webapp${jetty.version}.jar"/>
|
|
<include name="jetty9-continuation${jetty.version}.jar"/>
|
|
<include name="jetty9-security${jetty.version}.jar"/>
|
|
</patternset>
|
|
|
|
<patternset id="webruntime" >
|
|
<include name="asm-5.2.jar" />
|
|
<include name="asm-commons-5.2.jar" />
|
|
<include name="commons-compress-1.13.jar"/>
|
|
<include name="jetty9-plus${jetty.version}.jar"/>
|
|
<include name="jetty9-jndi${jetty.version}.jar"/>
|
|
<include name="jetty9-apache-jsp${jetty.version}-tweaked.jar" />
|
|
<include name="metrics-lib-${metricslibversion}.jar"/>
|
|
<include name="taglibs-standard-spec-1.2.5.jar"/>
|
|
<include name="tomcat8-embed-jasper-8.5.14.jar" />
|
|
<include name="tomcat8-embed-el-8.5.14.jar" />
|
|
<include name="tomcat8-embed-core-8.5.14.jar" />
|
|
<include name="eclipse-ecj-3.11.1.jar" />
|
|
</patternset>
|
|
|
|
<patternset id="runtime" >
|
|
<patternset refid="library" />
|
|
<patternset refid="web" />
|
|
</patternset>
|
|
|
|
<!-- Tasks for database testing. -->
|
|
<target name="test-all-dbs"
|
|
depends="init"
|
|
description="Run all available database pgTAP tests." >
|
|
<antcall target="test-db">
|
|
<param name="db2test" value="ipv6servers" />
|
|
</antcall>
|
|
<antcall target="test-db">
|
|
<param name="db2test" value="userstats" />
|
|
</antcall>
|
|
</target>
|
|
|
|
<target name="test-db" description="A helper task for task test-all-dbs." >
|
|
<property name="dbtestlog" value="${basedir}/${generated}/${db2test}-sql-test.txt" />
|
|
<exec executable="psql"
|
|
dir="${generated}"
|
|
failonerror="false" >
|
|
<arg value="--output=${dbtestlog}" />
|
|
<arg value="--log-file=${basedir}/${generated}/all-dbs-test.log" />
|
|
<arg value="--quiet" />
|
|
<arg value="--file=${basedir}/src/test/sql/${db2test}/test-${db2test}.sql" />
|
|
<arg value="--dbname=${db2test}"/>
|
|
</exec>
|
|
<exec executable="grep" outputproperty="dbtestresult"
|
|
dir="${generated}"
|
|
failonerror="false" >
|
|
<arg value="failed" />
|
|
<arg value="${dbtestlog}" />
|
|
</exec>
|
|
<fail message="${dbtestresult} see ${dbtestlog} for details." >
|
|
<condition>
|
|
<not>
|
|
<length string="${dbtestresult}"
|
|
length="0" />
|
|
</not>
|
|
</condition>
|
|
</fail>
|
|
<echo message="Tests for ${db2test} passed." />
|
|
</target>
|
|
|
|
<!-- Create a .war file for deployment. -->
|
|
<target name="war"
|
|
depends="submoduleupdate,compile">
|
|
<echo message="Removing problematic service definitions from"/>
|
|
<echo message="${libs}/jetty9-apache-jsp${jetty.version}.jar and using "/>
|
|
<echo message="${libs}/jetty9-apache-jsp${jetty.version}-tweaked.jar below." />
|
|
<delete file="${libs}/jetty9-apache-jsp${jetty.version}-tweaked.jar"
|
|
quiet="true" />
|
|
|
|
<jar destfile="${libs}/jetty9-apache-jsp${jetty.version}-tweaked.jar">
|
|
<zipfileset src="${libs}/jetty9-apache-jsp${jetty.version}.jar" >
|
|
<exclude name="**/javax.servlet.ServletContainerInitializer"/>
|
|
</zipfileset>
|
|
</jar>
|
|
|
|
<antcall target="generate-ml-javadoc" />
|
|
|
|
<war destfile="${dist}/${warfile}"
|
|
duplicate="fail"
|
|
webxml="${resources}/web.xml"
|
|
basedir="${classes}">
|
|
<restrict>
|
|
<not>
|
|
<and>
|
|
<name name="META-INF/*" />
|
|
<not>
|
|
<name name="META-INF/services/*" />
|
|
</not>
|
|
</and>
|
|
</not>
|
|
<archives>
|
|
<zips>
|
|
<fileset dir="${libs}">
|
|
<patternset refid="common" />
|
|
<patternset refid="web" />
|
|
<patternset refid="webruntime" />
|
|
</fileset>
|
|
</zips>
|
|
</archives>
|
|
</restrict>
|
|
<exclude name="**/Test*.class" />
|
|
<zipfileset dir="${resources}"
|
|
prefix=""
|
|
includes="logback.xml" />
|
|
<zipfileset dir="${resources}/web"
|
|
prefix=""
|
|
includes="css/* images/* js/* fonts/**" />
|
|
<zipfileset dir="${resources}/web/jsps"
|
|
prefix="WEB-INF"
|
|
includes="*.jsp"/>
|
|
<zipfileset dir="${resources}"
|
|
includes="*.properties" />
|
|
<fileset dir="${resources}" includes="jetty.xml" />
|
|
|
|
<zipfileset dir="${resources}/web/json"
|
|
prefix="WEB-INF/json"
|
|
includes="metrics.json categories.json news.json"/>
|
|
|
|
<zipfileset dir="${basedir}/src/submods/metrics-lib/generated/javadoc"
|
|
prefix="metrics-lib" />
|
|
<zipfileset dir="${libs}" prefix="WEB-INF/lib" >
|
|
<include name="taglibs-standard-impl-1.2.5.jar"/>
|
|
</zipfileset>
|
|
|
|
<metainf dir="${resources}"
|
|
includes="context.xml"/>
|
|
<manifest>
|
|
<attribute name="Implemented-By" value="The Tor Project" />
|
|
<attribute name="Implementation-Title" value="TorMetricsWeb Server"/>
|
|
<attribute name="Implementation-Version"
|
|
value="${release.version}-${git.revision}"/>
|
|
<attribute name="Main-Class"
|
|
value="org.torproject.metrics.web.ServerMain" />
|
|
</manifest>
|
|
</war>
|
|
</target>
|
|
|
|
<target name="generate-ml-javadoc" depends="submoduleupdate" >
|
|
<mkdir dir="${basedir}/src/submods/metrics-lib/lib" />
|
|
<exec executable="ant"
|
|
dir="${basedir}/src/submods/metrics-lib"
|
|
failonerror="true" >
|
|
<arg value="clean" />
|
|
<arg value="docs" />
|
|
</exec>
|
|
</target>
|
|
|
|
<!-- This can be adapted to point at the actual work directory. -->
|
|
<property name="prepare.deployment"
|
|
value="/srv/metrics.torproject.org/metrics/work" />
|
|
|
|
<!-- Don't alter the following. -->
|
|
<property name="modulebase" value="${prepare.deployment}/modules" />
|
|
|
|
<!-- Operational tasks. -->
|
|
<target name="run-web-prepare" depends="init" >
|
|
<mkdir dir="${prepare.deployment}/modules" />
|
|
<antcall target="collectdescs" />
|
|
<antcall target="connbidirect" />
|
|
<antcall target="onionperf" />
|
|
<antcall target="legacy" />
|
|
<antcall target="advbwdist" />
|
|
<antcall target="hidserv" />
|
|
<antcall target="clients" />
|
|
<antcall target="ipv6servers" />
|
|
<antcall target="webstats" />
|
|
<antcall target="make-data-available" />
|
|
</target>
|
|
|
|
<target name="collectdescs" >
|
|
<property name="module.name" value="collectdescs" />
|
|
<antcall target="run-java" />
|
|
</target>
|
|
|
|
<target name="connbidirect" >
|
|
<property name="module.name" value="connbidirect" />
|
|
<antcall target="run-java" />
|
|
</target>
|
|
|
|
<target name="onionperf" >
|
|
<property name="module.name" value="onionperf" />
|
|
<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" />
|
|
<antcall target="run-R" >
|
|
<param name="module.Rscript" value="aggregate.R" />
|
|
</antcall>
|
|
</target>
|
|
|
|
<target name="hidserv" >
|
|
<property name="module.name" value="hidserv" />
|
|
<antcall target="run-java" />
|
|
</target>
|
|
|
|
<target name="clients" >
|
|
<property name="module.name" value="clients" />
|
|
<property name="localmoddir" value="${modulebase}/${module.name}" />
|
|
|
|
<property name="rdatadir" value="${localmoddir}/RData" />
|
|
<mkdir dir="${rdatadir}" />
|
|
<property name="statsdir"
|
|
value="${localmoddir}/stats" />
|
|
<mkdir dir="${statsdir}" />
|
|
|
|
<antcall target="run-java" />
|
|
<apply executable="psql" failonerror="true" >
|
|
<arg value="--dbname=userstats"/>
|
|
<arg value="-f"/>
|
|
<fileset dir="${localmoddir}/out"
|
|
includes="*.sql" />
|
|
</apply>
|
|
|
|
<exec executable="psql"
|
|
dir="${localmoddir}"
|
|
failonerror="true" >
|
|
<arg value="-c COPY (SELECT * FROM estimated) TO STDOUT WITH CSV HEADER;" />
|
|
<arg value="--dbname=userstats"/>
|
|
<arg value="--output=userstats.csv" />
|
|
</exec>
|
|
|
|
<exec executable="psql"
|
|
dir="${localmoddir}"
|
|
failonerror="true" >
|
|
<arg value="-c COPY (SELECT * FROM combined) TO STDOUT WITH CSV HEADER;" />
|
|
<arg value="--dbname=userstats"/>
|
|
<arg value="--output=userstats-combined.csv" />
|
|
</exec>
|
|
|
|
<antcall target="run-R" >
|
|
<param name="module.Rscript" value="userstats-detector.R" />
|
|
</antcall>
|
|
|
|
<exec executable="python"
|
|
dir="${localmoddir}"
|
|
failonerror="true" >
|
|
<arg value="${pysources}/${module.name}/detector.py" />
|
|
<arg value="userstats-detector.csv" />
|
|
<arg value="userstats-ranges.csv" />
|
|
</exec>
|
|
|
|
<antcall target="run-R" >
|
|
<param name="module.Rscript" value="merge-clients.R" />
|
|
</antcall>
|
|
|
|
<copy file="${localmoddir}/clients.csv" todir="${statsdir}" />
|
|
<copy file="${localmoddir}/userstats-combined.csv" todir="${statsdir}" />
|
|
|
|
<antcall target="run-R" >
|
|
<param name="module.Rscript" value="split-clients.R" />
|
|
</antcall>
|
|
</target>
|
|
|
|
<target name="ipv6servers" >
|
|
<property name="module.name" value="ipv6servers" />
|
|
<antcall target="run-java" >
|
|
<param name="module.main"
|
|
value="org.torproject.metrics.stats.ipv6servers.Main" />
|
|
</antcall>
|
|
</target>
|
|
|
|
<target name="webstats" >
|
|
<property name="module.name" value="webstats" />
|
|
<property name="rdatadir" value="${modulebase}/${module.name}/RData" />
|
|
<mkdir dir="${rdatadir}" />
|
|
|
|
<antcall target="run-java" />
|
|
<antcall target="run-R" >
|
|
<param name="module.Rscript" value="write-RData.R" />
|
|
</antcall>
|
|
</target>
|
|
|
|
<!--
|
|
The run-rserver target documents a working option of
|
|
configuring an R server for running metrics-web.
|
|
It is not necessary for development to use this task
|
|
and it is not used for metrics.torproject.org in this way.
|
|
Eventually, this task will become obsolete when R is also
|
|
controlled from Java code.
|
|
-->
|
|
<target name="run-rserver">
|
|
<exec executable="R"
|
|
dir="${Rsources}/rserver"
|
|
failonerror="true" >
|
|
<arg value="CMD"/>
|
|
<arg value="Rserve" />
|
|
<arg value="--no-save" />
|
|
<arg value="--quiet" />
|
|
<arg value="--RS-conf" />
|
|
<arg value="${Rsources}/Rserv.conf" />
|
|
</exec>
|
|
</target>
|
|
|
|
<target name="make-data-available" >
|
|
<property name="statsdir" value="${metrics-web.deployment.base}/shared/stats/" />
|
|
<mkdir dir="${statsdir}" />
|
|
<property name="rdatadir" value="${metrics-web.deployment.base}/shared/RData" />
|
|
<mkdir dir="${rdatadir}" />
|
|
<copy todir="${statsdir}" >
|
|
<fileset dir="${modulebase}/onionperf/stats" includes="*.csv" />
|
|
<fileset dir="${modulebase}/connbidirect/stats" includes="connbidirect2.csv" />
|
|
<fileset dir="${modulebase}/advbwdist/stats" includes="advbwdist.csv" />
|
|
<fileset dir="${modulebase}/legacy/stats" includes="*.csv" />
|
|
<fileset dir="${modulebase}/hidserv/stats" includes="hidserv.csv" />
|
|
<fileset dir="${modulebase}/clients/stats"
|
|
includes="clients*.csv userstats-combined.csv" />
|
|
<fileset dir="${modulebase}/ipv6servers/stats" includes="ipv6servers.csv" />
|
|
<fileset dir="${modulebase}/webstats/stats" includes="webstats.csv" />
|
|
</copy>
|
|
<copy todir="${rdatadir}" >
|
|
<fileset dir="${modulebase}/clients/RData" includes="*.RData" />
|
|
<fileset dir="${modulebase}/webstats/RData" includes="*.RData" />
|
|
</copy>
|
|
</target>
|
|
|
|
<!-- Support tasks for operation -->
|
|
<target name="run-java">
|
|
<echo message="Running java module ${module.name} ... " />
|
|
<available file="${dist}/${jarfile}" property="have.jar"/>
|
|
<fail unless="have.jar" message="Please run 'ant jar' first."/>
|
|
<condition property="mainclass"
|
|
value="${module.main}"
|
|
else="org.torproject.metrics.${module.name}.Main" >
|
|
<isset property="module.main"/>
|
|
</condition>
|
|
<property name="workingdir" value="${modulebase}/${module.name}" />
|
|
<mkdir dir="${workingdir}" />
|
|
<java dir="${workingdir}"
|
|
fork="true"
|
|
maxmemory="4g"
|
|
classname="${mainclass}">
|
|
<classpath>
|
|
<pathelement location="${dist}/${jarfile}"/>
|
|
<pathelement location="${resources}"/>
|
|
</classpath>
|
|
<jvmarg value="-DLOGBASE=../logs"/>
|
|
<jvmarg value="-Duser.language=us" />
|
|
<jvmarg value="-Duser.region=US" />
|
|
</java>
|
|
<echo message="Java module ${module.name} finished. " />
|
|
</target>
|
|
|
|
<target name="run-R" >
|
|
<echo message="Running R module ${module.name}, script ${module.Rscript} ... " />
|
|
<property name="Rscript"
|
|
value="${Rsources}/${module.name}/${module.Rscript}" />
|
|
<exec executable="R"
|
|
dir="${modulebase}/${module.name}"
|
|
failonerror="true" >
|
|
<arg value="--slave"/>
|
|
<arg value="-f"/>
|
|
<arg value="${Rscript}" />
|
|
</exec>
|
|
<echo message="R module ${module.name}, script ${module.Rscript} finished. " />
|
|
</target>
|
|
|
|
<!-- The following line adds the common targets and properties
|
|
for Metrics' Java Projects.
|
|
-->
|
|
&base;
|
|
|
|
</project>
|
|
|