You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2014/12/05 15:22:53 UTC
[17/20] incubator-ignite git commit: # Renaming
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/package.html
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/package.html b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/package.html
new file mode 100644
index 0000000..cc92a66
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/package.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+ @html.file.header
+ _________ _____ __________________ _____
+ __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+-->
+<html>
+<body>
+ <!-- Package description. -->
+ Contains file-based swap space SPI.
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java
new file mode 100644
index 0000000..b8a93c3
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java
@@ -0,0 +1,126 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.spi.swapspace.noop;
+
+import org.apache.ignite.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.spi.*;
+import org.apache.ignite.spi.swapspace.*;
+import org.gridgain.grid.util.*;
+import org.gridgain.grid.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+
+/**
+ * No-op implementation of {@link org.apache.ignite.spi.swapspace.SwapSpaceSpi}. Exists for testing and benchmarking purposes.
+ */
+@IgniteSpiNoop
+@IgniteSpiMultipleInstancesSupport(true)
+public class NoopSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi {
+ /** Logger. */
+ @IgniteLoggerResource
+ private IgniteLogger log;
+
+ /** {@inheritDoc} */
+ @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException {
+ U.warn(log, "Swap space is disabled. To enable use GridFileSwapSpaceSpi.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void spiStop() throws IgniteSpiException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clear(@Nullable String space) throws IgniteSpiException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public long size(@Nullable String space) throws IgniteSpiException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long count(@Nullable String space) throws IgniteSpiException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override @Nullable public byte[] read(@Nullable String spaceName, SwapKey key, SwapContext ctx)
+ throws IgniteSpiException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<SwapKey, byte[]> readAll(@Nullable String spaceName, Iterable<SwapKey> keys,
+ SwapContext ctx) throws IgniteSpiException {
+ return Collections.emptyMap();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(@Nullable String spaceName, SwapKey key, @Nullable IgniteInClosure<byte[]> c,
+ SwapContext ctx) throws IgniteSpiException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeAll(@Nullable String spaceName, Collection<SwapKey> keys,
+ @Nullable IgniteBiInClosure<SwapKey, byte[]> c, SwapContext ctx) throws IgniteSpiException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void store(@Nullable String spaceName, SwapKey key, @Nullable byte[] val,
+ SwapContext ctx) throws IgniteSpiException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void storeAll(@Nullable String spaceName, Map<SwapKey, byte[]> pairs,
+ SwapContext ctx) throws IgniteSpiException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setListener(@Nullable SwapSpaceSpiListener evictLsnr) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Integer> partitions(@Nullable String spaceName) throws IgniteSpiException {
+ return Collections.emptyList();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K> IgniteSpiCloseableIterator<K> keyIterator(@Nullable String spaceName,
+ SwapContext ctx) throws IgniteSpiException {
+ return new GridEmptyCloseableIterator<>();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteSpiCloseableIterator<Map.Entry<byte[], byte[]>> rawIterator(
+ @Nullable String spaceName) throws IgniteSpiException {
+ return new GridEmptyCloseableIterator<>();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteSpiCloseableIterator<Map.Entry<byte[], byte[]>> rawIterator(@Nullable String spaceName,
+ int part) throws IgniteSpiException {
+ return new GridEmptyCloseableIterator<>();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(NoopSwapSpaceSpi.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/package.html
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/package.html b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/package.html
new file mode 100644
index 0000000..d003e95
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/package.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+ @html.file.header
+ _________ _____ __________________ _____
+ __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+-->
+<html>
+<body>
+ <!-- Package description. -->
+ Contains <b>default</b> no-op swap space SPI implementation.
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/apache/ignite/spi/swapspace/package.html
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/package.html b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/package.html
new file mode 100644
index 0000000..2106182
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/package.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+ @html.file.header
+ _________ _____ __________________ _____
+ __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+-->
+<html>
+<body>
+ <!-- Package description. -->
+ Contains APIs for swap space SPI.
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
index a9efc83..1401e06 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
@@ -52,9 +52,9 @@ import org.apache.ignite.spi.loadbalancing.*;
import org.apache.ignite.spi.loadbalancing.roundrobin.*;
import org.apache.ignite.spi.securesession.*;
import org.apache.ignite.spi.securesession.noop.*;
-import org.gridgain.grid.spi.swapspace.*;
-import org.gridgain.grid.spi.swapspace.file.*;
-import org.gridgain.grid.spi.swapspace.noop.*;
+import org.apache.ignite.spi.swapspace.*;
+import org.apache.ignite.spi.swapspace.file.*;
+import org.apache.ignite.spi.swapspace.noop.*;
import org.gridgain.grid.util.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.grid.util.typedef.internal.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
index fd489ad..152952b 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
@@ -22,7 +22,7 @@ import org.gridgain.grid.kernal.managers.communication.*;
import org.gridgain.grid.kernal.managers.eventstorage.*;
import org.gridgain.grid.kernal.processors.cache.*;
import org.gridgain.grid.security.*;
-import org.gridgain.grid.spi.swapspace.*;
+import org.apache.ignite.spi.swapspace.*;
import org.gridgain.grid.util.direct.*;
import org.gridgain.grid.util.tostring.*;
import org.gridgain.grid.util.typedef.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/gridgain/grid/kernal/managers/swapspace/GridSwapSpaceManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/swapspace/GridSwapSpaceManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/swapspace/GridSwapSpaceManager.java
index e08935e..93523b9 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/swapspace/GridSwapSpaceManager.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/swapspace/GridSwapSpaceManager.java
@@ -16,7 +16,7 @@ import org.apache.ignite.spi.*;
import org.gridgain.grid.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.managers.*;
-import org.gridgain.grid.spi.swapspace.*;
+import org.apache.ignite.spi.swapspace.*;
import org.gridgain.grid.util.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.gridgain.grid.util.lang.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapManager.java
index ff7f0e6..4369213 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapManager.java
@@ -15,7 +15,7 @@ import org.gridgain.grid.kernal.managers.swapspace.*;
import org.gridgain.grid.kernal.processors.cache.query.*;
import org.gridgain.grid.kernal.processors.license.*;
import org.gridgain.grid.kernal.processors.offheap.*;
-import org.gridgain.grid.spi.swapspace.*;
+import org.apache.ignite.spi.swapspace.*;
import org.gridgain.grid.util.*;
import org.gridgain.grid.util.lang.*;
import org.gridgain.grid.util.offheap.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapContext.java b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapContext.java
deleted file mode 100644
index c757651..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapContext.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.spi.swapspace;
-
-import org.gridgain.grid.util.typedef.internal.*;
-
-/**
- * Context for swap operations.
- */
-public class SwapContext {
- /** */
- private ClassLoader clsLdr;
-
- /**
- * @return Class loader.
- */
- public ClassLoader classLoader() {
- return clsLdr;
- }
-
- /**
- * @param clsLdr Class loader.
- */
- public void classLoader(ClassLoader clsLdr) {
- this.clsLdr = clsLdr;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(SwapContext.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapKey.java b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapKey.java
deleted file mode 100644
index 1bce5f7..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapKey.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.spi.swapspace;
-
-import org.gridgain.grid.util.typedef.internal.*;
-import org.gridgain.grid.util.tostring.*;
-import org.jetbrains.annotations.*;
-
-/**
- * Utility wrapper class that represents swap key.
- * <p>
- * This class also holds information about partition this key belongs to
- * (if needed for caches).
- */
-public class SwapKey {
- /** */
- @GridToStringInclude
- private final Object key;
-
- /** */
- private final int part;
-
- /** Serialized key. */
- @GridToStringExclude
- private byte[] keyBytes;
-
- /**
- * @param key Key.
- */
- public SwapKey(Object key) {
- this(key, Integer.MAX_VALUE, null);
- }
-
- /**
- * @param key Key.
- * @param part Partition.
- */
- public SwapKey(Object key, int part) {
- this(key, part, null);
- }
-
- /**
- * @param key Key.
- * @param part Part.
- * @param keyBytes Key bytes.
- */
- public SwapKey(Object key, int part, @Nullable byte[] keyBytes) {
- assert key != null;
- assert part >= 0;
-
- this.key = key;
- this.part = part;
- this.keyBytes = keyBytes;
- }
-
- /**
- * @return Key.
- */
- public Object key() {
- return key;
- }
-
- /**
- * @return Partition this key belongs to.
- */
- public int partition() {
- return part;
- }
-
- /**
- * @return Serialized key.
- */
- @Nullable public byte[] keyBytes() {
- return keyBytes;
- }
-
- /**
- * @param keyBytes Serialized key.
- */
- public void keyBytes(byte[] keyBytes) {
- assert keyBytes != null;
-
- this.keyBytes = keyBytes;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object obj) {
- if (obj == this)
- return true;
-
- if (obj instanceof SwapKey) {
- SwapKey other = (SwapKey)obj;
-
- return part == other.part && key.equals(other.key);
- }
-
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return key.hashCode();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(SwapKey.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpi.java b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpi.java
deleted file mode 100644
index 1a07535..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpi.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.spi.swapspace;
-
-import org.apache.ignite.lang.*;
-import org.apache.ignite.spi.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-/**
- * Provides a mechanism in grid for storing data on disk. GridGain cache uses swap space to overflow
- * data to disk if it cannot fit in memory. It's also possible to use swap space directly
- * by calling {@link org.apache.ignite.Ignite} API swap-related methods. Logically storage is organized into
- * independent 'spaces' in which data is stored.
- * <p>
- * All swap space implementations can be configured to prevent infinite growth and evict oldest entries.
- * <p>
- * The default swap space SPI is {@link org.gridgain.grid.spi.swapspace.file.FileSwapSpaceSpi} which stores values on disk in files and keeps keys in
- * memory.
- * <p>
- * Gridgain provides the following {@code GridSwapSpaceSpi} implementations:
- * <ul>
- * <li>
- * {@link org.gridgain.grid.spi.swapspace.file.FileSwapSpaceSpi} - pure Java implementation with in-memory keys. This SPI is used by default.
- * </li>
- * <li>
- * {@link org.gridgain.grid.spi.swapspace.noop.NoopSwapSpaceSpi} - no-op SPI mainly for testing.
- * </li>
- * </ul>
- * <p>
- * <p>
- * <b>NOTE:</b> this SPI (i.e. methods in this interface) should never be used directly. SPIs provide
- * internal view on the subsystem and is used internally by GridGain kernal. In rare use cases when
- * access to a specific implementation of this SPI is required - an instance of this SPI can be obtained
- * via {@link org.apache.ignite.Ignite#configuration()} method to check its configuration properties or call other non-SPI
- * methods. Note again that calling methods from this interface on the obtained instance can lead
- * to undefined behavior and explicitly not supported.
- */
-public interface SwapSpaceSpi extends IgniteSpi {
- /**
- * Entirely clears data space with given name, if any.
- *
- * @param spaceName Space name to clear.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
- */
- public void clear(@Nullable String spaceName) throws IgniteSpiException;
-
- /**
- * Gets size in bytes for data space with given name. If specified space does
- * not exist this method returns {@code 0}.
- *
- * @param spaceName Space name to get size for.
- * @return Size in bytes.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
- */
- public long size(@Nullable String spaceName) throws IgniteSpiException;
-
- /**
- * Gets number of stored entries (keys) in data space with given name. If specified
- * space does not exist this method returns {@code 0}.
- *
- * @param spaceName Space name to get number of entries for.
- * @return Number of stored entries in specified space.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
- */
- public long count(@Nullable String spaceName) throws IgniteSpiException;
-
- /**
- * Reads stored value as array of bytes by key from data space with given name.
- * If specified space does not exist this method returns {@code null}.
- *
- * @param spaceName Name of the data space to read from.
- * @param key Key used to read value from data space.
- * @param ctx Swap context.
- * @return Value as array of bytes stored in specified data space that matches
- * to given key.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
- */
- @Nullable public byte[] read(@Nullable String spaceName, SwapKey key, SwapContext ctx)
- throws IgniteSpiException;
-
- /**
- * Reads stored values as array of bytes by all passed keys from data space with
- * given name. If specified space does not exist this method returns empty map.
- *
- * @param spaceName Name of the data space to read from.
- * @param keys Keys used to read values from data space.
- * @param ctx Swap context.
- * @return Map in which keys are the ones passed into method and values are
- * corresponding values read from swap storage.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
- */
- public Map<SwapKey, byte[]> readAll(@Nullable String spaceName,
- Iterable<SwapKey> keys, SwapContext ctx) throws IgniteSpiException;
-
- /**
- * Removes value stored in data space with given name corresponding to specified key.
- *
- * @param spaceName Space name to remove value from.
- * @param key Key to remove value in the specified space for.
- * @param c Optional closure that takes removed value and executes after actual
- * removing. If there was no value in storage the closure is not executed.
- * @param ctx Swap context.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
- */
- public void remove(@Nullable String spaceName, SwapKey key,
- @Nullable IgniteInClosure<byte[]> c, SwapContext ctx) throws IgniteSpiException;
-
- /**
- * Removes values stored in data space with given name corresponding to specified keys.
- *
- * @param spaceName Space name to remove values from.
- * @param keys Keys to remove value in the specified space for.
- * @param c Optional closure that takes removed value and executes after actual
- * removing. If there was no value in storage the closure is not executed.
- * @param ctx Swap context.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
- */
- public void removeAll(@Nullable String spaceName, Collection<SwapKey> keys,
- @Nullable IgniteBiInClosure<SwapKey, byte[]> c, SwapContext ctx) throws IgniteSpiException;
-
- /**
- * Stores value as array of bytes with given key into data space with given name.
- *
- * @param spaceName Space name to store key-value pair into.
- * @param key Key to store given value for. This key can be used further to
- * read or remove stored value.
- * @param val Some value as array of bytes to store into specified data space.
- * @param ctx Swap context.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
- */
- public void store(@Nullable String spaceName, SwapKey key, @Nullable byte[] val, SwapContext ctx)
- throws IgniteSpiException;
-
- /**
- * Stores key-value pairs (both keys and values are arrays of bytes) into data
- * space with given name.
- *
- * @param spaceName Space name to store key-value pairs into.
- * @param pairs Map of stored key-value pairs where each one is an array of bytes.
- * @param ctx Swap context.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
- */
- public void storeAll(@Nullable String spaceName, Map<SwapKey, byte[]> pairs, SwapContext ctx)
- throws IgniteSpiException;
-
- /**
- * Sets eviction listener to receive notifications on evicted swap entries.
- *
- * @param evictLsnr Eviction listener ({@code null} to stop receiving notifications).
- */
- public void setListener(@Nullable SwapSpaceSpiListener evictLsnr);
-
- /**
- * Gets partitions IDs that are stored in the passed in space.
- *
- * @param spaceName Space name.
- * @return Partitions IDs or {@code null} if space is unknown.
- * @throws org.apache.ignite.spi.IgniteSpiException If failed.
- */
- @Nullable public Collection<Integer> partitions(@Nullable String spaceName) throws IgniteSpiException;
-
- /**
- * Gets iterator over space keys.
- *
- * @param spaceName Space name.
- * @param ctx Swap context.
- * @return Iterator over space entries or {@code null} if space is unknown.
- * @throws org.apache.ignite.spi.IgniteSpiException If failed.
- */
- @Nullable <K> IgniteSpiCloseableIterator<K> keyIterator(@Nullable String spaceName, SwapContext ctx)
- throws IgniteSpiException;
-
- /**
- * Gets raw iterator over space entries.
- *
- * @param spaceName Space name.
- * @return Iterator over space entries or {@code null} if space is unknown.
- * @throws org.apache.ignite.spi.IgniteSpiException If failed.
- */
- @Nullable public IgniteSpiCloseableIterator<Map.Entry<byte[], byte[]>> rawIterator(@Nullable String spaceName)
- throws IgniteSpiException;
-
- /**
- * Gets raw iterator over space entries.
- *
- * @param spaceName Space name.
- * @param part Partition.
- * @return Iterator over space entries or {@code null} if space is unknown.
- * @throws org.apache.ignite.spi.IgniteSpiException If failed.
- */
- @Nullable public IgniteSpiCloseableIterator<Map.Entry<byte[], byte[]>> rawIterator(@Nullable String spaceName,
- int part) throws IgniteSpiException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpiListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpiListener.java b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpiListener.java
deleted file mode 100644
index da8639d..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpiListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.spi.swapspace;
-
-import org.jetbrains.annotations.*;
-
-/**
- * Swap space SPI eviction listener.
- */
-public interface SwapSpaceSpiListener {
- /**
- * Notification for swap space events.
- *
- * @param evtType Event type. See {@link org.apache.ignite.events.IgniteSwapSpaceEvent}
- * @param spaceName Space name for this event or {@code null} for default space.
- * @param keyBytes Key bytes of affected entry. Not {@code null} only for evict notifications.
- */
- public void onSwapEvent(int evtType, @Nullable String spaceName, @Nullable byte[] keyBytes);
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef258ece/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/file/FileSwapArray.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/file/FileSwapArray.java b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/file/FileSwapArray.java
deleted file mode 100644
index e4a4f28..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/file/FileSwapArray.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.spi.swapspace.file;
-
-import org.jetbrains.annotations.*;
-
-import java.util.concurrent.atomic.*;
-
-/**
- * Growing array.
- */
-class FileSwapArray<X> {
- /** First partition size must be power of two. */
- private static final int FIRST_ARRAY_SIZE = 4096;
-
- /** */
- private static final int LADDER_SIZE = Integer.numberOfLeadingZeros(FIRST_ARRAY_SIZE) + 1;
-
- /** */
- @SuppressWarnings("unchecked")
- private final AtomicReferenceArray<X>[] ladder = new AtomicReferenceArray[LADDER_SIZE];
-
- /** */
- private int idx = 1;
-
- /**
- *
- */
- FileSwapArray() {
- synchronized (ladder) {
- ladder[0] = new AtomicReferenceArray<>(FIRST_ARRAY_SIZE);
- }
- }
-
- /**
- * @return Size.
- */
- public int size() {
- return idx;
- }
-
- /**
- * Adds value to the end.
- *
- * @param x Value.
- * @return Index where it was added.
- */
- int add(X x) {
- int i = idx++;
-
- assert i >= 0 && i != Integer.MAX_VALUE : "Integer overflow";
-
- Slot<X> s = slot(i);
-
- assert s != null; // We should add always in one thread.
-
- s.set(x);
-
- int len = s.arr.length();
-
- if (s.idx + 1 == len) {
- synchronized (ladder) {
- ladder[s.arrIdx + 1] = new AtomicReferenceArray<>(s.arrIdx == 0 ? len : len << 1);
- }
- }
-
- return i;
- }
-
- /**
- * @param size New size.
- */
- void truncate(int size) {
- assert size > 0;
-
- idx = size;
-
- int arrIdx = arrayIndex(idx) + 1;
-
- if (arrIdx < ladder.length && ladder[arrIdx] != null) {
- synchronized (ladder) {
- do {
- ladder[arrIdx++] = null;
- }
- while (arrIdx < ladder.length && ladder[arrIdx] != null);
- }
- }
- }
-
- /**
- * @param idx Absolute slot index.
- * @return Array index in {@link #ladder}.
- */
- static int arrayIndex(int idx) {
- if (idx < FIRST_ARRAY_SIZE)
- return 0;
-
- return LADDER_SIZE - Integer.numberOfLeadingZeros(idx);
- }
-
- /**
- * Slot for given absolute index.
- *
- * @param idx Absolute index.
- * @return Slot.
- */
- @Nullable Slot<X> slot(int idx) {
- assert idx > 0 : idx;
-
- int arrIdx = arrayIndex(idx);
-
- AtomicReferenceArray<X> arr = ladder[arrIdx];
-
- if (arr == null) {
- synchronized (ladder) { // Ensure visibility.
- arr = ladder[arrIdx];
- }
-
- if (arr == null)
- return null;
- }
-
- return new Slot<>(arrIdx, arr, arrIdx == 0 ? idx : idx - arr.length());
- }
-
- /**
- * Slot in array.
- */
- @SuppressWarnings("PublicInnerClass")
- static final class Slot<X> {
- /** */
- private final int arrIdx;
-
- /** */
- private final AtomicReferenceArray<X> arr;
-
- /** */
- private final int idx;
-
- /**
- * @param arrIdx Index of array.
- * @param arr Array.
- * @param idx Index within the array.
- */
- private Slot(int arrIdx, AtomicReferenceArray<X> arr, int idx) {
- this.arrIdx = arrIdx;
- this.arr = arr;
- this.idx = idx;
- }
-
- /**
- * @return Value.
- */
- public X get() {
- return arr.get(idx);
- }
-
- /**
- * @param exp Expected.
- * @param x New value.
- * @return {@code true} If succeeded.
- */
- public boolean cas(@Nullable X exp, @Nullable X x) {
- return exp == x || arr.compareAndSet(idx, exp, x);
- }
-
- /**
- * @param x value.
- */
- private void set(X x) {
- arr.lazySet(idx, x);
- }
- }
-}