Skip to content

Commit

Permalink
Merge pull request #3407 from smillidge/PAYARA-3250
Browse files Browse the repository at this point in the history
PAYARA-3250 move AutoDeployer thread onto the Scheduled Payara Executor Service
  • Loading branch information
Pandrex247 authored Nov 14, 2018
2 parents ff92bde + 4933b36 commit e650670
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
10 changes: 8 additions & 2 deletions nucleus/deployment/autodeploy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
<groupId>org.glassfish.annotations</groupId>
<artifactId>logging-annotation-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</dependency>
<dependency>
<groupId>fish.payara.payara-modules</groupId>
<artifactId>payara-executor-service</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@
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;
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;
import java.util.logging.Logger;
import java.util.logging.LogRecord;
Expand Down Expand Up @@ -95,12 +96,13 @@ public class AutoDeployService implements PostConstruct, PreDestroy, ConfigListe

@Inject
ServerEnvironment env;

@Inject
private PayaraExecutorService executor;

private AutoDeployer autoDeployer = null;

private Timer autoDeployerTimer;

private TimerTask autoDeployerTimerTask;
private ScheduledFuture<?> autoDeployerTimerTask;

private String target;

Expand Down Expand Up @@ -222,11 +224,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 {
Expand All @@ -236,9 +236,10 @@ public void run() {
AutoDeployer.deplLogger.log(Level.FINE, ex.getMessage(), ex);
}
}
},
pollingInterval,
pollingInterval);
},
0L,
pollingIntervalInSeconds,
TimeUnit.SECONDS);
logConfig(
"Started",
isAutoDeployEnabled(),
Expand All @@ -252,12 +253,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);
}
}

Expand Down

0 comments on commit e650670

Please sign in to comment.