chiark / gitweb /
debug write out deduped.tsv.gz not deduped.tsv
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Sep 2010 13:28:02 +0000 (14:28 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Sep 2010 13:28:02 +0000 (14:28 +0100)
src/com/tedpearson/ypp/market/MarketUploader.java

index 5fb927a..90a920a 100644 (file)
@@ -105,6 +105,13 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
            strm.close();
        }
 
+        private void debug_write_bytes(String what, byte[] data) throws FileNotFoundException,IOException {
+           if (dtxt==null) return;
+           FileOutputStream strm = new FileOutputStream(new File("jarrg-debug-"+what));
+           strm.write(data);
+           strm.close();
+       }
+
         private void progressNote(ProgressMonitor pm, String s) {
            String arb = null;
            if (arbitrageResult != null)
@@ -537,8 +544,6 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                        progressNote(pm, "Yarrg: Uploading");
                        progresslog("yarrg upload...");
 
-                       debug_write_stringdata("yarrg-deduped.tsv", yarrgdata);
-
                        doneyarrg = runYarrg(yarrgts, oceanName, islandName, yarrgdata);
                        progresslog("yarrg done.");
                }
@@ -586,11 +591,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                    progresslog("pctb send...");
 
                    byte[] ba = outStream.toByteArray();
-                   if (dtxt!=null) {
-                       FileOutputStream dbgdata = new FileOutputStream(new File("jarrg-debug-pctb-marketdata.gz"));
-                       dbgdata.write(ba);
-                       dbgdata.close();
-                   }
+                   debug_write_bytes("pctb-marketdata.gz", ba);
 
                    InputStream in = sendInitialData(new ByteArrayInputStream(ba));
                    progresslog("pctb sent.");
@@ -1055,7 +1056,9 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
        BufferedOutputStream bufos = new BufferedOutputStream(new GZIPOutputStream(bos));
        bufos.write(yarrgdata.getBytes() );
        bufos.close();
-       ByteArrayInputStream file = new ByteArrayInputStream(bos.toByteArray());
+       byte[] compressed = bos.toByteArray();
+       debug_write_bytes("yarrg-deduped.tsv.gz", compressed);
+       ByteArrayInputStream file = new ByteArrayInputStream(compressed);
 
        ClientHttpRequest http = new ClientHttpRequest (YARRG_URL);
        http.setParameter("clientname", YARRG_CLIENTNAME);