# IGNITE-436 Removed cache compact.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/79293ffb Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/79293ffb Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/79293ffb Branch: refs/heads/ignite-411 Commit: 79293ffbdd3351904d1ae1250c8559c1d341995a Parents: a46067a Author: AKuznetsov <akuznet...@gridgain.com> Authored: Wed Mar 11 23:09:41 2015 +0700 Committer: AKuznetsov <akuznet...@gridgain.com> Committed: Wed Mar 11 23:09:41 2015 +0700 ---------------------------------------------------------------------- .../visor/cache/VisorCacheCompactTask.java | 66 -------- .../ignite/visor/commands/VisorConsole.scala | 3 +- .../commands/cache/VisorCacheCommand.scala | 30 +--- .../cache/VisorCacheCompactCommand.scala | 151 ------------------- .../cache/VisorCacheCompactCommandSpec.scala | 103 ------------- .../testsuites/VisorConsoleSelfTestSuite.scala | 3 +- 6 files changed, 4 insertions(+), 352 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/79293ffb/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheCompactTask.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheCompactTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheCompactTask.java deleted file mode 100644 index cddf0c7..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheCompactTask.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.visor.cache; - -import org.apache.ignite.internal.processors.task.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.internal.visor.*; -import org.apache.ignite.lang.*; - -import java.util.*; - -/** - * Task that compacts caches. - */ -@GridInternal -public class VisorCacheCompactTask extends VisorOneNodeTask<Set<String>, Map<String, IgniteBiTuple<Integer, Integer>>> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCachesCompactJob job(Set<String> names) { - return new VisorCachesCompactJob(names, debug); - } - - /** Job that compact caches on node. */ - private static class VisorCachesCompactJob extends VisorJob<Set<String>, Map<String, IgniteBiTuple<Integer, Integer>>> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param names Cache names to compact. - * @param debug Debug flag. - */ - private VisorCachesCompactJob(Set<String> names, boolean debug) { - super(names, debug); - } - - /** {@inheritDoc} */ - @Override protected Map<String, IgniteBiTuple<Integer, Integer>> run(Set<String> names) { - // TODO IGNITE-436 remove command. - return Collections.emptyMap(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCachesCompactJob.class, this); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/79293ffb/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala index 8cc1895..7e88577 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala @@ -34,7 +34,7 @@ import scala.io._ // Note the importing of implicit conversions. import org.apache.ignite.visor.commands.ack.VisorAckCommand import org.apache.ignite.visor.commands.alert.VisorAlertCommand -import org.apache.ignite.visor.commands.cache.{VisorCacheClearCommand, VisorCacheCommand, VisorCacheCompactCommand, VisorCacheSwapCommand} +import org.apache.ignite.visor.commands.cache.{VisorCacheClearCommand, VisorCacheCommand, VisorCacheSwapCommand} import org.apache.ignite.visor.commands.config.VisorConfigurationCommand import org.apache.ignite.visor.commands.deploy.VisorDeployCommand import org.apache.ignite.visor.commands.disco.VisorDiscoveryCommand @@ -75,7 +75,6 @@ object VisorConsole extends App { VisorAlertCommand VisorCacheCommand VisorCacheClearCommand - VisorCacheCompactCommand VisorCacheSwapCommand VisorConfigurationCommand VisorDeployCommand http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/79293ffb/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala index 2096743..1023708 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala @@ -55,8 +55,6 @@ import scala.util.control.Breaks._ * | | R/r Number of cache reads. | * | | W/w Number of cache writes. | * +-----------------------------------------------------------------------------------------+ - * | cache -compact | Compacts all entries in cache on all nodes. | - * +-----------------------------------------------------------------------------------------+ * | cache -clear | Clears all entries from cache on all nodes. | * +-----------------------------------------------------------------------------------------+ * | cache -scan | List all entries in cache with specified name. | @@ -69,7 +67,6 @@ import scala.util.control.Breaks._ * cache -i * cache {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>} {-s=hi|mi|re|wr|cn} {-a} {-r} * cache -clear {-c=<cache-name>} - * cache -compact {-c=<cache-name>} * cache -scan -c=<cache-name> {-id=<node-id>|id8=<node-id8>} {-p=<page size>} * cache -swap {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>} * }}} @@ -103,8 +100,6 @@ import scala.util.control.Breaks._ * -a * Prints details statistics about each cache. * By default only aggregated summary is printed. - * -compact - * Compacts entries in cache. * -clear * Clears cache. * -scan @@ -128,10 +123,6 @@ import scala.util.control.Breaks._ * Prints cache statistics for interactively selected node. * cache -s=hi -r -a * Prints detailed statistics about all caches sorted by number of hits in reverse order. - * cache -compact - * Compacts entries in interactively selected cache. - * cache -compact -c=cache - * Compacts entries in cache with name 'cache'. * cache -clear * Clears interactively selected cache. * cache -clear -c=cache @@ -178,12 +169,6 @@ class VisorCacheCommand { * <ex>cache -s=no -r</ex> * Prints statistics about all caches sorted by number of nodes in reverse order. * <br> - * <ex>cache -compact</ex> - * Compacts entries in interactively selected cache. - * <br> - * <ex>cache -compact -c=cache</ex> - * Compacts entries in cache with name 'cache'. - * <br> * <ex>cache -clear</ex> * Clears interactively selected cache. * <br> @@ -252,7 +237,7 @@ class VisorCacheCommand { case cn => cn } - if (Seq("clear", "compact", "swap", "scan").exists(hasArgFlag(_, argLst))) { + if (Seq("clear", "swap", "scan").exists(hasArgFlag(_, argLst))) { if (cacheName.isEmpty) askForCache("Select cache from:", node) match { case Some(name) => argLst = argLst ++ Seq("c" -> name) @@ -261,8 +246,6 @@ class VisorCacheCommand { if (hasArgFlag("clear", argLst)) VisorCacheClearCommand().clear(argLst, node) - else if (hasArgFlag("compact", argLst)) - VisorCacheCompactCommand().compact(argLst, node) else if (hasArgFlag("swap", argLst)) VisorCacheSwapCommand().swap(argLst, node) else if (hasArgFlag("scan", argLst)) @@ -626,7 +609,7 @@ class VisorCacheCommand { object VisorCacheCommand { addHelp( name = "cache", - shortInfo = "Prints cache statistics, clears cache, compacts entries in cache, prints list of all entries from cache.", + shortInfo = "Prints cache statistics, clears cache, prints list of all entries from cache.", longInfo = Seq( "Prints statistics about caches from specified node on the entire grid.", "Output sorting can be specified in arguments.", @@ -640,8 +623,6 @@ object VisorCacheCommand { " ", "Clears cache.", " ", - "Compacts entries in cache.", - " ", "Prints list of all entries from cache.", " ", "Swaps backup entries in cache." @@ -650,7 +631,6 @@ object VisorCacheCommand { "cache", "cache -i", "cache {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>} {-s=hi|mi|re|wr} {-a} {-r}", - "cache -compact {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}", "cache -clear {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}", "cache -scan -c=<cache-name> {-id=<node-id>|id8=<node-id8>} {-p=<page size>}", "cache -swap {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}" @@ -671,9 +651,6 @@ object VisorCacheCommand { "Name of the cache.", "Note you can also use '@c0' ... '@cn' variables as shortcut to <cache-name>." ), - "-compact" -> Seq( - "Compacts entries in cache." - ), "-clear" -> Seq( "Clears cache." ), @@ -728,9 +705,6 @@ object VisorCacheCommand { ), "cache -s=hi -r -a" -> "Prints detailed statistics about all caches sorted by number of hits in reverse order.", - "cache -compact" -> "Compacts entries in interactively selected cache.", - "cache -compact -c=cache" -> "Compacts entries in cache with name 'cache'.", - "cache -compact -c=@c0" -> "Compacts cache with name taken from 'c0' memory variable.", "cache -clear" -> "Clears interactively selected cache.", "cache -clear -c=cache" -> "Clears cache with name 'cache'.", "cache -clear -c=@c0" -> "Clears cache with name taken from 'c0' memory variable.", http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/79293ffb/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommand.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommand.scala deleted file mode 100644 index e4cade9..0000000 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommand.scala +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.visor.commands.cache - -import org.apache.ignite.internal.visor.cache.VisorCacheCompactTask -import org.apache.ignite.internal.visor.util.VisorTaskUtils._ - -import org.apache.ignite.cluster.ClusterNode - -import java.util.Collections - -import org.apache.ignite.visor.commands.VisorTextTable -import org.apache.ignite.visor.visor -import visor._ - -import scala.collection.JavaConversions._ -import scala.language.reflectiveCalls -import scala.util.control.Breaks._ - -/** - * ==Overview== - * Visor 'compact' command implementation. - * - * ==Help== - * {{{ - * +--------------------------------------------------------+ - * | compact | Compacts all entries in cache on all nodes. | - * +--------------------------------------------------------+ - * }}} - * - * ====Specification==== - * {{{ - * compact - * compact -c=<cache-name> - * }}} - * - * ====Arguments==== - * {{{ - * <cache-name> - * Name of the cache. - * If not specified, entries in default cache will be compacted. - * }}} - * - * ====Examples==== - * {{{ - * compact - * Compacts entries in interactively selected cache. - * compact -c=cache - * Compacts entries in cache with name 'cache'. - * }}} - */ -class VisorCacheCompactCommand { - /** - * Prints error message and advise. - * - * @param errMsgs Error messages. - */ - private def scold(errMsgs: Any*) { - assert(errMsgs != null) - - warn(errMsgs: _*) - warn("Type 'help cache' to see how to use this command.") - } - - /** - * ===Command=== - * Compacts entries in cache. - * - * ===Examples=== - * <ex>cache -compact -c=cache</ex> - * Compacts entries in cache with name 'cache'. - * - * @param argLst Command arguments. - */ - def compact(argLst: ArgList, node: Option[ClusterNode]) = breakable { - val cacheArg = argValue("c", argLst) - - val cacheName = cacheArg match { - case None => null // default cache. - - case Some(s) if s.startsWith("@") => - warn("Can't find cache variable with specified name: " + s, - "Type 'cache' to see available cache variables." - ) - - break() - - case Some(name) => name - } - - val prj = if (node.isDefined) ignite.cluster.forNode(node.get) else ignite.cluster.forCacheNodes(cacheName) - - if (prj.nodes().isEmpty) { - val msg = - if (cacheName == null) - "Can't find nodes with default cache." - else - "Can't find nodes with specified cache: " + cacheName - - scold(msg).^^ - } - - val t = VisorTextTable() - - t #= ("Node ID8(@)", "Entries Compacted", "Cache Size Before", "Cache Size After") - - val cacheSet = Collections.singleton(cacheName) - - prj.nodes().foreach(node => { - val r = ignite.compute(ignite.cluster.forNode(node)) - .withName("visor-ccompact-task") - .withNoFailover() - .execute(classOf[VisorCacheCompactTask], toTaskArgument(node.id(), cacheSet)) - .get(cacheName) - - t += (nodeId8(node.id()), r.get1() - r.get2(), r.get1(), r.get2()) - }) - - println("Compacts entries in cache: " + escapeName(cacheName)) - - t.render() - } -} - -/** - * Companion object that does initialization of the command. - */ -object VisorCacheCompactCommand { - /** Singleton command. */ - private val cmd = new VisorCacheCompactCommand - - /** - * Singleton. - */ - def apply() = cmd -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/79293ffb/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommandSpec.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommandSpec.scala deleted file mode 100644 index ee184ad..0000000 --- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommandSpec.scala +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.visor.commands.cache - -import org.apache.ignite.cache.CacheMode -import CacheMode._ -import org.apache.ignite.visor.{VisorRuntimeBaseSpec, visor} - -import org.apache.ignite.Ignition -import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration} -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder -import org.jetbrains.annotations.Nullable - -import org.apache.ignite.visor.commands.cache.VisorCacheCommand._ - -import scala.collection.JavaConversions._ - -/** - * - */ -class VisorCacheCompactCommandSpec extends VisorRuntimeBaseSpec(2) { - /** IP finder. */ - val ipFinder = new TcpDiscoveryVmIpFinder(true) - - /** - * Creates grid configuration for provided grid host. - * - * @param name Grid name. - * @return Grid configuration. - */ - override def config(name: String): IgniteConfiguration = { - val cfg = new IgniteConfiguration - - cfg.setGridName(name) - cfg.setLocalHost("127.0.0.1") - cfg.setCacheConfiguration(cacheConfig(null), cacheConfig("cache")) - - val discoSpi = new TcpDiscoverySpi() - - discoSpi.setIpFinder(ipFinder) - - cfg.setDiscoverySpi(discoSpi) - - cfg - } - - /** - * @param name Cache name. - * @return Cache Configuration. - */ - def cacheConfig(@Nullable name: String): CacheConfiguration[Object, Object] = { - val cfg = new CacheConfiguration[Object, Object] - - cfg.setCacheMode(REPLICATED) - cfg.setName(name) - - cfg - } - - behavior of "An 'ccompact' visor command" - - it should "show correct result for default cache" in { - Ignition.ignite("node-1").jcache[Int, Int](null).putAll(Map(1 -> 1, 2 -> 2, 3 -> 3)) - - Ignition.ignite("node-1").jcache[Int, Int](null).localEvict(Set(1)) - - VisorCacheCompactCommand().compact(Nil, None) - } - - it should "show correct result for named cache" in { - Ignition.ignite("node-1").jcache[Int, Int]("cache").putAll(Map(1 -> 1, 2 -> 2, 3 -> 3)) - - Ignition.ignite("node-1").jcache[Int, Int]("cache").localEvict(Set(1)) - - visor.cache("-compact -c=cache") - } - - it should "show correct help" in { - VisorCacheCommand - - visor.help("cache") - } - - it should "show empty projection error message" in { - visor.cache("-compact -c=wrong") - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/79293ffb/modules/visor-console/src/test/scala/org/apache/ignite/visor/testsuites/VisorConsoleSelfTestSuite.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/testsuites/VisorConsoleSelfTestSuite.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/testsuites/VisorConsoleSelfTestSuite.scala index 94162f3..b0ff4b1 100644 --- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/testsuites/VisorConsoleSelfTestSuite.scala +++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/testsuites/VisorConsoleSelfTestSuite.scala @@ -24,7 +24,7 @@ import org.apache.ignite.visor.VisorTextTableSpec import org.apache.ignite.visor.commands.VisorArgListSpec import org.apache.ignite.visor.commands.ack.VisorAckCommandSpec import org.apache.ignite.visor.commands.alert.VisorAlertCommandSpec -import org.apache.ignite.visor.commands.cache.{VisorCacheClearCommandSpec, VisorCacheCommandSpec, VisorCacheCompactCommandSpec} +import org.apache.ignite.visor.commands.cache.{VisorCacheClearCommandSpec, VisorCacheCommandSpec} import org.apache.ignite.visor.commands.config.VisorConfigurationCommandSpec import org.apache.ignite.visor.commands.cswap.VisorCacheSwapCommandSpec import org.apache.ignite.visor.commands.deploy.VisorDeployCommandSpec @@ -55,7 +55,6 @@ class VisorConsoleSelfTestSuite extends Suites ( new VisorAlertCommandSpec, new VisorCacheCommandSpec, new VisorCacheClearCommandSpec, - new VisorCacheCompactCommandSpec, new VisorConfigurationCommandSpec, new VisorCacheSwapCommandSpec, new VisorDeployCommandSpec,