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
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,13 @@ class NullValueCount
double percent;
long nullCount;
long totalCount;
NullValueCount()
{
percent = 0.0;
nullCount = 0;
totalCount = 0;
}
}
......@@ -17,7 +17,9 @@ public interface Cutout
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;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.nio.file.StandardOpenOption;
import java.nio.file.Files;
......@@ -184,11 +185,32 @@ class CutoutImpl implements Cutout
public CutResult doFile(String relPathname, int hdunum,
Pos pos, Band band, Time time, Pol pol,
boolean countNullValues, FitsCard[] extraCards)
throws IOException, InterruptedException
{
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();
jReq.add(relPathname, hdunum);
jReq.add(pos);
......@@ -200,7 +222,10 @@ class CutoutImpl implements Cutout
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
protected void doCutoutFileStream(String id, Pos pos, Band band, Time time, Pol pol, OutputStream respOutputStream)
throws IOException
throws IOException, InterruptedException
{
LOGGER.info("trace" + pos);
......@@ -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,
boolean countNullValues, String respFormat)
throws IOException, InterruptedException
{
LOGGER.info("trace");
......
......@@ -71,6 +71,11 @@ class Settings
public int portNumber() { return portNum; }
public String routingKey() { return routingKey; }
public boolean isHostnameEmpty()
{
return ( (hostName == null) || hostName.trim().isEmpty() );
}
public String toString()
{
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