Skip to content

Commit

Permalink
Including MACRO task startup loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Jan 3, 2025
1 parent 019cffe commit 4c3a8c7
Show file tree
Hide file tree
Showing 22 changed files with 62 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/crosschecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_Elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_OpenSearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_Payara.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_Tomcat_H2_JSON.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_Tomcat_H2_XML.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_Tomcat_H2_YAML.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_WA_SAML2PS4UI_OIDCC4UI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_WA_SRA_CASClient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_WA_SRA_OAuth2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_WA_SRA_OIDC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_WA_SRA_SAML2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_Wildfly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fit_Zookeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand All @@ -66,7 +66,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand All @@ -66,7 +66,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/oracle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand All @@ -66,7 +66,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand All @@ -66,7 +66,7 @@ jobs:
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
maven-version: 3.9.6
- uses: actions/cache@v4
with:
path: ~/.m2/repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,65 +306,72 @@ public void load(final String domain, final DataSource datasource) {
return;
}

String notificationJobCronExp = AuthContextUtils.callAsAdmin(SyncopeConstants.MASTER_DOMAIN, () -> {
String result = StringUtils.EMPTY;

String conf = confParamOps.get(
SyncopeConstants.MASTER_DOMAIN, "notificationjob.cronExpression", null, String.class);
if (conf == null) {
result = NotificationJob.DEFAULT_CRON_EXP;
} else if (!StringUtils.EMPTY.equals(conf)) {
result = conf;
}
return result;
});

AuthContextUtils.callAsAdmin(domain, () -> {
// 1. jobs for SchedTasks
Set<SchedTask> tasks = new HashSet<>(taskDAO.<SchedTask>findAll(TaskType.SCHEDULED));
tasks.addAll(taskDAO.<SchedTask>findAll(TaskType.PULL));
tasks.addAll(taskDAO.<SchedTask>findAll(TaskType.PUSH));
tasks.addAll(taskDAO.<SchedTask>findAll(TaskType.MACRO));

boolean loadException = false;
for (Iterator<SchedTask> it = tasks.iterator(); it.hasNext() && !loadException;) {
SchedTask task = it.next();

LOG.debug("Loading job for {} Task {} {}",
taskUtilsFactory.getInstance(task).getType(), task.getKey(), task.getName());

try {
register(task, task.getStartAt(), securityProperties.getAdminUser());
} catch (Exception e) {
LOG.error("While loading job instance for task " + task.getKey(), e);
LOG.error("While loading job instance for task {}", task.getKey(), e);
loadException = true;
}
}

if (loadException) {
LOG.debug("Errors while loading job instances for tasks, aborting");
LOG.error("Errors while loading job for tasks, aborting");
} else {
// 2. jobs for Reports
for (Iterator<Report> it = reportDAO.findAll().iterator(); it.hasNext() && !loadException;) {
for (Iterator<? extends Report> it = reportDAO.findAll().iterator(); it.hasNext() && !loadException;) {
Report report = it.next();

LOG.debug("Loading job for Report {} {}", report.getKey(), report.getName());

try {
register(report, null, securityProperties.getAdminUser());
} catch (Exception e) {
LOG.error("While loading job instance for report " + report.getName(), e);
LOG.error("While loading job instance for report {}", report.getName(), e);
loadException = true;
}
}

if (loadException) {
LOG.debug("Errors while loading job instances for reports, aborting");
LOG.error("Errors while loading job for reports, aborting");
}
}

return null;
});

if (SyncopeConstants.MASTER_DOMAIN.equals(domain)) {
String notificationJobCronExp = AuthContextUtils.callAsAdmin(SyncopeConstants.MASTER_DOMAIN, () -> {
String result = StringUtils.EMPTY;

String conf = confParamOps.get(
SyncopeConstants.MASTER_DOMAIN, "notificationjob.cronExpression", null, String.class);
if (conf == null) {
result = NotificationJob.DEFAULT_CRON_EXP;
} else if (!StringUtils.EMPTY.equals(conf)) {
result = conf;
}
return result;
});

// 3. NotificationJob
if (StringUtils.isBlank(notificationJobCronExp)) {
LOG.debug("Empty value provided for {}'s cron, not registering anything on Quartz",
NotificationJob.class.getSimpleName());
LOG.debug("Empty value provided for {}'s cron, not scheduling", NotificationJob.class.getSimpleName());
} else {
LOG.debug("{}'s cron expression: {} - registering Quartz job and trigger",
LOG.debug("{}'s cron expression: {} - scheduling",
NotificationJob.class.getSimpleName(), notificationJobCronExp);

try {
Expand Down Expand Up @@ -403,21 +410,27 @@ public void unload(final String domain) {
Set<SchedTask> tasks = new HashSet<>(taskDAO.<SchedTask>findAll(TaskType.SCHEDULED));
tasks.addAll(taskDAO.<SchedTask>findAll(TaskType.PULL));
tasks.addAll(taskDAO.<SchedTask>findAll(TaskType.PUSH));
tasks.addAll(taskDAO.<SchedTask>findAll(TaskType.MACRO));

tasks.forEach(task -> {
LOG.debug("Unloading job for {} Task {} {}",
taskUtilsFactory.getInstance(task).getType(), task.getKey(), task.getName());

try {
unregister(task);
} catch (Exception e) {
LOG.error("While unloading job instance for task " + task.getKey(), e);
LOG.error("While unloading job for task {}", task.getKey(), e);
}
});

// 2. jobs for Reports
reportDAO.findAll().forEach(report -> {
LOG.debug("Unloading job for Report {} {}", report.getKey(), report.getName());

try {
unregister(report);
} catch (Exception e) {
LOG.error("While unloading job instance for report " + report.getName(), e);
LOG.error("While unloading job for report {}", report.getName(), e);
}
});

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ under the License.
<version>${targetJdk}</version>
</requireJavaVersion>
<requireMavenVersion>
<version>3.9.9</version>
<version>3.9.5</version>
</requireMavenVersion>
</rules>
</configuration>
Expand Down Expand Up @@ -1898,7 +1898,7 @@ under the License.
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>4.1.0</version>
<version>4.1.1</version>
<dependencies>
<dependency>
<groupId>org.apache.groovy</groupId>
Expand Down

0 comments on commit 4c3a8c7

Please sign in to comment.