This repository has been archived by the owner on Aug 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
1,316 additions
and
1,313 deletions.
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
28 changes: 28 additions & 0 deletions
28
...agement/src/main/java/uk/gov/justice/services/management/hibernation/api/Suspendable.java
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package uk.gov.justice.services.management.hibernation.api; | ||
|
||
import uk.gov.justice.services.management.hibernation.commands.SuspensionCommand; | ||
|
||
import java.util.UUID; | ||
|
||
public interface Suspendable { | ||
|
||
default String getName() { | ||
return this.getClass().getSimpleName(); | ||
} | ||
|
||
default boolean shouldSuspend() { | ||
return false; | ||
} | ||
|
||
default boolean shouldUnsuspend() { | ||
return false; | ||
} | ||
|
||
default SuspensionResult suspend(final UUID commandId, final SuspensionCommand suspensionCommand) throws SuspensionFailedException { | ||
throw new UnsupportedOperationException("Method not implemented"); | ||
} | ||
|
||
default SuspensionResult unsuspend(final UUID commandId, final SuspensionCommand suspensionCommand) throws SuspensionFailedException { | ||
throw new UnsupportedOperationException("Method not implemented"); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...in/java/uk/gov/justice/services/management/hibernation/api/SuspensionFailedException.java
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package uk.gov.justice.services.management.hibernation.api; | ||
|
||
public class SuspensionFailedException extends Exception { | ||
|
||
public SuspensionFailedException(final String message) { | ||
super(message); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
...src/main/java/uk/gov/justice/services/management/hibernation/commands/SuspendCommand.java
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package uk.gov.justice.services.management.hibernation.commands; | ||
|
||
import uk.gov.justice.services.jmx.api.command.BaseSystemCommand; | ||
|
||
public class SuspendCommand extends BaseSystemCommand implements SuspensionCommand { | ||
|
||
public static final String SUSPEND = "SUSPEND"; | ||
private static final String DESCRIPTION = "Suspends the application to allow for maintenance."; | ||
|
||
public SuspendCommand() { | ||
super(SUSPEND, DESCRIPTION); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../main/java/uk/gov/justice/services/management/hibernation/commands/SuspensionCommand.java
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package uk.gov.justice.services.management.hibernation.commands; | ||
|
||
import static uk.gov.justice.services.management.hibernation.commands.SuspendCommand.SUSPEND; | ||
import static uk.gov.justice.services.management.hibernation.commands.UnsuspendCommand.UNSUSPEND; | ||
|
||
import uk.gov.justice.services.jmx.api.command.SystemCommand; | ||
|
||
public interface SuspensionCommand extends SystemCommand { | ||
|
||
default boolean isSuspendCommand() { | ||
return SUSPEND.equals(getName()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...c/main/java/uk/gov/justice/services/management/hibernation/commands/UnsuspendCommand.java
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package uk.gov.justice.services.management.hibernation.commands; | ||
|
||
import uk.gov.justice.services.jmx.api.command.BaseSystemCommand; | ||
|
||
public class UnsuspendCommand extends BaseSystemCommand implements SuspensionCommand { | ||
|
||
public static final String UNSUSPEND = "UNSUSPEND"; | ||
private static final String DESCRIPTION = "Unsuspends the application."; | ||
|
||
public UnsuspendCommand() { | ||
super(UNSUSPEND, DESCRIPTION); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...in/java/uk/gov/justice/services/management/hibernation/executors/CommandApiSuspender.java
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package uk.gov.justice.services.management.hibernation.executors; | ||
|
||
import static uk.gov.justice.services.management.hibernation.api.SuspensionResult.shutteringSucceeded; | ||
|
||
import uk.gov.justice.services.management.hibernation.api.Suspendable; | ||
import uk.gov.justice.services.management.hibernation.api.SuspensionResult; | ||
import uk.gov.justice.services.management.hibernation.commands.SuspensionCommand; | ||
|
||
import java.util.UUID; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.slf4j.Logger; | ||
|
||
public class CommandApiSuspender implements Suspendable { | ||
|
||
@Inject | ||
private CommandApiSuspensionBean commandApiSuspensionBean; | ||
|
||
@Inject | ||
private Logger logger; | ||
|
||
@Override | ||
public boolean shouldSuspend() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean shouldUnsuspend() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public SuspensionResult suspend(final UUID commandId, final SuspensionCommand suspensionCommand) { | ||
|
||
logger.info("Suspending Command API"); | ||
|
||
commandApiSuspensionBean.suspend(); | ||
|
||
logger.info("Suspension of Command API complete"); | ||
|
||
return shutteringSucceeded( | ||
getName(), | ||
commandId, | ||
"Command API suspended with no errors", | ||
suspensionCommand | ||
); | ||
} | ||
|
||
@Override | ||
public SuspensionResult unsuspend(final UUID commandId, final SuspensionCommand suspensionCommand) { | ||
|
||
logger.info("Unsuspending Command API"); | ||
|
||
commandApiSuspensionBean.unsuspend(); | ||
|
||
logger.info("Unsuspension of Command API complete"); | ||
|
||
return shutteringSucceeded( | ||
getName(), | ||
commandId, | ||
"Command API unsuspended with no errors", | ||
suspensionCommand | ||
); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...tering/executors/StoredCommandSender.java → ...nation/executors/StoredCommandSender.java
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
Oops, something went wrong.