Vladsz83 commented on a change in pull request #7358: IGNITE-12614 : Disallow
silent deactivation of cluster to prevent in-mem data loss.
URL: https://github.com/apache/ignite/pull/7358#discussion_r375371188
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/commandline/DeactivateCommand.java
##########
@@ -59,25 +65,51 @@
* @param clientCfg Client configuration.
* @throws Exception If failed to deactivate.
*/
- @Override public Object execute(GridClientConfiguration clientCfg, Logger
logger) throws Exception {
- logger.warning("Command deprecated. Use " + SET_STATE.toString() + "
instead.");
+ @Override public Object execute(GridClientConfiguration clientCfg, Logger
log) throws Exception {
+ log.warning("Command deprecated. Use " + SET_STATE.toString() + "
instead.");
try (GridClient client = Command.startClient(clientCfg)) {
+
+ //Search for in-memory-only caches. Warn of possible data loss.
+ if (!force) {
+ String msg =
ClusterStateChangeCommand.isClusterReadyForDeactivation((cls) -> {
+ try {
+ return TaskExecutor.executeTask(client, cls, null,
clientCfg);
+ }
+ catch (GridClientException e) {
+ throw new RuntimeException("Failed to launch task for
checking check if cluster is ready for deactivation.", e);
+ }
+ });
+ if (!msg.isEmpty())
+ throw new IllegalStateException(msg + " Type --force to
proceed.");
+ }
+
GridClientClusterState state = client.state();
state.active(false);
- logger.info("Cluster deactivated");
+ log.info("Cluster deactivated.");
}
catch (Exception e) {
- logger.severe("Failed to deactivate cluster.");
+ log.severe("Failed to deactivate cluster.");
throw e;
}
return null;
}
+ /** {@inheritDoc} */
+ @Override public void parseArguments(CommandArgIterator argIter) {
+ if (argIter.hasNextArg()) {
+ String arg = argIter.peekNextArg();
+ if ("--force".equalsIgnoreCase(arg)) {
+ force = true;
+ argIter.nextArg("");
Review comment:
Fixed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services