Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vlkb-soda
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ViaLactea
vlkb-soda
Commits
cb30b206
Commit
cb30b206
authored
1 year ago
by
Robert Butora
Browse files
Options
Downloads
Patches
Plain Diff
(removes commented code from previous) implements response-*.json to add into tar.gz
parent
de78264d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
data-access/servlet/src/main/java/common/output/MCutResult.java
+10
-0
10 additions, 0 deletions
...ccess/servlet/src/main/java/common/output/MCutResult.java
data-access/servlet/src/main/java/cutout/DatasetsCli.java
+45
-54
45 additions, 54 deletions
data-access/servlet/src/main/java/cutout/DatasetsCli.java
with
55 additions
and
54 deletions
data-access/servlet/src/main/java/common/output/MCutResult.java
+
10
−
0
View file @
cb30b206
import
org.json.simple.JSONObject
;
class
MCutResult
class
MCutResult
{
{
...
@@ -10,6 +11,15 @@ class MCutResult
...
@@ -10,6 +11,15 @@ class MCutResult
public
int
index
;
public
int
index
;
public
ContentType
contentType
;
public
ContentType
contentType
;
public
String
content
;
public
String
content
;
JSONObject
toJsonObject
()
{
JSONObject
jo
=
new
JSONObject
();
//jo.put("input", inputs.toJsonObject());
jo
.
put
(
"type"
,
contentType
.
toString
());
jo
.
put
(
"content"
,
content
);
return
jo
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
data-access/servlet/src/main/java/cutout/DatasetsCli.java
+
45
−
54
View file @
cb30b206
...
@@ -32,6 +32,7 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
...
@@ -32,6 +32,7 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import
java.io.BufferedOutputStream
;
import
java.io.BufferedOutputStream
;
import
java.util.Date
;
import
java.util.Date
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
org.json.simple.JSONArray
;
import
vo.parameter.*
;
import
vo.parameter.*
;
...
@@ -89,7 +90,8 @@ class DatasetsCli implements Datasets
...
@@ -89,7 +90,8 @@ class DatasetsCli implements Datasets
CutArgs
[]
cutArgsArr
=
CutArgs
.
parseCutArgsArr
(
jdlJson
);
CutArgs
[]
cutArgsArr
=
CutArgs
.
parseCutArgsArr
(
jdlJson
);
MCutResult
.
Cut
[]
cutResultArr
=
doCutouts
(
cutArgsArr
);
MCutResult
.
Cut
[]
cutResultArr
=
doCutouts
(
cutArgsArr
);
mCutResult
=
doCompressCutFiles
(
cutResultArr
);
String
respJsonString
=
genResponseJson
(
cutResultArr
);
mCutResult
=
doCompressCutFiles
(
cutResultArr
,
respJsonString
);
return
mCutResult
;
return
mCutResult
;
}
}
...
@@ -121,46 +123,25 @@ class DatasetsCli implements Datasets
...
@@ -121,46 +123,25 @@ class DatasetsCli implements Datasets
// FIXME implement similar for Merge: MCutResult = call-Montage-demosaic-sequence(cutResultArr)
// FIXME implement similar for Merge: MCutResult = call-Montage-demosaic-sequence(cutResultArr)
private
MCutResult
doCompressCutFiles
(
MCutResult
.
Cut
[]
cutArr
)
private
MCutResult
doCompressCutFiles
(
MCutResult
.
Cut
[]
cutArr
,
String
respJsonString
)
throws
IOException
,
InterruptedException
throws
IOException
,
InterruptedException
{
{
String
timestamp
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
());
Instant
instant
=
Instant
.
now
();
String
timestamp
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
())
+
"_"
+
instant
.
getNano
();
final
String
tgzFileName
=
settings
.
fitsPaths
.
cutouts
()
+
"/mcutout_"
+
timestamp
+
".tar.gz"
;
final
String
tgzFileName
=
settings
.
fitsPaths
.
cutouts
()
+
"/mcutout_"
+
timestamp
+
".tar.gz"
;
/*
StringBuilder sb = new StringBuilder();
// generate response-*.json with timestamp
for(MCutResult.Cut cut : cutArr)
String
respJsonPathname
=
settings
.
fitsPaths
.
cutouts
()
+
"/response_"
+
timestamp
+
".json"
;
{
try
(
PrintWriter
out
=
new
PrintWriter
(
respJsonPathname
))
LOGGER.info("cut-id"+ String.valueOf(cut.index) + " -> " + cut.content);
if(cut.contentType == MCutResult.Cut.ContentType.FILENAME)
{
{
Path p = Paths.get(cut.content);
out
.
print
(
respJsonString
);
sb.append(" " + p.getFileName().toString());
}
}
}
String[] cmd = new String[6];
cmd[0] = "/bin/tar";
cmd[1] = "cfz";
cmd[2] = tgzFileName;
cmd[3] = "-C";
cmd[4] = settings.fitsPaths.cutouts();
cmd[5] = 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);
*/
List
<
Path
>
paths
=
new
ArrayList
<
Path
>();
List
<
Path
>
paths
=
new
ArrayList
<
Path
>();
paths
.
add
(
Paths
.
get
(
respJsonPathname
));
for
(
MCutResult
.
Cut
cut
:
cutArr
)
for
(
MCutResult
.
Cut
cut
:
cutArr
)
{
{
LOGGER
.
info
(
"cut-id"
+
String
.
valueOf
(
cut
.
index
)
+
" -> "
+
cut
.
content
);
LOGGER
.
info
(
"cut-id"
+
String
.
valueOf
(
cut
.
index
)
+
" -> "
+
cut
.
content
);
...
@@ -179,12 +160,26 @@ class DatasetsCli implements Datasets
...
@@ -179,12 +160,26 @@ class DatasetsCli implements Datasets
mCutResult
.
fileName
=
tgzFileName
;
mCutResult
.
fileName
=
tgzFileName
;
mCutResult
.
fileSize
=
Files
.
size
(
output
);
mCutResult
.
fileSize
=
Files
.
size
(
output
);
// FIXME add response.json to tar.gz, add nanosecs to timestamp
return
mCutResult
;
return
mCutResult
;
}
}
private
String
genResponseJson
(
MCutResult
.
Cut
[]
cutArr
)
{
List
<
Path
>
paths
=
new
ArrayList
<
Path
>();
JSONArray
jArr
=
new
JSONArray
();
for
(
MCutResult
.
Cut
cut
:
cutArr
)
{
jArr
.
add
(
cut
.
toJsonObject
());
}
return
jArr
.
toString
();
}
private
MCutResult
.
Cut
doFileByIdWithErr
(
String
id
,
Pos
pos
,
Band
band
,
Time
time
,
Pol
pol
,
String
pixels
,
private
MCutResult
.
Cut
doFileByIdWithErr
(
String
id
,
Pos
pos
,
Band
band
,
Time
time
,
Pol
pol
,
String
pixels
,
boolean
countNullValues
,
Subsurvey
[]
subsurveys
)
boolean
countNullValues
,
Subsurvey
[]
subsurveys
)
{
{
...
@@ -237,11 +232,8 @@ class DatasetsCli implements Datasets
...
@@ -237,11 +232,8 @@ class DatasetsCli implements Datasets
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
*/
*/
p
ublic
static
void
createTarGzipFiles
(
List
<
Path
>
paths
,
Path
output
)
p
rivate
static
void
createTarGzipFiles
(
List
<
Path
>
paths
,
Path
output
)
throws
IOException
throws
IOException
{
{
try
(
OutputStream
fOut
=
Files
.
newOutputStream
(
output
);
try
(
OutputStream
fOut
=
Files
.
newOutputStream
(
output
);
...
@@ -270,7 +262,6 @@ class DatasetsCli implements Datasets
...
@@ -270,7 +262,6 @@ class DatasetsCli implements Datasets
tOut
.
finish
();
tOut
.
finish
();
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment