# ignite-sprint-4 added put retries in test

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

Branch: refs/heads/ignite-446
Commit: 8b904516afff7cf49492494660e691a015dfd4f3
Parents: 4fe2a9a
Author: sboikov <sboi...@gridgain.com>
Authored: Wed Apr 15 11:01:48 2015 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Wed Apr 15 11:01:48 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCachePutAllTask.java   | 30 ++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8b904516/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllTask.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllTask.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllTask.java
index 479ff9c..f9d49f6 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllTask.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllTask.java
@@ -91,6 +91,8 @@ class GridCachePutAllTask extends 
ComputeTaskAdapter<Collection<Integer>, Void>
 
                     int cnt = 0;
 
+                    final int RETRIES = 5;
+
                     while (it.hasNext()) {
                         Integer val = it.next();
 
@@ -102,7 +104,19 @@ class GridCachePutAllTask extends 
ComputeTaskAdapter<Collection<Integer>, Void>
                             else
                                 log.info("Putting keys to cache [size=" + 
putMap.size() + ']');
 
-                            cache.putAll(putMap);
+                            for (int i = 0; i < RETRIES; i++) {
+                                try {
+                                    cache.putAll(putMap);
+
+                                    break;
+                                }
+                                catch (IgniteException e) {
+                                    if (i < RETRIES - 1)
+                                        log.info("Put error, will retry: " + 
e);
+                                    else
+                                        throw e;
+                                }
+                            }
 
                             cnt = 0;
 
@@ -118,7 +132,19 @@ class GridCachePutAllTask extends 
ComputeTaskAdapter<Collection<Integer>, Void>
                     else
                         log.info("Putting keys to cache [size=" + 
putMap.size() + ']');
 
-                    cache.putAll(putMap);
+                    for (int i = 0; i < RETRIES; i++) {
+                        try {
+                            cache.putAll(putMap);
+
+                            break;
+                        }
+                        catch (IgniteException e) {
+                            if (i < RETRIES - 1)
+                                log.info("Put error, will retry: " + e);
+                            else
+                                throw e;
+                        }
+                    }
 
                     if (DEBUG_DATA)
                         log.info("Finished putting data: " + data);

Reply via email to