Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-3250 move AutoDeployer thread onto the Scheduled Payara Executor Service #3407

Merged
merged 3 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,12 @@ public class AutoDeployService implements PostConstruct, PreDestroy, ConfigListe

@Inject
ServerEnvironment env;

@Inject PayaraExecutorService executor;
smillidge marked this conversation as resolved.
Show resolved Hide resolved

private AutoDeployer autoDeployer = null;

private Timer autoDeployerTimer;

private TimerTask autoDeployerTimerTask;
private ScheduledFuture<?> autoDeployerTimerTask;

private String target;

Expand Down Expand Up @@ -222,11 +223,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 +235,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 +252,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