ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [17/40] incubator-ignite git commit: # ignite-370: allowOverwrite warning in false case + add java-doc
Date Thu, 12 Mar 2015 13:08:10 GMT
# ignite-370: allowOverwrite warning in false case + add java-doc


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/6f649413
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/6f649413
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/6f649413

Branch: refs/heads/sprint-2
Commit: 6f649413cfd0af1eeddd352df77aa2e2ac77869c
Parents: e0d0584
Author: Artem Shutak <ashutak@gridgain.com>
Authored: Wed Mar 4 19:19:31 2015 +0300
Committer: Artem Shutak <ashutak@gridgain.com>
Committed: Wed Mar 4 19:19:31 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteDataStreamer.java   | 20 ++++++++++++++++++++
 .../datastream/IgniteDataStreamerImpl.java      | 20 ++++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6f649413/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 f5158b4..2e54225 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteDataStreamer.java
@@ -249,6 +249,10 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable
{
      * Note that loader will load data concurrently by multiple internal threads, so the
      * data may get to remote nodes in different order from which it was added to
      * the loader.
+     * <p>
+     * Note: if {@link IgniteDataStreamer#allowOverwrite()} set to {@code false} (by default)
+     * then data streamer will not overwrite existing cache entries for better performance
+     * (to change, set {@link IgniteDataStreamer#allowOverwrite(boolean)} to {@code true})
      *
      * @param key Key.
      * @param val Value or {@code null} if respective entry must be removed from cache.
@@ -257,6 +261,7 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable
{
      * @throws IgniteInterruptedException If thread has been interrupted.
      * @throws IllegalStateException If grid has been concurrently stopped or
      *      {@link #close(boolean)} has already been called on loader.
+     * @see #allowOverwrite()
      */
     public IgniteFuture<?> addData(K key, @Nullable V val) throws IgniteException,
IgniteInterruptedException,
         IllegalStateException;
@@ -268,6 +273,10 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable
{
      * Note that loader will load data concurrently by multiple internal threads, so the
      * data may get to remote nodes in different order from which it was added to
      * the loader.
+     * <p>
+     * Note: if {@link IgniteDataStreamer#allowOverwrite()} set to {@code false} (by default)
+     * then data streamer will not overwrite existing cache entries for better performance
+     * (to change, set {@link IgniteDataStreamer#allowOverwrite(boolean)} to {@code true})
      *
      * @param entry Entry.
      * @return Future fo this operation.
@@ -275,6 +284,7 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable
{
      * @throws IgniteInterruptedException If thread has been interrupted.
      * @throws IllegalStateException If grid has been concurrently stopped or
      *      {@link #close(boolean)} has already been called on loader.
+     * @see #allowOverwrite()      
      */
     public IgniteFuture<?> addData(Map.Entry<K, V> entry) throws IgniteException,
IgniteInterruptedException,
         IllegalStateException;
@@ -286,11 +296,16 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable
{
      * Note that loader will load data concurrently by multiple internal threads, so the
      * data may get to remote nodes in different order from which it was added to
      * the loader.
+     * <p>
+     * Note: if {@link IgniteDataStreamer#allowOverwrite()} set to {@code false} (by default)
+     * then data streamer will not overwrite existing cache entries for better performance

+     * (to change, set {@link IgniteDataStreamer#allowOverwrite(boolean)} to {@code true})
      *
      * @param entries Collection of entries to be loaded.
      * @throws IllegalStateException If grid has been concurrently stopped or
      *      {@link #close(boolean)} has already been called on loader.
      * @return Future for this load operation.
+     * @see #allowOverwrite()
      */
     public IgniteFuture<?> addData(Collection<? extends Map.Entry<K, V>>
entries) throws IllegalStateException;
 
@@ -301,11 +316,16 @@ public interface IgniteDataStreamer<K, V> extends AutoCloseable
{
      * Note that loader will load data concurrently by multiple internal threads, so the
      * data may get to remote nodes in different order from which it was added to
      * the loader.
+     * <p>
+     * Note: if {@link IgniteDataStreamer#allowOverwrite()} set to {@code false} (by default)
+     * then data streamer will not overwrite existing cache entries for better performance

+     * (to change, set {@link IgniteDataStreamer#allowOverwrite(boolean)} to {@code true})
      *
      * @param entries Map to be loaded.
      * @throws IllegalStateException If grid has been concurrently stopped or
      *      {@link #close(boolean)} has already been called on loader.
      * @return Future for this load operation.
+     * @see #allowOverwrite()
      */
     public IgniteFuture<?> addData(Map<K, V> entries) throws IllegalStateException;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6f649413/modules/core/src/main/java/org/apache/ignite/internal/processors/datastream/IgniteDataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastream/IgniteDataStreamerImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastream/IgniteDataStreamerImpl.java
index 9ac3ec8..47f72ee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastream/IgniteDataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastream/IgniteDataStreamerImpl.java
@@ -98,7 +98,7 @@ public class IgniteDataStreamerImpl<K, V> implements IgniteDataStreamer<K,
V>, D
     private ConcurrentMap<UUID, Buffer> bufMappings = new ConcurrentHashMap8<>();
 
     /** Logger. */
-    private IgniteLogger log;
+    private final IgniteLogger log;
 
     /** Discovery listener. */
     private final GridLocalEventListener discoLsnr;
@@ -159,6 +159,9 @@ public class IgniteDataStreamerImpl<K, V> implements IgniteDataStreamer<K,
V>, D
     /** */
     private int maxRemapCnt = DFLT_MAX_REMAP_CNT;
 
+    /** Whether a warning at {@link IgniteDataStreamerImpl#allowOverwrite()} printed */
+    private static boolean isWarningPrinted;
+
     /**
      * @param ctx Grid kernal context.
      * @param cacheName Cache name.
@@ -289,7 +292,20 @@ public class IgniteDataStreamerImpl<K, V> implements IgniteDataStreamer<K,
V>, D
 
     /** {@inheritDoc} */
     @Override public boolean allowOverwrite() {
-        return updater != ISOLATED_UPDATER;
+        boolean allow = updater != ISOLATED_UPDATER;
+        
+        if (!allow && !isWarningPrinted) {
+            synchronized (this) {
+                if (!isWarningPrinted) {
+                    log.warning("Data streamer will not overwrite existing cache entries
for better performance " +
+                        "(to change, set allowOverwrite to true)");
+
+                    isWarningPrinted = true;
+                }
+            }
+        }
+        
+        return allow;
     }
 
     /** {@inheritDoc} */


Mime
View raw message