You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2019/06/06 19:26:50 UTC

[geode-native] branch develop updated: GEODE-6546: Geode-Native User Guide - document 'putgetremove' example (#491)

This is an automated email from the ASF dual-hosted git repository.

bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new e309b57  GEODE-6546: Geode-Native User Guide - document 'putgetremove' example (#491)
e309b57 is described below

commit e309b575bd0f1f03e479b682cc6f0b532d3a8672
Author: Dave Barnes <db...@pivotal.io>
AuthorDate: Thu Jun 6 12:26:44 2019 -0700

    GEODE-6546: Geode-Native User Guide - document 'putgetremove' example (#491)
---
 .../source/subnavs/geode-nc-nav.erb                |   3 +
 docs/geode-native-docs/examples.html.md.erb        |  34 ------
 .../getting-started-nc-client.html.md.erb          |  67 ++++++-----
 .../getting-started/put-get-example.html.md.erb    | 129 +++++++++++++++++++++
 docs/geode-native-docs/transactions.html.md.erb    |   2 +-
 5 files changed, 168 insertions(+), 67 deletions(-)

diff --git a/docs/geode-native-book/master_middleman/source/subnavs/geode-nc-nav.erb b/docs/geode-native-book/master_middleman/source/subnavs/geode-nc-nav.erb
index ed5cf39..55d95fa 100644
--- a/docs/geode-native-book/master_middleman/source/subnavs/geode-nc-nav.erb
+++ b/docs/geode-native-book/master_middleman/source/subnavs/geode-nc-nav.erb
@@ -36,6 +36,9 @@ limitations under the License.
         <li>
           <a href="/docs/geode-native/<%=vars.product_version_nodot%>/getting-started/getting-started-nc-client.html#programming_examples">Programming Examples</a>
         </li>
+        <li>
+          <a href="/docs/geode-native/<%=vars.product_version_nodot%>/getting-started/put-get-example.html">Put/Get/Remove Examples</a>
+        </li>
       </ul>
     </li>
     <li class="has_submenu">
diff --git a/docs/geode-native-docs/examples.html.md.erb b/docs/geode-native-docs/examples.html.md.erb
deleted file mode 100644
index 420c390..0000000
--- a/docs/geode-native-docs/examples.html.md.erb
+++ /dev/null
@@ -1,34 +0,0 @@
----
-title:  Programming Examples
----
-
-The <%=vars.product_name%> Client build provides a set of programming examples to help you understand the client API.
-The `examples` directory contains CMake files and a `cpp` subdirectory containing C++ examples.
-The Windows build also includes a `dotnet` subdirectory containing C# examples.
-
-CMake files are located at each level of the directory structure to allow examples to be built individually or in groups.
-
-The directory structure resembles this hierarchy (some entries are omitted for clarity):
-
-    MyProject/
-      cmake/
-      CMakeLists.txt
-      examples/
-        BUILDING.md
-        CMakeLists.txt
-        CMakeLists.txt.in
-        cmake/
-        cpp/
-          BUILDING.md
-          customserializable/
-          customserializer/
-          put-get-remove/
-        dotnet/
-          AuthInitialize/
-          PdxAutoSerializer/
-          PutGetRemove/
-          README.md
-
-See the `BUILDING.md` or `README.md` file in each directory for detailed instructions on building
-and executing the examples, and read the source code to understand how the examples are constructed.
-
diff --git a/docs/geode-native-docs/getting-started/getting-started-nc-client.html.md.erb b/docs/geode-native-docs/getting-started/getting-started-nc-client.html.md.erb
index aeed8f9..647612c 100644
--- a/docs/geode-native-docs/getting-started/getting-started-nc-client.html.md.erb
+++ b/docs/geode-native-docs/getting-started/getting-started-nc-client.html.md.erb
@@ -120,38 +120,41 @@ CMake files are located at each level of the directory structure to allow exampl
 
 The directory structure resembles this hierarchy (some entries are omitted for clarity):
 
-    ```
-    MyProject/
-      cmake/
-      CMakeLists.txt
-      examples/
-        BUILD-EXAMPLES.md
-        CMakeLists.txt
-        CMakeLists.txt.in
-        cmake/
-        cpp/
-          authinitialize/
-          continuousquery/
-          dataserializable/
-          functionexecution/
-          pdxserializable/
-          pdxserializer/
-          putgetremove/
-          remotequery/
-          sslputget/
-          transaction/
-        dotnet/
-          authinitialize/
-          continuousquery/
-          dataserializable/
-          functionexecution/
-          pdxautoserializer/
-          pdxserializable/
-          putgetremove/
-          remotequery/
-          sslputget/
-          transaction/
-    ```
+```
+MyProject/
+  cmake/
+  CMakeLists.txt
+  examples/
+    BUILD-EXAMPLES.md
+    CMakeLists.txt
+    CMakeLists.txt.in
+    cmake/
+    cpp/
+      authinitialize/
+      continuousquery/
+      dataserializable/
+      functionexecution/
+      pdxserializable/
+      pdxserializer/
+      putgetremove/
+      remotequery/
+      sslputget/
+      transaction/
+    dotnet/
+      authinitialize/
+      continuousquery/
+      dataserializable/
+      functionexecution/
+      pdxautoserializer/
+      pdxserializable/
+      putgetremove/
+      remotequery/
+      sslputget/
+      transaction/
+```
 
 See the `BUILD-EXAMPLES.md` file for detailed instructions on building and executing the examples,
 and read the source code to understand how the examples are constructed.
+
+See [Put/Get/Remove Examples](put-get-example.html) for sample code showing the basics of how a client application
+connects to a <%=vars.product_name%> cluster and performs basic operations on a remote server.
diff --git a/docs/geode-native-docs/getting-started/put-get-example.html.md.erb b/docs/geode-native-docs/getting-started/put-get-example.html.md.erb
new file mode 100644
index 0000000..586fd29
--- /dev/null
+++ b/docs/geode-native-docs/getting-started/put-get-example.html.md.erb
@@ -0,0 +1,129 @@
+---
+title:  Put/Get/Remove Examples
+---
+
+<!--
+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.
+-->
+
+The native client release contains examples, written for .NET and C++, showing how a client application
+can establish a connection to a cluster and then use that connection to perform basic operations on a remote server. 
+The examples are located in `../examples/dotnet/putgetremove` and `../examples/cpp/putgetremove`, respectively. 
+
+Both examples perform the same sequence of operations, displaying simple log entries as they run.
+
+- To run an example, follow the instructions in the `README.md` file in the example directory.
+- Review the source code in the example directory to see exactly how it operates.
+
+- Begin by running a script that sets up the server-side environment by invoking `gfsh` commands to create a region, simply called "example_userinfo."
+
+- Run the example client application, which performs the following steps:
+
+  - Connects to the server
+  - Performs region put operations using key/value pairs
+  - Uses region get to retrieve the values
+  - Uses region remove to remove the values
+
+### .NET Example
+
+This section contains code snippets showing highlights of the .NET put/get/remove example. They are not intended for cut-and-paste execution.
+For the complete source, see the example source directory.
+
+The .NET example creates a cache, then uses it to create a connection pool and a region object (of class `IRegion`).
+
+```csharp
+   var cacheFactory = new CacheFactory()
+       .Set("log-level", "none");
+   var cache = cacheFactory.Create();
+
+   var poolFactory = cache.GetPoolFactory()
+       .AddLocator("localhost", 10334);
+   poolFactory.Create("pool");
+
+   var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
+       .SetPoolName("pool");
+   var region = regionFactory.Create<string, string("example_userinfo");
+```
+
+After declaring some keys and values, the client then populates the data store with two key/value pairs. 
+
+```csharp
+      region.Put(rtimmonsKey, rtimmonsValue);
+      region.Put(scharlesKey, scharlesValue);
+```
+
+Next, the application retrieves the stored values using `Get` operations.
+
+```csharp
+      var user1 = region.Get(rtimmonsKey, null);
+      var user2 = region.Get(scharlesKey, null);
+```
+
+Finally, the application deletes one of the stored values using the `Remove` method.
+
+```csharp
+      if (region.Remove(rtimmonsKey))
+      {
+        Console.WriteLine("Info for " + rtimmonsKey + " has been deleted");
+      }
+      else
+      {
+        Console.WriteLine("Info for " + rtimmonsKey + " has not been deleted");
+      }
+```
+
+### C++ Example
+
+This section contains code snippets showing highlights of the C++ put/get/remove example. They are not intended for cut-and-paste execution.
+For the complete source, see the example source directory.
+
+The C++ example creates a cache, then uses it to create a connection pool and a region object (of class `Region`).
+
+```cpp
+  auto cacheFactory = CacheFactory();
+  cacheFactory.set("log-level", "none");
+  auto cache = cacheFactory.create();
+  auto poolFactory = cache.getPoolManager().createFactory();
+
+  poolFactory.addLocator("localhost", 10334);
+  auto pool = poolFactory.create("pool");
+  auto regionFactory = cache.createRegionFactory(RegionShortcut::PROXY);
+  auto region = regionFactory.setPoolName("pool").create("example_userinfo");
+```
+
+The client then populates the data store with two key/value pairs. 
+
+```cpp
+  region->put("rtimmons", "Robert Timmons");
+  region->put("scharles", "Sylvia Charles");
+```
+
+Next, the application retrieves the stored values using `Get` operations.
+
+```cpp
+  auto user1 = region->get("rtimmons");
+  auto user2 = region->get("scharles");
+```
+
+Finally, the application deletes one of the stored values using the `Remove` method.
+
+```cpp
+  if (region->existsValue("rtimmons")) {
+    std::cout << "rtimmons's info not deleted" << std::endl;
+  } else {
+    std::cout << "rtimmons's info successfully deleted" << std::endl;
+  }
+```
diff --git a/docs/geode-native-docs/transactions.html.md.erb b/docs/geode-native-docs/transactions.html.md.erb
index 3b06112..9ae445b 100644
--- a/docs/geode-native-docs/transactions.html.md.erb
+++ b/docs/geode-native-docs/transactions.html.md.erb
@@ -69,7 +69,7 @@ Both examples perform the same sequence of operations, displaying simple log ent
 - To run an example, follow the instructions in the `README.md` file in the example directory.
 - Review the source code in the example directory to see exactly how it operates.
 
-- You begin by running a script that sets up the servers-side environment by invoking `gfsh` commands to create a region, simply called "exampleRegion".
+- You begin by running a script that sets up the server-side environment by invoking `gfsh` commands to create a region, simply called "exampleRegion."
 
 - You run the example client application, which performs the following steps: