From aaee99a201e97ac50ccebd5422267207dc50d4c8 Mon Sep 17 00:00:00 2001 From: smillidge Date: Sun, 11 Nov 2018 19:40:58 +0000 Subject: [PATCH 1/3] PAYARA-3250 move AutoDeployer thread onto the Scheduled Payara Executor Service to reduce thread usage by 1 --- nucleus/deployment/autodeploy/pom.xml | 10 ++++-- .../autodeploy/AutoDeployService.java | 31 ++++++++++--------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/nucleus/deployment/autodeploy/pom.xml b/nucleus/deployment/autodeploy/pom.xml index 94f6a2e0d4c..b810ebd3219 100755 --- a/nucleus/deployment/autodeploy/pom.xml +++ b/nucleus/deployment/autodeploy/pom.xml @@ -117,6 +117,12 @@ org.glassfish.annotations logging-annotation-processor true - - + + + fish.payara.payara-modules + payara-executor-service + ${project.version} + jar + + diff --git a/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java b/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java index 67e54dcccb5..cb1cb66ef60 100644 --- a/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java +++ b/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java @@ -42,6 +42,7 @@ package org.glassfish.deployment.autodeploy; import com.sun.enterprise.config.serverbeans.DasConfig; +import fish.payara.nucleus.executorservice.PayaraExecutorService; import java.beans.PropertyChangeEvent; import java.util.ArrayList; import java.util.Arrays; @@ -49,6 +50,8 @@ import java.util.Properties; import java.util.Timer; import java.util.TimerTask; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.LogRecord; @@ -95,12 +98,12 @@ public class AutoDeployService implements PostConstruct, PreDestroy, ConfigListe @Inject ServerEnvironment env; + + @Inject PayaraExecutorService executor; private AutoDeployer autoDeployer = null; - private Timer autoDeployerTimer; - - private TimerTask autoDeployerTimerTask; + private ScheduledFuture autoDeployerTimerTask; private String target; @@ -222,11 +225,9 @@ private int getPollingIntervalInSeconds() throws NumberFormatException { } private void startAutoDeployer(int pollingIntervalInSeconds) { - long pollingInterval = pollingIntervalInSeconds * 1000L; autoDeployer.init(); - autoDeployerTimer = new Timer("AutoDeployer", true); - autoDeployerTimer.schedule( - autoDeployerTimerTask = new TimerTask() { + autoDeployerTimerTask = executor.scheduleAtFixedRate( + new Runnable() { @Override public void run() { try { @@ -236,9 +237,10 @@ public void run() { AutoDeployer.deplLogger.log(Level.FINE, ex.getMessage(), ex); } } - }, - pollingInterval, - pollingInterval); + }, + 0L, + pollingIntervalInSeconds, + TimeUnit.SECONDS); logConfig( "Started", isAutoDeployEnabled(), @@ -252,12 +254,11 @@ private void stopAutoDeployer() { * and the timer. */ deplLogger.fine("[AutoDeploy] Stopping"); - if (autoDeployer!=null) + if (autoDeployer!=null) { autoDeployer.cancel(true); - if (autoDeployerTimerTask!=null) - autoDeployerTimerTask.cancel(); - if (autoDeployerTimer != null) { - autoDeployerTimer.cancel(); + } + if (autoDeployerTimerTask!=null) { + autoDeployerTimerTask.cancel(false); } } From 7ec0a6c4b9545e39d2d97d1da9e8194495629090 Mon Sep 17 00:00:00 2001 From: smillidge Date: Sun, 11 Nov 2018 19:43:05 +0000 Subject: [PATCH 2/3] PAYARA-3250 remove unused imports --- .../org/glassfish/deployment/autodeploy/AutoDeployService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java b/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java index cb1cb66ef60..5a4774c979d 100644 --- a/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java +++ b/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java @@ -48,8 +48,6 @@ import java.util.Arrays; import java.util.List; import java.util.Properties; -import java.util.Timer; -import java.util.TimerTask; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; From 4933b36a5e9d6b8257ecae793b23d202949dfa5b Mon Sep 17 00:00:00 2001 From: Arjan Tijms Date: Tue, 13 Nov 2018 18:21:17 +0000 Subject: [PATCH 3/3] Update nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java Co-Authored-By: smillidge --- .../org/glassfish/deployment/autodeploy/AutoDeployService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java b/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java index 5a4774c979d..84c420ee758 100644 --- a/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java +++ b/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java @@ -97,7 +97,8 @@ public class AutoDeployService implements PostConstruct, PreDestroy, ConfigListe @Inject ServerEnvironment env; - @Inject PayaraExecutorService executor; + @Inject + private PayaraExecutorService executor; private AutoDeployer autoDeployer = null;