Repository: incubator-ignite Updated Branches: refs/heads/ignite-37 436301ed8 -> eb4174ae8 (forced update)
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eb4174ae/modules/core/src/main/java/org/apache/ignite/mxbean/CacheMetricsMXBean.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/mxbean/CacheMetricsMXBean.java b/modules/core/src/main/java/org/apache/ignite/mxbean/CacheMetricsMXBean.java index 2ad07b5..4c37682 100644 --- a/modules/core/src/main/java/org/apache/ignite/mxbean/CacheMetricsMXBean.java +++ b/modules/core/src/main/java/org/apache/ignite/mxbean/CacheMetricsMXBean.java @@ -100,14 +100,58 @@ public interface CacheMetricsMXBean extends CacheStatisticsMXBean, CacheMXBean, public long getOverflowSize(); /** {@inheritDoc} */ + @MXBeanDescription("Number of gets from off-heap memory.") + public long getOffHeapGets(); + + /** {@inheritDoc} */ + @MXBeanDescription("Number of puts to off-heap memory.") + public long getOffHeapPuts(); + + /** {@inheritDoc} */ + @MXBeanDescription("Number of removed entries from off-heap memory.") + public long getOffHeapRemovals(); + + /** {@inheritDoc} */ + @MXBeanDescription("Number of evictions from off-heap memory.") + public long getOffHeapEvictions(); + + /** {@inheritDoc} */ + @MXBeanDescription("Number of hits on off-heap memory.") + public long getOffHeapHits(); + + /** {@inheritDoc} */ + @MXBeanDescription("Percentage of hits on off-heap memory.") + public float getOffHeapHitPercentage(); + + /** {@inheritDoc} */ + @MXBeanDescription("Number of misses on off-heap memory.") + public long getOffHeapMisses(); + + /** {@inheritDoc} */ + @MXBeanDescription("Percentage of misses on off-heap memory.") + public float getOffHeapMissPercentage(); + + /** {@inheritDoc} */ @MXBeanDescription("Number of entries stored in off-heap memory.") public long getOffHeapEntriesCount(); /** {@inheritDoc} */ + @MXBeanDescription("Number of primary entries stored in off-heap memory.") + public long getOffHeapPrimaryEntriesCount(); + + /** {@inheritDoc} */ + @MXBeanDescription("Number of backup stored in off-heap memory.") + public long getOffHeapBackupEntriesCount(); + + /** {@inheritDoc} */ @MXBeanDescription("Memory size allocated in off-heap.") public long getOffHeapAllocatedSize(); /** {@inheritDoc} */ + @MXBeanDescription("Off-heap memory maximum size.") + public long getOffHeapMaxSize(); + + /** {@inheritDoc} */ @MXBeanDescription("Number of non-null values in the cache.") public int getSize(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eb4174ae/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java index 871512c..b13cc97 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java @@ -29,7 +29,7 @@ import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.resources.*; -import org.apache.ignite.spi.swapspace.*; + import org.jetbrains.annotations.*; import javax.management.*; @@ -453,19 +453,20 @@ public abstract class IgniteSpiAdapter implements IgniteSpi, IgniteSpiManagement boolean isSpiConsistent = false; - String tipStr = " (fix configuration or set " + "-D" + IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK + "=true system property)"; + String tipStr = " (fix configuration or set " + + "-D" + IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK + "=true system property)"; if (rmtCls == null) { if (!optional && starting) - throw new IgniteSpiException("Remote SPI with the same name is not configured" + tipStr + " [name=" + name + - ", loc=" + locCls + ']'); + throw new IgniteSpiException("Remote SPI with the same name is not configured" + tipStr + + " [name=" + name + ", loc=" + locCls + ']'); sb.a(format(">>> Remote SPI with the same name is not configured: " + name, locCls)); } else if (!locCls.equals(rmtCls)) { if (!optional && starting) - throw new IgniteSpiException("Remote SPI with the same name is of different type" + tipStr + " [name=" + name + - ", loc=" + locCls + ", rmt=" + rmtCls + ']'); + throw new IgniteSpiException("Remote SPI with the same name is of different type" + tipStr + + " [name=" + name + ", loc=" + locCls + ", rmt=" + rmtCls + ']'); sb.a(format(">>> Remote SPI with the same name is of different type: " + name, locCls, rmtCls)); } @@ -627,27 +628,11 @@ public abstract class IgniteSpiAdapter implements IgniteSpi, IgniteSpiManagement } /** {@inheritDoc} */ - @Override public void writeToSwap(String spaceName, Object key, @Nullable Object val, - @Nullable ClassLoader ldr) { - /* No-op. */ - } - - /** {@inheritDoc} */ - @Override public <T> T readFromSwap(String spaceName, SwapKey key, @Nullable ClassLoader ldr) { - return null; - } - - /** {@inheritDoc} */ @Override public int partition(String cacheName, Object key) { return -1; } /** {@inheritDoc} */ - @Override public void removeFromSwap(String spaceName, Object key, @Nullable ClassLoader ldr) { - // No-op. - } - - /** {@inheritDoc} */ @Override public Collection<ClusterNode> nodes() { return locNode == null ? Collections.<ClusterNode>emptyList() : Collections.singletonList(locNode); } @@ -713,12 +698,6 @@ public abstract class IgniteSpiAdapter implements IgniteSpi, IgniteSpiManagement } /** {@inheritDoc} */ - @Nullable @Override public <T> T readValueFromOffheapAndSwap(@Nullable String spaceName, Object key, - @Nullable ClassLoader ldr) { - return null; - } - - /** {@inheritDoc} */ @Override public MessageFormatter messageFormatter() { return msgFormatter; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eb4174ae/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java index 6852b6d..55f46e5 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java @@ -24,7 +24,6 @@ import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.managers.eventstorage.*; import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.plugin.security.*; -import org.apache.ignite.spi.swapspace.*; import org.jetbrains.annotations.*; import javax.cache.*; @@ -253,30 +252,6 @@ public interface IgniteSpiContext { public <K> boolean containsKey(String cacheName, K key); /** - * Writes object to swap. - * - * @param spaceName Swap space name. - * @param key Key. - * @param val Value. - * @param ldr Class loader (optional). - * @throws IgniteException If any exception occurs. - */ - public void writeToSwap(String spaceName, Object key, @Nullable Object val, @Nullable ClassLoader ldr) - throws IgniteException; - - /** - * Reads object from swap. - * - * @param spaceName Swap space name. - * @param key Key. - * @param ldr Class loader (optional). - * @return Swapped value. - * @throws IgniteException If any exception occurs. - */ - @Nullable public <T> T readFromSwap(String spaceName, SwapKey key, @Nullable ClassLoader ldr) - throws IgniteException; - - /** * Calculates partition number for given key. * * @param cacheName Cache name. @@ -286,16 +261,6 @@ public interface IgniteSpiContext { public int partition(String cacheName, Object key); /** - * Removes object from swap. - * - * @param spaceName Swap space name. - * @param key Key. - * @param ldr Class loader (optional). - * @throws IgniteException If any exception occurs. - */ - public void removeFromSwap(String spaceName, Object key, @Nullable ClassLoader ldr) throws IgniteException; - - /** * Validates that new node can join grid topology, this method is called on coordinator * node before new node joins topology. * @@ -322,18 +287,6 @@ public interface IgniteSpiContext { public SecuritySubject authenticatedSubject(UUID subjId) throws IgniteException; /** - * Reads swapped cache value from off-heap and swap. - * - * @param spaceName Off-heap space name. - * @param key Key. - * @param ldr Class loader for unmarshalling. - * @return Value. - * @throws IgniteException If any exception occurs. - */ - @Nullable public <T> T readValueFromOffheapAndSwap(@Nullable String spaceName, Object key, - @Nullable ClassLoader ldr) throws IgniteException; - - /** * Gets message formatter. * * @return Message formatter. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eb4174ae/modules/core/src/test/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManagerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManagerSelfTest.java index 043311e..27e0fea 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManagerSelfTest.java @@ -21,10 +21,11 @@ import org.apache.ignite.*; import org.apache.ignite.configuration.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; +import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; -import org.apache.ignite.spi.swapspace.*; +import org.apache.ignite.marshaller.*; import org.apache.ignite.spi.swapspace.file.*; import org.apache.ignite.testframework.junits.common.*; @@ -40,7 +41,10 @@ import static org.apache.ignite.events.EventType.*; @GridCommonTest(group = "Kernal Self") public class GridSwapSpaceManagerSelfTest extends GridCommonAbstractTest { /** */ - private static final String spaceName = "swapspace_mgr"; + private static final String SPACE_NAME = "swapspace_mgr"; + + /** Partition. */ + private static final int PART = Integer.MAX_VALUE; /** * @@ -64,7 +68,7 @@ public class GridSwapSpaceManagerSelfTest extends GridCommonAbstractTest { * @param ignite Grid instance. * @return Swap space manager. */ - private GridSwapSpaceManager getSwapSpaceManager(Ignite ignite) { + private static GridSwapSpaceManager getSwapSpaceManager(Ignite ignite) { assert ignite != null; return ((IgniteKernal) ignite).context().swap(); @@ -89,7 +93,7 @@ public class GridSwapSpaceManagerSelfTest extends GridCommonAbstractTest { SwapSpaceEvent e = (SwapSpaceEvent) evt; - assert spaceName.equals(e.space()); + assert SPACE_NAME.equals(e.space()); assert ignite.cluster().localNode().id().equals(e.node().id()); switch (evt.type()) { @@ -123,41 +127,55 @@ public class GridSwapSpaceManagerSelfTest extends GridCommonAbstractTest { GridSwapSpaceManager mgr = getSwapSpaceManager(ignite); + ignite.getOrCreateCache((String)null); + + GridKernalContext ctx = ((IgniteKernal)ignite).context(); + + GridCacheContext cctx = ((IgniteCacheProxy)ignite.cache(null)).context(); + + Marshaller marsh = ctx.config().getMarshaller(); + assert mgr != null; // Empty data space. - assertEquals(0, mgr.swapSize(spaceName)); + assertEquals(0, mgr.swapSize(SPACE_NAME)); + + String key1 = "key1"; + + String key2 = "key2"; + + KeyCacheObject ckey1 = new KeyCacheObjectImpl(key1, marsh.marshal(key1)); - SwapKey key = new SwapKey("key1"); + KeyCacheObject ckey2 = new KeyCacheObjectImpl(key2, marsh.marshal(key2)); String val = "value"; - mgr.write(spaceName, key, val.getBytes(), null); + mgr.write(SPACE_NAME, PART, ckey1, marsh.marshal(val), cctx); - mgr.write(spaceName, new SwapKey("key2"), val.getBytes(), null); + mgr.write(SPACE_NAME, PART, ckey2, marsh.marshal(val), cctx); assert storeCnt.await(10, SECONDS); - byte[] arr = mgr.read(spaceName, key, null); + byte[] arr = mgr.read(SPACE_NAME, PART, ckey1, cctx); assert arr != null; - assert val.equals(new String(arr)); + assert val.equals(marsh.unmarshal(arr, cctx.deploy().globalLoader())); final GridTuple<Boolean> b = F.t(false); - mgr.remove(spaceName, key, new CI1<byte[]>() { + mgr.remove(SPACE_NAME, PART, ckey1, cctx, new CI1<byte[]>() { @Override public void apply(byte[] rmv) { b.set(rmv != null); } - }, null); + }); assert b.get(); assert rmvCnt.await(10, SECONDS); assert readCnt.await(10, SECONDS); - mgr.clear(spaceName); + mgr.clear(SPACE_NAME); assert clearCnt.await(10, SECONDS) : "Count: " + clearCnt.getCount(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eb4174ae/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java index bc04f90..5867fb8 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java @@ -29,7 +29,7 @@ import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.spi.*; -import org.apache.ignite.spi.swapspace.*; + import org.jetbrains.annotations.*; import java.io.*; @@ -447,28 +447,11 @@ public class GridSpiTestContext implements IgniteSpiContext { } /** {@inheritDoc} */ - @Override public void writeToSwap(String spaceName, Object key, @Nullable Object val, - @Nullable ClassLoader ldr) { - /* No-op. */ - } - - /** {@inheritDoc} */ - @Override public <T> T readFromSwap(String spaceName, SwapKey key, @Nullable ClassLoader ldr) { - return null; - } - - /** {@inheritDoc} */ @Override public int partition(String cacheName, Object key) { return -1; } /** {@inheritDoc} */ - @Override public void removeFromSwap(String spaceName, Object key, - @Nullable ClassLoader ldr) { - // No-op. - } - - /** {@inheritDoc} */ @Nullable @Override public IgniteNodeValidationResult validateNode(ClusterNode node) { return null; } @@ -484,12 +467,6 @@ public class GridSpiTestContext implements IgniteSpiContext { } /** {@inheritDoc} */ - @Nullable @Override public <T> T readValueFromOffheapAndSwap(@Nullable String spaceName, Object key, - @Nullable ClassLoader ldr) { - return null; - } - - /** {@inheritDoc} */ @Override public MessageFormatter messageFormatter() { if (formatter == null) { formatter = new MessageFormatter() {
