Skip to content

Commit

Permalink
Merge pull request #118 from CJSCommonPlatform/add-force-to-jmx-commands
Browse files Browse the repository at this point in the history
Add '-f' '--force' switch to the JmxCommandClient to bypass COMMAND_I…
  • Loading branch information
allanmckenzie committed Dec 8, 2023
2 parents 14bd832 + e8f818e commit a111299
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
- Limit logging of MissingEventRanges logged to sensible maximum number.
### Added
- New JNDI value `catchup.max.number.of.missing.event.ranges.to.log`
- Add '-f' '--force' switch to the JmxCommandClient to bypass COMMAND_IN_PROGRESS check
### Removed
- Removed dependency on apache-drools as it's not used by any of the framework code
### Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
import static uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand.CATCHUP;
import static uk.gov.justice.services.jmx.api.mbean.CommandRunMode.GUARDED;
import static uk.gov.justice.services.jmx.system.command.client.connection.JmxParametersBuilder.jmxParameters;
import static uk.gov.justice.services.test.utils.common.host.TestHostProvider.getHost;

Expand Down Expand Up @@ -170,7 +171,7 @@ private void runCatchup() throws Exception {

try (final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(jmxParameters)) {

systemCommanderClient.getRemote(CONTEXT_NAME).call(CATCHUP);
systemCommanderClient.getRemote(CONTEXT_NAME).call(CATCHUP, GUARDED);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand.CATCHUP;
import static uk.gov.justice.services.example.cakeshop.it.params.CakeShopMediaTypes.ADD_RECIPE_MEDIA_TYPE;
import static uk.gov.justice.services.example.cakeshop.it.params.CakeShopUris.RECIPES_RESOURCE_URI;
import static uk.gov.justice.services.jmx.api.mbean.CommandRunMode.GUARDED;
import static uk.gov.justice.services.jmx.system.command.client.connection.JmxParametersBuilder.jmxParameters;
import static uk.gov.justice.services.test.utils.common.host.TestHostProvider.getHost;
import static uk.gov.justice.services.test.utils.core.matchers.HttpStatusCodeMatcher.isStatus;
Expand Down Expand Up @@ -176,7 +177,7 @@ private void runCatchup() throws Exception {

try (final SystemCommanderClient systemCommanderClient = systemCommanderClientFactory.create(jmxParameters)) {

systemCommanderClient.getRemote(CONTEXT_NAME).call(CATCHUP);
systemCommanderClient.getRemote(CONTEXT_NAME).call(CATCHUP, GUARDED);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.junit.jupiter.api.Assertions.fail;
import static uk.gov.justice.services.jmx.api.domain.CommandState.COMMAND_COMPLETE;
import static uk.gov.justice.services.jmx.api.domain.CommandState.COMMAND_FAILED;
import static uk.gov.justice.services.jmx.api.mbean.CommandRunMode.GUARDED;
import static uk.gov.justice.services.jmx.system.command.client.connection.JmxParametersBuilder.jmxParameters;
import static uk.gov.justice.services.test.utils.common.host.TestHostProvider.getHost;

Expand Down Expand Up @@ -151,7 +152,7 @@ private Optional<SystemCommandStatus> runCommand(final JmxParameters jmxParamete

final SystemCommanderMBean systemCommanderMBean = systemCommanderClient.getRemote(CONTEXT_NAME);
final UUID commandId = systemCommanderMBean
.call(systemCommand.getName());
.call(systemCommand.getName(), GUARDED);

return poller.pollUntilFound(() -> commandNoLongerInProgress(systemCommanderMBean, commandId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
import static uk.gov.justice.services.eventstore.management.commands.RebuildCommand.REBUILD;
import static uk.gov.justice.services.jmx.api.mbean.CommandRunMode.GUARDED;
import static uk.gov.justice.services.jmx.system.command.client.connection.JmxParametersBuilder.jmxParameters;
import static uk.gov.justice.services.test.utils.common.host.TestHostProvider.getHost;

Expand Down Expand Up @@ -114,7 +115,7 @@ private void invokeRebuild() throws Exception {
.build();

try(final SystemCommanderClient systemCommanderClient = testSystemCommanderClientFactory.create(jmxParameters)) {
systemCommanderClient.getRemote(CONTEXT_NAME).call(REBUILD);
systemCommanderClient.getRemote(CONTEXT_NAME).call(REBUILD, GUARDED);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import static org.junit.jupiter.api.Assertions.fail;
import static org.slf4j.LoggerFactory.getLogger;
import static uk.gov.justice.services.jmx.api.domain.CommandState.COMMAND_COMPLETE;
import static uk.gov.justice.services.jmx.api.mbean.CommandRunMode.FORCED;
import static uk.gov.justice.services.jmx.api.mbean.CommandRunMode.GUARDED;
import static uk.gov.justice.services.jmx.system.command.client.connection.JmxParametersBuilder.jmxParameters;
import static uk.gov.justice.services.management.suspension.commands.SuspendCommand.SUSPEND;
import static uk.gov.justice.services.management.suspension.commands.UnsuspendCommand.UNSUSPEND;
Expand Down Expand Up @@ -91,7 +93,7 @@ public void cleanup() throws Exception {

final SystemCommanderMBean systemCommanderMBean = systemCommanderClient.getRemote(CONTEXT_NAME);

final UUID commandId = systemCommanderMBean.call(UNSUSPEND);
final UUID commandId = systemCommanderMBean.call(UNSUSPEND, GUARDED);

final Optional<SystemCommandStatus> unsuspendStatus = poller.pollUntilFound(() -> {
final SystemCommandStatus commandStatus = systemCommanderMBean.getCommandStatus(commandId);
Expand All @@ -118,7 +120,7 @@ public void shouldNotReturnRecipesAfterSuspending() throws Exception {
.build();
try (final SystemCommanderClient systemCommanderClient = testSystemCommanderClientFactory.create(jmxParameters)) {
final SystemCommanderMBean systemCommanderMBean = systemCommanderClient.getRemote(CONTEXT_NAME);
final UUID commandId = systemCommanderMBean.call(SUSPEND);
final UUID commandId = systemCommanderMBean.call(SUSPEND, FORCED);

final Optional<SystemCommandStatus> suspendStatus = poller.pollUntilFound(() -> {
final SystemCommandStatus commandStatus = systemCommanderMBean.getCommandStatus(commandId);
Expand Down Expand Up @@ -157,7 +159,7 @@ public void shouldQueryForRecipesAfterUnShuttering() throws Exception {
final SystemCommanderMBean systemCommanderMBean = systemCommanderClient.getRemote(CONTEXT_NAME);

//invoke suspending
final UUID suspendCommandId = systemCommanderMBean.call(SUSPEND);
final UUID suspendCommandId = systemCommanderMBean.call(SUSPEND, FORCED);

final Optional<SystemCommandStatus> suspendStatus = poller.pollUntilFound(() -> {
final SystemCommandStatus commandStatus = systemCommanderMBean.getCommandStatus(suspendCommandId);
Expand All @@ -183,7 +185,7 @@ public void shouldQueryForRecipesAfterUnShuttering() throws Exception {
verifyRecipeAdded(recipeId, recipeId2, null, null, false, NOT_FOUND);

//invoke unsuspending
final UUID unsuspendCommandId = systemCommanderMBean.call(UNSUSPEND);
final UUID unsuspendCommandId = systemCommanderMBean.call(UNSUSPEND, FORCED);

final Optional<SystemCommandStatus> unsuspendStatus = poller.pollUntilFound(() -> {
final SystemCommandStatus commandStatus = systemCommanderMBean.getCommandStatus(unsuspendCommandId);
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
<wildfly.version>26.1.2.Final</wildfly.version>
<wildfly.maven.plugin.version>4.1.1.Final</wildfly.maven.plugin.version>

<framework-libraries.version>17.2.0</framework-libraries.version>
<framework.version>17.2.0</framework.version>
<event-store.version>17.2.0</event-store.version>
<framework-libraries.version>17.3.1</framework-libraries.version>
<framework.version>17.4.0</framework.version>
<event-store.version>17.4.0</event-store.version>

<!-- TODO - move to common bom -->
<weld-junit5.version>1.2.2.Final</weld-junit5.version>
Expand Down

0 comments on commit a111299

Please sign in to comment.