Skip to content

Commit 04cf240

Browse files
authored
Merge branch 'main' into fix-queued-workflow-delete
2 parents e940aa9 + b98a2f9 commit 04cf240

File tree

9 files changed

+160
-26
lines changed

9 files changed

+160
-26
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: "Code scanning - action"
22

33
on:
44
push:
5+
branches: [main]
56
pull_request:
7+
branches: [main]
68
schedule:
79
- cron: '0 9 * * 0'
810

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ This application can be started with [Docker](https://www.docker.com/) and [Dock
3838

3939
Then run the following commands to clone the project in your local system.
4040

41-
```
41+
```
4242
git clone https://github.com/common-workflow-language/cwlviewer.git
43-
cd cwlviewer
43+
cd cwlviewer
4444
```
4545

4646
In the project directory, to start CWLViewer exposed on port `8080`, run:
4747

4848
docker-compose up
49-
50-
The web server will connect to a local host, you'll see the message saying "Tomacat started on port(s):8080".
5149

52-
To see the locally running CWL Viewer app, visit http://localhost:8080/ in your web browser.
53-
50+
The web server will connect to a local host, you'll see the message saying "Tomacat started on port(s):8080".
51+
52+
To see the locally running CWL Viewer app, visit http://localhost:8080/ in your web browser.
53+
5454
To stop and remove:
5555

5656
docker-compose down
@@ -72,6 +72,44 @@ If you have modified the source code, then you may want to build the docker imag
7272
7373
docker build -t commonworkflowlanguage/cwlviewer .
7474
75+
## Running Spring Boot locally for development, with MongoDB and Jena Fuseki in Docker
76+
77+
Create `docker-compose.override.yml`:
78+
79+
```
80+
version: '3.2'
81+
services:
82+
mongo:
83+
ports:
84+
- "27017:27017"
85+
sparql:
86+
ports:
87+
- "3030:3030"
88+
```
89+
90+
Then start the containers:
91+
92+
```
93+
docker-compose up
94+
```
95+
96+
Then start Spring Boot locally:
97+
98+
```
99+
mvn spring-boot:run -Dserver.port=7999
100+
```
101+
102+
Now you can connect to http://localhost:7999 in your browser.
103+
104+
## Deleting the data volumes to reset state
105+
106+
To completely reset the state, you must delete the data volumes:
107+
108+
```
109+
docker-compose down
110+
docker volume rm cwlviewer_bundle cwlviewer_git cwlviewer_graphviz cwlviewer_mongo cwlviewer_sparql
111+
```
112+
75113
## Running without Docker
76114
77115
### Requirements

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2424
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2525
<java.version>1.8</java.version>
26-
<jena.version>4.0.0</jena.version>
26+
<jena.version>4.1.0</jena.version>
2727
<!-- BEGIN should correspond to https://repo1.maven.org/maven2/org/apache/jena/jena/3.9.0/jena-3.9.0.pom -->
2828
<ver.jsonldjava>0.13.3</ver.jsonldjava>
29-
<ver.jackson>2.12.3</ver.jackson>
29+
<ver.jackson>2.12.4</ver.jackson>
3030
<!-- END -->
3131
</properties>
3232

@@ -70,7 +70,7 @@
7070
<dependency>
7171
<groupId>org.yaml</groupId>
7272
<artifactId>snakeyaml</artifactId>
73-
<version>1.28</version>
73+
<version>1.29</version>
7474
</dependency>
7575
<dependency>
7676
<groupId>com.github.jabbalaci</groupId>
@@ -106,7 +106,7 @@
106106
<dependency>
107107
<groupId>org.eclipse.jgit</groupId>
108108
<artifactId>org.eclipse.jgit</artifactId>
109-
<version>5.11.0.202103091610-r</version>
109+
<version>5.12.0.202106070339-r</version>
110110
</dependency>
111111
<dependency>
112112
<groupId>org.mockito</groupId>
@@ -117,7 +117,7 @@
117117
<dependency>
118118
<groupId>org.apache.commons</groupId>
119119
<artifactId>commons-compress</artifactId>
120-
<version>1.20</version>
120+
<version>1.21</version>
121121
</dependency>
122122
</dependencies>
123123

src/main/java/org/commonwl/view/CwlViewerApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
import org.springframework.boot.autoconfigure.SpringBootApplication;
2424
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
2525
import org.springframework.scheduling.annotation.EnableAsync;
26+
import org.springframework.scheduling.annotation.EnableScheduling;
2627

2728
@SpringBootApplication
2829
@EnableMongoRepositories
2930
@EnableAsync
31+
@EnableScheduling
3032
public class CwlViewerApplication {
3133

3234
public static void main(String[] args) {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.commonwl.view;
2+
3+
4+
import org.commonwl.view.workflow.QueuedWorkflowRepository;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.beans.factory.annotation.Value;
9+
import org.springframework.scheduling.annotation.Scheduled;
10+
import org.springframework.stereotype.Component;
11+
12+
import java.util.Calendar;
13+
import java.util.Date;
14+
15+
/**
16+
* Scheduler class for recurrent processes.
17+
*/
18+
@Component
19+
public class Scheduler {
20+
21+
private final Logger logger = LoggerFactory.getLogger(this.getClass());
22+
private final QueuedWorkflowRepository queuedWorkflowRepository;
23+
24+
@Value("${queuedWorkflowAgeLimitHours}")
25+
private Integer QUEUED_WORKFLOW_AGE_LIMIT_HOURS;
26+
27+
@Autowired
28+
public Scheduler(QueuedWorkflowRepository queuedWorkflowRepository) {
29+
this.queuedWorkflowRepository = queuedWorkflowRepository;
30+
}
31+
32+
33+
/**
34+
* A Scheduled function to delete old queued workflow entries
35+
* from the queue. Age is determined by QUEUED_WORKFLOW_AGE_LIMIT_HOURS
36+
*/
37+
@Scheduled(cron = "${cron.deleteOldQueuedWorkflows}")
38+
public void removeOldQueuedWorkflowEntries() {
39+
Calendar calendar = Calendar.getInstance();
40+
Date now = new Date();
41+
calendar.setTime(now);
42+
43+
if (QUEUED_WORKFLOW_AGE_LIMIT_HOURS == null) {
44+
QUEUED_WORKFLOW_AGE_LIMIT_HOURS = 24;
45+
}
46+
47+
// calculate time QUEUED_WORKFLOW_AGE_LIMIT_HOURS before now
48+
calendar.add(Calendar.HOUR, -QUEUED_WORKFLOW_AGE_LIMIT_HOURS);
49+
Date removeTime = calendar.getTime();
50+
51+
logger.info("The time is " + now);
52+
logger.info("Delete time interval is : OLDER THAN " + QUEUED_WORKFLOW_AGE_LIMIT_HOURS + " HOURS");
53+
logger.info("Deleting queued workflows older than or equal to " + removeTime);
54+
55+
logger.info(queuedWorkflowRepository.deleteByTempRepresentation_RetrievedOnLessThanEqual(removeTime)
56+
+ " Old queued workflows removed");
57+
}
58+
}

src/main/java/org/commonwl/view/workflow/QueuedWorkflowRepository.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import org.springframework.data.mongodb.repository.Query;
55
import org.springframework.data.repository.PagingAndSortingRepository;
66

7+
import java.util.Date;
8+
import java.util.List;
9+
710
/**
811
* Stores workflows in the queue waiting for cwltool
912
*/
@@ -23,4 +26,20 @@ public interface QueuedWorkflowRepository extends PagingAndSortingRepository<Que
2326
*/
2427
void deleteByTempRepresentation_RetrievedFrom(GitDetails retrievedFrom);
2528

29+
/**
30+
* Deletes all queued workflows with date retrieved on older or equal to the Date argument passed.
31+
* @param retrievedOn Date of when the queued workflow was retrieved
32+
* @return The number of queued workflows deleted
33+
*/
34+
Long deleteByTempRepresentation_RetrievedOnLessThanEqual(Date retrievedOn);
35+
36+
37+
/**
38+
* Finds and returns all queued workflows with date retrieved on older or equal to the Date argument passed.
39+
* @param retrievedOn Details of where the queued workflow is from
40+
* @return A list of queued workflows
41+
*/
42+
List<QueuedWorkflow> findByTempRepresentation_RetrievedOnLessThanEqual(Date retrievedOn);
43+
44+
2645
}

src/main/resources/application.properties

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,17 @@ spring.data.mongodb.port = 27017
4545
#=======================
4646
# SPARQL endpoint
4747
#=======================
48-
sparql.endpoint = http://localhost:3030/cwlviewer/
48+
sparql.endpoint = http://localhost:3030/cwlviewer/
49+
50+
51+
#=======================
52+
# Scheduler settings
53+
#=======================
54+
55+
# Cron expression that specifies the interval for running deletes of old queued workflow
56+
# For more info see https://spring.io/blog/2020/11/10/new-in-spring-5-3-improved-cron-expressions#usage
57+
# The expression below implies every hour at the 0th second and 0th minute i.e (01:00:00, 02:00::00,... etc)
58+
cron.deleteOldQueuedWorkflows = 0 0 * * * ?
59+
60+
# Age limit for queued workflows in hours.
61+
queuedWorkflowAgeLimitHours = 24

src/main/resources/static/bower_components/bootstrap/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ source 'https://rubygems.org'
22

33
group :development, :test do
44
gem 'jekyll', '~> 3.9.0'
5-
gem 'jekyll-sitemap', '~> 0.11.0'
5+
gem 'jekyll-sitemap', '~> 0.12.0'
66
end
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
addressable (2.4.0)
4+
addressable (2.8.0)
5+
public_suffix (>= 2.0.2, < 5.0)
56
colorator (1.1.0)
6-
concurrent-ruby (1.1.7)
7+
concurrent-ruby (1.1.9)
78
em-websocket (0.5.2)
89
eventmachine (>= 0.12.9)
910
http_parser.rb (~> 0.6.0)
1011
eventmachine (1.2.7)
1112
eventmachine (1.2.7-x64-mingw32)
12-
ffi (1.13.1)
13-
ffi (1.13.1-x64-mingw32)
13+
ffi (1.15.3)
14+
ffi (1.15.3-x64-mingw32)
1415
forwardable-extended (2.6.0)
1516
http_parser.rb (0.6.0)
1617
i18n (0.9.5)
1718
concurrent-ruby (~> 1.0)
18-
jekyll (3.9.0)
19+
jekyll (3.9.1)
1920
addressable (~> 2.4)
2021
colorator (~> 1.0)
2122
em-websocket (~> 0.5)
@@ -30,24 +31,25 @@ GEM
3031
safe_yaml (~> 1.0)
3132
jekyll-sass-converter (1.5.2)
3233
sass (~> 3.4)
33-
jekyll-sitemap (0.11.0)
34-
addressable (~> 2.4.0)
34+
jekyll-sitemap (0.12.0)
35+
jekyll (~> 3.3)
3536
jekyll-watch (2.2.1)
3637
listen (~> 3.0)
37-
kramdown (2.3.0)
38+
kramdown (2.3.1)
3839
rexml
3940
liquid (4.0.3)
40-
listen (3.3.3)
41+
listen (3.5.1)
4142
rb-fsevent (~> 0.10, >= 0.10.3)
4243
rb-inotify (~> 0.9, >= 0.9.10)
4344
mercenary (0.3.6)
4445
pathutil (0.16.2)
4546
forwardable-extended (~> 2.6)
46-
rb-fsevent (0.10.4)
47+
public_suffix (4.0.6)
48+
rb-fsevent (0.11.0)
4749
rb-inotify (0.10.1)
4850
ffi (~> 1.0)
49-
rexml (3.2.4)
50-
rouge (3.25.0)
51+
rexml (3.2.5)
52+
rouge (3.26.0)
5153
safe_yaml (1.0.5)
5254
sass (3.7.4)
5355
sass-listen (~> 4.0.0)
@@ -61,7 +63,7 @@ PLATFORMS
6163

6264
DEPENDENCIES
6365
jekyll (~> 3.9.0)
64-
jekyll-sitemap (~> 0.11.0)
66+
jekyll-sitemap (~> 0.12.0)
6567

6668
BUNDLED WITH
6769
1.17.3

0 commit comments

Comments
 (0)