Skip to content

Commit

Permalink
Merge pull request #6577 from breakponchito/FISH-7364-fixing-status-w…
Browse files Browse the repository at this point in the history
…hen-restarting-instances

FISH-7364: making status sync when restarting instance
  • Loading branch information
breakponchito authored Feb 29, 2024
2 parents 4de1ccf + ad42379 commit aa93c0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018-2022] [Payara Foundation and/or its affiliates]
// Portions Copyright [2018-2024] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.v3.admin.cluster;

Expand All @@ -50,6 +50,7 @@
import com.sun.enterprise.util.OS;
import com.sun.enterprise.util.ObjectAnalyzer;
import com.sun.enterprise.util.StringUtils;
import fish.payara.nucleus.executorservice.PayaraExecutorService;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.glassfish.api.ActionReport;
Expand All @@ -65,6 +66,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.sun.enterprise.v3.admin.cluster.StartInstanceCommand.pollForLife;

/**
* @author bnevins
*/
Expand Down Expand Up @@ -136,6 +139,9 @@ public class RestartInstanceCommand implements AdminCommand {

private AdminCommandContext context;

@Inject
private PayaraExecutorService executor;

private static final long WAIT_TIME_MS = 600000; // 10 minutes

@Override
Expand Down Expand Up @@ -169,13 +175,14 @@ public void execute(AdminCommandContext ctx) {
logger.log(Level.FINE, "Restart-instance old-pid = {0}", oldPid);
callInstance();
checkForRestart();

pollForLife(instance, executor, timeout);
synchronizeInstance();

if (!isError()) {
String msg = Strings.get("restart.instance.success", instanceName);
logger.info(msg);
report.setMessage(msg);
}
synchronizeInstance();
} catch (InstanceNotRunningException inre) {
start();
} catch (CommandException ce) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*
* Portions Copyright [2018-2019] [Payara Foundation and/or its affiliates]
* Portions Copyright [2018-2024] [Payara Foundation and/or its affiliates]
*/
package com.sun.enterprise.v3.admin.cluster;

Expand Down Expand Up @@ -244,7 +244,7 @@ public void execute(AdminCommandContext ctx) {

if (report.getActionExitCode() == SUCCESS) {
// Make sure instance is really up
if (!pollForLife(instance)) {
if (!pollForLife(instance, executor, timeout)) {
report.setMessage(Strings.get("start.instance.timeout", instanceName));
report.setActionExitCode(FAILURE);
}
Expand Down Expand Up @@ -330,7 +330,7 @@ private void startDockerContainer(AdminCommandContext adminCommandContext) {
*
* @return true if the instance started up, or false otherwise.
*/
private boolean pollForLife(Server instance) {
static boolean pollForLife(Server instance, PayaraExecutorService executor, int timeout) {

// Start a new thread to check when the instance has started
CountDownLatch instanceTimeout = new CountDownLatch(1);
Expand Down

0 comments on commit aa93c0a

Please sign in to comment.