You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/06/03 00:56:03 UTC

[GitHub] [geode] agingade commented on a change in pull request #5191: GEODE-8198: Revise docs description of putAll()

agingade commented on a change in pull request #5191:
URL: https://github.com/apache/geode/pull/5191#discussion_r434173604



##########
File path: geode-docs/basic_config/data_entries_custom_classes/managing_data_entries.html.md.erb
##########
@@ -60,39 +60,91 @@ You can also use the `gfsh put` command to add entries to a region, and the `get
 
 If you want only to create the entry (with a null value and with method failure if the entry already exists), use `Region.create` instead.
 
-## <a id="managing_data_entries__section_7578349EA26A4621B732FE851D71A84F" class="no-quick-link"></a>Batch Operations (getAll, putAll, removeAll)
+## <a id="getAll_method" class="no-quick-link"></a>The getAll Operation
 
-<%=vars.product_name%> provides three APIs to perform batch operations on multiple region entries:
+The batch operation `Region.getAll`
+takes a collection of keys and returns a `Map` of key-value pairs for
+the provided keys. If a given key does not exist in the region, then that key's value in the returned map will be null.
 
--   `Region.getAll`
--   `Region.putAll`
--   `Region.removeAll`
+## <a id="putAll_method" class="no-quick-link"></a>The putAll Operation
 
-The `getAll` method takes a collection of keys and returns a `Map` of values for the provided keys. If a given key does not exist in the region, then that key's value in the returned map will be null.
+The batch operation `Region.putAll`
+takes a `Map` of key-value pairs, puts them into the cache,
+and distributes them in a single operation.
 
-The `putAll` method takes a `Map` of key-value pairs and puts them into the cache and distributes them in a single operation.
+For partitioned regions,
+multiple keys are sent as a single message to each primary bucket
+and then distributed to the secondary buckets.
+For replicated regions, the keys are sent to one server.
+After applying all entry updates to that server,
+that server distributes the event to the other servers that host the region.
 
-**Example:**
+The design of a client application within a client-server design pattern

Review comment:
       The partial update can happen with non-client pattern (calling putAll in embedded application or in function execution)...In that case the application won't see ServerConnectivity or ServerOperation exception, do we want to call that out... 

##########
File path: geode-docs/basic_config/data_entries_custom_classes/managing_data_entries.html.md.erb
##########
@@ -60,39 +60,91 @@ You can also use the `gfsh put` command to add entries to a region, and the `get
 
 If you want only to create the entry (with a null value and with method failure if the entry already exists), use `Region.create` instead.
 
-## <a id="managing_data_entries__section_7578349EA26A4621B732FE851D71A84F" class="no-quick-link"></a>Batch Operations (getAll, putAll, removeAll)
+## <a id="getAll_method" class="no-quick-link"></a>The getAll Operation
 
-<%=vars.product_name%> provides three APIs to perform batch operations on multiple region entries:
+The batch operation `Region.getAll`
+takes a collection of keys and returns a `Map` of key-value pairs for
+the provided keys. If a given key does not exist in the region, then that key's value in the returned map will be null.
 
--   `Region.getAll`
--   `Region.putAll`
--   `Region.removeAll`
+## <a id="putAll_method" class="no-quick-link"></a>The putAll Operation
 
-The `getAll` method takes a collection of keys and returns a `Map` of values for the provided keys. If a given key does not exist in the region, then that key's value in the returned map will be null.
+The batch operation `Region.putAll`
+takes a `Map` of key-value pairs, puts them into the cache,
+and distributes them in a single operation.
 
-The `putAll` method takes a `Map` of key-value pairs and puts them into the cache and distributes them in a single operation.
+For partitioned regions,
+multiple keys are sent as a single message to each primary bucket

Review comment:
       Its key-value(s) (or entries).

##########
File path: geode-docs/basic_config/data_entries_custom_classes/managing_data_entries.html.md.erb
##########
@@ -60,39 +60,91 @@ You can also use the `gfsh put` command to add entries to a region, and the `get
 
 If you want only to create the entry (with a null value and with method failure if the entry already exists), use `Region.create` instead.
 
-## <a id="managing_data_entries__section_7578349EA26A4621B732FE851D71A84F" class="no-quick-link"></a>Batch Operations (getAll, putAll, removeAll)
+## <a id="getAll_method" class="no-quick-link"></a>The getAll Operation
 
-<%=vars.product_name%> provides three APIs to perform batch operations on multiple region entries:
+The batch operation `Region.getAll`
+takes a collection of keys and returns a `Map` of key-value pairs for
+the provided keys. If a given key does not exist in the region, then that key's value in the returned map will be null.
 
--   `Region.getAll`
--   `Region.putAll`
--   `Region.removeAll`
+## <a id="putAll_method" class="no-quick-link"></a>The putAll Operation
 
-The `getAll` method takes a collection of keys and returns a `Map` of values for the provided keys. If a given key does not exist in the region, then that key's value in the returned map will be null.
+The batch operation `Region.putAll`
+takes a `Map` of key-value pairs, puts them into the cache,
+and distributes them in a single operation.
 
-The `putAll` method takes a `Map` of key-value pairs and puts them into the cache and distributes them in a single operation.
+For partitioned regions,
+multiple keys are sent as a single message to each primary bucket
+and then distributed to the secondary buckets.
+For replicated regions, the keys are sent to one server.
+After applying all entry updates to that server,
+that server distributes the event to the other servers that host the region.
 
-**Example:**
+The design of a client application within a client-server design pattern
+faces the possibility that a partial operation can occur.
+Some, all, or none of the specified entries may be completed with `putAll`.
+If either `ServerOperationException` or `ServerConnectivityException` is
+thrown,
+it can indicate an incomplete operation.
 
 ``` pre
-void putAll(String command) throws CacheException 
-{ 
-// Get Entry keys and values into Strings key1, ... keyN and value1, ... valueN 
-  Map map = new LinkedHashMap(); 
-  map.put(key1, value1)); 
-  ...
-  map.put(keyN, valueN));
-  this.currRegion.putAll(map); 
+int retry = 0;
+RuntimeException rte = null;
+while (retry < 3) {
+  try {
+    region.putAll(map);
+  } catch (ServerOperationException e) {
+    if (e.getCause() instanceof TimeoutException
+        || e.getCause() instanceof LowMemoryException) {
+      // Retry due to transient error.
+      retry++;
+    } else {
+      rte = e;
+      break;
+    }
+  } catch (ServerConnectivityException e) {
+    // Retry due to transient error.
+    retry++;
+  }
+}
+
+if (retry == 3) {
+  System.out.println("3 putAll operations tried, and all failed.");
+} else if (rte != null) {

Review comment:
       To make the error handling consistent, I modified the sample code. 
   
    public void testPutAll() throws Exception {
       Throwable throwable = null;
       Map map = new LinkedHashMap();
       Region region;
   
       // Retry in case of transient exception.
       for (int retry = 0; retry < 3; retry++) {
         throwable = null;
         try {
           region.putAll(map);
         } catch (ServerOperationException e) {
           throwable = e.getCause();
           if (!(e.getCause() instanceof TimeoutException || e.getCause() instanceof LowMemoryException)) {
             // Non transient exception. Skip retry.
             break;
           }
         } catch (ServerConnectivityException e) {
           throwable = e;
         }
       }
   
       if (throwable != null) {
         // Take appropriate action, like throwing the exception or logging the message.
         System.out.println("putAll failed due to " + throwable);
         throw new Exception(throwable);
       }
     }
   
   I have shown the sample code to Gester and he is fine with this new code.

##########
File path: geode-docs/basic_config/data_entries_custom_classes/managing_data_entries.html.md.erb
##########
@@ -60,39 +60,91 @@ You can also use the `gfsh put` command to add entries to a region, and the `get
 
 If you want only to create the entry (with a null value and with method failure if the entry already exists), use `Region.create` instead.
 
-## <a id="managing_data_entries__section_7578349EA26A4621B732FE851D71A84F" class="no-quick-link"></a>Batch Operations (getAll, putAll, removeAll)
+## <a id="getAll_method" class="no-quick-link"></a>The getAll Operation
 
-<%=vars.product_name%> provides three APIs to perform batch operations on multiple region entries:
+The batch operation `Region.getAll`
+takes a collection of keys and returns a `Map` of key-value pairs for
+the provided keys. If a given key does not exist in the region, then that key's value in the returned map will be null.
 
--   `Region.getAll`
--   `Region.putAll`
--   `Region.removeAll`
+## <a id="putAll_method" class="no-quick-link"></a>The putAll Operation
 
-The `getAll` method takes a collection of keys and returns a `Map` of values for the provided keys. If a given key does not exist in the region, then that key's value in the returned map will be null.
+The batch operation `Region.putAll`
+takes a `Map` of key-value pairs, puts them into the cache,
+and distributes them in a single operation.
 
-The `putAll` method takes a `Map` of key-value pairs and puts them into the cache and distributes them in a single operation.
+For partitioned regions,
+multiple keys are sent as a single message to each primary bucket
+and then distributed to the secondary buckets.
+For replicated regions, the keys are sent to one server.

Review comment:
       Its key-value(s) (or entries).

##########
File path: geode-docs/basic_config/data_entries_custom_classes/managing_data_entries.html.md.erb
##########
@@ -60,39 +60,91 @@ You can also use the `gfsh put` command to add entries to a region, and the `get
 
 If you want only to create the entry (with a null value and with method failure if the entry already exists), use `Region.create` instead.
 
-## <a id="managing_data_entries__section_7578349EA26A4621B732FE851D71A84F" class="no-quick-link"></a>Batch Operations (getAll, putAll, removeAll)
+## <a id="getAll_method" class="no-quick-link"></a>The getAll Operation
 
-<%=vars.product_name%> provides three APIs to perform batch operations on multiple region entries:
+The batch operation `Region.getAll`
+takes a collection of keys and returns a `Map` of key-value pairs for
+the provided keys. If a given key does not exist in the region, then that key's value in the returned map will be null.
 
--   `Region.getAll`
--   `Region.putAll`
--   `Region.removeAll`
+## <a id="putAll_method" class="no-quick-link"></a>The putAll Operation
 
-The `getAll` method takes a collection of keys and returns a `Map` of values for the provided keys. If a given key does not exist in the region, then that key's value in the returned map will be null.
+The batch operation `Region.putAll`
+takes a `Map` of key-value pairs, puts them into the cache,
+and distributes them in a single operation.
 
-The `putAll` method takes a `Map` of key-value pairs and puts them into the cache and distributes them in a single operation.
+For partitioned regions,
+multiple keys are sent as a single message to each primary bucket
+and then distributed to the secondary buckets.
+For replicated regions, the keys are sent to one server.
+After applying all entry updates to that server,

Review comment:
       entry - entries




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org