Skip to content
Snippets Groups Projects
Commit ea31db30 authored by Robert Butora's avatar Robert Butora
Browse files

cutout: separates PIXELS and imcopydav

parent 2cf01a36
Branches
Tags
No related merge requests found
...@@ -15,7 +15,10 @@ public interface Soda ...@@ -15,7 +15,10 @@ public interface Soda
{ {
public int doStream(String relPathname, int hdunum, 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; OutputStream outputStream) throws IOException, InterruptedException;
} }
......
...@@ -44,7 +44,7 @@ class SodaImpl implements Soda ...@@ -44,7 +44,7 @@ class SodaImpl implements Soda
public int doStream(String relPathname, int hdunum, 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 OutputStream outputStream) throws IOException, InterruptedException
{ {
Instant start = Instant.now(); Instant start = Instant.now();
...@@ -54,15 +54,6 @@ class SodaImpl implements Soda ...@@ -54,15 +54,6 @@ class SodaImpl implements Soda
LOGGER.finest("supplied outputStream for cut-file is null"); LOGGER.finest("supplied outputStream for cut-file is null");
// FIXME throw excpetion here // 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; boolean has_overlap = false;
String boundsString = ""; String boundsString = "";
JsonEncoder jReq = new JsonEncoder(); JsonEncoder jReq = new JsonEncoder();
...@@ -105,5 +96,55 @@ class SodaImpl implements Soda ...@@ -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());
}
}
} }
...@@ -128,7 +128,11 @@ public class ServletCutout extends HttpServlet ...@@ -128,7 +128,11 @@ public class ServletCutout extends HttpServlet
resolver.resolve(id); 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);
} }
...@@ -162,8 +166,10 @@ public class ServletCutout extends HttpServlet ...@@ -162,8 +166,10 @@ public class ServletCutout extends HttpServlet
String cutAbsPathname = settings.fitsPaths.cutouts() + "/" String cutAbsPathname = settings.fitsPaths.cutouts() + "/"
+ generateSubimgPathname(resolver.relPathname(), resolver.hdunum()); + generateSubimgPathname(resolver.relPathname(), resolver.hdunum());
vlkb.doFile(resolver.relPathname(), resolver.hdunum(), if(pixels != null)
pos, band, time, pol, pixels, cutAbsPathname); 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 // VLKB specific: null-value-count and extra-cards
......
...@@ -88,7 +88,7 @@ class VlkbCli implements Vlkb ...@@ -88,7 +88,7 @@ class VlkbCli implements Vlkb
} }
public CutResult doFileAmqp(String relPathname, int hdunum, 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, boolean countNullValues, FitsCard[] extraCards,
String cutAbsPathname) String cutAbsPathname)
throws IOException, InterruptedException throws IOException, InterruptedException
...@@ -101,8 +101,7 @@ class VlkbCli implements Vlkb ...@@ -101,8 +101,7 @@ class VlkbCli implements Vlkb
public void doFile(String relPathname, int hdunum, 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,
/*boolean countNullValues, FitsCard[] extraCards,*/
String cutAbsPathname) String cutAbsPathname)
throws IOException, InterruptedException throws IOException, InterruptedException
{ {
...@@ -110,25 +109,22 @@ class VlkbCli implements Vlkb ...@@ -110,25 +109,22 @@ class VlkbCli implements Vlkb
try(OutputStream fileOutputStream = new FileOutputStream(new File(cutAbsPathname))) 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; public void doFile(String relPathname, int hdunum,
cutResult.fileSize = Files.size(Paths.get(cutAbsPathname)); String pixels, String cutAbsPathname)
if(countNullValues) throws IOException, InterruptedException
{ {
cutResult.nullValueCount = doCountNullValues(cutAbsPathname, 1); LOGGER.fine("trace: " + cutAbsPathname );
}
if(extraCards == null || (extraCards.length < 1)) 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) public MCutResult doMCutout(String jdlJson, String workDir)
...@@ -205,7 +201,10 @@ class VlkbCli implements Vlkb ...@@ -205,7 +201,10 @@ class VlkbCli implements Vlkb
String cutAbsPathname = workDir + "/" String cutAbsPathname = workDir + "/"
+ generateSubimgPathname(ix, relPathname, hdunum, MAX_FILENAME_LEN); + 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.content = cutAbsPathname;
cut.contentType = MCutResult.Cut.ContentType.FILENAME; cut.contentType = MCutResult.Cut.ContentType.FILENAME;
......
...@@ -14,10 +14,15 @@ import vo.parameter.*; ...@@ -14,10 +14,15 @@ import vo.parameter.*;
public interface Vlkb public interface Vlkb
{ {
public void doFile(String relPathname, int hdunum, 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) String cutAbsPathname)
throws IOException, InterruptedException; throws IOException, InterruptedException;
public void doFile(String relPathname, int hdunum,
String pixels, String cutAbsPathname)
throws IOException, InterruptedException;
public MCutResult doMCutout(String jdlJson, String workDir) public MCutResult doMCutout(String jdlJson, String workDir)
throws IOException, InterruptedException; throws IOException, InterruptedException;
...@@ -34,7 +39,7 @@ public interface Vlkb ...@@ -34,7 +39,7 @@ public interface Vlkb
// deprecated - used only in VlkbAmqp // deprecated - used only in VlkbAmqp
public CutResult doFileAmqp(String relPathname, int hdunum, 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, boolean countNullValues, FitsCard[] extraCards,
String cutAbsPathname) String cutAbsPathname)
throws IOException, InterruptedException; throws IOException, InterruptedException;
......
...@@ -83,16 +83,24 @@ class VlkbAmqp implements Vlkb ...@@ -83,16 +83,24 @@ class VlkbAmqp implements Vlkb
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
public void doFile(String relPathname, int hdunum, 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 dummyCutAbsPathname)
/*boolean countNullValues, FitsCard[] extraCards,*/ String dummyCutAbsPathname)
throws IOException, InterruptedException throws IOException, InterruptedException
{ {
;// only placehoder for compatibility with Vlkb.java interface, ;// only placehoder for compatibility with Vlkb.java interface,
//Amqp support is deprecated //Amqp support is deprecated
} }
public void doFile(String relPathname, int hdunum,
String pixels, String dummyCutAbsPathname)
throws IOException, InterruptedException
{
;// only placehoder for compatibility with Vlkb.java interface,
//Amqp support is deprecated
}
public CutResult doFileAmqp(String relPathname, int hdunum, 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 dummyCutAbsPathname) boolean countNullValues, FitsCard[] extraCards, String dummyCutAbsPathname)
throws IOException, InterruptedException throws IOException, InterruptedException
{ {
...@@ -109,8 +117,6 @@ class VlkbAmqp implements Vlkb ...@@ -109,8 +117,6 @@ class VlkbAmqp implements Vlkb
jReq.add(time); jReq.add(time);
jReq.add(pol); jReq.add(pol);
// jReq.add(pixels), FIXME implement to supoort PIXLES in vlkb-legacy by AMQP
jReq.add(countNullValues); jReq.add(countNullValues);
jReq.add(extraCards); jReq.add(extraCards);
...@@ -123,7 +129,7 @@ class VlkbAmqp implements Vlkb ...@@ -123,7 +129,7 @@ class VlkbAmqp implements Vlkb
private CutResult doFileById(String id, Pos pos, Band band, Time time, Pol pol, String pixels, private CutResult doFileById(String id, Pos pos, Band band, Time time, Pol pol,
boolean countNullValues, Subsurvey[] subsurveys) boolean countNullValues, Subsurvey[] subsurveys)
throws IOException, InterruptedException throws IOException, InterruptedException
{ {
...@@ -147,7 +153,7 @@ class VlkbAmqp implements Vlkb ...@@ -147,7 +153,7 @@ class VlkbAmqp implements Vlkb
final String DEFAULT_TIME_SYSTEM = "MJD_UTC"; // FIXME take from confif file final String DEFAULT_TIME_SYSTEM = "MJD_UTC"; // FIXME take from confif file
CutResult cutResult = doFileAmqp(relPathname, hdunum, pos, band, time, pol, pixels, CutResult cutResult = doFileAmqp(relPathname, hdunum, pos, band, time, pol,
countNullValues, extraCards, null); countNullValues, extraCards, null);
return cutResult; return cutResult;
...@@ -224,8 +230,6 @@ class VlkbAmqp implements Vlkb ...@@ -224,8 +230,6 @@ class VlkbAmqp implements Vlkb
jReq.add(coord.time); jReq.add(coord.time);
jReq.add(coord.pol); jReq.add(coord.pol);
// jReq.add(pixels), FIXME implement to supoort PIXLES in vlkb-legacy by AMQP
jReq.add(countNullValues); jReq.add(countNullValues);
jReq.add(extraCards); jReq.add(extraCards);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment