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

cutout: implements Coutput::doFile with doStream into localfile if AMQP hostname not configured

parent a15f93cf
Branches
No related tags found
No related merge requests found
...@@ -6,6 +6,13 @@ class NullValueCount ...@@ -6,6 +6,13 @@ class NullValueCount
double percent; double percent;
long nullCount; long nullCount;
long totalCount; long totalCount;
NullValueCount()
{
percent = 0.0;
nullCount = 0;
totalCount = 0;
}
} }
...@@ -17,7 +17,9 @@ public interface Cutout ...@@ -17,7 +17,9 @@ public interface Cutout
public CutResult doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, public CutResult doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol,
boolean countNullValues, FitsCard[] extraCards); boolean countNullValues, FitsCard[] extraCards)
throws IOException, InterruptedException;
;
} }
...@@ -16,6 +16,7 @@ import java.io.PrintWriter; ...@@ -16,6 +16,7 @@ import java.io.PrintWriter;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.nio.file.StandardOpenOption; import java.nio.file.StandardOpenOption;
import java.nio.file.Files; import java.nio.file.Files;
...@@ -184,11 +185,32 @@ class CutoutImpl implements Cutout ...@@ -184,11 +185,32 @@ class CutoutImpl implements Cutout
public CutResult doFile(String relPathname, int hdunum, public CutResult doFile(String relPathname, int hdunum,
Pos pos, Band band, Time time, Pol pol, Pos pos, Band band, Time time, Pol pol,
boolean countNullValues, FitsCard[] extraCards) boolean countNullValues, FitsCard[] extraCards)
throws IOException, InterruptedException
{ {
LOGGER.info("trace: " + pos.toString() ); LOGGER.info("trace: " + pos.toString() );
String absSubimgPathname = settings.fitsPaths.cutouts() + "/" + generateSubimgPathname(relPathname, hdunum); CutResult cutResult = new CutResult();
if(settings.amqpConn.isHostnameEmpty())
{
String absSubimgPathname = settings.fitsPaths.cutouts()
+ "/" + generateSubimgPathname(relPathname, hdunum);
OutputStream fileOutputStream = new FileOutputStream( new File(absSubimgPathname) );
doStream(relPathname, hdunum, pos, band, time, pol, fileOutputStream);
// engine returns absPathname see common/cutout.cpp::do_cutout_file()
cutResult.filename = absSubimgPathname;
cutResult.filesize = Files.size(Paths.get(absSubimgPathname));
if(countNullValues)
{
LOGGER.info("NullValuesCount not implemented when used with Cutout::doStream()");
}
}
else
{
JsonEncoder jReq = new JsonEncoder(); JsonEncoder jReq = new JsonEncoder();
jReq.add(relPathname, hdunum); jReq.add(relPathname, hdunum);
jReq.add(pos); jReq.add(pos);
...@@ -200,7 +222,10 @@ class CutoutImpl implements Cutout ...@@ -200,7 +222,10 @@ class CutoutImpl implements Cutout
String outJson = doRpc( jReq.toString() ); String outJson = doRpc( jReq.toString() );
return JsonDecoder.responseFromCutoutJson( outJson ); cutResult = JsonDecoder.responseFromCutoutJson( outJson );
}
return cutResult;
} }
......
...@@ -113,7 +113,7 @@ public class ServletCutout extends javax.servlet.http.HttpServlet ...@@ -113,7 +113,7 @@ public class ServletCutout extends javax.servlet.http.HttpServlet
protected void doCutoutFileStream(String id, Pos pos, Band band, Time time, Pol pol, OutputStream respOutputStream) protected void doCutoutFileStream(String id, Pos pos, Band band, Time time, Pol pol, OutputStream respOutputStream)
throws IOException throws IOException, InterruptedException
{ {
LOGGER.info("trace" + pos); LOGGER.info("trace" + pos);
...@@ -137,6 +137,7 @@ public class ServletCutout extends javax.servlet.http.HttpServlet ...@@ -137,6 +137,7 @@ public class ServletCutout extends javax.servlet.http.HttpServlet
protected DataLink doCutoutFile(String id, Pos pos, Band band, Time time, Pol pol, protected DataLink doCutoutFile(String id, Pos pos, Band band, Time time, Pol pol,
boolean countNullValues, String respFormat) boolean countNullValues, String respFormat)
throws IOException, InterruptedException
{ {
LOGGER.info("trace"); LOGGER.info("trace");
......
...@@ -71,6 +71,11 @@ class Settings ...@@ -71,6 +71,11 @@ class Settings
public int portNumber() { return portNum; } public int portNumber() { return portNum; }
public String routingKey() { return routingKey; } public String routingKey() { return routingKey; }
public boolean isHostnameEmpty()
{
return ( (hostName == null) || hostName.trim().isEmpty() );
}
public String toString() public String toString()
{ {
return hostName + " " + String.valueOf(portNum) + " " + routingKey; return hostName + " " + String.valueOf(portNum) + " " + routingKey;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment