Repository: incubator-ignite Updated Branches: refs/heads/ignite-45 bd8b1805c -> b57e47ed3
#ignite-525: IgniteDataStreamer should throw CacheException instead of IgniteException Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e6fbedf8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e6fbedf8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e6fbedf8 Branch: refs/heads/ignite-45 Commit: e6fbedf822069a728438d394268803c9b8cc0b31 Parents: dfcfc0e Author: ivasilinets <[email protected]> Authored: Fri Mar 20 15:30:57 2015 +0300 Committer: ivasilinets <[email protected]> Committed: Fri Mar 20 15:30:57 2015 +0300 ---------------------------------------------------------------------- .../org/apache/ignite/IgniteDataStreamer.java | 37 ++++++++++---------- .../datastreamer/DataStreamerImpl.java | 11 +++--- 2 files changed, 25 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6fbedf8/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java b/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java index c6f28bf..72fa6a7 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java @@ -20,6 +20,7 @@ package org.apache.ignite; import org.apache.ignite.lang.*; import org.jetbrains.annotations.*; +import javax.cache.*; import java.io.*; import java.util.*; @@ -117,9 +118,9 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable { * Default is {@code false}. When this flag is set, updates will not be propagated to the cache store. * * @param allowOverwrite Flag value. - * @throws IgniteException If failed. + * @throws CacheException If failed. */ - public void allowOverwrite(boolean allowOverwrite) throws IgniteException; + public void allowOverwrite(boolean allowOverwrite) throws CacheException; /** * Gets flag indicating that write-through behavior should be disabled for data streaming. @@ -237,12 +238,12 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable { * * @param key Key. * @return Future fo this operation. - * @throws IgniteException If failed to map key to node. + * @throws CacheException If failed to map key to node. * @throws IgniteInterruptedException If thread has been interrupted. * @throws IllegalStateException If grid has been concurrently stopped or * {@link #close(boolean)} has already been called on streamer. */ - public IgniteFuture<?> removeData(K key) throws IgniteException, IgniteInterruptedException, IllegalStateException; + public IgniteFuture<?> removeData(K key) throws CacheException, IgniteInterruptedException, IllegalStateException; /** * Adds data for streaming on remote node. This method can be called from multiple @@ -259,13 +260,13 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable { * @param key Key. * @param val Value or {@code null} if respective entry must be removed from cache. * @return Future fo this operation. - * @throws IgniteException If failed to map key to node. + * @throws CacheException If failed to map key to node. * @throws IgniteInterruptedException If thread has been interrupted. * @throws IllegalStateException If grid has been concurrently stopped or * {@link #close(boolean)} has already been called on streamer. * @see #allowOverwrite() */ - public IgniteFuture<?> addData(K key, @Nullable V val) throws IgniteException, IgniteInterruptedException, + public IgniteFuture<?> addData(K key, @Nullable V val) throws CacheException, IgniteInterruptedException, IllegalStateException; /** @@ -282,13 +283,13 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable { * * @param entry Entry. * @return Future fo this operation. - * @throws IgniteException If failed to map key to node. + * @throws CacheException If failed to map key to node. * @throws IgniteInterruptedException If thread has been interrupted. * @throws IllegalStateException If grid has been concurrently stopped or * {@link #close(boolean)} has already been called on streamer. * @see #allowOverwrite() */ - public IgniteFuture<?> addData(Map.Entry<K, V> entry) throws IgniteException, IgniteInterruptedException, + public IgniteFuture<?> addData(Map.Entry<K, V> entry) throws CacheException, IgniteInterruptedException, IllegalStateException; /** @@ -340,34 +341,34 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable { * another thread to complete flush and exit. If you don't want to wait in this case, * use {@link #tryFlush()} method. * - * @throws IgniteException If failed to map key to node. + * @throws CacheException If failed to map key to node. * @throws IgniteInterruptedException If thread has been interrupted. * @throws IllegalStateException If grid has been concurrently stopped or * {@link #close(boolean)} has already been called on streamer. * @see #tryFlush() */ - public void flush() throws IgniteException, IgniteInterruptedException, IllegalStateException; + public void flush() throws CacheException, IgniteInterruptedException, IllegalStateException; /** * Makes an attempt to stream remaining data. This method is mostly similar to {@link #flush}, * with the difference that it won't wait and will exit immediately. * - * @throws IgniteException If failed to map key to node. + * @throws CacheException If failed to map key to node. * @throws IgniteInterruptedException If thread has been interrupted. * @throws IllegalStateException If grid has been concurrently stopped or * {@link #close(boolean)} has already been called on streamer. * @see #flush() */ - public void tryFlush() throws IgniteException, IgniteInterruptedException, IllegalStateException; + public void tryFlush() throws CacheException, IgniteInterruptedException, IllegalStateException; /** * Streams any remaining data and closes this streamer. * * @param cancel {@code True} to cancel ongoing streaming operations. - * @throws IgniteException If failed to map key to node. + * @throws CacheException If failed to map key to node. * @throws IgniteInterruptedException If thread has been interrupted. */ - public void close(boolean cancel) throws IgniteException, IgniteInterruptedException; + public void close(boolean cancel) throws CacheException, IgniteInterruptedException; /** * Closes data streamer. This method is identical to calling {@link #close(boolean) close(false)} method. @@ -375,10 +376,10 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable { * The method is invoked automatically on objects managed by the * {@code try-with-resources} statement. * - * @throws IgniteException If failed to close data streamer. + * @throws CacheException If failed to close data streamer. * @throws IgniteInterruptedException If thread has been interrupted. */ - @Override public void close() throws IgniteException, IgniteInterruptedException; + @Override public void close() throws CacheException, IgniteInterruptedException; /** * Updates cache with batch of entries. Usually it is enough to configure {@link IgniteDataStreamer#allowOverwrite(boolean)} @@ -394,8 +395,8 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable { * * @param cache Cache. * @param entries Collection of entries. - * @throws IgniteException If failed. + * @throws CacheException If failed. */ - public void update(IgniteCache<K, V> cache, Collection<Map.Entry<K, V>> entries) throws IgniteException; + public void update(IgniteCache<K, V> cache, Collection<Map.Entry<K, V>> entries) throws CacheException; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6fbedf8/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java index dd8df35..46da1ef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java @@ -41,6 +41,7 @@ import org.apache.ignite.lang.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; +import javax.cache.*; import java.util.*; import java.util.Map.*; import java.util.concurrent.*; @@ -305,7 +306,7 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed ClusterNode node = F.first(ctx.grid().cluster().forCacheNodes(cacheName).nodes()); if (node == null) - throw new IgniteException("Failed to get node for cache: " + cacheName); + throw new CacheException("Failed to get node for cache: " + cacheName); updater = allow ? DataStreamerCacheUpdaters.<K, V>individual() : ISOLATED_UPDATER; } @@ -744,7 +745,7 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed /** {@inheritDoc} */ @SuppressWarnings("ForLoopReplaceableByForEach") - @Override public void flush() throws IgniteException { + @Override public void flush() throws CacheException { enterBusy(); try { @@ -785,9 +786,9 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed /** * @param cancel {@code True} to close with cancellation. - * @throws IgniteException If failed. + * @throws CacheException If failed. */ - @Override public void close(boolean cancel) throws IgniteException { + @Override public void close(boolean cancel) throws CacheException { try { closeEx(cancel); } @@ -844,7 +845,7 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed } /** {@inheritDoc} */ - @Override public void close() throws IgniteException { + @Override public void close() throws CacheException { close(false); }
