Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-rest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
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
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-rest
Commits
ae47c967
Commit
ae47c967
authored
Jul 7, 2021
by
Sonia Zorba
Browse files
Options
Downloads
Patches
Plain Diff
Retrieved start/end time of jobs in JobDAO
parent
82291316
No related branches found
No related tags found
No related merge requests found
Pipeline
#2089
passed
Jul 7, 2021
Stage: build
Stage: test
Stage: dockerize
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/it/inaf/oats/vospace/persistence/JobDAO.java
+39
-35
39 additions, 35 deletions
src/main/java/it/inaf/oats/vospace/persistence/JobDAO.java
src/test/java/it/inaf/oats/vospace/persistence/JobDAOTest.java
+9
-1
9 additions, 1 deletion
...est/java/it/inaf/oats/vospace/persistence/JobDAOTest.java
with
48 additions
and
36 deletions
src/main/java/it/inaf/oats/vospace/persistence/JobDAO.java
+
39
−
35
View file @
ae47c967
...
...
@@ -51,8 +51,8 @@ public class JobDAO {
public
void
createJob
(
JobSummary
jobSummary
)
{
String
sql
=
"INSERT INTO job(job_id, owner_id, job_type, phase, job_info,"
String
sql
=
"INSERT INTO job(job_id, owner_id, job_type, phase, job_info,"
+
" error_message, error_type, error_has_detail, error_detail) "
+
"VALUES (?, ?, ?, ?, ?, ? ,? ,? ,?)"
;
...
...
@@ -125,6 +125,9 @@ public class JobDAO {
jobSummary
.
setPhase
(
ExecutionPhase
.
fromValue
(
rs
.
getString
(
"phase"
)));
jobSummary
.
setJobInfo
(
getJobPayload
(
rs
.
getString
(
"job_info"
)));
jobSummary
.
setResults
(
getResults
(
rs
.
getString
(
"results"
)));
jobSummary
.
setCreationTime
(
toXMLGregorianCalendar
(
rs
.
getTimestamp
(
"creation_time"
)));
jobSummary
.
setStartTime
(
toXMLGregorianCalendar
(
rs
.
getTimestamp
(
"start_time"
)));
jobSummary
.
setEndTime
(
toXMLGregorianCalendar
(
rs
.
getTimestamp
(
"end_time"
)));
// Retrieve error information if any
String
errorType
=
rs
.
getString
(
"error_type"
);
...
...
@@ -265,15 +268,13 @@ public class JobDAO {
String
sql
=
"UPDATE job SET (phase, results"
;
ErrorSummary
errorSummary
=
job
.
getErrorSummary
();
if
(
errorSummary
!=
null
)
{
if
(
errorSummary
!=
null
)
{
sql
+=
", error_message, error_type, error_has_detail, error_detail"
;
}
sql
+=
") = (?, ?"
;
if
(
errorSummary
!=
null
)
{
if
(
errorSummary
!=
null
)
{
sql
+=
", ?, ?, ?, ?"
;
}
...
...
@@ -283,8 +284,7 @@ public class JobDAO {
int
i
=
0
;
ps
.
setObject
(++
i
,
job
.
getPhase
().
name
(),
Types
.
OTHER
);
ps
.
setObject
(++
i
,
toJson
(
job
.
getResults
()),
Types
.
OTHER
);
if
(
errorSummary
!=
null
)
{
if
(
errorSummary
!=
null
)
{
ps
.
setString
(++
i
,
errorSummary
.
getMessage
());
ps
.
setObject
(++
i
,
errorSummary
.
getType
().
value
(),
Types
.
OTHER
);
ps
.
setBoolean
(++
i
,
errorSummary
.
isHasDetail
());
...
...
@@ -303,9 +303,9 @@ public class JobDAO {
}
public
static
XMLGregorianCalendar
toXMLGregorianCalendar
(
Timestamp
t
)
{
XMLGregorianCalendar
cal
=
null
;
if
(
t
!
=
null
)
{
try
{
cal
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
();
XMLGregorianCalendar
cal
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
();
LocalDateTime
ldt
=
t
.
toLocalDateTime
();
...
...
@@ -317,10 +317,14 @@ public class JobDAO {
cal
.
setSecond
(
ldt
.
getSecond
());
cal
.
setFractionalSecond
(
new
BigDecimal
(
"0."
+
ldt
.
getNano
()));
// return calendar only if it has been fully initialized (otherwise
// toString issue could appear); return null in other cases.
return
cal
;
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Error while generating XMLGregorianCalendar"
,
e
);
}
}
return
ca
l
;
return
nul
l
;
}
}
This diff is collapsed.
Click to expand it.
src/test/java/it/inaf/oats/vospace/persistence/JobDAOTest.java
+
9
−
1
View file @
ae47c967
...
...
@@ -29,6 +29,8 @@ import net.ivoa.xml.uws.v1.Jobs;
import
it.inaf.oats.vospace.exception.ErrorSummaryFactory
;
import
it.inaf.oats.vospace.exception.PermissionDeniedException
;
import
java.util.Arrays
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNull
;
@ExtendWith
(
SpringExtension
.
class
)
@ContextConfiguration
(
classes
=
{
DataSourceConfig
.
class
})
...
...
@@ -80,11 +82,16 @@ public class JobDAOTest {
// uses the job retrieved from DAO to perform the update (reproduced a bug in job update)
job
=
dao
.
getJob
(
"123"
).
get
();
assertNotNull
(
job
.
getCreationTime
());
assertNull
(
job
.
getStartTime
());
job
.
setPhase
(
ExecutionPhase
.
EXECUTING
);
dao
.
updateJob
(
job
);
assertEquals
(
ExecutionPhase
.
EXECUTING
,
dao
.
getJob
(
"123"
).
get
().
getPhase
());
job
=
dao
.
getJob
(
"123"
).
get
();
assertEquals
(
ExecutionPhase
.
EXECUTING
,
job
.
getPhase
());
assertNotNull
(
job
.
getStartTime
());
assertNull
(
job
.
getEndTime
());
}
@Test
...
...
@@ -143,6 +150,7 @@ public class JobDAOTest {
JobSummary
retrievedJob
=
retrievedJobOpt
.
get
();
assertEquals
(
ExecutionPhase
.
ERROR
,
retrievedJob
.
getPhase
());
assertTrue
(
areEqual
(
job
.
getErrorSummary
(),
retrievedJob
.
getErrorSummary
()));
assertNotNull
(
retrievedJob
.
getEndTime
());
}
@Test
...
...
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