Loading data-access/servlet/src/main/java/cutout/Soda.java +4 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,10 @@ public interface Soda { public int doStream(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, Pos pos, Band band, Time time, Pol pol, OutputStream outputStream) throws IOException, InterruptedException; public int doStream(String relPathname, int hdunum, String pixels, OutputStream outputStream) throws IOException, InterruptedException; } Loading data-access/servlet/src/main/java/cutout/SodaImpl.java +51 −10 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class SodaImpl implements Soda public int doStream(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, Pos pos, Band band, Time time, Pol pol, OutputStream outputStream) throws IOException, InterruptedException { Instant start = Instant.now(); Loading @@ -54,15 +54,6 @@ class SodaImpl implements Soda LOGGER.finest("supplied outputStream for cut-file is null"); // FIXME throw excpetion here //boolean pixels_valid = (pixels != null); //final boolean isDavCall = relPathname.startsWith("http://") // || relPathname.startsWith("https://"); //final boolean isAbsPath = relPathname.startsWith("/"); // Resolver removes schema from file:// // file:///some_abs_path -> /soma_abs_path // file://some_rel_path -> some_rel_path //String absPathname = (isDavCall || isAbsPath) ? relPathname // : (fitsPaths.surveys() +"/"+ relPathname); boolean has_overlap = false; String boundsString = ""; JsonEncoder jReq = new JsonEncoder(); Loading Loading @@ -105,5 +96,55 @@ class SodaImpl implements Soda } } public int doStream(String relPathname, int hdunum, String pixels, OutputStream outputStream) throws IOException, InterruptedException { Instant start = Instant.now(); LOGGER.fine("trace"); if(outputStream == null) LOGGER.finest("supplied outputStream for cut-file is null"); final boolean isDavCall= relPathname.startsWith("http://") || relPathname.startsWith("https://"); final boolean isAbsPath= relPathname.startsWith("/"); String absPathname = (isDavCall || isAbsPath) ? relPathname : (fitsPaths.surveys() +"/"+ relPathname); String[] cmd = new String[5]; cmd[0] = "/usr/local/bin/vlkb"; cmd[1] = (isDavCall) ? "imcopydav" : "imcopy"; cmd[2] = absPathname; cmd[3] = String.valueOf(hdunum); cmd[4] = pixels; LOGGER.finest(String.join(" ", cmd)); StringBuilder errorStrBuilder = new StringBuilder(); ExecCmd exec = new ExecCmd(); exec.doRun(outputStream, cmd, errorStrBuilder); int rc = exec.exitValue; LOGGER.finest("exec cutout exitValue: " + rc); LOGGER.finer("EXECTIME cutoutDone: " + Duration.between(start, Instant.now())); if(rc == 0) { return rc; // OK } else if(rc == 1) { return rc; // OK, but no overlap } else { throw new IllegalArgumentException( "overlap computation could not be completed with the given arguments. " + errorStrBuilder.toString()); } } } data-access/servlet/src/main/java/cutout/webapi/ServletCutout.java +9 −3 Original line number Diff line number Diff line Loading @@ -128,7 +128,11 @@ public class ServletCutout extends HttpServlet resolver.resolve(id); return soda.doStream(resolver.relPathname(), resolver.hdunum(), pos, band, time, pol, pixels, respOutputStream); if(pixels != null) return soda.doStream(resolver.relPathname(), resolver.hdunum(), pixels, respOutputStream); else return soda.doStream(resolver.relPathname(), resolver.hdunum(), pos, band, time, pol, respOutputStream); } Loading Loading @@ -162,8 +166,10 @@ public class ServletCutout extends HttpServlet String cutAbsPathname = settings.fitsPaths.cutouts() + "/" + generateSubimgPathname(resolver.relPathname(), resolver.hdunum()); vlkb.doFile(resolver.relPathname(), resolver.hdunum(), pos, band, time, pol, pixels, cutAbsPathname); if(pixels != null) vlkb.doFile(resolver.relPathname(), resolver.hdunum(), pos,band,time,pol, cutAbsPathname); else vlkb.doFile(resolver.relPathname(), resolver.hdunum(), pixels, cutAbsPathname); // VLKB specific: null-value-count and extra-cards Loading data-access/servlet/src/main/java/mcutout/VlkbCli.java +23 −24 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ class VlkbCli implements Vlkb } public CutResult doFileAmqp(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, Pos pos, Band band, Time time, Pol pol, boolean countNullValues, FitsCard[] extraCards, String cutAbsPathname) throws IOException, InterruptedException Loading @@ -101,8 +101,7 @@ class VlkbCli implements Vlkb public void doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, /*boolean countNullValues, FitsCard[] extraCards,*/ Pos pos, Band band, Time time, Pol pol, String cutAbsPathname) throws IOException, InterruptedException { Loading @@ -110,25 +109,22 @@ class VlkbCli implements Vlkb try(OutputStream fileOutputStream = new FileOutputStream(new File(cutAbsPathname))) { soda.doStream(relPathname, hdunum, pos, band, time, pol, pixels, fileOutputStream); soda.doStream(relPathname, hdunum, pos, band, time, pol, fileOutputStream); } } /* CutResult cutResult = new CutResult(); cutResult.fileName = cutAbsPathname; cutResult.fileSize = Files.size(Paths.get(cutAbsPathname)); if(countNullValues) public void doFile(String relPathname, int hdunum, String pixels, String cutAbsPathname) throws IOException, InterruptedException { cutResult.nullValueCount = doCountNullValues(cutAbsPathname, 1); } if(extraCards == null || (extraCards.length < 1)) LOGGER.fine("trace: " + cutAbsPathname ); try(OutputStream fileOutputStream = new FileOutputStream(new File(cutAbsPathname))) { LOGGER.finer("Adding extraCards to cut-file implemented only in VlkbAmql"); soda.doStream(relPathname, hdunum, pixels, fileOutputStream); } } cutResult.pixels = null; return cutResult; */ } public MCutResult doMCutout(String jdlJson, String workDir) Loading Loading @@ -205,7 +201,10 @@ class VlkbCli implements Vlkb String cutAbsPathname = workDir + "/" + generateSubimgPathname(ix, relPathname, hdunum, MAX_FILENAME_LEN); doFile(relPathname, hdunum, pos, band, time, pol, pixels, cutAbsPathname); if(pixels != null) doFile(relPathname, hdunum, pixels, cutAbsPathname); else doFile(relPathname, hdunum, pos, band, time, pol, cutAbsPathname); cut.content = cutAbsPathname; cut.contentType = MCutResult.Cut.ContentType.FILENAME; Loading data-access/servlet/src/main/java/vlkb/Vlkb.java +7 −2 Original line number Diff line number Diff line Loading @@ -14,10 +14,15 @@ import vo.parameter.*; public interface Vlkb { public void doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, Pos pos, Band band, Time time, Pol pol, String cutAbsPathname) throws IOException, InterruptedException; public void doFile(String relPathname, int hdunum, String pixels, String cutAbsPathname) throws IOException, InterruptedException; public MCutResult doMCutout(String jdlJson, String workDir) throws IOException, InterruptedException; Loading @@ -34,7 +39,7 @@ public interface Vlkb // deprecated - used only in VlkbAmqp public CutResult doFileAmqp(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, Pos pos, Band band, Time time, Pol pol, boolean countNullValues, FitsCard[] extraCards, String cutAbsPathname) throws IOException, InterruptedException; Loading Loading
data-access/servlet/src/main/java/cutout/Soda.java +4 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,10 @@ public interface Soda { public int doStream(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, Pos pos, Band band, Time time, Pol pol, OutputStream outputStream) throws IOException, InterruptedException; public int doStream(String relPathname, int hdunum, String pixels, OutputStream outputStream) throws IOException, InterruptedException; } Loading
data-access/servlet/src/main/java/cutout/SodaImpl.java +51 −10 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class SodaImpl implements Soda public int doStream(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, Pos pos, Band band, Time time, Pol pol, OutputStream outputStream) throws IOException, InterruptedException { Instant start = Instant.now(); Loading @@ -54,15 +54,6 @@ class SodaImpl implements Soda LOGGER.finest("supplied outputStream for cut-file is null"); // FIXME throw excpetion here //boolean pixels_valid = (pixels != null); //final boolean isDavCall = relPathname.startsWith("http://") // || relPathname.startsWith("https://"); //final boolean isAbsPath = relPathname.startsWith("/"); // Resolver removes schema from file:// // file:///some_abs_path -> /soma_abs_path // file://some_rel_path -> some_rel_path //String absPathname = (isDavCall || isAbsPath) ? relPathname // : (fitsPaths.surveys() +"/"+ relPathname); boolean has_overlap = false; String boundsString = ""; JsonEncoder jReq = new JsonEncoder(); Loading Loading @@ -105,5 +96,55 @@ class SodaImpl implements Soda } } public int doStream(String relPathname, int hdunum, String pixels, OutputStream outputStream) throws IOException, InterruptedException { Instant start = Instant.now(); LOGGER.fine("trace"); if(outputStream == null) LOGGER.finest("supplied outputStream for cut-file is null"); final boolean isDavCall= relPathname.startsWith("http://") || relPathname.startsWith("https://"); final boolean isAbsPath= relPathname.startsWith("/"); String absPathname = (isDavCall || isAbsPath) ? relPathname : (fitsPaths.surveys() +"/"+ relPathname); String[] cmd = new String[5]; cmd[0] = "/usr/local/bin/vlkb"; cmd[1] = (isDavCall) ? "imcopydav" : "imcopy"; cmd[2] = absPathname; cmd[3] = String.valueOf(hdunum); cmd[4] = pixels; LOGGER.finest(String.join(" ", cmd)); StringBuilder errorStrBuilder = new StringBuilder(); ExecCmd exec = new ExecCmd(); exec.doRun(outputStream, cmd, errorStrBuilder); int rc = exec.exitValue; LOGGER.finest("exec cutout exitValue: " + rc); LOGGER.finer("EXECTIME cutoutDone: " + Duration.between(start, Instant.now())); if(rc == 0) { return rc; // OK } else if(rc == 1) { return rc; // OK, but no overlap } else { throw new IllegalArgumentException( "overlap computation could not be completed with the given arguments. " + errorStrBuilder.toString()); } } }
data-access/servlet/src/main/java/cutout/webapi/ServletCutout.java +9 −3 Original line number Diff line number Diff line Loading @@ -128,7 +128,11 @@ public class ServletCutout extends HttpServlet resolver.resolve(id); return soda.doStream(resolver.relPathname(), resolver.hdunum(), pos, band, time, pol, pixels, respOutputStream); if(pixels != null) return soda.doStream(resolver.relPathname(), resolver.hdunum(), pixels, respOutputStream); else return soda.doStream(resolver.relPathname(), resolver.hdunum(), pos, band, time, pol, respOutputStream); } Loading Loading @@ -162,8 +166,10 @@ public class ServletCutout extends HttpServlet String cutAbsPathname = settings.fitsPaths.cutouts() + "/" + generateSubimgPathname(resolver.relPathname(), resolver.hdunum()); vlkb.doFile(resolver.relPathname(), resolver.hdunum(), pos, band, time, pol, pixels, cutAbsPathname); if(pixels != null) vlkb.doFile(resolver.relPathname(), resolver.hdunum(), pos,band,time,pol, cutAbsPathname); else vlkb.doFile(resolver.relPathname(), resolver.hdunum(), pixels, cutAbsPathname); // VLKB specific: null-value-count and extra-cards Loading
data-access/servlet/src/main/java/mcutout/VlkbCli.java +23 −24 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ class VlkbCli implements Vlkb } public CutResult doFileAmqp(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, Pos pos, Band band, Time time, Pol pol, boolean countNullValues, FitsCard[] extraCards, String cutAbsPathname) throws IOException, InterruptedException Loading @@ -101,8 +101,7 @@ class VlkbCli implements Vlkb public void doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, /*boolean countNullValues, FitsCard[] extraCards,*/ Pos pos, Band band, Time time, Pol pol, String cutAbsPathname) throws IOException, InterruptedException { Loading @@ -110,25 +109,22 @@ class VlkbCli implements Vlkb try(OutputStream fileOutputStream = new FileOutputStream(new File(cutAbsPathname))) { soda.doStream(relPathname, hdunum, pos, band, time, pol, pixels, fileOutputStream); soda.doStream(relPathname, hdunum, pos, band, time, pol, fileOutputStream); } } /* CutResult cutResult = new CutResult(); cutResult.fileName = cutAbsPathname; cutResult.fileSize = Files.size(Paths.get(cutAbsPathname)); if(countNullValues) public void doFile(String relPathname, int hdunum, String pixels, String cutAbsPathname) throws IOException, InterruptedException { cutResult.nullValueCount = doCountNullValues(cutAbsPathname, 1); } if(extraCards == null || (extraCards.length < 1)) LOGGER.fine("trace: " + cutAbsPathname ); try(OutputStream fileOutputStream = new FileOutputStream(new File(cutAbsPathname))) { LOGGER.finer("Adding extraCards to cut-file implemented only in VlkbAmql"); soda.doStream(relPathname, hdunum, pixels, fileOutputStream); } } cutResult.pixels = null; return cutResult; */ } public MCutResult doMCutout(String jdlJson, String workDir) Loading Loading @@ -205,7 +201,10 @@ class VlkbCli implements Vlkb String cutAbsPathname = workDir + "/" + generateSubimgPathname(ix, relPathname, hdunum, MAX_FILENAME_LEN); doFile(relPathname, hdunum, pos, band, time, pol, pixels, cutAbsPathname); if(pixels != null) doFile(relPathname, hdunum, pixels, cutAbsPathname); else doFile(relPathname, hdunum, pos, band, time, pol, cutAbsPathname); cut.content = cutAbsPathname; cut.contentType = MCutResult.Cut.ContentType.FILENAME; Loading
data-access/servlet/src/main/java/vlkb/Vlkb.java +7 −2 Original line number Diff line number Diff line Loading @@ -14,10 +14,15 @@ import vo.parameter.*; public interface Vlkb { public void doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, Pos pos, Band band, Time time, Pol pol, String cutAbsPathname) throws IOException, InterruptedException; public void doFile(String relPathname, int hdunum, String pixels, String cutAbsPathname) throws IOException, InterruptedException; public MCutResult doMCutout(String jdlJson, String workDir) throws IOException, InterruptedException; Loading @@ -34,7 +39,7 @@ public interface Vlkb // deprecated - used only in VlkbAmqp public CutResult doFileAmqp(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, String pixels, Pos pos, Band band, Time time, Pol pol, boolean countNullValues, FitsCard[] extraCards, String cutAbsPathname) throws IOException, InterruptedException; Loading