You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ma...@apache.org on 2016/07/08 19:47:32 UTC

[01/11] incubator-geode git commit: GEODE-33 - Removing unused assumption

Repository: incubator-geode
Updated Branches:
  refs/heads/develop 617d31327 -> 92d961a65


GEODE-33 - Removing unused assumption


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/92d961a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/92d961a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/92d961a6

Branch: refs/heads/develop
Commit: 92d961a652f52618e4cbd004032aaf7f9fe21d24
Parents: 540698b
Author: William Markito <wm...@pivotal.io>
Authored: Thu Jul 7 17:22:27 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/replicated/README.md | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92d961a6/geode-examples/replicated/README.md
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/README.md b/geode-examples/replicated/README.md
index 99ae753..ea923dd 100644
--- a/geode-examples/replicated/README.md
+++ b/geode-examples/replicated/README.md
@@ -43,5 +43,3 @@ The producer puts 50 entries into the replicated region. The consumer prints the
         $ scripts/stopAll.sh
 
 This example is a simple demonstration on basic APIs of Geode, as well how to write tests using mocks for Geode applications.
-
-TODO: assume jUnit4


[07/11] incubator-geode git commit: GEODE-33 - Adding link to replicated examples

Posted by ma...@apache.org.
GEODE-33 - Adding link to replicated examples


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

Branch: refs/heads/develop
Commit: c76554ca9bf3570ea4437b26fdb59e0d74dd3d3d
Parents: ab4bdd9
Author: William Markito <wm...@pivotal.io>
Authored: Tue Jun 21 11:43:50 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c76554ca/geode-examples/README.md
----------------------------------------------------------------------
diff --git a/geode-examples/README.md b/geode-examples/README.md
index edba63a..5925725 100644
--- a/geode-examples/README.md
+++ b/geode-examples/README.md
@@ -22,7 +22,7 @@ All examples:
 
 ### Basics
 
-*  [Replicated Region]()
+*  [Replicated Region]('replicated')
 *  Partitioned Region
 *  Persistence
 *  OQL (Querying)


[06/11] incubator-geode git commit: GEODE-1525: Examples README.md should set env variable GEODE-1523: Improve examples README.md markdown

Posted by ma...@apache.org.
GEODE-1525: Examples README.md should set env variable
GEODE-1523: Improve examples README.md markdown

This PR fixes addresses both GEODE-1525 and GEODE-1523, as they
both change the contents of the same file: geode-examples/README.md.

- Each example will likely use a scripts/setEnv.sh script to set
  the path to gfsh. The script depends on a GEODE_HOME environment
  variable, so this top level of instructions for setting up
  the examples now tells the user to set a GEODE_HOME env variable
  directly after the installation.

- Implement a more strict markdown that displays correctly for a
  wide variety of markdown implementations.

- Put in links for the 3 references.

- Improve the prose.


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

Branch: refs/heads/develop
Commit: fb75348a3ded7fddb45424956cd946cf13b5a20b
Parents: b7c5965
Author: Karen Miller <km...@pivotal.io>
Authored: Wed Jun 15 15:30:03 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/README.md | 86 ++++++++++++++++++++++---------------------
 1 file changed, 44 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb75348a/geode-examples/README.md
----------------------------------------------------------------------
diff --git a/geode-examples/README.md b/geode-examples/README.md
index 25a0dfc..edba63a 100644
--- a/geode-examples/README.md
+++ b/geode-examples/README.md
@@ -1,68 +1,70 @@
 # Apache Geode examples
 
-This is the home of Apache Geode examples that are bundled with the project. Contributions<sup>[2]</sup> and corrections are as usual welcome and if you have any suggestions come talk to us at [dev@geode.incubator.apache.org](mailto:dev@geode.incubator.apache.org) or just submit a [pull request](https://github.com/apache/incubator-geode/pull/new/develop).
+This is the home of Apache Geode examples that are bundled with the project. Contributions<sup>[2]</sup> and corrections are welcome. Please talk to us about your suggestions at [dev@geode.incubator.apache.org](mailto:dev@geode.incubator.apache.org) or submit a [pull request](https://github.com/apache/incubator-geode/pull/new/develop).
 
 ## Example requirements
 
 All examples:
- * Needs to be testable. (unit tests, integration tests or what's applicable) - Tests will ran through project CI.
- * Should be `Gradle` projects or part of existing ones. <sup>There could be a few exceptions here, but community should have consensus to accept</sup>
- * Have to follow code format & style from Apache Geode <sup>[1]</sup> guidelines.
- * Should contain a `README.md` file with step-by-step instruction on how to setup and run. (Diagrams give extra credits).
- * Donations need to be licensed through ASL 2.0 and contributors need to file an ICLA<sup>[3]</sup>
+
+*  Need to be testable. Use unit tests, integration tests or whatever is applicable. Tests will run through the project's CI.
+*  Should be `Gradle` projects or part of existing ones. There may be exceptions here, but the community should have a consensus to accept.
+*  Have to follow code format & style from Apache Geode <sup>[1]</sup> guidelines.
+*  Should contain a `README.md` file with step-by-step instruction on how to set up and run the example. *Diagrams give you extra credit.*
+*  Donations need to be licensed through ASL 2.0 and contributors need to file an ICLA<sup>[3]</sup>.
 
 ## Structure
 
-### Quick start & Installation
+### Installation and a Tutorial for Beginners
 
-  * [How to Install](http://geode.docs.pivotal.io/docs/getting_started/installation/install_standalone.html)
-  * [Apache Geode in 15 minutes or Less](http://geode.docs.pivotal.io/docs/getting_started/15_minute_quickstart_gfsh.html)
+*  [How to Install](http://geode.docs.pivotal.io/docs/getting_started/installation/install_standalone.html)
+*  Set a `GEODE_HOME` environment variable to point to the `bin` directory of the installation. For those that have built from source, this will be the `geode-assembly/build/install/apache-geode` directory.
+*  If desired run the tutorial: [Apache Geode in 15 minutes or Less](http://geode.docs.pivotal.io/docs/getting_started/15_minute_quickstart_gfsh.html)
 
 ### Basics
 
-  * [Replicated Region]()
-  * Partitioned Region
-  * Persistence
-  * OQL (Querying)
+*  [Replicated Region]()
+*  Partitioned Region
+*  Persistence
+*  OQL (Querying)
 
 ### Intermediate
 
-  * PDX & Serialization
-  * Functions
-  * CacheLoader & CacheWriter
-  * Listeners
-  * Async Event Queues
-  * Continuous Querying
-  * Transactions
-  * Eviction
-  * Expiration
-  * Overflow
-  * Security
-  * Off-heap
+*  PDX & Serialization
+*  Functions
+*  CacheLoader & CacheWriter
+*  Listeners
+*  Async Event Queues
+*  Continuous Querying
+*  Transactions
+*  Eviction
+*  Expiration
+*  Overflow
+*  Security
+*  Off-heap
 
 ### Advanced
 
-  * WAN Gateway
-  * Durable subscriptions
-  * Delta propagation
-  * Network partition detection
-  * D-lock
-  * Compression
-  * Resource manager
-  * PDX Advanced
+*  WAN Gateway
+*  Durable subscriptions
+*  Delta propagation
+*  Network partition detection
+*  D-lock
+*  Compression
+*  Resource manager
+*  PDX Advanced
 
 ### Use cases & integrations
 
- This section should have self contained little projects that illustrate a use case or integration with some other projects.
+This section has self-contained little projects that illustrate a use case or an integration with other projects.
 
-  * SpringBoot Application
-  * HTTP Session replication
-  * Redis
-  * Memcached
-  * Spark Connector
+*  SpringBoot Application
+*  HTTP Session replication
+*  Redis
+*  Memcached
+*  Spark Connector
 
 ## References
 
-- [1] - https://cwiki.apache.org/confluence/display/GEODE/Criteria+for+Code+Submissions
-- [2] - https://cwiki.apache.org/confluence/display/GEODE/How+to+Contribute
-- [3] - http://www.apache.org/licenses/#clas
+- [1]  [https://cwiki.apache.org/confluence/display/GEODE/Criteria+for+Code+Submissions](https://cwiki.apache.org/confluence/display/GEODE/Criteria+for+Code+Submissions)
+- [2]  [https://cwiki.apache.org/confluence/display/GEODE/How+to+Contribute](https://cwiki.apache.org/confluence/display/GEODE/How+to+Contribute)
+- [3]  [http://www.apache.org/licenses/#clas](http://www.apache.org/licenses/#clas)


[05/11] incubator-geode git commit: GEODE-1531: Improve README.md for replicated example

Posted by ma...@apache.org.
GEODE-1531: Improve README.md for replicated example

- Improved the appearance of the markdown

- Added commands for how to kill a single server

- Added last step to run scripts/stopAll.sh so the system is
  shut down when the example ends, not leaving a locator and
  a server running

- Improved the prose describing what the example does


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

Branch: refs/heads/develop
Commit: b7c5965043ad187aa31f2ed963fb56b4c62a5df9
Parents: bd75c73
Author: Karen Miller <km...@pivotal.io>
Authored: Wed Jun 15 14:34:37 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/replicated/README.md | 74 ++++++++++++++++++--------------
 1 file changed, 41 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b7c59650/geode-examples/replicated/README.md
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/README.md b/geode-examples/replicated/README.md
index d6c0936..99ae753 100644
--- a/geode-examples/replicated/README.md
+++ b/geode-examples/replicated/README.md
@@ -1,39 +1,47 @@
 # Geode replicated region example
 
-This is one of the most basic examples for Geode. 
-It created a replicated region and insert a couple of entries and then print the number of entries in the server.
+This is one of the most basic examples. 
+Two servers host a replicated region.
+The producer puts 50 entries into the replicated region. The consumer prints the number of entries in the region.
 
 ## Steps
-1. Start servers
-```
-$ scripts/startAll.sh
-```
-1. Run producer
-```
-$ gradle run -Pmain=Producer
-...
-... 
-INFO: Done. Inserted 50 entries.
-```
-1. Run consumer
-```
-$ gradle run -Pmain=Consumer
-...
-...
-INFO: Done. 50 entries available on the server(s).
-```
-1. Kill a node
-```
-$ ???
-```
-1. Run the consumer a 2nd time
-``` 
-$ gradle run -Pmain=Consumer
-...
-...
-INFO: Done. 50 entries available on the server(s).
-```
-
-This example is a simple demonstration on basic APIs of Geode as well how to write tests using mocks for Geode applications.
+1. From the ```geode-examples/replicated``` directory, start the locator and two servers:
+
+        $ scripts/startAll.sh
+
+2. Run the producer:
+
+        $ gradle run -Pmain=Producer
+        ...
+        ... 
+        INFO: Done. Inserted 50 entries.
+
+3. Run the consumer:
+
+        $ gradle run -Pmain=Consumer
+        ...
+        ...
+        INFO: Done. 50 entries available on the server(s).
+
+4. Kill one of the servers:
+
+        $ gfsh
+        ...
+        gfsh>connect
+        gfsh>stop server --name=server1
+        gfsh>quit
+
+5. Run the consumer a second time, and notice that all the entries are still available due to replication: 
+
+        $ gradle run -Pmain=Consumer
+        ...
+        ...
+        INFO: Done. 50 entries available on the server(s).
+
+6. Shutdown the system:
+
+        $ scripts/stopAll.sh
+
+This example is a simple demonstration on basic APIs of Geode, as well how to write tests using mocks for Geode applications.
 
 TODO: assume jUnit4


[11/11] incubator-geode git commit: GEODE-33: clarify GEODE_HOME value

Posted by ma...@apache.org.
GEODE-33: clarify GEODE_HOME value

Clarify prose that identifies value to set for GEODE_HOME,
based on dev feedback.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/3eaa1cdf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/3eaa1cdf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/3eaa1cdf

Branch: refs/heads/develop
Commit: 3eaa1cdfc12491bfafd7be39b2cacc175363cf6b
Parents: 859dc76
Author: Karen Miller <km...@pivotal.io>
Authored: Fri Jun 24 09:27:51 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3eaa1cdf/geode-examples/README.md
----------------------------------------------------------------------
diff --git a/geode-examples/README.md b/geode-examples/README.md
index cd91b2a..fccffc9 100644
--- a/geode-examples/README.md
+++ b/geode-examples/README.md
@@ -17,7 +17,7 @@ All examples:
 ### Installation and a Tutorial for Beginners
 
 *  [How to Install](http://geode.docs.pivotal.io/docs/getting_started/installation/install_standalone.html)
-*  Set a `GEODE_HOME` environment variable to point to the `bin` directory of the installation. For those that have built from source, this will be the `geode-assembly/build/install/apache-geode` directory.
+*  Set a `GEODE_HOME` environment variable to point to the root directory of the installation; this directory contains `bin/`. For those that have built from source, it will be the `geode-assembly/build/install/apache-geode` directory.
 *  If desired run the tutorial: [Apache Geode in 15 minutes or Less](http://geode.docs.pivotal.io/docs/getting_started/15_minute_quickstart_gfsh.html)
 
 ### Basics


[10/11] incubator-geode git commit: GEODE-33 - Minor fixes after review comments.

Posted by ma...@apache.org.
GEODE-33 - Minor fixes after review comments.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/540698b8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/540698b8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/540698b8

Branch: refs/heads/develop
Commit: 540698b811959ebe4d2390ca0395f7a359a57200
Parents: a4010b2
Author: William Markito <wm...@pivotal.io>
Authored: Thu Jul 7 17:19:24 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/README.md                        |  4 ++-
 .../geode/examples/replicated/BaseClient.java   |  8 +++---
 .../geode/examples/replicated/Consumer.java     |  8 ++----
 .../geode/examples/replicated/ConsumerTest.java | 27 ++++++++++++--------
 .../geode/examples/replicated/ProducerTest.java | 19 ++++++--------
 .../examples/replicated/ReplicatedTest.java     |  2 +-
 6 files changed, 34 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/540698b8/geode-examples/README.md
----------------------------------------------------------------------
diff --git a/geode-examples/README.md b/geode-examples/README.md
index fccffc9..1d4eafb 100644
--- a/geode-examples/README.md
+++ b/geode-examples/README.md
@@ -30,6 +30,8 @@ All examples:
 ### Intermediate
 
 *  PDX & Serialization
+*  Lucene Indexing
+*  OQL Indexing
 *  Functions
 *  CacheLoader & CacheWriter
 *  Listeners
@@ -53,7 +55,7 @@ All examples:
 *  Resource manager
 *  PDX Advanced
 
-### Use cases & integrations
+### Use cases, integrations and external examples
 
 This section has self-contained little projects that illustrate a use case or an integration with other projects.
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/540698b8/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/BaseClient.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/BaseClient.java b/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/BaseClient.java
index 45349ac..9a86224 100644
--- a/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/BaseClient.java
+++ b/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/BaseClient.java
@@ -16,13 +16,13 @@
  */
 package org.apache.geode.examples.replicated;
 
+import java.util.logging.Logger;
+
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.client.ClientCache;
 import com.gemstone.gemfire.cache.client.ClientCacheFactory;
 import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
 
-import java.util.logging.Logger;
-
 
 public abstract class BaseClient {
 
@@ -34,8 +34,8 @@ public abstract class BaseClient {
   }
 
   private Region region;
-  private final String locatorHost = System.getProperty("locatorHost", "localhost");
-  private final int locatorPort = Integer.getInteger("locatorPort", 10334);
+  private final String locatorHost = System.getProperty("GEODE_LOCATOR_HOST", "localhost");
+  private final int locatorPort = Integer.getInteger("GEODE_LOCATOR_PORT", 10334);
   protected static final String REGION_NAME = "myRegion";
   static final int NUM_ENTRIES = 50;
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/540698b8/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Consumer.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Consumer.java b/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Consumer.java
index 7fa32b1..d4eca43 100644
--- a/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Consumer.java
+++ b/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Consumer.java
@@ -18,14 +18,10 @@ package org.apache.geode.examples.replicated;
 
 import com.gemstone.gemfire.cache.client.ClientCache;
 
-/**
- * @author wmarkito
- * @date 5/31/16.
- */
 public class Consumer extends BaseClient {
 
   public static void main(String[] args) {
-    new Consumer().countEntries();
+    new Consumer().countEntriesOnServer();
   }
 
   public Consumer() {
@@ -35,7 +31,7 @@ public class Consumer extends BaseClient {
     this.clientCache = clientCache;
   }
 
-  public int countEntries() {
+  public int countEntriesOnServer() {
     int size = getRegion().keySetOnServer().size();
     logger.info(String.format("Done. %d entries available on the server(s).", size));
     return size;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/540698b8/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ConsumerTest.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ConsumerTest.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ConsumerTest.java
index 3231092..b9b4d30 100644
--- a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ConsumerTest.java
+++ b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ConsumerTest.java
@@ -17,19 +17,19 @@
 
 package org.apache.geode.examples.replicated;
 
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.client.ClientCache;
-import com.gemstone.gemfire.cache.client.NoAvailableLocatorsException;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.util.Set;
 
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
-import java.util.Set;
-
-import static org.mockito.Mockito.*;
-import static org.junit.Assert.*;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.NoAvailableLocatorsException;
 
 public class ConsumerTest {
 
@@ -52,15 +52,20 @@ public class ConsumerTest {
   }
 
   @Test
-  public void countEntriesOnARegion() throws Exception {
-    assertEquals(consumer.NUM_ENTRIES, consumer.countEntries());
+  public void numberOfEntriesOnServerShouldMatchConsumerEntries() throws Exception {
+    assertEquals(consumer.NUM_ENTRIES, consumer.countEntriesOnServer());
+  }
+
+  @Test
+  public void numberOfEntriesShouldBeGreaterThanZero() throws Exception {
+    assertTrue(consumer.NUM_ENTRIES > 0);
   }
 
   @Test
-  public void countEntriesOnARegionWithNoConnection() throws Exception {
+  public void countingEntriesWithoutConnectionShouldThrowNoAvailableLocatorsException() throws Exception {
     consumer = new Consumer();
     expectedException.expect(NoAvailableLocatorsException.class);
-    assertEquals(consumer.NUM_ENTRIES, consumer.countEntries());
+    assertEquals(consumer.NUM_ENTRIES, consumer.countEntriesOnServer());
   }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/540698b8/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ProducerTest.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ProducerTest.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ProducerTest.java
index 85f8038..c3ccb80 100644
--- a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ProducerTest.java
+++ b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ProducerTest.java
@@ -16,8 +16,10 @@
  */
 package org.apache.geode.examples.replicated;
 
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.client.ClientCache;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+
+import java.util.Set;
 
 import org.junit.After;
 import org.junit.Before;
@@ -25,13 +27,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
-import java.util.Set;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ClientCache;
 
 public class ProducerTest {
 
@@ -51,7 +48,7 @@ public class ProducerTest {
   }
 
   @Test
-  public void populateRegion() throws Exception {
+  public void populateRegionShouldReturnCorrectNumberOfEntries() throws Exception {
     producer = new Producer(clientCache);
     producer.setRegion(region);
 
@@ -60,7 +57,7 @@ public class ProducerTest {
   }
 
   @Test
-  public void populateWhenRegionDoesntExist() throws Exception {
+  public void populateWhenRegionDoesNotExistShouldThrowNullPointer() throws Exception {
     producer = new Producer(clientCache);
     expectedException.expect(NullPointerException.class);
     producer.populateRegion();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/540698b8/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
index dc4e65f..1901221 100644
--- a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
+++ b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
@@ -73,7 +73,7 @@ public class ReplicatedTest {
   @Test
   public void checkIfScriptsExistsAndAreExecutable() throws IOException {
     assertTrue(shell.getFileFromClassLoader(startScriptFileName).map(x -> x.isFile()).orElse(false));
-    assertTrue(shell.getFileFromClassLoader(startScriptFileName).map(x -> x.isFile()).orElse(false));
+    assertTrue(shell.getFileFromClassLoader(stopScriptFileName).map(x -> x.isFile()).orElse(false));
   }
 
   @Test


[08/11] incubator-geode git commit: Merge #158 into feature/GEODE-33 GEODE-1530: geode-examples setEnv.sh script needs to export path

Posted by ma...@apache.org.
Merge #158 into feature/GEODE-33
GEODE-1530: geode-examples setEnv.sh script needs to export path

Without an export of the path, using the GEODE_HOME env variable,
the scripts/startAll.sh script will pick up the first gfsh in the
path that it finds.

Also updated the scripts/stopAll.sh script to run the setEnv.sh
script, so that stopAll.sh uses the correct gfsh.


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

Branch: refs/heads/develop
Commit: d3d8543110ae772d76c114d2d8d52d53355e4e07
Parents: fb75348
Author: Karen Miller <km...@pivotal.io>
Authored: Wed Jun 15 11:07:03 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/replicated/scripts/setEnv.sh  | 5 ++++-
 geode-examples/replicated/scripts/stopAll.sh | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d3d85431/geode-examples/replicated/scripts/setEnv.sh
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/scripts/setEnv.sh b/geode-examples/replicated/scripts/setEnv.sh
index 77784ff..3cc1549 100755
--- a/geode-examples/replicated/scripts/setEnv.sh
+++ b/geode-examples/replicated/scripts/setEnv.sh
@@ -21,4 +21,7 @@
 
 ## check if gfsh script is accessible and print version
 : ${GEODE_HOME/bin/gfsh?"gfsh doesn't seem to be available. Please check $GEODE_HOME"}
-echo "Geode version: `$GEODE_HOME/bin/gfsh version`"
\ No newline at end of file
+echo "Geode version: `$GEODE_HOME/bin/gfsh version`"
+
+## prefer GEODE_HOME for finding gfsh
+export PATH=$GEODE_HOME/bin:$PATH

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d3d85431/geode-examples/replicated/scripts/stopAll.sh
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/scripts/stopAll.sh b/geode-examples/replicated/scripts/stopAll.sh
index 4d792de..d2fb2be 100755
--- a/geode-examples/replicated/scripts/stopAll.sh
+++ b/geode-examples/replicated/scripts/stopAll.sh
@@ -19,4 +19,6 @@ set -e
 
 cd `dirname $0`
 
+. ./setEnv.sh
+
 gfsh -e "connect" -e "shutdown --include-locators=true"


[03/11] incubator-geode git commit: [GEODE-33] Fixed hardcoded path for resources on tests - Included rat exclusion rules

Posted by ma...@apache.org.
[GEODE-33] Fixed hardcoded path for resources on tests
- Included rat exclusion rules


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

Branch: refs/heads/develop
Commit: ab4bdd9fa8561da95858d6e74bb885273468907d
Parents: d3d8543
Author: William Markito <wm...@pivotal.io>
Authored: Tue Jun 21 00:00:41 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/.gitignore                       |   1 +
 .../gradle/wrapper/gradle-wrapper.jar           | Bin 53636 -> 53639 bytes
 .../gradle/wrapper/gradle-wrapper.properties    |   4 +-
 geode-examples/gradlew.bat                      |   2 +-
 geode-examples/replicated/build.gradle          |   4 +
 .../examples/replicated/ReplicatedTest.java     |  98 ++++---------------
 .../geode/examples/replicated/ShellUtil.java    |  13 ++-
 gradle/rat.gradle                               |   6 ++
 8 files changed, 42 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab4bdd9f/geode-examples/.gitignore
----------------------------------------------------------------------
diff --git a/geode-examples/.gitignore b/geode-examples/.gitignore
new file mode 100644
index 0000000..b1001a6
--- /dev/null
+++ b/geode-examples/.gitignore
@@ -0,0 +1 @@
+.idea/**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab4bdd9f/geode-examples/gradle/wrapper/gradle-wrapper.jar
----------------------------------------------------------------------
diff --git a/geode-examples/gradle/wrapper/gradle-wrapper.jar b/geode-examples/gradle/wrapper/gradle-wrapper.jar
index 9411448..2c6137b 100644
Binary files a/geode-examples/gradle/wrapper/gradle-wrapper.jar and b/geode-examples/gradle/wrapper/gradle-wrapper.jar differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab4bdd9f/geode-examples/gradle/wrapper/gradle-wrapper.properties
----------------------------------------------------------------------
diff --git a/geode-examples/gradle/wrapper/gradle-wrapper.properties b/geode-examples/gradle/wrapper/gradle-wrapper.properties
index 9af0d52..6132c99 100644
--- a/geode-examples/gradle/wrapper/gradle-wrapper.properties
+++ b/geode-examples/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Jun 01 15:34:43 PDT 2016
+#Mon Jun 20 23:30:08 PDT 2016
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab4bdd9f/geode-examples/gradlew.bat
----------------------------------------------------------------------
diff --git a/geode-examples/gradlew.bat b/geode-examples/gradlew.bat
index 8a0b282..5f19212 100644
--- a/geode-examples/gradlew.bat
+++ b/geode-examples/gradlew.bat
@@ -46,7 +46,7 @@ echo location of your Java installation.
 goto fail
 
 :init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
 
 if not "%OS%" == "Windows_NT" goto win9xME_args
 if "%@eval[2+2]" == "4" goto 4NT_args

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab4bdd9f/geode-examples/replicated/build.gradle
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/build.gradle b/geode-examples/replicated/build.gradle
index ae6f28c..52283ec 100644
--- a/geode-examples/replicated/build.gradle
+++ b/geode-examples/replicated/build.gradle
@@ -14,3 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+sourceSets.test {
+  resources.srcDirs = ["${projectDir}/scripts"]
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab4bdd9f/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
index aeccf7b..6d777d0 100644
--- a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
+++ b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
@@ -16,62 +16,50 @@
  */
 package org.apache.geode.examples.replicated;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.*;
 
+import java.io.File;
 import java.io.IOException;
-import java.nio.file.Paths;
 import java.util.concurrent.TimeUnit;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.junit.After;
+import org.junit.Test;
 
 public class ReplicatedTest {
 
   //TODO: parameterize
-  private String startScript = "/Users/wmarkito/Pivotal/ASF/incubator-geode/geode-examples/replicated/scripts/startAll.sh";
-  private String stopScript = "/Users/wmarkito/Pivotal/ASF/incubator-geode/geode-examples/replicated/scripts/stopAll.sh";
+  private String startScriptFileName = "startAll.sh";
+  private String stopScriptFileName = "stopAll.sh";
   private boolean processRunning = false;
-  private ShellUtil shell;
+  private ShellUtil shell = new ShellUtil();
   private Process process;
 
-  private int waitTimeForScript=1000;
-
-  @Before
-  public void setup() {
-    if (processRunning) {
-      stop();
-    }
-  }
+  private int waitTimeForScript=60;
 
   @Test
   public void checkIfScriptsExists() throws IOException {
-//
-//    ClassLoader classLoader = getClass().getClassLoader();
-//
-//    File file = new File(classLoader.getResource("startAll.sh").getFile());
-//
-//    System.out.println(file.getCanonicalPath());
-
-    assertTrue(Paths.get(startScript).toFile().exists());
-    assertTrue(Paths.get(stopScript).toFile().exists());
+    ClassLoader classLoader = getClass().getClassLoader();
+
+    File file = new File(classLoader.getResource(startScriptFileName).getFile());
+    assertTrue(file.exists());
+
+    file = new File(classLoader.getResource(stopScriptFileName).getFile());
+    assertTrue(file.exists());
   }
 
 
   private Process start() {
-    Process p = new ShellUtil().exec(startScript).get();
+    Process p = shell.executeFile(startScriptFileName).get();
     processRunning = true;
     return p;
   }
 
   private Process stop() {
-    Process p = new ShellUtil().exec(stopScript).get();
+    Process p = shell.executeFile(stopScriptFileName).get();
     processRunning = false;
     return p;
   }
 
-
   @Test
   public void testStartAndStop() throws InterruptedException {
     boolean status = false;
@@ -100,56 +88,4 @@ public class ReplicatedTest {
     }
   }
 
-
-//  @Test
-//  public void testStopScript() {
-//    assertEquals(0, new ShellUtil().exec(stopScript).get().exitValue());
-//  }
-
-
-//  @Test
-//  public void test() {
-//    Producer producer = new Producer();
-//    Consumer consumer = new Consumer();
-//
-//    producer.populateRegion();
-//    int numEntries = consumer.countEntries();
-//
-//    assertEquals(BaseClient.NUM_ENTRIES, numEntries);
-//  }
-//
-//  private Cache setupCacheServer() {
-//    Cache cache = new CacheFactory()
-//            .set("name", "geode-server")
-//            .set("mcast-port", "0")
-//            .set("log-file", "ReplicatedTest.log")
-//            .set("log-level", "config")
-//            .create();
-//
-//    RegionFactory<String, String> regionFactory = cache.createRegionFactory();
-//
-//    regionFactory.setDataPolicy(DataPolicy.REPLICATE);
-//
-//    Region myRegion = regionFactory.create(BaseClient.REGION_NAME);
-//
-//    assertNotNull("The /myExample Region was not properly configured and initialized!", myRegion);
-////    assertEquals(BaseClient.REGION_NAME, myRegion.getFullPath());
-//    assertEquals(BaseClient.REGION_NAME, myRegion.getName());
-//    assertTrue(myRegion.isEmpty());
-//
-//    CacheServer cacheServer = cache.addCacheServer();
-//
-//    cacheServer.setPort(0);
-//    cacheServer.setMaxConnections(5);
-//
-//    try {
-//      cacheServer.start();
-//    } catch (IOException e) {
-//      throw new RuntimeException(e);
-//    }
-//    assertTrue("Cache Server is not running!", cacheServer.isRunning());
-//
-//    return cache;
-//  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab4bdd9f/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java
index 852ac88..b93f828 100644
--- a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java
+++ b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java
@@ -17,14 +17,23 @@
 
 package org.apache.geode.examples.replicated;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.Optional;
 
 public class ShellUtil {
 
-  public Optional<Process> exec(String command) {
+  /**
+   * File name should available on the classpath
+   * @param fileName
+   * @return <Optional>Process</Optional>
+   */
+  public Optional<Process> executeFile(String fileName) {
     try {
-      return Optional.of(Runtime.getRuntime().exec(command));
+      ClassLoader classLoader = getClass().getClassLoader();
+      File file = new File(classLoader.getResource(fileName).getFile());
+
+      return Optional.of(Runtime.getRuntime().exec(file.getAbsolutePath()));
     } catch (IOException e) {
       e.printStackTrace();
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab4bdd9f/gradle/rat.gradle
----------------------------------------------------------------------
diff --git a/gradle/rat.gradle b/gradle/rat.gradle
index 93cb91c..dfbb52d 100644
--- a/gradle/rat.gradle
+++ b/gradle/rat.gradle
@@ -43,6 +43,12 @@ rat {
     'geode-spark-connector/**/target/**',
     'geode-spark-connector/sbt',
 
+    // Geode examples
+    'geode-examples/*/scripts/**',
+    'geode-examples/.idea/**',
+    'geode-examples/gradlew*/**',
+    'geode-examples/gradle/wrapper/**',
+
     // IDE
     'etc/eclipseFormatterProfile.xml',
     'etc/intellijIdeaCodeStyle.xml',


[02/11] incubator-geode git commit: GEODE-33 - Applying PR feedback items * Minor fixes (adding mavenLocal to list of repositories, fixed dependency versions and use of gradle.properties). * Locator port now is parameterized and uses env variable. If not

Posted by ma...@apache.org.
GEODE-33 - Applying PR feedback items
* Minor fixes (adding mavenLocal to list of repositories, fixed dependency versions and use of gradle.properties).
* Locator port now is parameterized and uses env variable. If not set will use default port 10334.
* Applied PR feedback on testing classes and shellUtil now is based on Apache commons-exec.
* Merged #173
* Moved ShellUtil to utils submodule.


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

Branch: refs/heads/develop
Commit: a4010b2043ee708b8c85c987d21169da69af6df6
Parents: 3eaa1cd
Author: William Markito <wm...@pivotal.io>
Authored: Thu Jul 7 14:07:24 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/build.gradle                     |   8 +-
 geode-examples/gradle.properties                |   4 +-
 geode-examples/replicated/.gitignore            |   2 +
 geode-examples/replicated/scripts/pidkiller.sh  |  36 +++++
 geode-examples/replicated/scripts/setEnv.sh     |   6 +
 geode-examples/replicated/scripts/startAll.sh   |  13 +-
 geode-examples/replicated/scripts/stopAll.sh    |   6 +-
 .../examples/replicated/ReplicatedTest.java     | 151 ++++++++++++++-----
 .../geode/examples/replicated/ShellUtil.java    |  42 ------
 geode-examples/settings.gradle                  |   4 +-
 .../apache/geode/example/utils/ShellUtil.java   | 106 +++++++++++++
 gradle/rat.gradle                               |   3 +-
 12 files changed, 289 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/build.gradle
----------------------------------------------------------------------
diff --git a/geode-examples/build.gradle b/geode-examples/build.gradle
index fe0d93b..1eadc31 100644
--- a/geode-examples/build.gradle
+++ b/geode-examples/build.gradle
@@ -15,12 +15,12 @@
  * limitations under the License.
  */
 
-
 subprojects {
 
     apply plugin:'java'
 
     repositories {
+        mavenLocal()
         maven {
             url "https://repository.apache.org/content/repositories/snapshots/"
         }
@@ -28,11 +28,12 @@ subprojects {
     }
 
     dependencies {
+        testCompile project(":utils")
         compile "org.apache.geode:geode-core:$geodeVersion"
-//        testCompile "org.apache.geode:geode-junit:$geodeVersion"
         testCompile "junit:junit:$junitVersion"
         testCompile "org.mockito:mockito-core:$mockitocoreVersion"
-        compile "com.jayway.awaitility:awaitility:1.7.0"
+        compile "org.apache.commons:commons-exec:$commonsExecVersion"
+        compile "com.jayway.awaitility:awaitility:$awaitilityVersion"
     }
 
     task run(type: JavaExec) {
@@ -47,5 +48,6 @@ subprojects {
         }
     }
 
+
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/gradle.properties
----------------------------------------------------------------------
diff --git a/geode-examples/gradle.properties b/geode-examples/gradle.properties
index 31e0ed5..9c7822a 100644
--- a/geode-examples/gradle.properties
+++ b/geode-examples/gradle.properties
@@ -16,4 +16,6 @@
 #
 geodeVersion = 1.0.0-incubating.M3-SNAPSHOT
 junitVersion = 4.12
-mockitocoreVersion = 1.10.19
\ No newline at end of file
+mockitocoreVersion = 1.10.19
+commonsExecVersion = 1.3
+awaitilityVersion = 1.7.0
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/replicated/.gitignore
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/.gitignore b/geode-examples/replicated/.gitignore
new file mode 100644
index 0000000..b858ea8
--- /dev/null
+++ b/geode-examples/replicated/.gitignore
@@ -0,0 +1,2 @@
+server*/*
+locator*/*

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/replicated/scripts/pidkiller.sh
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/scripts/pidkiller.sh b/geode-examples/replicated/scripts/pidkiller.sh
new file mode 100755
index 0000000..1a3eaf2
--- /dev/null
+++ b/geode-examples/replicated/scripts/pidkiller.sh
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+#!/bin/bash
+#
+# @brief Script that look for .pid files on a directory and kill those processes. 
+#
+
+export DIR=$1
+
+if [ $# -eq 0 ]
+  then
+    echo "No arguments supplied. Script needs directory to look for pid files."
+    exit 1
+fi
+
+for pid in `find $DIR -name "*.pid"`
+do
+ echo "Found: $pid"
+ kill -9 `cat $pid`
+ echo "Killed."
+done
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/replicated/scripts/setEnv.sh
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/scripts/setEnv.sh b/geode-examples/replicated/scripts/setEnv.sh
index 3cc1549..60befc6 100755
--- a/geode-examples/replicated/scripts/setEnv.sh
+++ b/geode-examples/replicated/scripts/setEnv.sh
@@ -16,6 +16,9 @@
 #
 #!/bin/bash
 
+## check if locator port has been set otherwise set to default
+export GEODE_LOCATOR_PORT="${GEODE_LOCATOR_PORT:-10334}"
+
 ## check if GEODE_HOME has been set
 : ${GEODE_HOME?"GEODE_HOME enviroment variable needs to be set"}
 
@@ -25,3 +28,6 @@ echo "Geode version: `$GEODE_HOME/bin/gfsh version`"
 
 ## prefer GEODE_HOME for finding gfsh
 export PATH=$GEODE_HOME/bin:$PATH
+
+
+: ${GEODE_LOCATOR_PORT?}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/replicated/scripts/startAll.sh
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/scripts/startAll.sh b/geode-examples/replicated/scripts/startAll.sh
index f543412..f4ce413 100755
--- a/geode-examples/replicated/scripts/startAll.sh
+++ b/geode-examples/replicated/scripts/startAll.sh
@@ -18,23 +18,28 @@
 
 set -e
 
+current=`pwd`
+
 cd `dirname $0`
 
 . ./setEnv.sh
 
+cd $current
+
+#export GEODE_LOCATOR_PORT="${GEODE_LOCATOR_PORT:-10334}"
 # start a locator
-gfsh start locator --name=locator1 --mcast-port=0
+gfsh start locator --name=locator1 --mcast-port=0 --port=${GEODE_LOCATOR_PORT}
 
 # start 2 servers on a random available port
 for N in {1..2}
 do
- gfsh start server --locators=localhost[10334] --name=server$N  --server-port=0 --mcast-port=0
+ gfsh start server --locators=localhost[${GEODE_LOCATOR_PORT}] --name=server$N  --server-port=0 --mcast-port=0
 done
 
 # create a region using GFSH
-gfsh -e "connect" -e "create region --name=myRegion --type=REPLICATE"
+gfsh -e "connect --locator=localhost[${GEODE_LOCATOR_PORT}]" -e "create region --name=myRegion --type=REPLICATE"
 
-gfsh -e "connect" -e "list members"
+gfsh -e "connect --locator=localhost[${GEODE_LOCATOR_PORT}]" -e "list members"
 
 exit 0
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/replicated/scripts/stopAll.sh
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/scripts/stopAll.sh b/geode-examples/replicated/scripts/stopAll.sh
index d2fb2be..2a2c39b 100755
--- a/geode-examples/replicated/scripts/stopAll.sh
+++ b/geode-examples/replicated/scripts/stopAll.sh
@@ -17,8 +17,12 @@
 #!/bin/bash
 set -e
 
+current=`pwd`
+
 cd `dirname $0`
 
 . ./setEnv.sh
 
-gfsh -e "connect" -e "shutdown --include-locators=true"
+cd $current
+
+gfsh -e "connect --locator=localhost[${GEODE_LOCATOR_PORT}]" -e "shutdown --include-locators=true"

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
index 6d777d0..dc4e65f 100644
--- a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
+++ b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
@@ -16,76 +16,149 @@
  */
 package org.apache.geode.examples.replicated;
 
+import static org.hamcrest.core.Is.*;
 import static org.junit.Assert.*;
+import static org.junit.Assume.*;
 
-import java.io.File;
 import java.io.IOException;
+import java.net.ServerSocket;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
-
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecuteResultHandler;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.environment.EnvironmentUtils;
+import org.apache.geode.example.utils.ShellUtil;
 import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
+/**
+ * Tests for the shell scripts of the replicated example
+ */
 public class ReplicatedTest {
 
   //TODO: parameterize
-  private String startScriptFileName = "startAll.sh";
-  private String stopScriptFileName = "stopAll.sh";
+  public static final String GEODE_LOCATOR_PORT = "GEODE_LOCATOR_PORT=";
+  private static final String startScriptFileName = "startAll.sh";
+  private static final String stopScriptFileName = "stopAll.sh";
+  private static final String pidkillerScriptFileName = "pidkiller.sh";
   private boolean processRunning = false;
   private ShellUtil shell = new ShellUtil();
-  private Process process;
+  private final long scriptTimeout = TimeUnit.SECONDS.toMillis(60);
+  private static final Logger logger = Logger.getAnonymousLogger();
 
-  private int waitTimeForScript=60;
+  @Rule
+  public TemporaryFolder testFolder = new TemporaryFolder();
 
-  @Test
-  public void checkIfScriptsExists() throws IOException {
-    ClassLoader classLoader = getClass().getClassLoader();
+  private int locatorPort;
+  private Map environment;
 
-    File file = new File(classLoader.getResource(startScriptFileName).getFile());
-    assertTrue(file.exists());
+  @Before
+  public void setup() throws IOException {
+    // ignores test if running on windows
+    assumeThat(System.getProperty("os.name").startsWith("Windows"), is(false));
 
-    file = new File(classLoader.getResource(stopScriptFileName).getFile());
-    assertTrue(file.exists());
+    locatorPort = getAvailablePort();
+    environment = EnvironmentUtils.getProcEnvironment();
+    EnvironmentUtils.addVariableToEnvironment(environment, GEODE_LOCATOR_PORT + locatorPort);
+    logger.fine("Locator port: " + locatorPort);
   }
 
-
-  private Process start() {
-    Process p = shell.executeFile(startScriptFileName).get();
-    processRunning = true;
-    return p;
+  @Test
+  public void checkIfScriptsExistsAndAreExecutable() throws IOException {
+    assertTrue(shell.getFileFromClassLoader(startScriptFileName).map(x -> x.isFile()).orElse(false));
+    assertTrue(shell.getFileFromClassLoader(startScriptFileName).map(x -> x.isFile()).orElse(false));
   }
 
-  private Process stop() {
-    Process p = shell.executeFile(stopScriptFileName).get();
-    processRunning = false;
-    return p;
+  @Test
+  public void executeStartThenStopScript() throws InterruptedException, IOException {
+    final int exitCodeStart = executeScript(startScriptFileName);
+    assertEquals(0, exitCodeStart);
+
+    final int exitCodeStop = executeScript(stopScriptFileName);
+    assertEquals(0, exitCodeStop);
   }
 
   @Test
-  public void testStartAndStop() throws InterruptedException {
-    boolean status = false;
-    int exitCode = -1;
-
-    process = start();
-    status =  process.waitFor(waitTimeForScript, TimeUnit.SECONDS);
-    exitCode = process.exitValue();
-    verify(status, exitCode);
-
-    process = stop();
-    status = process.waitFor(waitTimeForScript, TimeUnit.SECONDS);
-    exitCode = process.exitValue();
-    verify(status, exitCode);
+  public void failToStopWhenNoServersAreRunning() throws InterruptedException, IOException {
+    final int exitCode;
+
+    exitCode = executeScript(stopScriptFileName);
+    assertEquals(1, exitCode);
   }
 
-  private void verify(boolean status, int exitCode) {
-    assertEquals(exitCode, 0);
-    assertEquals(status, true);
+  /**
+   * Execute the kill script that looks for pid files
+   * @throws IOException
+   * @throws InterruptedException
+   */
+  private void runKillScript() throws IOException, InterruptedException {
+    CommandLine cmdLine = CommandLine.parse(shell.getFileFromClassLoader(pidkillerScriptFileName)
+                                                 .map(x -> x.getAbsolutePath())
+                                                 .orElseThrow(IllegalArgumentException::new));
+    cmdLine.addArgument(testFolder.getRoot().getAbsolutePath());
+
+    DefaultExecuteResultHandler resultHandler = shell.execute(cmdLine, scriptTimeout, environment, testFolder
+      .getRoot());
+    resultHandler.waitFor(scriptTimeout);
+  }
+
+  /**
+   * Given a script file name, runs the script and return the exit code.
+   * If exitCode != 0 extract and prints exception.
+   * @param scriptName
+   * @return <code>int</code> with exitCode
+   * @throws IOException
+   * @throws InterruptedException
+   */
+  private int executeScript(String scriptName) throws IOException, InterruptedException {
+    final int exitCode;
+    DefaultExecuteResultHandler resultHandler = shell.execute(scriptName, scriptTimeout, environment, testFolder
+      .getRoot());
+    processRunning = true;
+    resultHandler.waitFor();
+
+    logger.finest(String.format("Executing %s...", scriptName));
+    exitCode = resultHandler.getExitValue();
+
+    // extract and log exception if any happened
+    if (exitCode != 0) {
+      ExecuteException executeException = resultHandler.getException();
+      logger.log(Level.SEVERE, executeException.getMessage(), executeException);
+    }
+    return exitCode;
   }
 
   @After
   public void tearDown() {
     if (processRunning) {
-      stop();
+      try {
+        runKillScript();
+      } catch (IOException | InterruptedException e) {
+        e.printStackTrace();
+      }
+    }
+  }
+
+  /**
+   * Get a random available port
+   * @return <code>int</code>  port number
+   */
+  private static int getAvailablePort() {
+    try (ServerSocket socket = new ServerSocket(0)) {
+      int port = socket.getLocalPort();
+      socket.close();
+      return port;
+    } catch (IOException ioex) {
+      logger.log(Level.SEVERE, ioex.getMessage(), ioex);
     }
+    throw new IllegalStateException("No TCP/IP ports available.");
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java
deleted file mode 100644
index b93f828..0000000
--- a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.geode.examples.replicated;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Optional;
-
-public class ShellUtil {
-
-  /**
-   * File name should available on the classpath
-   * @param fileName
-   * @return <Optional>Process</Optional>
-   */
-  public Optional<Process> executeFile(String fileName) {
-    try {
-      ClassLoader classLoader = getClass().getClassLoader();
-      File file = new File(classLoader.getResource(fileName).getFile());
-
-      return Optional.of(Runtime.getRuntime().exec(file.getAbsolutePath()));
-    } catch (IOException e) {
-      e.printStackTrace();
-    }
-    return Optional.empty();
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/settings.gradle
----------------------------------------------------------------------
diff --git a/geode-examples/settings.gradle b/geode-examples/settings.gradle
index cb71558..432a8eb 100644
--- a/geode-examples/settings.gradle
+++ b/geode-examples/settings.gradle
@@ -16,4 +16,6 @@
  */
 rootProject.name = 'geode-examples'
 
-include 'replicated'
\ No newline at end of file
+include 'replicated'
+include 'utils'
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/geode-examples/utils/src/main/java/org/apache/geode/example/utils/ShellUtil.java
----------------------------------------------------------------------
diff --git a/geode-examples/utils/src/main/java/org/apache/geode/example/utils/ShellUtil.java b/geode-examples/utils/src/main/java/org/apache/geode/example/utils/ShellUtil.java
new file mode 100644
index 0000000..c5290b8
--- /dev/null
+++ b/geode-examples/utils/src/main/java/org/apache/geode/example/utils/ShellUtil.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.geode.example.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecuteResultHandler;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.exec.ShutdownHookProcessDestroyer;
+
+/**
+ * Utility class for executing shell commands using Apache commons-exec
+ */
+public class ShellUtil {
+
+  private final ClassLoader classLoader = getClass().getClassLoader();
+
+  public Optional<File> getFileFromClassLoader(String fileName) {
+    URL resourceURL = classLoader.getResource(fileName);
+    return (resourceURL == null) ? Optional.empty() : Optional.of(new File(resourceURL.getFile()));
+  }
+
+  public CommandLine parseCommandLine(String fileName) {
+    return getFileFromClassLoader(fileName).map(file -> CommandLine.parse(file.getAbsolutePath()))
+                                           .orElseThrow(IllegalArgumentException::new);
+  }
+
+  public DefaultExecuteResultHandler execute(CommandLine cmdLine, long timeout, Map environment, File dir) throws IOException {
+    ExecutorTemplate exampleTestExecutor = new ExecutorTemplate(timeout, dir).invoke();
+    DefaultExecutor executor = exampleTestExecutor.getExecutor();
+    DefaultExecuteResultHandler resultHandler = exampleTestExecutor.getResultHandler();
+    executor.execute(cmdLine, environment, resultHandler);
+
+    return resultHandler;
+
+  }
+
+  public DefaultExecuteResultHandler execute(String fileName, long timeout, Map environment, File dir) throws IOException {
+    ExecutorTemplate exampleTestExecutor = new ExecutorTemplate(timeout, dir).invoke();
+    DefaultExecutor executor = exampleTestExecutor.getExecutor();
+    DefaultExecuteResultHandler resultHandler = exampleTestExecutor.getResultHandler();
+    executor.execute(parseCommandLine(fileName), environment, resultHandler);
+
+    return resultHandler;
+  }
+
+  /**
+   * Executor template for common scenarios
+   */
+  private static class ExecutorTemplate {
+
+    private final long timeout;
+    private final File dir;
+    private DefaultExecutor executor;
+    private DefaultExecuteResultHandler resultHandler;
+
+    public ExecutorTemplate(final long timeout, final File dir) {
+      this.timeout = timeout;
+      this.dir = dir;
+    }
+
+    public DefaultExecutor getExecutor() {
+      return executor;
+    }
+
+    public DefaultExecuteResultHandler getResultHandler() {
+      return resultHandler;
+    }
+
+    public ExecutorTemplate invoke() {
+      executor = new DefaultExecutor();
+      ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
+      executor.setWatchdog(watchdog);
+
+      PumpStreamHandler psh = new PumpStreamHandler(System.out, System.err);
+      executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
+      executor.setStreamHandler(psh);
+      executor.setWorkingDirectory(dir);
+
+      resultHandler = new DefaultExecuteResultHandler();
+      return this;
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a4010b20/gradle/rat.gradle
----------------------------------------------------------------------
diff --git a/gradle/rat.gradle b/gradle/rat.gradle
index dfbb52d..02bf85c 100644
--- a/gradle/rat.gradle
+++ b/gradle/rat.gradle
@@ -44,7 +44,8 @@ rat {
     'geode-spark-connector/sbt',
 
     // Geode examples
-    'geode-examples/*/scripts/**',
+    'geode-examples/*/scripts/server*/',
+    'geode-examples/*/scripts/locator*/',
     'geode-examples/.idea/**',
     'geode-examples/gradlew*/**',
     'geode-examples/gradle/wrapper/**',


[09/11] incubator-geode git commit: GEODE-33 - Removing quote from folder name

Posted by ma...@apache.org.
GEODE-33 - Removing quote from folder name


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/859dc76a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/859dc76a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/859dc76a

Branch: refs/heads/develop
Commit: 859dc76ac81dd563262f38918c33f465378cdc7e
Parents: c76554c
Author: William Markito <wm...@pivotal.io>
Authored: Tue Jun 21 11:47:19 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/859dc76a/geode-examples/README.md
----------------------------------------------------------------------
diff --git a/geode-examples/README.md b/geode-examples/README.md
index 5925725..cd91b2a 100644
--- a/geode-examples/README.md
+++ b/geode-examples/README.md
@@ -22,7 +22,7 @@ All examples:
 
 ### Basics
 
-*  [Replicated Region]('replicated')
+*  [Replicated Region](replicated)
 *  Partitioned Region
 *  Persistence
 *  OQL (Querying)


[04/11] incubator-geode git commit: [GEODE-33] - Adding geode-example module Creating a simple example for replicated regions to test the proposed example model Adding script tests Adding server folders to gitignore Adding gitignore and readme files

Posted by ma...@apache.org.
[GEODE-33] - Adding geode-example module
Creating a simple example for replicated regions to test the proposed example model
Adding script tests
Adding server folders to gitignore
Adding gitignore and readme files


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

Branch: refs/heads/develop
Commit: bd75c732aa21d4d92e78d5cd960a507039d0fd40
Parents: 617d313
Author: William Markito <wm...@pivotal.io>
Authored: Wed Jun 8 20:30:32 2016 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Fri Jul 8 12:42:39 2016 -0700

----------------------------------------------------------------------
 geode-examples/README.md                        |  68 ++++++++
 geode-examples/build.gradle                     |  51 ++++++
 geode-examples/gradle.properties                |  19 +++
 .../gradle/wrapper/gradle-wrapper.jar           | Bin 0 -> 53636 bytes
 .../gradle/wrapper/gradle-wrapper.properties    |   6 +
 geode-examples/gradlew                          | 160 +++++++++++++++++++
 geode-examples/gradlew.bat                      |  90 +++++++++++
 geode-examples/replicated/README.md             |  39 +++++
 geode-examples/replicated/build.gradle          |  16 ++
 geode-examples/replicated/scripts/.gitignore    |   2 +
 geode-examples/replicated/scripts/setEnv.sh     |  24 +++
 geode-examples/replicated/scripts/startAll.sh   |  40 +++++
 geode-examples/replicated/scripts/stopAll.sh    |  22 +++
 .../geode/examples/replicated/BaseClient.java   |  63 ++++++++
 .../geode/examples/replicated/Consumer.java     |  44 +++++
 .../geode/examples/replicated/Producer.java     |  40 +++++
 .../geode/examples/replicated/ConsumerTest.java |  66 ++++++++
 .../geode/examples/replicated/ProducerTest.java |  73 +++++++++
 .../examples/replicated/ReplicatedTest.java     | 155 ++++++++++++++++++
 .../geode/examples/replicated/ShellUtil.java    |  33 ++++
 geode-examples/settings.gradle                  |  19 +++
 21 files changed, 1030 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/README.md
----------------------------------------------------------------------
diff --git a/geode-examples/README.md b/geode-examples/README.md
new file mode 100644
index 0000000..25a0dfc
--- /dev/null
+++ b/geode-examples/README.md
@@ -0,0 +1,68 @@
+# Apache Geode examples
+
+This is the home of Apache Geode examples that are bundled with the project. Contributions<sup>[2]</sup> and corrections are as usual welcome and if you have any suggestions come talk to us at [dev@geode.incubator.apache.org](mailto:dev@geode.incubator.apache.org) or just submit a [pull request](https://github.com/apache/incubator-geode/pull/new/develop).
+
+## Example requirements
+
+All examples:
+ * Needs to be testable. (unit tests, integration tests or what's applicable) - Tests will ran through project CI.
+ * Should be `Gradle` projects or part of existing ones. <sup>There could be a few exceptions here, but community should have consensus to accept</sup>
+ * Have to follow code format & style from Apache Geode <sup>[1]</sup> guidelines.
+ * Should contain a `README.md` file with step-by-step instruction on how to setup and run. (Diagrams give extra credits).
+ * Donations need to be licensed through ASL 2.0 and contributors need to file an ICLA<sup>[3]</sup>
+
+## Structure
+
+### Quick start & Installation
+
+  * [How to Install](http://geode.docs.pivotal.io/docs/getting_started/installation/install_standalone.html)
+  * [Apache Geode in 15 minutes or Less](http://geode.docs.pivotal.io/docs/getting_started/15_minute_quickstart_gfsh.html)
+
+### Basics
+
+  * [Replicated Region]()
+  * Partitioned Region
+  * Persistence
+  * OQL (Querying)
+
+### Intermediate
+
+  * PDX & Serialization
+  * Functions
+  * CacheLoader & CacheWriter
+  * Listeners
+  * Async Event Queues
+  * Continuous Querying
+  * Transactions
+  * Eviction
+  * Expiration
+  * Overflow
+  * Security
+  * Off-heap
+
+### Advanced
+
+  * WAN Gateway
+  * Durable subscriptions
+  * Delta propagation
+  * Network partition detection
+  * D-lock
+  * Compression
+  * Resource manager
+  * PDX Advanced
+
+### Use cases & integrations
+
+ This section should have self contained little projects that illustrate a use case or integration with some other projects.
+
+  * SpringBoot Application
+  * HTTP Session replication
+  * Redis
+  * Memcached
+  * Spark Connector
+
+## References
+
+- [1] - https://cwiki.apache.org/confluence/display/GEODE/Criteria+for+Code+Submissions
+- [2] - https://cwiki.apache.org/confluence/display/GEODE/How+to+Contribute
+- [3] - http://www.apache.org/licenses/#clas

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/build.gradle
----------------------------------------------------------------------
diff --git a/geode-examples/build.gradle b/geode-examples/build.gradle
new file mode 100644
index 0000000..fe0d93b
--- /dev/null
+++ b/geode-examples/build.gradle
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+
+subprojects {
+
+    apply plugin:'java'
+
+    repositories {
+        maven {
+            url "https://repository.apache.org/content/repositories/snapshots/"
+        }
+        mavenCentral()
+    }
+
+    dependencies {
+        compile "org.apache.geode:geode-core:$geodeVersion"
+//        testCompile "org.apache.geode:geode-junit:$geodeVersion"
+        testCompile "junit:junit:$junitVersion"
+        testCompile "org.mockito:mockito-core:$mockitocoreVersion"
+        compile "com.jayway.awaitility:awaitility:1.7.0"
+    }
+
+    task run(type: JavaExec) {
+        description = 'Run example'
+        def mainClass = rootProject.hasProperty('main') ? "${rootProject.getProperty('main')}" : 'Main'
+        main = "org.apache.geode.examples.${project.name}.$mainClass"
+        classpath = sourceSets.main.runtimeClasspath
+        standardInput = System.in
+        systemProperties = System.getProperties()
+        if (rootProject.hasProperty('args')) {
+            args = ["${rootProject.getProperty('args')}"]
+        }
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/gradle.properties
----------------------------------------------------------------------
diff --git a/geode-examples/gradle.properties b/geode-examples/gradle.properties
new file mode 100644
index 0000000..31e0ed5
--- /dev/null
+++ b/geode-examples/gradle.properties
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+geodeVersion = 1.0.0-incubating.M3-SNAPSHOT
+junitVersion = 4.12
+mockitocoreVersion = 1.10.19
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/gradle/wrapper/gradle-wrapper.jar
----------------------------------------------------------------------
diff --git a/geode-examples/gradle/wrapper/gradle-wrapper.jar b/geode-examples/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..9411448
Binary files /dev/null and b/geode-examples/gradle/wrapper/gradle-wrapper.jar differ

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/gradle/wrapper/gradle-wrapper.properties
----------------------------------------------------------------------
diff --git a/geode-examples/gradle/wrapper/gradle-wrapper.properties b/geode-examples/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..9af0d52
--- /dev/null
+++ b/geode-examples/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Jun 01 15:34:43 PDT 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/gradlew
----------------------------------------------------------------------
diff --git a/geode-examples/gradlew b/geode-examples/gradlew
new file mode 100755
index 0000000..9d82f78
--- /dev/null
+++ b/geode-examples/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/gradlew.bat
----------------------------------------------------------------------
diff --git a/geode-examples/gradlew.bat b/geode-examples/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/geode-examples/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/README.md
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/README.md b/geode-examples/replicated/README.md
new file mode 100644
index 0000000..d6c0936
--- /dev/null
+++ b/geode-examples/replicated/README.md
@@ -0,0 +1,39 @@
+# Geode replicated region example
+
+This is one of the most basic examples for Geode. 
+It created a replicated region and insert a couple of entries and then print the number of entries in the server.
+
+## Steps
+1. Start servers
+```
+$ scripts/startAll.sh
+```
+1. Run producer
+```
+$ gradle run -Pmain=Producer
+...
+... 
+INFO: Done. Inserted 50 entries.
+```
+1. Run consumer
+```
+$ gradle run -Pmain=Consumer
+...
+...
+INFO: Done. 50 entries available on the server(s).
+```
+1. Kill a node
+```
+$ ???
+```
+1. Run the consumer a 2nd time
+``` 
+$ gradle run -Pmain=Consumer
+...
+...
+INFO: Done. 50 entries available on the server(s).
+```
+
+This example is a simple demonstration on basic APIs of Geode as well how to write tests using mocks for Geode applications.
+
+TODO: assume jUnit4

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/build.gradle
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/build.gradle b/geode-examples/replicated/build.gradle
new file mode 100644
index 0000000..ae6f28c
--- /dev/null
+++ b/geode-examples/replicated/build.gradle
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/scripts/.gitignore
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/scripts/.gitignore b/geode-examples/replicated/scripts/.gitignore
new file mode 100644
index 0000000..32f8870
--- /dev/null
+++ b/geode-examples/replicated/scripts/.gitignore
@@ -0,0 +1,2 @@
+locator1/
+server*/

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/scripts/setEnv.sh
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/scripts/setEnv.sh b/geode-examples/replicated/scripts/setEnv.sh
new file mode 100755
index 0000000..77784ff
--- /dev/null
+++ b/geode-examples/replicated/scripts/setEnv.sh
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+#!/bin/bash
+
+## check if GEODE_HOME has been set
+: ${GEODE_HOME?"GEODE_HOME enviroment variable needs to be set"}
+
+## check if gfsh script is accessible and print version
+: ${GEODE_HOME/bin/gfsh?"gfsh doesn't seem to be available. Please check $GEODE_HOME"}
+echo "Geode version: `$GEODE_HOME/bin/gfsh version`"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/scripts/startAll.sh
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/scripts/startAll.sh b/geode-examples/replicated/scripts/startAll.sh
new file mode 100755
index 0000000..f543412
--- /dev/null
+++ b/geode-examples/replicated/scripts/startAll.sh
@@ -0,0 +1,40 @@
+#
+# 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.
+#
+#!/bin/bash
+
+set -e
+
+cd `dirname $0`
+
+. ./setEnv.sh
+
+# start a locator
+gfsh start locator --name=locator1 --mcast-port=0
+
+# start 2 servers on a random available port
+for N in {1..2}
+do
+ gfsh start server --locators=localhost[10334] --name=server$N  --server-port=0 --mcast-port=0
+done
+
+# create a region using GFSH
+gfsh -e "connect" -e "create region --name=myRegion --type=REPLICATE"
+
+gfsh -e "connect" -e "list members"
+
+exit 0
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/scripts/stopAll.sh
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/scripts/stopAll.sh b/geode-examples/replicated/scripts/stopAll.sh
new file mode 100755
index 0000000..4d792de
--- /dev/null
+++ b/geode-examples/replicated/scripts/stopAll.sh
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+#!/bin/bash
+set -e
+
+cd `dirname $0`
+
+gfsh -e "connect" -e "shutdown --include-locators=true"

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/BaseClient.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/BaseClient.java b/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/BaseClient.java
new file mode 100644
index 0000000..45349ac
--- /dev/null
+++ b/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/BaseClient.java
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+package org.apache.geode.examples.replicated;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+
+import java.util.logging.Logger;
+
+
+public abstract class BaseClient {
+
+  static final Logger logger = Logger.getAnonymousLogger();
+  protected ClientCache clientCache;
+
+  protected void setRegion(Region region) {
+    this.region = region;
+  }
+
+  private Region region;
+  private final String locatorHost = System.getProperty("locatorHost", "localhost");
+  private final int locatorPort = Integer.getInteger("locatorPort", 10334);
+  protected static final String REGION_NAME = "myRegion";
+  static final int NUM_ENTRIES = 50;
+
+  public BaseClient() {
+    this.clientCache = getClientCache();
+  }
+
+  protected Region getRegion() {
+    if (region == null) {
+      region = getClientCache()
+              .<String, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
+              .create(REGION_NAME);
+    }
+    return region;
+  }
+
+  protected ClientCache getClientCache() {
+    if (clientCache == null) {
+      clientCache = new ClientCacheFactory().addPoolLocator(locatorHost, locatorPort)
+              .set("log-level", "WARN")
+              .create();
+    }
+    return clientCache;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Consumer.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Consumer.java b/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Consumer.java
new file mode 100644
index 0000000..7fa32b1
--- /dev/null
+++ b/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Consumer.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+package org.apache.geode.examples.replicated;
+
+import com.gemstone.gemfire.cache.client.ClientCache;
+
+/**
+ * @author wmarkito
+ * @date 5/31/16.
+ */
+public class Consumer extends BaseClient {
+
+  public static void main(String[] args) {
+    new Consumer().countEntries();
+  }
+
+  public Consumer() {
+  }
+
+  public Consumer(ClientCache clientCache) {
+    this.clientCache = clientCache;
+  }
+
+  public int countEntries() {
+    int size = getRegion().keySetOnServer().size();
+    logger.info(String.format("Done. %d entries available on the server(s).", size));
+    return size;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Producer.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Producer.java b/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Producer.java
new file mode 100644
index 0000000..e25ca01
--- /dev/null
+++ b/geode-examples/replicated/src/main/java/org/apache/geode/examples/replicated/Producer.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+package org.apache.geode.examples.replicated;
+
+import com.gemstone.gemfire.cache.client.ClientCache;
+
+public class Producer extends BaseClient {
+
+  public static void main(String[] args) {
+    new Producer().populateRegion();
+  }
+
+  public Producer() {
+  }
+
+  public Producer(ClientCache clientCache) {
+    this.clientCache = clientCache;
+  }
+
+  public void populateRegion() {
+    for (int i=0; i < NUM_ENTRIES; i++) {
+      getRegion().put(i, "value" + i);
+    }
+    logger.info("Done. Inserted " + NUM_ENTRIES + " entries.");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ConsumerTest.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ConsumerTest.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ConsumerTest.java
new file mode 100644
index 0000000..3231092
--- /dev/null
+++ b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ConsumerTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+package org.apache.geode.examples.replicated;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.NoAvailableLocatorsException;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.Set;
+
+import static org.mockito.Mockito.*;
+import static org.junit.Assert.*;
+
+public class ConsumerTest {
+
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private Consumer consumer;
+  private ClientCache clientCache = mock(ClientCache.class);
+  private Region region = mock(Region.class);
+  private Set keys = mock(Set.class);
+
+  @Before
+  public void setup() {
+    when(region.getName()).thenReturn(Consumer.REGION_NAME);
+    when(keys.size()).thenReturn(Consumer.NUM_ENTRIES);
+    when(region.keySetOnServer()).thenReturn(keys);
+    when(clientCache.getRegion(any())).thenReturn(region);
+    consumer = new Consumer(clientCache);
+    consumer.setRegion(region);
+  }
+
+  @Test
+  public void countEntriesOnARegion() throws Exception {
+    assertEquals(consumer.NUM_ENTRIES, consumer.countEntries());
+  }
+
+  @Test
+  public void countEntriesOnARegionWithNoConnection() throws Exception {
+    consumer = new Consumer();
+    expectedException.expect(NoAvailableLocatorsException.class);
+    assertEquals(consumer.NUM_ENTRIES, consumer.countEntries());
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ProducerTest.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ProducerTest.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ProducerTest.java
new file mode 100644
index 0000000..85f8038
--- /dev/null
+++ b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ProducerTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+package org.apache.geode.examples.replicated;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ClientCache;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.Set;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class ProducerTest {
+
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private Producer producer;
+  private ClientCache clientCache = mock(ClientCache.class);
+  private Region region = mock(Region.class);
+  private Set keys = mock(Set.class);
+
+  @Before
+  public void setup() throws Exception {
+    when(region.getName()).thenReturn(Producer.REGION_NAME);
+    when(region.keySetOnServer()).thenReturn(keys);
+    when(clientCache.getRegion(any())).thenReturn(region);
+  }
+
+  @Test
+  public void populateRegion() throws Exception {
+    producer = new Producer(clientCache);
+    producer.setRegion(region);
+
+    producer.populateRegion();
+    verify(region, times(producer.NUM_ENTRIES)).put(any(), any());
+  }
+
+  @Test
+  public void populateWhenRegionDoesntExist() throws Exception {
+    producer = new Producer(clientCache);
+    expectedException.expect(NullPointerException.class);
+    producer.populateRegion();
+  }
+
+  @After
+  public void tearDown() {
+
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
new file mode 100644
index 0000000..aeccf7b
--- /dev/null
+++ b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ReplicatedTest.java
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+package org.apache.geode.examples.replicated;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class ReplicatedTest {
+
+  //TODO: parameterize
+  private String startScript = "/Users/wmarkito/Pivotal/ASF/incubator-geode/geode-examples/replicated/scripts/startAll.sh";
+  private String stopScript = "/Users/wmarkito/Pivotal/ASF/incubator-geode/geode-examples/replicated/scripts/stopAll.sh";
+  private boolean processRunning = false;
+  private ShellUtil shell;
+  private Process process;
+
+  private int waitTimeForScript=1000;
+
+  @Before
+  public void setup() {
+    if (processRunning) {
+      stop();
+    }
+  }
+
+  @Test
+  public void checkIfScriptsExists() throws IOException {
+//
+//    ClassLoader classLoader = getClass().getClassLoader();
+//
+//    File file = new File(classLoader.getResource("startAll.sh").getFile());
+//
+//    System.out.println(file.getCanonicalPath());
+
+    assertTrue(Paths.get(startScript).toFile().exists());
+    assertTrue(Paths.get(stopScript).toFile().exists());
+  }
+
+
+  private Process start() {
+    Process p = new ShellUtil().exec(startScript).get();
+    processRunning = true;
+    return p;
+  }
+
+  private Process stop() {
+    Process p = new ShellUtil().exec(stopScript).get();
+    processRunning = false;
+    return p;
+  }
+
+
+  @Test
+  public void testStartAndStop() throws InterruptedException {
+    boolean status = false;
+    int exitCode = -1;
+
+    process = start();
+    status =  process.waitFor(waitTimeForScript, TimeUnit.SECONDS);
+    exitCode = process.exitValue();
+    verify(status, exitCode);
+
+    process = stop();
+    status = process.waitFor(waitTimeForScript, TimeUnit.SECONDS);
+    exitCode = process.exitValue();
+    verify(status, exitCode);
+  }
+
+  private void verify(boolean status, int exitCode) {
+    assertEquals(exitCode, 0);
+    assertEquals(status, true);
+  }
+
+  @After
+  public void tearDown() {
+    if (processRunning) {
+      stop();
+    }
+  }
+
+
+//  @Test
+//  public void testStopScript() {
+//    assertEquals(0, new ShellUtil().exec(stopScript).get().exitValue());
+//  }
+
+
+//  @Test
+//  public void test() {
+//    Producer producer = new Producer();
+//    Consumer consumer = new Consumer();
+//
+//    producer.populateRegion();
+//    int numEntries = consumer.countEntries();
+//
+//    assertEquals(BaseClient.NUM_ENTRIES, numEntries);
+//  }
+//
+//  private Cache setupCacheServer() {
+//    Cache cache = new CacheFactory()
+//            .set("name", "geode-server")
+//            .set("mcast-port", "0")
+//            .set("log-file", "ReplicatedTest.log")
+//            .set("log-level", "config")
+//            .create();
+//
+//    RegionFactory<String, String> regionFactory = cache.createRegionFactory();
+//
+//    regionFactory.setDataPolicy(DataPolicy.REPLICATE);
+//
+//    Region myRegion = regionFactory.create(BaseClient.REGION_NAME);
+//
+//    assertNotNull("The /myExample Region was not properly configured and initialized!", myRegion);
+////    assertEquals(BaseClient.REGION_NAME, myRegion.getFullPath());
+//    assertEquals(BaseClient.REGION_NAME, myRegion.getName());
+//    assertTrue(myRegion.isEmpty());
+//
+//    CacheServer cacheServer = cache.addCacheServer();
+//
+//    cacheServer.setPort(0);
+//    cacheServer.setMaxConnections(5);
+//
+//    try {
+//      cacheServer.start();
+//    } catch (IOException e) {
+//      throw new RuntimeException(e);
+//    }
+//    assertTrue("Cache Server is not running!", cacheServer.isRunning());
+//
+//    return cache;
+//  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java
----------------------------------------------------------------------
diff --git a/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java
new file mode 100644
index 0000000..852ac88
--- /dev/null
+++ b/geode-examples/replicated/src/test/java/org/apache/geode/examples/replicated/ShellUtil.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package org.apache.geode.examples.replicated;
+
+import java.io.IOException;
+import java.util.Optional;
+
+public class ShellUtil {
+
+  public Optional<Process> exec(String command) {
+    try {
+      return Optional.of(Runtime.getRuntime().exec(command));
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    return Optional.empty();
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd75c732/geode-examples/settings.gradle
----------------------------------------------------------------------
diff --git a/geode-examples/settings.gradle b/geode-examples/settings.gradle
new file mode 100644
index 0000000..cb71558
--- /dev/null
+++ b/geode-examples/settings.gradle
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+rootProject.name = 'geode-examples'
+
+include 'replicated'
\ No newline at end of file