Skip to content

Commit

Permalink
Hazelcast may take much longer time to restart #10605
Browse files Browse the repository at this point in the history
  • Loading branch information
anatol-sialitski committed Jun 27, 2024
1 parent b87ce4e commit e2dd690
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
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 @@ public class FrameworkService
{
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 stop()
public void restart()
{
LOG.info( "Restarting server..." );
stop();
try
{
doStop();
}
catch ( Exception e )
{
LOG.error( "Restarting failed. Try restarting manually.", e );
return;
}
start();
}

Expand Down Expand Up @@ -181,7 +193,12 @@ private void doStop()
{
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() );
}
}

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

0 comments on commit e2dd690

Please sign in to comment.