Loading src/main/java/org/torproject/onionoo/cron/Main.java +4 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ * See LICENSE for licensing information */ package org.torproject.onionoo.cron; import java.io.File; import java.util.Calendar; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; Loading Loading @@ -141,6 +142,8 @@ public class Main implements Runnable { private DocumentStore ds; private File outDir = new File("out"); private StatusUpdateRunner sur; private DocumentWriterRunner dwr; Loading @@ -160,6 +163,7 @@ public class Main implements Runnable { this.log.info("Initialized status update runner"); } if (!this.downloadOnly && !this.updateOnly) { this.ds.setOutDir(outDir); this.dwr = new DocumentWriterRunner(); this.log.info("Initialized document writer runner"); } Loading src/main/java/org/torproject/onionoo/docs/DocumentStore.java +9 −12 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -45,12 +44,8 @@ public class DocumentStore { private final File statusDir = new File("status"); private File outDir = new File("out"); public void setOutDir(File outDir) throws FileNotFoundException { if (!outDir.exists() || !outDir.isDirectory()) { throw new FileNotFoundException("Cannot access directory " + outDir); } private File outDir = null; public void setOutDir(File outDir) { this.outDir = outDir; } Loading Loading @@ -156,9 +151,8 @@ public class DocumentStore { private void cacheSummaryDocuments() { SortedMap<String, SummaryDocument> parsedSummaryDocuments = new TreeMap<String, SummaryDocument>(); File directory = this.outDir; if (directory != null) { File summaryFile = new File(directory, "summary"); if (this.outDir != null) { File summaryFile = new File(this.outDir, "summary"); if (summaryFile.exists()) { String line = null; try { Loading Loading @@ -757,6 +751,10 @@ public class DocumentStore { } private void writeSummaryDocuments() { if (this.outDir == null) { /* Can't write out/summary without knowing the path of out/. */ return; } StringBuilder sb = new StringBuilder(); Gson gson = new Gson(); for (SummaryDocument summaryDocument : Loading Loading @@ -786,8 +784,7 @@ public class DocumentStore { private void writeUpdateStatus() { if (this.outDir == null) { log.error("Unable to write update status file without knowing the " + "'out' directory to write to!"); /* Can't write out/update without knowing the path of out/. */ return; } UpdateStatus updateStatus = new UpdateStatus(); Loading src/main/java/org/torproject/onionoo/server/NodeIndexer.java +3 −4 Original line number Diff line number Diff line Loading @@ -35,14 +35,13 @@ public class NodeIndexer implements ServletContextListener, Runnable { public void contextInitialized(ServletContextEvent contextEvent) { ServletContext servletContext = contextEvent.getServletContext(); File outDir = new File(servletContext.getInitParameter("outDir")); DocumentStore documentStore = DocumentStoreFactory.getDocumentStore(); try { documentStore.setOutDir(outDir); } catch(FileNotFoundException fnfe) { if (!outDir.exists() || !outDir.isDirectory()) { log.error("\n\n\tOut-dir not found! Expected directory: " + outDir + "\n\tVerify the configuration in ./etc/web.xml.template"); System.exit(1); } DocumentStore documentStore = DocumentStoreFactory.getDocumentStore(); documentStore.setOutDir(outDir); /* The servlet container created us, and we need to avoid that * ApplicationFactory creates another instance of us. */ NodeIndexerFactory.setNodeIndexer(this); Loading Loading
src/main/java/org/torproject/onionoo/cron/Main.java +4 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ * See LICENSE for licensing information */ package org.torproject.onionoo.cron; import java.io.File; import java.util.Calendar; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; Loading Loading @@ -141,6 +142,8 @@ public class Main implements Runnable { private DocumentStore ds; private File outDir = new File("out"); private StatusUpdateRunner sur; private DocumentWriterRunner dwr; Loading @@ -160,6 +163,7 @@ public class Main implements Runnable { this.log.info("Initialized status update runner"); } if (!this.downloadOnly && !this.updateOnly) { this.ds.setOutDir(outDir); this.dwr = new DocumentWriterRunner(); this.log.info("Initialized document writer runner"); } Loading
src/main/java/org/torproject/onionoo/docs/DocumentStore.java +9 −12 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -45,12 +44,8 @@ public class DocumentStore { private final File statusDir = new File("status"); private File outDir = new File("out"); public void setOutDir(File outDir) throws FileNotFoundException { if (!outDir.exists() || !outDir.isDirectory()) { throw new FileNotFoundException("Cannot access directory " + outDir); } private File outDir = null; public void setOutDir(File outDir) { this.outDir = outDir; } Loading Loading @@ -156,9 +151,8 @@ public class DocumentStore { private void cacheSummaryDocuments() { SortedMap<String, SummaryDocument> parsedSummaryDocuments = new TreeMap<String, SummaryDocument>(); File directory = this.outDir; if (directory != null) { File summaryFile = new File(directory, "summary"); if (this.outDir != null) { File summaryFile = new File(this.outDir, "summary"); if (summaryFile.exists()) { String line = null; try { Loading Loading @@ -757,6 +751,10 @@ public class DocumentStore { } private void writeSummaryDocuments() { if (this.outDir == null) { /* Can't write out/summary without knowing the path of out/. */ return; } StringBuilder sb = new StringBuilder(); Gson gson = new Gson(); for (SummaryDocument summaryDocument : Loading Loading @@ -786,8 +784,7 @@ public class DocumentStore { private void writeUpdateStatus() { if (this.outDir == null) { log.error("Unable to write update status file without knowing the " + "'out' directory to write to!"); /* Can't write out/update without knowing the path of out/. */ return; } UpdateStatus updateStatus = new UpdateStatus(); Loading
src/main/java/org/torproject/onionoo/server/NodeIndexer.java +3 −4 Original line number Diff line number Diff line Loading @@ -35,14 +35,13 @@ public class NodeIndexer implements ServletContextListener, Runnable { public void contextInitialized(ServletContextEvent contextEvent) { ServletContext servletContext = contextEvent.getServletContext(); File outDir = new File(servletContext.getInitParameter("outDir")); DocumentStore documentStore = DocumentStoreFactory.getDocumentStore(); try { documentStore.setOutDir(outDir); } catch(FileNotFoundException fnfe) { if (!outDir.exists() || !outDir.isDirectory()) { log.error("\n\n\tOut-dir not found! Expected directory: " + outDir + "\n\tVerify the configuration in ./etc/web.xml.template"); System.exit(1); } DocumentStore documentStore = DocumentStoreFactory.getDocumentStore(); documentStore.setOutDir(outDir); /* The servlet container created us, and we need to avoid that * ApplicationFactory creates another instance of us. */ NodeIndexerFactory.setNodeIndexer(this); Loading