Commit 6a2999f8 authored by Robert Butora's avatar Robert Butora
Browse files

implements compressing tar.gz of mcutout files

parent 304a9173
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ public interface Datasets


   public MCutResult doMCutout(String jdlJson)
      throws IOException;
      throws IOException, InterruptedException;

}
+31 −4
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ class DatasetsCli implements Datasets


   public MCutResult doMCutout(String jdlJson)
         throws IOException
      throws IOException, InterruptedException
      {
         LOGGER.info("trace");

@@ -114,18 +114,45 @@ class DatasetsCli implements Datasets

   // FIXME implement similar for Merge: MCutResult = call-Montage-demosaic-sequence(cutResultArr)
   private MCutResult doCompressCutFiles(MCutResult.Cut[] cutArr)
      throws IOException, InterruptedException
   {
      // FIXME do compression here
      StringBuilder sb = new StringBuilder();
      for(MCutResult.Cut cut : cutArr)
      {
         LOGGER.info("TBD compress cut-id"+ String.valueOf(cut.index) + " -> " + cut.content);
         LOGGER.info("cut-id"+ String.valueOf(cut.index) + " -> " + cut.content);
         if(cut.contentType == MCutResult.Cut.ContentType.FILENAME)
         {
            sb.append(" " + cut.content);
         }
      }

      final String tgzFileName = settings.fitsPaths.cutouts() + "/mcutout_TIMESTAMP.tar.gz";

      String[] cmd = new String[4];
      cmd[0] = "/bin/tar";
      cmd[1] = "cfz";
      cmd[2] = tgzFileName;
      cmd[3] = sb.toString();

      LOGGER.info("CMD: " + String.join(" ",cmd));

      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      if(bos == null)
         throw new AssertionError("byte output stream for bounds was not created, is null");

      ExecCmd exec = new ExecCmd();
      exec.doRun(bos, cmd);
      LOGGER.info("exec tar.gz exitValue: " + exec.exitValue);

      boolean has_result = (exec.exitValue == 0);

      MCutResult mCutResult = new MCutResult();
      mCutResult.cutResArr = cutArr;
      mCutResult.fileName = "filename.tar.gz"; // FIXME do-zip-all-cuts(cutResultArr)
      mCutResult.fileName = tgzFileName;
      mCutResult.fileSize = 0;

      // FIXME add timestamp, add filesize when successful

      return mCutResult;
   }

+1 −1
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ public class ServletMCutout extends javax.servlet.http.HttpServlet


      }
      catch(IOException ex)
      catch(Exception ex)
      {
         /* FIXME find better exception */
         throw new AssertionError("internal error: jsonFile.open() throws IOException:" + ex.getMessage());