diff --git a/core/src/main/java/org/infinispan/commands/RemoteCommandsFactory.java b/core/src/main/java/org/infinispan/commands/RemoteCommandsFactory.java index b48c437ff440..254d6287c5a4 100644 --- a/core/src/main/java/org/infinispan/commands/RemoteCommandsFactory.java +++ b/core/src/main/java/org/infinispan/commands/RemoteCommandsFactory.java @@ -275,9 +275,6 @@ public CacheRpcCommand fromStream(byte id, byte type, ByteString cacheName) { case StateResponseCommand.COMMAND_ID: command = new StateResponseCommand(cacheName); break; - case RemoveCacheCommand.COMMAND_ID: - command = new RemoveCacheCommand(cacheName, cacheManager); - break; case TxCompletionNotificationCommand.COMMAND_ID: command = new TxCompletionNotificationCommand(cacheName); break; diff --git a/core/src/main/java/org/infinispan/commands/RemoveCacheCommand.java b/core/src/main/java/org/infinispan/commands/RemoveCacheCommand.java deleted file mode 100644 index f36008806269..000000000000 --- a/core/src/main/java/org/infinispan/commands/RemoveCacheCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.infinispan.commands; - -import static org.infinispan.factories.KnownComponentNames.CACHE_DEPENDENCY_GRAPH; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.concurrent.CompletableFuture; - -import org.infinispan.Cache; -import org.infinispan.commands.remote.BaseRpcCommand; -import org.infinispan.configuration.ConfigurationManager; -import org.infinispan.eviction.PassivationManager; -import org.infinispan.factories.ComponentRegistry; -import org.infinispan.factories.GlobalComponentRegistry; -import org.infinispan.jmx.CacheJmxRegistration; -import org.infinispan.manager.EmbeddedCacheManager; -import org.infinispan.persistence.manager.PersistenceManager; -import org.infinispan.util.ByteString; -import org.infinispan.util.DependencyGraph; -import org.infinispan.util.concurrent.CompletableFutures; - -/** - * Command to stop a cache and remove all its contents from both - * memory and any backing store. - * - * @author Galder ZamarreƱo - * @since 5.0 - * @deprecated Use {@link org.infinispan.commons.api.CacheContainerAdmin#removeCache(String)} instead - */ -@Deprecated // TODO remove in 10.0 -public class RemoveCacheCommand extends BaseRpcCommand { - - public static final byte COMMAND_ID = 18; - - private EmbeddedCacheManager cacheManager; - - private RemoveCacheCommand() { - super(null); // For command id uniqueness test - } - - public RemoveCacheCommand(ByteString cacheName, EmbeddedCacheManager cacheManager) { - super(cacheName); - this.cacheManager = cacheManager; - } - - @Override - public CompletableFuture invokeAsync() throws Throwable { - removeCache(cacheManager, cacheName.toString()); - return CompletableFutures.completedNull(); - } - - public static void removeCache(EmbeddedCacheManager cacheManager, String cacheName) { - GlobalComponentRegistry globalComponentRegistry = cacheManager.getGlobalComponentRegistry(); - ComponentRegistry cacheComponentRegistry = globalComponentRegistry.getNamedComponentRegistry(cacheName); - if (cacheComponentRegistry != null) { - cacheComponentRegistry.getComponent(PersistenceManager.class).setClearOnStop(true); - cacheComponentRegistry.getComponent(CacheJmxRegistration.class).setUnregisterCacheMBean(true); - cacheComponentRegistry.getComponent(PassivationManager.class).skipPassivationOnStop(true); - Cache cache = cacheManager.getCache(cacheName, false); - if (cache != null) { - cache.stop(); - } - } - globalComponentRegistry.removeCache(cacheName); - // Remove cache configuration and remove it from the computed cache name list - globalComponentRegistry.getComponent(ConfigurationManager.class).removeConfiguration(cacheName); - // Remove cache from dependency graph - //noinspection unchecked - globalComponentRegistry.getComponent(DependencyGraph.class, CACHE_DEPENDENCY_GRAPH).remove(cacheName); - } - - @Override - public byte getCommandId() { - return COMMAND_ID; - } - - @Override - public void writeTo(ObjectOutput output) throws IOException { - // No parameters - } - - @Override - public void readFrom(ObjectInput input) throws IOException, ClassNotFoundException { - // No parameters - } - - @Override - public boolean isReturnValueExpected() { - return false; - } - - @Override - public boolean canBlock() { - return true; - } - @Override - public String toString() { - return "RemoveCacheCommand{" + - "cacheName='" + cacheName + '\'' + - '}'; - } - -} diff --git a/core/src/main/java/org/infinispan/marshall/exts/CacheRpcCommandExternalizer.java b/core/src/main/java/org/infinispan/marshall/exts/CacheRpcCommandExternalizer.java index 0b30c977f056..9db876e17a48 100644 --- a/core/src/main/java/org/infinispan/marshall/exts/CacheRpcCommandExternalizer.java +++ b/core/src/main/java/org/infinispan/marshall/exts/CacheRpcCommandExternalizer.java @@ -7,7 +7,6 @@ import org.infinispan.commands.CancelCommand; import org.infinispan.commands.CreateCacheCommand; -import org.infinispan.commands.RemoveCacheCommand; import org.infinispan.commands.control.LockControlCommand; import org.infinispan.commands.remote.CacheRpcCommand; import org.infinispan.commands.remote.ClusteredGetAllCommand; @@ -79,7 +78,7 @@ public Set> getTypeClasses() { Set> coreCommands = Util.asSet(LockControlCommand.class, StateRequestCommand.class, StateResponseCommand.class, ClusteredGetCommand.class, SingleRpcCommand.class, CommitCommand.class, - PrepareCommand.class, RollbackCommand.class, RemoveCacheCommand.class, + PrepareCommand.class, RollbackCommand.class, TxCompletionNotificationCommand.class, GetInDoubtTransactionsCommand.class, GetInDoubtTxInfoCommand.class, CompleteTransactionCommand.class, VersionedPrepareCommand.class, CreateCacheCommand.class, CancelCommand.class,