Repository: incubator-ignite Updated Branches: refs/heads/ignite-6 6759af1ec -> 9772e720f
# ignite-6 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/85a0f375 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/85a0f375 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/85a0f375 Branch: refs/heads/ignite-6 Commit: 85a0f3750bb0c045255f74355eb825b4daf023aa Parents: 6e3b88d Author: sboikov <sboi...@gridgain.com> Authored: Wed Jan 28 16:22:15 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Wed Jan 28 16:22:15 2015 +0300 ---------------------------------------------------------------------- .../datastructures/CacheQueueExample.java | 22 +- .../datastructures/CacheSetExample.java | 23 +- .../java/org/apache/ignite/IgniteCache.java | 5 - .../java/org/apache/ignite/cache/GridCache.java | 13 - .../datastructures/CacheDataStructures.java | 220 --------------- .../IgniteAtomicConfiguration.java | 8 +- .../IgniteCollectionConfiguration.java | 20 ++ .../processors/cache/GridCacheAdapter.java | 6 - .../processors/cache/GridCacheProxyImpl.java | 5 - .../CacheDataStructuresProcessor.java | 93 ++++--- .../GridCacheDataStructuresProxy.java | 267 ------------------- .../DatastructuresCommandHandler.java | 1 + .../GridCacheAtomicLongApiAbstractSelfTest.java | 3 +- ...CacheAtomicReferenceApiSelfAbstractTest.java | 3 +- ...idCacheAtomicStampedApiSelfAbstractTest.java | 3 +- .../GridCacheSequenceApiSelfAbstractTest.java | 3 +- 16 files changed, 100 insertions(+), 595 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheQueueExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheQueueExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheQueueExample.java index aebb950..fa22848 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheQueueExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheQueueExample.java @@ -18,6 +18,7 @@ package org.apache.ignite.examples.datagrid.datastructures; import org.apache.ignite.*; +import org.apache.ignite.configuration.*; import org.apache.ignite.examples.datagrid.*; import org.apache.ignite.lang.*; @@ -34,9 +35,6 @@ import java.util.*; * start GridGain node with {@code examples/config/example-cache.xml} configuration. */ public class CacheQueueExample { - /** Cache name. */ - private static final String CACHE_NAME = "partitioned_tx"; - /** Number of retries */ private static final int RETRIES = 20; @@ -78,8 +76,10 @@ public class CacheQueueExample { * @throws IgniteCheckedException If execution failed. */ private static IgniteQueue<String> initializeQueue(Ignite g, String queueName) throws IgniteCheckedException { + IgniteCollectionConfiguration colCfg = new IgniteCollectionConfiguration(); + // Initialize new FIFO queue. - IgniteQueue<String> queue = g.cache(CACHE_NAME).dataStructures().queue(queueName, 0, false, true); + IgniteQueue<String> queue = g.queue(queueName, colCfg, 0, true); // Initialize queue items. // We will be use blocking operation and queue size must be appropriated. @@ -101,7 +101,7 @@ public class CacheQueueExample { final String queueName = queue.name(); // Read queue items on each node. - g.compute().run(new QueueClosure(CACHE_NAME, queueName, false)); + g.compute().run(new QueueClosure(queueName, false)); System.out.println("Queue size after reading [expected=0, actual=" + queue.size() + ']'); } @@ -116,7 +116,7 @@ public class CacheQueueExample { final String queueName = queue.name(); // Write queue items on each node. - g.compute().run(new QueueClosure(CACHE_NAME, queueName, true)); + g.compute().run(new QueueClosure(queueName, true)); System.out.println("Queue size after writing [expected=" + g.cluster().nodes().size() * RETRIES + ", actual=" + queue.size() + ']'); @@ -158,9 +158,6 @@ public class CacheQueueExample { * Closure to populate or poll the queue. */ private static class QueueClosure implements IgniteRunnable { - /** Cache name. */ - private final String cacheName; - /** Queue name. */ private final String queueName; @@ -168,12 +165,10 @@ public class CacheQueueExample { private final boolean put; /** - * @param cacheName Cache name. * @param queueName Queue name. * @param put Flag indicating whether to put or poll. */ - QueueClosure(String cacheName, String queueName, boolean put) { - this.cacheName = cacheName; + QueueClosure(String queueName, boolean put) { this.queueName = queueName; this.put = put; } @@ -181,8 +176,7 @@ public class CacheQueueExample { /** {@inheritDoc} */ @Override public void run() { try { - IgniteQueue<String> queue = Ignition.ignite().cache(cacheName).dataStructures(). - queue(queueName, 0, false, true); + IgniteQueue<String> queue = Ignition.ignite().queue(queueName, null, 0, false); if (put) { UUID locId = Ignition.ignite().cluster().localNode().id(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheSetExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheSetExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheSetExample.java index 6e767bd..9a92f2f 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheSetExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheSetExample.java @@ -18,6 +18,7 @@ package org.apache.ignite.examples.datagrid.datastructures; import org.apache.ignite.*; +import org.apache.ignite.configuration.*; import org.apache.ignite.examples.datagrid.*; import org.apache.ignite.lang.*; @@ -33,9 +34,6 @@ import java.util.*; * start GridGain node with {@code examples/config/example-cache.xml} configuration. */ public class CacheSetExample { - /** Cache name. */ - private static final String CACHE_NAME = "partitioned_tx"; - /** Set instance. */ private static IgniteSet<String> set; @@ -72,8 +70,10 @@ public class CacheSetExample { * @throws IgniteCheckedException If execution failed. */ private static IgniteSet<String> initializeSet(Ignite g, String setName) throws IgniteCheckedException { + IgniteCollectionConfiguration setCfg = new IgniteCollectionConfiguration(); + // Initialize new set. - IgniteSet<String> set = g.cache(CACHE_NAME).dataStructures().set(setName, false, true); + IgniteSet<String> set = g.set(setName, setCfg, true); // Initialize set items. for (int i = 0; i < 10; i++) @@ -94,7 +94,7 @@ public class CacheSetExample { final String setName = set.name(); // Write set items on each node. - g.compute().broadcast(new SetClosure(CACHE_NAME, setName)); + g.compute().broadcast(new SetClosure(setName)); System.out.println("Set size after writing [expected=" + (10 + g.cluster().nodes().size() * 5) + ", actual=" + set.size() + ']'); @@ -136,8 +136,8 @@ public class CacheSetExample { System.out.println("Set size after clearing: " + set.size()); - // Remove set from cache. - g.cache(CACHE_NAME).dataStructures().removeSet(set.name()); + // Remove set. + set.close(); System.out.println("Set was removed: " + set.removed()); @@ -154,25 +154,20 @@ public class CacheSetExample { * Closure to populate the set. */ private static class SetClosure implements IgniteRunnable { - /** Cache name. */ - private final String cacheName; - /** Set name. */ private final String setName; /** - * @param cacheName Cache name. * @param setName Set name. */ - SetClosure(String cacheName, String setName) { - this.cacheName = cacheName; + SetClosure(String setName) { this.setName = setName; } /** {@inheritDoc} */ @Override public void run() { try { - IgniteSet<String> set = Ignition.ignite().cache(cacheName).dataStructures().set(setName, false, true); + IgniteSet<String> set = Ignition.ignite().set(setName, null, false); UUID locId = Ignition.ignite().cluster().localNode().id(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/main/java/org/apache/ignite/IgniteCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index 8a26bdd..e8c0816 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -49,11 +49,6 @@ import java.util.concurrent.locks.*; * data partitioning and mapping keys to grid nodes responsible for caching those keys. * </li> * <li> - * Method {@link #dataStructures()} provides {@link org.apache.ignite.cache.datastructures.CacheDataStructures} service for - * creating and working with distributed concurrent data structures, such as - * {@link IgniteAtomicLong}, {@link IgniteAtomicReference}, {@link IgniteQueue}, etc. - * </li> - * <li> * Methods like {@code 'tx{Un}Synchronize(..)'} witch allow to get notifications for transaction state changes. * This feature is very useful when integrating cache transactions with some other in-house transactions. * </li> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/main/java/org/apache/ignite/cache/GridCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCache.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCache.java index 797ac3f..e42fd4f 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/GridCache.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCache.java @@ -45,11 +45,6 @@ import java.util.*; * data partitioning and mapping keys to grid nodes responsible for caching those keys. * </li> * <li> - * Method {@link #dataStructures()} provides {@link org.apache.ignite.cache.datastructures.CacheDataStructures} service for - * creating and working with distributed concurrent data structures, such as - * {@link org.apache.ignite.IgniteAtomicLong}, {@link org.apache.ignite.IgniteAtomicReference}, {@link org.apache.ignite.IgniteQueue}, etc. - * </li> - * <li> * Methods like {@code 'tx{Un}Synchronize(..)'} witch allow to get notifications for transaction state changes. * This feature is very useful when integrating cache transactions with some other in-house transactions. * </li> @@ -103,14 +98,6 @@ public interface GridCache<K, V> extends CacheProjection<K, V> { public CacheAffinity<K> affinity(); /** - * Gets data structures service to provide a gateway for creating various - * distributed data structures similar in APIs to {@code java.util.concurrent} package. - * - * @return Cache data structures service. - */ - public CacheDataStructures dataStructures(); - - /** * Gets metrics (statistics) for this cache. * * @return Cache metrics. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/main/java/org/apache/ignite/cache/datastructures/CacheDataStructures.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/datastructures/CacheDataStructures.java b/modules/core/src/main/java/org/apache/ignite/cache/datastructures/CacheDataStructures.java deleted file mode 100644 index 2f0e251..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/datastructures/CacheDataStructures.java +++ /dev/null @@ -1,220 +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.cache.datastructures; - -import org.apache.ignite.*; -import org.jetbrains.annotations.*; - -/** - * Facade for working with distributed cache data structures. All cache data structures are similar - * in APIs to {@code 'java.util.concurrent'} package, but all operations on them are grid-aware. - * For example, if you increment {@link IgniteAtomicLong} on one node, another node will - * know about the change. Or if you add an element to {@link IgniteQueue} on one node, - * you can poll it on another node. - * <p> - * You can get data structures facade by calling {@link org.apache.ignite.cache.GridCache#dataStructures()} method. - */ -public interface CacheDataStructures { - /** - * Will get an atomic sequence from cache and create one if it has not been created yet and {@code create} flag - * is {@code true}. - * - * @param name Sequence name. - * @param initVal Initial value for sequence. If sequence already cached, {@code initVal} will be ignored. - * @param create Boolean flag indicating whether data structure should be created if does not exist. - * @return Sequence for the given name. - * @throws IgniteCheckedException If sequence could not be fetched or created. - */ - @Nullable public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create) - throws IgniteCheckedException; - - /** - * Remove sequence from cache. - * - * @param name Sequence name. - * @return {@code True} if sequence has been removed, {@code false} otherwise. - * @throws IgniteCheckedException If remove failed. - */ - public boolean removeAtomicSequence(String name) throws IgniteCheckedException; - - /** - * Will get a atomic long from cache and create one if it has not been created yet and {@code create} flag - * is {@code true}. - * - * @param name Name of atomic long. - * @param initVal Initial value for atomic long. If atomic long already cached, {@code initVal} - * will be ignored. - * @param create Boolean flag indicating whether data structure should be created if does not exist. - * @return Atomic long. - * @throws IgniteCheckedException If atomic long could not be fetched or created. - */ - @Nullable public IgniteAtomicLong atomicLong(String name, long initVal, boolean create) throws IgniteCheckedException; - - /** - * Remove atomic long from cache. - * - * @param name Name of atomic long. - * @return {@code True} if atomic long has been removed, {@code false} otherwise. - * @throws IgniteCheckedException If removing failed. - */ - public boolean removeAtomicLong(String name) throws IgniteCheckedException; - - /** - * Will get a named queue from cache and create one if it has not been created yet and {@code create} flag - * is {@code true}. - * If queue is present in cache already, queue properties will not be changed. Use - * collocation for {@link org.apache.ignite.cache.CacheMode#PARTITIONED} caches if you have lots of relatively - * small queues as it will make fetching, querying, and iteration a lot faster. If you have - * few very large queues, then you should consider turning off collocation as they simply - * may not fit in a single node's memory. However note that in this case - * to get a single element off the queue all nodes may have to be queried. - * - * @param name Name of queue. - * @param cap Capacity of queue, {@code 0} for unbounded queue. - * @param collocated If {@code true} then all items within the same queue will be collocated on the same node. - * Otherwise elements of the same queue maybe be cached on different nodes. If you have lots of relatively - * small queues, then you should use collocation. If you have few large queues, then you should turn off - * collocation. This parameter works only for {@link org.apache.ignite.cache.CacheMode#PARTITIONED} cache. - * @param create Boolean flag indicating whether data structure should be created if does not exist. - * @return Queue with given properties. - * @throws IgniteCheckedException If remove failed. - */ - @Nullable public <T> IgniteQueue<T> queue(String name, int cap, boolean collocated, - boolean create) throws IgniteCheckedException; - - /** - * Remove queue from cache. Internally one transaction will be created for all elements - * in the queue. If you anticipate that queue may be large, then it's better to use - * {@link #removeQueue(String, int)} which allows to specify batch size. In that case - * transaction will be split into multiple transactions which will have upto {@code batchSize} - * elements in it. - * - * @param name Name queue. - * @return {@code True} if queue has been removed and false if it's not cached. - * @throws IgniteCheckedException If remove failed. - */ - public boolean removeQueue(String name) throws IgniteCheckedException; - - /** - * Remove queue from cache. Internally multiple transactions will be created - * with no more than {@code batchSize} elements in them. For larger queues, this - * method is preferrable over {@link #removeQueue(String)} which will create only - * one transaction for the whole operation. - * - * @param name Name queue. - * @param batchSize Batch size. - * @return {@code True} if queue has been removed and false if it's not cached. - * @throws IgniteCheckedException If remove failed. - */ - public boolean removeQueue(String name, int batchSize) throws IgniteCheckedException; - - /** - * Will get a named set from cache and create one if it has not been created yet and {@code create} flag - * is {@code true}. - * - * @param name Set name. - * @param collocated If {@code true} then all items within the same set will be collocated on the same node. - * Otherwise elements of the same set maybe be cached on different nodes. This parameter works only - * for {@link org.apache.ignite.cache.CacheMode#PARTITIONED} cache. - * @param create Flag indicating whether set should be created if does not exist. - * @return Set with given properties. - * @throws IgniteCheckedException If failed. - */ - @Nullable public <T> IgniteSet<T> set(String name, boolean collocated, boolean create) throws IgniteCheckedException; - - /** - * Removes set from cache. - * - * @param name Set name. - * @return {@code True} if set has been removed and false if it's not cached. - * @throws IgniteCheckedException If failed. - */ - public boolean removeSet(String name) throws IgniteCheckedException; - - /** - * Will get a atomic reference from cache and create one if it has not been created yet and {@code create} flag - * is {@code true}. - * - * @param name Atomic reference name. - * @param initVal Initial value for atomic reference. If atomic reference already cached, - * {@code initVal} will be ignored. - * @param create Boolean flag indicating whether data structure should be created if does not exist. - * @return Atomic reference for the given name. - * @throws IgniteCheckedException If atomic reference could not be fetched or created. - */ - @Nullable public <T> IgniteAtomicReference<T> atomicReference(String name, @Nullable T initVal, boolean create) - throws IgniteCheckedException; - - /** - * Remove atomic reference from cache. - * - * @param name Atomic reference name. - * @return {@code True} if atomic reference has been removed, {@code false} otherwise. - * @throws IgniteCheckedException If remove failed. - */ - public boolean removeAtomicReference(String name) throws IgniteCheckedException; - - /** - * Will get a atomic stamped from cache and create one if it has not been created yet and {@code create} flag - * is {@code true}. - * - * @param name Atomic stamped name. - * @param initVal Initial value for atomic stamped. If atomic stamped already cached, - * {@code initVal} will be ignored. - * @param initStamp Initial stamp for atomic stamped. If atomic stamped already cached, - * {@code initStamp} will be ignored. - * @param create Boolean flag indicating whether data structure should be created if does not exist. - * @return Atomic stamped for the given name. - * @throws IgniteCheckedException If atomic stamped could not be fetched or created. - */ - @Nullable public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, @Nullable T initVal, - @Nullable S initStamp, boolean create) throws IgniteCheckedException; - - /** - * Remove atomic stamped from cache. - * - * @param name Atomic stamped name. - * @return {@code True} if atomic stamped has been removed, {@code false} otherwise. - * @throws IgniteCheckedException If remove failed. - */ - public boolean removeAtomicStamped(String name) throws IgniteCheckedException; - - /** - * Gets or creates count down latch. If count down latch is not found in cache and {@code create} flag - * is {@code true}, it is created using provided name and count parameter. - * - * @param name Name of the latch. - * @param cnt Count for new latch creation. - * @param autoDel {@code True} to automatically delete latch from cache - * when its count reaches zero. - * @param create Boolean flag indicating whether data structure should be created if does not exist. - * @return Count down latch for the given name. - * @throws IgniteCheckedException If operation failed. - */ - @Nullable public IgniteCountDownLatch countDownLatch(String name, int cnt, boolean autoDel, boolean create) - throws IgniteCheckedException; - - /** - * Removes count down latch from cache. - * - * @param name Name of the latch. - * @return Count down latch for the given name. - * @throws IgniteCheckedException If operation failed. - */ - public boolean removeCountDownLatch(String name) throws IgniteCheckedException; -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/main/java/org/apache/ignite/configuration/IgniteAtomicConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteAtomicConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteAtomicConfiguration.java index 893f8f8..3f27927 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteAtomicConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteAtomicConfiguration.java @@ -45,28 +45,28 @@ public class IgniteAtomicConfiguration { private int backups = DFLT_BACKUPS; /** - * @return + * @return Number of backup nodes. */ public int getBackups() { return backups; } /** - * @param backups + * @param backups Number of backup nodes. */ public void setBackups(int backups) { this.backups = backups; } /** - * @return + * @return Cache mode. */ public CacheMode getCacheMode() { return cacheMode; } /** - * @param cacheMode + * @param cacheMode Cache mode. */ public void setCacheMode(CacheMode cacheMode) { this.cacheMode = cacheMode; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/main/java/org/apache/ignite/configuration/IgniteCollectionConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteCollectionConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteCollectionConfiguration.java index cfd3de3..04bf5c0 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteCollectionConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteCollectionConfiguration.java @@ -43,6 +43,12 @@ public class IgniteCollectionConfiguration { /** Default distribution mode. */ public static final CacheDistributionMode DFLT_DISTRIBUTION_MODE = PARTITIONED_ONLY; + /** Default off-heap storage size is {@code -1} which means that off-heap storage is disabled. */ + public static final long DFLT_OFFHEAP_MEMORY = -1; + + /** Off-heap memory size. */ + private long offHeapMaxMem = DFLT_OFFHEAP_MEMORY; + /** Cache mode. */ private CacheMode cacheMode = DFLT_CACHE_MODE; @@ -146,4 +152,18 @@ public class IgniteCollectionConfiguration { public void setDistributionMode(CacheDistributionMode distro) { this.distro = distro; } + + /** + * @param offHeapMaxMem Maximum memory in bytes available to off-heap memory space. + */ + public void setOffHeapMaxMemory(long offHeapMaxMem) { + this.offHeapMaxMem = offHeapMaxMem; + } + + /** + * @return Maximum memory in bytes available to off-heap memory space. + */ + public long getOffHeapMaxMemory() { + return offHeapMaxMem; + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 978a291..b73b0d1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -358,12 +358,6 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, } /** {@inheritDoc} */ - @Override public CacheDataStructures dataStructures() { - // TODO IGNITE-6. - return null; - } - - /** {@inheritDoc} */ @SuppressWarnings({"unchecked", "RedundantCast"}) @Override public <K1, V1> GridCache<K1, V1> cache() { return (GridCache<K1, V1>)this; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index 8bef0ce..14b2673 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -146,11 +146,6 @@ public class GridCacheProxyImpl<K, V> implements GridCacheProxy<K, V>, Externali } /** {@inheritDoc} */ - @Override public CacheDataStructures dataStructures() { - return null; - } - - /** {@inheritDoc} */ @Override public CacheConfiguration configuration() { return cache.configuration(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/CacheDataStructuresProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/CacheDataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/CacheDataStructuresProcessor.java index 644c07c..b52036f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/CacheDataStructuresProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/CacheDataStructuresProcessor.java @@ -165,8 +165,7 @@ public final class CacheDataStructuresProcessor extends GridProcessorAdapter { return val; return CU.outTx(new Callable<IgniteAtomicSequence>() { - @Override - public IgniteAtomicSequence call() throws Exception { + @Override public IgniteAtomicSequence call() throws Exception { try (IgniteTx tx = CU.txStartInternal(atomicsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) { GridCacheAtomicSequenceValue seqVal = cast(dsView.get(key), GridCacheAtomicSequenceValue.class); @@ -297,11 +296,9 @@ public final class CacheDataStructuresProcessor extends GridProcessorAdapter { return atomicLong; return CU.outTx(new Callable<IgniteAtomicLong>() { - @Override - public IgniteAtomicLong call() throws Exception { + @Override public IgniteAtomicLong call() throws Exception { try (IgniteTx tx = CU.txStartInternal(atomicsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) { - GridCacheAtomicLongValue val = cast(dsView.get(key), - GridCacheAtomicLongValue.class); + GridCacheAtomicLongValue val = cast(dsView.get(key), GridCacheAtomicLongValue.class); // Check that atomic long hasn't been created in other thread yet. GridCacheAtomicLongEx a = cast(dsMap.get(key), GridCacheAtomicLongEx.class); @@ -351,10 +348,9 @@ public final class CacheDataStructuresProcessor extends GridProcessorAdapter { * Removes atomic long from cache. * * @param name Atomic long name. - * @return Method returns {@code true} if atomic long has been removed and {@code false} if it's not cached. * @throws IgniteCheckedException If removing failed. */ - public final boolean removeAtomicLong(String name) throws IgniteCheckedException { + public final void removeAtomicLong(String name) throws IgniteCheckedException { assert name != null; assert atomicsCacheCtx != null; @@ -363,7 +359,7 @@ public final class CacheDataStructuresProcessor extends GridProcessorAdapter { try { GridCacheInternal key = new GridCacheInternalKeyImpl(name); - return removeInternal(key, GridCacheAtomicLongValue.class); + removeInternal(key, GridCacheAtomicLongValue.class); } catch (Exception e) { throw new IgniteCheckedException("Failed to remove atomic long by name: " + name, e); @@ -459,10 +455,9 @@ public final class CacheDataStructuresProcessor extends GridProcessorAdapter { * Removes atomic reference from cache. * * @param name Atomic reference name. - * @return Method returns {@code true} if atomic reference has been removed and {@code false} if it's not cached. * @throws IgniteCheckedException If removing failed. */ - public final boolean removeAtomicReference(String name) throws IgniteCheckedException { + public final void removeAtomicReference(String name) throws IgniteCheckedException { assert name != null; assert atomicsCacheCtx != null; @@ -471,7 +466,10 @@ public final class CacheDataStructuresProcessor extends GridProcessorAdapter { try { GridCacheInternal key = new GridCacheInternalKeyImpl(name); - return removeInternal(key, GridCacheAtomicReferenceValue.class); + removeInternal(key, GridCacheAtomicReferenceValue.class); + } + catch (Exception e) { + throw new IgniteCheckedException("Failed to remove atomic reference by name: " + name, e); } finally { atomicsCacheCtx.gate().leave(); @@ -563,10 +561,9 @@ public final class CacheDataStructuresProcessor extends GridProcessorAdapter { * Removes atomic stamped from cache. * * @param name Atomic stamped name. - * @return Method returns {@code true} if atomic stamped has been removed and {@code false} if it's not cached. * @throws IgniteCheckedException If removing failed. */ - public final boolean removeAtomicStamped(String name) throws IgniteCheckedException { + public final void removeAtomicStamped(String name) throws IgniteCheckedException { assert name != null; assert atomicsCacheCtx != null; @@ -575,7 +572,7 @@ public final class CacheDataStructuresProcessor extends GridProcessorAdapter { try { GridCacheInternal key = new GridCacheInternalKeyImpl(name); - return removeInternal(key, GridCacheAtomicStampedValue.class); + removeInternal(key, GridCacheAtomicStampedValue.class); } catch (Exception e) { throw new IgniteCheckedException("Failed to remove atomic stamped by name: " + name, e); @@ -707,49 +704,46 @@ public final class CacheDataStructuresProcessor extends GridProcessorAdapter { * Removes count down latch from cache. * * @param name Name of the latch. - * @return Count down latch for the given name. * @throws IgniteCheckedException If operation failed. */ - public boolean removeCountDownLatch(final String name) throws IgniteCheckedException { + public void removeCountDownLatch(final String name) throws IgniteCheckedException { assert name != null; assert atomicsCacheCtx != null; atomicsCacheCtx.gate().enter(); try { - return CU.outTx( - new Callable<Boolean>() { - @Override public Boolean call() throws Exception { - GridCacheInternal key = new GridCacheInternalKeyImpl(name); - - try (IgniteTx tx = CU.txStartInternal(atomicsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) { - // Check correctness type of removable object. - GridCacheCountDownLatchValue val = - cast(dsView.get(key), GridCacheCountDownLatchValue.class); - - if (val != null) { - if (val.get() > 0) { - throw new IgniteCheckedException("Failed to remove count down latch " + - "with non-zero count: " + val.get()); - } + CU.outTx(new Callable<Boolean>() { + @Override public Boolean call() throws Exception { + GridCacheInternal key = new GridCacheInternalKeyImpl(name); - dsView.removex(key); + try (IgniteTx tx = CU.txStartInternal(atomicsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) { + // Check correctness type of removable object. + GridCacheCountDownLatchValue val = + cast(dsView.get(key), GridCacheCountDownLatchValue.class); - tx.commit(); + if (val != null) { + if (val.get() > 0) { + throw new IgniteCheckedException("Failed to remove count down latch " + + "with non-zero count: " + val.get()); } - else - tx.setRollbackOnly(); - return val != null; - } - catch (Error | Exception e) { - U.error(log, "Failed to remove data structure: " + key, e); + dsView.removex(key); - throw e; + tx.commit(); } + else + tx.setRollbackOnly(); + + return val != null; } - }, - atomicsCacheCtx); + catch (Error | Exception e) { + U.error(log, "Failed to remove data structure: " + key, e); + + throw e; + } + } + }, atomicsCacheCtx); } catch (Exception e) { throw new IgniteCheckedException("Failed to remove count down latch by name: " + name, e); @@ -969,6 +963,19 @@ public final class CacheDataStructuresProcessor extends GridProcessorAdapter { } /** + * @param info Data structure information. + * @throws IgniteException If validation failed. + */ + private void updateUtilityCache(DataStructureInfo info) throws IgniteException { + validateDataStructure(info); + + IgniteException err = utilityCache.invoke(DATA_STRUCTURES_KEY, new AddAtomicProcessor(info)); + + if (err != null) + throw err; + } + + /** * @throws IgniteException If atomics configuration is not provided. */ private void checkAtomicsConfiguration() throws IgniteException { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheDataStructuresProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheDataStructuresProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheDataStructuresProxy.java deleted file mode 100644 index 82ec648..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheDataStructuresProxy.java +++ /dev/null @@ -1,267 +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.processors.datastructures; - -import org.apache.ignite.*; -import org.apache.ignite.cache.datastructures.*; -import org.apache.ignite.internal.processors.cache.*; -import org.jetbrains.annotations.*; - -import java.io.*; - -/** - * Data structures proxy object. - */ -public class GridCacheDataStructuresProxy<K, V> implements CacheDataStructures, Externalizable { - /** */ - private static final long serialVersionUID = 0L; - - /** Delegate object. */ - private CacheDataStructures delegate; - - /** Cache gateway. */ - private GridCacheGateway<K, V> gate; - - /** Context. */ - private GridCacheContext<K, V> cctx; - - /** - * Required by {@link Externalizable}. - */ - public GridCacheDataStructuresProxy() { - // No-op. - } - - /** - * @param cctx Cache context. - * @param delegate Delegate object. - */ - public GridCacheDataStructuresProxy(GridCacheContext<K, V> cctx, CacheDataStructures delegate) { - this.delegate = delegate; - this.cctx = cctx; - - gate = cctx.gate(); - } - - /** {@inheritDoc} */ - @Override public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create) - throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.atomicSequence(name, initVal, create); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public boolean removeAtomicSequence(String name) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.removeAtomicSequence(name); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public IgniteAtomicLong atomicLong(String name, long initVal, boolean create) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.atomicLong(name, initVal, create); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public boolean removeAtomicLong(String name) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.removeAtomicLong(name); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public <T> IgniteAtomicReference<T> atomicReference(String name, T initVal, boolean create) - throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.atomicReference(name, initVal, create); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public boolean removeAtomicReference(String name) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.removeAtomicReference(name); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, T initVal, S initStamp, - boolean create) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.atomicStamped(name, initVal, initStamp, create); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public boolean removeAtomicStamped(String name) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.removeAtomicStamped(name); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public <T> IgniteQueue<T> queue(String name, int cap, boolean collocated, boolean create) - throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.queue(name, cap, collocated, create); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public boolean removeQueue(String name) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.removeQueue(name, 0); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public boolean removeQueue(String name, int batchSize) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.removeQueue(name, batchSize); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Nullable @Override public <T> IgniteSet<T> set(String name, boolean collocated, boolean create) - throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.set(name, collocated, create); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public boolean removeSet(String name) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.removeSet(name); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Nullable @Override public IgniteCountDownLatch countDownLatch(String name, int cnt, boolean autoDel, - boolean create) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.countDownLatch(name, cnt, autoDel, create); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public boolean removeCountDownLatch(String name) throws IgniteCheckedException { - GridCacheProjectionImpl<K, V> old = gate.enter(null); - - try { - return delegate.removeCountDownLatch(name); - } - finally { - gate.leave(old); - } - } - - /** {@inheritDoc} */ - @Override public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(cctx); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - cctx = (GridCacheContext<K, V>)in.readObject(); - } - - /** - * Reconstructs object on unmarshalling. - * - * @return Reconstructed object. - * @throws ObjectStreamException Thrown in case of unmarshalling error. - */ - private Object readResolve() throws ObjectStreamException { - return cctx.grid().cache(cctx.cache().name()).dataStructures(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/datastructures/DatastructuresCommandHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/datastructures/DatastructuresCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/datastructures/DatastructuresCommandHandler.java index b4cb672..0c60466 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/datastructures/DatastructuresCommandHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/datastructures/DatastructuresCommandHandler.java @@ -41,6 +41,7 @@ public class DataStructuresCommandHandler extends GridRestCommandHandlerAdapter CACHE_INCREMENT, CACHE_DECREMENT ); + /** * @param ctx Context. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicLongApiAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicLongApiAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicLongApiAbstractSelfTest.java index 8eb34a7..d7603eb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicLongApiAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicLongApiAbstractSelfTest.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache.datastructures; import org.apache.ignite.*; import org.apache.ignite.cache.*; +import org.apache.ignite.cache.datastructures.*; import org.apache.ignite.configuration.*; import org.apache.ignite.transactions.*; @@ -91,7 +92,7 @@ public abstract class GridCacheAtomicLongApiAbstractSelfTest extends IgniteAtomi fail(); } - catch (IgniteCheckedException e) { + catch (DataStructureRemovedException e) { info("Caught expected exception: " + e.getMessage()); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java index e46222f..8eea62c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache.datastructures; import org.apache.ignite.*; +import org.apache.ignite.cache.datastructures.*; import java.util.*; @@ -63,7 +64,7 @@ public abstract class GridCacheAtomicReferenceApiSelfAbstractTest extends Ignite fail(); } - catch (IgniteCheckedException e) { + catch (DataStructureRemovedException e) { info("Caught expected exception: " + e.getMessage()); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicStampedApiSelfAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicStampedApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicStampedApiSelfAbstractTest.java index 31e4c0d..0651a13 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicStampedApiSelfAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicStampedApiSelfAbstractTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache.datastructures; import org.apache.ignite.*; +import org.apache.ignite.cache.datastructures.*; import java.util.*; @@ -63,7 +64,7 @@ public abstract class GridCacheAtomicStampedApiSelfAbstractTest extends IgniteAt fail(); } - catch (IgniteCheckedException e) { + catch (DataStructureRemovedException e) { info("Caught expected exception: " + e.getMessage()); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85a0f375/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceApiSelfAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceApiSelfAbstractTest.java index 0b7a0d2..f999894 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceApiSelfAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceApiSelfAbstractTest.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache.datastructures; import org.apache.ignite.*; import org.apache.ignite.cache.*; +import org.apache.ignite.cache.datastructures.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; @@ -346,7 +347,7 @@ public abstract class GridCacheSequenceApiSelfAbstractTest extends IgniteAtomics fail("Exception expected."); } - catch (IgniteCheckedException e) { + catch (DataStructureRemovedException e) { info("Caught expected exception: " + e); } }