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

Hazelcast may take much longer time to restart #10605 #10616

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.hooks.weaving.WeavingHook;
import org.osgi.framework.startlevel.BundleStartLevel;
Expand All @@ -31,21 +32,24 @@
{
private static final Logger LOG = LoggerFactory.getLogger( FrameworkService.class );

public static final int WAIT_FOR_STOP_TIMEOUT_MS = 10_000;
private static final int WAIT_FOR_STOP_TIMEOUT_MS = 600_000;

private final ConfigProperties config;

private final List<BundleActivator> activators = new CopyOnWriteArrayList<>();

private final Map<String, Object> services = new ConcurrentHashMap<>();

private final long stopGracePeriod;

private volatile Felix felix;

private volatile long startTime;

public FrameworkService( final ConfigProperties config )
{
this.config = config;
this.stopGracePeriod = Long.getLong( "xp.stop.gracePeriod", WAIT_FOR_STOP_TIMEOUT_MS );
}

public FrameworkService activator( final BundleActivator activator )
Expand Down Expand Up @@ -151,7 +155,15 @@
public void restart()
{
LOG.info( "Restarting server..." );
stop();
try
{
doStop();
}
catch ( Exception e )

Check warning on line 162 in modules/launcher/launcher-impl/src/main/java/com/enonic/xp/launcher/impl/framework/FrameworkService.java

View check run for this annotation

Codecov / codecov/patch

modules/launcher/launcher-impl/src/main/java/com/enonic/xp/launcher/impl/framework/FrameworkService.java#L162

Added line #L162 was not covered by tests
{
LOG.error( "Restarting failed. Try restarting manually.", e );
return;

Check warning on line 165 in modules/launcher/launcher-impl/src/main/java/com/enonic/xp/launcher/impl/framework/FrameworkService.java

View check run for this annotation

Codecov / codecov/patch

modules/launcher/launcher-impl/src/main/java/com/enonic/xp/launcher/impl/framework/FrameworkService.java#L164-L165

Added lines #L164 - L165 were not covered by tests
}
start();
}

Expand Down Expand Up @@ -181,7 +193,12 @@
{
stopActivators();
this.felix.stop();
this.felix.waitForStop( WAIT_FOR_STOP_TIMEOUT_MS );

final FrameworkEvent frameworkEvent = this.felix.waitForStop( stopGracePeriod );
if ( frameworkEvent.getType() != FrameworkEvent.STOPPED )
{
throw new IllegalStateException( "Failed to stop framework: " + frameworkEvent.getType(), frameworkEvent.getThrowable() );

Check warning on line 200 in modules/launcher/launcher-impl/src/main/java/com/enonic/xp/launcher/impl/framework/FrameworkService.java

View check run for this annotation

Codecov / codecov/patch

modules/launcher/launcher-impl/src/main/java/com/enonic/xp/launcher/impl/framework/FrameworkService.java#L200

Added line #L200 was not covered by tests
}
}

private void startActivators()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ xp.config.paths=${xp.home}/config
# Initialization settings
#
# xp.init.maxTries = 300
# xp.stop.gracePeriod = 600000

1 change: 1 addition & 0 deletions modules/runtime/src/home/config/system.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
# xp.init.adminUserCreation = true
# xp.init.maxTries = 300
# xp.stop.gracePeriod = 600000

#
# Configuration FileMonitor properties
Expand Down