-
Notifications
You must be signed in to change notification settings - Fork 305
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-3344 Added System Property for Shutdown Grace Period #3702
Merged
Pandrex247
merged 4 commits into
payara:master
from
jbee:PAYARA-3344-graceful-server-shutdown
Feb 12, 2019
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,10 +47,13 @@ | |
import org.glassfish.embeddable.Deployer; | ||
import org.glassfish.embeddable.GlassFish; | ||
import org.glassfish.embeddable.GlassFishException; | ||
import org.glassfish.grizzly.threadpool.Threads; | ||
import org.glassfish.hk2.api.ServiceLocator; | ||
|
||
import java.util.Properties; | ||
|
||
import javax.swing.plaf.SliderUI; | ||
jbee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
|
@@ -87,10 +90,24 @@ public synchronized void stop() throws GlassFishException { | |
throw new IllegalStateException("Already in " + status + " state."); | ||
} | ||
status = Status.STOPPING; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here: do we prevent accepting new requests effectively? |
||
sleepShutdownGracePeriod(); | ||
gfKernel.stop(); | ||
status = Status.STOPPED; | ||
} | ||
|
||
public static void sleepShutdownGracePeriod() { | ||
String shutdowngrace = System.getProperty("fish.payara.shutdowngrace"); | ||
Pandrex247 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (shutdowngrace != null) { | ||
try { | ||
Thread.sleep(Integer.parseInt(shutdowngrace)); | ||
} catch (InterruptedException e) { | ||
Thread.currentThread().interrupt(); | ||
} catch (NumberFormatException e) { | ||
// no sleep, continue shutdown | ||
} | ||
} | ||
} | ||
|
||
public synchronized void dispose() throws GlassFishException { | ||
if (status == Status.DISPOSED) { | ||
throw new IllegalStateException("Already disposed."); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question is: after status is
STOPPING
will this prevent accepting new requests? I think the intention is to finish the ongoing ones but I guess we do not want to accept new ones.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow what the question is here?
There's a check literally above this that prints an error if multiple things try to stop the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I wanted to point out is that before the wait only the
status
was changed. No internal processing has been signalled to stop by that point. I would imagine that it could very well be the case that new request still are accepted and start to process. If the goal with this feature is to give time to finish started requests it seams only consequent not to accept new ones. I would assume that some parts of the server needs to be stopped or flagged to get this behaviour.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Searching the source I don't see that status is used much other than to print it into the admin console. Perhaps we could use this status variable better to stop processing etc.However that would be a different JIRA.