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

[01/36] incubator-geode git commit: adding the required license header to a generated test class

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1372 c31633c4e -> d6fb78341


adding the required license header to a generated test class


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

Branch: refs/heads/feature/GEODE-1372
Commit: 3fe55d4ad0701ede358c87629f3f13d4de965cfa
Parents: 625d491
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Mon May 9 16:13:38 2016 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Mon May 9 16:14:33 2016 -0700

----------------------------------------------------------------------
 .../distributed/DistributedLockBlackboard.java     | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3fe55d4a/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedLockBlackboard.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedLockBlackboard.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedLockBlackboard.java
index de8809c..e475bcc 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedLockBlackboard.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedLockBlackboard.java
@@ -1,3 +1,20 @@
+/*
+ * 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 com.gemstone.gemfire.distributed;
 
 import java.io.Serializable;


[14/36] incubator-geode git commit: GEODE-1282: fix wan off-heap leak

Posted by hi...@apache.org.
GEODE-1282: fix wan off-heap leak

destroyFromTempQueue now releases GatewaySenderEventImpl when it is removed from the tempQueue


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

Branch: refs/heads/feature/GEODE-1372
Commit: 463ae16a7c0b762abdf33d2aad1002721cccb53a
Parents: 9d28009
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Mon May 9 10:23:25 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed May 11 10:11:16 2016 -0700

----------------------------------------------------------------------
 .../internal/cache/wan/parallel/ParallelQueueRemovalMessage.java    | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/463ae16a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelQueueRemovalMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelQueueRemovalMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelQueueRemovalMessage.java
index 09f70a6..14d2f20 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelQueueRemovalMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelQueueRemovalMessage.java
@@ -237,6 +237,7 @@ public class ParallelQueueRemovalMessage extends PooledDistributionMessage {
           afterAckForSecondary_EventInTempQueue(qPR.getParallelGatewaySender(), eventForFilter);
           if (eventForFilter.getShadowKey().equals(key)) {
             itr.remove();
+            eventForFilter.release(); // GEODE-1282
             isDestroyed = true;
           }
         }


[27/36] incubator-geode git commit: GEODE-11: Integration test of lucene index with analyzers

Posted by hi...@apache.org.
GEODE-11: Integration test of lucene index with analyzers

Also moved the LuceneIndexCreationIngregrationTest to the public
package.


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

Branch: refs/heads/feature/GEODE-1372
Commit: a83e428be67e5e9f17ffa90bc2e25e36656707f5
Parents: 43a038e
Author: Dan Smith <up...@apache.org>
Authored: Wed May 11 16:40:56 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Thu May 12 11:11:48 2016 -0700

----------------------------------------------------------------------
 .../gemfire/cache/lucene/LuceneService.java     |   4 +-
 .../LuceneIndexForPartitionedRegion.java        |   4 +-
 .../LuceneIndexCreationIntegrationTest.java     | 122 +++++++++++++++++++
 .../cache/lucene/LuceneIntegrationTest.java     |  55 +++++++++
 .../lucene/LuceneQueriesIntegrationTest.java    |  21 +---
 .../LuceneIndexCreationIntegrationTest.java     |  74 -----------
 .../lucene/internal/LuceneIntegrationTest.java  |  47 -------
 7 files changed, 181 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a83e428b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneService.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneService.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneService.java
index a42ab72..462aa7e 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneService.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneService.java
@@ -80,10 +80,8 @@ public interface LuceneService {
    * @param indexName index name
    * @param regionPath region name
    * @param analyzerPerField analyzer per field map
-   * @deprecated TODO This feature is not yet implemented
    */
-  @Deprecated
-  public void createIndex(String indexName, String regionPath,  
+  public void createIndex(String indexName, String regionPath,
       Map<String, Analyzer> analyzerPerField);
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a83e428b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index 382f61c..dd9d384 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -138,7 +138,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     return createRegion(fileRegionName, regionShortCut, this.regionPath, partitionAttributes);
   }
 
-  String createFileRegionName() {
+  public String createFileRegionName() {
     return LuceneServiceImpl.getUniqueIndexName(indexName, regionPath)+".files";
   }
 
@@ -152,7 +152,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     return createRegion(chunkRegionName, regionShortCut, fileRegionName, partitionAttributes);
   }
 
-  String createChunkRegionName() {
+  public String createChunkRegionName() {
     return LuceneServiceImpl.getUniqueIndexName(indexName, regionPath) + ".chunks";
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a83e428b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
new file mode 100644
index 0000000..1dfaf51
--- /dev/null
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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 com.gemstone.gemfire.cache.lucene;
+
+import static org.junit.Assert.*;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.lucene.LuceneIndex;
+import com.gemstone.gemfire.cache.lucene.LuceneIntegrationTest;
+import com.gemstone.gemfire.cache.lucene.LuceneServiceProvider;
+import com.gemstone.gemfire.cache.lucene.internal.LuceneIndexForPartitionedRegion;
+import com.gemstone.gemfire.internal.cache.BucketNotFoundException;
+import com.gemstone.gemfire.internal.cache.LocalRegion;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.jayway.awaitility.Awaitility;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.core.KeywordTokenizer;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(IntegrationTest.class)
+public class LuceneIndexCreationIntegrationTest extends LuceneIntegrationTest {
+  public static final String INDEX_NAME = "index";
+  public static final String REGION_NAME = "region";
+
+  @Test
+  public void shouldCreateIndexWriterWithAnalyzersWhenSettingPerFieldAnalyzers()
+    throws BucketNotFoundException, InterruptedException
+  {
+    Map<String, Analyzer> analyzers = new HashMap<>();
+
+    final RecordingAnalyzer field1Analyzer = new RecordingAnalyzer();
+    final RecordingAnalyzer field2Analyzer = new RecordingAnalyzer();
+    analyzers.put("field1", field1Analyzer);
+    analyzers.put("field2", field2Analyzer);
+    luceneService.createIndex(INDEX_NAME, REGION_NAME, analyzers);
+    Region region = createRegion();
+    final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
+    region.put("key1", new TestObject());
+
+    assertEquals(analyzers, index.getFieldAnalyzers());
+    Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
+      assertEquals(Arrays.asList("field1"), field1Analyzer.analyzedfields);
+      assertEquals(Arrays.asList("field2"), field2Analyzer.analyzedfields);
+    });
+  }
+
+  @Test
+  public void verifyLuceneRegionInternal() {
+    createIndex("text");
+
+    // Create partitioned region
+    createRegion();
+
+    // Get index
+    LuceneIndexForPartitionedRegion index = (LuceneIndexForPartitionedRegion) luceneService.getIndex(INDEX_NAME, REGION_NAME);
+
+    // Verify the meta regions exist and are internal
+    LocalRegion chunkRegion = (LocalRegion) cache.getRegion(index.createChunkRegionName());
+    assertTrue(chunkRegion.isInternalRegion());
+    LocalRegion fileRegion = (LocalRegion) cache.getRegion(index.createFileRegionName());
+    assertTrue(fileRegion.isInternalRegion());
+
+    // Verify the meta regions are not contained in the root regions
+    for (Region region : cache.rootRegions()) {
+      assertNotEquals(chunkRegion.getFullPath(), region.getFullPath());
+      assertNotEquals(fileRegion.getFullPath(), region.getFullPath());
+    }
+  }
+
+  private Region createRegion() {
+    return this.cache.createRegionFactory(RegionShortcut.PARTITION).create(REGION_NAME);
+  }
+
+  private void createIndex(String fieldName) {
+    LuceneServiceProvider.get(this.cache).createIndex(INDEX_NAME, REGION_NAME, fieldName);
+  }
+
+  private static class TestObject implements Serializable {
+
+    String field1 = "a b c d";
+    String field2 = "f g h";
+  }
+
+  private static class RecordingAnalyzer extends Analyzer {
+
+    private List<String> analyzedfields = new ArrayList<String>();
+
+    @Override protected TokenStreamComponents createComponents(final String fieldName) {
+      analyzedfields.add(fieldName);
+      return new TokenStreamComponents(new KeywordTokenizer());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a83e428b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIntegrationTest.java
new file mode 100644
index 0000000..8c6f59e
--- /dev/null
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIntegrationTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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 com.gemstone.gemfire.cache.lucene;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.lucene.LuceneService;
+import com.gemstone.gemfire.cache.lucene.LuceneServiceProvider;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+public class LuceneIntegrationTest {
+
+  protected Cache cache;
+  protected LuceneService luceneService;
+
+  @Rule
+  public TestName name = new TestName();
+
+  @After
+  public void tearDown() {
+    if(this.cache != null) {
+      this.cache.close();
+    }
+  }
+
+  @Before
+  public void createCache() {
+    CacheFactory cf = new CacheFactory();
+    cf.set("mcast-port", "0");
+    cf.set("locators", "");
+    this.cache = cf.create();
+    luceneService = LuceneServiceProvider.get(this.cache);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a83e428b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesIntegrationTest.java
index 9009e3d..2262339 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesIntegrationTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesIntegrationTest.java
@@ -19,17 +19,12 @@ package com.gemstone.gemfire.cache.lucene;
 import static org.hamcrest.Matchers.isA;
 import static org.junit.Assert.*;
 
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.execute.FunctionException;
 import com.gemstone.gemfire.cache.query.QueryException;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -39,25 +34,11 @@ import org.junit.rules.ExpectedException;
  * This class contains tests of lucene queries that can fit
  */
 @Category(IntegrationTest.class)
-public class LuceneQueriesIntegrationTest {
+public class LuceneQueriesIntegrationTest extends LuceneIntegrationTest {
   @Rule
   public ExpectedException thrown = ExpectedException.none();
   private static final String INDEX_NAME = "index";
   protected static final String REGION_NAME = "index";
-  Cache cache;
-
-  @Before
-  public void createCache() {
-    cache = new CacheFactory()
-      .set("mcast-port", "0")
-      .set("locators", "")
-      .set("log-level", "warning").create();
-  }
-
-  @After
-  public void closeCache() {
-    cache.close();
-  }
 
   @Test()
   public void throwFunctionExceptionWhenGivenBadQuery() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a83e428b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationIntegrationTest.java
deleted file mode 100644
index e04d1c7..0000000
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationIntegrationTest.java
+++ /dev/null
@@ -1,74 +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 com.gemstone.gemfire.cache.lucene.internal;
-
-import static org.junit.Assert.*;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache.lucene.LuceneServiceProvider;
-import com.gemstone.gemfire.internal.cache.LocalRegion;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category(IntegrationTest.class)
-public class LuceneIndexCreationIntegrationTest extends LuceneIntegrationTest {
-
-  @Test
-  public void verifyLuceneRegionInternal() {
-    // Create cache
-    createCache();
-
-    // Create index
-    String indexName = "index";
-    String regionName = this.name.getMethodName();
-    createIndex(indexName, regionName, "text");
-
-    // Create partitioned region
-    createRegion(regionName);
-
-    // Get index
-    LuceneIndexForPartitionedRegion index = (LuceneIndexForPartitionedRegion) LuceneServiceProvider.get(this.cache).getIndex(indexName, regionName);
-    assertNotNull(index);
-
-    // Verify the meta regions exist and are internal
-    LocalRegion chunkRegion = (LocalRegion) this.cache.getRegion(index.createChunkRegionName());
-    assertNotNull(chunkRegion);
-    assertTrue(chunkRegion.isInternalRegion());
-    LocalRegion fileRegion = (LocalRegion) this.cache.getRegion(index.createFileRegionName());
-    assertNotNull(fileRegion);
-    assertTrue(fileRegion.isInternalRegion());
-
-    // Verify the meta regions are not contained in the root regions
-    for (Region region : cache.rootRegions()) {
-      assertNotEquals(chunkRegion.getFullPath(), region.getFullPath());
-      assertNotEquals(fileRegion.getFullPath(), region.getFullPath());
-    }
-  }
-
-  private Region createRegion(String regionName) {
-    return this.cache.createRegionFactory(RegionShortcut.PARTITION).create(regionName);
-  }
-
-  private void createIndex(String indexName, String regionName, String fieldName) {
-    LuceneServiceProvider.get(this.cache).createIndex(indexName, regionName, fieldName);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a83e428b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIntegrationTest.java
deleted file mode 100644
index 4d94042..0000000
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIntegrationTest.java
+++ /dev/null
@@ -1,47 +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 com.gemstone.gemfire.cache.lucene.internal;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import org.junit.After;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-
-public class LuceneIntegrationTest {
-
-  protected Cache cache;
-
-  @Rule
-  public TestName name = new TestName();
-
-  @After
-  public void tearDown() {
-    if(this.cache != null) {
-      this.cache.close();
-    }
-  }
-
-  protected void createCache() {
-    CacheFactory cf = new CacheFactory();
-    cf.set("mcast-port", "0");
-    this.cache = cf.create();
-  }
-}


[35/36] incubator-geode git commit: Merge branch 'feature/GEODE-1372' of https://git-wip-us.apache.org/repos/asf/incubator-geode into GEODE-1372

Posted by hi...@apache.org.
Merge branch 'feature/GEODE-1372' of https://git-wip-us.apache.org/repos/asf/incubator-geode into GEODE-1372


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

Branch: refs/heads/feature/GEODE-1372
Commit: 4d5f94778c8a38966a201fa9a3024b4ddbd34120
Parents: a08172f c31633c
Author: Hitesh Khamesra <hi...@yahoo.com>
Authored: Thu May 19 10:53:28 2016 -0700
Committer: Hitesh Khamesra <hi...@yahoo.com>
Committed: Thu May 19 10:53:28 2016 -0700

----------------------------------------------------------------------
 .../membership/gms/messenger/GMSEncrypt.java    | 233 ++++++++-----------
 .../gms/messenger/GMSEncryptJUnitTest.java      |  13 +-
 2 files changed, 109 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d5f9477/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
----------------------------------------------------------------------
diff --cc geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
index 3d3633d,7cec567..f307290
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
@@@ -42,86 -43,64 +42,77 @@@ import org.apache.logging.log4j.Logger
  import com.gemstone.gemfire.distributed.internal.DistributionConfig;
  import com.gemstone.gemfire.internal.logging.LogService;
  
--public class GMSEncrypt implements Cloneable{
--  
++public class GMSEncrypt implements Cloneable {
++
    public static long encodingsPerformed;
    public static long decodingsPerformed;
  
    private static final Logger logger = LogService.getLogger();
  
    // Parameters for the Diffie-Hellman key exchange
--  private static final BigInteger dhP = new BigInteger(
--    "13528702063991073999718992897071702177131142188276542919088770094024269"
--      +  "73079899070080419278066109785292538223079165925365098181867673946"
--      +  "34756714063947534092593553024224277712367371302394452615862654308"
--      +  "11180902979719649450105660478776364198726078338308557022096810447"
--      +  "3500348898008043285865193451061481841186553");
--
--  private static final BigInteger dhG = new BigInteger(
--    "13058345680719715096166513407513969537624553636623932169016704425008150"
--      +  "56576152779768716554354314319087014857769741104157332735258102835"
--      +  "93126577393912282416840649805564834470583437473176415335737232689"
--      +  "81480201869671811010996732593655666464627559582258861254878896534"
--      +  "1273697569202082715873518528062345259949959");
++  private static final BigInteger dhP = new BigInteger("13528702063991073999718992897071702177131142188276542919088770094024269" + "73079899070080419278066109785292538223079165925365098181867673946"
++      + "34756714063947534092593553024224277712367371302394452615862654308" + "11180902979719649450105660478776364198726078338308557022096810447" + "3500348898008043285865193451061481841186553");
++
++  private static final BigInteger dhG = new BigInteger("13058345680719715096166513407513969537624553636623932169016704425008150" + "56576152779768716554354314319087014857769741104157332735258102835"
++      + "93126577393912282416840649805564834470583437473176415335737232689" + "81480201869671811010996732593655666464627559582258861254878896534" + "1273697569202082715873518528062345259949959");
  
    private static final int dhL = 1023;
  
--  private  PrivateKey dhPrivateKey = null;
++  private PrivateKey dhPrivateKey = null;
  
--  private  PublicKey dhPublicKey = null;
++  private PublicKey dhPublicKey = null;
  
--  private  String dhSKAlgo = null;
++  private String dhSKAlgo = null;
  
    private Services services;
-   
+ 
 +  private InternalDistributedMember localMember;
 +
    private NetView view;
  
    private Map<InternalDistributedMember, PeerEncryptor> memberToPeerEncryptor = new ConcurrentHashMap<>();
-   
-   private ClusterEncryptor clusterEncryptor;
  
++  private ClusterEncryptor clusterEncryptor;
  
 -  protected void installView(NetView view) {
 +  protected void installView(NetView view) throws Exception {
      this.view = view;
      this.view.setPublicKey(services.getJoinLeave().getMemberID(), getPublicKeyBytes());
 -    // TODO remove ciphers for departed members
    }
--  
 -  protected void installView(NetView view, InternalDistributedMember mbr) {
++
 +  protected void installView(NetView view, InternalDistributedMember mbr) throws Exception {
      this.view = view;
-    // this.view.setPublicKey(mbr, getPublicKeyBytes());
 -    this.view.setPublicKey(mbr, getPublicKeyBytes());
++    // this.view.setPublicKey(mbr, getPublicKeyBytes());
      // TODO remove ciphers for departed members
-     //addClusterKey();
++    // addClusterKey();
 +  }
-   
++
 +  protected byte[] getSecretBytes() {
 +    return this.clusterEncryptor.secretBytes;
 +  }
-   
++
 +  protected synchronized void addClusterKey() throws Exception {
 +    this.clusterEncryptor = new ClusterEncryptor(this);
 +  }
-   
++
 +  protected synchronized void addClusterKey(byte[] secretBytes) throws Exception {
 +    this.clusterEncryptor = new ClusterEncryptor(secretBytes);
    }
  
    protected GMSEncrypt() {
--    
++
    }
  
--  public GMSEncrypt(Services services) throws  Exception {
++  public GMSEncrypt(Services services) throws Exception {
      this.services = services;
      initDHKeys(services.getConfig().getDistributionConfig());
    }
-   
-   public GMSEncrypt(Services services, InternalDistributedMember mbr) throws  Exception {
+ 
++  public GMSEncrypt(Services services, InternalDistributedMember mbr) throws Exception {
 +    this.services = services;
 +    this.localMember = mbr;
 +    initDHKeys(services.getConfig().getDistributionConfig());
 +  }
 +
    public byte[] decryptData(byte[] data, InternalDistributedMember member) throws Exception {
      return getPeerEncryptor(member).decryptBytes(data);
    }
@@@ -129,16 -108,7 +120,15 @@@
    public byte[] encryptData(byte[] data, InternalDistributedMember member) throws Exception {
      return getPeerEncryptor(member).encryptBytes(data);
    }
-   
  
 +  public byte[] decryptData(byte[] data) throws Exception {
 +    return this.clusterEncryptor.decryptBytes(data);
 +  }
 +
 +  public byte[] encryptData(byte[] data) throws Exception {
 +    return this.clusterEncryptor.encryptBytes(data);
 +  }
 +
    protected byte[] getPublicKeyBytes() {
      return dhPublicKey.getEncoded();
    }
@@@ -158,7 -127,7 +148,7 @@@
        System.out.println("private key format " + format);
        System.out.println("public ksy format " + this.dhPublicKey.getFormat());
        PKCS8EncodedKeySpec x509KeySpecPKey = new PKCS8EncodedKeySpec(this.dhPrivateKey.getEncoded());
--      
++
        keyFact = KeyFactory.getInstance("DH");
        // PublicKey pubKey = keyFact.generatePublic(x509KeySpec);
        gmsEncrypt.dhPrivateKey = keyFact.generatePrivate(x509KeySpecPKey);
@@@ -190,7 -162,7 +180,7 @@@
      }
    }
  
--  protected synchronized PeerEncryptor getPeerEncryptor(InternalDistributedMember member) throws Exception{
++  protected synchronized PeerEncryptor getPeerEncryptor(InternalDistributedMember member) throws Exception {
      PeerEncryptor result = memberToPeerEncryptor.get(member);
      if (result == null) {
        result = createPeerEncryptor(member);
@@@ -205,7 -177,7 +195,6 @@@
      return result;
    }
  
--
    private static int getKeySize(String skAlgo) {
      // skAlgo contain both algo and key size info
      int colIdx = skAlgo.indexOf(':');
@@@ -214,20 -186,20 +203,16 @@@
      if (colIdx >= 0) {
        algoStr = skAlgo.substring(0, colIdx);
        algoKeySize = Integer.parseInt(skAlgo.substring(colIdx + 1));
--    }
--    else {
++    } else {
        algoStr = skAlgo;
      }
      int keysize = -1;
      if (algoStr.equalsIgnoreCase("DESede")) {
        keysize = 24;
--    }
--    else if (algoStr.equalsIgnoreCase("Blowfish")) {
++    } else if (algoStr.equalsIgnoreCase("Blowfish")) {
        keysize = algoKeySize > 128 ? algoKeySize / 8 : 16;
--    }
--    else if (algoStr.equalsIgnoreCase("AES")) {
--      keysize = (algoKeySize != 192 && algoKeySize != 256) ? 16
--        : algoKeySize / 8;
++    } else if (algoStr.equalsIgnoreCase("AES")) {
++      keysize = (algoKeySize != 192 && algoKeySize != 256) ? 16 : algoKeySize / 8;
      }
      return keysize;
    }
@@@ -237,8 -209,8 +222,7 @@@
      String algoStr;
      if (colIdx >= 0) {
        algoStr = skAlgo.substring(0, colIdx);
--    }
--    else {
++    } else {
        algoStr = skAlgo;
      }
      return algoStr;
@@@ -249,75 -221,101 +233,69 @@@
      String algoStr = getDhAlgoStr(skAlgo);
      if (algoStr.equalsIgnoreCase("DESede")) {
        blocksize = 8;
--    }
--    else if (algoStr.equalsIgnoreCase("Blowfish")) {
++    } else if (algoStr.equalsIgnoreCase("Blowfish")) {
        blocksize = 8;
--    }
--    else if (algoStr.equalsIgnoreCase("AES")) {
++    } else if (algoStr.equalsIgnoreCase("AES")) {
        blocksize = 16;
      }
      return blocksize;
    }
  
--  static public byte[] encryptBytes(byte[] data, Cipher encrypt) throws Exception{
--    synchronized(GMSEncrypt.class) {
++  static public byte[] encryptBytes(byte[] data, Cipher encrypt) throws Exception {
++    synchronized (GMSEncrypt.class) {
        encodingsPerformed++;
      }
      return encrypt.doFinal(data);
    }
  
--  static public byte[] decryptBytes(byte[] data, Cipher decrypt)
--    throws Exception{
++  static public byte[] decryptBytes(byte[] data, Cipher decrypt) throws Exception {
      try {
        byte[] decryptBytes = decrypt.doFinal(data);
--      synchronized(GMSEncrypt.class) {
++      synchronized (GMSEncrypt.class) {
          decodingsPerformed++;
        }
        return decryptBytes;
--    }catch(Exception ex) {
++    } catch (Exception ex) {
        throw ex;
      }
    }
  
--
    protected class PeerEncryptor {
  
      private PublicKey peerPublicKey = null;
  
      private String peerSKAlgo = null;
  
 -    private Cipher _encrypt;
 +    private Cipher encrypt;
-     
+ 
 -    protected PeerEncryptor(byte[] peerPublicKeyBytes) throws NoSuchAlgorithmException, InvalidKeySpecException {
 -      X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(peerPublicKeyBytes);
 -      KeyFactory keyFact = KeyFactory.getInstance("DH");
 -      //PublicKey pubKey = keyFact.generatePublic(x509KeySpec);
 -      this.peerPublicKey = keyFact.generatePublic(x509KeySpec);
 +    private Cipher decrypt = null;
 +
 +    protected PeerEncryptor(byte[] peerPublicKeyBytes) throws Exception {
 +      this.peerPublicKey = getPublicKey(peerPublicKeyBytes);
      }
  
--    public byte [] encryptBytes(byte[] data) throws Exception {
++    public byte[] encryptBytes(byte[] data) throws Exception {
        String algo = null;
        if (this.peerSKAlgo != null) {
          algo = this.peerSKAlgo;
        } else {
          algo = dhSKAlgo;
        }
 -      return GMSEncrypt.encryptBytes(data, getEncryptCipher(algo, this.peerPublicKey));
 +      return GMSEncrypt.encryptBytes(data, getEncryptCipher(algo));
      }
  
-     private Cipher getEncryptCipher(String dhSKAlgo)
 -    private Cipher getEncryptCipher(String dhSKAlgo, PublicKey publicKey)
--      throws Exception{
++    private Cipher getEncryptCipher(String dhSKAlgo) throws Exception {
        try {
-         if(encrypt == null) {
 -        if(_encrypt == null) {
 -          KeyAgreement ka = KeyAgreement.getInstance("DH");
 -          ka.init(dhPrivateKey);
 -          ka.doPhase(publicKey, true);
 -
 -          Cipher encrypt;
 -
 -          int keysize = getKeySize(dhSKAlgo);
 -          int blocksize = getBlockSize(dhSKAlgo);
 -
 -          if (keysize == -1 || blocksize == -1) {
 -            SecretKey sKey = ka.generateSecret(dhSKAlgo);
 -            encrypt = Cipher.getInstance(dhSKAlgo);
 -            encrypt.init(Cipher.ENCRYPT_MODE, sKey);
 -          }
 -          else {
 -            String dhAlgoStr = getDhAlgoStr(dhSKAlgo);
 -
 -            byte[] sKeyBytes = ka.generateSecret();
 -            SecretKeySpec sks = new SecretKeySpec(sKeyBytes, 0, keysize, dhAlgoStr);
 -            IvParameterSpec ivps = new IvParameterSpec(sKeyBytes, keysize, blocksize);
 -
 -            encrypt = Cipher.getInstance(dhAlgoStr + "/CBC/PKCS5Padding");
 -            encrypt.init(Cipher.ENCRYPT_MODE, sks, ivps);
 -          }
 -          _encrypt = encrypt;
++        if (encrypt == null) {
 +          encrypt = GMSEncrypt.getEncryptCipher(dhSKAlgo, dhPrivateKey, this.peerPublicKey);
          }
--      }catch(Exception ex) {
++      } catch (Exception ex) {
          throw ex;
        }
 -      return _encrypt;
 +      return encrypt;
      }
-     
-     public byte[] decryptBytes(byte[] data) throws Exception
-     {
+ 
 -
 -    public byte[] decryptBytes(byte[] data) throws Exception
 -    {
++    public byte[] decryptBytes(byte[] data) throws Exception {
        String algo = null;
        if (this.peerSKAlgo != null) {
          algo = this.peerSKAlgo;
@@@ -327,213 -325,48 +305,206 @@@
        Cipher c = getDecryptCipher(algo, this.peerPublicKey);
        return GMSEncrypt.decryptBytes(data, c);
  
-     }    
+     }
  
-     private Cipher getDecryptCipher( String dhSKAlgo, PublicKey publicKey)
-       throws Exception{
-       if(decrypt == null) {
++    private Cipher getDecryptCipher(String dhSKAlgo, PublicKey publicKey) throws Exception {
++      if (decrypt == null) {
 +        decrypt = GMSEncrypt.getDecryptCipher(dhSKAlgo, dhPrivateKey, this.peerPublicKey);
 +      }
 +      return decrypt;
 +    }
 +
 +  }
  
-   protected static Cipher getEncryptCipher(String dhSKAlgo, PrivateKey privateKey, PublicKey peerPublicKey) 
-     throws Exception{
++  protected static Cipher getEncryptCipher(String dhSKAlgo, PrivateKey privateKey, PublicKey peerPublicKey) throws Exception {
 +    KeyAgreement ka = KeyAgreement.getInstance("DH");
 +    ka.init(privateKey);
 +    ka.doPhase(peerPublicKey, true);
-     
+ 
 -    private Cipher _decrypt = null;
 +    Cipher encrypt;
  
 -    private Cipher getDecryptCipher( String dhSKAlgo, PublicKey publicKey)
 -      throws Exception{
 -      if(_decrypt == null) {
 -        try {
 -          KeyAgreement ka = KeyAgreement.getInstance("DH");
 -          ka.init(dhPrivateKey);
 -          ka.doPhase(publicKey, true);
 +    int keysize = getKeySize(dhSKAlgo);
 +    int blocksize = getBlockSize(dhSKAlgo);
  
 -          Cipher decrypt;
 +    if (keysize == -1 || blocksize == -1) {
 +      SecretKey sKey = ka.generateSecret(dhSKAlgo);
 +      encrypt = Cipher.getInstance(dhSKAlgo);
 +      encrypt.init(Cipher.ENCRYPT_MODE, sKey);
-     }
-     else {
++    } else {
 +      String dhAlgoStr = getDhAlgoStr(dhSKAlgo);
  
 -          int keysize = getKeySize(dhSKAlgo);
 -          int blocksize = getBlockSize(dhSKAlgo);
 +      byte[] sKeyBytes = ka.generateSecret();
 +      SecretKeySpec sks = new SecretKeySpec(sKeyBytes, 0, keysize, dhAlgoStr);
 +      IvParameterSpec ivps = new IvParameterSpec(sKeyBytes, keysize, blocksize);
  
 -          if (keysize == -1 || blocksize == -1) {
 -            SecretKey sKey = ka.generateSecret(dhSKAlgo);
 -            decrypt = Cipher.getInstance(dhSKAlgo);
 -            decrypt.init(Cipher.DECRYPT_MODE, sKey);
 -          }
 -          else {
 -            String algoStr = getDhAlgoStr(dhSKAlgo);
 +      encrypt = Cipher.getInstance(dhAlgoStr + "/CBC/PKCS5Padding");
 +      encrypt.init(Cipher.ENCRYPT_MODE, sks, ivps);
 +    }
  
 -            byte[] sKeyBytes = ka.generateSecret();
 -            SecretKeySpec sks = new SecretKeySpec(sKeyBytes, 0, keysize, algoStr);
 -            IvParameterSpec ivps = new IvParameterSpec(sKeyBytes, keysize, blocksize);
 +    return encrypt;
 +  }
-   
-   protected static Cipher getEncryptCipher(String dhSKAlgo, byte[] secretBytes) 
-       throws Exception{
-       
-       Cipher encrypt = null;
- 
-       int keysize = getKeySize(dhSKAlgo);
-       int blocksize = getBlockSize(dhSKAlgo);
- 
-       if (keysize == -1 || blocksize == -1) {
-         //TODO how should we do here
-         /*SecretKey sKey = ka.generateSecret(dhSKAlgo);
-         encrypt = Cipher.getInstance(dhSKAlgo);
-         encrypt.init(Cipher.ENCRYPT_MODE, sKey);*/
-       }
-       else {
-         String dhAlgoStr = getDhAlgoStr(dhSKAlgo);
  
-         SecretKeySpec sks = new SecretKeySpec(secretBytes, 0, keysize, dhAlgoStr);
-         IvParameterSpec ivps = new IvParameterSpec(secretBytes, keysize, blocksize);
 -            decrypt = Cipher.getInstance(algoStr + "/CBC/PKCS5Padding");
 -            decrypt.init(Cipher.DECRYPT_MODE, sks, ivps);
 -          }
++  protected static Cipher getEncryptCipher(String dhSKAlgo, byte[] secretBytes) throws Exception {
  
-         encrypt = Cipher.getInstance(dhAlgoStr + "/CBC/PKCS5Padding");
-         encrypt.init(Cipher.ENCRYPT_MODE, sks, ivps);
-       }
 -          _decrypt = decrypt;
 -        }catch(Exception ex) {
 -          throw ex;
++    Cipher encrypt = null;
 +
-       return encrypt;
++    int keysize = getKeySize(dhSKAlgo);
++    int blocksize = getBlockSize(dhSKAlgo);
++
++    if (keysize == -1 || blocksize == -1) {
++      // TODO how should we do here
++      /* SecretKey sKey = ka.generateSecret(dhSKAlgo);
++       * encrypt = Cipher.getInstance(dhSKAlgo);
++       * encrypt.init(Cipher.ENCRYPT_MODE, sKey); */
++    } else {
++      String dhAlgoStr = getDhAlgoStr(dhSKAlgo);
++
++      SecretKeySpec sks = new SecretKeySpec(secretBytes, 0, keysize, dhAlgoStr);
++      IvParameterSpec ivps = new IvParameterSpec(secretBytes, keysize, blocksize);
++
++      encrypt = Cipher.getInstance(dhAlgoStr + "/CBC/PKCS5Padding");
++      encrypt.init(Cipher.ENCRYPT_MODE, sks, ivps);
 +    }
-   
++
++    return encrypt;
++  }
++
 +  protected static Cipher getDecryptCipher(String dhSKAlgo, PrivateKey privateKey, PublicKey publicKey) throws Exception {
 +    KeyAgreement ka = KeyAgreement.getInstance("DH");
 +    ka.init(privateKey);
 +    ka.doPhase(publicKey, true);
-     
++
 +    Cipher decrypt;
 +
 +    int keysize = getKeySize(dhSKAlgo);
 +    int blocksize = getBlockSize(dhSKAlgo);
 +
 +    if (keysize == -1 || blocksize == -1) {
 +      SecretKey sKey = ka.generateSecret(dhSKAlgo);
 +      decrypt = Cipher.getInstance(dhSKAlgo);
 +      decrypt.init(Cipher.DECRYPT_MODE, sKey);
 +    } else {
 +      String algoStr = getDhAlgoStr(dhSKAlgo);
 +
 +      byte[] sKeyBytes = ka.generateSecret();
 +      SecretKeySpec sks = new SecretKeySpec(sKeyBytes, 0, keysize, algoStr);
 +      IvParameterSpec ivps = new IvParameterSpec(sKeyBytes, keysize, blocksize);
 +
 +      decrypt = Cipher.getInstance(algoStr + "/CBC/PKCS5Padding");
 +      decrypt.init(Cipher.DECRYPT_MODE, sks, ivps);
 +    }
 +    return decrypt;
 +  }
-   
++
 +  protected static Cipher getDecryptCipher(String dhSKAlgo, byte[] secretBytes) throws Exception {
 +    Cipher decrypt = null;
 +
 +    int keysize = getKeySize(dhSKAlgo);
 +    int blocksize = getBlockSize(dhSKAlgo);
 +
 +    if (keysize == -1 || blocksize == -1) {
-       //TODO: how to do here
-       /*SecretKey sKey = ka.generateSecret(dhSKAlgo);
-       decrypt = Cipher.getInstance(dhSKAlgo);
-       decrypt.init(Cipher.DECRYPT_MODE, sKey);*/
++      // TODO: how to do here
++      /* SecretKey sKey = ka.generateSecret(dhSKAlgo);
++       * decrypt = Cipher.getInstance(dhSKAlgo);
++       * decrypt.init(Cipher.DECRYPT_MODE, sKey); */
 +    } else {
 +      String algoStr = getDhAlgoStr(dhSKAlgo);
 +
 +      SecretKeySpec sks = new SecretKeySpec(secretBytes, 0, keysize, algoStr);
 +      IvParameterSpec ivps = new IvParameterSpec(secretBytes, keysize, blocksize);
 +
 +      decrypt = Cipher.getInstance(algoStr + "/CBC/PKCS5Padding");
 +      decrypt.init(Cipher.DECRYPT_MODE, sks, ivps);
 +    }
 +    return decrypt;
 +  }
++
 +  protected static byte[] generateSecret(String dhSKAlgo, PrivateKey privateKey, PublicKey otherPublicKey) throws Exception {
 +    KeyAgreement ka = KeyAgreement.getInstance("DH");
 +    ka.init(privateKey);
 +    ka.doPhase(otherPublicKey, true);
-     
++
 +    int keysize = getKeySize(dhSKAlgo);
 +    int blocksize = getBlockSize(dhSKAlgo);
 +
 +    if (keysize == -1 || blocksize == -1) {
 +      SecretKey sKey = ka.generateSecret(dhSKAlgo);
 +      return sKey.getEncoded();
 +    } else {
 +      String algoStr = getDhAlgoStr(dhSKAlgo);
 +
 +      return ka.generateSecret();
 +    }
 +  }
-   
++
 +  protected static PublicKey getPublicKey(byte[] publicKeyBytes) throws Exception {
 +    X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(publicKeyBytes);
 +    KeyFactory keyFact = KeyFactory.getInstance("DH");
-     //PublicKey pubKey = keyFact.generatePublic(x509KeySpec);
++    // PublicKey pubKey = keyFact.generatePublic(x509KeySpec);
 +    return keyFact.generatePublic(x509KeySpec);
 +  }
 +
-   protected static void initEncryptCipher(KeyAgreement ka, List<PublicKey> publicKeys) throws Exception{
++  protected static void initEncryptCipher(KeyAgreement ka, List<PublicKey> publicKeys) throws Exception {
 +    Iterator<PublicKey> itr = publicKeys.iterator();
-     while(itr.hasNext()) {
-        ka.doPhase(itr.next(), !itr.hasNext());
++    while (itr.hasNext()) {
++      ka.doPhase(itr.next(), !itr.hasNext());
 +    }
 +  }
++
 +  /***
 +   * this will hold the common key for cluster
 +   * that will be created using publickey of all the members..
 +   *
 +   */
-   protected class ClusterEncryptor{
++  protected class ClusterEncryptor {
 +    byte[] secretBytes;
 +    Cipher encrypt;
 +    Cipher decrypt;
 +    int viewId;
 +    Set<InternalDistributedMember> mbrs;
-     
++
 +    public ClusterEncryptor(GMSEncrypt other) throws Exception {
-       GMSEncrypt mine = new GMSEncrypt(other.services);      
++      GMSEncrypt mine = new GMSEncrypt(other.services);
 +      this.secretBytes = GMSEncrypt.generateSecret(mine.dhSKAlgo, mine.dhPrivateKey, other.dhPublicKey);
 +    }
-     
++
 +    public ClusterEncryptor(byte[] sb) {
 +      this.secretBytes = sb;
 +    }
-     
-     public byte [] encryptBytes(byte[] data) throws Exception {
++
++    public byte[] encryptBytes(byte[] data) throws Exception {
 +      String algo = dhSKAlgo;
 +      return GMSEncrypt.encryptBytes(data, getEncryptCipher(algo));
 +    }
 +
-     private Cipher getEncryptCipher(String dhSKAlgo)
-       throws Exception{
++    private Cipher getEncryptCipher(String dhSKAlgo) throws Exception {
 +      try {
-         if(encrypt == null) {
++        if (encrypt == null) {
 +          synchronized (this) {
-             if(encrypt == null)
++            if (encrypt == null)
 +              encrypt = GMSEncrypt.getEncryptCipher(dhSKAlgo, secretBytes);
-           }          
++          }
          }
-       }catch(Exception ex) {
++      } catch (Exception ex) {
 +        throw ex;
        }
 -      return _decrypt;
 +      return encrypt;
      }
-     
-     public byte[] decryptBytes(byte[] data) throws Exception
-     {
+ 
++    public byte[] decryptBytes(byte[] data) throws Exception {
 +      String algo = dhSKAlgo;
 +      Cipher c = getDecryptCipher(algo);
 +      return GMSEncrypt.decryptBytes(data, c);
 +    }
 +
-     private Cipher getDecryptCipher( String dhSKAlgo)
-       throws Exception{
-       if(decrypt == null) {
++    private Cipher getDecryptCipher(String dhSKAlgo) throws Exception {
++      if (decrypt == null) {
 +        synchronized (this) {
-           if(decrypt == null)
++          if (decrypt == null)
 +            decrypt = GMSEncrypt.getDecryptCipher(dhSKAlgo, secretBytes);
-         }        
++        }
 +      }
 +      return decrypt;
 +    }
    }
  }
- 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d5f9477/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
index 8652b67,de90328..3a08faa
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
@@@ -9,15 -8,9 +8,18 @@@ import com.gemstone.gemfire.distributed
  import com.gemstone.gemfire.distributed.internal.membership.gms.ServiceConfig;
  import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
  import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
 +
 +import org.junit.Assert;
 +import org.junit.Test;
 +
 +import java.math.BigInteger;
 +import java.security.Key;
 +import java.security.KeyPair;
 +import java.security.KeyPairGenerator;
 +import java.security.NoSuchAlgorithmException;
+ import org.junit.Assert;
+ import org.junit.Test;
+ 
  import java.util.Arrays;
  import java.util.LinkedList;
  import java.util.List;
@@@ -151,406 -137,4 +152,406 @@@ public class GMSEncryptJUnitTest 
      Assert.assertTrue(Arrays.equals(responseBytes, decryptedResponse));
  
    }
 +  
 +  @Test
 +  public void testForClusterSecretKey() throws Exception{
 +    initMocks();
 +
 +    GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services, mockMembers[1]); // this will be the sender
 +    gmsEncrypt1.addClusterKey();
 +    // establish the public keys for the sender and receiver
 +    netView.setPublicKey(mockMembers[1], gmsEncrypt1.getPublicKeyBytes());
 +    
 +    gmsEncrypt1.installView(netView, mockMembers[1]);
 +    
 +    // sender encrypts a message, so use receiver's public key
 +    String ch = "Hello world";
 +    byte[] challenge =  ch.getBytes();
 +    byte[]  encryptedChallenge =  gmsEncrypt1.encryptData(challenge);
 +
 +    // receiver decrypts the message using the sender's public key
 +    byte[] decryptBytes = gmsEncrypt1.decryptData(encryptedChallenge);
 +    
 +    Assert.assertFalse(Arrays.equals(challenge, encryptedChallenge));
 +
 +    Assert.assertTrue(Arrays.equals(challenge, decryptBytes));    
 +  }
 +  
 +  @Test
 +  public void testForClusterSecretKeyFromOtherMember() throws Exception{
 +    initMocks();
 +
 +    GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services, mockMembers[1]); // this will be the sender
 +    gmsEncrypt1.addClusterKey();
 +    GMSEncrypt gmsEncrypt2 = new GMSEncrypt(services, mockMembers[2]); // this will be the sender
 +    
 +    // establish the public keys for the sender and receiver
 +    netView.setPublicKey(mockMembers[1], gmsEncrypt1.getPublicKeyBytes());
 +    netView.setPublicKey(mockMembers[2], gmsEncrypt2.getPublicKeyBytes());
 +    
 +    gmsEncrypt1.installView(netView, mockMembers[1]);
 +    
 +    byte[] secretBytes = gmsEncrypt1.getSecretBytes();
 +    gmsEncrypt2.addClusterKey(secretBytes);
 +    
 +    gmsEncrypt2.installView(netView, mockMembers[1]);
 +    
 +    // sender encrypts a message, so use receiver's public key
 +    String ch = "Hello world";
 +    byte[] challenge =  ch.getBytes();
 +    byte[]  encryptedChallenge =  gmsEncrypt1.encryptData(challenge);
 +
 +    // receiver decrypts the message using the sender's public key
 +    byte[] decryptBytes = gmsEncrypt2.decryptData(encryptedChallenge);
 +    
 +    // now send a response
 +    String response = "Hello yourself!";
 +    byte[] responseBytes = response.getBytes();
 +    byte[] encryptedResponse = gmsEncrypt2.encryptData(responseBytes);
 +
 +    // receiver decodes the response
 +    byte[] decryptedResponse = gmsEncrypt1.decryptData(encryptedResponse);
 +
 +    Assert.assertFalse(Arrays.equals(challenge, encryptedChallenge));
 +
 +    Assert.assertTrue(Arrays.equals(challenge, decryptBytes));
 +
 +    Assert.assertFalse(Arrays.equals(responseBytes, encryptedResponse));
 +
 +    Assert.assertTrue(Arrays.equals(responseBytes, decryptedResponse));  
 +  }
 +  
 +    
 +  @Test
 +    public void testDHAlgo() throws Exception {
 +
 +      DHParameterSpec dhSkipParamSpec;
 +
 +      System.out.println("Using SKIP Diffie-Hellman parameters");
 +      dhSkipParamSpec = new DHParameterSpec(skip1024Modulus, skip1024Base);
 +
 +      // Alice creates her own DH key pair
 +      System.out.println("ALICE: Generate DH keypair ...");
 +      KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH");
 +      aliceKpairGen.initialize(dhSkipParamSpec);
 +      KeyPair aliceKpair = aliceKpairGen.generateKeyPair();
 +
 +      // Bob creates his own DH key pair
 +      System.out.println("BOB: Generate DH keypair ...");
 +      KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH");
 +      bobKpairGen.initialize(dhSkipParamSpec);
 +      KeyPair bobKpair = bobKpairGen.generateKeyPair();
 +
 +      // Carol creates her own DH key pair
 +      System.out.println("CAROL: Generate DH keypair ...");
 +      KeyPairGenerator carolKpairGen = KeyPairGenerator.getInstance("DH");
 +      carolKpairGen.initialize(dhSkipParamSpec);
 +      KeyPair carolKpair = carolKpairGen.generateKeyPair();
 +
 +
 +      // Alice initialize
 +      System.out.println("ALICE: Initialize ...");
 +      KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH");
 +      aliceKeyAgree.init(aliceKpair.getPrivate());
 +
 +      // Bob initialize
 +      System.out.println("BOB: Initialize ...");
 +      KeyAgreement bobKeyAgree = KeyAgreement.getInstance("DH");
 +      bobKeyAgree.init(bobKpair.getPrivate());
 +
 +      // Carol initialize
 +      System.out.println("CAROL: Initialize ...");
 +      KeyAgreement carolKeyAgree = KeyAgreement.getInstance("DH");
 +      carolKeyAgree.init(carolKpair.getPrivate());
 +
 +
 +      // Alice uses Carol's public key
 +      Key ac = aliceKeyAgree.doPhase(carolKpair.getPublic(), false);
 +
 +      // Bob uses Alice's public key
 +      Key ba = bobKeyAgree.doPhase(aliceKpair.getPublic(), false);
 +
 +      // Carol uses Bob's public key
 +      Key cb = carolKeyAgree.doPhase(bobKpair.getPublic(), false);
 +
 +
 +      // Alice uses Carol's result from above
 +      aliceKeyAgree.doPhase(cb, true);
 +
 +      // Bob uses Alice's result from above
 +      bobKeyAgree.doPhase(ac, true);
 +
 +      // Carol uses Bob's result from above
 +      carolKeyAgree.doPhase(ba, true);
 +
 +
 +      // Alice, Bob and Carol compute their secrets
 +      byte[] aliceSharedSecret = aliceKeyAgree.generateSecret();
 +      System.out.println("Alice secret: " + toHexString(aliceSharedSecret));
 +
 +      byte[] bobSharedSecret = bobKeyAgree.generateSecret();
 +      System.out.println("Bob secret: " + toHexString(bobSharedSecret));
 +
 +      byte[] carolSharedSecret = carolKeyAgree.generateSecret();
 +      System.out.println("Carol secret: " + toHexString(carolSharedSecret));
 +
 +
 +      // Compare Alice and Bob
 +      if (!java.util.Arrays.equals(aliceSharedSecret, bobSharedSecret))
 +          throw new Exception("Alice and Bob differ");
 +      System.out.println("Alice and Bob are the same");
 +
 +      // Compare Bob and Carol
 +      if (!java.util.Arrays.equals(bobSharedSecret, carolSharedSecret))
 +          throw new Exception("Bob and Carol differ");
 +      System.out.println("Bob and Carol are the same");
 +  }
 +  
 +  @Test
 +  public void testDHAlgo2() throws Exception {
 +
 +    DHParameterSpec dhSkipParamSpec;
 +
 +    System.out.println("Using SKIP Diffie-Hellman parameters");
 +    dhSkipParamSpec = new DHParameterSpec(skip1024Modulus, skip1024Base);
 +
 + // Alice creates her own DH key pair
 +    System.out.println("ALICE: Generate DH keypair ...");
 +    KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH");
 +    aliceKpairGen.initialize(dhSkipParamSpec);
 +    KeyPair aliceKpair = aliceKpairGen.generateKeyPair();
 +
 +    
 +    // Bob creates his own DH key pair
 +    System.out.println("BOB: Generate DH keypair ...");
 +    KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH");
 +    bobKpairGen.initialize(dhSkipParamSpec);
 +    KeyPair bobKpair = bobKpairGen.generateKeyPair();
 +
 +    
 +    // Alice initialize
 +    System.out.println("ALICE: Initialize ...");
 +    KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH");
 +    aliceKeyAgree.init(aliceKpair.getPrivate()); 
 +
 +    // Bob initialize
 +    System.out.println("BOB  : Initialize ...");
 +    KeyAgreement bobKeyAgree = KeyAgreement.getInstance("DH");
 +    bobKeyAgree.init(bobKpair.getPrivate());
 +    
 +    // Alice uses Carol's public key
 +    aliceKeyAgree.doPhase(bobKpair.getPublic(), true);       
 +    
 +    // Bob uses Alice's public key
 +    bobKeyAgree.doPhase(aliceKpair.getPublic(), true);
 +
 +    // Alice, Bob and Carol compute their secrets
 +    byte[] aliceSharedSecret = aliceKeyAgree.generateSecret();
 +    System.out.println("Alice secret: " + toHexString(aliceSharedSecret));
 +
 +    
 +    byte[] bobSharedSecret = bobKeyAgree.generateSecret();
 +    System.out.println("Bob   secret: " + toHexString(bobSharedSecret));
 +    
 +    
 +    // Compare Alice and Bob
 +    if (!java.util.Arrays.equals(aliceSharedSecret, bobSharedSecret))
 +        throw new Exception("Alice and Bob differ");
 +    System.out.println("Alice and Bob are the same");
 +
 +  }
 +  
 +  @Test
 +  public void testDHAlgo3() throws Exception {
 +
 +    DHParameterSpec dhSkipParamSpec;
 +
 +    System.out.println("Using SKIP Diffie-Hellman parameters");
 +    dhSkipParamSpec = new DHParameterSpec(skip1024Modulus, skip1024Base);
 +
 + // Alice creates her own DH key pair
 +    System.out.println("ALICE: Generate DH keypair ...");
 +    KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH");
 +    aliceKpairGen.initialize(dhSkipParamSpec);
 +    KeyPair aliceKpair = aliceKpairGen.generateKeyPair();
 +
 +    
 +    // Bob creates his own DH key pair
 +    System.out.println("BOB: Generate DH keypair ...");
 +    KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH");
 +    bobKpairGen.initialize(dhSkipParamSpec);
 +    KeyPair bobKpair = bobKpairGen.generateKeyPair();
 +
 +    
 +    // Alice initialize
 +    System.out.println("ALICE: Initialize ...");
 +    KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH");
 +    aliceKeyAgree.init(aliceKpair.getPrivate()); 
 +
 +    // Bob initialize
 +    System.out.println("BOB  : Initialize ...");
 +    KeyAgreement bobKeyAgree = KeyAgreement.getInstance("DH");
 +    bobKeyAgree.init(bobKpair.getPrivate());
 +    
 +    // Alice uses Carol's public key
 +    aliceKeyAgree.doPhase(bobKpair.getPublic(), true);       
 +    
 +    // Bob uses Alice's public key
 +    bobKeyAgree.doPhase(aliceKpair.getPublic(), true);
 +
 +    String dhKalgo = "AES"; 
 +    // Alice, Bob and Carol compute their secrets
 +    SecretKey aliceSharedSecret = aliceKeyAgree.generateSecret(dhKalgo);
 +    System.out.println("Alice secret: " + toHexString(aliceSharedSecret.getEncoded()));
 +
 +    
 +    
 +    SecretKey bobSharedSecret = bobKeyAgree.generateSecret(dhKalgo);
 +    System.out.println("Bob   secret: " + toHexString(bobSharedSecret.getEncoded()));
 +    
-     applyMAC(aliceSharedSecret);
-     applyMAC(bobSharedSecret);
++    //applyMAC(aliceSharedSecret);
++    //applyMAC(bobSharedSecret);
 +    
 +    // Compare Alice and Bob
 +    if (!java.util.Arrays.equals(aliceSharedSecret.getEncoded(), bobSharedSecret.getEncoded()))
 +        throw new Exception("Alice and Bob differ");
 +    System.out.println("Alice and Bob are the same");
 +  }
 +  
 +  private void applyMAC(Key key) throws Exception {
 +    SecretKey key2 = new SecretKey() {
 +      
 +      @Override
 +      public String getFormat() {
 +        // TODO Auto-generated method stub
 +        return key.getFormat();
 +      }
 +      
 +      @Override
 +      public byte[] getEncoded() {
 +        // TODO Auto-generated method stub
 +        String hitesh = "This is from Hitesh";
 +        byte[] secbytes = hitesh.getBytes();
 +        byte[] origsecret = key.getEncoded(); 
 +        byte[] ns = new byte[origsecret.length + secbytes.length];
 +        System.arraycopy(origsecret, 0, ns, 0, origsecret.length);
 +        System.arraycopy(secbytes, 0, ns, origsecret.length, secbytes.length);
 +        return ns;
 +      }
 +      
 +      @Override
 +      public String getAlgorithm() {
 +        // TODO Auto-generated method stub
 +        return key.getAlgorithm();
 +      }
 +    };
 + // Generate secret key for HMAC-MD5
 +    //KeyGenerator kg = KeyGenerator.getInstance("HmacMD5");
 +    //SecretKey sk = kg.generateKey();
 +
 +    // Get instance of Mac object implementing HMAC-MD5, and
 +    // initialize it with the above secret key
 +    
 +    System.out.println("Key2 secret " + toHexString(key2.getEncoded()));
 +    
 +    Mac mac = Mac.getInstance("HmacMD5");
 +    mac.init(key2);
 +    byte[] result = mac.doFinal("Hi There".getBytes());
 +   
 +    
 +    System.out.println("Message Authentication code length: " + mac.getMacLength());
 +    System.out.println("Message Authentication code : " + toHexString(result));
 +    
 +    verifyMacBody(mac, result);
 +  }
 +  
 +  private byte[] verifyMacBody(Mac hmac, byte[] encryptedAndMac) throws Exception {               
 +    byte[] encrypted = new byte[encryptedAndMac.length - hmac.getMacLength()];
 +    System.arraycopy(encryptedAndMac, 0, encrypted, 0, encrypted.length);
 +
 +    byte[] remoteMac = new byte[hmac.getMacLength()];
 +    System.arraycopy(encryptedAndMac, encryptedAndMac.length - remoteMac.length, remoteMac, 0, remoteMac.length);
 +
 +    byte[] localMac  = hmac.doFinal(encrypted);
 +
 +    System.out.println("Message Authentication code remoteMac : " + toHexString(remoteMac));
 +    System.out.println("Message Authentication code localMac : " + toHexString(localMac));
 +    if (!Arrays.equals(remoteMac, localMac))
 +      throw new Exception("MAC doesen't match.");
 +
 +    return encrypted;
 +  }
 +  // The 1024 bit Diffie-Hellman modulus values used by SKIP
 +  private static final byte skip1024ModulusBytes[] = {
 +      (byte)0xF4, (byte)0x88, (byte)0xFD, (byte)0x58,
 +      (byte)0x4E, (byte)0x49, (byte)0xDB, (byte)0xCD,
 +      (byte)0x20, (byte)0xB4, (byte)0x9D, (byte)0xE4,
 +      (byte)0x91, (byte)0x07, (byte)0x36, (byte)0x6B,
 +      (byte)0x33, (byte)0x6C, (byte)0x38, (byte)0x0D,
 +      (byte)0x45, (byte)0x1D, (byte)0x0F, (byte)0x7C,
 +      (byte)0x88, (byte)0xB3, (byte)0x1C, (byte)0x7C,
 +      (byte)0x5B, (byte)0x2D, (byte)0x8E, (byte)0xF6,
 +      (byte)0xF3, (byte)0xC9, (byte)0x23, (byte)0xC0,
 +      (byte)0x43, (byte)0xF0, (byte)0xA5, (byte)0x5B,
 +      (byte)0x18, (byte)0x8D, (byte)0x8E, (byte)0xBB,
 +      (byte)0x55, (byte)0x8C, (byte)0xB8, (byte)0x5D,
 +      (byte)0x38, (byte)0xD3, (byte)0x34, (byte)0xFD,
 +      (byte)0x7C, (byte)0x17, (byte)0x57, (byte)0x43,
 +      (byte)0xA3, (byte)0x1D, (byte)0x18, (byte)0x6C,
 +      (byte)0xDE, (byte)0x33, (byte)0x21, (byte)0x2C,
 +      (byte)0xB5, (byte)0x2A, (byte)0xFF, (byte)0x3C,
 +      (byte)0xE1, (byte)0xB1, (byte)0x29, (byte)0x40,
 +      (byte)0x18, (byte)0x11, (byte)0x8D, (byte)0x7C,
 +      (byte)0x84, (byte)0xA7, (byte)0x0A, (byte)0x72,
 +      (byte)0xD6, (byte)0x86, (byte)0xC4, (byte)0x03,
 +      (byte)0x19, (byte)0xC8, (byte)0x07, (byte)0x29,
 +      (byte)0x7A, (byte)0xCA, (byte)0x95, (byte)0x0C,
 +      (byte)0xD9, (byte)0x96, (byte)0x9F, (byte)0xAB,
 +      (byte)0xD0, (byte)0x0A, (byte)0x50, (byte)0x9B,
 +      (byte)0x02, (byte)0x46, (byte)0xD3, (byte)0x08,
 +      (byte)0x3D, (byte)0x66, (byte)0xA4, (byte)0x5D,
 +      (byte)0x41, (byte)0x9F, (byte)0x9C, (byte)0x7C,
 +      (byte)0xBD, (byte)0x89, (byte)0x4B, (byte)0x22,
 +      (byte)0x19, (byte)0x26, (byte)0xBA, (byte)0xAB,
 +      (byte)0xA2, (byte)0x5E, (byte)0xC3, (byte)0x55,
 +      (byte)0xE9, (byte)0x2F, (byte)0x78, (byte)0xC7
 +  };
 +  
 +
 +
 +  // The SKIP 1024 bit modulus
 +  private static final BigInteger skip1024Modulus
 +  = new BigInteger(1, skip1024ModulusBytes);
 +
 +  // The base used with the SKIP 1024 bit modulus
 +  private static final BigInteger skip1024Base = BigInteger.valueOf(2);
 +  
 +  /*
 +   * Converts a byte to hex digit and writes to the supplied buffer
 +   */
 +  private void byte2hex(byte b, StringBuffer buf) {
 +      char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
 +                          '9', 'A', 'B', 'C', 'D', 'E', 'F' };
 +      int high = ((b & 0xf0) >> 4);
 +      int low = (b & 0x0f);
 +      buf.append(hexChars[high]);
 +      buf.append(hexChars[low]);
 +  }
 +
 +  /*
 +   * Converts a byte array to hex string
 +   */
 +  private String toHexString(byte[] block) {
 +      StringBuffer buf = new StringBuffer();
 +
 +      int len = block.length;
 +
 +      for (int i = 0; i < len; i++) {
 +           byte2hex(block[i], buf);
 +           if (i < len-1) {
 +               buf.append(":");
 +           }
 +      }
 +      return buf.toString();
 +  }
  }



[30/36] incubator-geode git commit: GEODE-1327 Now parent thread process copy of unresponsive members

Posted by hi...@apache.org.
GEODE-1327 Now parent thread process copy of unresponsive members


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

Branch: refs/heads/feature/GEODE-1372
Commit: 89b91cbe51c04a8b1867a608757585c832006639
Parents: 2c2caae
Author: Hitesh Khamesra <hk...@pivotal.io>
Authored: Thu May 12 12:49:34 2016 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Thu May 12 12:53:40 2016 -0700

----------------------------------------------------------------------
 .../internal/membership/gms/membership/GMSJoinLeave.java       | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/89b91cbe/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 41ec1ea..e12740e 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -2191,7 +2191,11 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         unresponsive.removeAll(removalReqs);
         unresponsive.removeAll(leaveReqs);
         if (!unresponsive.isEmpty()) {
-          removeHealthyMembers(unresponsive);          
+          removeHealthyMembers(unresponsive);
+          synchronized (viewRequests) {
+            //now lets get copy of it in viewRequests sync, as other thread might be accessing it 
+            unresponsive = new HashSet<>(unresponsive);
+          }
         }
 
         logger.debug("unresponsive members that could not be reached: {}", unresponsive);


[25/36] incubator-geode git commit: GEODE-1224: fix mutation of cloning on PRs

Posted by hi...@apache.org.
GEODE-1224: fix mutation of cloning on PRs

Changed BucketRegon getCloningEnabled ans setCloningEnabled to delegate
to the bucket's PartitionedRegion.

This closes #142


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

Branch: refs/heads/feature/GEODE-1372
Commit: 123ddb7ccf847203c35b314dd86dd6425a4cb500
Parents: 6dd3a58
Author: Scott Jewell <sj...@pivotal.io>
Authored: Fri Apr 29 13:37:22 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed May 11 15:29:41 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/cache/AbstractRegion.java  |   2 +-
 .../gemfire/internal/cache/BucketRegion.java    |  10 ++
 .../com/gemstone/gemfire/DeltaTestImpl.java     |  10 ++
 .../cache/PRDeltaPropagationDUnitTest.java      | 173 +++++++++++++++++--
 4 files changed, 182 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/123ddb7c/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java
index ef7e4e3..8651cc8 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java
@@ -206,7 +206,7 @@ public abstract class AbstractRegion implements Region, RegionAttributes,
    */
   protected boolean offHeap;
 
-  protected boolean cloningEnable = false;
+  private boolean cloningEnable = false;
 
   protected DiskWriteAttributes diskWriteAttributes;
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/123ddb7c/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java
index f5ae0fb..e2482bb 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java
@@ -2407,6 +2407,16 @@ implements Bucket
   }
 
   @Override
+  public void setCloningEnabled(boolean isCloningEnabled){
+    this.partitionedRegion.setCloningEnabled(isCloningEnabled);
+  }
+
+  @Override
+  public boolean getCloningEnabled(){
+    return this.partitionedRegion.getCloningEnabled();
+  }
+
+  @Override
   protected void generateLocalFilterRouting(InternalCacheEvent event) {
     if (event.getLocalFilterInfo() == null) {
       super.generateLocalFilterRouting(event);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/123ddb7c/geode-core/src/test/java/com/gemstone/gemfire/DeltaTestImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/DeltaTestImpl.java b/geode-core/src/test/java/com/gemstone/gemfire/DeltaTestImpl.java
index cd82459..6356ab8 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/DeltaTestImpl.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/DeltaTestImpl.java
@@ -51,6 +51,7 @@ public class DeltaTestImpl implements DataSerializable, Delta {
   private static long toDeltaInvokations;
   private static long toDeltaFailure;
   private static long fromDeltaFailure;
+  private static long timesConstructed = 0;
   public static boolean NEED_TO_RESET_T0_DELTA = true;
   /** *********************************************************************** */
   
@@ -69,6 +70,7 @@ public class DeltaTestImpl implements DataSerializable, Delta {
   private boolean hasDelta = false;
 
   public DeltaTestImpl() {
+    timesConstructed++;
   }
 
   public DeltaTestImpl(int intVal, String str) {
@@ -85,6 +87,14 @@ public class DeltaTestImpl implements DataSerializable, Delta {
     this.testObj = testObj;
   }
 
+  public static long getTimesConstructed() {
+    return timesConstructed;
+  }
+  
+  public static void setTimesConstructed(long cnt) {
+    timesConstructed = cnt;
+  }
+  
   public void resetDeltaStatus() {
     this.deltaBits = 0x0;
     this.hasDelta = false;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/123ddb7c/geode-cq/src/test/java/com/gemstone/gemfire/internal/cache/PRDeltaPropagationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/internal/cache/PRDeltaPropagationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/internal/cache/PRDeltaPropagationDUnitTest.java
index e8816f9..3b35954 100755
--- a/geode-cq/src/test/java/com/gemstone/gemfire/internal/cache/PRDeltaPropagationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/internal/cache/PRDeltaPropagationDUnitTest.java
@@ -156,6 +156,123 @@ public class PRDeltaPropagationDUnitTest extends DistributedTestCase {
   }
 
   /**
+   *  Monitor number of times constructor is called
+   *  Without copy or cloning, we should have 1 instance
+   */
+  public void testConstructorCountWithoutCloning() throws Throwable {
+
+    clearConstructorCounts();
+    createCacheInAllPRVms();
+    createDeltaPR(Boolean.FALSE);
+    
+    // Verify that cloning is disabled
+    assertFalse(((LocalRegion)deltaPR).getCloningEnabled());
+
+    verifyNoCopy();
+    
+    putInitial();  // Does multiple puts
+   
+    verifyConstructorCount(1);
+  }
+  
+  /**
+   *  Monitor number of times constructor is called
+   *  With cloning, we should have more than 1 instance
+   *  on members receiving delta updates
+   */
+  public void testConstructorCountWithCloning() throws Throwable {
+
+    clearConstructorCounts();
+    createCacheInAllPRVms();
+    createDeltaPRWithCloning(Boolean.FALSE);
+        
+    // Verify that cloning is enabled
+    assertTrue(((LocalRegion)deltaPR).getCloningEnabled());
+
+    verifyNoCopy();
+    
+    putInitial();  // Does multiple puts
+   
+    verifyConstructorCount(2);
+
+  }
+
+  /**
+   *  Create partition with cloning disabled, then
+   *  enable cloning and verify proper operation 
+   */
+  public void testConstructorCountWithMutator() throws Throwable {
+
+    clearConstructorCounts();
+    createCacheInAllPRVms();
+    createDeltaPR(Boolean.FALSE);
+        
+    // Verify that cloning is disabled
+    assertFalse(((LocalRegion)deltaPR).getCloningEnabled());
+
+    verifyNoCopy();
+    
+    PRDeltaTestImpl myDTI = putInitial();  // Does multiple puts
+   
+    // With cloning disabled only single instance
+    verifyConstructorCount(1);
+
+    // Now set cloning enabled
+    setPRCloning(true);
+    // Verify that cloning is enabled
+    assertTrue(((LocalRegion)deltaPR).getCloningEnabled());
+  
+    // With cloning enabled each put/delta should create a new instance
+    putMore(myDTI);  
+    
+    verifyConstructorCount(3);
+  }
+
+  private void verifyConstructorCount(int timesConstructed) throws Exception {
+        
+    long buildCount0 = getBuildCount();
+    long buildCount1 = (long)dataStore1.invoke(() -> PRDeltaPropagationDUnitTest.getBuildCount());
+    long buildCount2 = (long)dataStore2.invoke(() -> PRDeltaPropagationDUnitTest.getBuildCount());
+    
+    assertEquals(1, buildCount0);
+    assertEquals(timesConstructed, buildCount1);
+    assertEquals(timesConstructed, buildCount2);
+  }
+
+  private void setPRCloning(boolean cloning) {
+    setCloningEnabled(cloning);
+    dataStore1.invoke(() -> PRDeltaPropagationDUnitTest.setCloningEnabled(cloning));
+    dataStore2.invoke(() -> PRDeltaPropagationDUnitTest.setCloningEnabled(cloning));
+  }
+  
+  private static void setCloningEnabled(boolean cloningEnabled) {
+    ((LocalRegion)deltaPR).setCloningEnabled(cloningEnabled);
+  }
+  
+  private void verifyNoCopy() {
+    // Ensure not some other reason to make a copy
+    FilterProfile fp = ((LocalRegion)deltaPR).getFilterProfile();
+    boolean copy = ((LocalRegion)deltaPR).getCompressor() == null &&
+        (((LocalRegion)deltaPR).isCopyOnRead()
+        || (fp != null && fp.getCqCount() > 0));
+    assertFalse(copy);
+  }
+  
+  private void clearConstructorCounts() throws Throwable {
+    setBuildCount(0);
+    dataStore1.invoke(() -> PRDeltaPropagationDUnitTest.setBuildCount(0));
+    dataStore2.invoke(() -> PRDeltaPropagationDUnitTest.setBuildCount(0));
+  }
+  
+  public static long getBuildCount() throws Exception {
+    return DeltaTestImpl.getTimesConstructed();
+  }
+
+  public static void setBuildCount(long cnt) throws Exception {
+    DeltaTestImpl.setTimesConstructed(cnt);
+  }
+
+  /**
    * Check delta propagation works properly with PR failover.    
    */
 
@@ -760,17 +877,26 @@ public class PRDeltaPropagationDUnitTest extends DistributedTestCase {
     }
   }
 
-  private static void createDeltaPR(Boolean flag) {
+  private static void createDeltaPR(Boolean setExpiry) {
+    Object args[] = new Object[] { "DeltaPR", new Integer(1), new Integer(50),
+        new Integer(8), setExpiry, false, null };
+    createPR("DeltaPR", new Integer(1), new Integer(0), new Integer(8), setExpiry, false, null);
+    dataStore1.invoke(PRDeltaPropagationDUnitTest.class, "createPR", args);
+    dataStore2.invoke(PRDeltaPropagationDUnitTest.class, "createPR", args);
+
+  }
+
+  private static void createDeltaPRWithCloning(Boolean setExpiry) {
     Object args[] = new Object[] { "DeltaPR", new Integer(1), new Integer(50),
-        new Integer(8), flag, null };
-    createPR("DeltaPR", new Integer(1), new Integer(0), new Integer(8), flag, null);
+        new Integer(8), setExpiry, true, null };
+    createPR("DeltaPR", new Integer(1), new Integer(0), new Integer(8), setExpiry, true, null);
     dataStore1.invoke(PRDeltaPropagationDUnitTest.class, "createPR", args);
     dataStore2.invoke(PRDeltaPropagationDUnitTest.class, "createPR", args);
 
   }
 
   public static void createPR(String partitionedRegionName, Integer redundancy,
-      Integer localMaxMemory, Integer totalNumBuckets, Boolean setExpiry, Compressor compressor) {
+      Integer localMaxMemory, Integer totalNumBuckets, Boolean setExpiry, Boolean withCloning, Compressor compressor) {
 
     PartitionAttributesFactory paf = new PartitionAttributesFactory();
     PartitionAttributes prAttr = paf.setRedundantCopies(redundancy.intValue())
@@ -779,7 +905,8 @@ public class PRDeltaPropagationDUnitTest extends DistributedTestCase {
     AttributesFactory attr = new AttributesFactory();
     attr.setPartitionAttributes(prAttr);
     attr.setDataPolicy(DataPolicy.PARTITION);
-    attr.setConcurrencyChecksEnabled(true);
+    attr.setConcurrencyChecksEnabled(true);    
+    attr.setCloningEnabled(withCloning);    
     if (setExpiry) {
       attr.setStatisticsEnabled(true);
       attr.setEntryIdleTimeout(new ExpirationAttributes(1,
@@ -800,14 +927,16 @@ public class PRDeltaPropagationDUnitTest extends DistributedTestCase {
   public static Integer createCacheServerWithPR(String partitionedRegionName,
       Integer redundancy, Integer localMaxMemory, Integer totalNumBuckets,
       Boolean setExpiry, Compressor compressor) {
-    new PRDeltaPropagationDUnitTest("temp").createCache(new Properties());
+    
+    createCacheInVm();
+    
     createPR(partitionedRegionName, redundancy, localMaxMemory,
-        totalNumBuckets, setExpiry, compressor);
-    assertNotNull(deltaPR);
+        totalNumBuckets, setExpiry, Boolean.FALSE, compressor);
     deltaPR.put(DELTA_KEY, new PRDeltaTestImpl());
     
     CacheServer server1 = cache.addCacheServer();
     assertNotNull(server1);
+    
     int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     server1.setPort(port);
     try {
@@ -996,18 +1125,39 @@ public class PRDeltaPropagationDUnitTest extends DistributedTestCase {
   }
 
   public static void put() throws Exception {
-    DeltaTestImpl test = new DeltaTestImpl();
+    PRDeltaTestImpl test = new PRDeltaTestImpl();
     deltaPR.put(DELTA_KEY, test);
 
     test.setIntVar(10);
     deltaPR.put(DELTA_KEY, test);
 
-    test = new DeltaTestImpl();
+    test = new PRDeltaTestImpl();
+    
     test.setStr("DELTA");
     deltaPR.put(DELTA_KEY, test);
+  }
+
+  public static PRDeltaTestImpl putInitial() throws Exception {
+    PRDeltaTestImpl test = new PRDeltaTestImpl();
+    deltaPR.put(DELTA_KEY, test);
+
+    test.setIntVar(10);
+    deltaPR.put(DELTA_KEY, test);
 
+    test.setStr("DELTA");
+    deltaPR.put(DELTA_KEY, test);
+    
+    return test;
   }
 
+  public static void putMore(PRDeltaTestImpl val) throws Exception {
+    val.setIntVar(13);
+    put(val);
+
+    val.setStr("DELTA2");
+    put(val);
+  }
+  
   public static void put(PRDeltaTestImpl val) throws Exception {
     deltaPR.put(DELTA_KEY, val);
   }
@@ -1141,9 +1291,8 @@ public class PRDeltaPropagationDUnitTest extends DistributedTestCase {
   static class PRDeltaTestImpl extends DeltaTestImpl {
     int deltaSent = 0;
     int deltaApplied = 0;
-
+    
     public PRDeltaTestImpl() {
-
     }
 
     public void toDelta(DataOutput out) throws IOException {


[26/36] incubator-geode git commit: GEODE-1203: include spring-web in gfshDependency.jar

Posted by hi...@apache.org.
GEODE-1203: include spring-web in gfshDependency.jar


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

Branch: refs/heads/feature/GEODE-1372
Commit: 43a038e9c6c9db32884b43cf2aa2d8348dc89789
Parents: 123ddb7
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Thu May 12 07:52:33 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Thu May 12 07:52:33 2016 -0700

----------------------------------------------------------------------
 geode-assembly/src/test/resources/expected_jars.txt | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/43a038e9/geode-assembly/src/test/resources/expected_jars.txt
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/resources/expected_jars.txt b/geode-assembly/src/test/resources/expected_jars.txt
index da05d54..bb2ba19 100644
--- a/geode-assembly/src/test/resources/expected_jars.txt
+++ b/geode-assembly/src/test/resources/expected_jars.txt
@@ -1,5 +1,6 @@
 activation
 antlr
+aopalliance
 classmate
 commons-beanutils
 commons-collections


[32/36] incubator-geode git commit: Fixed eisting test issue. Added unit test to check whether we can transfer keypair.

Posted by hi...@apache.org.
Fixed eisting test issue. Added unit test to check whether we can
transfer keypair.


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

Branch: refs/heads/feature/GEODE-1372
Commit: db32370f31e0a07950f7dc1b19d5684ecf1c3c19
Parents: a28b223
Author: Hitesh Khamesra <hi...@yahoo.com>
Authored: Mon May 16 09:20:38 2016 -0700
Committer: Hitesh Khamesra <hi...@yahoo.com>
Committed: Thu May 19 10:18:23 2016 -0700

----------------------------------------------------------------------
 .../membership/gms/messenger/GMSEncrypt.java    | 43 +++++++++++++++++-
 .../gms/messenger/GMSEncryptJUnitTest.java      | 47 +++++++++++++++++++-
 2 files changed, 86 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/db32370f/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
index 3f61453..7cec567 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
@@ -19,7 +19,9 @@ package com.gemstone.gemfire.distributed.internal.membership.gms.messenger;
 
 import java.math.BigInteger;
 import java.security.*;
+import java.security.spec.EncodedKeySpec;
 import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
 import java.security.spec.X509EncodedKeySpec;
 import java.util.HashMap;
 import java.util.Map;
@@ -35,12 +37,14 @@ import javax.crypto.spec.SecretKeySpec;
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.distributed.internal.membership.NetView;
 import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
+
 import org.apache.logging.log4j.Logger;
 
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.internal.logging.LogService;
 
-public class GMSEncrypt {
+public class GMSEncrypt implements Cloneable{
+  
   public static long encodingsPerformed;
   public static long decodingsPerformed;
 
@@ -81,8 +85,16 @@ public class GMSEncrypt {
     this.view.setPublicKey(services.getJoinLeave().getMemberID(), getPublicKeyBytes());
     // TODO remove ciphers for departed members
   }
+  
+  protected void installView(NetView view, InternalDistributedMember mbr) {
+    this.view = view;
+    this.view.setPublicKey(mbr, getPublicKeyBytes());
+    // TODO remove ciphers for departed members
+  }
 
-
+  protected GMSEncrypt() {
+    
+  }
 
   public GMSEncrypt(Services services) throws  Exception {
     this.services = services;
@@ -101,6 +113,33 @@ public class GMSEncrypt {
     return dhPublicKey.getEncoded();
   }
 
+  @Override
+  protected GMSEncrypt clone() throws CloneNotSupportedException {
+    try {
+      GMSEncrypt gmsEncrypt = new GMSEncrypt();
+      gmsEncrypt.dhSKAlgo = this.dhSKAlgo;
+
+      X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(this.dhPublicKey.getEncoded());
+      KeyFactory keyFact = KeyFactory.getInstance("DH");
+      // PublicKey pubKey = keyFact.generatePublic(x509KeySpec);
+      gmsEncrypt.dhPublicKey = keyFact.generatePublic(x509KeySpec);
+      final String format = this.dhPrivateKey.getFormat();
+      System.out.println("private key format " + format);
+      System.out.println("public ksy format " + this.dhPublicKey.getFormat());
+      PKCS8EncodedKeySpec x509KeySpecPKey = new PKCS8EncodedKeySpec(this.dhPrivateKey.getEncoded());
+      
+      keyFact = KeyFactory.getInstance("DH");
+      // PublicKey pubKey = keyFact.generatePublic(x509KeySpec);
+      gmsEncrypt.dhPrivateKey = keyFact.generatePrivate(x509KeySpecPKey);
+
+      return gmsEncrypt;
+    } catch (Exception e) {
+      throw new RuntimeException("Unable to clone", e);
+    }
+  }
+
+
+
 
   /**
    * Initialize the Diffie-Hellman keys. This method is not thread safe

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/db32370f/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
index a591e47..de90328 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
@@ -66,8 +66,51 @@ public class GMSEncryptJUnitTest {
     netView.setPublicKey(mockMembers[1], gmsEncrypt1.getPublicKeyBytes());
     netView.setPublicKey(mockMembers[2], gmsEncrypt2.getPublicKeyBytes());
 
-    gmsEncrypt1.installView(netView);
-    gmsEncrypt2.installView(netView);
+    gmsEncrypt1.installView(netView, mockMembers[1]);
+    gmsEncrypt2.installView(netView, mockMembers[2]);
+
+    // sender encrypts a message, so use receiver's public key
+    String ch = "Hello world";
+    byte[] challenge =  ch.getBytes();
+    byte[]  encryptedChallenge =  gmsEncrypt1.encryptData(challenge, mockMembers[2]);
+
+    // receiver decrypts the message using the sender's public key
+    byte[] decryptBytes = gmsEncrypt2.decryptData(encryptedChallenge,  mockMembers[1]);
+
+    // now send a response
+    String response = "Hello yourself!";
+    byte[] responseBytes = response.getBytes();
+    byte[] encryptedResponse = gmsEncrypt2.encryptData(responseBytes, mockMembers[1]);
+
+    // receiver decodes the response
+    byte[] decryptedResponse = gmsEncrypt1.decryptData(encryptedResponse,  mockMembers[2]);
+
+    Assert.assertFalse(Arrays.equals(challenge, encryptedChallenge));
+
+    Assert.assertTrue(Arrays.equals(challenge, decryptBytes));
+
+    Assert.assertFalse(Arrays.equals(responseBytes, encryptedResponse));
+
+    Assert.assertTrue(Arrays.equals(responseBytes, decryptedResponse));
+
+  }
+  
+  @Test
+  public void testPublicKeyPrivateKeyFromSameMember() throws Exception{
+    initMocks();
+
+    GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services); // this will be the sender
+    GMSEncrypt gmsEncrypt2 = new GMSEncrypt(services); // this will be the receiver
+    
+    gmsEncrypt1 = gmsEncrypt1.clone();
+    gmsEncrypt2 = gmsEncrypt2.clone();
+
+    // establish the public keys for the sender and receiver
+    netView.setPublicKey(mockMembers[1], gmsEncrypt1.getPublicKeyBytes());
+    netView.setPublicKey(mockMembers[2], gmsEncrypt2.getPublicKeyBytes());
+
+    gmsEncrypt1.installView(netView, mockMembers[1]);
+    gmsEncrypt2.installView(netView, mockMembers[2]);
 
     // sender encrypts a message, so use receiver's public key
     String ch = "Hello world";


[22/36] incubator-geode git commit: GEODE-1203: include spring-web in gfshDependency.jar

Posted by hi...@apache.org.
GEODE-1203: include spring-web in gfshDependency.jar


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

Branch: refs/heads/feature/GEODE-1372
Commit: aaaa89bf4764f7b0656555bf3205bed0a1d199c0
Parents: 02b7688
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Wed May 11 08:40:28 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Wed May 11 13:14:25 2016 -0700

----------------------------------------------------------------------
 geode-assembly/build.gradle | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/aaaa89bf/geode-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle
index ed5154e..f6167c5 100755
--- a/geode-assembly/build.gradle
+++ b/geode-assembly/build.gradle
@@ -45,6 +45,7 @@ configurations {
   bundled {
     description 'A dependency that is shipped with geode, but is not required to compile'
   }
+  gfshDependencies
 }
 
 dependencies {
@@ -72,6 +73,11 @@ dependencies {
   testCompile 'org.apache.httpcomponents:httpcore:' + project.'httpcore.version'
 
   testRuntime files("${System.getProperty('java.home')}/../lib/tools.jar")
+
+  gfshDependencies ('org.springframework:spring-web:' + project.'springframework.version'){
+    exclude module: 'spring-core'
+    exclude module: 'commons-logging'
+  }
 }
 
 sourceSets {
@@ -188,13 +194,12 @@ task depsJar (type: Jar, dependsOn: ':geode-core:classes') {
 // a dependent project.  Please fix me.
 task gfshDepsJar (type: Jar, dependsOn: ':geode-core:classes') {
   description 'Assembles the jar archive that defines the gfsh classpath.'
-  def springWeb = configurations.runtime.collect { it.getName() }.find { it.contains('spring-web') }
   archiveName 'gfsh-dependencies.jar'
   doFirst {
     manifest {
       attributes("Class-Path": cp() + 
         ' ' + project(':geode-core').webJar.archiveName +
-        ' ' + springWeb
+        ' ' + configurations.gfshDependencies.collect{ it.getName() }.flatten().join(' ')
       )
     }
   }
@@ -325,6 +330,7 @@ distributions {
         from project(":geode-lucene").configurations.archives.allArtifacts.files
 
         from configurations.bundled
+        from configurations.gfshDependencies
 
         //These tasks are included as closures (wrapped in {}) because gradle may evaluate
         //this CopySpec before it evaluates the geode-core build file.


[28/36] incubator-geode git commit: GEODE-11: Tests of indexes on regions with overflow, eviction, expiration

Posted by hi...@apache.org.
GEODE-11: Tests of indexes on regions with overflow,eviction,expiration

Adding integration tests of indexes on these types of regions.


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

Branch: refs/heads/feature/GEODE-1372
Commit: 665471aea91528a660079ff51e274127381a055d
Parents: a83e428
Author: Dan Smith <up...@apache.org>
Authored: Wed May 11 17:51:12 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Thu May 12 11:11:48 2016 -0700

----------------------------------------------------------------------
 .../LuceneIndexCreationIntegrationTest.java     | 75 +++++++++++++++++---
 1 file changed, 67 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/665471ae/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
index 1dfaf51..2d16e32 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
@@ -29,7 +29,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Consumer;
+import java.util.function.Function;
 
+import com.gemstone.gemfire.cache.EvictionAttributes;
+import com.gemstone.gemfire.cache.ExpirationAttributes;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionShortcut;
 import com.gemstone.gemfire.cache.lucene.LuceneIndex;
@@ -74,26 +77,82 @@ public class LuceneIndexCreationIntegrationTest extends LuceneIntegrationTest {
   }
 
   @Test
-  public void verifyLuceneRegionInternal() {
+  public void shouldUseRedundancyForInternalRegionsWhenUserRegionHasRedundancy() {
+    createIndex("text");
+    cache.createRegionFactory(RegionShortcut.PARTITION_REDUNDANT).create(REGION_NAME);
+    verifyInternalRegions(region -> {
+      assertEquals(1, region.getAttributes().getPartitionAttributes().getRedundantCopies());
+    });
+  }
+
+  @Test
+  public void shouldNotUseEvictionForInternalRegionsWhenUserRegionHasEviction() {
+    createIndex("text");
+    cache.createRegionFactory(RegionShortcut.PARTITION)
+      .setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1))
+      .create(REGION_NAME);
+
+    verifyInternalRegions(region -> {
+      assertEquals(true, region.getAttributes().getEvictionAttributes().getAction().isNone());
+    });
+  }
+
+  @Test
+  public void shouldNotUseIdleTimeoutForInternalRegionsWhenUserRegionHasIdleTimeout() {
+    createIndex("text");
+    cache.createRegionFactory(RegionShortcut.PARTITION)
+      .setEntryIdleTimeout(new ExpirationAttributes(5))
+      .create(REGION_NAME);
+
+    verifyInternalRegions(region -> {
+      assertEquals(0, region.getAttributes().getEntryIdleTimeout().getTimeout());
+    });
+  }
+
+  @Test
+  public void shouldNotUseTTLForInternalRegionsWhenUserRegionHasTTL() {
+    createIndex("text");
+    cache.createRegionFactory(RegionShortcut.PARTITION)
+      .setEntryTimeToLive(new ExpirationAttributes(5))
+      .create(REGION_NAME);
+
+    verifyInternalRegions(region -> {
+      assertEquals(0, region.getAttributes().getEntryTimeToLive().getTimeout());
+    });
+  }
+
+  @Test
+  public void shouldNotUseOverflowForInternalRegionsWhenUserRegionHasOverflow() {
+    createIndex("text");
+    cache.createRegionFactory(RegionShortcut.PARTITION_OVERFLOW).create(REGION_NAME);
+    verifyInternalRegions(region -> {
+      assertTrue(region.getAttributes().getEvictionAttributes().getAction().isNone());
+    });
+  }
+
+  @Test
+  public void shouldCreateInternalRegionsForIndex() {
     createIndex("text");
 
     // Create partitioned region
     createRegion();
 
+    verifyInternalRegions(region -> {
+      region.isInternalRegion();
+      cache.rootRegions().contains(region);
+    });
+  }
+
+  private void verifyInternalRegions(Consumer<LocalRegion> verify) {
     // Get index
     LuceneIndexForPartitionedRegion index = (LuceneIndexForPartitionedRegion) luceneService.getIndex(INDEX_NAME, REGION_NAME);
 
     // Verify the meta regions exist and are internal
     LocalRegion chunkRegion = (LocalRegion) cache.getRegion(index.createChunkRegionName());
-    assertTrue(chunkRegion.isInternalRegion());
     LocalRegion fileRegion = (LocalRegion) cache.getRegion(index.createFileRegionName());
-    assertTrue(fileRegion.isInternalRegion());
+    verify.accept(chunkRegion);
+    verify.accept(fileRegion);
 
-    // Verify the meta regions are not contained in the root regions
-    for (Region region : cache.rootRegions()) {
-      assertNotEquals(chunkRegion.getFullPath(), region.getFullPath());
-      assertNotEquals(fileRegion.getFullPath(), region.getFullPath());
-    }
   }
 
   private Region createRegion() {


[12/36] incubator-geode git commit: GEODE-699 CI failure PartitionedRegionSingleHopDUnitTest.test_MetadataServiceCallAccuracy

Posted by hi...@apache.org.
GEODE-699 CI failure
PartitionedRegionSingleHopDUnitTest.test_MetadataServiceCallAccuracy

Replace WaitCriterion with Awaitility


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

Branch: refs/heads/feature/GEODE-1372
Commit: fe69f0a8a40a2825c979dab01b66f1c1d5a0b974
Parents: 036c931
Author: Jianxia Chen <jc...@pivotal.io>
Authored: Wed May 11 09:52:26 2016 -0700
Committer: Jianxia Chen <jc...@pivotal.io>
Committed: Wed May 11 09:52:26 2016 -0700

----------------------------------------------------------------------
 .../PartitionedRegionSingleHopDUnitTest.java    | 441 ++++++-------------
 1 file changed, 139 insertions(+), 302 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe69f0a8/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSingleHopDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSingleHopDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSingleHopDUnitTest.java
index 399f1ca..f79d6c6 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSingleHopDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSingleHopDUnitTest.java
@@ -29,7 +29,10 @@ import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
 
+import com.jayway.awaitility.Awaitility;
+import org.jgroups.blocks.locking.AwaitInfo;
 import org.junit.Ignore;
 import org.junit.experimental.categories.Category;
 
@@ -105,7 +108,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
   private static Cache cache = null;
 
   private static Locator locator = null;
-  
+
   public PartitionedRegionSingleHopDUnitTest(String name) {
     super(name);
   }
@@ -124,7 +127,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
   public final void postTearDownCacheTestCase() throws Exception {
     try {
       closeCacheAndDisconnect();
-      
+
       member0 = null;
       member1 = null;
       member2 = null;
@@ -148,7 +151,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
       cacheServer.stop();
     }
   }
-  
+
  public static void startLocatorInVM(final int locatorPort) {
 
     File logFile = new File("locator-" + locatorPort + ".log");
@@ -380,44 +383,21 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.printView());
     final ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     cms.satisfyRefreshMetadata_TEST_ONLY(false);
-    
+
     region.put(new Integer(0), "create0");
     region.put(new Integer(1), "create1");
     region.put(new Integer(2), "create2");
     region.put(new Integer(3), "create3");
-    
-    
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        if (cms.isRefreshMetadataTestOnly()) {
-          return true;
-        }
-        return false;
-      }
 
-      public String description() {
-        return "expected metadataservice to be called atleast once, but it was not called";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> cms.isRefreshMetadataTestOnly() == true);
 
     cms.satisfyRefreshMetadata_TEST_ONLY(false);
     region.put(new Integer(0), "create0");
     region.put(new Integer(1), "create1");
     region.put(new Integer(2), "create2");
     region.put(new Integer(3), "create3");
-    //pause(5000);
-    wc = new WaitCriterion() {
-      public boolean done() {
-        return !cms.isRefreshMetadataTestOnly();
-      }
-
-      public String description() {
-        return "expected no metadata to be refreshed";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
 
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> cms.isRefreshMetadataTestOnly() == false);
   }
 
   public void test_MetadataServiceCallAccuracy_FromDestroyOp() {
@@ -434,26 +414,13 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.printView());
     final ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     cms.satisfyRefreshMetadata_TEST_ONLY(false);
-    
+
     region.destroy(new Integer(0));
     region.destroy(new Integer(1));
     region.destroy(new Integer(2));
     region.destroy(new Integer(3));
-    
-    
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        if (cms.isRefreshMetadataTestOnly()) {
-          return true;
-        }
-        return false;
-      }
 
-      public String description() {
-        return "expected metadataservice to be called atleast once, but it was not called";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> cms.isRefreshMetadataTestOnly() == true);
   }
 
   public void test_MetadataServiceCallAccuracy_FromGetOp() {
@@ -470,26 +437,14 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     final ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     cms.satisfyRefreshMetadata_TEST_ONLY(false);
 
-    
+
 
     region.get(new Integer(0));
     region.get(new Integer(1));
     region.get(new Integer(2));
     region.get(new Integer(3));
 
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        if (cms.isRefreshMetadataTestOnly()) {
-          return true;
-        }
-        return false;
-      }
-
-      public String description() {
-        return "expected metadataservice to be called atleast once, but it was not called";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> cms.isRefreshMetadataTestOnly() == true);
     printMetadata();
     Wait.pause(5000);
     cms.satisfyRefreshMetadata_TEST_ONLY(false);
@@ -521,19 +476,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
       region.put(new Integer(i), new Integer(i + 1));
     }
 
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        if (cms.isRefreshMetadataTestOnly()) {
-          return true;
-        }
-        return false;
-      }
-
-      public String description() {
-        return "expected metadataservice to be called atleast once, but it was not called";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> cms.isRefreshMetadataTestOnly() == true);
 
     // kill server
     member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.stopServer());
@@ -580,7 +523,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     }
   }
 
-  
+
   public void test_NoMetadataServiceCall_ForGetOp() {
     Integer port0 = (Integer)member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer( 0, 4 ));
     Integer port1 = (Integer)member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer( 0, 4 ));
@@ -623,11 +566,11 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
         .invoke(() -> PartitionedRegionSingleHopDUnitTest.putIntoSinglePR());
     ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     cms.satisfyRefreshMetadata_TEST_ONLY(false);
-    
+
     member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.printView());
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.printView());
 
- 
+
     region.put(new Integer(0), "create0");
     final boolean metadataRefreshed_get1 = cms
         .isRefreshMetadataTestOnly();
@@ -690,20 +633,20 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     Integer port2 = (Integer)member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer( 3, 4 ));
     Integer port3 = (Integer)member3.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer( 3, 4 ));
     createClient(port0, port1, port2, port3);
-    putIntoPartitionedRegions();    
+    putIntoPartitionedRegions();
     getFromPartitionedRegions();
     Wait.pause(5000);
     ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
-    Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();    
+    Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
     assertEquals(4, regionMetaData.size());
     assertTrue(regionMetaData.containsKey(region.getFullPath()));
     assertTrue(regionMetaData.containsKey(customerRegion.getFullPath()));
     assertTrue(regionMetaData.containsKey(orderRegion.getFullPath()));
     assertTrue(regionMetaData.containsKey(shipmentRegion.getFullPath()));
-    
-    ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath()); 
+
+    ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
     assertEquals(4/*numBuckets*/, prMetaData.getBucketServerLocationsMap_TEST_ONLY().size());
-    
+
     for (Entry entry : prMetaData.getBucketServerLocationsMap_TEST_ONLY().entrySet()) {
       assertEquals(4, ((List)entry.getValue()).size());
     }
@@ -714,7 +657,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     verifyDeadServer(regionMetaData, customerRegion, port0, port1);
     verifyDeadServer(regionMetaData, region, port0, port1);
   }
-  
+
   public void testMetadataFetchOnlyThroughFunctions() {
     //Workaround for 52004
     IgnoredException.addIgnoredException("InternalFunctionInvocationTargetException");
@@ -726,23 +669,14 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     executeFunctions();
     ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
-    
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        return (regionMetaData.size() == 1);
-      }
 
-      public String description() {
-        return "expected no metadata to be refreshed";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
-    
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> regionMetaData.size() == 1);
+
     assertEquals(1, regionMetaData.size());
     assertTrue(regionMetaData.containsKey(region.getFullPath()));
-    
-    final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath()); 
-    
+
+    final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
+
     //Fixes a race condition in GEODE-414 by retrying as 
     //region.clientMetaDataLock.tryLock() may prevent fetching the 
     //metadata through functional calls as only limited functions are executed in the test.
@@ -760,17 +694,8 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
         break;
       }
     } while (System.currentTimeMillis() - start < 60000);
-    
-    wc = new WaitCriterion() {
-      public boolean done() {
-        return (prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() == 4);
-      }
 
-      public String description() {
-        return "expected no metadata to be refreshed";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() == 4));
 //    assertIndexDetailsEquals(4/*numBuckets*/, prMetaData.getBucketServerLocationsMap_TEST_ONLY().size());
   }
 
@@ -782,35 +707,18 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     createClient(port0, port1, port2, port3);
     putAll();
     ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
-    final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();    
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        return (regionMetaData.size() == 1);
-      }
+    final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
 
-      public String description() {
-        return "expected no metadata to be refreshed";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
-    
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (regionMetaData.size() == 1));
     assertTrue(regionMetaData.containsKey(region.getFullPath()));
-    
-    final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath()); 
-    wc = new WaitCriterion() {
-      public boolean done() {
-        return (prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() == 4);
-      }
 
-      public String description() {
-        return "expected no metadata to be refreshed";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);  
+    final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
+
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() == 4));
   }
-  
-  
-  
+
+
+
   @Ignore("Bug 47950")
   public void DISABLED_testMetadataIsSameOnAllServersAndClients() {
     Integer port0 = (Integer)member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer( 3, 4 ));
@@ -823,15 +731,15 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
     member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
     member3.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
-    
-    
+
+
     ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     cms.getClientPRMetadata((LocalRegion)region);
-    
-    Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();    
+
+    Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
     assertEquals(1, regionMetaData.size());
     assertTrue(regionMetaData.containsKey(region.getFullPath()));
-    
+
     ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
     final Map<Integer, List<BucketServerLocation66>> clientMap  = prMetaData.getBucketServerLocationsMap_TEST_ONLY();
     WaitCriterion wc = new WaitCriterion() {
@@ -843,7 +751,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
         return "expected no metadata to be refreshed";
       }
     };
-    Wait.waitForCriterion(wc, 60000, 1000, true); 
+    Wait.waitForCriterion(wc, 60000, 1000, true);
     for (Entry entry : clientMap.entrySet()) {
       assertEquals(4, ((List)entry.getValue()).size());
     }
@@ -851,10 +759,10 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
     member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
     member3.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
-    
+
     member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.stopServer());
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.stopServer());
-    
+
     member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.startServerOnPort( port0 ));
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.startServerOnPort( port1 ));
     put();
@@ -862,15 +770,15 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
     member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
     member3.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
-    
+
     cms = ((GemFireCacheImpl)cache).getClientMetadataService();
-    
+
     wc = new WaitCriterion() {
       public boolean done() {
-        ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();    
-        Map<String, ClientPartitionAdvisor>  regionMetaData = cms.getClientPRMetadata_TEST_ONLY();    
+        ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
+        Map<String, ClientPartitionAdvisor>  regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
         assertEquals(1, regionMetaData.size());
-        assertTrue(regionMetaData.containsKey(region.getFullPath()));    
+        assertTrue(regionMetaData.containsKey(region.getFullPath()));
         ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
         Map<Integer, List<BucketServerLocation66>> clientMap  = prMetaData.getBucketServerLocationsMap_TEST_ONLY();
         assertEquals(4/*numBuckets*/, clientMap.size());
@@ -892,11 +800,11 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     Wait.waitForCriterion(wc, 60000, 400, true);
     cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     cms.getClientPRMetadata((LocalRegion)region);
-    
-    regionMetaData = cms.getClientPRMetadata_TEST_ONLY();    
+
+    regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
     assertEquals(1, regionMetaData.size());
     assertTrue(regionMetaData.containsKey(region.getFullPath()));
-    
+
     prMetaData = regionMetaData.get(region.getFullPath());
     final Map<Integer, List<BucketServerLocation66>> clientMap2  = prMetaData.getBucketServerLocationsMap_TEST_ONLY();
     wc = new WaitCriterion() {
@@ -908,19 +816,19 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
         return "expected no metadata to be refreshed";
       }
     };
-    Wait.waitForCriterion(wc, 60000, 1000, true); 
+    Wait.waitForCriterion(wc, 60000, 1000, true);
     for (Entry entry : clientMap.entrySet()) {
       assertEquals(4, ((List)entry.getValue()).size());
     }
-    
+
     member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
     member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
     member3.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
-    
+
     member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.closeCacheAndDisconnect());
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.closeCacheAndDisconnect());
-    
+
 //    member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServerOnPort(3,4,port0 ));
 //    member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServerOnPort(3,4,port1 ));
     put();
@@ -932,7 +840,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
             .getRegionAdvisor().getAllClientBucketProfilesTest();
       }
     });
-    
+
     member3.invoke(new CacheSerializableRunnable("aba") {
       @Override
       public void run2() throws CacheException {
@@ -941,31 +849,22 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
             .getRegionAdvisor().getAllClientBucketProfilesTest();
       }
     });
-    
+
 //    member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
 //    member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
     member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
     member3.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
-    
+
     cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     cms.getClientPRMetadata((LocalRegion)region);
-    
-    regionMetaData = cms.getClientPRMetadata_TEST_ONLY();    
+
+    regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
     assertEquals(1, regionMetaData.size());
     assertTrue(regionMetaData.containsKey(region.getFullPath()));
-    
+
     prMetaData = regionMetaData.get(region.getFullPath());
     final Map<Integer, List<BucketServerLocation66>> clientMap3  = prMetaData.getBucketServerLocationsMap_TEST_ONLY();
-    wc = new WaitCriterion() {
-      public boolean done() {
-        return (clientMap3.size() == 4);
-      }
-
-      public String description() {
-        return "expected no metadata to be refreshed";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true); 
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (clientMap3.size() == 4));
     for (Entry entry : clientMap.entrySet()) {
       assertEquals(2, ((List)entry.getValue()).size());
     }
@@ -988,36 +887,28 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
       public String description() {
         return "verification of metadata on all members";
       }
-      
+
     }, 20000, 2000, true);
+
   }
-  
+
   public void testMetadataIsSameOnAllServersAndClientsHA() {
     Integer port0 = (Integer)member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer( 2, 4 ));
     Integer port1 = (Integer)member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer( 2, 4 ));
-    
+
     createClient(port0, port1, port0, port1);
     put();
-    
+
     ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     cms.getClientPRMetadata((LocalRegion)region);
-    
-    final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();    
-    
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        return (regionMetaData.size() == 1);
-      }
 
-      public String description() {
-        return "expected metadata is ready";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
-    
+    final Map<String, ClientPartitionAdvisor> regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
+
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (regionMetaData.size() == 1));
+
     assertEquals(1, regionMetaData.size());
     assertTrue(regionMetaData.containsKey(region.getFullPath()));
-    
+
     member0.invoke(new CacheSerializableRunnable("aba") {
       @Override
       public void run2() throws CacheException {
@@ -1026,7 +917,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
             .getRegionAdvisor().getAllClientBucketProfilesTest();
       }
     });
-    
+
     member1.invoke(new CacheSerializableRunnable("aba") {
       @Override
       public void run2() throws CacheException {
@@ -1035,73 +926,55 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
             .getRegionAdvisor().getAllClientBucketProfilesTest();
       }
     });
-    
+
     ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
     final Map<Integer, List<BucketServerLocation66>> clientMap  = prMetaData.getBucketServerLocationsMap_TEST_ONLY();
-    wc = new WaitCriterion() {
-      public boolean done() {
-        return (clientMap.size() == 4);
-      }
-
-      public String description() {
-        return "expected no metadata to be refreshed";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true); 
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (clientMap.size() == 4));
     for (Entry entry : clientMap.entrySet()) {
       assertEquals(2, ((List)entry.getValue()).size());
     }
     member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
-    
+
     member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.stopServer());
-    
+
     put();
-    
+
     cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     cms.getClientPRMetadata((LocalRegion)region);
-    
+
     //member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.verifyMetadata(clientMap));
-    
+
     assertEquals(4/*numBuckets*/, clientMap.size());
     for (Entry entry : clientMap.entrySet()) {
       assertEquals(1, ((List)entry.getValue()).size());
     }
-    
-    wc = new WaitCriterion() {
-      private int bucketId;
-      private int size;
+
+    assertEquals(1, regionMetaData.size());
+    assertTrue(regionMetaData.containsKey(region.getFullPath()));
+    assertEquals(4/*numBuckets*/, clientMap.size());
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> {
+      int bucketId = -1;
+      int size = -1;
       List globalList = new ArrayList();
-      public boolean done() {
-        ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();    
-        Map<String, ClientPartitionAdvisor>  regionMetaData = cms.getClientPRMetadata_TEST_ONLY();    
-        assertEquals(1, regionMetaData.size());
-        assertTrue(regionMetaData.containsKey(region.getFullPath()));    
-        ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
-        Map<Integer, List<BucketServerLocation66>> clientMap  = prMetaData.getBucketServerLocationsMap_TEST_ONLY();
-        assertEquals(4/*numBuckets*/, clientMap.size());
-        boolean finished = true;
-        for (Entry entry : clientMap.entrySet()) {
-          List list = (List)entry.getValue();
-          if(list.size() != 1){
-            size = list.size();
-            globalList = list;
-            bucketId = (Integer)entry.getKey();
-            finished = false;
-          }
+      boolean finished = true;
+      for (Entry entry : clientMap.entrySet()) {
+        List list = (List) entry.getValue();
+        if (list.size() != 1) {
+          size = list.size();
+          globalList = list;
+          bucketId = (Integer) entry.getKey();
+          finished = false;
+          System.out.println("bucket copies are not created, the locations size for bucket id : "
+              + bucketId + " size : " + size + " the list is " + globalList);
         }
-        return finished;
       }
-      public String description() {
-        return "bucket copies are not created, the locations size for bucket id : "
-            + bucketId + " size : " + size + " the list is " + globalList;
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 400, true);
+      return finished;
+    });
   }
 
   //TODO This is failing in WAN_Dev_Dec11 branch after downmerge from trunk revision 34709
-  
+
   // This test is disabled due to intermittent failures in unit test runs
   // Please see ticket #52203
   public void disabledtestClientMetadataForPersistentPrs() throws Exception {
@@ -1109,14 +982,14 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     Integer port1 = (Integer)member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.createPersistentPrsAndServer( 3, 4 ));
     Integer port2 = (Integer)member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.createPersistentPrsAndServer( 3, 4 ));
     Integer port3 = (Integer)member3.invoke(() -> PartitionedRegionSingleHopDUnitTest.createPersistentPrsAndServer( 3, 4 ));
-    
+
     member3.invoke(() -> PartitionedRegionSingleHopDUnitTest.putIntoPartitionedRegions());
-    
+
     member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
     member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
     member2.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
     member3.invoke(() -> PartitionedRegionSingleHopDUnitTest.waitForLocalBucketsCreation(4));
-    
+
     createClient(port0, port1, port2, port3);
     fetchAndValidateMetadata();
     member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.closeCacheAndDisconnect());
@@ -1134,8 +1007,8 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     m0.join();
     fetchAndValidateMetadata();
   }
-  
-  
+
+
   private void fetchAndValidateMetadata() {
     ClientMetadataService service = ((GemFireCacheImpl)this.cache)
         .getClientMetadataService();
@@ -1156,14 +1029,14 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
       if (servers.size() < 4) {
         fail("Servers size is " +servers.size() + " less than expected 4.");
       }
-    }   
+    }
   }
-  
+
   public static void verifyMetadata(Map<Integer, List<BucketServerLocation66>> clientMap){
     final PartitionedRegion pr = (PartitionedRegion)region;
     ConcurrentHashMap<Integer, Set<ServerBucketProfile>> serverMap = pr.getRegionAdvisor().getAllClientBucketProfilesTest();
     assertEquals(clientMap.size(), serverMap.size());
-    assertTrue(clientMap.keySet().containsAll(serverMap.keySet()));    
+    assertTrue(clientMap.keySet().containsAll(serverMap.keySet()));
     for(Map.Entry<Integer, List<BucketServerLocation66>> entry : clientMap.entrySet()){
       int bucketId = entry.getKey();
       List<BucketServerLocation66> list = entry.getValue();
@@ -1191,7 +1064,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
       assertTrue(primaryCnt==1);
     }
   }
-  
+
   public static void waitForLocalBucketsCreation(final int numBuckets){
     final PartitionedRegion pr = (PartitionedRegion)region;
     WaitCriterion wc = new WaitCriterion() {
@@ -1211,37 +1084,21 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     };
     Wait.waitForCriterion(wc, 60000, 400, true);
   }
-  
-  public static void waitForBucketsCreation(){
-    final PartitionedRegion pr = (PartitionedRegion)region;
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        if (pr.getDataStore().getAllLocalBuckets().size() == 2) {
-          return true;
-        }
-        return false;
-      }
-      public String description() {
-        return "bucket copies are not created";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 400, true);
-  }
-  
+
   private void verifyDeadServer(Map<String, ClientPartitionAdvisor> regionMetaData, Region region, int port0, int port1) {
-    
+
     ServerLocation sl0 = new ServerLocation("localhost", port0);
     ServerLocation sl1 = new ServerLocation("localhost", port1);
-    
-    final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath()); 
-    
+
+    final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
+
     for (Entry entry : prMetaData.getBucketServerLocationsMap_TEST_ONLY().entrySet()) {
       List servers = (List)entry.getValue();
       assertFalse( servers.contains(sl0) );
       assertFalse( servers.contains(sl1) );
     }
   }
-  
+
   public static void createClientWithoutPRSingleHopEnabled(int port0) {
     Properties props = new Properties();
     props = new Properties();
@@ -1267,7 +1124,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
 
     createRegionsInClientCache(p.getName());
   }
-  
+
   public static int createAccessorServer() {
     CacheTestCase test = new PartitionedRegionSingleHopDUnitTest(
         "PartitionedRegionSingleHopDUnitTest");
@@ -1405,13 +1262,13 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     assertNotNull(shipmentRegion);
     LogWriterUtils.getLogWriter().info(
         "Partitioned Region SHIPMENT created Successfully :"
-            + shipmentRegion.toString());    
-    
+            + shipmentRegion.toString());
+
     replicatedRegion = cache.createRegion("rr", new AttributesFactory().create());
 
     return port;
   }
-  
+
   public static int createPersistentPrsAndServer(int redundantCopies, int totalNoofBuckets) {
     CacheTestCase test = new PartitionedRegionSingleHopDUnitTest(
         "PartitionedRegionSingleHopDUnitTest");
@@ -1481,8 +1338,8 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     assertNotNull(shipmentRegion);
     LogWriterUtils.getLogWriter().info(
         "Partitioned Region SHIPMENT created Successfully :"
-            + shipmentRegion.toString());    
-    
+            + shipmentRegion.toString());
+
     replicatedRegion = cache.createRegion("rr", new AttributesFactory().create());
     CacheServer server = cache.addCacheServer();
     int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
@@ -1565,8 +1422,8 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     assertNotNull(shipmentRegion);
     LogWriterUtils.getLogWriter().info(
         "Partitioned Region SHIPMENT created Successfully :"
-            + shipmentRegion.toString());    
-    
+            + shipmentRegion.toString());
+
     replicatedRegion = cache.createRegion("rr", new AttributesFactory().create());
     CacheServer server = cache.addCacheServer();
     server.setPort(port);
@@ -1645,12 +1502,12 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     assertNotNull(shipmentRegion);
     LogWriterUtils.getLogWriter().info(
         "Partitioned Region SHIPMENT created Successfully :"
-            + shipmentRegion.toString());    
-    
+            + shipmentRegion.toString());
+
     replicatedRegion = cache.createRegion("rr", new AttributesFactory().create());
 
   }
-  
+
   public static void startServerOnPort(int port) {
     CacheTestCase test = new PartitionedRegionSingleHopDUnitTest(
         "PartitionedRegionSingleHopDUnitTest");
@@ -1665,7 +1522,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
       Assert.fail("Failed to start server ", e);
     }
   }
-  
+
 
   public static void createPeer() {
     CacheTestCase test = new PartitionedRegionSingleHopDUnitTest(
@@ -1826,7 +1683,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
 
     createRegionsInClientCache(p.getName());
   }
-  
+
   private static void createRegionsInClientCache(String poolName) {
     AttributesFactory factory = new AttributesFactory();
     factory.setPoolName(poolName);
@@ -1876,7 +1733,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     factory.setPoolName(poolName);
     replicatedRegion = cache.createRegion("rr", factory.create());
   }
-  
+
   public static void putIntoPartitionedRegions() {
     for (int i = 0; i <= 3; i++) {
       CustId custid = new CustId(i);
@@ -1948,7 +1805,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
       return true;
     }
   }
-  
+
   public static void executeFunctions() {
     Set filter = new HashSet();
     filter.add(0);
@@ -1960,7 +1817,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     FunctionService.onRegion(region).withFilter(filter).execute(new MyFunctionAdapter()).getResult();
     FunctionService.onRegion(region).execute(new MyFunctionAdapter()).getResult();
   }
-  
+
   public static void putAll() {
     Map map = new HashMap();
     map.put(0, 0);
@@ -1971,8 +1828,8 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     region.putAll(map);
     region.putAll(map);
     region.putAll(map);
-  }  
-  
+  }
+
   public static void put() {
 
     region.put(new Integer(0), "create0");
@@ -1992,7 +1849,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     region.put(new Integer(1), "update11");
     region.put(new Integer(2), "update22");
     region.put(new Integer(3), "update33");
-*/  }  
+*/  }
 
   public static void getFromPartitionedRegions() {
     for (int i = 0; i <= 3; i++) {
@@ -2052,7 +1909,7 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     cms.satisfyRefreshMetadata_TEST_ONLY(false);
     region.put(new Integer(0), "update0");
     assertEquals(false, cms.isRefreshMetadataTestOnly());
-    
+
 
     region.put(new Integer(1), "update1");
     assertEquals(false, cms.isRefreshMetadataTestOnly());
@@ -2118,31 +1975,11 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase {
     ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
     final Map<String, ClientPartitionAdvisor> regionMetaData = cms
         .getClientPRMetadata_TEST_ONLY();
-    
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        return (regionMetaData.size() == 4);
-      }
-
-      public String description() {
-        return "expected PRAdvisor to be ready";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
-    
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (regionMetaData.size() == 4));
     assertEquals(4, regionMetaData.size());
     assertTrue(regionMetaData.containsKey(region.getFullPath()));
     final ClientPartitionAdvisor prMetaData = regionMetaData.get(region.getFullPath());
-    wc = new WaitCriterion() {
-      public boolean done() {
-        return (prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() == 4);
-      }
-
-      public String description() {
-        return "expected no metadata to be refreshed";
-      }
-    };
-    Wait.waitForCriterion(wc, 60000, 1000, true);
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (prMetaData.getBucketServerLocationsMap_TEST_ONLY().size() == 4));
   }
 }
 



[21/36] incubator-geode git commit: GEODE-1371: delete unused xml file from java src set

Posted by hi...@apache.org.
GEODE-1371: delete unused xml file from java src set


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

Branch: refs/heads/feature/GEODE-1372
Commit: 3222b0514ba049ee2fdf52685e61a80a92b4eaa3
Parents: 980b492
Author: Kirk Lund <kl...@apache.org>
Authored: Wed May 11 11:23:27 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Wed May 11 11:23:27 2016 -0700

----------------------------------------------------------------------
 .../gemstone/gemfire/test/golden/log4j2-test.xml  | 18 ------------------
 1 file changed, 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3222b051/geode-core/src/test/java/com/gemstone/gemfire/test/golden/log4j2-test.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/golden/log4j2-test.xml b/geode-core/src/test/java/com/gemstone/gemfire/test/golden/log4j2-test.xml
deleted file mode 100755
index 6a885ef..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/golden/log4j2-test.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="ERROR" shutdownHook="disable" packages="com.gemstone.org.apache.logging.log4j.core.config.xml,com.gemstone.gemfire.internal.logging.log4j">
-  <Properties>
-    <Property name="gemfire-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS z} &lt;%thread&gt; tid=%tid] %message%n%throwable%n</Property>
-  </Properties>
-  <Appenders>
-    <Console name="STDOUT" target="SYSTEM_OUT">
-      <PatternLayout pattern="${gemfire-pattern}"/>
-    </Console>
-  </Appenders>
-  <Loggers>
-    <Logger name="com.gemstone" level="WARN" additivity="true"/>
-    <Logger name="quickstart" level="WARN" additivity="true"/>
-    <Root level="ERROR">
-      <AppenderRef ref="STDOUT"/>
-    </Root>
-  </Loggers>
-</Configuration>


[19/36] incubator-geode git commit: GEODE-1330: Set boolean so that internal lucene regions aren't generated in xml

Posted by hi...@apache.org.
GEODE-1330: Set boolean so that internal lucene regions aren't generated in xml


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

Branch: refs/heads/feature/GEODE-1372
Commit: c92e5dad2464a7d633db11ccf80b1a07dc6d569a
Parents: 3ebcf1f
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Mon May 9 15:00:31 2016 -0700
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Wed May 11 10:43:56 2016 -0700

----------------------------------------------------------------------
 .../LuceneIndexForPartitionedRegion.java        | 38 ++++-----
 .../LuceneIndexForReplicatedRegion.java         |  1 +
 .../cache/lucene/internal/LuceneIndexImpl.java  | 29 +++++++
 .../LuceneIndexCreationIntegrationTest.java     | 74 ++++++++++++++++++
 .../LuceneIndexForPartitionedRegionTest.java    | 82 +++++++++++---------
 .../lucene/internal/LuceneIntegrationTest.java  | 47 +++++++++++
 6 files changed, 217 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c92e5dad/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index 28ff543..382f61c 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -19,6 +19,7 @@
 
 package com.gemstone.gemfire.cache.lucene.internal;
 
+import com.gemstone.gemfire.cache.AttributesFactory;
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.DataPolicy;
 import com.gemstone.gemfire.cache.PartitionAttributes;
@@ -37,12 +38,8 @@ import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 /* wrapper of IndexWriter */
 public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
 
-  private final Cache cache;
-
   public LuceneIndexForPartitionedRegion(String indexName, String regionPath, Cache cache) {
-    this.indexName = indexName;
-    this.regionPath = regionPath;
-    this.cache = cache;
+    super(indexName, regionPath, cache);
   }
 
   @Override
@@ -138,13 +135,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
   Region createFileRegion(final RegionShortcut regionShortCut,
                                 final String fileRegionName,
                                 final PartitionAttributes partitionAttributes) {
-    PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory<String, File>();
-    partitionAttributesFactory.setColocatedWith(regionPath);
-    configureLuceneRegionAttributesFactory(partitionAttributesFactory, partitionAttributes);
-
-    return cache.<String, File> createRegionFactory(regionShortCut)
-        .setPartitionAttributes(partitionAttributesFactory.create())
-        .create(fileRegionName);
+    return createRegion(fileRegionName, regionShortCut, this.regionPath, partitionAttributes);
   }
 
   String createFileRegionName() {
@@ -158,13 +149,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
   Region<ChunkKey, byte[]> createChunkRegion(final RegionShortcut regionShortCut,
                            final String fileRegionName,
                            final PartitionAttributes partitionAttributes, final String chunkRegionName) {
-    PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory<String, File>();
-    partitionAttributesFactory.setColocatedWith(fileRegionName);
-    configureLuceneRegionAttributesFactory(partitionAttributesFactory, partitionAttributes);
-
-    return cache.<ChunkKey, byte[]> createRegionFactory(regionShortCut)
-      .setPartitionAttributes(partitionAttributesFactory.create())
-      .create(chunkRegionName);
+    return createRegion(chunkRegionName, regionShortCut, fileRegionName, partitionAttributes);
   }
 
   String createChunkRegionName() {
@@ -177,6 +162,21 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     return attributesFactory;
   }
 
+  protected <K, V> Region<K, V> createRegion(final String regionName, final RegionShortcut regionShortCut,
+      final String colocatedWithRegionName, final PartitionAttributes partitionAttributes) {
+    PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory<String, File>();
+    partitionAttributesFactory.setColocatedWith(colocatedWithRegionName);
+    configureLuceneRegionAttributesFactory(partitionAttributesFactory, partitionAttributes);
+
+    // Create AttributesFactory based on input RegionShortcut
+    RegionAttributes baseAttributes = this.cache.getRegionAttributes(regionShortCut.toString());
+    AttributesFactory factory = new AttributesFactory(baseAttributes);
+    factory.setPartitionAttributes(partitionAttributesFactory.create());
+    RegionAttributes<K, V> attributes = factory.create();
+
+    return createRegion(regionName, attributes);
+  }
+
   public void close() {
     // TODO Auto-generated method stub
     

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c92e5dad/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForReplicatedRegion.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForReplicatedRegion.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForReplicatedRegion.java
index cd07672..c24cb9d 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForReplicatedRegion.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForReplicatedRegion.java
@@ -29,6 +29,7 @@ import com.gemstone.gemfire.cache.Cache;
 public class LuceneIndexForReplicatedRegion extends LuceneIndexImpl {
 
   public LuceneIndexForReplicatedRegion(String indexName, String regionPath, Cache cache) {
+    super(indexName, regionPath, cache);
     throw new UnsupportedOperationException("Lucene indexes on replicated regions is not yet implemented");
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c92e5dad/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java
index 1158fd1..0b5f8fa 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java
@@ -22,6 +22,12 @@ package com.gemstone.gemfire.cache.lucene.internal;
 import java.util.Collections;
 import java.util.Map;
 
+import com.gemstone.gemfire.InternalGemFireError;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.InternalRegionArguments;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import org.apache.logging.log4j.Logger;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -50,6 +56,14 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
   protected boolean hasInitialized = false;
   protected Map<String, Analyzer> fieldAnalyzers;
 
+  protected final Cache cache;
+  
+  protected LuceneIndexImpl(String indexName, String regionPath, Cache cache) {
+    this.indexName = indexName;
+    this.regionPath = regionPath;
+    this.cache = cache;
+  }
+
   @Override
   public String getName() {
     return this.indexName;
@@ -108,4 +122,19 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
     creation.setFieldAnalyzers(this.getFieldAnalyzers());
     dataRegion.getExtensionPoint().addExtension(creation);
   }
+
+  protected <K, V> Region<K, V> createRegion(final String regionName, final RegionAttributes<K, V> attributes) {
+    // Create InternalRegionArguments to set isUsedForMetaRegion true to suppress xml generation (among other things)
+    InternalRegionArguments ira = new InternalRegionArguments().setDestroyLockFlag(true).setRecreateFlag(false)
+        .setSnapshotInputStream(null).setImageTarget(null).setIsUsedForMetaRegion(true);
+
+    // Create the region
+    try {
+      return ((GemFireCacheImpl)this.cache).createVMRegion(regionName, attributes, ira);
+    } catch (Exception e) {
+      InternalGemFireError ige = new InternalGemFireError(LocalizedStrings.GemFireCache_UNEXPECTED_EXCEPTION.toLocalizedString());
+      ige.initCause(e);
+      throw ige;
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c92e5dad/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationIntegrationTest.java
new file mode 100644
index 0000000..e04d1c7
--- /dev/null
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationIntegrationTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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 com.gemstone.gemfire.cache.lucene.internal;
+
+import static org.junit.Assert.*;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.lucene.LuceneServiceProvider;
+import com.gemstone.gemfire.internal.cache.LocalRegion;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(IntegrationTest.class)
+public class LuceneIndexCreationIntegrationTest extends LuceneIntegrationTest {
+
+  @Test
+  public void verifyLuceneRegionInternal() {
+    // Create cache
+    createCache();
+
+    // Create index
+    String indexName = "index";
+    String regionName = this.name.getMethodName();
+    createIndex(indexName, regionName, "text");
+
+    // Create partitioned region
+    createRegion(regionName);
+
+    // Get index
+    LuceneIndexForPartitionedRegion index = (LuceneIndexForPartitionedRegion) LuceneServiceProvider.get(this.cache).getIndex(indexName, regionName);
+    assertNotNull(index);
+
+    // Verify the meta regions exist and are internal
+    LocalRegion chunkRegion = (LocalRegion) this.cache.getRegion(index.createChunkRegionName());
+    assertNotNull(chunkRegion);
+    assertTrue(chunkRegion.isInternalRegion());
+    LocalRegion fileRegion = (LocalRegion) this.cache.getRegion(index.createFileRegionName());
+    assertNotNull(fileRegion);
+    assertTrue(fileRegion.isInternalRegion());
+
+    // Verify the meta regions are not contained in the root regions
+    for (Region region : cache.rootRegions()) {
+      assertNotEquals(chunkRegion.getFullPath(), region.getFullPath());
+      assertNotEquals(fileRegion.getFullPath(), region.getFullPath());
+    }
+  }
+
+  private Region createRegion(String regionName) {
+    return this.cache.createRegionFactory(RegionShortcut.PARTITION).create(regionName);
+  }
+
+  private void createIndex(String indexName, String regionName, String fieldName) {
+    LuceneServiceProvider.get(this.cache).createIndex(indexName, regionName, fieldName);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c92e5dad/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
index ff22f85..984b221 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
@@ -27,12 +27,15 @@ import org.junit.experimental.categories.Category;
 import org.junit.rules.ExpectedException;
 
 import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheListener;
 import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.ExpirationAttributes;
+import com.gemstone.gemfire.cache.MembershipAttributes;
 import com.gemstone.gemfire.cache.PartitionAttributes;
 import com.gemstone.gemfire.cache.RegionAttributes;
-import com.gemstone.gemfire.cache.RegionFactory;
 import com.gemstone.gemfire.cache.RegionShortcut;
 import com.gemstone.gemfire.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.extension.ExtensionPoint;
 import com.gemstone.gemfire.test.fake.Fakes;
@@ -113,38 +116,6 @@ public class LuceneIndexForPartitionedRegionTest {
   }
 
   @Test
-  public void createChunkRegionWithPartitionShortcutCreatesRegionThroughFactory() {
-    String name = "indexName";
-    String regionPath = "regionName";
-    Cache cache = Fakes.cache();
-    RegionFactory regionFactory = mock(RegionFactory.class);
-    PartitionAttributes partitionAttributes = mock(PartitionAttributes.class);
-    when(cache.createRegionFactory(RegionShortcut.PARTITION)).thenReturn(regionFactory);
-    when(regionFactory.setPartitionAttributes(any())).thenReturn(regionFactory);
-    when(partitionAttributes.getTotalNumBuckets()).thenReturn(113);
-    LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache);
-
-    index.createChunkRegion(RegionShortcut.PARTITION, index.createFileRegionName(), partitionAttributes, index.createChunkRegionName());
-    verify(regionFactory).create(index.createChunkRegionName());
-  }
-
-  @Test
-  public void createFileRegionWithPartitionShortcutCreatesRegionThroughFactory() {
-    String name = "indexName";
-    String regionPath = "regionName";
-    Cache cache = Fakes.cache();
-    RegionFactory regionFactory = mock(RegionFactory.class);
-    PartitionAttributes partitionAttributes = mock(PartitionAttributes.class);
-    when(cache.createRegionFactory(RegionShortcut.PARTITION)).thenReturn(regionFactory);
-    when(regionFactory.setPartitionAttributes(any())).thenReturn(regionFactory);
-    when(partitionAttributes.getTotalNumBuckets()).thenReturn(113);
-    LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache);
-
-    index.createFileRegion(RegionShortcut.PARTITION, index.createFileRegionName(), partitionAttributes);
-    verify(regionFactory).create(index.createFileRegionName());
-  }
-
-  @Test
   public void createAEQWithPersistenceCallsCreateOnAEQFactory() {
     String name = "indexName";
     String regionPath = "regionName";
@@ -181,11 +152,9 @@ public class LuceneIndexForPartitionedRegionTest {
     PartitionedRegion region = mock(PartitionedRegion.class);
     RegionAttributes regionAttributes = mock(RegionAttributes.class);
     PartitionAttributes partitionAttributes = mock(PartitionAttributes.class);
-    RegionFactory regionFactory = mock(RegionFactory.class);
     DataPolicy dataPolicy = mock(DataPolicy.class);
     ExtensionPoint extensionPoint = mock(ExtensionPoint.class);
     when(cache.getRegion(regionPath)).thenReturn(region);
-    when(cache.createRegionFactory(isA(RegionShortcut.class))).thenReturn(regionFactory);
     when(region.getAttributes()).thenReturn(regionAttributes);
     when(regionAttributes.getPartitionAttributes()).thenReturn(partitionAttributes);
     when(regionAttributes.getDataPolicy()).thenReturn(dataPolicy);
@@ -195,6 +164,20 @@ public class LuceneIndexForPartitionedRegionTest {
     when(region.getExtensionPoint()).thenReturn(extensionPoint);
   }
 
+  private PartitionAttributes initializeAttributes(final Cache cache) {
+    PartitionAttributes partitionAttributes = mock(PartitionAttributes.class);
+    RegionAttributes attributes = mock(RegionAttributes.class);
+    when(attributes.getCacheListeners()).thenReturn(new CacheListener[0]);
+    when(attributes.getRegionTimeToLive()).thenReturn(ExpirationAttributes.DEFAULT);
+    when(attributes.getRegionIdleTimeout()).thenReturn(ExpirationAttributes.DEFAULT);
+    when(attributes.getEntryTimeToLive()).thenReturn(ExpirationAttributes.DEFAULT);
+    when(attributes.getEntryIdleTimeout()).thenReturn(ExpirationAttributes.DEFAULT);
+    when(attributes.getMembershipAttributes()).thenReturn(new MembershipAttributes());
+    when(cache.getRegionAttributes(RegionShortcut.PARTITION.toString())).thenReturn(attributes);
+    when(partitionAttributes.getTotalNumBuckets()).thenReturn(113);
+    return partitionAttributes;
+  }
+
   @Test
   public void initializeWithNoLocalMemoryThrowsException() {
     expectedExceptions.expect(IllegalStateException.class);
@@ -285,6 +268,35 @@ public class LuceneIndexForPartitionedRegionTest {
   }
 
   @Test
+  public void createFileRegionWithPartitionShortcutCreatesRegionUsingCreateVMRegion() throws Exception {
+    String name = "indexName";
+    String regionPath = "regionName";
+    GemFireCacheImpl cache = Fakes.cache();
+    PartitionAttributes partitionAttributes = initializeAttributes(cache);
+    LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache);
+    LuceneIndexForPartitionedRegion indexSpy = spy(index);
+    indexSpy.createFileRegion(RegionShortcut.PARTITION, index.createFileRegionName(), partitionAttributes);
+    String fileRegionName = index.createFileRegionName();
+    verify(indexSpy).createRegion(fileRegionName, RegionShortcut.PARTITION, regionPath, partitionAttributes);
+    verify(cache).createVMRegion(eq(fileRegionName), any(), any());
+  }
+
+  @Test
+  public void createChunkRegionWithPartitionShortcutCreatesRegionUsingCreateVMRegion() throws Exception {
+    String name = "indexName";
+    String regionPath = "regionName";
+    GemFireCacheImpl cache = Fakes.cache();
+    PartitionAttributes partitionAttributes = initializeAttributes(cache);
+    LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache);
+    LuceneIndexForPartitionedRegion indexSpy = spy(index);
+    String chunkRegionName = index.createChunkRegionName();
+    String fileRegionName = index.createFileRegionName();
+    indexSpy.createChunkRegion(RegionShortcut.PARTITION, fileRegionName, partitionAttributes, chunkRegionName);
+    verify(indexSpy).createRegion(chunkRegionName, RegionShortcut.PARTITION, fileRegionName, partitionAttributes);
+    verify(cache).createVMRegion(eq(chunkRegionName), any(), any());
+  }
+
+  @Test
   public void initializeShouldCreatePartitionPersistentChunkRegion() {
     boolean withPersistence = true;
     String name = "indexName";

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c92e5dad/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIntegrationTest.java
new file mode 100644
index 0000000..4d94042
--- /dev/null
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIntegrationTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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 com.gemstone.gemfire.cache.lucene.internal;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+public class LuceneIntegrationTest {
+
+  protected Cache cache;
+
+  @Rule
+  public TestName name = new TestName();
+
+  @After
+  public void tearDown() {
+    if(this.cache != null) {
+      this.cache.close();
+    }
+  }
+
+  protected void createCache() {
+    CacheFactory cf = new CacheFactory();
+    cf.set("mcast-port", "0");
+    this.cache = cf.create();
+  }
+}


[02/36] incubator-geode git commit: GEODE-1234: add a test hook to track client transactions scheduled to be removed.

Posted by hi...@apache.org.
GEODE-1234: add a test hook to track client transactions scheduled to be removed.


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

Branch: refs/heads/feature/GEODE-1372
Commit: 0bf5425491a0ddbe0d614ab174be98957072f962
Parents: 3fe55d4
Author: eshu <es...@pivotal.io>
Authored: Mon May 9 16:36:59 2016 -0700
Committer: eshu <es...@pivotal.io>
Committed: Mon May 9 16:36:59 2016 -0700

----------------------------------------------------------------------
 .../cache/tier/sockets/ClientHealthMonitor.java       | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0bf54254/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientHealthMonitor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientHealthMonitor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientHealthMonitor.java
index 93e543d..c0f5021 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientHealthMonitor.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientHealthMonitor.java
@@ -42,6 +42,7 @@ import com.gemstone.gemfire.internal.cache.IncomingGatewayStatus;
 import com.gemstone.gemfire.internal.cache.TXId;
 import com.gemstone.gemfire.internal.cache.TXManagerImpl;
 import com.gemstone.gemfire.internal.cache.tier.Acceptor;
+import com.gemstone.gemfire.internal.concurrent.ConcurrentHashSet;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
@@ -278,6 +279,16 @@ public class ClientHealthMonitor {
       }
     }
   }
+  
+  private final Set<TXId> scheduledToBeRemovedTx = Boolean.getBoolean("gemfire.trackScheduledToBeRemovedTx")? 
+      new ConcurrentHashSet<TXId>() : null;
+
+  /**
+   * provide a test hook to track client transactions to be removed
+   */
+  public Set<TXId> getScheduledToBeRemovedTx() {
+    return scheduledToBeRemovedTx;
+  }
 
   /**
    * expire the transaction states for the given client.  This uses the
@@ -298,13 +309,16 @@ public class ClientHealthMonitor {
       if (logger.isDebugEnabled()) {
         logger.debug("expiring {} transaction contexts for {} timeout={}", txids.size(), proxyID, timeout/1000);
       }
+
       if (timeout <= 0) {
         txMgr.removeTransactions(txids, true);
       } else {
+        if (scheduledToBeRemovedTx != null) scheduledToBeRemovedTx.addAll(txids);       
         SystemTimerTask task = new SystemTimerTask() {
           @Override
           public void run2() {
             txMgr.removeTransactions(txids, true);
+            if (scheduledToBeRemovedTx != null) scheduledToBeRemovedTx.removeAll(txids);
           }
         };
         ((GemFireCacheImpl)this._cache).getCCPTimer().schedule(task, timeout);


[31/36] incubator-geode git commit: GEODE-1372 Geode UDP communications are not secure when SSL is configured

Posted by hi...@apache.org.
GEODE-1372 Geode UDP communications are not secure when SSL is configured

This branch contains Diffe Hellman encoding of UDP communications in Geode
using the encryption scheme that is already available for client/server
communications.  The current implementation uses security-client-dhalgo
to enable encryption.

Membership views hold the public keys of peers.  GMSEncrypt is a new
object that is held by JGroupsMessenger and is used to perform the
encryption/decryption.

GMSJoinLeave is modified to send a new member's public key to the
membership coordinator.  The coordinator sends its public key back prior
to announcing the new membership view with the new member.  This should
be changed to have the coordinator's public key be sent to the joining
member and the coordinator should get the new member's public key from
a locator as well.

GMSEncrypt needs to be changed to record time spent encrypting and
decrypting in DistributionStats as well as the number of encryptions/decryptions
performed.


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

Branch: refs/heads/feature/GEODE-1372
Commit: a28b223a60c9ede73776cca245c9f650b4db66c1
Parents: 89b91cb
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Mon May 9 15:59:33 2016 -0700
Committer: Hitesh Khamesra <hi...@yahoo.com>
Committed: Thu May 19 10:18:23 2016 -0700

----------------------------------------------------------------------
 .../internal/membership/NetView.java            |  33 +-
 .../membership/gms/interfaces/Messenger.java    |   8 +
 .../membership/gms/membership/GMSJoinLeave.java |  30 +-
 .../gms/messages/JoinRequestMessage.java        |  15 +-
 .../membership/gms/messenger/GMSEncrypt.java    | 333 +++++++++++++++++++
 .../gms/messenger/JGroupsMessenger.java         | 160 ++++++---
 .../membership/MembershipJUnitTest.java         | 138 ++++++++
 .../gms/messenger/GMSEncryptJUnitTest.java      |  97 ++++++
 .../messenger/JGroupsMessengerJUnitTest.java    |   6 +-
 9 files changed, 748 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a28b223a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/NetView.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/NetView.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/NetView.java
old mode 100644
new mode 100755
index af4aec3..365a193
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/NetView.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/NetView.java
@@ -19,15 +19,8 @@ package com.gemstone.gemfire.distributed.internal.membership;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Random;
-import java.util.Set;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
 import com.gemstone.gemfire.internal.logging.LogService;
 import org.apache.logging.log4j.Logger;
@@ -50,6 +43,8 @@ public class NetView implements DataSerializableFixedID {
 
   private int viewId;
   private List<InternalDistributedMember> members;
+  // TODO this should be a List
+  private Map<InternalDistributedMember, Object> publicKeys = new ConcurrentHashMap<>();
   private int[] failureDetectionPorts = new int[10];
   private Set<InternalDistributedMember> shutdownMembers;
   private Set<InternalDistributedMember> crashedMembers;
@@ -114,6 +109,7 @@ public class NetView implements DataSerializableFixedID {
     this.hashedMembers = new HashSet<InternalDistributedMember>(other.members);
     this.failureDetectionPorts = new int[other.failureDetectionPorts.length];
     System.arraycopy(other.failureDetectionPorts, 0, this.failureDetectionPorts, 0, other.failureDetectionPorts.length);
+    this.publicKeys = new HashMap<>(other.publicKeys);
     this.shutdownMembers = new HashSet<InternalDistributedMember>(other.shutdownMembers);
     this.crashedMembers = new HashSet<InternalDistributedMember>(other.crashedMembers);
   }
@@ -142,6 +138,19 @@ public class NetView implements DataSerializableFixedID {
     this.creator = creator;
   }
   
+  public Object getPublicKey(InternalDistributedMember mbr) {
+    return publicKeys.get(mbr);
+  }
+
+  public void setPublicKey(InternalDistributedMember mbr, Object key) {
+    publicKeys.put(mbr, key);
+  }
+
+  public void setPublicKeys(NetView otherView) {
+    this.publicKeys.putAll(otherView.publicKeys);
+  }
+
+
   public int[] getFailureDetectionPorts() {
     return this.failureDetectionPorts;
   }
@@ -153,7 +162,8 @@ public class NetView implements DataSerializableFixedID {
     }
     return failureDetectionPorts[idx];
   }
-  
+
+
   public void setFailureDetectionPort(InternalDistributedMember mbr, int port) {
     int idx = members.indexOf(mbr);
     if (idx < 0) {
@@ -575,6 +585,8 @@ public class NetView implements DataSerializableFixedID {
     InternalDataSerializer.writeSet(shutdownMembers, out);
     InternalDataSerializer.writeSet(crashedMembers, out);
     DataSerializer.writeIntArray(failureDetectionPorts, out);
+    // TODO expensive serialization
+    DataSerializer.writeObject(publicKeys, out);
   }
 
   @Override
@@ -586,6 +598,7 @@ public class NetView implements DataSerializableFixedID {
     shutdownMembers = InternalDataSerializer.readHashSet(in);
     crashedMembers = InternalDataSerializer.readHashSet(in);
     failureDetectionPorts = DataSerializer.readIntArray(in);
+    publicKeys = DataSerializer.readObject(in);
   }
 
   /** this will deserialize as an ArrayList */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a28b223a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Messenger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Messenger.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Messenger.java
index 5bb6c4b..e10f325 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Messenger.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Messenger.java
@@ -21,6 +21,7 @@ import java.util.Set;
 
 import com.gemstone.gemfire.distributed.internal.DistributionMessage;
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
+import com.gemstone.gemfire.distributed.internal.membership.NetView;
 import com.gemstone.gemfire.distributed.internal.membership.QuorumChecker;
 
 public interface Messenger extends Service {
@@ -30,6 +31,13 @@ public interface Messenger extends Service {
   void addHandler(Class c, MessageHandler h);
 
   /**
+   * sends an asynchronous message when the membership view may not have
+   * been established.  Returns destinations that did not
+   * receive the message due to no longer being in the view
+   */
+  Set<InternalDistributedMember> send(DistributionMessage m, NetView alternateView);
+
+  /**
    * sends an asynchronous message.  Returns destinations that did not
    * receive the message due to no longer being in the view
    */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a28b223a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index e12740e..d70884a 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -362,7 +362,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
       logger.info("Attempting to join the distributed system through coordinator " + coord + " using address " + this.localAddress);
       int port = services.getHealthMonitor().getFailureDetectionPort();
       JoinRequestMessage req = new JoinRequestMessage(coord, this.localAddress, services.getAuthenticator().getCredentials(coord), port);
-      services.getMessenger().send(req);
+      services.getMessenger().send(req, state.view);
     }
 
     JoinResponseMessage response = null;
@@ -770,6 +770,14 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     }
   }
 
+  private void sendJoinResponses(List<InternalDistributedMember> newMbrs, NetView newView) {
+    for (InternalDistributedMember mbr : newMbrs) {
+      JoinResponseMessage response = new JoinResponseMessage(mbr, newView);
+      services.getMessenger().send(response);
+    }
+  }
+
+
   boolean prepareView(NetView view, List<InternalDistributedMember> newMembers) throws InterruptedException {
     return sendView(view, newMembers, true, this.prepareProcessor);
   }
@@ -833,7 +841,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     pendingRemovals.removeAll(view.getCrashedMembers());
     viewReplyProcessor.initialize(id, responders);
     viewReplyProcessor.processPendingRequests(pendingLeaves, pendingRemovals);
-    services.getMessenger().send(msg);
+    services.getMessenger().send(msg, view);
 
     // only wait for responses during preparation
     if (preparing) {
@@ -892,22 +900,22 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         services.getMessenger().send(new ViewAckMessage(m.getSender(), this.preparedView));
       } else {
         this.preparedView = view;
-        ackView(m);
         if (viewContainsMyUnjoinedAddress) {
           installView(view); // this will notifyAll the joinResponse
         }
+        ackView(m);
       }
     } else { // !preparing
       if (isJoined && currentView != null && !view.contains(this.localAddress)) {
         logger.fatal("This member is no longer in the membership view.  My ID is {} and the new view is {}", localAddress, view);
         forceDisconnect("This node is no longer in the membership view");
       } else {
-        if (!m.isRebroadcast()) { // no need to ack a rebroadcast view
-          ackView(m);
-        }
         if (isJoined || viewContainsMyUnjoinedAddress) {
           installView(view);
         }
+        if (!m.isRebroadcast()) { // no need to ack a rebroadcast view
+          ackView(m);
+        }
       }
     }
   }
@@ -919,7 +927,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
 
   private void ackView(InstallViewMessage m) {
     if (!playingDead && m.getView().contains(m.getView().getCreator())) {
-      services.getMessenger().send(new ViewAckMessage(m.getSender(), m.getView().getViewId(), m.isPreparing()));
+      services.getMessenger().send(new ViewAckMessage(m.getSender(), m.getView().getViewId(), m.isPreparing()), m.getView());
     }
   }
 
@@ -1901,6 +1909,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         for (InternalDistributedMember newMember : newMembers) {
           newView.add(newMember);
           newView.setFailureDetectionPort(newMember, v.getFailureDetectionPort(newMember));
+          newView.setPublicKey(newMember, v.getPublicKey(newMember));
         }
 
         // use the new view as the initial view
@@ -2024,6 +2033,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     void createAndSendView(List<DistributionMessage> requests) throws InterruptedException {
       List<InternalDistributedMember> joinReqs = new ArrayList<>(10);
       Map<InternalDistributedMember, Integer> joinPorts = new HashMap<>(10);
+      Map<InternalDistributedMember, Object> joinKeys = new HashMap<>(10);
       Set<InternalDistributedMember> leaveReqs = new HashSet<>(10);
       List<InternalDistributedMember> removalReqs = new ArrayList<>(10);
       List<String> removalReasons = new ArrayList<String>(10);
@@ -2057,6 +2067,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
           if (!joinReqs.contains(mbr)) {
             joinReqs.add(mbr);
             joinPorts.put(mbr, port);
+            joinKeys.put(mbr, jmsg.getPublicKey());
           }
           break;
         case LEAVE_REQUEST_MESSAGE:
@@ -2126,10 +2137,12 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         for (InternalDistributedMember mbr : joinReqs) {
           if (mbrs.contains(mbr)) {
             newView.setFailureDetectionPort(mbr, joinPorts.get(mbr));
+            newView.setPublicKey(mbr, joinKeys.get(mbr));
           }
         }
         if (currentView != null) {
           newView.setFailureDetectionPorts(currentView);
+          newView.setPublicKeys(currentView);
         }
       }
 
@@ -2147,6 +2160,9 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
       if (isShutdown()) {
         return;
       }
+
+      sendJoinResponses(joinReqs, newView);
+
       // send removal messages before installing the view so we stop
       // getting messages from members that have been kicked out
       sendRemoveMessages(removalReqs, removalReasons, newView, oldIDs);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a28b223a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messages/JoinRequestMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messages/JoinRequestMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messages/JoinRequestMessage.java
index 0e84e92..5545935 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messages/JoinRequestMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messages/JoinRequestMessage.java
@@ -30,20 +30,25 @@ public class JoinRequestMessage extends HighPriorityDistributionMessage {
   private InternalDistributedMember memberID;
   private Object credentials;
   private int failureDetectionPort = -1;
+  private Object publicKey;
   
   public JoinRequestMessage(InternalDistributedMember coord,
-      InternalDistributedMember id, Object credentials, int fdPort) {
+                            InternalDistributedMember id, Object credentials, int fdPort) {
     super();
     setRecipient(coord);
     this.memberID = id;
     this.credentials = credentials;
+    this.publicKey = null;
     this.failureDetectionPort = fdPort;
   }
-  
   public JoinRequestMessage() {
     // no-arg constructor for serialization
   }
 
+  public void setPublicKey(Object key) {
+    this.publicKey = key;
+  }
+
   @Override
   public int getDSFID() {
     return JOIN_REQUEST;
@@ -61,6 +66,10 @@ public class JoinRequestMessage extends HighPriorityDistributionMessage {
   public Object getCredentials() {
     return credentials;
   }
+
+  public Object getPublicKey() {
+    return publicKey;
+  }
   
   @Override
   public String toString() {
@@ -76,6 +85,7 @@ public class JoinRequestMessage extends HighPriorityDistributionMessage {
   public void toData(DataOutput out) throws IOException {
     DataSerializer.writeObject(memberID, out);
     DataSerializer.writeObject(credentials, out);
+    DataSerializer.writeObject(publicKey, out);
     DataSerializer.writePrimitiveInt(failureDetectionPort, out);
     // preserve the multicast setting so the receiver can tell
     // if this is a mcast join request
@@ -86,6 +96,7 @@ public class JoinRequestMessage extends HighPriorityDistributionMessage {
   public void fromData(DataInput in) throws IOException, ClassNotFoundException {
     memberID = DataSerializer.readObject(in);
     credentials = DataSerializer.readObject(in);
+    publicKey = DataSerializer.readObject(in);
     failureDetectionPort = DataSerializer.readPrimitiveInt(in);
     setMulticast(in.readBoolean());
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a28b223a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
new file mode 100755
index 0000000..3f61453
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
@@ -0,0 +1,333 @@
+/*
+ * 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 com.gemstone.gemfire.distributed.internal.membership.gms.messenger;
+
+
+import java.math.BigInteger;
+import java.security.*;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyAgreement;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.DHParameterSpec;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
+import com.gemstone.gemfire.distributed.internal.membership.NetView;
+import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
+import org.apache.logging.log4j.Logger;
+
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.logging.LogService;
+
+public class GMSEncrypt {
+  public static long encodingsPerformed;
+  public static long decodingsPerformed;
+
+  private static final Logger logger = LogService.getLogger();
+
+  // Parameters for the Diffie-Hellman key exchange
+  private static final BigInteger dhP = new BigInteger(
+    "13528702063991073999718992897071702177131142188276542919088770094024269"
+      +  "73079899070080419278066109785292538223079165925365098181867673946"
+      +  "34756714063947534092593553024224277712367371302394452615862654308"
+      +  "11180902979719649450105660478776364198726078338308557022096810447"
+      +  "3500348898008043285865193451061481841186553");
+
+  private static final BigInteger dhG = new BigInteger(
+    "13058345680719715096166513407513969537624553636623932169016704425008150"
+      +  "56576152779768716554354314319087014857769741104157332735258102835"
+      +  "93126577393912282416840649805564834470583437473176415335737232689"
+      +  "81480201869671811010996732593655666464627559582258861254878896534"
+      +  "1273697569202082715873518528062345259949959");
+
+  private static final int dhL = 1023;
+
+  private  PrivateKey dhPrivateKey = null;
+
+  private  PublicKey dhPublicKey = null;
+
+  private  String dhSKAlgo = null;
+
+  private Services services;
+
+  private NetView view;
+
+  private Map<InternalDistributedMember, PeerEncryptor> memberToPeerEncryptor = new ConcurrentHashMap<>();
+
+
+  protected void installView(NetView view) {
+    this.view = view;
+    this.view.setPublicKey(services.getJoinLeave().getMemberID(), getPublicKeyBytes());
+    // TODO remove ciphers for departed members
+  }
+
+
+
+  public GMSEncrypt(Services services) throws  Exception {
+    this.services = services;
+    initDHKeys(services.getConfig().getDistributionConfig());
+  }
+
+  public byte[] decryptData(byte[] data, InternalDistributedMember member) throws Exception {
+    return getPeerEncryptor(member).decryptBytes(data);
+  }
+
+  public byte[] encryptData(byte[] data, InternalDistributedMember member) throws Exception {
+    return getPeerEncryptor(member).encryptBytes(data);
+  }
+
+  protected byte[] getPublicKeyBytes() {
+    return dhPublicKey.getEncoded();
+  }
+
+
+  /**
+   * Initialize the Diffie-Hellman keys. This method is not thread safe
+   */
+  private void initDHKeys(DistributionConfig config) throws Exception {
+
+    dhSKAlgo = config.getSecurityClientDHAlgo();
+    // Initialize the keys when either the host is a peer that has
+    // non-blank setting for DH symmetric algo, or this is a server
+    // that has authenticator defined.
+    if ((dhSKAlgo != null && dhSKAlgo.length() > 0)) {
+      KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH");
+      DHParameterSpec dhSpec = new DHParameterSpec(dhP, dhG, dhL);
+      keyGen.initialize(dhSpec);
+      KeyPair keypair = keyGen.generateKeyPair();
+
+      // Get the generated public and private keys
+      dhPrivateKey = keypair.getPrivate();
+      dhPublicKey = keypair.getPublic();
+    }
+  }
+
+  protected synchronized PeerEncryptor getPeerEncryptor(InternalDistributedMember member) throws Exception{
+    PeerEncryptor result = memberToPeerEncryptor.get(member);
+    if (result == null) {
+      result = createPeerEncryptor(member);
+    }
+    return result;
+  }
+
+  private PeerEncryptor createPeerEncryptor(InternalDistributedMember member) throws Exception {
+    byte[] peerKeyBytes = (byte[]) view.getPublicKey(member);
+    PeerEncryptor result = new PeerEncryptor(peerKeyBytes);
+    memberToPeerEncryptor.put(member, result);
+    return result;
+  }
+
+
+  private static int getKeySize(String skAlgo) {
+    // skAlgo contain both algo and key size info
+    int colIdx = skAlgo.indexOf(':');
+    String algoStr;
+    int algoKeySize = 0;
+    if (colIdx >= 0) {
+      algoStr = skAlgo.substring(0, colIdx);
+      algoKeySize = Integer.parseInt(skAlgo.substring(colIdx + 1));
+    }
+    else {
+      algoStr = skAlgo;
+    }
+    int keysize = -1;
+    if (algoStr.equalsIgnoreCase("DESede")) {
+      keysize = 24;
+    }
+    else if (algoStr.equalsIgnoreCase("Blowfish")) {
+      keysize = algoKeySize > 128 ? algoKeySize / 8 : 16;
+    }
+    else if (algoStr.equalsIgnoreCase("AES")) {
+      keysize = (algoKeySize != 192 && algoKeySize != 256) ? 16
+        : algoKeySize / 8;
+    }
+    return keysize;
+  }
+
+  private static String getDhAlgoStr(String skAlgo) {
+    int colIdx = skAlgo.indexOf(':');
+    String algoStr;
+    if (colIdx >= 0) {
+      algoStr = skAlgo.substring(0, colIdx);
+    }
+    else {
+      algoStr = skAlgo;
+    }
+    return algoStr;
+  }
+
+  private static int getBlockSize(String skAlgo) {
+    int blocksize = -1;
+    String algoStr = getDhAlgoStr(skAlgo);
+    if (algoStr.equalsIgnoreCase("DESede")) {
+      blocksize = 8;
+    }
+    else if (algoStr.equalsIgnoreCase("Blowfish")) {
+      blocksize = 8;
+    }
+    else if (algoStr.equalsIgnoreCase("AES")) {
+      blocksize = 16;
+    }
+    return blocksize;
+  }
+
+  static public byte[] encryptBytes(byte[] data, Cipher encrypt) throws Exception{
+    synchronized(GMSEncrypt.class) {
+      encodingsPerformed++;
+    }
+    return encrypt.doFinal(data);
+  }
+
+  static public byte[] decryptBytes(byte[] data, Cipher decrypt)
+    throws Exception{
+    try {
+      byte[] decryptBytes = decrypt.doFinal(data);
+      synchronized(GMSEncrypt.class) {
+        decodingsPerformed++;
+      }
+      return decryptBytes;
+    }catch(Exception ex) {
+      throw ex;
+    }
+  }
+
+
+  protected class PeerEncryptor {
+
+    private PublicKey peerPublicKey = null;
+
+    private String peerSKAlgo = null;
+
+    private Cipher _encrypt;
+
+    protected PeerEncryptor(byte[] peerPublicKeyBytes) throws NoSuchAlgorithmException, InvalidKeySpecException {
+      X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(peerPublicKeyBytes);
+      KeyFactory keyFact = KeyFactory.getInstance("DH");
+      //PublicKey pubKey = keyFact.generatePublic(x509KeySpec);
+      this.peerPublicKey = keyFact.generatePublic(x509KeySpec);
+    }
+
+    public byte [] encryptBytes(byte[] data) throws Exception {
+      String algo = null;
+      if (this.peerSKAlgo != null) {
+        algo = this.peerSKAlgo;
+      } else {
+        algo = dhSKAlgo;
+      }
+      return GMSEncrypt.encryptBytes(data, getEncryptCipher(algo, this.peerPublicKey));
+    }
+
+    private Cipher getEncryptCipher(String dhSKAlgo, PublicKey publicKey)
+      throws Exception{
+      try {
+        if(_encrypt == null) {
+          KeyAgreement ka = KeyAgreement.getInstance("DH");
+          ka.init(dhPrivateKey);
+          ka.doPhase(publicKey, true);
+
+          Cipher encrypt;
+
+          int keysize = getKeySize(dhSKAlgo);
+          int blocksize = getBlockSize(dhSKAlgo);
+
+          if (keysize == -1 || blocksize == -1) {
+            SecretKey sKey = ka.generateSecret(dhSKAlgo);
+            encrypt = Cipher.getInstance(dhSKAlgo);
+            encrypt.init(Cipher.ENCRYPT_MODE, sKey);
+          }
+          else {
+            String dhAlgoStr = getDhAlgoStr(dhSKAlgo);
+
+            byte[] sKeyBytes = ka.generateSecret();
+            SecretKeySpec sks = new SecretKeySpec(sKeyBytes, 0, keysize, dhAlgoStr);
+            IvParameterSpec ivps = new IvParameterSpec(sKeyBytes, keysize, blocksize);
+
+            encrypt = Cipher.getInstance(dhAlgoStr + "/CBC/PKCS5Padding");
+            encrypt.init(Cipher.ENCRYPT_MODE, sks, ivps);
+          }
+          _encrypt = encrypt;
+        }
+      }catch(Exception ex) {
+        throw ex;
+      }
+      return _encrypt;
+    }
+
+
+    public byte[] decryptBytes(byte[] data) throws Exception
+    {
+      String algo = null;
+      if (this.peerSKAlgo != null) {
+        algo = this.peerSKAlgo;
+      } else {
+        algo = dhSKAlgo;
+      }
+      Cipher c = getDecryptCipher(algo, this.peerPublicKey);
+      return GMSEncrypt.decryptBytes(data, c);
+
+    }
+
+
+
+    private Cipher _decrypt = null;
+
+    private Cipher getDecryptCipher( String dhSKAlgo, PublicKey publicKey)
+      throws Exception{
+      if(_decrypt == null) {
+        try {
+          KeyAgreement ka = KeyAgreement.getInstance("DH");
+          ka.init(dhPrivateKey);
+          ka.doPhase(publicKey, true);
+
+          Cipher decrypt;
+
+          int keysize = getKeySize(dhSKAlgo);
+          int blocksize = getBlockSize(dhSKAlgo);
+
+          if (keysize == -1 || blocksize == -1) {
+            SecretKey sKey = ka.generateSecret(dhSKAlgo);
+            decrypt = Cipher.getInstance(dhSKAlgo);
+            decrypt.init(Cipher.DECRYPT_MODE, sKey);
+          }
+          else {
+            String algoStr = getDhAlgoStr(dhSKAlgo);
+
+            byte[] sKeyBytes = ka.generateSecret();
+            SecretKeySpec sks = new SecretKeySpec(sKeyBytes, 0, keysize, algoStr);
+            IvParameterSpec ivps = new IvParameterSpec(sKeyBytes, keysize, blocksize);
+
+            decrypt = Cipher.getInstance(algoStr + "/CBC/PKCS5Padding");
+            decrypt.init(Cipher.DECRYPT_MODE, sks, ivps);
+          }
+
+          _decrypt = decrypt;
+        }catch(Exception ex) {
+          throw ex;
+        }
+      }
+      return _decrypt;
+    }
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a28b223a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index 0460964..25a9c43 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -149,6 +149,8 @@ public class JGroupsMessenger implements Messenger {
     ClassConfigurator.addProtocol(JGROUPS_PROTOCOL_TRANSPORT, Transport.class);
   }
 
+  private GMSEncrypt encrypt;
+
   @Override
   @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
   public void init(Services s) {
@@ -250,7 +252,15 @@ public class JGroupsMessenger implements Messenger {
     properties = replaceStrings(properties, "FC_MAX_BLOCK", ""+dc.getMcastFlowControl().getRechargeBlockMs());
 
     this.jgStackConfig = properties;
-    
+
+    if ( !dc.getSecurityClientDHAlgo().isEmpty() ) {
+      try {
+        this.encrypt = new GMSEncrypt(services);
+      } catch (Exception e) {
+        throw new GemFireConfigException("problem initializing encryption protocol", e);
+      }
+    }
+
   }
 
   @Override
@@ -377,6 +387,10 @@ public class JGroupsMessenger implements Messenger {
     this.myChannel.down(new Event(Event.VIEW_CHANGE, jgv));
 
     addressesWithIoExceptionsProcessed.clear();
+
+    if (encrypt != null) {
+//      encrypt.installView(v);
+    }
   }
   
 
@@ -588,7 +602,15 @@ public class JGroupsMessenger implements Messenger {
   public Set<InternalDistributedMember> sendUnreliably(DistributionMessage msg) {
     return send(msg, false);
   }
-    
+
+  @Override
+  public Set<InternalDistributedMember> send(DistributionMessage msg, NetView alternateView) {
+    if (this.encrypt != null) {
+     // this.encrypt.installView(alternateView);
+    }
+    return send(msg, true);
+  }
+
   @Override
   public Set<InternalDistributedMember> send(DistributionMessage msg) {
     return send(msg, true);
@@ -638,7 +660,7 @@ public class JGroupsMessenger implements Messenger {
     if (useMcast) {
 
       long startSer = theStats.startMsgSerialization();
-      Message jmsg = createJGMessage(msg, local, Version.CURRENT_ORDINAL);
+      Message jmsg = createJGMessage(msg, local, null, Version.CURRENT_ORDINAL);
       theStats.endMsgSerialization(startSer);
 
       Exception problem = null;
@@ -680,7 +702,7 @@ public class JGroupsMessenger implements Messenger {
     } // useMcast
     else { // ! useMcast
       int len = destinations.length;
-      List<GMSMember> calculatedMembers; // explicit list of members
+      List<InternalDistributedMember> calculatedMembers; // explicit list of members
       int calculatedLen; // == calculatedMembers.len
       if (len == 1 && destinations[0] == DistributionMessage.ALL_RECIPIENTS) { // send to all
         // Grab a copy of the current membership
@@ -688,51 +710,40 @@ public class JGroupsMessenger implements Messenger {
 
         // Construct the list
         calculatedLen = v.size();
-        calculatedMembers = new LinkedList<GMSMember>();
+        calculatedMembers = new LinkedList<InternalDistributedMember>();
         for (int i = 0; i < calculatedLen; i ++) {
           InternalDistributedMember m = (InternalDistributedMember)v.get(i);
-          calculatedMembers.add((GMSMember)m.getNetMember());
+          calculatedMembers.add(m);
         }
       } // send to all
       else { // send to explicit list
         calculatedLen = len;
-        calculatedMembers = new LinkedList<GMSMember>();
+        calculatedMembers = new LinkedList<>();
         for (int i = 0; i < calculatedLen; i ++) {
-          calculatedMembers.add((GMSMember)destinations[i].getNetMember());
+          calculatedMembers.add(destinations[i]);
         }
       } // send to explicit list
       Int2ObjectOpenHashMap<Message> messages = new Int2ObjectOpenHashMap<>();
       long startSer = theStats.startMsgSerialization();
+
+      boolean encode = (encrypt != null);
+
       boolean firstMessage = true;
-      for (Iterator<GMSMember> it=calculatedMembers.iterator(); it.hasNext(); ) {
-        GMSMember mbr = it.next();
-        short version = mbr.getVersionOrdinal();
-        if ( !messages.containsKey(version) ) {
-          Message jmsg = createJGMessage(msg, local, version);
-          messages.put(version, jmsg);
-          if (firstMessage) {
-            theStats.incSentBytes(jmsg.getLength());
-            firstMessage = false;
-          }
-        }
-      }
-      theStats.endMsgSerialization(startSer);
       Collections.shuffle(calculatedMembers);
       int i=0;
-      for (GMSMember mbr: calculatedMembers) {
+      for (InternalDistributedMember mbr: calculatedMembers) {
+        short version = mbr.getNetMember().getVersionOrdinal();
         JGAddress to = new JGAddress(mbr);
-        short version = mbr.getVersionOrdinal();
-        Message jmsg = (Message)messages.get(version);
+        Message jmsg = createJGMessage(msg, local, mbr, version);
         Exception problem = null;
         try {
-          Message tmp = (i < (calculatedLen-1)) ? jmsg.copy(true) : jmsg;
           if (!reliably) {
             jmsg.setFlag(Message.Flag.NO_RELIABILITY);
           }
-          tmp.setDest(to);
-          tmp.setSrc(this.jgAddress);
+          jmsg.setDest(to);
+          jmsg.setSrc(this.jgAddress);
           logger.trace("Unicasting to {}", to);
-          myChannel.send(tmp);
+          myChannel.send(jmsg);
         }
         catch (Exception e) {
           problem = e;
@@ -789,7 +800,7 @@ public class JGroupsMessenger implements Messenger {
    * @param version the version of the recipient
    * @return the new message
    */
-  Message createJGMessage(DistributionMessage gfmsg, JGAddress src, short version) {
+  Message createJGMessage(DistributionMessage gfmsg, JGAddress src, InternalDistributedMember recipient, short version) {
     if(gfmsg instanceof DirectReplyMessage) {
       ((DirectReplyMessage) gfmsg).registerProcessor();
     }
@@ -803,7 +814,31 @@ public class JGroupsMessenger implements Messenger {
         new HeapDataOutputStream(Version.fromOrdinalOrCurrent(version));
       Version.CURRENT.writeOrdinal(out_stream, true);
       DataSerializer.writeObject(this.localAddress.getNetMember(), out_stream);
-      DataSerializer.writeObject(gfmsg, out_stream);
+      boolean encode = encrypt != null && recipient != null;
+      if (encode) {
+        // Coordinator doesn't know our publicKey for a JoinRequest
+        if (gfmsg.getDSFID() == JOIN_REQUEST || gfmsg.getDSFID() == JOIN_RESPONSE) {
+          encode = false;
+        }
+      }
+      if (encode) {
+        logger.info("encoding {}", gfmsg);
+        try {
+          out_stream.writeBoolean(true); // TODO we should have flag bits
+          HeapDataOutputStream out_stream2 =
+            new HeapDataOutputStream(Version.fromOrdinalOrCurrent(version));
+          DataSerializer.writeObject(gfmsg, out_stream2);
+          byte[] payload = out_stream2.toByteArray();
+          payload = encrypt.encryptData(payload, recipient);
+          DataSerializer.writeByteArray(payload, out_stream);
+        } catch (Exception e) {
+          throw new GemFireIOException("unable to send message", e);
+        }
+      } else {
+        logger.info("not encoding {}", gfmsg);
+        out_stream.writeBoolean(false);
+        DataSerializer.writeObject(gfmsg, out_stream);
+      }
       msg.setBuffer(out_stream.toByteArray());
       services.getStatistics().endMsgSerialization(start);
     }
@@ -869,7 +904,8 @@ public class JGroupsMessenger implements Messenger {
     try {
       long start = services.getStatistics().startMsgDeserialization();
       
-      DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buf, 
+
+      DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buf,
           jgmsg.getOffset(), jgmsg.getLength()));
 
       short ordinal = Version.readOrdinal(dis);
@@ -878,9 +914,27 @@ public class JGroupsMessenger implements Messenger {
         dis = new VersionedDataInputStream(dis, Version.fromOrdinalNoThrow(
             ordinal, true));
       }
-      
+
       GMSMember m = DataSerializer.readObject(dis);
 
+      sender = getMemberFromView(m, ordinal);
+
+      boolean encrypted = dis.readBoolean();
+
+      if (encrypted && encrypt != null) {
+        byte[] payload = DataSerializer.readByteArray(dis);
+        try {
+          payload = encrypt.decryptData(payload, sender);
+          dis = new DataInputStream(new ByteArrayInputStream(payload));
+          if (ordinal < Version.CURRENT_ORDINAL) {
+            dis = new VersionedDataInputStream(dis, Version.fromOrdinalNoThrow(
+              ordinal, true));
+          }
+        } catch (Exception e) {
+          throw new GemFireIOException("unable to receive message", e);
+        }
+      }
+
       result = DataSerializer.readObject(dis);
 
       DistributionMessage dm = (DistributionMessage)result;
@@ -891,8 +945,6 @@ public class JGroupsMessenger implements Messenger {
       // request's sender ID
       if (dm.getDSFID() == JOIN_REQUEST) {
         sender = ((JoinRequestMessage)dm).getMemberID();
-      } else {
-        sender = getMemberFromView(m, ordinal);
       }
       ((DistributionMessage)result).setSender(sender);
       
@@ -914,25 +966,33 @@ public class JGroupsMessenger implements Messenger {
   /** look for certain messages that may need to be altered before being sent */
   void filterOutgoingMessage(DistributionMessage m) {
     switch (m.getDSFID()) {
-    case JOIN_RESPONSE:
-      JoinResponseMessage jrsp = (JoinResponseMessage)m;
-      
-      if (jrsp.getRejectionMessage() == null
+      case JOIN_REQUEST:
+        if (encrypt == null) {
+          break;
+        }
+        JoinRequestMessage joinMsg = (JoinRequestMessage)m;
+        joinMsg.setPublicKey(encrypt.getPublicKeyBytes());
+        break;
+
+      case JOIN_RESPONSE:
+        JoinResponseMessage jrsp = (JoinResponseMessage)m;
+
+        if (jrsp.getRejectionMessage() == null
           &&  services.getConfig().getTransport().isMcastEnabled()) {
-        // get the multicast message digest and pass it with the join response
-        Digest digest = (Digest)this.myChannel.getProtocolStack()
+          // get the multicast message digest and pass it with the join response
+          Digest digest = (Digest)this.myChannel.getProtocolStack()
             .getTopProtocol().down(Event.GET_DIGEST_EVT);
-        HeapDataOutputStream hdos = new HeapDataOutputStream(500, Version.CURRENT);
-        try {
-          digest.writeTo(hdos);
-        } catch (Exception e) {
-          logger.fatal("Unable to serialize JGroups messaging digest", e);
+          HeapDataOutputStream hdos = new HeapDataOutputStream(500, Version.CURRENT);
+          try {
+            digest.writeTo(hdos);
+          } catch (Exception e) {
+            logger.fatal("Unable to serialize JGroups messaging digest", e);
+          }
+          jrsp.setMessengerData(hdos.toByteArray());
         }
-        jrsp.setMessengerData(hdos.toByteArray());
-      }
-      break;
-    default:
-      break;
+        break;
+      default:
+        break;
     }
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a28b223a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
index 7a4971f..c050751 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
@@ -28,6 +28,7 @@ import java.io.File;
 import java.net.InetAddress;
 import java.util.Properties;
 
+import com.gemstone.gemfire.distributed.internal.membership.gms.messenger.GMSEncrypt;
 import org.apache.logging.log4j.Level;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -217,6 +218,143 @@ public class MembershipJUnitTest {
     }
   }
   
+  /**
+   * This test ensures that secure communications are
+   * enabled.
+   *
+   * This test creates a locator with a colocated
+   * membership manager and then creates a second
+   * manager that joins the system of the first.
+   *
+   * It then makes assertions about the state of
+   * the membership view, closes one of the managers
+   * and makes more assertions.
+   */
+  @Test
+  public void testLocatorAndTwoServersJoinUsingDiffeHellman() throws Exception {
+
+    MembershipManager m1=null, m2=null;
+    Locator l = null;
+    int mcastPort = AvailablePortHelper.getRandomAvailableUDPPort();
+
+    try {
+
+      // boot up a locator
+      int port = AvailablePortHelper.getRandomAvailableTCPPort();
+      InetAddress localHost = SocketCreator.getLocalHost();
+
+      // this locator will hook itself up with the first MembershipManager
+      // to be created
+      l = InternalLocator.startLocator(port, new File(""), null,
+        null, null, localHost, false, new Properties(), true, false, null,
+        false);
+
+      // create configuration objects
+      Properties nonDefault = new Properties();
+      nonDefault.put(DistributionConfig.DISABLE_TCP_NAME, "true");
+      nonDefault.put(DistributionConfig.MCAST_PORT_NAME, String.valueOf(mcastPort));
+      nonDefault.put(DistributionConfig.LOG_FILE_NAME, "");
+      nonDefault.put(DistributionConfig.LOG_LEVEL_NAME, "fine");
+      nonDefault.put(DistributionConfig.GROUPS_NAME, "red, blue");
+      nonDefault.put(DistributionConfig.MEMBER_TIMEOUT_NAME, "2000");
+      nonDefault.put(DistributionConfig.LOCATORS_NAME, localHost.getHostName()+'['+port+']');
+      nonDefault.put(DistributionConfig.SECURITY_CLIENT_DHALGO_NAME, "AES:128");
+      DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
+      RemoteTransportConfig transport = new RemoteTransportConfig(config,
+        DistributionManager.NORMAL_DM_TYPE);
+
+      // start the first membership manager
+      try {
+        System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
+        DistributedMembershipListener listener1 = mock(DistributedMembershipListener.class);
+        DMStats stats1 = mock(DMStats.class);
+        System.out.println("creating 1st membership manager");
+        m1 = MemberFactory.newMembershipManager(listener1, config, transport, stats1);
+        m1.startEventProcessing();
+      } finally {
+        System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
+      }
+
+      // start the second membership manager
+      DistributedMembershipListener listener2 = mock(DistributedMembershipListener.class);
+      DMStats stats2 = mock(DMStats.class);
+      System.out.println("creating 2nd membership manager");
+      m2 = MemberFactory.newMembershipManager(listener2, config, transport, stats2);
+      m2.startEventProcessing();
+
+      // we have to check the views with JoinLeave because the membership
+      // manager queues new views for processing through the DM listener,
+      // which is a mock object in this test
+      System.out.println("waiting for views to stabilize");
+      JoinLeave jl1 = ((GMSMembershipManager)m1).getServices().getJoinLeave();
+      JoinLeave jl2 = ((GMSMembershipManager)m2).getServices().getJoinLeave();
+      long giveUp = System.currentTimeMillis() + 15000;
+      for (;;) {
+        try {
+          assertTrue("view = " + jl2.getView(), jl2.getView().size() == 2);
+          assertTrue("view = " + jl1.getView(), jl1.getView().size() == 2);
+          assertTrue(jl1.getView().getCreator().equals(jl2.getView().getCreator()));
+          assertTrue(jl1.getView().getViewId() == jl2.getView().getViewId());
+          break;
+        } catch  (AssertionError e) {
+          if (System.currentTimeMillis() > giveUp) {
+            throw e;
+          }
+        }
+      }
+
+      System.out.println("testing multicast availability");
+      assertTrue(m1.testMulticast());
+
+      System.out.println("multicasting SerialAckedMessage from m1 to m2");
+      SerialAckedMessage msg = new SerialAckedMessage();
+      msg.setRecipient(m2.getLocalMember());
+      msg.setMulticast(true);
+      m1.send(new InternalDistributedMember[] {m2.getLocalMember()}, msg, null);
+      giveUp = System.currentTimeMillis() + 5000;
+      boolean verified = false;
+      Throwable problem = null;
+      while (giveUp > System.currentTimeMillis()) {
+        try {
+          verify(listener2).messageReceived(isA(SerialAckedMessage.class));
+          verified = true;
+          break;
+        } catch (Error e) {
+          problem = e;
+          Thread.sleep(500);
+        }
+      }
+      if (!verified) {
+        if (problem != null) {
+          problem.printStackTrace();
+        }
+        fail("Expected a multicast message to be received");
+      }
+
+      // let the managers idle for a while and get used to each other
+      Thread.sleep(4000l);
+
+      m2.shutdown();
+      assertTrue(!m2.isConnected());
+
+      assertTrue(m1.getView().size() == 1);
+
+      System.out.println("encodings performed: " + GMSEncrypt.encodingsPerformed + "; decodings performed: " + GMSEncrypt.decodingsPerformed);
+    }
+    finally {
+
+      if (m2 != null) {
+        m2.shutdown();
+      }
+      if (m1 != null) {
+        m1.shutdown();
+      }
+      if (l != null) {
+        l.stop();
+      }
+    }
+  }
+
   @Test
   public void testJoinTimeoutSetting() throws Exception {
     long timeout = 30000;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a28b223a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
new file mode 100755
index 0000000..a591e47
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
@@ -0,0 +1,97 @@
+package com.gemstone.gemfire.distributed.internal.membership.gms.messenger;
+import static org.mockito.Mockito.*;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
+import com.gemstone.gemfire.distributed.internal.DistributionManager;
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
+import com.gemstone.gemfire.distributed.internal.membership.NetView;
+import com.gemstone.gemfire.distributed.internal.membership.gms.ServiceConfig;
+import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
+import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Created by bschuchardt on 5/6/2016.
+ */
+public class GMSEncryptJUnitTest {
+
+  Services services;
+
+  InternalDistributedMember mockMembers[];
+
+  NetView netView;
+
+  private void initMocks() throws Exception {
+    Properties nonDefault = new Properties();
+    nonDefault.put(DistributionConfig.SECURITY_CLIENT_DHALGO_NAME, "AES:128");
+    DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
+    RemoteTransportConfig tconfig = new RemoteTransportConfig(config,
+      DistributionManager.NORMAL_DM_TYPE);
+
+    ServiceConfig serviceConfig = new ServiceConfig(tconfig, config);
+
+    services = mock(Services.class);
+    when(services.getConfig()).thenReturn(serviceConfig);
+
+    mockMembers = new InternalDistributedMember[4];
+    for (int i = 0; i < mockMembers.length; i++) {
+      mockMembers[i] = new InternalDistributedMember("localhost", 8888 + i);
+    }
+    int viewId = 1;
+    List<InternalDistributedMember> mbrs = new LinkedList<>();
+    mbrs.add(mockMembers[0]);
+    mbrs.add(mockMembers[1]);
+    mbrs.add(mockMembers[2]);
+
+    //prepare the view
+    netView = new NetView(mockMembers[0], viewId, mbrs);
+
+  }
+
+
+  @Test
+  public void testOneMemberCanDecryptAnothersMessage() throws Exception{
+    initMocks();
+
+    GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services); // this will be the sender
+    GMSEncrypt gmsEncrypt2 = new GMSEncrypt(services); // this will be the receiver
+
+    // establish the public keys for the sender and receiver
+    netView.setPublicKey(mockMembers[1], gmsEncrypt1.getPublicKeyBytes());
+    netView.setPublicKey(mockMembers[2], gmsEncrypt2.getPublicKeyBytes());
+
+    gmsEncrypt1.installView(netView);
+    gmsEncrypt2.installView(netView);
+
+    // sender encrypts a message, so use receiver's public key
+    String ch = "Hello world";
+    byte[] challenge =  ch.getBytes();
+    byte[]  encryptedChallenge =  gmsEncrypt1.encryptData(challenge, mockMembers[2]);
+
+    // receiver decrypts the message using the sender's public key
+    byte[] decryptBytes = gmsEncrypt2.decryptData(encryptedChallenge,  mockMembers[1]);
+
+    // now send a response
+    String response = "Hello yourself!";
+    byte[] responseBytes = response.getBytes();
+    byte[] encryptedResponse = gmsEncrypt2.encryptData(responseBytes, mockMembers[1]);
+
+    // receiver decodes the response
+    byte[] decryptedResponse = gmsEncrypt1.decryptData(encryptedResponse,  mockMembers[2]);
+
+    Assert.assertFalse(Arrays.equals(challenge, encryptedChallenge));
+
+    Assert.assertTrue(Arrays.equals(challenge, decryptBytes));
+
+    Assert.assertFalse(Arrays.equals(responseBytes, encryptedResponse));
+
+    Assert.assertTrue(Arrays.equals(responseBytes, decryptedResponse));
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a28b223a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
index 2ad970b..60e790b 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
@@ -431,13 +431,13 @@ public class JGroupsMessengerJUnitTest {
     InternalDistributedMember sender = createAddress(8888);
     JoinRequestMessage msg = new JoinRequestMessage(messenger.localAddress, sender, null, -1);
     
-    Message jmsg = messenger.createJGMessage(msg, messenger.jgAddress, Version.CURRENT_ORDINAL);
+    Message jmsg = messenger.createJGMessage(msg, messenger.jgAddress, null, Version.CURRENT_ORDINAL);
     interceptor.up(new Event(Event.MSG, jmsg));
     
     verify(mh, times(1)).processMessage(any(JoinRequestMessage.class));
     
     LeaveRequestMessage lmsg = new LeaveRequestMessage(messenger.localAddress, sender, "testing");
-    jmsg = messenger.createJGMessage(lmsg, messenger.jgAddress, Version.CURRENT_ORDINAL);
+    jmsg = messenger.createJGMessage(lmsg, messenger.jgAddress, null, Version.CURRENT_ORDINAL);
     interceptor.up(new Event(Event.MSG, jmsg));
     
     verify(manager).processMessage(any(LeaveRequestMessage.class));
@@ -805,7 +805,7 @@ public class JGroupsMessengerJUnitTest {
       dmsg.setRecipients(recipients);
   
       // a message is ignored during manager shutdown
-      msg = messenger.createJGMessage(dmsg, new JGAddress(other), Version.CURRENT_ORDINAL);
+      msg = messenger.createJGMessage(dmsg, new JGAddress(other), null, Version.CURRENT_ORDINAL);
       when(manager.shutdownInProgress()).thenReturn(Boolean.TRUE);
       receiver.receive(msg);
       verify(manager, never()).processMessage(isA(DistributionMessage.class));


[17/36] incubator-geode git commit: GEODE-1379: update javadocs for off-heap and cloning

Posted by hi...@apache.org.
GEODE-1379: update javadocs for off-heap and cloning

the javadocs now make clear that off-heap regions always clone


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

Branch: refs/heads/feature/GEODE-1372
Commit: f4a167998076d82319aecafc34da076882ceb8d3
Parents: 4d52260
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Tue May 10 15:37:17 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed May 11 10:35:14 2016 -0700

----------------------------------------------------------------------
 .../src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java | 1 +
 .../src/main/java/com/gemstone/gemfire/cache/AttributesMutator.java | 1 +
 .../src/main/java/com/gemstone/gemfire/cache/RegionFactory.java     | 1 +
 .../java/com/gemstone/gemfire/cache/client/ClientRegionFactory.java | 1 +
 4 files changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f4a16799/geode-core/src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java
index 34eafb9..fe7910a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java
@@ -1223,6 +1223,7 @@ public class AttributesFactory<K,V> {
   /**
    * Sets cloning on region.
    * Default is false.
+   * Note: off-heap regions always behave as if cloning is enabled.
    * 
    * @param cloningEnable
    * @since 6.1

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f4a16799/geode-core/src/main/java/com/gemstone/gemfire/cache/AttributesMutator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/AttributesMutator.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/AttributesMutator.java
index 0a69437..27d161d 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/AttributesMutator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/AttributesMutator.java
@@ -167,6 +167,7 @@ public interface AttributesMutator<K,V> {
 
   /**
    * Sets cloning on region
+   * Note: off-heap regions always behave as if cloning is enabled.
    * @param cloningEnable
    * @since 6.1
    */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f4a16799/geode-core/src/main/java/com/gemstone/gemfire/cache/RegionFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/RegionFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/RegionFactory.java
index b919cc0..5110d40 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/RegionFactory.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/RegionFactory.java
@@ -851,6 +851,7 @@ public class RegionFactory<K,V>
   
   /**
    * Sets cloning on region
+   * Note: off-heap regions always behave as if cloning is enabled.
    * @param cloningEnable
    * @return a reference to this RegionFactory object
    * @since 6.1

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f4a16799/geode-core/src/main/java/com/gemstone/gemfire/cache/client/ClientRegionFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/ClientRegionFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/ClientRegionFactory.java
index 9c7fae0..fc68a99 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/ClientRegionFactory.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/ClientRegionFactory.java
@@ -272,6 +272,7 @@ public interface ClientRegionFactory<K,V> {
 
   /**
    * Sets cloning on region
+   * Note: off-heap regions always behave as if cloning is enabled.
    * @param cloningEnable
    * @return a reference to this ClientRegionFactory object
    * @see AttributesFactory#setCloningEnabled


[36/36] incubator-geode git commit: updated juint test

Posted by hi...@apache.org.
updated juint test


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

Branch: refs/heads/feature/GEODE-1372
Commit: d6fb78341622b8f05f3af9dae602f6f4256bb81d
Parents: 4d5f947
Author: Hitesh Khamesra <hi...@yahoo.com>
Authored: Thu May 19 12:25:50 2016 -0700
Committer: Hitesh Khamesra <hi...@yahoo.com>
Committed: Thu May 19 12:25:50 2016 -0700

----------------------------------------------------------------------
 .../membership/gms/messenger/GMSEncryptJUnitTest.java        | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d6fb7834/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
index 3a08faa..0dc268c 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
@@ -1,5 +1,6 @@
 package com.gemstone.gemfire.distributed.internal.membership.gms.messenger;
 import static org.mockito.Mockito.*;
+
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
 import com.gemstone.gemfire.distributed.internal.DistributionManager;
@@ -8,6 +9,7 @@ import com.gemstone.gemfire.distributed.internal.membership.NetView;
 import com.gemstone.gemfire.distributed.internal.membership.gms.ServiceConfig;
 import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
 import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -16,9 +18,7 @@ import java.math.BigInteger;
 import java.security.Key;
 import java.security.KeyPair;
 import java.security.KeyPairGenerator;
-import java.security.NoSuchAlgorithmException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import java.util.Arrays;
 import java.util.LinkedList;
@@ -28,12 +28,12 @@ import java.util.Properties;
 import javax.crypto.KeyAgreement;
 import javax.crypto.Mac;
 import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactory;
 import javax.crypto.spec.DHParameterSpec;
 
 /**
  * Created by bschuchardt on 5/6/2016.
  */
+@Category(IntegrationTest.class)
 public class GMSEncryptJUnitTest {
 
   Services services;


[34/36] incubator-geode git commit: removed unused packages.

Posted by hi...@apache.org.
removed unused packages.


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

Branch: refs/heads/feature/GEODE-1372
Commit: a08172fcf0e70135cf48eee7b894a31c21aa1dc1
Parents: ab14e19
Author: Hitesh Khamesra <hi...@yahoo.com>
Authored: Thu May 19 10:15:41 2016 -0700
Committer: Hitesh Khamesra <hi...@yahoo.com>
Committed: Thu May 19 10:19:26 2016 -0700

----------------------------------------------------------------------
 .../internal/membership/gms/messenger/GMSEncrypt.java        | 8 --------
 1 file changed, 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a08172fc/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
index bf8f7bc..3d3633d 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
@@ -16,18 +16,10 @@
  */
 package com.gemstone.gemfire.distributed.internal.membership.gms.messenger;
 
-
-import io.codearte.catchexception.shade.mockito.cglib.core.Local;
-
 import java.math.BigInteger;
 import java.security.*;
-import java.security.spec.EncodedKeySpec;
-import java.security.spec.InvalidKeySpecException;
 import java.security.spec.PKCS8EncodedKeySpec;
 import java.security.spec.X509EncodedKeySpec;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;


[10/36] incubator-geode git commit: GEODE-1360: Enabling to specify log4j2.xml for test in gradle

Posted by hi...@apache.org.
GEODE-1360: Enabling to specify log4j2.xml for test in gradle

Product code has built in log4j's trace log. However there's no command line
parameter to turn on it. This fix let gradlew to transfer the system property
to unit test framework, and let unit test framework to set it in run-time jvm.


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

Branch: refs/heads/feature/GEODE-1372
Commit: 036c931705fab5122a81a446d67e4ab5bc6620b7
Parents: 9a77054
Author: zhouxh <gz...@pivotal.io>
Authored: Mon May 9 17:03:15 2016 -0700
Committer: zhouxh <gz...@pivotal.io>
Committed: Tue May 10 14:21:39 2016 -0700

----------------------------------------------------------------------
 .../test/dunit/standalone/DUnitLauncher.java    |  2 +
 .../test/dunit/standalone/ProcessManager.java   | 45 ++++++++++++--------
 gradle/test.gradle                              |  4 ++
 3 files changed, 34 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/036c9317/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java
index 0c294ec..4e7095c 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java
@@ -76,6 +76,8 @@ public class DUnitLauncher {
   /** change this to use a different log level in unit tests */
   public static final String LOG_LEVEL = System.getProperty("logLevel", "info");
   
+  public static final String LOG4J = System.getProperty("log4j.configurationFile");
+  
   static int locatorPort;
 
   private static final int NUM_VMS = 4;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/036c9317/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ProcessManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ProcessManager.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ProcessManager.java
index dd532c4..5dbdfd6 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ProcessManager.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ProcessManager.java
@@ -28,6 +28,7 @@ import java.rmi.AccessException;
 import java.rmi.NotBoundException;
 import java.rmi.RemoteException;
 import java.rmi.registry.Registry;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
@@ -161,23 +162,33 @@ public class ProcessManager {
     }
 
     String jdkSuspend = vmNum == suspendVM ? "y" : "n";
-
-    return new String[] {
-      cmd, "-classpath", classPath,
-      "-D" + DUnitLauncher.RMI_PORT_PARAM + "=" + namingPort,
-      "-D" + DUnitLauncher.VM_NUM_PARAM + "=" + vmNum,
-      "-D" + DUnitLauncher.WORKSPACE_DIR_PARAM + "=" + new File(".").getAbsolutePath(),
-      "-DlogLevel=" + DUnitLauncher.LOG_LEVEL,
-      "-Djava.library.path=" + System.getProperty("java.library.path"),
-      "-Xrunjdwp:transport=dt_socket,server=y,suspend=" + jdkSuspend + jdkDebug,
-      "-XX:+HeapDumpOnOutOfMemoryError",
-      "-Xmx512m",
-      "-Dgemfire.DEFAULT_MAX_OPLOG_SIZE=10",
-      "-Dgemfire.disallowMcastDefaults=true",
-      "-ea", "-XX:+PrintGC", "-XX:+PrintGCDetails","-XX:+PrintGCTimeStamps",
-      agent,
-      ChildVM.class.getName()
-    };
+    ArrayList<String> cmds = new ArrayList<String>();
+    cmds.add(cmd);
+    cmds.add("-classpath"); 
+    cmds.add(classPath);
+    cmds.add("-D" + DUnitLauncher.RMI_PORT_PARAM + "=" + namingPort);
+    cmds.add("-D" + DUnitLauncher.VM_NUM_PARAM + "=" + vmNum);
+    cmds.add("-D" + DUnitLauncher.WORKSPACE_DIR_PARAM + "=" + new File(".").getAbsolutePath());
+    cmds.add("-DlogLevel=" + DUnitLauncher.LOG_LEVEL);
+    if (DUnitLauncher.LOG4J!=null) {
+      cmds.add("-Dlog4j.configurationFile="+DUnitLauncher.LOG4J);
+    }
+    cmds.add("-Djava.library.path=" + System.getProperty("java.library.path"));
+    cmds.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=" + jdkSuspend + jdkDebug);
+    cmds.add("-XX:+HeapDumpOnOutOfMemoryError");
+    cmds.add("-Xmx512m");
+    cmds.add("-Dgemfire.DEFAULT_MAX_OPLOG_SIZE=10");
+    cmds.add("-Dgemfire.disallowMcastDefaults=true");
+    cmds.add("-ea");
+    cmds.add("-XX:+PrintGC");
+    cmds.add("-XX:+PrintGCDetails");
+    cmds.add("-XX:+PrintGCTimeStamps");
+    cmds.add(agent);
+    cmds.add(ChildVM.class.getName());
+    String[] rst = new String[cmds.size()];
+    cmds.toArray(rst);
+    
+    return rst;
   }
   
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/036c9317/gradle/test.gradle
----------------------------------------------------------------------
diff --git a/gradle/test.gradle b/gradle/test.gradle
index 2dd7521..96fbfc5 100644
--- a/gradle/test.gradle
+++ b/gradle/test.gradle
@@ -211,6 +211,10 @@ subprojects {
         if (logLevel != null) {
           systemProperty 'logLevel', logLevel
         }
+        def log4jLocation = System.getProperty('log4j.configurationFile')
+        if (log4jLocation != null) {
+          systemProperty 'log4j.configurationFile', log4jLocation
+        }
 
         def eol = System.getProperty('line.separator')
         def progress = new File(resultsDir, "$test.name-progress.txt")


[16/36] incubator-geode git commit: GEODE-1356: remove DataAsAddress references

Posted by hi...@apache.org.
GEODE-1356: remove DataAsAddress references


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

Branch: refs/heads/feature/GEODE-1372
Commit: 4d52260550c18e73382e3b337f464f290ffa4093
Parents: fc943cb
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Tue May 10 14:36:52 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed May 11 10:27:52 2016 -0700

----------------------------------------------------------------------
 .../com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java | 2 +-
 .../gemfire/internal/offheap/OffHeapRegionEntryHelper.java       | 4 ++--
 .../internal/offheap/OffHeapRegionEntryHelperJUnitTest.java      | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d522605/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
index 46a851d..481c3be 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
@@ -1281,7 +1281,7 @@ public abstract class AbstractRegionEntry implements RegionEntry,
             throw new IllegalStateException("Could not use an off heap value because it was freed");
           }
         }
-        // else it is DataAsAddress. This code just returns it as prepared.
+        // else it is has no refCount so just return it as prepared.
       } else {
         byte[] data;
         boolean isSerialized = !(val instanceof byte[]);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d522605/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
index 158e6fe..8b57c43 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
@@ -129,7 +129,7 @@ public class OffHeapRegionEntryHelper {
     }
   }
   
-  public static int getSerializedLengthFromDataAsAddress(TinyStoredObject dataAsAddress) {
+  public static int getSerializedLength(TinyStoredObject dataAsAddress) {
     final long ohAddress = dataAsAddress.getAddress();
     
      if ((ohAddress & ENCODED_BIT) != 0) {     
@@ -307,7 +307,7 @@ public class OffHeapRegionEntryHelper {
     }
     if (decompress && isCompressed) {
       if (!compressedOk) {
-        throw new UnsupportedOperationException("Did not expect DataAsAddress to be compressed");
+        throw new UnsupportedOperationException("Did not expect encoded address to be compressed");
       }
     }
     return bytes;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d522605/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
index 2f33927..b9b3dfc 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
@@ -790,7 +790,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     long address = OffHeapRegionEntryHelper.encodeDataAsAddress(data, isSerialized, isCompressed);
     TinyStoredObject daa = new TinyStoredObject(address);
 
-    int actualLength = OffHeapRegionEntryHelper.getSerializedLengthFromDataAsAddress(daa);
+    int actualLength = OffHeapRegionEntryHelper.getSerializedLength(daa);
 
     assertThat(actualLength).isEqualTo(data.length);
   }
@@ -798,7 +798,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
   @Test
   public void getSerializedLengthFromDataAsAddressShouldReturnZeroForNonEncodedAddress() {
     TinyStoredObject nonEncodedAddress = new TinyStoredObject(100000L);
-    int actualLength = OffHeapRegionEntryHelper.getSerializedLengthFromDataAsAddress(nonEncodedAddress);
+    int actualLength = OffHeapRegionEntryHelper.getSerializedLength(nonEncodedAddress);
     assertThat(actualLength).isZero();
   }
 


[07/36] incubator-geode git commit: GEODE-1369: change ConfigCommandsDUnitTest to use TemporaryFolder

Posted by hi...@apache.org.
GEODE-1369: change ConfigCommandsDUnitTest to use TemporaryFolder

* use TemporaryFolder for all disk files
* re-enable testAlterUpdatesSharedConfig (might be a FlakyTest) -- was disabled for TRAC #52204 but it passes
* use static imports


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

Branch: refs/heads/feature/GEODE-1372
Commit: f93c87f13b4bf1bda67d994587d1299163694772
Parents: c8ca8a0
Author: Kirk Lund <kl...@apache.org>
Authored: Tue May 10 11:03:09 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue May 10 11:03:09 2016 -0700

----------------------------------------------------------------------
 .../cli/commands/ConfigCommandsDUnitTest.java   | 319 ++++++++++---------
 1 file changed, 171 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f93c87f1/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommandsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommandsDUnitTest.java
index c342142..1d861c6 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommandsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommandsDUnitTest.java
@@ -16,10 +16,13 @@
  */
 package com.gemstone.gemfire.management.internal.cli.commands;
 
+import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
+import static com.gemstone.gemfire.internal.AvailablePort.*;
+import static com.gemstone.gemfire.internal.AvailablePortHelper.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
-import static com.gemstone.gemfire.test.dunit.Invoke.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 import static com.gemstone.gemfire.test.dunit.Wait.*;
+import static org.apache.commons.io.FileUtils.*;
 
 import java.io.File;
 import java.io.FileReader;
@@ -32,6 +35,9 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.server.CacheServer;
 import com.gemstone.gemfire.distributed.Locator;
@@ -39,9 +45,6 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.distributed.internal.InternalLocator;
 import com.gemstone.gemfire.distributed.internal.SharedConfiguration;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.FileUtil;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
 import com.gemstone.gemfire.internal.logging.LogWriterImpl;
@@ -58,10 +61,6 @@ import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
-import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
 /**
  * Dunit class for testing GemFire config commands : export config
  *
@@ -71,110 +70,113 @@ import org.junit.experimental.categories.Category;
 @SuppressWarnings("serial")
 public class ConfigCommandsDUnitTest extends CliCommandTestBase {
 
-  File managerConfigFile = new File("Manager-cache.xml");
-  File managerPropsFile = new File("Manager-gf.properties");
-  File vm1ConfigFile = new File("VM1-cache.xml");
-  File vm1PropsFile = new File("VM1-gf.properties");
-  File vm2ConfigFile = new File("VM2-cache.xml");
-  File vm2PropsFile = new File("VM2-gf.properties");
-  File shellConfigFile = new File("Shell-cache.xml");
-  File shellPropsFile = new File("Shell-gf.properties");
-  File subDir = new File("ConfigCommandsDUnitTestSubDir");
-  File subManagerConfigFile = new File(subDir, managerConfigFile.getName());
+  private File managerConfigFile;
+  private File managerPropsFile;
+  private File vm1ConfigFile;
+  private File vm1PropsFile;
+  private File vm2ConfigFile;
+  private File vm2PropsFile;
+  private File shellConfigFile;
+  private File shellPropsFile;
+  private File subDir;
+  private File subManagerConfigFile;
 
   @Override
-  protected void preTearDownCliCommandTestBase() throws Exception {
-    deleteTestFiles();
-    invokeInEveryVM(new SerializableRunnable() {
-
-      @Override
-      public void run() {
-        try {
-          deleteTestFiles();
-        } catch (IOException e) {
-          fail("error", e);
-        }
-      }
-    });
+  protected final void postSetUpCliCommandTestBase() throws Exception {
+    this.managerConfigFile = this.temporaryFolder.newFile("Manager-cache.xml");
+    this.managerPropsFile = this.temporaryFolder.newFile("Manager-gf.properties");
+    this.vm1ConfigFile = this.temporaryFolder.newFile("VM1-cache.xml");
+    this.vm1PropsFile = this.temporaryFolder.newFile("VM1-gf.properties");
+    this.vm2ConfigFile = this.temporaryFolder.newFile("VM2-cache.xml");
+    this.vm2PropsFile = this.temporaryFolder.newFile("VM2-gf.properties");
+    this.shellConfigFile = this.temporaryFolder.newFile("Shell-cache.xml");
+    this.shellPropsFile = this.temporaryFolder.newFile("Shell-gf.properties");
+    this.subDir = this.temporaryFolder.newFolder(getName());
+    this.subManagerConfigFile = new File(this.subDir, this.managerConfigFile.getName());
   }
 
   @Test
-  public void testDescribeConfig() throws ClassNotFoundException, IOException {
+  public void testDescribeConfig() throws Exception {
     setUpJmxManagerOnVm0ThenConnect(null);
     final String controllerName = "Member2";
 
-    /***
+    /*
      * Create properties for the controller VM
      */
     final Properties localProps = new Properties();
-    localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    localProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info");
-    localProps.setProperty(DistributionConfig.STATISTIC_SAMPLING_ENABLED_NAME, "true");
-    localProps.setProperty(DistributionConfig.ENABLE_TIME_STATISTICS_NAME, "true");
-    localProps.setProperty(DistributionConfig.NAME_NAME, controllerName);
-    localProps.setProperty(DistributionConfig.GROUPS_NAME, "G1");
+    localProps.setProperty(MCAST_PORT_NAME, "0");
+    localProps.setProperty(LOG_LEVEL_NAME, "info");
+    localProps.setProperty(STATISTIC_SAMPLING_ENABLED_NAME, "true");
+    localProps.setProperty(ENABLE_TIME_STATISTICS_NAME, "true");
+    localProps.setProperty(NAME_NAME, controllerName);
+    localProps.setProperty(GROUPS_NAME, "G1");
     getSystem(localProps);
     Cache cache = getCache();
-    int ports[] = AvailablePortHelper.getRandomAvailableTCPPorts(1);
+
+    int ports[] = getRandomAvailableTCPPorts(1);
     CacheServer cs = getCache().addCacheServer();
     cs.setPort(ports[0]);
     cs.setMaxThreads(10);
     cs.setMaxConnections(9);
     cs.start();
+    try {
 
-    RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
-    List<String> jvmArgs = runtimeBean.getInputArguments();
+      RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
+      List<String> jvmArgs = runtimeBean.getInputArguments();
 
-    getLogWriter().info("#SB Actual JVM Args : ");
+      getLogWriter().info("#SB Actual JVM Args : ");
 
-    for (String jvmArg : jvmArgs) {
-      getLogWriter().info("#SB JVM " + jvmArg);
-    }
+      for (String jvmArg : jvmArgs) {
+        getLogWriter().info("#SB JVM " + jvmArg);
+      }
 
-    InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem();
-    DistributionConfig config = system.getConfig();
-    config.setArchiveFileSizeLimit(1000);
+      InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem();
+      DistributionConfig config = system.getConfig();
+      config.setArchiveFileSizeLimit(1000);
 
-    String command = CliStrings.DESCRIBE_CONFIG + " --member=" + controllerName;
-    CommandProcessor cmdProcessor = new CommandProcessor();
-    cmdProcessor.createCommandStatement(command, Collections.EMPTY_MAP).process();
+      String command = CliStrings.DESCRIBE_CONFIG + " --member=" + controllerName;
+      CommandProcessor cmdProcessor = new CommandProcessor();
+      cmdProcessor.createCommandStatement(command, Collections.EMPTY_MAP).process();
 
-    CommandResult cmdResult = executeCommand(command);
+      CommandResult cmdResult = executeCommand(command);
 
-    String resultStr = commandResultToString(cmdResult);
-    getLogWriter().info("#SB Hiding the defaults\n" + resultStr);
+      String resultStr = commandResultToString(cmdResult);
+      getLogWriter().info("#SB Hiding the defaults\n" + resultStr);
 
-    assertEquals(true, cmdResult.getStatus().equals(Status.OK));
-    assertEquals(true, resultStr.contains("G1"));
-    assertEquals(true, resultStr.contains(controllerName));
-    assertEquals(true, resultStr.contains("archive-file-size-limit"));
-    assertEquals(true, !resultStr.contains("copy-on-read"));
+      assertEquals(true, cmdResult.getStatus().equals(Status.OK));
+      assertEquals(true, resultStr.contains("G1"));
+      assertEquals(true, resultStr.contains(controllerName));
+      assertEquals(true, resultStr.contains("archive-file-size-limit"));
+      assertEquals(true, !resultStr.contains("copy-on-read"));
 
-    cmdResult = executeCommand(command + " --" + CliStrings.DESCRIBE_CONFIG__HIDE__DEFAULTS + "=false");
-    resultStr = commandResultToString(cmdResult);
-    getLogWriter().info("#SB No hiding of defaults\n" + resultStr);
+      cmdResult = executeCommand(command + " --" + CliStrings.DESCRIBE_CONFIG__HIDE__DEFAULTS + "=false");
+      resultStr = commandResultToString(cmdResult);
 
-    assertEquals(true, cmdResult.getStatus().equals(Status.OK));
-    assertEquals(true, resultStr.contains("is-server"));
-    assertEquals(true, resultStr.contains(controllerName));
-    assertEquals(true, resultStr.contains("copy-on-read"));
+      getLogWriter().info("#SB No hiding of defaults\n" + resultStr);
+
+      assertEquals(true, cmdResult.getStatus().equals(Status.OK));
+      assertEquals(true, resultStr.contains("is-server"));
+      assertEquals(true, resultStr.contains(controllerName));
+      assertEquals(true, resultStr.contains("copy-on-read"));
 
-    cs.stop();
+    } finally {
+      cs.stop();
+    }
   }
 
   @Test
-  public void testExportConfig() throws IOException {
+  public void testExportConfig() throws Exception {
     Properties localProps = new Properties();
-    localProps.setProperty(DistributionConfig.NAME_NAME, "Manager");
-    localProps.setProperty(DistributionConfig.GROUPS_NAME, "Group1");
+    localProps.setProperty(NAME_NAME, "Manager");
+    localProps.setProperty(GROUPS_NAME, "Group1");
     setUpJmxManagerOnVm0ThenConnect(localProps);
 
     // Create a cache in another VM (VM1)
     Host.getHost(0).getVM(1).invoke(new SerializableRunnable() {
       public void run() {
         Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.NAME_NAME, "VM1");
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, "Group2");
+        localProps.setProperty(NAME_NAME, "VM1");
+        localProps.setProperty(GROUPS_NAME, "Group2");
         getSystem(localProps);
         getCache();
       }
@@ -184,8 +186,8 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
     Host.getHost(0).getVM(2).invoke(new SerializableRunnable() {
       public void run() {
         Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.NAME_NAME, "VM2");
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, "Group2");
+        localProps.setProperty(NAME_NAME, "VM2");
+        localProps.setProperty(GROUPS_NAME, "Group2");
         getSystem(localProps);
         getCache();
       }
@@ -193,47 +195,47 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
 
     // Create a cache in the local VM
     localProps = new Properties();
-    localProps.setProperty(DistributionConfig.NAME_NAME, "Shell");
+    localProps.setProperty(NAME_NAME, "Shell");
     getSystem(localProps);
     Cache cache = getCache();
 
     // Test export config for all members
     deleteTestFiles();
-    CommandResult cmdResult = executeCommand("export config");
+    CommandResult cmdResult = executeCommand("export config --dir=" + this.temporaryFolder.getRoot().getAbsolutePath());
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
-    assertTrue(this.managerConfigFile.exists());
-    assertTrue(this.managerPropsFile.exists());
-    assertTrue(this.vm1ConfigFile.exists());
-    assertTrue(this.vm1PropsFile.exists());
-    assertTrue(this.vm2ConfigFile.exists());
-    assertTrue(this.vm2PropsFile.exists());
-    assertTrue(this.shellConfigFile.exists());
-    assertTrue(this.shellPropsFile.exists());
+    assertTrue(this.managerConfigFile + " should exist", this.managerConfigFile.exists());
+    assertTrue(this.managerPropsFile + " should exist", this.managerPropsFile.exists());
+    assertTrue(this.vm1ConfigFile + " should exist", this.vm1ConfigFile.exists());
+    assertTrue(this.vm1PropsFile + " should exist", this.vm1PropsFile.exists());
+    assertTrue(this.vm2ConfigFile + " should exist", this.vm2ConfigFile.exists());
+    assertTrue(this.vm2PropsFile + " should exist", this.vm2PropsFile.exists());
+    assertTrue(this.shellConfigFile + " should exist", this.shellConfigFile.exists());
+    assertTrue(this.shellPropsFile + " should exist", this.shellPropsFile.exists());
 
     // Test exporting member
     deleteTestFiles();
-    cmdResult = executeCommand("export config --member=Manager");
+    cmdResult = executeCommand("export config --member=Manager --dir=" + this.temporaryFolder.getRoot().getAbsolutePath());
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
-    assertTrue(this.managerConfigFile.exists());
-    assertFalse(this.vm1ConfigFile.exists());
-    assertFalse(this.vm2ConfigFile.exists());
-    assertFalse(this.shellConfigFile.exists());
+    assertTrue(this.managerConfigFile + " should exist", this.managerConfigFile.exists());
+    assertFalse(this.vm1ConfigFile + " should not exist", this.vm1ConfigFile.exists());
+    assertFalse(this.vm2ConfigFile + " should not exist", this.vm2ConfigFile.exists());
+    assertFalse(this.shellConfigFile + " should not exist", this.shellConfigFile.exists());
 
     // Test exporting group
     deleteTestFiles();
-    cmdResult = executeCommand("export config --group=Group2");
+    cmdResult = executeCommand("export config --group=Group2 --dir=" + this.temporaryFolder.getRoot().getAbsolutePath());
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
-    assertFalse(this.managerConfigFile.exists());
-    assertTrue(this.vm1ConfigFile.exists());
-    assertTrue(this.vm2ConfigFile.exists());
-    assertFalse(this.shellConfigFile.exists());
+    assertFalse(this.managerConfigFile + " should not exist", this.managerConfigFile.exists());
+    assertTrue(this.vm1ConfigFile + " should exist", this.vm1ConfigFile.exists());
+    assertTrue(this.vm2ConfigFile + " should exist", this.vm2ConfigFile.exists());
+    assertFalse(this.shellConfigFile + " should not exist", this.shellConfigFile.exists());
 
     // Test export to directory
     deleteTestFiles();
-    cmdResult = executeCommand("export config --dir=" + subDir.getAbsolutePath());
+    cmdResult = executeCommand("export config --dir=" + this.subDir.getAbsolutePath());
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     assertFalse(this.managerConfigFile.exists());
@@ -246,30 +248,32 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
     String configToMatch = stringWriter.toString();
 
     deleteTestFiles();
-    cmdResult = executeCommand("export config --member=Shell");
+    cmdResult = executeCommand("export config --member=Shell --dir=" + this.temporaryFolder.getRoot().getAbsolutePath());
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     char[] fileContents = new char[configToMatch.length()];
-    try {
-      FileReader reader = new FileReader(shellConfigFile);
-      reader.read(fileContents);
-    } catch (Exception ex) {
-      fail("Unable to read file contents for comparison", ex);
-    }
+    FileReader reader = new FileReader(this.shellConfigFile);
+    reader.read(fileContents);
 
     assertEquals(configToMatch, new String(fileContents));
   }
 
   @Test
-  public void testAlterRuntimeConfig() throws ClassNotFoundException, IOException {
+  public void testAlterRuntimeConfig() throws Exception {
     final String controller = "controller";
+    String directory = this.temporaryFolder.newFolder(controller).getAbsolutePath();
+    String statFilePath = new File(directory, "stat.gfs").getAbsolutePath();
+
     setUpJmxManagerOnVm0ThenConnect(null);
+
     Properties localProps = new Properties();
-    localProps.setProperty(DistributionConfig.NAME_NAME, controller);
-    localProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "error");
+    localProps.setProperty(NAME_NAME, controller);
+    localProps.setProperty(LOG_LEVEL_NAME, "error");
     getSystem(localProps);
+
     final GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
     final DistributionConfig config = cache.getSystem().getConfig();
+
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__MEMBER, controller);
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL, "info");
@@ -277,13 +281,16 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, "32");
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, "49");
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "2000");
-    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, "stat.gfs");
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, statFilePath);
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "true");
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+
     CommandResult cmdResult = executeCommand(csb.getCommandString());
     String resultString = commandResultToString(cmdResult);
+
     getLogWriter().info("Result\n");
     getLogWriter().info(resultString);
+
     assertEquals(true, cmdResult.getStatus().equals(Status.OK));
     assertEquals(LogWriterImpl.INFO_LEVEL, config.getLogLevel());
     assertEquals(50, config.getLogFileSizeLimit());
@@ -293,27 +300,29 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
     assertEquals(true, config.getStatisticSamplingEnabled());
     assertEquals(10, config.getLogDiskSpaceLimit());
 
-
     CommandProcessor commandProcessor = new CommandProcessor();
     Result result = commandProcessor.createCommandStatement("alter runtime", Collections.EMPTY_MAP).process();
   }
 
   @Test
-  public void testAlterRuntimeConfigRandom() {
+  public void testAlterRuntimeConfigRandom() throws Exception {
     final String member1 = "VM1";
     final String controller = "controller";
+
     setUpJmxManagerOnVm0ThenConnect(null);
+
     Properties localProps = new Properties();
-    localProps.setProperty(DistributionConfig.NAME_NAME, controller);
-    localProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "error");
+    localProps.setProperty(NAME_NAME, controller);
+    localProps.setProperty(LOG_LEVEL_NAME, "error");
     getSystem(localProps);
+
     final GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
     final DistributionConfig config = cache.getSystem().getConfig();
 
     Host.getHost(0).getVM(1).invoke(new SerializableRunnable() {
       public void run() {
         Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.NAME_NAME, member1);
+        localProps.setProperty(NAME_NAME, member1);
         getSystem(localProps);
         Cache cache = getCache();
       }
@@ -322,8 +331,10 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
     CommandResult cmdResult = executeCommand(csb.getCommandString());
     String resultAsString = commandResultToString(cmdResult);
+
     getLogWriter().info("#SB Result\n");
     getLogWriter().info(resultAsString);
+
     assertEquals(true, cmdResult.getStatus().equals(Status.ERROR));
     assertTrue(resultAsString.contains(CliStrings.ALTER_RUNTIME_CONFIG__RELEVANT__OPTION__MESSAGE));
 
@@ -331,45 +342,56 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "2000000000");
     cmdResult = executeCommand(csb.getCommandString());
     resultAsString = commandResultToString(cmdResult);
+
     getLogWriter().info("#SB Result\n");
     getLogWriter().info(resultAsString);
-    assertEquals(true, cmdResult.getStatus().equals(Status.ERROR));
 
+    assertEquals(true, cmdResult.getStatus().equals(Status.ERROR));
   }
 
   @Test
-  public void testAlterRuntimeConfigOnAllMembers() {
+  public void testAlterRuntimeConfigOnAllMembers() throws Exception {
     final String member1 = "VM1";
     final String controller = "controller";
+
+    String controllerDirectory = this.temporaryFolder.newFolder(controller).getAbsolutePath();
+    String controllerStatFilePath = new File(controllerDirectory, "stat.gfs").getAbsolutePath();
+
     setUpJmxManagerOnVm0ThenConnect(null);
+
     Properties localProps = new Properties();
-    localProps.setProperty(DistributionConfig.NAME_NAME, controller);
-    localProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "error");
+    localProps.setProperty(NAME_NAME, controller);
+    localProps.setProperty(LOG_LEVEL_NAME, "error");
     getSystem(localProps);
+
     final GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
     final DistributionConfig config = cache.getSystem().getConfig();
 
     Host.getHost(0).getVM(1).invoke(new SerializableRunnable() {
       public void run() {
         Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.NAME_NAME, member1);
+        localProps.setProperty(NAME_NAME, member1);
         getSystem(localProps);
         Cache cache = getCache();
       }
     });
+
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL, "info");
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50");
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, "32");
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, "49");
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "2000");
-    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, "stat.gfs");
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, controllerStatFilePath);
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "true");
     csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+
     CommandResult cmdResult = executeCommand(csb.getCommandString());
     String resultString = commandResultToString(cmdResult);
+
     getLogWriter().info("#SB Result\n");
     getLogWriter().info(resultString);
+
     assertEquals(true, cmdResult.getStatus().equals(Status.OK));
     assertEquals(LogWriterImpl.INFO_LEVEL, config.getLogLevel());
     assertEquals(50, config.getLogFileSizeLimit());
@@ -384,7 +406,8 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
     Host.getHost(0).getVM(1).invoke(new SerializableRunnable() {
       public void run() {
         GemFireCacheImpl cacheVM1 = (GemFireCacheImpl) getCache();
-        final DistributionConfig configVM1 = cacheVM1.getSystem().getConfig();
+        DistributionConfig configVM1 = cacheVM1.getSystem().getConfig();
+
         assertEquals(LogWriterImpl.INFO_LEVEL, configVM1.getLogLevel());
         assertEquals(50, configVM1.getLogFileSizeLimit());
         assertEquals(49, configVM1.getArchiveFileSizeLimit());
@@ -399,51 +422,51 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
 
   /**
    * Asserts that altering the runtime config correctly updates the shared configuration.
-   * <p>
-   * Disabled: this test frequently fails during unit test runs. See ticket #52204
    */
-  public void disabledtestAlterUpdatesSharedConfig() {
-    disconnectAllFromDS();
-
-    final String groupName = "testAlterRuntimeConfigSharedConfigGroup";
+  @Test
+  public void testAlterUpdatesSharedConfig() throws Exception {
+    final String groupName = getName();
 
     // Start the Locator and wait for shared configuration to be available
-    final int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    final int locatorPort = getRandomAvailablePort(SOCKET);
+    final String locatorDirectory = this.temporaryFolder.newFolder("Locator").getAbsolutePath();
+
     Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
       @Override
       public void run() {
+        final File locatorLogFile = new File(locatorDirectory, "locator-" + locatorPort + ".log");
 
-        final File locatorLogFile = new File("locator-" + locatorPort + ".log");
         final Properties locatorProps = new Properties();
-        locatorProps.setProperty(DistributionConfig.NAME_NAME, "Locator");
-        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+        locatorProps.setProperty(NAME_NAME, "Locator");
+        locatorProps.setProperty(MCAST_PORT_NAME, "0");
+        locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+        locatorProps.setProperty(CLUSTER_CONFIGURATION_DIR, locatorDirectory);
+
         try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, locatorLogFile, null,
-              locatorProps);
+          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, locatorLogFile, null, locatorProps);
 
           WaitCriterion wc = new WaitCriterion() {
             @Override
             public boolean done() {
               return locator.isSharedConfigurationRunning();
             }
-
             @Override
             public String description() {
               return "Waiting for shared configuration to be started";
             }
           };
           waitForCriterion(wc, 5000, 500, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
+
+        } catch (IOException e) {
+          fail("Unable to create a locator with a shared configuration", e);
         }
       }
     });
 
     // Start the default manager
     Properties managerProps = new Properties();
-    managerProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    managerProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
+    managerProps.setProperty(MCAST_PORT_NAME, "0");
+    managerProps.setProperty(LOCATORS_NAME, "localhost:" + locatorPort);
     setUpJmxManagerOnVm0ThenConnect(managerProps);
 
     // Create a cache in VM 1
@@ -451,18 +474,15 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
     vm.invoke(new SerializableCallable() {
       @Override
       public Object call() throws Exception {
-        //Make sure no previous shared config is screwing up this test.
-        FileUtil.delete(new File("ConfigDiskDir_Locator"));
-        FileUtil.delete(new File("cluster_config"));
         Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
-        localProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "error");
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
+        localProps.setProperty(MCAST_PORT_NAME, "0");
+        localProps.setProperty(LOCATORS_NAME, "localhost:" + locatorPort);
+        localProps.setProperty(LOG_LEVEL_NAME, "error");
+        localProps.setProperty(GROUPS_NAME, groupName);
         getSystem(localProps);
 
         assertNotNull(getCache());
-        assertEquals("error", basicGetSystem().getConfig().getAttribute(DistributionConfig.LOG_LEVEL_NAME));
+        assertEquals("error", basicGetSystem().getConfig().getAttribute(LOG_LEVEL_NAME));
         return null;
       }
     });
@@ -472,6 +492,7 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
     commandStringBuilder.addOption(CliStrings.ALTER_RUNTIME_CONFIG__GROUP, groupName);
     commandStringBuilder.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL, "fine");
     CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     // Make sure the shared config was updated
@@ -479,13 +500,15 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
       @Override
       public void run() {
         SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
-        Properties gemfireProperties;
+        Properties gemfireProperties = null;
+
         try {
           gemfireProperties = sharedConfig.getConfiguration(groupName).getGemfireProperties();
-          assertEquals("fine", gemfireProperties.get(DistributionConfig.LOG_LEVEL_NAME));
         } catch (Exception e) {
           fail("Error occurred in cluster configuration service", e);
         }
+
+        assertEquals("fine", gemfireProperties.get(LOG_LEVEL_NAME));
       }
     });
   }
@@ -500,6 +523,6 @@ public class ConfigCommandsDUnitTest extends CliCommandTestBase {
     this.shellConfigFile.delete();
     this.shellPropsFile.delete();
 
-    FileUtils.deleteDirectory(this.subDir);
+    deleteDirectory(this.subDir);
   }
 }


[18/36] incubator-geode git commit: GEODE-1289: remove @Retained from getValueInVM

Posted by hi...@apache.org.
GEODE-1289: remove @Retained from getValueInVM

@Retained has been removed from the getValueInVM declaration
and callers have been changed to no longer act as if the result
of getValueInVM might be off-heap.


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

Branch: refs/heads/feature/GEODE-1372
Commit: 3ebcf1f750f3692179219b80737a39289d90c72d
Parents: f4a1679
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Tue May 10 16:12:56 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed May 11 10:40:26 2016 -0700

----------------------------------------------------------------------
 .../query/internal/index/AbstractIndex.java     | 12 +--------
 .../internal/cache/AbstractRegionEntry.java     | 12 +++------
 .../internal/cache/AbstractRegionMap.java       | 26 +++-----------------
 .../gemfire/internal/cache/RegionEntry.java     |  2 --
 4 files changed, 8 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3ebcf1f7/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
index 96e83b2..393428b 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
@@ -1472,23 +1472,13 @@ public abstract class AbstractIndex implements IndexProtocol
         valuesInRegion = evaluateIndexIteratorsFromRE(re, context);
         valueInIndex = verifyAndGetPdxDomainObject(value);
       } else{
-        @Released Object val = re.getValueInVM(context.getPartitionedRegion());
-        StoredObject valToFree = null;
-        if (val instanceof StoredObject) {
-          valToFree = (StoredObject)val;
-        }
-        try {
+        Object val = re.getValueInVM(context.getPartitionedRegion());
         if (val instanceof CachedDeserializable) {
           val = ((CachedDeserializable)val).getDeserializedValue(getRegion(), re);
         }
         val = verifyAndGetPdxDomainObject(val);   
         valueInIndex = verifyAndGetPdxDomainObject(value);
         valuesInRegion = evaluateIndexIteratorsFromRE(val, context);
-        } finally {
-          if (valToFree != null) {
-            valToFree.release();
-          }
-        }
       }
     } catch (Exception e) {
       // TODO: Create a new LocalizedString for this.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3ebcf1f7/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
index 481c3be..25cc818 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
@@ -557,20 +557,18 @@ public abstract class AbstractRegionEntry implements RegionEntry,
   }
   
   
-  @Retained
   public final Object getValueInVM(RegionEntryContext context) {
     ReferenceCountHelper.createReferenceCountOwner();
-    @Retained Object v = _getValueRetain(context, true);
+    @Released Object v = _getValueRetain(context, true);
     
     if (v == null) { // should only be possible if disk entry
       v = Token.NOT_AVAILABLE;
     }
-    @Retained Object result = OffHeapHelper.copyAndReleaseIfNeeded(v);
+    Object result = OffHeapHelper.copyAndReleaseIfNeeded(v);
     ReferenceCountHelper.setReferenceCountOwner(null);
     return result;
   }
   
-  @Retained
   public  Object getValueInVMOrDiskWithoutFaultIn(LocalRegion owner) {
    return getValueInVM(owner);
   }
@@ -642,8 +640,7 @@ public abstract class AbstractRegionEntry implements RegionEntry,
         // Because the pr meta data region will not have an LRU.
         newValueToWrite = ((CachedDeserializable) newValueToWrite).getDeserializedValue(region, null);
         if (!create && newValueToWrite instanceof Versionable) {
-          @Retained @Released final Object oldValue = getValueInVM(region); // Heap value should always be deserialized at this point // OFFHEAP will not be deserialized
-          try {
+          final Object oldValue = getValueInVM(region); // Heap value should always be deserialized at this point // OFFHEAP will not be deserialized
           // BUGFIX for 35029. If oldValue is null the newValue should be put.
           if(oldValue == null) {
           	putValue = true;
@@ -653,9 +650,6 @@ public abstract class AbstractRegionEntry implements RegionEntry,
             Versionable ov = (Versionable) oldValue;
             putValue = nv.isNewerThan(ov);
           }  
-          } finally {
-            OffHeapHelper.release(oldValue);
-          }
         }
       }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3ebcf1f7/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
index 75a1e32..5248d3d 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
@@ -1588,8 +1588,7 @@ public abstract class AbstractRegionMap implements RegionMap {
           synchronized (re) {
             if (!re.isRemoved() || re.isTombstone()) {
               EntryEventImpl sqlfEvent = null;
-              @Retained @Released Object oldValue = re.getValueInVM(owner);
-              try {
+              Object oldValue = re.getValueInVM(owner);
               final int oldSize = owner.calculateRegionEntryValueSize(re);
               // Create an entry event only if the calling context is
               // a receipt of a TXCommitMessage AND there are callbacks installed
@@ -1672,9 +1671,6 @@ public abstract class AbstractRegionMap implements RegionMap {
               } finally {
                 if (!cbEventInPending) cbEvent.release();
               }
-              } finally {
-                OffHeapHelper.release(oldValue);
-              }
             }
           }
         } finally {
@@ -1959,18 +1955,14 @@ public abstract class AbstractRegionMap implements RegionMap {
                       if (!oldRe.isRemoved() && 
                           (fp != null && fp.getCqCount() > 0)) {
                         
-                        @Retained @Released Object oldValue = oldRe.getValueInVM(owner); // OFFHEAP EntryEventImpl oldValue
+                        Object oldValue = oldRe.getValueInVM(owner); // OFFHEAP EntryEventImpl oldValue
                         
                         // this will not fault in the value.
-                        try {
                         if (oldValue == Token.NOT_AVAILABLE){
                           event.setOldValue(oldRe.getValueOnDiskOrBuffer(owner));
                         } else {
                           event.setOldValue(oldValue);
                         }
-                        } finally {
-                          OffHeapHelper.release(oldValue);
-                        }
                       }
                       boolean isCreate = false;
                       try {
@@ -2196,14 +2188,8 @@ public abstract class AbstractRegionMap implements RegionMap {
                     if (re.isValueNull()) {
                       event.setOldValue(re.getValueOnDiskOrBuffer(owner));
                     } else {
-                      
-                      @Retained @Released Object v = re.getValueInVM(owner);
-                      
-                      try {
-                        event.setOldValue(v); // OFFHEAP escapes to EntryEventImpl oldValue
-                      } finally {
-                        OffHeapHelper.release(v);
-                      }
+                      Object v = re.getValueInVM(owner);
+                      event.setOldValue(v); // OFFHEAP escapes to EntryEventImpl oldValue
                     }
                   }
                   final boolean oldWasTombstone = re.isTombstone();
@@ -2400,7 +2386,6 @@ public abstract class AbstractRegionMap implements RegionMap {
                     final boolean oldWasTombstone = oldRe.isTombstone();
                     final int oldSize = owner.calculateRegionEntryValueSize(oldRe);
                     Object oldValue = oldRe.getValueInVM(owner); // OFFHEAP eei
-                    try {
                     // Create an entry event only if the calling context is
                     // a receipt of a TXCommitMessage AND there are callbacks
                     // installed
@@ -2462,9 +2447,6 @@ public abstract class AbstractRegionMap implements RegionMap {
                     } finally {
                       if (!cbEventInPending) cbEvent.release();
                     }
-                    } finally {
-                      OffHeapHelper.release(oldValue);
-                    }
                   }
                 }
               }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3ebcf1f7/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RegionEntry.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RegionEntry.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RegionEntry.java
index bedbf81..09aef2a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RegionEntry.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RegionEntry.java
@@ -283,7 +283,6 @@ public interface RegionEntry {
    *
    * @see LocalRegion#getValueInVM
    */
-  @Retained
   public Object getValueInVM(RegionEntryContext context);
   /**
    * Returns the value of an entry as it resides on disk.  For
@@ -383,7 +382,6 @@ public interface RegionEntry {
    * return a temporary copy. For SQLFabric this is used during table scans in
    * queries when faulting in every value will be only an unnecessary overhead.
    */
-  @Retained
   public Object getValueInVMOrDiskWithoutFaultIn(LocalRegion owner);
 
   /**


[13/36] incubator-geode git commit: GEODE-1370: restore name of destroySharedConfiguration_forTestsOnly

Posted by hi...@apache.org.
GEODE-1370: restore name of destroySharedConfiguration_forTestsOnly


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

Branch: refs/heads/feature/GEODE-1372
Commit: 9d28009f1018bba74dab671c64ee42e8b4a25899
Parents: fe69f0a
Author: Kirk Lund <kl...@apache.org>
Authored: Wed May 11 09:56:07 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Wed May 11 09:56:07 2016 -0700

----------------------------------------------------------------------
 .../gemfire/distributed/internal/SharedConfiguration.java         | 2 +-
 .../internal/configuration/SharedConfigurationDUnitTest.java      | 2 +-
 .../internal/configuration/SharedConfigurationTestUtils.java      | 2 +-
 .../configuration/SharedConfigurationUsingDirDUnitTest.java       | 3 +--
 4 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9d28009f/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/SharedConfiguration.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/SharedConfiguration.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/SharedConfiguration.java
index 0f349e9..ba9c7dc 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/SharedConfiguration.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/SharedConfiguration.java
@@ -406,7 +406,7 @@ public class SharedConfiguration {
    * <p/>
    * Throws {@code AssertionError} wrapping any exception thrown by operation.
    */
-  public void destroySharedConfiguration_forTestsOnly() {
+  public void destroySharedConfiguration() {
     try {
       Region<String, Configuration> configRegion = getConfigurationRegion();
       if (configRegion != null) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9d28009f/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationDUnitTest.java
index c07eab7..f0c685b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationDUnitTest.java
@@ -187,7 +187,7 @@ public class SharedConfigurationDUnitTest extends JUnit4CacheTestCase {
       public Object call() {
         InternalLocator locator = (InternalLocator) Locator.getLocator();
         SharedConfiguration sharedConfig = locator.getSharedConfiguration();
-        sharedConfig.destroySharedConfiguration_forTestsOnly();
+        sharedConfig.destroySharedConfiguration();
         locator.stop();
         return null;
       }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9d28009f/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationTestUtils.java
index 235f02e..1174c7d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationTestUtils.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationTestUtils.java
@@ -30,7 +30,7 @@ public class SharedConfigurationTestUtils {
       if (locator != null) {
         SharedConfiguration sharedConfig = locator.getSharedConfiguration();
         if (sharedConfig != null) {
-          sharedConfig.destroySharedConfiguration_forTestsOnly();
+          sharedConfig.destroySharedConfiguration();
         }
         locator.stop();
       }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9d28009f/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
index 9cbb12c..8f80877 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
@@ -33,7 +33,6 @@ import java.util.Arrays;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
-import org.junit.After;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -62,7 +61,7 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
 
         SharedConfiguration sharedConfig = locator.getSharedConfiguration();
         if (sharedConfig != null) {
-          sharedConfig.destroySharedConfiguration_forTestsOnly();
+          sharedConfig.destroySharedConfiguration();
         }
       });
     }


[11/36] incubator-geode git commit: GEODE-1153: BucketOperatorWrapper fails to invoke completion callback.

Posted by hi...@apache.org.
GEODE-1153: BucketOperatorWrapper fails to invoke completion callback.

 * Fixed BucketOperatorWrapper to invoke onFailure if bucket creation fails
 * Promoted BucketOperatorWrapper & BucketOperatorImpl to be higher level classes
   to ease unit test callback invocation
 * Added JUnit tests to test these higher level classes
 * Added a DUnit to test redundancy is met if redundant bucket creation fails


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

Branch: refs/heads/feature/GEODE-1372
Commit: 02b7688663f5bb2919c07183336704f300462b63
Parents: 3222b05
Author: Sai Boorlagadda <sb...@pivotal.io>
Authored: Thu Mar 31 15:37:25 2016 -0700
Committer: Sai Boorlagadda <sb...@pivotal.io>
Committed: Tue May 10 22:31:33 2016 -0700

----------------------------------------------------------------------
 .../PartitionedRegionRebalanceOp.java           | 322 ++----------------
 .../rebalance/BucketOperatorImpl.java           |  78 +++++
 .../rebalance/BucketOperatorWrapper.java        | 235 ++++++++++++++
 .../rebalance/PartitionedRegionLoadModel.java   |   2 +
 .../control/RebalanceOperationDUnitTest.java    | 148 ++++++++-
 .../rebalance/BucketOperatorImplTest.java       | 138 ++++++++
 .../rebalance/BucketOperatorWrapperTest.java    | 323 +++++++++++++++++++
 7 files changed, 950 insertions(+), 296 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02b76886/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PartitionedRegionRebalanceOp.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PartitionedRegionRebalanceOp.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PartitionedRegionRebalanceOp.java
index 8642876..641d43d 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PartitionedRegionRebalanceOp.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PartitionedRegionRebalanceOp.java
@@ -47,6 +47,8 @@ import com.gemstone.gemfire.internal.cache.partitioned.BecomePrimaryBucketMessag
 import com.gemstone.gemfire.internal.cache.partitioned.MoveBucketMessage.MoveBucketResponse;
 import com.gemstone.gemfire.internal.cache.partitioned.RemoveBucketMessage.RemoveBucketResponse;
 import com.gemstone.gemfire.internal.cache.partitioned.rebalance.BucketOperator;
+import com.gemstone.gemfire.internal.cache.partitioned.rebalance.BucketOperatorImpl;
+import com.gemstone.gemfire.internal.cache.partitioned.rebalance.BucketOperatorWrapper;
 import com.gemstone.gemfire.internal.cache.partitioned.rebalance.ParallelBucketOperator;
 import com.gemstone.gemfire.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel;
 import com.gemstone.gemfire.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.AddressComparor;
@@ -413,9 +415,9 @@ public class PartitionedRegionRebalanceOp {
     }
     BucketOperator operator = simulate ? 
         new SimulatedBucketOperator() 
-        : new BucketOperatorImpl();
+        : new BucketOperatorImpl(this);
     BucketOperatorWrapper wrapper = new BucketOperatorWrapper(
-        operator, rebalanceDetails);
+        operator, rebalanceDetails, stats, leaderRegion);
     return wrapper;
   }
 
@@ -509,17 +511,12 @@ public class PartitionedRegionRebalanceOp {
    *          the member on which to create the redundant bucket
    * @param bucketId
    *          the identifier of the bucket
-   * @param pr
-   *          the partitioned region which contains the bucket
-   * @param forRebalance
-   *          true if part of a rebalance operation
    * @return true if the redundant bucket was created
    */
-  public static boolean createRedundantBucketForRegion(
-      InternalDistributedMember target, int bucketId, PartitionedRegion pr,
-      boolean forRebalance, boolean replaceOfflineData) {
-    return pr.getRedundancyProvider().createBackupBucketOnMember(bucketId,
-        target, forRebalance, replaceOfflineData,null, true);
+  public boolean createRedundantBucketForRegion(
+      InternalDistributedMember target, int bucketId) {
+    return getLeaderRegion().getRedundancyProvider().createBackupBucketOnMember(bucketId,
+        target, isRebalance, replaceOfflineData,null, true);
   }
   
   /**
@@ -529,20 +526,18 @@ public class PartitionedRegionRebalanceOp {
    *          the member on which to create the redundant bucket
    * @param bucketId
    *          the identifier of the bucket
-   * @param pr
-   *          the partitioned region which contains the bucket
    * @return true if the redundant bucket was removed
    */
-  public static boolean removeRedundantBucketForRegion(
-      InternalDistributedMember target, int bucketId, PartitionedRegion pr) {
+  public boolean removeRedundantBucketForRegion(
+      InternalDistributedMember target, int bucketId) {
     boolean removed = false;
-    if (pr.getDistributionManager().getId().equals(target)) {
+    if (getLeaderRegion().getDistributionManager().getId().equals(target)) {
       // invoke directly on local member...
-      removed = pr.getDataStore().removeBucket(bucketId, false);
+      removed = getLeaderRegion().getDataStore().removeBucket(bucketId, false);
     }
     else {
       // send message to remote member...
-      RemoveBucketResponse response = RemoveBucketMessage.send(target, pr,
+      RemoveBucketResponse response = RemoveBucketMessage.send(target, getLeaderRegion(),
           bucketId, false);
       if (response != null) {
         removed = response.waitForResponse();
@@ -558,28 +553,23 @@ public class PartitionedRegionRebalanceOp {
    *          the member which should be primary
    * @param bucketId
    *          the identifier of the bucket
-   * @param pr
-   *          the partitioned region which contains the bucket
-   * @param forRebalance
-   *          true if part of a rebalance operation
    * @return true if the move was successful
    */
-  public static boolean movePrimaryBucketForRegion(
-      InternalDistributedMember target, int bucketId, PartitionedRegion pr,
-      boolean forRebalance) {
+  public boolean movePrimaryBucketForRegion(
+      InternalDistributedMember target, int bucketId) {
     boolean movedPrimary = false;
-    if (pr.getDistributionManager().getId().equals(target)) {
+    if (getLeaderRegion().getDistributionManager().getId().equals(target)) {
       // invoke directly on local member...
-      BucketAdvisor bucketAdvisor = pr.getRegionAdvisor().getBucketAdvisor(
+      BucketAdvisor bucketAdvisor = getLeaderRegion().getRegionAdvisor().getBucketAdvisor(
           bucketId);
       if (bucketAdvisor.isHosting()) {
-        movedPrimary = bucketAdvisor.becomePrimary(forRebalance);
+        movedPrimary = bucketAdvisor.becomePrimary(isRebalance);
       }
     }
     else {
       // send message to remote member...
       BecomePrimaryBucketResponse response = BecomePrimaryBucketMessage.send(
-          target, pr, bucketId, forRebalance);
+          target, getLeaderRegion(), bucketId, isRebalance);
       if (response != null) {
         movedPrimary = response.waitForResponse();
       }
@@ -596,20 +586,18 @@ public class PartitionedRegionRebalanceOp {
    *          member which should receive the bucket
    * @param bucketId
    *          the identifier of the bucket
-   * @param pr
-   *          the partitioned region which contains the bucket
    * @return true if the bucket was moved
    */
-  public static boolean moveBucketForRegion(InternalDistributedMember source,
-      InternalDistributedMember target, int bucketId, PartitionedRegion pr) {
+  public boolean moveBucketForRegion(InternalDistributedMember source,
+      InternalDistributedMember target, int bucketId) {
     boolean movedBucket = false;
-    if (pr.getDistributionManager().getId().equals(target)) {
+    if (getLeaderRegion().getDistributionManager().getId().equals(target)) {
       // invoke directly on local member...
-      movedBucket = pr.getDataStore().moveBucket(bucketId, source, false);
+      movedBucket = getLeaderRegion().getDataStore().moveBucket(bucketId, source, false);
     }
     else {
       // send message to remote member...
-      MoveBucketResponse response = MoveBucketMessage.send(target, pr,
+      MoveBucketResponse response = MoveBucketMessage.send(target, getLeaderRegion(),
           bucketId, source);
       if (response != null) {
         movedBucket = response.waitForResponse();
@@ -626,6 +614,10 @@ public class PartitionedRegionRebalanceOp {
            leaderRegion.getDataPolicy().withPersistence());
   }
   
+  public PartitionedRegion getLeaderRegion() {
+    return leaderRegion;
+  }
+  
   private class MembershipChangeListener implements MembershipListener {
 
     public void memberDeparted(InternalDistributedMember id, boolean crashed) {
@@ -650,262 +642,4 @@ public class PartitionedRegionRebalanceOp {
     public void quorumLost(Set<InternalDistributedMember> failures, List<InternalDistributedMember> remaining) {
     }
   }
-  
-  private class BucketOperatorImpl implements BucketOperator {
-
-    @Override
-    public boolean moveBucket(InternalDistributedMember source,
-        InternalDistributedMember target, int bucketId,
-        Map<String, Long> colocatedRegionBytes) {
-
-      InternalResourceManager.getResourceObserver().movingBucket(
-          leaderRegion, bucketId, source, target);
-      return moveBucketForRegion(source, target, bucketId, leaderRegion);
-    }
-
-    @Override
-    public boolean movePrimary(InternalDistributedMember source,
-        InternalDistributedMember target, int bucketId) {
-
-      InternalResourceManager.getResourceObserver().movingPrimary(
-          leaderRegion, bucketId, source, target);
-      return movePrimaryBucketForRegion(target, bucketId, leaderRegion, isRebalance); 
-    }
-
-    @Override
-    public void createRedundantBucket(
-        InternalDistributedMember targetMember, int bucketId,
-        Map<String, Long> colocatedRegionBytes, Completion completion) {
-      boolean result = false;
-      try {
-        result = createRedundantBucketForRegion(targetMember, bucketId,
-          leaderRegion, isRebalance,replaceOfflineData);
-      } finally {
-        if(result) {
-          completion.onSuccess();
-        } else {
-          completion.onFailure();
-        }
-      }
-    }
-    
-    @Override
-    public void waitForOperations() {
-      //do nothing, all operations are synchronous
-    }
-
-    @Override
-    public boolean removeBucket(InternalDistributedMember targetMember, int bucketId,
-        Map<String, Long> colocatedRegionBytes) {
-      return removeRedundantBucketForRegion(targetMember, bucketId,
-          leaderRegion);
-    }
-  }
-
-  /**
-   * A wrapper class which delegates actual bucket operations to the enclosed BucketOperator,
-   * but keeps track of statistics about how many buckets are created, transfered, etc.
-   *
-   */
-  private class BucketOperatorWrapper implements 
-      BucketOperator {
-    private final BucketOperator delegate;
-    private final Set<PartitionRebalanceDetailsImpl> detailSet;
-    private final int regionCount;
-  
-    public BucketOperatorWrapper(
-        BucketOperator delegate,
-        Set<PartitionRebalanceDetailsImpl> rebalanceDetails) {
-      this.delegate = delegate;
-      this.detailSet = rebalanceDetails;
-      this.regionCount = detailSet.size();
-    }
-    @Override
-    public boolean moveBucket(InternalDistributedMember sourceMember,
-        InternalDistributedMember targetMember, int id,
-        Map<String, Long> colocatedRegionBytes) {
-      long start = System.nanoTime();
-      boolean result = false;
-      long elapsed = 0;
-      long totalBytes = 0;
-
-
-      if (stats != null) {
-        stats.startBucketTransfer(regionCount);
-      }
-      try {
-        result = delegate.moveBucket(sourceMember, targetMember, id,
-            colocatedRegionBytes);
-        elapsed = System.nanoTime() - start;
-        if (result) {
-          if (logger.isDebugEnabled()) {
-            logger.debug("Rebalancing {} bucket {} moved from {} to {}", leaderRegion, id, sourceMember, targetMember);
-          }
-          for (PartitionRebalanceDetailsImpl details : detailSet) {
-            String regionPath = details.getRegionPath();
-            Long regionBytes = colocatedRegionBytes.get(regionPath);
-            if(regionBytes != null) {
-            //only increment the elapsed time for the leader region
-              details.incTransfers(regionBytes.longValue(),
-                  details.getRegion().equals(leaderRegion) ? elapsed : 0);
-              totalBytes += regionBytes.longValue();
-            }
-          }
-        } else {
-          if (logger.isDebugEnabled()) {
-            logger.debug("Rebalancing {} bucket {} moved failed from {} to {}", leaderRegion, id, sourceMember, targetMember);
-          }
-        }
-      } finally {
-        if(stats != null) {
-          stats.endBucketTransfer(regionCount, result, totalBytes, elapsed);
-        }
-      }
-      
-      return result;
-    }
-
-    @Override
-    public void createRedundantBucket(
-        final InternalDistributedMember targetMember, final int i, 
-        final Map<String, Long> colocatedRegionBytes, final Completion completion) {
-      
-      if(stats != null) {
-        stats.startBucketCreate(regionCount);
-      }
-      
-      final long start = System.nanoTime();
-      delegate.createRedundantBucket(targetMember, i,  
-          colocatedRegionBytes, new Completion() {
-
-        @Override
-        public void onSuccess() {
-          long totalBytes = 0;
-          long elapsed= System.nanoTime() - start;
-          if(logger.isDebugEnabled()) {
-            logger.debug("Rebalancing {} redundant bucket {} created on {}", leaderRegion, i, targetMember);
-          }
-          for (PartitionRebalanceDetailsImpl details : detailSet) {
-            String regionPath = details.getRegionPath();
-            Long lrb = colocatedRegionBytes.get(regionPath);
-            if (lrb != null) { // region could have gone away - esp during shutdow
-              long regionBytes = lrb.longValue();
-              //Only add the elapsed time to the leader region.
-              details.incCreates(regionBytes, 
-                  details.getRegion().equals(leaderRegion) ? elapsed : 0);
-              totalBytes += regionBytes;
-            }
-          }
-
-          if(stats != null) {
-            stats.endBucketCreate(regionCount, true, totalBytes, elapsed);
-          }
-
-        }
-
-        @Override
-        public void onFailure() {
-          long elapsed= System.nanoTime() - start;
-
-          if (logger.isDebugEnabled()) {
-            logger.debug("Rebalancing {} redundant bucket {} failed creation on {}", leaderRegion, i, targetMember);
-          }
-
-          if(stats != null) {
-            stats.endBucketCreate(regionCount, false, 0, elapsed);
-          }
-        }
-      });
-    }
-    
-    @Override
-    public boolean removeBucket(
-        InternalDistributedMember targetMember, int i, 
-        Map<String, Long> colocatedRegionBytes) {
-      boolean result = false;
-      long elapsed = 0;
-      long totalBytes = 0;
-      
-      
-      if(stats != null) {
-        stats.startBucketRemove(regionCount);
-      }
-      try {
-        long start = System.nanoTime();
-        result = delegate.removeBucket(targetMember, i,  
-            colocatedRegionBytes);
-        elapsed= System.nanoTime() - start;
-        if (result) {
-          if(logger.isDebugEnabled()) {
-            logger.debug("Rebalancing {} redundant bucket {} removed from {}", leaderRegion, i, targetMember);
-          }
-          for (PartitionRebalanceDetailsImpl details : detailSet) {
-            String regionPath = details.getRegionPath();
-            Long lrb = colocatedRegionBytes.get(regionPath);
-            if (lrb != null) { // region could have gone away - esp during shutdow
-              long regionBytes = lrb.longValue();
-              //Only add the elapsed time to the leader region.
-              details.incRemoves(regionBytes, 
-                  details.getRegion().equals(leaderRegion) ? elapsed : 0);
-              totalBytes += regionBytes;
-            }
-          }
-        } else {
-          if (logger.isDebugEnabled()) {
-            logger.debug("Rebalancing {} redundant bucket {} failed removal o{}", leaderRegion, i, targetMember);
-          }
-        }
-      } finally {
-        if(stats != null) {
-          stats.endBucketRemove(regionCount, result, totalBytes, elapsed);
-        }
-      }
-      
-      return result;
-    }
-  
-    @Override
-    public boolean movePrimary(InternalDistributedMember source,
-        InternalDistributedMember target, int bucketId) {
-      boolean result = false;
-      long elapsed = 0;
-      
-      if(stats != null) {
-        stats.startPrimaryTransfer(regionCount);
-      }
-
-      try {
-        long start = System.nanoTime();
-        result = delegate.movePrimary(source, target, bucketId);
-        elapsed = System.nanoTime() - start;
-        if (result) {
-          if (logger.isDebugEnabled()) {
-            logger.debug("Rebalancing {} primary bucket {} moved from {} to {}", leaderRegion, bucketId, source, target);
-          }
-          for (PartitionRebalanceDetailsImpl details : detailSet) {
-            details.incPrimaryTransfers(details.getRegion().equals(leaderRegion) ? elapsed : 0);
-          }
-        } else {
-          if (logger.isDebugEnabled()) {
-            logger.debug("Rebalancing {} primary bucket {} failed to move from {} to {}", leaderRegion, bucketId, source, target);
-          }
-        }
-    } finally {
-      if(stats != null) {
-        stats.endPrimaryTransfer(regionCount, result, elapsed);
-      }
-    }
-      
-      return result;
-    }
-    
-    @Override
-    public void waitForOperations() {
-      delegate.waitForOperations();
-    }
-
-    public Set<PartitionRebalanceDetailsImpl> getDetailSet() {
-      return this.detailSet;
-    }
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02b76886/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorImpl.java
new file mode 100644
index 0000000..2f38752
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorImpl.java
@@ -0,0 +1,78 @@
+/*
+ * 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 com.gemstone.gemfire.internal.cache.partitioned.rebalance;
+
+import java.util.Map;
+
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
+import com.gemstone.gemfire.internal.cache.control.InternalResourceManager;
+import com.gemstone.gemfire.internal.cache.partitioned.PartitionedRegionRebalanceOp;
+
+public class BucketOperatorImpl implements BucketOperator {
+  
+  private PartitionedRegionRebalanceOp rebalanceOp;
+
+  public BucketOperatorImpl(PartitionedRegionRebalanceOp rebalanceOp) {
+    this.rebalanceOp = rebalanceOp;
+  }
+
+  @Override
+  public boolean moveBucket(InternalDistributedMember source,
+      InternalDistributedMember target, int bucketId,
+      Map<String, Long> colocatedRegionBytes) {
+
+    InternalResourceManager.getResourceObserver().movingBucket(
+        rebalanceOp.getLeaderRegion(), bucketId, source, target);
+    return rebalanceOp.moveBucketForRegion(source, target, bucketId);
+  }
+
+  @Override
+  public boolean movePrimary(InternalDistributedMember source,
+      InternalDistributedMember target, int bucketId) {
+
+    InternalResourceManager.getResourceObserver().movingPrimary(
+        rebalanceOp.getLeaderRegion(), bucketId, source, target);
+    return rebalanceOp.movePrimaryBucketForRegion(target, bucketId); 
+  }
+
+  @Override
+  public void createRedundantBucket(
+      InternalDistributedMember targetMember, int bucketId,
+      Map<String, Long> colocatedRegionBytes, Completion completion) {
+    boolean result = false;
+    try {
+      result = rebalanceOp.createRedundantBucketForRegion(targetMember, bucketId);
+    } finally {
+      if(result) {
+        completion.onSuccess();
+      } else {
+        completion.onFailure();
+      }
+    }
+  }
+  
+  @Override
+  public void waitForOperations() {
+    //do nothing, all operations are synchronous
+  }
+
+  @Override
+  public boolean removeBucket(InternalDistributedMember targetMember, int bucketId,
+      Map<String, Long> colocatedRegionBytes) {
+    return rebalanceOp.removeRedundantBucketForRegion(targetMember, bucketId);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02b76886/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorWrapper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorWrapper.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorWrapper.java
new file mode 100644
index 0000000..d058a04
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorWrapper.java
@@ -0,0 +1,235 @@
+/*
+ * 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 com.gemstone.gemfire.internal.cache.partitioned.rebalance;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.logging.log4j.Logger;
+
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.control.PartitionRebalanceDetailsImpl;
+import com.gemstone.gemfire.internal.cache.control.ResourceManagerStats;
+import com.gemstone.gemfire.internal.logging.LogService;
+
+public class BucketOperatorWrapper implements BucketOperator {
+  private static final Logger logger = LogService.getLogger();
+  
+  private final BucketOperator delegate;
+  private final Set<PartitionRebalanceDetailsImpl> detailSet;
+  private final int regionCount;
+  private final ResourceManagerStats stats;
+  private final PartitionedRegion leaderRegion;
+
+  public BucketOperatorWrapper(BucketOperator delegate, Set<PartitionRebalanceDetailsImpl> rebalanceDetails, 
+      ResourceManagerStats stats, PartitionedRegion leaderRegion) {
+    this.delegate = delegate;
+    this.detailSet = rebalanceDetails;
+    this.regionCount = detailSet.size();
+    this.stats = stats;
+    this.leaderRegion = leaderRegion;
+  }
+
+  @Override
+  public boolean moveBucket(InternalDistributedMember sourceMember, 
+      InternalDistributedMember targetMember, int id, 
+      Map<String, Long> colocatedRegionBytes) {
+    long start = System.nanoTime();
+    boolean result = false;
+    long elapsed = 0;
+    long totalBytes = 0;
+
+    if (stats != null) {
+      stats.startBucketTransfer(regionCount);
+    }
+    try {
+      result = delegate.moveBucket(sourceMember, targetMember, id, colocatedRegionBytes);
+      elapsed = System.nanoTime() - start;
+      if (result) {
+        if (logger.isDebugEnabled()) {
+          logger.debug("Rebalancing {} bucket {} moved from {} to {}", leaderRegion, id, sourceMember, targetMember);
+        }
+        for (PartitionRebalanceDetailsImpl details : detailSet) {
+          String regionPath = details.getRegionPath();
+          Long regionBytes = colocatedRegionBytes.get(regionPath);
+          if (regionBytes != null) {
+            // only increment the elapsed time for the leader region
+            details.incTransfers(regionBytes.longValue(), 
+                details.getRegion().equals(leaderRegion) ? elapsed : 0);
+            totalBytes += regionBytes.longValue();
+          }
+        }
+      } else {
+        if (logger.isDebugEnabled()) {
+          logger.debug("Rebalancing {} bucket {} moved failed from {} to {}", leaderRegion, id, sourceMember, targetMember);
+        }
+      }
+    } finally {
+      if (stats != null) {
+        stats.endBucketTransfer(regionCount, result, totalBytes, elapsed);
+      }
+    }
+
+    return result;
+  }
+
+  @Override
+  public void createRedundantBucket(
+      final InternalDistributedMember targetMember, final int i, 
+      final Map<String, Long> colocatedRegionBytes, final Completion completion) {
+
+    if (stats != null) {
+      stats.startBucketCreate(regionCount);
+    }
+
+    final long start = System.nanoTime();
+    delegate.createRedundantBucket(targetMember, i, 
+        colocatedRegionBytes, new Completion() {
+
+      @Override
+      public void onSuccess() {
+        long totalBytes = 0;
+        long elapsed = System.nanoTime() - start;
+        if (logger.isDebugEnabled()) {
+          logger.debug("Rebalancing {} redundant bucket {} created on {}", leaderRegion, i, targetMember);
+        }
+        for (PartitionRebalanceDetailsImpl details : detailSet) {
+          String regionPath = details.getRegionPath();
+          Long lrb = colocatedRegionBytes.get(regionPath);
+          if (lrb != null) { // region could have gone away - esp during shutdow
+            long regionBytes = lrb.longValue();
+            // Only add the elapsed time to the leader region.
+            details.incCreates(regionBytes, details.getRegion().equals(leaderRegion) ? elapsed : 0);
+            totalBytes += regionBytes;
+          }
+        }
+
+        if (stats != null) {
+          stats.endBucketCreate(regionCount, true, totalBytes, elapsed);
+        }
+        
+        //invoke onSuccess on the received completion callback
+        completion.onSuccess();
+      }
+
+      @Override
+      public void onFailure() {
+        long elapsed = System.nanoTime() - start;
+
+        if (logger.isDebugEnabled()) {
+          logger.info("Rebalancing {} redundant bucket {} failed creation on {}", leaderRegion, i, targetMember);
+        }
+
+        if (stats != null) {
+          stats.endBucketCreate(regionCount, false, 0, elapsed);
+        }
+        
+        //invoke onFailure on the received completion callback
+        completion.onFailure();
+      }
+    });
+  }
+
+  @Override
+  public boolean removeBucket(
+      InternalDistributedMember targetMember, int i, 
+      Map<String, Long> colocatedRegionBytes) {
+    boolean result = false;
+    long elapsed = 0;
+    long totalBytes = 0;
+
+    if (stats != null) {
+      stats.startBucketRemove(regionCount);
+    }
+    try {
+      long start = System.nanoTime();
+      result = delegate.removeBucket(targetMember, i, colocatedRegionBytes);
+      elapsed = System.nanoTime() - start;
+      if (result) {
+        if (logger.isDebugEnabled()) {
+          logger.debug("Rebalancing {} redundant bucket {} removed from {}", leaderRegion, i, targetMember);
+        }
+        for (PartitionRebalanceDetailsImpl details : detailSet) {
+          String regionPath = details.getRegionPath();
+          Long lrb = colocatedRegionBytes.get(regionPath);
+          if (lrb != null) { // region could have gone away - esp during shutdow
+            long regionBytes = lrb.longValue();
+            // Only add the elapsed time to the leader region.
+            details.incRemoves(regionBytes, 
+                details.getRegion().equals(leaderRegion) ? elapsed : 0);
+            totalBytes += regionBytes;
+          }
+        }
+      } else {
+        if (logger.isDebugEnabled()) {
+          logger.debug("Rebalancing {} redundant bucket {} failed removal o{}", leaderRegion, i, targetMember);
+        }
+      }
+    } finally {
+      if (stats != null) {
+        stats.endBucketRemove(regionCount, result, totalBytes, elapsed);
+      }
+    }
+
+    return result;
+  }
+
+  @Override
+  public boolean movePrimary(InternalDistributedMember source, 
+      InternalDistributedMember target, int bucketId) {
+    boolean result = false;
+    long elapsed = 0;
+
+    if (stats != null) {
+      stats.startPrimaryTransfer(regionCount);
+    }
+
+    try {
+      long start = System.nanoTime();
+      result = delegate.movePrimary(source, target, bucketId);
+      elapsed = System.nanoTime() - start;
+      if (result) {
+        if (logger.isDebugEnabled()) {
+          logger.debug("Rebalancing {} primary bucket {} moved from {} to {}", leaderRegion, bucketId, source, target);
+        }
+        for (PartitionRebalanceDetailsImpl details : detailSet) {
+          details.incPrimaryTransfers(details.getRegion().equals(leaderRegion) ? elapsed : 0);
+        }
+      } else {
+        if (logger.isDebugEnabled()) {
+          logger.debug("Rebalancing {} primary bucket {} failed to move from {} to {}", leaderRegion, bucketId, source, target);
+        }
+      }
+    } finally {
+      if (stats != null) {
+        stats.endPrimaryTransfer(regionCount, result, elapsed);
+      }
+    }
+
+    return result;
+  }
+
+  @Override
+  public void waitForOperations() {
+    delegate.waitForOperations();
+  }
+
+  public Set<PartitionRebalanceDetailsImpl> getDetailSet() {
+    return this.detailSet;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02b76886/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/PartitionedRegionLoadModel.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/PartitionedRegionLoadModel.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/PartitionedRegionLoadModel.java
index e024011..1cfa4a4 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/PartitionedRegionLoadModel.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/PartitionedRegionLoadModel.java
@@ -402,6 +402,8 @@ public class PartitionedRegionLoadModel {
         //If the bucket creation failed, we need to undo the changes
         //we made to the model
         attemptedBucketCreations.add(move);
+        //remove the bucket from lowRedundancyBuckets before mutating the state
+        lowRedundancyBuckets.remove(bucket);
         bucket.removeMember(targetMember);
         if(bucket.getRedundancy() < requiredRedundancy) {
           lowRedundancyBuckets.add(bucket);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02b76886/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/control/RebalanceOperationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/control/RebalanceOperationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/control/RebalanceOperationDUnitTest.java
index 6049e14..05febda 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/control/RebalanceOperationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/control/RebalanceOperationDUnitTest.java
@@ -16,6 +16,13 @@
  */
 package com.gemstone.gemfire.internal.cache.control;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -43,7 +50,6 @@ import com.gemstone.gemfire.cache.DiskStoreFactory;
 import com.gemstone.gemfire.cache.EntryEvent;
 import com.gemstone.gemfire.cache.EvictionAction;
 import com.gemstone.gemfire.cache.EvictionAttributes;
-import com.gemstone.gemfire.cache.GemFireCache;
 import com.gemstone.gemfire.cache.LoaderHelper;
 import com.gemstone.gemfire.cache.PartitionAttributes;
 import com.gemstone.gemfire.cache.PartitionAttributesFactory;
@@ -63,11 +69,12 @@ import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.distributed.DistributedSystem;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.internal.cache.BucketRegion;
 import com.gemstone.gemfire.internal.cache.ColocationHelper;
 import com.gemstone.gemfire.internal.cache.DiskStoreImpl;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.cache.InternalCache;
+import com.gemstone.gemfire.internal.cache.PRHARedundancyProvider;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegionDataStore;
 import com.gemstone.gemfire.internal.cache.control.InternalResourceManager.ResourceObserverAdapter;
@@ -972,6 +979,143 @@ public class RebalanceOperationDUnitTest extends CacheTestCase {
     return (DistributedMember) vm.invoke(createPrRegion);
   }
   
+  public void testRecoverRedundancyBalancingIfCreateBucketFails() {
+    Host host = Host.getHost(0);
+    VM vm0 = host.getVM(0);
+    VM vm1 = host.getVM(1);
+    VM vm2 = host.getVM(2);
+    
+
+    final DistributedMember member1 = createPrRegion(vm0, "region1", 100, null);
+    
+    vm0.invoke(new SerializableRunnable("createSomeBuckets") {
+      
+      public void run() {
+        Cache cache = getCache();
+        Region region = cache.getRegion("region1");
+        for(int i = 0; i < 1; i++) {
+          region.put(Integer.valueOf(i), "A");
+        }
+      }
+    });
+    
+    
+    SerializableRunnable checkRedundancy= new SerializableRunnable("checkRedundancy") {
+
+      public void run() {
+        Cache cache = getCache();
+        Region region = cache.getRegion("region1");
+        PartitionRegionInfo details = PartitionRegionHelper.getPartitionRegionInfo(region);
+        assertEquals(1, details.getCreatedBucketCount());
+        assertEquals(0,details.getActualRedundantCopies());
+        assertEquals(1,details.getLowRedundancyBucketCount());
+      }
+    };
+    
+    vm0.invoke(checkRedundancy);
+        
+    //Now create the region in 2 more VMs
+    //Let localMaxMemory(VM1) > localMaxMemory(VM2)
+    //so that redundant bucket will always be attempted on VM1
+    final DistributedMember member2 = createPrRegion(vm1, "region1", 100, null);
+    final DistributedMember member3 = createPrRegion(vm2, "region1", 90, null);
+    
+    vm0.invoke(checkRedundancy);
+    
+    //Inject mock PRHARedundancyProvider to simulate createBucketFailures
+    vm0.invoke(new SerializableRunnable("injectCreateBucketFailureAndRebalance") {
+      
+      @Override
+      public void run() {
+        GemFireCacheImpl cache = spy(getGemfireCache());
+        //set the spied cache instance
+        GemFireCacheImpl origCache = GemFireCacheImpl.setInstanceForTests(cache);
+        
+        PartitionedRegion origRegion = (PartitionedRegion) cache.getRegion("region1");
+        PartitionedRegion spyRegion = spy(origRegion);
+        PRHARedundancyProvider redundancyProvider = spy(new PRHARedundancyProvider(spyRegion));   
+
+        //return the spied region when ever getPartitionedRegions() is invoked
+        Set<PartitionedRegion> parRegions = cache.getPartitionedRegions();
+        parRegions.remove(origRegion);
+        parRegions.add(spyRegion);
+
+        doReturn(parRegions).when(cache).getPartitionedRegions();
+        doReturn(redundancyProvider).when(spyRegion).getRedundancyProvider();
+        
+        //simulate create bucket fails on member2 and test if it creates on member3
+        doReturn(false).when(redundancyProvider).createBackupBucketOnMember(anyInt(), eq((InternalDistributedMember) member2), anyBoolean(), anyBoolean(), any(), anyBoolean());
+
+        //Now simulate a rebalance
+        //Create operationImpl and not factory as we need spied cache to be passed to operationImpl
+        RegionFilter filter = new FilterByPath(null, null);
+        RebalanceOperationImpl operation = new RebalanceOperationImpl(cache, false, filter);
+        operation.start();
+        RebalanceResults results = null;
+        try {
+          results = operation.getResults(MAX_WAIT, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+          Assert.fail("Interrupted waiting on rebalance", e);
+        } catch (TimeoutException e) {
+          Assert.fail("Timeout waiting on rebalance", e);
+        }
+        assertEquals(1, results.getTotalBucketCreatesCompleted());
+        assertEquals(0, results.getTotalPrimaryTransfersCompleted());
+        assertEquals(0, results.getTotalBucketTransferBytes());
+        assertEquals(0, results.getTotalBucketTransfersCompleted());
+        Set<PartitionRebalanceInfo> detailSet = results.getPartitionRebalanceDetails();
+        assertEquals(1, detailSet.size());
+        PartitionRebalanceInfo details = detailSet.iterator().next();
+        assertEquals(1, details.getBucketCreatesCompleted());
+        assertEquals(0, details.getPrimaryTransfersCompleted());
+        assertEquals(0, details.getBucketTransferBytes());
+        assertEquals(0, details.getBucketTransfersCompleted());
+        
+        Set<PartitionMemberInfo> afterDetails = details.getPartitionMemberDetailsAfter();
+        assertEquals(3, afterDetails.size());
+        for(PartitionMemberInfo memberDetails: afterDetails) {
+          if(memberDetails.getDistributedMember().equals(member1)) {
+            assertEquals(1, memberDetails.getBucketCount());
+            assertEquals(1, memberDetails.getPrimaryCount());
+          } else if(memberDetails.getDistributedMember().equals(member2)) {
+            assertEquals(0, memberDetails.getBucketCount());
+            assertEquals(0, memberDetails.getPrimaryCount());
+          } else if(memberDetails.getDistributedMember().equals(member3)) {
+            assertEquals(1, memberDetails.getBucketCount());
+            assertEquals(0, memberDetails.getPrimaryCount());
+          }
+        }
+        
+        ResourceManagerStats stats = cache.getResourceManager().getStats();
+        
+        assertEquals(0, stats.getRebalancesInProgress());
+        assertEquals(1, stats.getRebalancesCompleted());
+        assertEquals(0, stats.getRebalanceBucketCreatesInProgress());
+        assertEquals(results.getTotalBucketCreatesCompleted(), stats.getRebalanceBucketCreatesCompleted());
+        assertEquals(1, stats.getRebalanceBucketCreatesFailed());
+        
+        //set the original cache
+        GemFireCacheImpl.setInstanceForTests(origCache);
+      }
+    });
+    
+    SerializableRunnable checkRedundancyFixed = new SerializableRunnable("checkLowRedundancy") {
+
+      public void run() {
+        Cache cache = getCache();
+        Region region = cache.getRegion("region1");
+        PartitionRegionInfo details = PartitionRegionHelper.getPartitionRegionInfo(region);
+        assertEquals(1, details.getCreatedBucketCount());
+        assertEquals(1,details.getActualRedundantCopies());
+        assertEquals(0,details.getLowRedundancyBucketCount());
+      }
+    };
+
+    vm0.invoke(checkRedundancyFixed);
+    vm1.invoke(checkRedundancyFixed);
+    vm2.invoke(checkRedundancyFixed);
+  }
+  
   public void testRecoverRedundancyColocatedRegionsSimulation() {
     recoverRedundancyColocatedRegions(true);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02b76886/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorImplTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorImplTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorImplTest.java
new file mode 100644
index 0000000..a5c8982
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorImplTest.java
@@ -0,0 +1,138 @@
+/*
+ * 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 com.gemstone.gemfire.internal.cache.partitioned.rebalance;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.control.InternalResourceManager;
+import com.gemstone.gemfire.internal.cache.partitioned.PartitionedRegionRebalanceOp;
+import com.gemstone.gemfire.internal.cache.partitioned.rebalance.BucketOperator.Completion;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class BucketOperatorImplTest {
+
+  private InternalResourceManager.ResourceObserver resourceObserver;
+
+  private BucketOperatorImpl operator;
+
+  private PartitionedRegion region;
+  private PartitionedRegionRebalanceOp rebalanceOp;
+  private Completion completion;
+
+  private Map<String, Long> colocatedRegionBytes = new HashMap<String, Long>();
+  private int bucketId = 1;
+  private InternalDistributedMember sourceMember, targetMember;
+
+  @Before
+  public void setup() throws UnknownHostException {
+    region = mock(PartitionedRegion.class);
+    rebalanceOp = mock(PartitionedRegionRebalanceOp.class);
+    completion = mock(Completion.class);
+    
+    resourceObserver = spy(new InternalResourceManager.ResourceObserverAdapter());
+    InternalResourceManager.setResourceObserver(resourceObserver);
+    
+    doReturn(region).when(rebalanceOp).getLeaderRegion();
+
+    operator = new BucketOperatorImpl(rebalanceOp);
+
+    sourceMember = new InternalDistributedMember(InetAddress.getByName("127.0.0.1"), 1);
+    targetMember = new InternalDistributedMember(InetAddress.getByName("127.0.0.2"), 1);
+  }
+
+  @After
+  public void after() {
+    reset(resourceObserver);
+  }
+
+  @Test
+  public void moveBucketShouldDelegateToParRegRebalanceOpMoveBucketForRegion() throws UnknownHostException {
+    doReturn(true).when(rebalanceOp).moveBucketForRegion(sourceMember, targetMember, bucketId);
+
+    operator.moveBucket(sourceMember, targetMember, bucketId, colocatedRegionBytes);
+
+    verify(resourceObserver, times(1)).movingBucket(region, bucketId, sourceMember, targetMember);
+    verify(rebalanceOp, times(1)).moveBucketForRegion(sourceMember, targetMember, bucketId);
+  }
+
+  @Test
+  public void movePrimaryShouldDelegateToParRegRebalanceOpMovePrimaryBucketForRegion() throws UnknownHostException {
+    doReturn(true).when(rebalanceOp).movePrimaryBucketForRegion(targetMember, bucketId);
+
+    operator.movePrimary(sourceMember, targetMember, bucketId);
+
+    verify(resourceObserver, times(1)).movingPrimary(region, bucketId, sourceMember, targetMember);
+    verify(rebalanceOp, times(1)).movePrimaryBucketForRegion(targetMember, bucketId);
+  }
+
+  @Test
+  public void createBucketShouldDelegateToParRegRebalanceOpCreateRedundantBucketForRegion() throws UnknownHostException {
+    doReturn(true).when(rebalanceOp).createRedundantBucketForRegion(targetMember, bucketId);
+
+    operator.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completion);
+
+    verify(rebalanceOp, times(1)).createRedundantBucketForRegion(targetMember, bucketId);
+  }
+
+  @Test
+  public void createBucketShouldInvokeOnSuccessIfCreateBucketSucceeds() {
+    doReturn(true).when(rebalanceOp).createRedundantBucketForRegion(targetMember, bucketId);
+
+    operator.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completion);
+
+    verify(rebalanceOp, times(1)).createRedundantBucketForRegion(targetMember, bucketId);
+    verify(completion, times(1)).onSuccess();
+  }
+
+  @Test
+  public void createBucketShouldInvokeOnFailureIfCreateBucketFails() {
+    doReturn(false).when(rebalanceOp).createRedundantBucketForRegion(targetMember, bucketId); //return false for create fail
+
+    operator.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completion);
+
+    verify(rebalanceOp, times(1)).createRedundantBucketForRegion(targetMember, bucketId);
+    verify(completion, times(1)).onFailure();
+  }
+
+  @Test
+  public void removeBucketShouldDelegateToParRegRebalanceOpRemoveRedundantBucketForRegion() {
+    doReturn(true).when(rebalanceOp).removeRedundantBucketForRegion(targetMember, bucketId);
+
+    operator.removeBucket(targetMember, bucketId, colocatedRegionBytes);
+
+    verify(rebalanceOp, times(1)).removeRedundantBucketForRegion(targetMember, bucketId);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02b76886/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorWrapperTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorWrapperTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorWrapperTest.java
new file mode 100644
index 0000000..558062b
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/rebalance/BucketOperatorWrapperTest.java
@@ -0,0 +1,323 @@
+/*
+ * 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 com.gemstone.gemfire.internal.cache.partitioned.rebalance;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.spy;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.control.PartitionRebalanceDetailsImpl;
+import com.gemstone.gemfire.internal.cache.control.ResourceManagerStats;
+import com.gemstone.gemfire.internal.cache.partitioned.rebalance.BucketOperator.Completion;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class BucketOperatorWrapperTest {
+  
+  private ResourceManagerStats stats;
+  private PartitionedRegion leaderRegion;
+  private PartitionedRegion colocatedRegion;
+  private Set<PartitionRebalanceDetailsImpl> rebalanceDetails;
+  private BucketOperatorWrapper wrapper;
+  private BucketOperatorImpl delegate;
+  
+  private Map<String, Long> colocatedRegionBytes;
+  private int bucketId = 1;
+  private InternalDistributedMember sourceMember, targetMember;
+  
+  private final static String PR_LEADER_REGION_NAME = "leadregion1";
+  private final static String PR_COLOCATED_REGION_NAME = "coloregion1";
+  
+  @Before
+  public void setUp() throws UnknownHostException {
+    colocatedRegionBytes = new HashMap<String, Long>();
+    colocatedRegionBytes.put(PR_LEADER_REGION_NAME, 100L);
+    colocatedRegionBytes.put(PR_COLOCATED_REGION_NAME, 50L);
+    
+    sourceMember = new InternalDistributedMember(InetAddress.getByName("127.0.0.1"), 1);
+    targetMember = new InternalDistributedMember(InetAddress.getByName("127.0.0.2"), 1);
+
+    stats = mock(ResourceManagerStats.class);
+    doNothing().when(stats).startBucketCreate(anyInt());
+    doNothing().when(stats).endBucketCreate(anyInt(), anyBoolean(), anyLong(), anyLong());
+    
+    leaderRegion = mock(PartitionedRegion.class);
+    doReturn(PR_LEADER_REGION_NAME).when(leaderRegion).getFullPath();
+    colocatedRegion = mock(PartitionedRegion.class);
+    doReturn(PR_COLOCATED_REGION_NAME).when(colocatedRegion).getFullPath();
+    
+    rebalanceDetails = new HashSet<PartitionRebalanceDetailsImpl>();
+    PartitionRebalanceDetailsImpl details = spy(new PartitionRebalanceDetailsImpl(leaderRegion));
+    rebalanceDetails.add(details);
+    
+    delegate = mock(BucketOperatorImpl.class);
+    
+    wrapper = new BucketOperatorWrapper(delegate, rebalanceDetails, stats, leaderRegion);
+  }
+  
+  @Test
+  public void bucketWrapperShouldDelegateCreateBucketToEnclosedOperator() {
+    Completion completionSentToWrapper = mock(Completion.class);
+
+    doNothing().when(delegate).createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
+
+    wrapper.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
+    
+    verify(delegate, times(1)).createRedundantBucket(eq(targetMember), eq(bucketId), eq(colocatedRegionBytes), any(Completion.class));
+  }
+  
+  @Test
+  public void bucketWrapperShouldRecordNumberOfBucketsCreatedIfCreateBucketSucceeds() {
+    doAnswer(new Answer<Object>() {
+      public Object answer(InvocationOnMock invocation) {
+        //3rd argument is Completion object sent to BucketOperatorImpl.createRedundantBucket
+        ((Completion) invocation.getArguments()[3]).onSuccess();
+        return null;
+      }
+    }).when(delegate).createRedundantBucket(eq(targetMember), eq(bucketId), eq(colocatedRegionBytes), any(Completion.class));
+    
+    Completion completionSentToWrapper = mock(Completion.class);
+    wrapper.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
+    
+    //verify create buckets is recorded
+    for( PartitionRebalanceDetailsImpl details : rebalanceDetails) {
+      if(details.getRegionPath().equalsIgnoreCase(PR_LEADER_REGION_NAME))
+        verify(details, times(1)).incCreates(eq(colocatedRegionBytes.get(PR_LEADER_REGION_NAME)), anyLong());
+      else if(details.getRegionPath().equals(PR_COLOCATED_REGION_NAME))
+        verify(details, times(1)).incTransfers(colocatedRegionBytes.get(PR_COLOCATED_REGION_NAME), 0); //elapsed is recorded only if its leader
+    }
+  }
+  
+  @Test
+  public void bucketWrapperShouldNotRecordNumberOfBucketsCreatedIfCreateBucketFails() {
+    doAnswer(new Answer<Object>() {
+      public Object answer(InvocationOnMock invocation) {
+        //3rd argument is Completion object sent to BucketOperatorImpl.createRedundantBucket
+        ((Completion) invocation.getArguments()[3]).onFailure();
+        return null;
+      }
+    }).when(delegate).createRedundantBucket(eq(targetMember), eq(bucketId), eq(colocatedRegionBytes), any(Completion.class));
+    
+    Completion completionSentToWrapper = mock(Completion.class);
+    wrapper.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
+    
+    //verify create buckets is not recorded
+    for( PartitionRebalanceDetailsImpl details : rebalanceDetails) {
+      verify(details, times(0)).incTransfers(anyLong(), anyLong());
+    }
+  }
+  
+  @Test
+  public void bucketWrapperShouldInvokeOnFailureWhenCreateBucketFails() {        
+    doAnswer(new Answer<Object>() {
+      public Object answer(InvocationOnMock invocation) {
+        //3rd argument is Completion object sent to BucketOperatorImpl.createRedundantBucket
+        ((Completion) invocation.getArguments()[3]).onFailure();
+        return null;
+      }
+    }).when(delegate).createRedundantBucket(eq(targetMember), eq(bucketId), eq(colocatedRegionBytes), any(Completion.class));
+    
+    Completion completionSentToWrapper = mock(Completion.class);
+    wrapper.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
+    
+    //verify onFailure is invoked
+    verify(completionSentToWrapper, times(1)).onFailure();
+  }
+  
+  @Test
+  public void bucketWrapperShouldInvokeOnSuccessWhenCreateBucketSucceeds() {       
+    doAnswer(new Answer<Object>() {
+      public Object answer(InvocationOnMock invocation) {
+        //3rd argument is Completion object sent to BucketOperatorImpl.createRedundantBucket
+        ((Completion) invocation.getArguments()[3]).onSuccess();
+        return null;
+      }
+    }).when(delegate).createRedundantBucket(eq(targetMember), eq(bucketId), eq(colocatedRegionBytes), any(Completion.class));
+    
+    Completion completionSentToWrapper = mock(Completion.class);
+    wrapper.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
+    
+    verify(completionSentToWrapper, times(1)).onSuccess();
+  }
+  
+  @Test
+  public void bucketWrapperShouldDelegateMoveBucketToEnclosedOperator() {    
+    doReturn(true).when(delegate).moveBucket(sourceMember, targetMember, bucketId, colocatedRegionBytes);
+
+    wrapper.moveBucket(sourceMember, targetMember, bucketId, colocatedRegionBytes);
+    
+    //verify the delegate is invoked
+    verify(delegate, times(1)).moveBucket(sourceMember, targetMember, bucketId, colocatedRegionBytes);
+    
+    //verify we recorded necessary stats
+    verify(stats, times(1)).startBucketTransfer(anyInt());
+    verify(stats, times(1)).endBucketTransfer(anyInt(), anyBoolean(), anyLong(), anyLong());
+  }
+  
+  @Test
+  public void bucketWrapperShouldRecordBytesTransferredPerRegionAfterMoveBucketIsSuccessful() {    
+    doReturn(true).when(delegate).moveBucket(sourceMember, targetMember, bucketId, colocatedRegionBytes);
+
+    wrapper.moveBucket(sourceMember, targetMember, bucketId, colocatedRegionBytes);
+    
+    //verify the details is updated with bytes transfered
+    for( PartitionRebalanceDetailsImpl details : rebalanceDetails) {
+      if(details.getRegionPath().equalsIgnoreCase(PR_LEADER_REGION_NAME))
+        verify(details, times(1)).incTransfers(eq(colocatedRegionBytes.get(PR_LEADER_REGION_NAME)), anyLong());
+      else if(details.getRegionPath().equals(PR_COLOCATED_REGION_NAME))
+        verify(details, times(1)).incTransfers(colocatedRegionBytes.get(PR_COLOCATED_REGION_NAME), 0); //elapsed is recorded only if its leader
+    }
+    
+    //verify we recorded necessary stats
+    verify(stats, times(1)).startBucketTransfer(anyInt());
+    verify(stats, times(1)).endBucketTransfer(anyInt(), anyBoolean(), anyLong(), anyLong());
+  }
+  
+  @Test
+  public void bucketWrapperShouldDoNotRecordBytesTransferedIfMoveBucketFails() {
+    doReturn(false).when(delegate).moveBucket(sourceMember, targetMember, bucketId, colocatedRegionBytes);
+
+    wrapper.moveBucket(sourceMember, targetMember, bucketId, colocatedRegionBytes);
+    
+    //verify the details is not updated with bytes transfered
+    for( PartitionRebalanceDetailsImpl details : rebalanceDetails) {
+        verify(details, times(0)).incTransfers(anyLong(), anyLong());
+    }
+    
+    //verify we recorded necessary stats
+    verify(stats, times(1)).startBucketTransfer(anyInt());
+    verify(stats, times(1)).endBucketTransfer(anyInt(), anyBoolean(), anyLong(), anyLong());
+  }
+  
+  @Test
+  public void bucketWrapperShouldDelegateRemoveBucketToEnclosedOperator() {    
+    wrapper.removeBucket(targetMember, bucketId, colocatedRegionBytes);
+    
+    //verify the delegate is invoked
+    verify(delegate, times(1)).removeBucket(targetMember, bucketId, colocatedRegionBytes);
+    
+    //verify we recorded necessary stats
+    verify(stats, times(1)).startBucketRemove(anyInt());
+    verify(stats, times(1)).endBucketRemove(anyInt(), anyBoolean(), anyLong(), anyLong());
+  }
+  
+  @Test
+  public void bucketWrapperShouldRecordBucketRemovesPerRegionAfterRemoveBucketIsSuccessful() {    
+    doReturn(true).when(delegate).removeBucket(targetMember, bucketId, colocatedRegionBytes);
+
+    wrapper.removeBucket(targetMember, bucketId, colocatedRegionBytes);
+    
+    //verify the details is updated with bytes transfered
+    for( PartitionRebalanceDetailsImpl details : rebalanceDetails) {
+      if(details.getRegionPath().equalsIgnoreCase(PR_LEADER_REGION_NAME))
+        verify(details, times(1)).incRemoves((eq(colocatedRegionBytes.get(PR_LEADER_REGION_NAME))), anyLong());
+      else if(details.getRegionPath().equals(PR_COLOCATED_REGION_NAME))
+        verify(details, times(1)).incRemoves(colocatedRegionBytes.get(PR_COLOCATED_REGION_NAME), 0); //elapsed is recorded only if its leader
+    }
+    
+    //verify we recorded necessary stats
+    verify(stats, times(1)).startBucketRemove(anyInt());
+    verify(stats, times(1)).endBucketRemove(anyInt(), anyBoolean(), anyLong(), anyLong());
+  }
+  
+  @Test
+  public void bucketWrapperShouldDoNotRecordBucketRemovesIfMoveBucketFails() {
+    doReturn(false).when(delegate).removeBucket(targetMember, bucketId, colocatedRegionBytes);
+
+    wrapper.removeBucket(targetMember, bucketId, colocatedRegionBytes);
+    
+    //verify the details is not updated with bytes transfered
+    for( PartitionRebalanceDetailsImpl details : rebalanceDetails) {
+        verify(details, times(0)).incTransfers(anyLong(), anyLong());
+    }
+    
+    //verify we recorded necessary stats
+    verify(stats, times(1)).startBucketRemove(anyInt());
+    verify(stats, times(1)).endBucketRemove(anyInt(), anyBoolean(), anyLong(), anyLong());
+  }
+  
+  @Test
+  public void bucketWrapperShouldDelegateMovePrimaryToEnclosedOperator() {    
+    wrapper.movePrimary(sourceMember, targetMember, bucketId);
+    
+    //verify the delegate is invoked
+    verify(delegate, times(1)).movePrimary(sourceMember, targetMember, bucketId);
+    
+    //verify we recorded necessary stats
+    verify(stats, times(1)).startPrimaryTransfer(anyInt());
+    verify(stats, times(1)).endPrimaryTransfer(anyInt(), anyBoolean(), anyLong());
+  }
+  
+  @Test
+  public void bucketWrapperShouldRecordPrimaryTransfersPerRegionAfterMovePrimaryIsSuccessful() {    
+    doReturn(true).when(delegate).movePrimary(sourceMember, targetMember, bucketId);
+
+    wrapper.movePrimary(sourceMember, targetMember, bucketId);
+    
+    //verify the details is updated with bytes transfered
+    for( PartitionRebalanceDetailsImpl details : rebalanceDetails) {
+      if(details.getRegionPath().equalsIgnoreCase(PR_LEADER_REGION_NAME))
+        verify(details, times(1)).incPrimaryTransfers(anyLong());
+      else if(details.getRegionPath().equals(PR_COLOCATED_REGION_NAME))
+        verify(details, times(1)).incPrimaryTransfers(0); //elapsed is recorded only if its leader
+    }
+    
+    //verify we recorded necessary stats
+    verify(stats, times(1)).startPrimaryTransfer(anyInt());
+    verify(stats, times(1)).endPrimaryTransfer(anyInt(), anyBoolean(), anyLong());
+  }
+  
+  @Test
+  public void bucketWrapperShouldNotRecordPrimaryTransfersPerRegionAfterMovePrimaryFails() {
+    doReturn(false).when(delegate).movePrimary(sourceMember, targetMember, bucketId);
+
+    wrapper.movePrimary(sourceMember, targetMember, bucketId);
+    
+    //verify the details is not updated with bytes transfered
+    for( PartitionRebalanceDetailsImpl details : rebalanceDetails) {
+        verify(details, times(0)).incTransfers(anyLong(), anyLong());
+    }
+    
+    //verify we recorded necessary stats
+    verify(stats, times(1)).startPrimaryTransfer(anyInt());
+    verify(stats, times(1)).endPrimaryTransfer(anyInt(), anyBoolean(), anyLong());
+  }
+}


[04/36] incubator-geode git commit: GEODE-1260: Cache SCM metadata for source distributions

Posted by hi...@apache.org.
GEODE-1260: Cache SCM metadata for source distributions

The GemFireVersion.properties file is generated by the build and
contains the git branch, commit, and source date. This change
caches the SCM info in the build root (.buildinfo) for use by the
source distribution.

Actually works this time.


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

Branch: refs/heads/feature/GEODE-1372
Commit: 44c2f398ff0a67d3e639c224c7df3ec861fe2c70
Parents: c33de6d
Author: Anthony Baker <ab...@apache.org>
Authored: Wed May 4 15:19:39 2016 -0700
Committer: Anthony Baker <ab...@apache.org>
Committed: Mon May 9 19:48:25 2016 -0700

----------------------------------------------------------------------
 geode-assembly/build.gradle | 12 +++++++
 geode-core/build.gradle     | 68 +++++++++++++++++++++++-----------------
 gradle/rat.gradle           |  1 +
 3 files changed, 52 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44c2f398/geode-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle
index e786b24..ed5154e 100755
--- a/geode-assembly/build.gradle
+++ b/geode-assembly/build.gradle
@@ -227,6 +227,17 @@ task docs(type: Javadoc) {
    }
 }
 
+task writeBuildInfo {
+  def buildInfo = file "$buildDir/.buildinfo"
+  outputs.file buildInfo
+  doLast {
+    buildInfo.getParentFile().mkdirs();
+    new FileOutputStream(buildInfo).withStream { fos ->
+      project(':geode-core').readScmInfo().store(fos, '')
+    }
+  }
+}
+
 gradle.taskGraph.whenReady( { graph ->
   tasks.withType(AbstractArchiveTask).findAll {
     it.name.toLowerCase().contains("dist")
@@ -242,6 +253,7 @@ distributions {
   src {
     baseName = 'apache-geode-src'
     contents {
+      from writeBuildInfo
       from (rootDir) {
         exclude 'KEYS'
         exclude 'gradlew'

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44c2f398/geode-core/build.gradle
----------------------------------------------------------------------
diff --git a/geode-core/build.gradle b/geode-core/build.gradle
index 45051dc..8cd5bf3 100755
--- a/geode-core/build.gradle
+++ b/geode-core/build.gradle
@@ -131,7 +131,40 @@ sourceSets {
     output.dir(generatedResources, builtBy: 'createVersionPropertiesFile')
   }
 }
- 
+
+ext.readScmInfo = {
+  try {
+    def git = org.ajoberstar.grgit.Grgit.open(currentDir: projectDir)
+    try {
+      return [
+        'Source-Repository': git.branch.getCurrent().name,
+        'Source-Revision'  : git.head().id,
+        'Source-Date'      : git.head().getDate().format('yyyy-MM-dd HH:mm:ss Z')
+      ] as Properties
+    } finally {
+      git.close()
+    }
+  } catch (IllegalArgumentException e) {
+    // if we're building from the source distribution, we don't have git so
+    // use cached info written during the assembly process
+    def buildInfo = file "$rootDir/.buildinfo"
+    if (buildInfo.exists()) {
+      def props = new Properties()
+      new FileInputStream(buildInfo).withStream { fis ->
+        props.load(fis)
+      }
+      return props
+    }
+
+    logger.warn( '***** Unable to find Git workspace. Using default version information *****' )
+    return [
+      'Source-Repository': 'UNKNOWN',
+      'Source-Revision'  : 'UNKNOWN',
+      'Source-Date'      : new Date().format('yyyy-MM-dd HH:mm:ss Z')
+    ] as Properties
+  }
+}
+
 // Creates the version properties file and writes it to the classes dir
 task createVersionPropertiesFile {
   def propertiesFile = file(generatedResources + "/com/gemstone/gemfire/internal/GemFireVersion.properties");
@@ -139,38 +172,15 @@ task createVersionPropertiesFile {
   inputs.dir compileJava.destinationDir
 
   doLast {
-
-    try {
-      def grgit = org.ajoberstar.grgit.Grgit.open(currentDir: projectDir)
-      ext.branch = grgit.branch.getCurrent().name
-      ext.commitId = grgit.head().id
-      ext.sourceDate = grgit.head().getDate().format('yyyy-MM-dd HH:mm:ss Z')
-      grgit.close()
-    } catch (Exception e) {
-      logger.warn( '***** Unable to find Git workspace. Using default version information *****' )
-      ext.branch = 'UNKNOWN'
-      ext.commitId = 'UNKNOWN'
-      ext.sourceDate = new Date().format('yyyy-MM-dd HH:mm:ss Z')
-    }
-
-    ext.osArch = System.getProperty('os.arch')
-    ext.osName = System.getProperty('os.name')
-    ext.osVersion = System.getProperty('os.version')
-    ext.buildDate = new Date().format('yyyy-MM-dd HH:mm:ss Z')
-    ext.buildNumber = new Date().format('MMddyy')
-    ext.jdkVersion = System.getProperty('java.version')
-
     def props = [
       "Product-Name"      : "Apache Geode (incubating)",
       "Product-Version"   : version,
-      "Build-Id"          : System.env.USER + ' ' + ext.buildNumber,
-      "Build-Date"        : ext.buildDate,
-      "Build-Platform"    : ext.osName + ' ' + ext.osVersion + ' ' + ext.osArch,
-      "Build-Java-Version": ext.jdkVersion,
-      "Source-Date"       : ext.sourceDate,
-      "Source-Revision"   : ext.commitId,
-      "Source-Repository" : ext.branch
+      "Build-Id"          : "${System.env.USER} ${new Date().format('MMddyy')}".toString(),
+      "Build-Date"        : new Date().format('yyyy-MM-dd HH:mm:ss Z'),
+      "Build-Platform"    : "${System.properties['os.name']} ${System.properties['os.version']} ${System.properties['os.arch']}".toString(),
+      "Build-Java-Version": System.properties['java.version']
     ] as Properties
+    props.putAll(readScmInfo())
 
     propertiesFile.getParentFile().mkdirs();
     new FileOutputStream(propertiesFile).withStream { fos ->

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44c2f398/gradle/rat.gradle
----------------------------------------------------------------------
diff --git a/gradle/rat.gradle b/gradle/rat.gradle
index f35b157..3d0826a 100644
--- a/gradle/rat.gradle
+++ b/gradle/rat.gradle
@@ -37,6 +37,7 @@ rat {
     'native/**',
     'wrapper/**',
     '**/build/**',
+    '.buildinfo',
 
     // SBT
     'geode-spark-connector/**/target/**',


[06/36] incubator-geode git commit: GEODE-11: Adding package level javadocs for lucene

Posted by hi...@apache.org.
GEODE-11: Adding package level javadocs for lucene

Adding package-info.java files to all of the lucene packages. The public
API javadocs provide and overview of the what the lucene package does
and where to start.

The internal javadocs provide an overview of the purpose of each
internal package.


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

Branch: refs/heads/feature/GEODE-1372
Commit: c8ca8a0ed893d19e6da395cb13b72a61532ee555
Parents: f4b0643
Author: Dan Smith <up...@apache.org>
Authored: Mon May 9 18:09:47 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Tue May 10 10:03:49 2016 -0700

----------------------------------------------------------------------
 .../lucene/internal/directory/package-info.java | 23 ++++++++++++++
 .../internal/distributed/package-info.java      | 25 +++++++++++++++
 .../lucene/internal/filesystem/FileSystem.java  | 11 ++++++-
 .../internal/filesystem/package-info.java       | 26 ++++++++++++++++
 .../cache/lucene/internal/package-info.java     | 23 ++++++++++++++
 .../internal/repository/package-info.java       | 25 +++++++++++++++
 .../repository/serializer/package-info.java     | 23 ++++++++++++++
 .../cache/lucene/internal/xml/package-info.java | 24 +++++++++++++++
 .../gemfire/cache/lucene/package-info.java      | 32 ++++++++++++++++++++
 9 files changed, 211 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ca8a0e/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/directory/package-info.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/directory/package-info.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/directory/package-info.java
new file mode 100644
index 0000000..2dd0606
--- /dev/null
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/directory/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * An implementation of Lucene's {@link org.apache.lucene.store.Directory} interface that uses the filesystem
+ * API in {@link com.gemstone.gemfire.cache.lucene.internal.filesystem.FileSystem}
+ */
+package com.gemstone.gemfire.cache.lucene.internal.directory;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ca8a0e/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/package-info.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/package-info.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/package-info.java
new file mode 100644
index 0000000..4079ad4
--- /dev/null
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/distributed/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+/**
+ * Classes used for distributing lucene queries to geode nodes. Contains the lucene related functions
+ * like {@link com.gemstone.gemfire.cache.lucene.internal.distributed.LuceneFunction} as well as objects that are
+ * passed between nodes like {@link com.gemstone.gemfire.cache.lucene.internal.distributed.EntryScore}
+ */
+
+package com.gemstone.gemfire.cache.lucene.internal.distributed;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ca8a0e/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/FileSystem.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/FileSystem.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/FileSystem.java
index 44513f1..fdafcbe 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/FileSystem.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/FileSystem.java
@@ -25,7 +25,7 @@ import java.util.Collection;
 import java.util.concurrent.ConcurrentMap;
 
 /**
- * A Filesystem like interface that stores file data in gemfire regions.
+ * A Filesystem like interface that stores file data in geode regions.
  * 
  * This filesystem is safe for use with multiple threads if the threads are not
  * modifying the same files. A single file is not safe to modify by multiple
@@ -33,6 +33,7 @@ import java.util.concurrent.ConcurrentMap;
  * 
  * Changes to a file may not be visible to other members of the system until the
  * FileOutputStream is closed.
+ *
  */
 public class FileSystem {
   // private final Cache cache;
@@ -41,6 +42,14 @@ public class FileSystem {
   
   static final int CHUNK_SIZE = 1024 * 1024; //1 MB
 
+  /**
+   * Create filesystem that will store data in the two provided regions. The fileRegion contains
+   * metadata about the files, and the chunkRegion contains the actual data. If data from either region is missing
+   * or inconsistent, no guarantees are made about what this class will do, so it's best if these regions are colocated
+   * and in the same disk store to ensure the data remains together.
+   * @param fileRegion the region to store metadata about the files
+   * @param chunkRegion the region to store actual file data.
+   */
   public FileSystem(ConcurrentMap<String, File> fileRegion, ConcurrentMap<ChunkKey, byte[]> chunkRegion) {
     super();
     this.fileRegion = fileRegion;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ca8a0e/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/package-info.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/package-info.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/package-info.java
new file mode 100644
index 0000000..f8b612c
--- /dev/null
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+/**
+ * A distributed filesystem implementation that uses a geode region as the underlying storage mechanism.
+ *
+ * Users of this filesystem should interact with the {@link com.gemstone.gemfire.cache.lucene.internal.filesystem.FileSystem} class.
+ *
+ */
+
+package com.gemstone.gemfire.cache.lucene.internal.filesystem;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ca8a0e/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/package-info.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/package-info.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/package-info.java
new file mode 100644
index 0000000..22670f3
--- /dev/null
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * Internal lucene classes, not intended to be used directly.
+ */
+
+package com.gemstone.gemfire.cache.lucene.internal;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ca8a0e/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/package-info.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/package-info.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/package-info.java
new file mode 100644
index 0000000..894b464
--- /dev/null
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * The repository package contains classes for managing a Lucene index in geode.
+ *
+ * All lucene index access should be through the {@link com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository}
+ * class.
+ */
+package com.gemstone.gemfire.cache.lucene.internal.repository;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ca8a0e/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/serializer/package-info.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/serializer/package-info.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/serializer/package-info.java
new file mode 100644
index 0000000..dca7737
--- /dev/null
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/repository/serializer/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * Classes for converting gemfire objects into lucene documents.
+ */
+
+package com.gemstone.gemfire.cache.lucene.internal.repository.serializer;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ca8a0e/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/xml/package-info.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/xml/package-info.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/xml/package-info.java
new file mode 100644
index 0000000..4eb1ca3
--- /dev/null
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/xml/package-info.java
@@ -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.
+ */
+/**
+ * Classes for parsing lucene index elements a cache.xml file. See the lucene-1.0.xsd file for
+ * the schema.
+ */
+
+package com.gemstone.gemfire.cache.lucene.internal.xml;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ca8a0e/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/package-info.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/package-info.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/package-info.java
new file mode 100644
index 0000000..0e0c89b
--- /dev/null
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/package-info.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+/**
+ * This package provides an integration with Apache Lucene that allows Geode regions to be indexed in a distributed
+ * Lucene index and queries using Lucene queries.
+ * <p>
+ * All indexing and query operations are performed through the {@link com.gemstone.gemfire.cache.lucene.LuceneService} class.
+ * See {@link com.gemstone.gemfire.cache.lucene.LuceneService} for an example of how to add a lucene index to a geode region.
+ * <p>
+ *
+ * The Lucene indexes created using this API are stored in geode and colocated with the indexed region, which means they
+ * have the same availability guarantees as the underlying region. The indexes are maintained asynchronously, so changes
+ * to the region may not be immediately visible in the lucene index.
+ */
+
+package com.gemstone.gemfire.cache.lucene;
\ No newline at end of file


[23/36] incubator-geode git commit: GEODE-951: repackage GemFireParameterizedMessage and its factory

Posted by hi...@apache.org.
GEODE-951: repackage GemFireParameterizedMessage and its factory

* move to package com.gemstone.gemfire.internal.logging.log4j.message
* add javadocs about original source of these classes
* add comments pointing out Geode optimizations in these classes


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

Branch: refs/heads/feature/GEODE-1372
Commit: 96c67d4af01277b2d782cb0a5d52159e146b0d63
Parents: aaaa89b
Author: Kirk Lund <kl...@apache.org>
Authored: Wed May 11 14:37:56 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Wed May 11 14:37:56 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/logging/LogService.java    |   2 +-
 .../internal/logging/log4j/LogWriterLogger.java |   2 +-
 .../message/GemFireParameterizedMessage.java    | 556 +++++++++++++++++++
 .../GemFireParameterizedMessageFactory.java     |  56 ++
 .../message/GemFireParameterizedMessage.java    | 554 ------------------
 .../GemFireParameterizedMessageFactory.java     |  54 --
 .../gemfire/codeAnalysis/excludedClasses.txt    |   2 +
 .../codeAnalysis/sanctionedSerializables.txt    |   3 -
 8 files changed, 616 insertions(+), 613 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/96c67d4a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
index 5572d11..3aa7734 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
@@ -35,7 +35,7 @@ import com.gemstone.gemfire.internal.logging.log4j.ConfigLocator;
 import com.gemstone.gemfire.internal.logging.log4j.Configurator;
 import com.gemstone.gemfire.internal.logging.log4j.FastLogger;
 import com.gemstone.gemfire.internal.logging.log4j.LogWriterLogger;
-import com.gemstone.org.apache.logging.log4j.message.GemFireParameterizedMessageFactory;
+import com.gemstone.gemfire.internal.logging.log4j.message.GemFireParameterizedMessageFactory;
 
 /**
  * Centralizes log configuration and initialization.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/96c67d4a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLogger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLogger.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLogger.java
index f1e314a..dc36f95 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLogger.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLogger.java
@@ -32,7 +32,7 @@ import com.gemstone.gemfire.i18n.StringId;
 import com.gemstone.gemfire.internal.logging.GemFireHandler;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.org.apache.logging.log4j.message.GemFireParameterizedMessageFactory;
+import com.gemstone.gemfire.internal.logging.log4j.message.GemFireParameterizedMessageFactory;
 
 /**
  * Implements GemFireLogger with custom levels while also bridging LogWriter 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/96c67d4a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/message/GemFireParameterizedMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/message/GemFireParameterizedMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/message/GemFireParameterizedMessage.java
new file mode 100755
index 0000000..641645b
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/message/GemFireParameterizedMessage.java
@@ -0,0 +1,556 @@
+/*
+ * 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 com.gemstone.gemfire.internal.logging.log4j.message;
+
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.logging.log4j.message.Message;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.internal.cache.EntriesSet;
+
+/**
+ * Handles messages that consist of a format string containing '{}' to represent each replaceable token, and
+ * the parameters.
+ * <p/>
+ * This class was originally written for <a href="http://lilithapp.com/">Lilith</a> by Joern Huxhorn where it is
+ * licensed under the LGPL. It has been relicensed here with his permission providing that this attribution remain.
+ * <p/>
+ * Copied into Geode from org.apache.logging.log4j.message.ParameterizedMessage (http://logging.apache.org/log4j/2.x/license.html)
+ * <p/>
+ * Geode changes include changing class name and package. Additional changes are commented with "// GEODE: note"
+ */
+public class GemFireParameterizedMessage implements Message {
+
+  /**
+   * Prefix for recursion.
+   */
+  public static final String RECURSION_PREFIX = "[...";
+  /**
+   * Suffix for recursion.
+   */
+  public static final String RECURSION_SUFFIX = "...]";
+
+  /**
+   * Prefix for errors.
+   */
+  public static final String ERROR_PREFIX = "[!!!";
+  /**
+   * Separator for errors.
+   */
+  public static final String ERROR_SEPARATOR = "=>";
+  /**
+   * Separator for error messages.
+   */
+  public static final String ERROR_MSG_SEPARATOR = ":";
+  /**
+   * Suffix for errors.
+   */
+  public static final String ERROR_SUFFIX = "!!!]";
+
+  private static final long serialVersionUID = -665975803997290697L;
+
+  private static final int HASHVAL = 31;
+
+  private static final char DELIM_START = '{';
+  private static final char DELIM_STOP = '}';
+  private static final char ESCAPE_CHAR = '\\';
+
+  private final String messagePattern;
+  private final String[] stringArgs;
+  private transient Object[] argArray;
+  private transient String formattedMessage;
+  private transient Throwable throwable;
+
+  /**
+   * Creates a parameterized message.
+   * @param messagePattern The message "format" string. This will be a String containing "{}" placeholders
+   * where parameters should be substituted.
+   * @param stringArgs The arguments for substitution.
+   * @param throwable A Throwable.
+   */
+  public GemFireParameterizedMessage(final String messagePattern, final String[] stringArgs, final Throwable throwable) {
+      this.messagePattern = messagePattern;
+      this.stringArgs = stringArgs;
+      this.throwable = throwable;
+  }
+
+  /**
+   * Creates a parameterized message.
+   * @param messagePattern The message "format" string. This will be a String containing "{}" placeholders
+   * where parameters should be substituted.
+   * @param objectArgs The arguments for substitution.
+   * @param throwable A Throwable.
+   */
+  public GemFireParameterizedMessage(final String messagePattern, final Object[] objectArgs, final Throwable throwable) {
+      this.messagePattern = messagePattern;
+      this.throwable = throwable;
+      this.stringArgs = parseArguments(objectArgs);
+  }
+
+  /**
+   * Constructs a ParameterizedMessage which contains the arguments converted to String as well as an optional
+   * Throwable.
+   *
+   * <p>If the last argument is a Throwable and is NOT used up by a placeholder in the message pattern it is returned
+   * in {@link #getThrowable()} and won't be contained in the created String[].
+   * If it is used up {@link #getThrowable()} will return null even if the last argument was a Throwable!</p>
+   *
+   * @param messagePattern the message pattern that to be checked for placeholders.
+   * @param arguments      the argument array to be converted.
+   */
+  public GemFireParameterizedMessage(final String messagePattern, final Object[] arguments) {
+      this.messagePattern = messagePattern;
+      this.stringArgs = parseArguments(arguments);
+  }
+
+  /**
+   * Constructor with a pattern and a single parameter.
+   * @param messagePattern The message pattern.
+   * @param arg The parameter.
+   */
+  public GemFireParameterizedMessage(final String messagePattern, final Object arg) {
+      this(messagePattern, new Object[]{arg});
+  }
+
+  /**
+   * Constructor with a pattern and two parameters.
+   * @param messagePattern The message pattern.
+   * @param arg1 The first parameter.
+   * @param arg2 The second parameter.
+   */
+  public GemFireParameterizedMessage(final String messagePattern, final Object arg1, final Object arg2) {
+      this(messagePattern, new Object[]{arg1, arg2});
+  }
+
+  private String[] parseArguments(final Object[] arguments) {
+      if (arguments == null) {
+          return null;
+      }
+      final int argsCount = countArgumentPlaceholders(messagePattern);
+      int resultArgCount = arguments.length;
+      if (argsCount < arguments.length && throwable == null && arguments[arguments.length - 1] instanceof Throwable) {
+          throwable = (Throwable) arguments[arguments.length - 1];
+          resultArgCount--;
+      }
+      argArray = new Object[resultArgCount];
+      System.arraycopy(arguments, 0, argArray, 0, resultArgCount);
+
+      String[] strArgs;
+      if (argsCount == 1 && throwable == null && arguments.length > 1) {
+          // special case
+          strArgs = new String[1];
+          strArgs[0] = deepToString(arguments);
+      } else {
+          strArgs = new String[resultArgCount];
+          for (int i = 0; i < strArgs.length; i++) {
+              strArgs[i] = deepToString(arguments[i]);
+          }
+      }
+      return strArgs;
+  }
+
+  /**
+   * Returns the formatted message.
+   * @return the formatted message.
+   */
+  @Override
+  public String getFormattedMessage() {
+      if (formattedMessage == null) {
+          formattedMessage = formatMessage(messagePattern, stringArgs);
+      }
+      return formattedMessage;
+  }
+
+  /**
+   * Returns the message pattern.
+   * @return the message pattern.
+   */
+  @Override
+  public String getFormat() {
+      return messagePattern;
+  }
+
+  /**
+   * Returns the message parameters.
+   * @return the message parameters.
+   */
+  @Override
+  public Object[] getParameters() {
+      if (argArray != null) {
+          return argArray;
+      }
+      return stringArgs;
+  }
+
+  /**
+   * Returns the Throwable that was given as the last argument, if any.
+   * It will not survive serialization. The Throwable exists as part of the message
+   * primarily so that it can be extracted from the end of the list of parameters
+   * and then be added to the LogEvent. As such, the Throwable in the event should
+   * not be used once the LogEvent has been constructed.
+   *
+   * @return the Throwable, if any.
+   */
+  @Override
+  public Throwable getThrowable() {
+      return throwable;
+  }
+
+  protected String formatMessage(final String msgPattern, final String[] sArgs) {
+      return format(msgPattern, sArgs);
+  }
+
+  @Override
+  public boolean equals(final Object o) {
+      if (this == o) {
+          return true;
+      }
+      if (o == null || getClass() != o.getClass()) {
+          return false;
+      }
+
+      final GemFireParameterizedMessage that = (GemFireParameterizedMessage) o;
+
+      if (messagePattern != null ? !messagePattern.equals(that.messagePattern) : that.messagePattern != null) {
+          return false;
+      }
+      if (!Arrays.equals(stringArgs, that.stringArgs)) {
+          return false;
+      }
+      //if (throwable != null ? !throwable.equals(that.throwable) : that.throwable != null) return false;
+
+      return true;
+  }
+
+  @Override
+  public int hashCode() {
+      int result = messagePattern != null ? messagePattern.hashCode() : 0;
+      result = HASHVAL * result + (stringArgs != null ? Arrays.hashCode(stringArgs) : 0);
+      return result;
+  }
+
+  /**
+   * Replace placeholders in the given messagePattern with arguments.
+   *
+   * @param messagePattern the message pattern containing placeholders.
+   * @param arguments      the arguments to be used to replace placeholders.
+   * @return the formatted message.
+   */
+  public static String format(final String messagePattern, final Object[] arguments) {
+      if (messagePattern == null || arguments == null || arguments.length == 0) {
+          return messagePattern;
+      }
+
+      final StringBuilder result = new StringBuilder();
+      int escapeCounter = 0;
+      int currentArgument = 0;
+      for (int i = 0; i < messagePattern.length(); i++) {
+          final char curChar = messagePattern.charAt(i);
+          if (curChar == ESCAPE_CHAR) {
+              escapeCounter++;
+          } else {
+              if (curChar == DELIM_START && i < messagePattern.length() - 1
+                      && messagePattern.charAt(i + 1) == DELIM_STOP) {
+                  // write escaped escape chars
+                  final int escapedEscapes = escapeCounter / 2;
+                  for (int j = 0; j < escapedEscapes; j++) {
+                      result.append(ESCAPE_CHAR);
+                  }
+
+                  if (escapeCounter % 2 == 1) {
+                      // i.e. escaped
+                      // write escaped escape chars
+                      result.append(DELIM_START);
+                      result.append(DELIM_STOP);
+                  } else {
+                      // unescaped
+                      if (currentArgument < arguments.length) {
+                          result.append(arguments[currentArgument]);
+                      } else {
+                          result.append(DELIM_START).append(DELIM_STOP);
+                      }
+                      currentArgument++;
+                  }
+                  i++;
+                  escapeCounter = 0;
+                  continue;
+              }
+              // any other char beside ESCAPE or DELIM_START/STOP-combo
+              // write unescaped escape chars
+              if (escapeCounter > 0) {
+                  for (int j = 0; j < escapeCounter; j++) {
+                      result.append(ESCAPE_CHAR);
+                  }
+                  escapeCounter = 0;
+              }
+              result.append(curChar);
+          }
+      }
+      return result.toString();
+  }
+
+  /**
+   * Counts the number of unescaped placeholders in the given messagePattern.
+   *
+   * @param messagePattern the message pattern to be analyzed.
+   * @return the number of unescaped placeholders.
+   */
+  public static int countArgumentPlaceholders(final String messagePattern) {
+      if (messagePattern == null) {
+          return 0;
+      }
+
+      final int delim = messagePattern.indexOf(DELIM_START);
+
+      if (delim == -1) {
+          // special case, no placeholders at all.
+          return 0;
+      }
+      int result = 0;
+      boolean isEscaped = false;
+      for (int i = 0; i < messagePattern.length(); i++) {
+          final char curChar = messagePattern.charAt(i);
+          if (curChar == ESCAPE_CHAR) {
+              isEscaped = !isEscaped;
+          } else if (curChar == DELIM_START) {
+              if (!isEscaped && i < messagePattern.length() - 1 && messagePattern.charAt(i + 1) == DELIM_STOP) {
+                  result++;
+                  i++;
+              }
+              isEscaped = false;
+          } else {
+              isEscaped = false;
+          }
+      }
+      return result;
+  }
+
+  /**
+   * This method performs a deep toString of the given Object.
+   * Primitive arrays are converted using their respective Arrays.toString methods while
+   * special handling is implemented for "container types", i.e. Object[], Map and Collection because those could
+   * contain themselves.
+   * <p>
+   * It should be noted that neither AbstractMap.toString() nor AbstractCollection.toString() implement such a
+   * behavior. They only check if the container is directly contained in itself, but not if a contained container
+   * contains the original one. Because of that, Arrays.toString(Object[]) isn't safe either.
+   * Confusing? Just read the last paragraph again and check the respective toString() implementation.
+   * </p>
+   * <p>
+   * This means, in effect, that logging would produce a usable output even if an ordinary System.out.println(o)
+   * would produce a relatively hard-to-debug StackOverflowError.
+   * </p>
+   * @param o The object.
+   * @return The String representation.
+   */
+  public static String deepToString(final Object o) {
+      if (o == null) {
+          return null;
+      }
+      if (o instanceof String) {
+          return (String) o;
+      }
+      final StringBuilder str = new StringBuilder();
+      final Set<String> dejaVu = new HashSet<String>(); // that's actually a neat name ;)
+      recursiveDeepToString(o, str, dejaVu);
+      return str.toString();
+  }
+
+  /**
+   * This method performs a deep toString of the given Object.
+   * Primitive arrays are converted using their respective Arrays.toString methods while
+   * special handling is implemented for "container types", i.e. Object[], Map and Collection because those could
+   * contain themselves.
+   * <p>
+   * dejaVu is used in case of those container types to prevent an endless recursion.
+   * </p>
+   * <p>
+   * It should be noted that neither AbstractMap.toString() nor AbstractCollection.toString() implement such a
+   * behavior.
+   * They only check if the container is directly contained in itself, but not if a contained container contains the
+   * original one. Because of that, Arrays.toString(Object[]) isn't safe either.
+   * Confusing? Just read the last paragraph again and check the respective toString() implementation.
+   * </p>
+   * <p>
+   * This means, in effect, that logging would produce a usable output even if an ordinary System.out.println(o)
+   * would produce a relatively hard-to-debug StackOverflowError.
+   * </p>
+   *
+   * @param o      the Object to convert into a String
+   * @param str    the StringBuilder that o will be appended to
+   * @param dejaVu a list of container identities that were already used.
+   */
+  private static void recursiveDeepToString(final Object o, final StringBuilder str, final Set<String> dejaVu) {
+      if (o == null) {
+          str.append("null");
+          return;
+      }
+      if (o instanceof String) {
+          str.append(o);
+          return;
+      }
+
+      final Class<?> oClass = o.getClass();
+      if (oClass.isArray()) {
+          if (oClass == byte[].class) {
+              str.append(Arrays.toString((byte[]) o));
+          } else if (oClass == short[].class) {
+              str.append(Arrays.toString((short[]) o));
+          } else if (oClass == int[].class) {
+              str.append(Arrays.toString((int[]) o));
+          } else if (oClass == long[].class) {
+              str.append(Arrays.toString((long[]) o));
+          } else if (oClass == float[].class) {
+              str.append(Arrays.toString((float[]) o));
+          } else if (oClass == double[].class) {
+              str.append(Arrays.toString((double[]) o));
+          } else if (oClass == boolean[].class) {
+              str.append(Arrays.toString((boolean[]) o));
+          } else if (oClass == char[].class) {
+              str.append(Arrays.toString((char[]) o));
+          } else {
+              // special handling of container Object[]
+              final String id = identityToString(o);
+              if (dejaVu.contains(id)) {
+                  str.append(RECURSION_PREFIX).append(id).append(RECURSION_SUFFIX);
+              } else {
+                  dejaVu.add(id);
+                  final Object[] oArray = (Object[]) o;
+                  str.append('[');
+                  boolean first = true;
+                  for (final Object current : oArray) {
+                      if (first) {
+                          first = false;
+                      } else {
+                          str.append(", ");
+                      }
+                      recursiveDeepToString(current, str, new HashSet<String>(dejaVu));
+                  }
+                  str.append(']');
+              }
+              //str.append(Arrays.deepToString((Object[]) o));
+          }
+      } else if (o instanceof Map && !(o instanceof Region)) { // GEODE: do NOT use Map handling if instanceof Geode Region
+          // special handling of container Map
+          final String id = identityToString(o);
+          if (dejaVu.contains(id)) {
+              str.append(RECURSION_PREFIX).append(id).append(RECURSION_SUFFIX);
+          } else {
+              dejaVu.add(id);
+              final Map<?, ?> oMap = (Map<?, ?>) o;
+              str.append('{');
+              boolean isFirst = true;
+              for (final Object o1 : oMap.entrySet()) {
+                  final Map.Entry<?, ?> current = (Map.Entry<?, ?>) o1;
+                  if (isFirst) {
+                      isFirst = false;
+                  } else {
+                      str.append(", ");
+                  }
+                  final Object key = current.getKey();
+                  final Object value = current.getValue();
+                  recursiveDeepToString(key, str, new HashSet<String>(dejaVu));
+                  str.append('=');
+                  recursiveDeepToString(value, str, new HashSet<String>(dejaVu));
+              }
+              str.append('}');
+          }
+      } else if (o instanceof Collection && !(o instanceof EntriesSet)) { // GEODE: do NOT use Colleciton handling if instanceof Geode EntriesSet
+          // special handling of container Collection
+          final String id = identityToString(o);
+          if (dejaVu.contains(id)) {
+              str.append(RECURSION_PREFIX).append(id).append(RECURSION_SUFFIX);
+          } else {
+              dejaVu.add(id);
+              final Collection<?> oCol = (Collection<?>) o;
+              str.append('[');
+              boolean isFirst = true;
+              for (final Object anOCol : oCol) {
+                  if (isFirst) {
+                      isFirst = false;
+                  } else {
+                      str.append(", ");
+                  }
+                  recursiveDeepToString(anOCol, str, new HashSet<String>(dejaVu));
+              }
+              str.append(']');
+          }
+      } else if (o instanceof Date) {
+          final Date date = (Date) o;
+          final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+          // I'll leave it like this for the moment... this could probably be optimized using ThreadLocal...
+          str.append(format.format(date));
+      } else {
+          // it's just some other Object, we can only use toString().
+          try {
+              str.append(o.toString());
+          } catch (final Throwable t) {
+              str.append(ERROR_PREFIX);
+              str.append(identityToString(o));
+              str.append(ERROR_SEPARATOR);
+              final String msg = t.getMessage();
+              final String className = t.getClass().getName();
+              str.append(className);
+              if (!className.equals(msg)) {
+                  str.append(ERROR_MSG_SEPARATOR);
+                  str.append(msg);
+              }
+              str.append(ERROR_SUFFIX);
+          }
+      }
+  }
+
+  /**
+   * This method returns the same as if Object.toString() would not have been
+   * overridden in obj.
+   * <p>
+   * Note that this isn't 100% secure as collisions can always happen with hash codes.
+   * </p>
+   * <p>
+   * Copied from Object.hashCode():
+   * </p>
+   * <blockquote>
+   * As much as is reasonably practical, the hashCode method defined by
+   * class {@code Object} does return distinct integers for distinct
+   * objects. (This is typically implemented by converting the internal
+   * address of the object into an integer, but this implementation
+   * technique is not required by the Java&#8482; programming language.)
+   * </blockquote>
+   *
+   * @param obj the Object that is to be converted into an identity string.
+   * @return the identity string as also defined in Object.toString()
+   */
+  public static String identityToString(final Object obj) {
+      if (obj == null) {
+          return null;
+      }
+      return obj.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(obj));
+  }
+
+  @Override
+  public String toString() {
+      return "GemFireParameterizedMessage[messagePattern=" + messagePattern + ", stringArgs=" +
+          Arrays.toString(stringArgs) + ", throwable=" + throwable + ']'; // GEODE: adjust toString to GemFireParameterizedMessage
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/96c67d4a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/message/GemFireParameterizedMessageFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/message/GemFireParameterizedMessageFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/message/GemFireParameterizedMessageFactory.java
new file mode 100755
index 0000000..3756da7
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/message/GemFireParameterizedMessageFactory.java
@@ -0,0 +1,56 @@
+/*
+ * 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 com.gemstone.gemfire.internal.logging.log4j.message;
+
+import org.apache.logging.log4j.message.AbstractMessageFactory;
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.MessageFactory;
+import org.apache.logging.log4j.message.ParameterizedMessage;
+
+/**
+ * Enables use of <code>{}</code> parameter markers in message strings.
+ * <p/>
+ * Creates {@link ParameterizedMessage} instances for {@link #newMessage(String, Object...)}.
+ * <p/>
+ * This class is immutable.
+ * <p/>
+ * Copied into Geode from org.apache.logging.log4j.message.ParameterizedMessageFactory (http://logging.apache.org/log4j/2.x/license.html)
+ * <p/>
+ * Geode changes include changing class name and package. Additional changes are commented with "// GEODE: note"
+ */
+public final class GemFireParameterizedMessageFactory extends AbstractMessageFactory {
+
+    private static final long serialVersionUID = 1L;
+    
+    /**
+     * Instance of StringFormatterMessageFactory.
+     */
+    public static final GemFireParameterizedMessageFactory INSTANCE = new GemFireParameterizedMessageFactory();
+
+    /**
+     * Creates {@link ParameterizedMessage} instances.
+     * @param message The message pattern.
+     * @param params The message parameters.
+     * @return The Message.
+     *
+     * @see MessageFactory#newMessage(String, Object...)
+     */
+    @Override
+    public Message newMessage(final String message, final Object... params) {
+        return new GemFireParameterizedMessage(message, params); // GEODE: change to construct GemFireParameterizedMessage
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/96c67d4a/geode-core/src/main/java/com/gemstone/org/apache/logging/log4j/message/GemFireParameterizedMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/org/apache/logging/log4j/message/GemFireParameterizedMessage.java b/geode-core/src/main/java/com/gemstone/org/apache/logging/log4j/message/GemFireParameterizedMessage.java
deleted file mode 100755
index d638a8c..0000000
--- a/geode-core/src/main/java/com/gemstone/org/apache/logging/log4j/message/GemFireParameterizedMessage.java
+++ /dev/null
@@ -1,554 +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 com.gemstone.org.apache.logging.log4j.message;
-
-
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.logging.log4j.message.Message;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.cache.EntriesSet;
-
-/**
- * Handles messages that consist of a format string containing '{}' to represent each replaceable token, and
- * the parameters.
- * <p>
- * This class was originally written for <a href="http://lilithapp.com/">Lilith</a> by Joern Huxhorn where it is
- * licensed under the LGPL. It has been relicensed here with his permission providing that this attribution remain.
- * </p>
- */
-public class GemFireParameterizedMessage implements Message {
-
-  /**
-   * Prefix for recursion.
-   */
-  public static final String RECURSION_PREFIX = "[...";
-  /**
-   * Suffix for recursion.
-   */
-  public static final String RECURSION_SUFFIX = "...]";
-
-  /**
-   * Prefix for errors.
-   */
-  public static final String ERROR_PREFIX = "[!!!";
-  /**
-   * Separator for errors.
-   */
-  public static final String ERROR_SEPARATOR = "=>";
-  /**
-   * Separator for error messages.
-   */
-  public static final String ERROR_MSG_SEPARATOR = ":";
-  /**
-   * Suffix for errors.
-   */
-  public static final String ERROR_SUFFIX = "!!!]";
-
-  private static final long serialVersionUID = -665975803997290697L;
-
-  private static final int HASHVAL = 31;
-
-  private static final char DELIM_START = '{';
-  private static final char DELIM_STOP = '}';
-  private static final char ESCAPE_CHAR = '\\';
-
-  private final String messagePattern;
-  private final String[] stringArgs;
-  private transient Object[] argArray;
-  private transient String formattedMessage;
-  private transient Throwable throwable;
-
-  /**
-   * Creates a parameterized message.
-   * @param messagePattern The message "format" string. This will be a String containing "{}" placeholders
-   * where parameters should be substituted.
-   * @param stringArgs The arguments for substitution.
-   * @param throwable A Throwable.
-   */
-  public GemFireParameterizedMessage(final String messagePattern, final String[] stringArgs, final Throwable throwable) {
-      this.messagePattern = messagePattern;
-      this.stringArgs = stringArgs;
-      this.throwable = throwable;
-  }
-
-  /**
-   * Creates a parameterized message.
-   * @param messagePattern The message "format" string. This will be a String containing "{}" placeholders
-   * where parameters should be substituted.
-   * @param objectArgs The arguments for substitution.
-   * @param throwable A Throwable.
-   */
-  public GemFireParameterizedMessage(final String messagePattern, final Object[] objectArgs, final Throwable throwable) {
-      this.messagePattern = messagePattern;
-      this.throwable = throwable;
-      this.stringArgs = parseArguments(objectArgs);
-  }
-
-  /**
-   * Constructs a ParameterizedMessage which contains the arguments converted to String as well as an optional
-   * Throwable.
-   *
-   * <p>If the last argument is a Throwable and is NOT used up by a placeholder in the message pattern it is returned
-   * in {@link #getThrowable()} and won't be contained in the created String[].
-   * If it is used up {@link #getThrowable()} will return null even if the last argument was a Throwable!</p>
-   *
-   * @param messagePattern the message pattern that to be checked for placeholders.
-   * @param arguments      the argument array to be converted.
-   */
-  public GemFireParameterizedMessage(final String messagePattern, final Object[] arguments) {
-      this.messagePattern = messagePattern;
-      this.stringArgs = parseArguments(arguments);
-  }
-
-  /**
-   * Constructor with a pattern and a single parameter.
-   * @param messagePattern The message pattern.
-   * @param arg The parameter.
-   */
-  public GemFireParameterizedMessage(final String messagePattern, final Object arg) {
-      this(messagePattern, new Object[]{arg});
-  }
-
-  /**
-   * Constructor with a pattern and two parameters.
-   * @param messagePattern The message pattern.
-   * @param arg1 The first parameter.
-   * @param arg2 The second parameter.
-   */
-  public GemFireParameterizedMessage(final String messagePattern, final Object arg1, final Object arg2) {
-      this(messagePattern, new Object[]{arg1, arg2});
-  }
-
-  private String[] parseArguments(final Object[] arguments) {
-      if (arguments == null) {
-          return null;
-      }
-      final int argsCount = countArgumentPlaceholders(messagePattern);
-      int resultArgCount = arguments.length;
-      if (argsCount < arguments.length && throwable == null && arguments[arguments.length - 1] instanceof Throwable) {
-          throwable = (Throwable) arguments[arguments.length - 1];
-          resultArgCount--;
-      }
-      argArray = new Object[resultArgCount];
-      System.arraycopy(arguments, 0, argArray, 0, resultArgCount);
-
-      String[] strArgs;
-      if (argsCount == 1 && throwable == null && arguments.length > 1) {
-          // special case
-          strArgs = new String[1];
-          strArgs[0] = deepToString(arguments);
-      } else {
-          strArgs = new String[resultArgCount];
-          for (int i = 0; i < strArgs.length; i++) {
-              strArgs[i] = deepToString(arguments[i]);
-          }
-      }
-      return strArgs;
-  }
-
-  /**
-   * Returns the formatted message.
-   * @return the formatted message.
-   */
-  @Override
-  public String getFormattedMessage() {
-      if (formattedMessage == null) {
-          formattedMessage = formatMessage(messagePattern, stringArgs);
-      }
-      return formattedMessage;
-  }
-
-  /**
-   * Returns the message pattern.
-   * @return the message pattern.
-   */
-  @Override
-  public String getFormat() {
-      return messagePattern;
-  }
-
-  /**
-   * Returns the message parameters.
-   * @return the message parameters.
-   */
-  @Override
-  public Object[] getParameters() {
-      if (argArray != null) {
-          return argArray;
-      }
-      return stringArgs;
-  }
-
-  /**
-   * Returns the Throwable that was given as the last argument, if any.
-   * It will not survive serialization. The Throwable exists as part of the message
-   * primarily so that it can be extracted from the end of the list of parameters
-   * and then be added to the LogEvent. As such, the Throwable in the event should
-   * not be used once the LogEvent has been constructed.
-   *
-   * @return the Throwable, if any.
-   */
-  @Override
-  public Throwable getThrowable() {
-      return throwable;
-  }
-
-  protected String formatMessage(final String msgPattern, final String[] sArgs) {
-      return format(msgPattern, sArgs);
-  }
-
-  @Override
-  public boolean equals(final Object o) {
-      if (this == o) {
-          return true;
-      }
-      if (o == null || getClass() != o.getClass()) {
-          return false;
-      }
-
-      final GemFireParameterizedMessage that = (GemFireParameterizedMessage) o;
-
-      if (messagePattern != null ? !messagePattern.equals(that.messagePattern) : that.messagePattern != null) {
-          return false;
-      }
-      if (!Arrays.equals(stringArgs, that.stringArgs)) {
-          return false;
-      }
-      //if (throwable != null ? !throwable.equals(that.throwable) : that.throwable != null) return false;
-
-      return true;
-  }
-
-  @Override
-  public int hashCode() {
-      int result = messagePattern != null ? messagePattern.hashCode() : 0;
-      result = HASHVAL * result + (stringArgs != null ? Arrays.hashCode(stringArgs) : 0);
-      return result;
-  }
-
-  /**
-   * Replace placeholders in the given messagePattern with arguments.
-   *
-   * @param messagePattern the message pattern containing placeholders.
-   * @param arguments      the arguments to be used to replace placeholders.
-   * @return the formatted message.
-   */
-  public static String format(final String messagePattern, final Object[] arguments) {
-      if (messagePattern == null || arguments == null || arguments.length == 0) {
-          return messagePattern;
-      }
-
-      final StringBuilder result = new StringBuilder();
-      int escapeCounter = 0;
-      int currentArgument = 0;
-      for (int i = 0; i < messagePattern.length(); i++) {
-          final char curChar = messagePattern.charAt(i);
-          if (curChar == ESCAPE_CHAR) {
-              escapeCounter++;
-          } else {
-              if (curChar == DELIM_START && i < messagePattern.length() - 1
-                      && messagePattern.charAt(i + 1) == DELIM_STOP) {
-                  // write escaped escape chars
-                  final int escapedEscapes = escapeCounter / 2;
-                  for (int j = 0; j < escapedEscapes; j++) {
-                      result.append(ESCAPE_CHAR);
-                  }
-
-                  if (escapeCounter % 2 == 1) {
-                      // i.e. escaped
-                      // write escaped escape chars
-                      result.append(DELIM_START);
-                      result.append(DELIM_STOP);
-                  } else {
-                      // unescaped
-                      if (currentArgument < arguments.length) {
-                          result.append(arguments[currentArgument]);
-                      } else {
-                          result.append(DELIM_START).append(DELIM_STOP);
-                      }
-                      currentArgument++;
-                  }
-                  i++;
-                  escapeCounter = 0;
-                  continue;
-              }
-              // any other char beside ESCAPE or DELIM_START/STOP-combo
-              // write unescaped escape chars
-              if (escapeCounter > 0) {
-                  for (int j = 0; j < escapeCounter; j++) {
-                      result.append(ESCAPE_CHAR);
-                  }
-                  escapeCounter = 0;
-              }
-              result.append(curChar);
-          }
-      }
-      return result.toString();
-  }
-
-  /**
-   * Counts the number of unescaped placeholders in the given messagePattern.
-   *
-   * @param messagePattern the message pattern to be analyzed.
-   * @return the number of unescaped placeholders.
-   */
-  public static int countArgumentPlaceholders(final String messagePattern) {
-      if (messagePattern == null) {
-          return 0;
-      }
-
-      final int delim = messagePattern.indexOf(DELIM_START);
-
-      if (delim == -1) {
-          // special case, no placeholders at all.
-          return 0;
-      }
-      int result = 0;
-      boolean isEscaped = false;
-      for (int i = 0; i < messagePattern.length(); i++) {
-          final char curChar = messagePattern.charAt(i);
-          if (curChar == ESCAPE_CHAR) {
-              isEscaped = !isEscaped;
-          } else if (curChar == DELIM_START) {
-              if (!isEscaped && i < messagePattern.length() - 1 && messagePattern.charAt(i + 1) == DELIM_STOP) {
-                  result++;
-                  i++;
-              }
-              isEscaped = false;
-          } else {
-              isEscaped = false;
-          }
-      }
-      return result;
-  }
-
-  /**
-   * This method performs a deep toString of the given Object.
-   * Primitive arrays are converted using their respective Arrays.toString methods while
-   * special handling is implemented for "container types", i.e. Object[], Map and Collection because those could
-   * contain themselves.
-   * <p>
-   * It should be noted that neither AbstractMap.toString() nor AbstractCollection.toString() implement such a
-   * behavior. They only check if the container is directly contained in itself, but not if a contained container
-   * contains the original one. Because of that, Arrays.toString(Object[]) isn't safe either.
-   * Confusing? Just read the last paragraph again and check the respective toString() implementation.
-   * </p>
-   * <p>
-   * This means, in effect, that logging would produce a usable output even if an ordinary System.out.println(o)
-   * would produce a relatively hard-to-debug StackOverflowError.
-   * </p>
-   * @param o The object.
-   * @return The String representation.
-   */
-  public static String deepToString(final Object o) {
-      if (o == null) {
-          return null;
-      }
-      if (o instanceof String) {
-          return (String) o;
-      }
-      final StringBuilder str = new StringBuilder();
-      final Set<String> dejaVu = new HashSet<String>(); // that's actually a neat name ;)
-      recursiveDeepToString(o, str, dejaVu);
-      return str.toString();
-  }
-
-  /**
-   * This method performs a deep toString of the given Object.
-   * Primitive arrays are converted using their respective Arrays.toString methods while
-   * special handling is implemented for "container types", i.e. Object[], Map and Collection because those could
-   * contain themselves.
-   * <p>
-   * dejaVu is used in case of those container types to prevent an endless recursion.
-   * </p>
-   * <p>
-   * It should be noted that neither AbstractMap.toString() nor AbstractCollection.toString() implement such a
-   * behavior.
-   * They only check if the container is directly contained in itself, but not if a contained container contains the
-   * original one. Because of that, Arrays.toString(Object[]) isn't safe either.
-   * Confusing? Just read the last paragraph again and check the respective toString() implementation.
-   * </p>
-   * <p>
-   * This means, in effect, that logging would produce a usable output even if an ordinary System.out.println(o)
-   * would produce a relatively hard-to-debug StackOverflowError.
-   * </p>
-   *
-   * @param o      the Object to convert into a String
-   * @param str    the StringBuilder that o will be appended to
-   * @param dejaVu a list of container identities that were already used.
-   */
-  private static void recursiveDeepToString(final Object o, final StringBuilder str, final Set<String> dejaVu) {
-      if (o == null) {
-          str.append("null");
-          return;
-      }
-      if (o instanceof String) {
-          str.append(o);
-          return;
-      }
-
-      final Class<?> oClass = o.getClass();
-      if (oClass.isArray()) {
-          if (oClass == byte[].class) {
-              str.append(Arrays.toString((byte[]) o));
-          } else if (oClass == short[].class) {
-              str.append(Arrays.toString((short[]) o));
-          } else if (oClass == int[].class) {
-              str.append(Arrays.toString((int[]) o));
-          } else if (oClass == long[].class) {
-              str.append(Arrays.toString((long[]) o));
-          } else if (oClass == float[].class) {
-              str.append(Arrays.toString((float[]) o));
-          } else if (oClass == double[].class) {
-              str.append(Arrays.toString((double[]) o));
-          } else if (oClass == boolean[].class) {
-              str.append(Arrays.toString((boolean[]) o));
-          } else if (oClass == char[].class) {
-              str.append(Arrays.toString((char[]) o));
-          } else {
-              // special handling of container Object[]
-              final String id = identityToString(o);
-              if (dejaVu.contains(id)) {
-                  str.append(RECURSION_PREFIX).append(id).append(RECURSION_SUFFIX);
-              } else {
-                  dejaVu.add(id);
-                  final Object[] oArray = (Object[]) o;
-                  str.append('[');
-                  boolean first = true;
-                  for (final Object current : oArray) {
-                      if (first) {
-                          first = false;
-                      } else {
-                          str.append(", ");
-                      }
-                      recursiveDeepToString(current, str, new HashSet<String>(dejaVu));
-                  }
-                  str.append(']');
-              }
-              //str.append(Arrays.deepToString((Object[]) o));
-          }
-      } else if (o instanceof Map && !(o instanceof Region)) {
-          // special handling of container Map
-          final String id = identityToString(o);
-          if (dejaVu.contains(id)) {
-              str.append(RECURSION_PREFIX).append(id).append(RECURSION_SUFFIX);
-          } else {
-              dejaVu.add(id);
-              final Map<?, ?> oMap = (Map<?, ?>) o;
-              str.append('{');
-              boolean isFirst = true;
-              for (final Object o1 : oMap.entrySet()) {
-                  final Map.Entry<?, ?> current = (Map.Entry<?, ?>) o1;
-                  if (isFirst) {
-                      isFirst = false;
-                  } else {
-                      str.append(", ");
-                  }
-                  final Object key = current.getKey();
-                  final Object value = current.getValue();
-                  recursiveDeepToString(key, str, new HashSet<String>(dejaVu));
-                  str.append('=');
-                  recursiveDeepToString(value, str, new HashSet<String>(dejaVu));
-              }
-              str.append('}');
-          }
-      } else if (o instanceof Collection && !(o instanceof EntriesSet)) {
-          // special handling of container Collection
-          final String id = identityToString(o);
-          if (dejaVu.contains(id)) {
-              str.append(RECURSION_PREFIX).append(id).append(RECURSION_SUFFIX);
-          } else {
-              dejaVu.add(id);
-              final Collection<?> oCol = (Collection<?>) o;
-              str.append('[');
-              boolean isFirst = true;
-              for (final Object anOCol : oCol) {
-                  if (isFirst) {
-                      isFirst = false;
-                  } else {
-                      str.append(", ");
-                  }
-                  recursiveDeepToString(anOCol, str, new HashSet<String>(dejaVu));
-              }
-              str.append(']');
-          }
-      } else if (o instanceof Date) {
-          final Date date = (Date) o;
-          final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
-          // I'll leave it like this for the moment... this could probably be optimized using ThreadLocal...
-          str.append(format.format(date));
-      } else {
-          // it's just some other Object, we can only use toString().
-          try {
-              str.append(o.toString());
-          } catch (final Throwable t) {
-              str.append(ERROR_PREFIX);
-              str.append(identityToString(o));
-              str.append(ERROR_SEPARATOR);
-              final String msg = t.getMessage();
-              final String className = t.getClass().getName();
-              str.append(className);
-              if (!className.equals(msg)) {
-                  str.append(ERROR_MSG_SEPARATOR);
-                  str.append(msg);
-              }
-              str.append(ERROR_SUFFIX);
-          }
-      }
-  }
-
-  /**
-   * This method returns the same as if Object.toString() would not have been
-   * overridden in obj.
-   * <p>
-   * Note that this isn't 100% secure as collisions can always happen with hash codes.
-   * </p>
-   * <p>
-   * Copied from Object.hashCode():
-   * </p>
-   * <blockquote>
-   * As much as is reasonably practical, the hashCode method defined by
-   * class {@code Object} does return distinct integers for distinct
-   * objects. (This is typically implemented by converting the internal
-   * address of the object into an integer, but this implementation
-   * technique is not required by the Java&#8482; programming language.)
-   * </blockquote>
-   *
-   * @param obj the Object that is to be converted into an identity string.
-   * @return the identity string as also defined in Object.toString()
-   */
-  public static String identityToString(final Object obj) {
-      if (obj == null) {
-          return null;
-      }
-      return obj.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(obj));
-  }
-
-  @Override
-  public String toString() {
-      return "GemFireParameterizedMessage[messagePattern=" + messagePattern + ", stringArgs=" +
-          Arrays.toString(stringArgs) + ", throwable=" + throwable + ']';
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/96c67d4a/geode-core/src/main/java/com/gemstone/org/apache/logging/log4j/message/GemFireParameterizedMessageFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/org/apache/logging/log4j/message/GemFireParameterizedMessageFactory.java b/geode-core/src/main/java/com/gemstone/org/apache/logging/log4j/message/GemFireParameterizedMessageFactory.java
deleted file mode 100755
index f113aa6..0000000
--- a/geode-core/src/main/java/com/gemstone/org/apache/logging/log4j/message/GemFireParameterizedMessageFactory.java
+++ /dev/null
@@ -1,54 +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 com.gemstone.org.apache.logging.log4j.message;
-
-import org.apache.logging.log4j.message.AbstractMessageFactory;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.MessageFactory;
-import org.apache.logging.log4j.message.ParameterizedMessage;
-
-/**
- * Enables use of <code>{}</code> parameter markers in message strings.
- * <p>
- * Creates {@link ParameterizedMessage} instances for {@link #newMessage(String, Object...)}.
- * </p>
- * <p>
- * This class is immutable.
- * </p>
- */
-public final class GemFireParameterizedMessageFactory extends AbstractMessageFactory {
-
-    private static final long serialVersionUID = 1L;
-    
-    /**
-     * Instance of StringFormatterMessageFactory.
-     */
-    public static final GemFireParameterizedMessageFactory INSTANCE = new GemFireParameterizedMessageFactory();
-
-    /**
-     * Creates {@link ParameterizedMessage} instances.
-     * @param message The message pattern.
-     * @param params The message parameters.
-     * @return The Message.
-     *
-     * @see MessageFactory#newMessage(String, Object...)
-     */
-    @Override
-    public Message newMessage(final String message, final Object... params) {
-        return new GemFireParameterizedMessage(message, params);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/96c67d4a/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/excludedClasses.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/excludedClasses.txt b/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/excludedClasses.txt
index 4b2d447..61a5937 100644
--- a/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/excludedClasses.txt
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/excludedClasses.txt
@@ -19,6 +19,8 @@ com/gemstone/gemfire/internal/logging/log4j/LocalizedMessage
 com/gemstone/gemfire/internal/logging/log4j/LogWriterAppenders
 com/gemstone/gemfire/internal/logging/log4j/LogWriterAppenders$Identifier
 com/gemstone/gemfire/internal/logging/log4j/LogWriterLogger
+com/gemstone/gemfire/internal/logging/log4j/message/GemFireParameterizedMessage
+com/gemstone/gemfire/internal/logging/log4j/message/GemFireParameterizedMessageFactory
 com/gemstone/gemfire/internal/offheap/RefCountChangeInfo
 com/gemstone/gemfire/internal/process/BlockingProcessStreamReader
 com/gemstone/gemfire/internal/process/NonBlockingProcessStreamReader

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/96c67d4a/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt b/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt
index ed0f9fc..fa02ca3 100755
--- a/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt
@@ -765,7 +765,6 @@ com/gemstone/gemfire/management/internal/configuration/functions/DeleteJarFuncti
 com/gemstone/gemfire/management/internal/configuration/functions/DeleteXmlEntityFunction,true,1
 com/gemstone/gemfire/management/internal/configuration/functions/GetAllJarsFunction,true,1
 com/gemstone/gemfire/management/internal/configuration/functions/ModifyPropertiesFunction,true,1
-com/gemstone/gemfire/management/internal/security/Resource,false
 com/gemstone/gemfire/management/internal/web/domain/Link,false,href:java/net/URI,method:com/gemstone/gemfire/management/internal/web/http/HttpMethod,relation:java/lang/String
 com/gemstone/gemfire/management/internal/web/domain/QueryParameterSource,true,34131123582155,objectName:javax/management/ObjectName,queryExpression:javax/management/QueryExp
 com/gemstone/gemfire/management/internal/web/http/HttpHeader,false,name:java/lang/String
@@ -797,5 +796,3 @@ com/gemstone/gemfire/security/AuthenticationFailedException,true,-82028664722790
 com/gemstone/gemfire/security/AuthenticationRequiredException,true,4675976651103154919
 com/gemstone/gemfire/security/GemFireSecurityException,true,3814254578203076926,cause:java/lang/Throwable
 com/gemstone/gemfire/security/NotAuthorizedException,true,419215768216387745,principal:java/security/Principal
-com/gemstone/org/apache/logging/log4j/message/GemFireParameterizedMessage,true,-665975803997290697,messagePattern:java/lang/String,stringArgs:java/lang/String[]
-com/gemstone/org/apache/logging/log4j/message/GemFireParameterizedMessageFactory,true,1


[33/36] incubator-geode git commit: Common secret

Posted by hi...@apache.org.
Common secret


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

Branch: refs/heads/feature/GEODE-1372
Commit: ab14e19f4f25b8b15a3cccc1d58d5c4c5d3cb297
Parents: db32370
Author: Hitesh Khamesra <hi...@yahoo.com>
Authored: Thu May 19 09:40:11 2016 -0700
Committer: Hitesh Khamesra <hi...@yahoo.com>
Committed: Thu May 19 10:19:26 2016 -0700

----------------------------------------------------------------------
 .../membership/gms/messenger/GMSEncrypt.java    | 329 ++++++++++----
 .../gms/messenger/JGroupsMessenger.java         |  14 +-
 .../gms/messenger/GMSEncryptJUnitTest.java      | 428 ++++++++++++++++++-
 3 files changed, 686 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab14e19f/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
index 7cec567..bf8f7bc 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncrypt.java
@@ -17,14 +17,21 @@
 package com.gemstone.gemfire.distributed.internal.membership.gms.messenger;
 
 
+import io.codearte.catchexception.shade.mockito.cglib.core.Local;
+
 import java.math.BigInteger;
 import java.security.*;
 import java.security.spec.EncodedKeySpec;
 import java.security.spec.InvalidKeySpecException;
 import java.security.spec.PKCS8EncodedKeySpec;
 import java.security.spec.X509EncodedKeySpec;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.crypto.Cipher;
@@ -74,22 +81,38 @@ public class GMSEncrypt implements Cloneable{
   private  String dhSKAlgo = null;
 
   private Services services;
+  
+  private InternalDistributedMember localMember;
 
   private NetView view;
 
   private Map<InternalDistributedMember, PeerEncryptor> memberToPeerEncryptor = new ConcurrentHashMap<>();
+  
+  private ClusterEncryptor clusterEncryptor;
 
 
-  protected void installView(NetView view) {
+  protected void installView(NetView view) throws Exception {
     this.view = view;
     this.view.setPublicKey(services.getJoinLeave().getMemberID(), getPublicKeyBytes());
-    // TODO remove ciphers for departed members
   }
   
-  protected void installView(NetView view, InternalDistributedMember mbr) {
+  protected void installView(NetView view, InternalDistributedMember mbr) throws Exception {
     this.view = view;
-    this.view.setPublicKey(mbr, getPublicKeyBytes());
+   // this.view.setPublicKey(mbr, getPublicKeyBytes());
     // TODO remove ciphers for departed members
+    //addClusterKey();
+  }
+  
+  protected byte[] getSecretBytes() {
+    return this.clusterEncryptor.secretBytes;
+  }
+  
+  protected synchronized void addClusterKey() throws Exception {
+    this.clusterEncryptor = new ClusterEncryptor(this);
+  }
+  
+  protected synchronized void addClusterKey(byte[] secretBytes) throws Exception {
+    this.clusterEncryptor = new ClusterEncryptor(secretBytes);
   }
 
   protected GMSEncrypt() {
@@ -100,6 +123,12 @@ public class GMSEncrypt implements Cloneable{
     this.services = services;
     initDHKeys(services.getConfig().getDistributionConfig());
   }
+  
+  public GMSEncrypt(Services services, InternalDistributedMember mbr) throws  Exception {
+    this.services = services;
+    this.localMember = mbr;
+    initDHKeys(services.getConfig().getDistributionConfig());
+  }
 
   public byte[] decryptData(byte[] data, InternalDistributedMember member) throws Exception {
     return getPeerEncryptor(member).decryptBytes(data);
@@ -108,6 +137,15 @@ public class GMSEncrypt implements Cloneable{
   public byte[] encryptData(byte[] data, InternalDistributedMember member) throws Exception {
     return getPeerEncryptor(member).encryptBytes(data);
   }
+  
+
+  public byte[] decryptData(byte[] data) throws Exception {
+    return this.clusterEncryptor.decryptBytes(data);
+  }
+
+  public byte[] encryptData(byte[] data) throws Exception {
+    return this.clusterEncryptor.encryptBytes(data);
+  }
 
   protected byte[] getPublicKeyBytes() {
     return dhPublicKey.getEncoded();
@@ -117,6 +155,7 @@ public class GMSEncrypt implements Cloneable{
   protected GMSEncrypt clone() throws CloneNotSupportedException {
     try {
       GMSEncrypt gmsEncrypt = new GMSEncrypt();
+      gmsEncrypt.localMember = this.localMember;
       gmsEncrypt.dhSKAlgo = this.dhSKAlgo;
 
       X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(this.dhPublicKey.getEncoded());
@@ -138,9 +177,6 @@ public class GMSEncrypt implements Cloneable{
     }
   }
 
-
-
-
   /**
    * Initialize the Diffie-Hellman keys. This method is not thread safe
    */
@@ -258,13 +294,12 @@ public class GMSEncrypt implements Cloneable{
 
     private String peerSKAlgo = null;
 
-    private Cipher _encrypt;
+    private Cipher encrypt;
+    
+    private Cipher decrypt = null;
 
-    protected PeerEncryptor(byte[] peerPublicKeyBytes) throws NoSuchAlgorithmException, InvalidKeySpecException {
-      X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(peerPublicKeyBytes);
-      KeyFactory keyFact = KeyFactory.getInstance("DH");
-      //PublicKey pubKey = keyFact.generatePublic(x509KeySpec);
-      this.peerPublicKey = keyFact.generatePublic(x509KeySpec);
+    protected PeerEncryptor(byte[] peerPublicKeyBytes) throws Exception {
+      this.peerPublicKey = getPublicKey(peerPublicKeyBytes);
     }
 
     public byte [] encryptBytes(byte[] data) throws Exception {
@@ -274,46 +309,21 @@ public class GMSEncrypt implements Cloneable{
       } else {
         algo = dhSKAlgo;
       }
-      return GMSEncrypt.encryptBytes(data, getEncryptCipher(algo, this.peerPublicKey));
+      return GMSEncrypt.encryptBytes(data, getEncryptCipher(algo));
     }
 
-    private Cipher getEncryptCipher(String dhSKAlgo, PublicKey publicKey)
+    private Cipher getEncryptCipher(String dhSKAlgo)
       throws Exception{
       try {
-        if(_encrypt == null) {
-          KeyAgreement ka = KeyAgreement.getInstance("DH");
-          ka.init(dhPrivateKey);
-          ka.doPhase(publicKey, true);
-
-          Cipher encrypt;
-
-          int keysize = getKeySize(dhSKAlgo);
-          int blocksize = getBlockSize(dhSKAlgo);
-
-          if (keysize == -1 || blocksize == -1) {
-            SecretKey sKey = ka.generateSecret(dhSKAlgo);
-            encrypt = Cipher.getInstance(dhSKAlgo);
-            encrypt.init(Cipher.ENCRYPT_MODE, sKey);
-          }
-          else {
-            String dhAlgoStr = getDhAlgoStr(dhSKAlgo);
-
-            byte[] sKeyBytes = ka.generateSecret();
-            SecretKeySpec sks = new SecretKeySpec(sKeyBytes, 0, keysize, dhAlgoStr);
-            IvParameterSpec ivps = new IvParameterSpec(sKeyBytes, keysize, blocksize);
-
-            encrypt = Cipher.getInstance(dhAlgoStr + "/CBC/PKCS5Padding");
-            encrypt.init(Cipher.ENCRYPT_MODE, sks, ivps);
-          }
-          _encrypt = encrypt;
+        if(encrypt == null) {
+          encrypt = GMSEncrypt.getEncryptCipher(dhSKAlgo, dhPrivateKey, this.peerPublicKey);
         }
       }catch(Exception ex) {
         throw ex;
       }
-      return _encrypt;
+      return encrypt;
     }
-
-
+    
     public byte[] decryptBytes(byte[] data) throws Exception
     {
       String algo = null;
@@ -325,48 +335,213 @@ public class GMSEncrypt implements Cloneable{
       Cipher c = getDecryptCipher(algo, this.peerPublicKey);
       return GMSEncrypt.decryptBytes(data, c);
 
+    }    
+
+    private Cipher getDecryptCipher( String dhSKAlgo, PublicKey publicKey)
+      throws Exception{
+      if(decrypt == null) {
+        decrypt = GMSEncrypt.getDecryptCipher(dhSKAlgo, dhPrivateKey, this.peerPublicKey);
+      }
+      return decrypt;
     }
 
+  }
 
+  protected static Cipher getEncryptCipher(String dhSKAlgo, PrivateKey privateKey, PublicKey peerPublicKey) 
+    throws Exception{
+    KeyAgreement ka = KeyAgreement.getInstance("DH");
+    ka.init(privateKey);
+    ka.doPhase(peerPublicKey, true);
+    
+    Cipher encrypt;
 
-    private Cipher _decrypt = null;
+    int keysize = getKeySize(dhSKAlgo);
+    int blocksize = getBlockSize(dhSKAlgo);
 
-    private Cipher getDecryptCipher( String dhSKAlgo, PublicKey publicKey)
+    if (keysize == -1 || blocksize == -1) {
+      SecretKey sKey = ka.generateSecret(dhSKAlgo);
+      encrypt = Cipher.getInstance(dhSKAlgo);
+      encrypt.init(Cipher.ENCRYPT_MODE, sKey);
+    }
+    else {
+      String dhAlgoStr = getDhAlgoStr(dhSKAlgo);
+
+      byte[] sKeyBytes = ka.generateSecret();
+      SecretKeySpec sks = new SecretKeySpec(sKeyBytes, 0, keysize, dhAlgoStr);
+      IvParameterSpec ivps = new IvParameterSpec(sKeyBytes, keysize, blocksize);
+
+      encrypt = Cipher.getInstance(dhAlgoStr + "/CBC/PKCS5Padding");
+      encrypt.init(Cipher.ENCRYPT_MODE, sks, ivps);
+    }
+
+    return encrypt;
+  }
+  
+  protected static Cipher getEncryptCipher(String dhSKAlgo, byte[] secretBytes) 
       throws Exception{
-      if(_decrypt == null) {
-        try {
-          KeyAgreement ka = KeyAgreement.getInstance("DH");
-          ka.init(dhPrivateKey);
-          ka.doPhase(publicKey, true);
-
-          Cipher decrypt;
-
-          int keysize = getKeySize(dhSKAlgo);
-          int blocksize = getBlockSize(dhSKAlgo);
-
-          if (keysize == -1 || blocksize == -1) {
-            SecretKey sKey = ka.generateSecret(dhSKAlgo);
-            decrypt = Cipher.getInstance(dhSKAlgo);
-            decrypt.init(Cipher.DECRYPT_MODE, sKey);
-          }
-          else {
-            String algoStr = getDhAlgoStr(dhSKAlgo);
-
-            byte[] sKeyBytes = ka.generateSecret();
-            SecretKeySpec sks = new SecretKeySpec(sKeyBytes, 0, keysize, algoStr);
-            IvParameterSpec ivps = new IvParameterSpec(sKeyBytes, keysize, blocksize);
-
-            decrypt = Cipher.getInstance(algoStr + "/CBC/PKCS5Padding");
-            decrypt.init(Cipher.DECRYPT_MODE, sks, ivps);
-          }
-
-          _decrypt = decrypt;
-        }catch(Exception ex) {
-          throw ex;
+      
+      Cipher encrypt = null;
+
+      int keysize = getKeySize(dhSKAlgo);
+      int blocksize = getBlockSize(dhSKAlgo);
+
+      if (keysize == -1 || blocksize == -1) {
+        //TODO how should we do here
+        /*SecretKey sKey = ka.generateSecret(dhSKAlgo);
+        encrypt = Cipher.getInstance(dhSKAlgo);
+        encrypt.init(Cipher.ENCRYPT_MODE, sKey);*/
+      }
+      else {
+        String dhAlgoStr = getDhAlgoStr(dhSKAlgo);
+
+        SecretKeySpec sks = new SecretKeySpec(secretBytes, 0, keysize, dhAlgoStr);
+        IvParameterSpec ivps = new IvParameterSpec(secretBytes, keysize, blocksize);
+
+        encrypt = Cipher.getInstance(dhAlgoStr + "/CBC/PKCS5Padding");
+        encrypt.init(Cipher.ENCRYPT_MODE, sks, ivps);
+      }
+
+      return encrypt;
+    }
+  
+  protected static Cipher getDecryptCipher(String dhSKAlgo, PrivateKey privateKey, PublicKey publicKey) throws Exception {
+    KeyAgreement ka = KeyAgreement.getInstance("DH");
+    ka.init(privateKey);
+    ka.doPhase(publicKey, true);
+    
+    Cipher decrypt;
+
+    int keysize = getKeySize(dhSKAlgo);
+    int blocksize = getBlockSize(dhSKAlgo);
+
+    if (keysize == -1 || blocksize == -1) {
+      SecretKey sKey = ka.generateSecret(dhSKAlgo);
+      decrypt = Cipher.getInstance(dhSKAlgo);
+      decrypt.init(Cipher.DECRYPT_MODE, sKey);
+    } else {
+      String algoStr = getDhAlgoStr(dhSKAlgo);
+
+      byte[] sKeyBytes = ka.generateSecret();
+      SecretKeySpec sks = new SecretKeySpec(sKeyBytes, 0, keysize, algoStr);
+      IvParameterSpec ivps = new IvParameterSpec(sKeyBytes, keysize, blocksize);
+
+      decrypt = Cipher.getInstance(algoStr + "/CBC/PKCS5Padding");
+      decrypt.init(Cipher.DECRYPT_MODE, sks, ivps);
+    }
+    return decrypt;
+  }
+  
+  protected static Cipher getDecryptCipher(String dhSKAlgo, byte[] secretBytes) throws Exception {
+    Cipher decrypt = null;
+
+    int keysize = getKeySize(dhSKAlgo);
+    int blocksize = getBlockSize(dhSKAlgo);
+
+    if (keysize == -1 || blocksize == -1) {
+      //TODO: how to do here
+      /*SecretKey sKey = ka.generateSecret(dhSKAlgo);
+      decrypt = Cipher.getInstance(dhSKAlgo);
+      decrypt.init(Cipher.DECRYPT_MODE, sKey);*/
+    } else {
+      String algoStr = getDhAlgoStr(dhSKAlgo);
+
+      SecretKeySpec sks = new SecretKeySpec(secretBytes, 0, keysize, algoStr);
+      IvParameterSpec ivps = new IvParameterSpec(secretBytes, keysize, blocksize);
+
+      decrypt = Cipher.getInstance(algoStr + "/CBC/PKCS5Padding");
+      decrypt.init(Cipher.DECRYPT_MODE, sks, ivps);
+    }
+    return decrypt;
+  }
+  protected static byte[] generateSecret(String dhSKAlgo, PrivateKey privateKey, PublicKey otherPublicKey) throws Exception {
+    KeyAgreement ka = KeyAgreement.getInstance("DH");
+    ka.init(privateKey);
+    ka.doPhase(otherPublicKey, true);
+    
+    int keysize = getKeySize(dhSKAlgo);
+    int blocksize = getBlockSize(dhSKAlgo);
+
+    if (keysize == -1 || blocksize == -1) {
+      SecretKey sKey = ka.generateSecret(dhSKAlgo);
+      return sKey.getEncoded();
+    } else {
+      String algoStr = getDhAlgoStr(dhSKAlgo);
+
+      return ka.generateSecret();
+    }
+  }
+  
+  protected static PublicKey getPublicKey(byte[] publicKeyBytes) throws Exception {
+    X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(publicKeyBytes);
+    KeyFactory keyFact = KeyFactory.getInstance("DH");
+    //PublicKey pubKey = keyFact.generatePublic(x509KeySpec);
+    return keyFact.generatePublic(x509KeySpec);
+  }
+
+  protected static void initEncryptCipher(KeyAgreement ka, List<PublicKey> publicKeys) throws Exception{
+    Iterator<PublicKey> itr = publicKeys.iterator();
+    while(itr.hasNext()) {
+       ka.doPhase(itr.next(), !itr.hasNext());
+    }
+  }
+  /***
+   * this will hold the common key for cluster
+   * that will be created using publickey of all the members..
+   *
+   */
+  protected class ClusterEncryptor{
+    byte[] secretBytes;
+    Cipher encrypt;
+    Cipher decrypt;
+    int viewId;
+    Set<InternalDistributedMember> mbrs;
+    
+    public ClusterEncryptor(GMSEncrypt other) throws Exception {
+      GMSEncrypt mine = new GMSEncrypt(other.services);      
+      this.secretBytes = GMSEncrypt.generateSecret(mine.dhSKAlgo, mine.dhPrivateKey, other.dhPublicKey);
+    }
+    
+    public ClusterEncryptor(byte[] sb) {
+      this.secretBytes = sb;
+    }
+    
+    public byte [] encryptBytes(byte[] data) throws Exception {
+      String algo = dhSKAlgo;
+      return GMSEncrypt.encryptBytes(data, getEncryptCipher(algo));
+    }
+
+    private Cipher getEncryptCipher(String dhSKAlgo)
+      throws Exception{
+      try {
+        if(encrypt == null) {
+          synchronized (this) {
+            if(encrypt == null)
+              encrypt = GMSEncrypt.getEncryptCipher(dhSKAlgo, secretBytes);
+          }          
         }
+      }catch(Exception ex) {
+        throw ex;
       }
-      return _decrypt;
+      return encrypt;
+    }
+    
+    public byte[] decryptBytes(byte[] data) throws Exception
+    {
+      String algo = dhSKAlgo;
+      Cipher c = getDecryptCipher(algo);
+      return GMSEncrypt.decryptBytes(data, c);
     }
 
+    private Cipher getDecryptCipher( String dhSKAlgo)
+      throws Exception{
+      if(decrypt == null) {
+        synchronized (this) {
+          if(decrypt == null)
+            decrypt = GMSEncrypt.getDecryptCipher(dhSKAlgo, secretBytes);
+        }        
+      }
+      return decrypt;
+    }
   }
 }
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab14e19f/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index 25a9c43..cba5d5f 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -389,7 +389,12 @@ public class JGroupsMessenger implements Messenger {
     addressesWithIoExceptionsProcessed.clear();
 
     if (encrypt != null) {
-//      encrypt.installView(v);
+      try {
+        encrypt.installView(v);
+      } catch (Exception e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      }
     }
   }
   
@@ -606,7 +611,12 @@ public class JGroupsMessenger implements Messenger {
   @Override
   public Set<InternalDistributedMember> send(DistributionMessage msg, NetView alternateView) {
     if (this.encrypt != null) {
-     // this.encrypt.installView(alternateView);
+      try {
+        this.encrypt.installView(alternateView);
+      } catch (Exception e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      }
     }
     return send(msg, true);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ab14e19f/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
index de90328..8652b67 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
@@ -1,5 +1,6 @@
 package com.gemstone.gemfire.distributed.internal.membership.gms.messenger;
 import static org.mockito.Mockito.*;
+
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
 import com.gemstone.gemfire.distributed.internal.DistributionManager;
@@ -8,14 +9,26 @@ import com.gemstone.gemfire.distributed.internal.membership.NetView;
 import com.gemstone.gemfire.distributed.internal.membership.gms.ServiceConfig;
 import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
 import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
+
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.math.BigInteger;
+import java.security.Key;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Properties;
 
+import javax.crypto.KeyAgreement;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.DHParameterSpec;
+
 /**
  * Created by bschuchardt on 5/6/2016.
  */
@@ -45,12 +58,13 @@ public class GMSEncryptJUnitTest {
     }
     int viewId = 1;
     List<InternalDistributedMember> mbrs = new LinkedList<>();
-    mbrs.add(mockMembers[0]);
+    //mbrs.add(mockMembers[0]);
     mbrs.add(mockMembers[1]);
     mbrs.add(mockMembers[2]);
+    mbrs.add(mockMembers[3]);
 
     //prepare the view
-    netView = new NetView(mockMembers[0], viewId, mbrs);
+    netView = new NetView(mockMembers[1], viewId, mbrs);
 
   }
 
@@ -59,8 +73,8 @@ public class GMSEncryptJUnitTest {
   public void testOneMemberCanDecryptAnothersMessage() throws Exception{
     initMocks();
 
-    GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services); // this will be the sender
-    GMSEncrypt gmsEncrypt2 = new GMSEncrypt(services); // this will be the receiver
+    GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services, mockMembers[1]); // this will be the sender
+    GMSEncrypt gmsEncrypt2 = new GMSEncrypt(services, mockMembers[2]); // this will be the receiver
 
     // establish the public keys for the sender and receiver
     netView.setPublicKey(mockMembers[1], gmsEncrypt1.getPublicKeyBytes());
@@ -99,8 +113,8 @@ public class GMSEncryptJUnitTest {
   public void testPublicKeyPrivateKeyFromSameMember() throws Exception{
     initMocks();
 
-    GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services); // this will be the sender
-    GMSEncrypt gmsEncrypt2 = new GMSEncrypt(services); // this will be the receiver
+    GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services, mockMembers[1]); // this will be the sender
+    GMSEncrypt gmsEncrypt2 = new GMSEncrypt(services, mockMembers[2]); // this will be the receiver
     
     gmsEncrypt1 = gmsEncrypt1.clone();
     gmsEncrypt2 = gmsEncrypt2.clone();
@@ -137,4 +151,406 @@ public class GMSEncryptJUnitTest {
     Assert.assertTrue(Arrays.equals(responseBytes, decryptedResponse));
 
   }
+  
+  @Test
+  public void testForClusterSecretKey() throws Exception{
+    initMocks();
+
+    GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services, mockMembers[1]); // this will be the sender
+    gmsEncrypt1.addClusterKey();
+    // establish the public keys for the sender and receiver
+    netView.setPublicKey(mockMembers[1], gmsEncrypt1.getPublicKeyBytes());
+    
+    gmsEncrypt1.installView(netView, mockMembers[1]);
+    
+    // sender encrypts a message, so use receiver's public key
+    String ch = "Hello world";
+    byte[] challenge =  ch.getBytes();
+    byte[]  encryptedChallenge =  gmsEncrypt1.encryptData(challenge);
+
+    // receiver decrypts the message using the sender's public key
+    byte[] decryptBytes = gmsEncrypt1.decryptData(encryptedChallenge);
+    
+    Assert.assertFalse(Arrays.equals(challenge, encryptedChallenge));
+
+    Assert.assertTrue(Arrays.equals(challenge, decryptBytes));    
+  }
+  
+  @Test
+  public void testForClusterSecretKeyFromOtherMember() throws Exception{
+    initMocks();
+
+    GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services, mockMembers[1]); // this will be the sender
+    gmsEncrypt1.addClusterKey();
+    GMSEncrypt gmsEncrypt2 = new GMSEncrypt(services, mockMembers[2]); // this will be the sender
+    
+    // establish the public keys for the sender and receiver
+    netView.setPublicKey(mockMembers[1], gmsEncrypt1.getPublicKeyBytes());
+    netView.setPublicKey(mockMembers[2], gmsEncrypt2.getPublicKeyBytes());
+    
+    gmsEncrypt1.installView(netView, mockMembers[1]);
+    
+    byte[] secretBytes = gmsEncrypt1.getSecretBytes();
+    gmsEncrypt2.addClusterKey(secretBytes);
+    
+    gmsEncrypt2.installView(netView, mockMembers[1]);
+    
+    // sender encrypts a message, so use receiver's public key
+    String ch = "Hello world";
+    byte[] challenge =  ch.getBytes();
+    byte[]  encryptedChallenge =  gmsEncrypt1.encryptData(challenge);
+
+    // receiver decrypts the message using the sender's public key
+    byte[] decryptBytes = gmsEncrypt2.decryptData(encryptedChallenge);
+    
+    // now send a response
+    String response = "Hello yourself!";
+    byte[] responseBytes = response.getBytes();
+    byte[] encryptedResponse = gmsEncrypt2.encryptData(responseBytes);
+
+    // receiver decodes the response
+    byte[] decryptedResponse = gmsEncrypt1.decryptData(encryptedResponse);
+
+    Assert.assertFalse(Arrays.equals(challenge, encryptedChallenge));
+
+    Assert.assertTrue(Arrays.equals(challenge, decryptBytes));
+
+    Assert.assertFalse(Arrays.equals(responseBytes, encryptedResponse));
+
+    Assert.assertTrue(Arrays.equals(responseBytes, decryptedResponse));  
+  }
+  
+    
+  @Test
+    public void testDHAlgo() throws Exception {
+
+      DHParameterSpec dhSkipParamSpec;
+
+      System.out.println("Using SKIP Diffie-Hellman parameters");
+      dhSkipParamSpec = new DHParameterSpec(skip1024Modulus, skip1024Base);
+
+      // Alice creates her own DH key pair
+      System.out.println("ALICE: Generate DH keypair ...");
+      KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH");
+      aliceKpairGen.initialize(dhSkipParamSpec);
+      KeyPair aliceKpair = aliceKpairGen.generateKeyPair();
+
+      // Bob creates his own DH key pair
+      System.out.println("BOB: Generate DH keypair ...");
+      KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH");
+      bobKpairGen.initialize(dhSkipParamSpec);
+      KeyPair bobKpair = bobKpairGen.generateKeyPair();
+
+      // Carol creates her own DH key pair
+      System.out.println("CAROL: Generate DH keypair ...");
+      KeyPairGenerator carolKpairGen = KeyPairGenerator.getInstance("DH");
+      carolKpairGen.initialize(dhSkipParamSpec);
+      KeyPair carolKpair = carolKpairGen.generateKeyPair();
+
+
+      // Alice initialize
+      System.out.println("ALICE: Initialize ...");
+      KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH");
+      aliceKeyAgree.init(aliceKpair.getPrivate());
+
+      // Bob initialize
+      System.out.println("BOB: Initialize ...");
+      KeyAgreement bobKeyAgree = KeyAgreement.getInstance("DH");
+      bobKeyAgree.init(bobKpair.getPrivate());
+
+      // Carol initialize
+      System.out.println("CAROL: Initialize ...");
+      KeyAgreement carolKeyAgree = KeyAgreement.getInstance("DH");
+      carolKeyAgree.init(carolKpair.getPrivate());
+
+
+      // Alice uses Carol's public key
+      Key ac = aliceKeyAgree.doPhase(carolKpair.getPublic(), false);
+
+      // Bob uses Alice's public key
+      Key ba = bobKeyAgree.doPhase(aliceKpair.getPublic(), false);
+
+      // Carol uses Bob's public key
+      Key cb = carolKeyAgree.doPhase(bobKpair.getPublic(), false);
+
+
+      // Alice uses Carol's result from above
+      aliceKeyAgree.doPhase(cb, true);
+
+      // Bob uses Alice's result from above
+      bobKeyAgree.doPhase(ac, true);
+
+      // Carol uses Bob's result from above
+      carolKeyAgree.doPhase(ba, true);
+
+
+      // Alice, Bob and Carol compute their secrets
+      byte[] aliceSharedSecret = aliceKeyAgree.generateSecret();
+      System.out.println("Alice secret: " + toHexString(aliceSharedSecret));
+
+      byte[] bobSharedSecret = bobKeyAgree.generateSecret();
+      System.out.println("Bob secret: " + toHexString(bobSharedSecret));
+
+      byte[] carolSharedSecret = carolKeyAgree.generateSecret();
+      System.out.println("Carol secret: " + toHexString(carolSharedSecret));
+
+
+      // Compare Alice and Bob
+      if (!java.util.Arrays.equals(aliceSharedSecret, bobSharedSecret))
+          throw new Exception("Alice and Bob differ");
+      System.out.println("Alice and Bob are the same");
+
+      // Compare Bob and Carol
+      if (!java.util.Arrays.equals(bobSharedSecret, carolSharedSecret))
+          throw new Exception("Bob and Carol differ");
+      System.out.println("Bob and Carol are the same");
+  }
+  
+  @Test
+  public void testDHAlgo2() throws Exception {
+
+    DHParameterSpec dhSkipParamSpec;
+
+    System.out.println("Using SKIP Diffie-Hellman parameters");
+    dhSkipParamSpec = new DHParameterSpec(skip1024Modulus, skip1024Base);
+
+ // Alice creates her own DH key pair
+    System.out.println("ALICE: Generate DH keypair ...");
+    KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH");
+    aliceKpairGen.initialize(dhSkipParamSpec);
+    KeyPair aliceKpair = aliceKpairGen.generateKeyPair();
+
+    
+    // Bob creates his own DH key pair
+    System.out.println("BOB: Generate DH keypair ...");
+    KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH");
+    bobKpairGen.initialize(dhSkipParamSpec);
+    KeyPair bobKpair = bobKpairGen.generateKeyPair();
+
+    
+    // Alice initialize
+    System.out.println("ALICE: Initialize ...");
+    KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH");
+    aliceKeyAgree.init(aliceKpair.getPrivate()); 
+
+    // Bob initialize
+    System.out.println("BOB  : Initialize ...");
+    KeyAgreement bobKeyAgree = KeyAgreement.getInstance("DH");
+    bobKeyAgree.init(bobKpair.getPrivate());
+    
+    // Alice uses Carol's public key
+    aliceKeyAgree.doPhase(bobKpair.getPublic(), true);       
+    
+    // Bob uses Alice's public key
+    bobKeyAgree.doPhase(aliceKpair.getPublic(), true);
+
+    // Alice, Bob and Carol compute their secrets
+    byte[] aliceSharedSecret = aliceKeyAgree.generateSecret();
+    System.out.println("Alice secret: " + toHexString(aliceSharedSecret));
+
+    
+    byte[] bobSharedSecret = bobKeyAgree.generateSecret();
+    System.out.println("Bob   secret: " + toHexString(bobSharedSecret));
+    
+    
+    // Compare Alice and Bob
+    if (!java.util.Arrays.equals(aliceSharedSecret, bobSharedSecret))
+        throw new Exception("Alice and Bob differ");
+    System.out.println("Alice and Bob are the same");
+
+  }
+  
+  @Test
+  public void testDHAlgo3() throws Exception {
+
+    DHParameterSpec dhSkipParamSpec;
+
+    System.out.println("Using SKIP Diffie-Hellman parameters");
+    dhSkipParamSpec = new DHParameterSpec(skip1024Modulus, skip1024Base);
+
+ // Alice creates her own DH key pair
+    System.out.println("ALICE: Generate DH keypair ...");
+    KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH");
+    aliceKpairGen.initialize(dhSkipParamSpec);
+    KeyPair aliceKpair = aliceKpairGen.generateKeyPair();
+
+    
+    // Bob creates his own DH key pair
+    System.out.println("BOB: Generate DH keypair ...");
+    KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH");
+    bobKpairGen.initialize(dhSkipParamSpec);
+    KeyPair bobKpair = bobKpairGen.generateKeyPair();
+
+    
+    // Alice initialize
+    System.out.println("ALICE: Initialize ...");
+    KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH");
+    aliceKeyAgree.init(aliceKpair.getPrivate()); 
+
+    // Bob initialize
+    System.out.println("BOB  : Initialize ...");
+    KeyAgreement bobKeyAgree = KeyAgreement.getInstance("DH");
+    bobKeyAgree.init(bobKpair.getPrivate());
+    
+    // Alice uses Carol's public key
+    aliceKeyAgree.doPhase(bobKpair.getPublic(), true);       
+    
+    // Bob uses Alice's public key
+    bobKeyAgree.doPhase(aliceKpair.getPublic(), true);
+
+    String dhKalgo = "AES"; 
+    // Alice, Bob and Carol compute their secrets
+    SecretKey aliceSharedSecret = aliceKeyAgree.generateSecret(dhKalgo);
+    System.out.println("Alice secret: " + toHexString(aliceSharedSecret.getEncoded()));
+
+    
+    
+    SecretKey bobSharedSecret = bobKeyAgree.generateSecret(dhKalgo);
+    System.out.println("Bob   secret: " + toHexString(bobSharedSecret.getEncoded()));
+    
+    applyMAC(aliceSharedSecret);
+    applyMAC(bobSharedSecret);
+    
+    // Compare Alice and Bob
+    if (!java.util.Arrays.equals(aliceSharedSecret.getEncoded(), bobSharedSecret.getEncoded()))
+        throw new Exception("Alice and Bob differ");
+    System.out.println("Alice and Bob are the same");
+  }
+  
+  private void applyMAC(Key key) throws Exception {
+    SecretKey key2 = new SecretKey() {
+      
+      @Override
+      public String getFormat() {
+        // TODO Auto-generated method stub
+        return key.getFormat();
+      }
+      
+      @Override
+      public byte[] getEncoded() {
+        // TODO Auto-generated method stub
+        String hitesh = "This is from Hitesh";
+        byte[] secbytes = hitesh.getBytes();
+        byte[] origsecret = key.getEncoded(); 
+        byte[] ns = new byte[origsecret.length + secbytes.length];
+        System.arraycopy(origsecret, 0, ns, 0, origsecret.length);
+        System.arraycopy(secbytes, 0, ns, origsecret.length, secbytes.length);
+        return ns;
+      }
+      
+      @Override
+      public String getAlgorithm() {
+        // TODO Auto-generated method stub
+        return key.getAlgorithm();
+      }
+    };
+ // Generate secret key for HMAC-MD5
+    //KeyGenerator kg = KeyGenerator.getInstance("HmacMD5");
+    //SecretKey sk = kg.generateKey();
+
+    // Get instance of Mac object implementing HMAC-MD5, and
+    // initialize it with the above secret key
+    
+    System.out.println("Key2 secret " + toHexString(key2.getEncoded()));
+    
+    Mac mac = Mac.getInstance("HmacMD5");
+    mac.init(key2);
+    byte[] result = mac.doFinal("Hi There".getBytes());
+   
+    
+    System.out.println("Message Authentication code length: " + mac.getMacLength());
+    System.out.println("Message Authentication code : " + toHexString(result));
+    
+    verifyMacBody(mac, result);
+  }
+  
+  private byte[] verifyMacBody(Mac hmac, byte[] encryptedAndMac) throws Exception {               
+    byte[] encrypted = new byte[encryptedAndMac.length - hmac.getMacLength()];
+    System.arraycopy(encryptedAndMac, 0, encrypted, 0, encrypted.length);
+
+    byte[] remoteMac = new byte[hmac.getMacLength()];
+    System.arraycopy(encryptedAndMac, encryptedAndMac.length - remoteMac.length, remoteMac, 0, remoteMac.length);
+
+    byte[] localMac  = hmac.doFinal(encrypted);
+
+    System.out.println("Message Authentication code remoteMac : " + toHexString(remoteMac));
+    System.out.println("Message Authentication code localMac : " + toHexString(localMac));
+    if (!Arrays.equals(remoteMac, localMac))
+      throw new Exception("MAC doesen't match.");
+
+    return encrypted;
+  }
+  // The 1024 bit Diffie-Hellman modulus values used by SKIP
+  private static final byte skip1024ModulusBytes[] = {
+      (byte)0xF4, (byte)0x88, (byte)0xFD, (byte)0x58,
+      (byte)0x4E, (byte)0x49, (byte)0xDB, (byte)0xCD,
+      (byte)0x20, (byte)0xB4, (byte)0x9D, (byte)0xE4,
+      (byte)0x91, (byte)0x07, (byte)0x36, (byte)0x6B,
+      (byte)0x33, (byte)0x6C, (byte)0x38, (byte)0x0D,
+      (byte)0x45, (byte)0x1D, (byte)0x0F, (byte)0x7C,
+      (byte)0x88, (byte)0xB3, (byte)0x1C, (byte)0x7C,
+      (byte)0x5B, (byte)0x2D, (byte)0x8E, (byte)0xF6,
+      (byte)0xF3, (byte)0xC9, (byte)0x23, (byte)0xC0,
+      (byte)0x43, (byte)0xF0, (byte)0xA5, (byte)0x5B,
+      (byte)0x18, (byte)0x8D, (byte)0x8E, (byte)0xBB,
+      (byte)0x55, (byte)0x8C, (byte)0xB8, (byte)0x5D,
+      (byte)0x38, (byte)0xD3, (byte)0x34, (byte)0xFD,
+      (byte)0x7C, (byte)0x17, (byte)0x57, (byte)0x43,
+      (byte)0xA3, (byte)0x1D, (byte)0x18, (byte)0x6C,
+      (byte)0xDE, (byte)0x33, (byte)0x21, (byte)0x2C,
+      (byte)0xB5, (byte)0x2A, (byte)0xFF, (byte)0x3C,
+      (byte)0xE1, (byte)0xB1, (byte)0x29, (byte)0x40,
+      (byte)0x18, (byte)0x11, (byte)0x8D, (byte)0x7C,
+      (byte)0x84, (byte)0xA7, (byte)0x0A, (byte)0x72,
+      (byte)0xD6, (byte)0x86, (byte)0xC4, (byte)0x03,
+      (byte)0x19, (byte)0xC8, (byte)0x07, (byte)0x29,
+      (byte)0x7A, (byte)0xCA, (byte)0x95, (byte)0x0C,
+      (byte)0xD9, (byte)0x96, (byte)0x9F, (byte)0xAB,
+      (byte)0xD0, (byte)0x0A, (byte)0x50, (byte)0x9B,
+      (byte)0x02, (byte)0x46, (byte)0xD3, (byte)0x08,
+      (byte)0x3D, (byte)0x66, (byte)0xA4, (byte)0x5D,
+      (byte)0x41, (byte)0x9F, (byte)0x9C, (byte)0x7C,
+      (byte)0xBD, (byte)0x89, (byte)0x4B, (byte)0x22,
+      (byte)0x19, (byte)0x26, (byte)0xBA, (byte)0xAB,
+      (byte)0xA2, (byte)0x5E, (byte)0xC3, (byte)0x55,
+      (byte)0xE9, (byte)0x2F, (byte)0x78, (byte)0xC7
+  };
+  
+
+
+  // The SKIP 1024 bit modulus
+  private static final BigInteger skip1024Modulus
+  = new BigInteger(1, skip1024ModulusBytes);
+
+  // The base used with the SKIP 1024 bit modulus
+  private static final BigInteger skip1024Base = BigInteger.valueOf(2);
+  
+  /*
+   * Converts a byte to hex digit and writes to the supplied buffer
+   */
+  private void byte2hex(byte b, StringBuffer buf) {
+      char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
+                          '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+      int high = ((b & 0xf0) >> 4);
+      int low = (b & 0x0f);
+      buf.append(hexChars[high]);
+      buf.append(hexChars[low]);
+  }
+
+  /*
+   * Converts a byte array to hex string
+   */
+  private String toHexString(byte[] block) {
+      StringBuffer buf = new StringBuffer();
+
+      int len = block.length;
+
+      for (int i = 0; i < len; i++) {
+           byte2hex(block[i], buf);
+           if (i < len-1) {
+               buf.append(":");
+           }
+      }
+      return buf.toString();
+  }
 }


[05/36] incubator-geode git commit: GEODE-92: PR with entry eviction 1 leaves 3 entries in memory with async overflow

Posted by hi...@apache.org.
GEODE-92: PR with entry eviction 1 leaves 3 entries in memory with async overflow

 Found that invoking lruUpdateCallback multiple times with in a single get
 could mess up entry eviction state. So disabled lru callback and invoked
 at the end of the operation.


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

Branch: refs/heads/feature/GEODE-1372
Commit: f4b0643829b00d0ba9b0852fdd3a679812395545
Parents: 44c2f39
Author: Sai Boorlagadda <sb...@pivotal.io>
Authored: Tue Apr 26 13:31:25 2016 -0700
Committer: Sai Boorlagadda <sb...@pivotal.io>
Committed: Tue May 10 08:33:09 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/cache/AbstractLRURegionMap.java  |  9 +++------
 .../gemstone/gemfire/internal/cache/LocalRegion.java  |  6 ++++++
 .../cache/PartitionedRegionStatsJUnitTest.java        | 14 ++------------
 3 files changed, 11 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f4b06438/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java
index 2cc7a55..14c431d 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java
@@ -197,17 +197,14 @@ public abstract class AbstractLRURegionMap extends AbstractRegionMap {
     int delta = le.updateEntrySize(_getCCHelper(), new CDValueWrapper(v));
     if (delta != 0) {
       result = true;
-      boolean needToDisableCallbacks = !getCallbackDisabled();
-      if (needToDisableCallbacks) {
-        setCallbackDisabled(true);
-      }
+      boolean disabledLURCallbacks = disableLruUpdateCallback();
       // by making sure that callbacks are disabled when we call
       // setDelta; it ensures that the setDelta will just inc the delta
       // value and not call lruUpdateCallback which we call in
       // finishChangeValueForm
       setDelta(delta);
-      if (needToDisableCallbacks) {
-        setCallbackDisabled(false);
+      if (disabledLURCallbacks) {
+        enableLruUpdateCallback();
       }
     }
     // fix for bug 42090

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f4b06438/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
index 3ad294c..e9f5819 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
@@ -1298,6 +1298,7 @@ public class LocalRegion extends AbstractRegion
   @Retained
   protected final Object getDeserialized(RegionEntry re, boolean updateStats, boolean disableCopyOnRead, boolean preferCD, boolean retainResult) {
     assert !retainResult || preferCD;
+    boolean disabledLRUCallback = this.entries.disableLruUpdateCallback();
     try {
       @Retained Object v = null;
       try {
@@ -1340,6 +1341,11 @@ public class LocalRegion extends AbstractRegion
       IllegalArgumentException iae = new IllegalArgumentException(LocalizedStrings.DONT_RELEASE.toLocalizedString("Error while deserializing value for key="+re.getKey()));
       iae.initCause(i);
       throw iae;
+    } finally {
+      if(disabledLRUCallback) {
+        this.entries.enableLruUpdateCallback();
+        this.entries.lruUpdateCallback();
+      }
     }
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f4b06438/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionStatsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionStatsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionStatsJUnitTest.java
index 167b89b..1a3277c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionStatsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionStatsJUnitTest.java
@@ -436,11 +436,7 @@ public class PartitionedRegionStatsJUnitTest
     
     pr.getDiskStore().flush();
     
-    //Workaround for GEODE-92. We are leaving more than 1 entry in memory. To
-    //validate that stats, let's confirm the stats match what is actually in
-    //memory
-    //int entriesInMem = 1;
-    int entriesInMem = countEntriesInMem(pr);
+    int entriesInMem = 1;
     
     assertEquals(singleEntryMemSize * entriesInMem, stats.getLong("dataStoreBytesInUse"));
     assertEquals(numEntries , stats.getInt("dataStoreEntryCount"));
@@ -475,13 +471,7 @@ public class PartitionedRegionStatsJUnitTest
     System.out.println("----Done with random operations");
 
     numEntries = pr.entryCount();
-    
-    //Workaround for GEODE-92. We are leaving more than 1 entry in memory. To
-    //validate that stats, let's confirm the stats match what is actually in
-    //memory
-    //entriesInMem = 1;
-    entriesInMem = countEntriesInMem(pr);
-    
+        
     assertEquals(singleEntryMemSize * entriesInMem, stats.getLong("dataStoreBytesInUse"));
     assertEquals(numEntries , stats.getInt("dataStoreEntryCount"));
     assertEquals((numEntries - entriesInMem) * entryOverflowSize, diskStats.getNumOverflowBytesOnDisk());


[29/36] incubator-geode git commit: GEODE-1146: Amending Testcase to use proper client caches rather than peer servers. Also amending JUnit4CacheTestCase.java to set "locators" and "mcast-port" to correct settings for clients.

Posted by hi...@apache.org.
GEODE-1146: Amending Testcase to use proper client caches rather than peer servers. Also amending JUnit4CacheTestCase.java to set "locators" and "mcast-port" to correct settings for clients.


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

Branch: refs/heads/feature/GEODE-1372
Commit: 2c2caae9db8d687107d5d15af44a5f0d14465b35
Parents: 665471a
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri May 13 04:32:15 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri May 13 04:37:13 2016 +1000

----------------------------------------------------------------------
 .../query/dunit/QueryUsingPoolDUnitTest.java    | 192 +++++++------------
 .../cache/internal/JUnit4CacheTestCase.java     |  17 +-
 2 files changed, 73 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2c2caae9/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
index a87c243..0e25d05 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
@@ -18,11 +18,11 @@ package com.gemstone.gemfire.cache.query.dunit;
 
 import cacheRunner.Portfolio;
 import cacheRunner.Position;
-import org.junit.experimental.categories.Category;
-
 import com.gemstone.gemfire.DataSerializable;
 import com.gemstone.gemfire.DataSerializer;
 import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
 import com.gemstone.gemfire.cache.client.PoolFactory;
 import com.gemstone.gemfire.cache.client.PoolManager;
 import com.gemstone.gemfire.cache.query.*;
@@ -35,16 +35,11 @@ import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
 import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.cache30.ClientServerTestCase;
 import com.gemstone.gemfire.internal.cache.tier.sockets.CacheClientNotifier;
-import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
-import com.gemstone.gemfire.test.dunit.NetworkUtils;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.test.dunit.*;
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import com.jayway.awaitility.Awaitility;
+import org.junit.experimental.categories.Category;
 
 import java.io.DataInput;
 import java.io.DataOutput;
@@ -53,6 +48,7 @@ import java.util.Comparator;
 import java.util.Iterator;
 import java.util.Properties;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Tests remote (client/server) query execution.
@@ -114,29 +110,24 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
   public void createPool(final String poolName, final String[] servers, final int[] ports,
       final boolean subscriptionEnabled) {
     // Create Cache.
-    getCache();
+    getCache(true);
 
-    PoolFactory cpf = PoolManager.createFactory();
-    cpf.setSubscriptionEnabled(subscriptionEnabled);
+    PoolFactory poolFactory = PoolManager.createFactory();
+    poolFactory.setSubscriptionEnabled(subscriptionEnabled);
     for (int i = 0; i < servers.length; i++) {
-      LogWriterUtils.getLogWriter().info("### Adding to Pool. ### Server : " + servers[i] + " Port : " + ports[i]);
-      cpf.addServer(servers[i], ports[i]);
+      LogService.getLogger().info("### Adding to Pool. ### Server : " + servers[i] + " Port : " + ports[i]);
+      poolFactory.addServer(servers[i], ports[i]);
     }
-
-    cpf.create(poolName);
+    poolFactory.setMinConnections(1);
+    poolFactory.setMaxConnections(5);
+    poolFactory.setRetryAttempts(5);
+    poolFactory.create(poolName);
   }
 
   public void validateCompiledQuery(final long compiledQueryCount) {
-    long count = 0;
-    for (int i = 0; i < 100; i++) {
-      count = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-      if (count == compiledQueryCount) {
-        break;
-      } else {
-        Wait.pause(1 * 100);
-      }
-    }
-    assertEquals(compiledQueryCount, count);
+    Awaitility.await().pollInterval(100, TimeUnit.MILLISECONDS)
+        .pollDelay(100, TimeUnit.MILLISECONDS).timeout(60, TimeUnit.SECONDS)
+        .until(() -> CacheClientNotifier.getInstance().getStats().getCompiledQueryCount() == compiledQueryCount);
   }
 
   /**
@@ -160,7 +151,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       AttributesFactory factory = new AttributesFactory();
       factory.setScope(Scope.LOCAL);
       createRegion(name, rootRegionName, factory.create());
-      Wait.pause(1000);
+      //      Wait.pause(1000);
       try {
         startBridgeServer(0, false);
       } catch (Exception ex) {
@@ -286,7 +277,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       AttributesFactory factory = new AttributesFactory();
       factory.setScope(Scope.LOCAL);
       createRegion(name, factory.create());
-      Wait.pause(1000);
+      //      Wait.pause(1000);
       try {
         startBridgeServer(0, false);
       } catch (Exception ex) {
@@ -413,7 +404,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       AttributesFactory factory = new AttributesFactory();
       factory.setScope(Scope.LOCAL);
       createRegion(name, factory.create());
-      Wait.pause(1000);
+      //      Wait.pause(1000);
       try {
         startBridgeServer(0, false);
       } catch (Exception ex) {
@@ -596,7 +587,6 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       AttributesFactory factory = new AttributesFactory();
       factory.setScope(Scope.LOCAL);
       createRegion(name, factory.create());
-      Wait.pause(1000);
       try {
         startBridgeServer(0, false);
       } catch (Exception ex) {
@@ -800,7 +790,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
 
         for (int i = 0; i < queryString.length; i++) {
           try {
-            LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
+            LogService.getLogger().info("### Executing Query :" + queryString[i]);
             Query query = qService.newQuery(queryString[i]);
             results = (SelectResults) query.execute(params[i]);
           } catch (Exception e) {
@@ -830,7 +820,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       for (int x = 0; x < useMaintainedCompiledQueries; x++) {
         for (int i = 0; i < queryString.length; i++) {
           try {
-            LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
+            LogService.getLogger().info("### Executing Query :" + queryString[i]);
             Query query = qService.newQuery(queryString[i]);
             results = (SelectResults) query.execute(params[i]);
           } catch (Exception e) {
@@ -911,8 +901,8 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     });
 
     // Create client region
-    final int port0 = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
-    final int port1 = vm1.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port0 = vm0.invoke("getCacheServerPort", () -> getCacheServerPort());
+    final int port1 = vm1.invoke("getCacheServerPort", () -> getCacheServerPort());
 
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
@@ -935,7 +925,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
         for (int j = 0; j < queryString.length; j++) {
           for (int i = 0; i < queryString.length; i++) {
             try {
-              LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
+              LogService.getLogger().info("### Executing Query :" + queryString[i]);
               Query query = qService.newQuery(queryString[i]);
               results = (SelectResults) query.execute(params[i]);
             } catch (Exception e) {
@@ -978,8 +968,8 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     });
 
     // recreate clients and execute queries.
-    vm2.invoke("createPool", () -> createPool(poolName, new String[] { host0,host0 }, new int[] { port1, port0 }, true));
-    vm3.invoke("createPool", () -> createPool(poolName, new String[] { host0,host0 }, new int[] { port0, port1 }, true));
+    vm2.invoke("createPool", () -> createPool(poolName, new String[] { host0, host0 }, new int[] { port1, port0 }, true));
+    vm3.invoke("createPool", () -> createPool(poolName, new String[] { host0, host0 }, new int[] { port0, port1 }, true));
 
     vm2.invoke(executeQueries);
     vm3.invoke(executeQueries);
@@ -1134,14 +1124,10 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     // Validate maintained compiled queries.
     vm0.invoke("validate Compiled query", () -> validateCompiledQuery(queryString.length));
 
-    // Let the compiled queries to be idle (not used).
-    Wait.pause(2 * 1000);
-
     // Validate maintained compiled queries.
     vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
 
     // Close clients
-
     vm1.invoke("closeClient", () -> closeClient());
     vm2.invoke("closeClient", () -> closeClient());
 
@@ -1261,8 +1247,6 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
   @Category(FlakyTest.class) // GEODE-1146: time senstiive, thread sleeps, uses zero port for servers (good!), async actions, AsyncInvocation orphans
   public void testBindParamsWithMulitipleClients() throws CacheException {
 
-    final String name = this.getName();
-
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
@@ -1298,7 +1282,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     });
 
     // Create client region
-    final int port0 = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port0 = vm0.invoke("getCacheServerPort", () -> getCacheServerPort());
 
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
@@ -1324,7 +1308,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
         for (int j = 0; j < 5; j++) {
           for (int i = 0; i < 2; i++) {
             try {
-              LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
+              LogService.getLogger().info("### Executing Query :" + queryString[i]);
               Query query = qService.newQuery(queryString[i]);
               rs[0][0] = (SelectResults) query.execute(params[i]);
               Query query2 = qService.newQuery(querys[i]);
@@ -1333,37 +1317,17 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
             } catch (Exception e) {
               Assert.fail("Failed executing " + queryString[i], e);
             }
-            LogWriterUtils.getLogWriter().info("### Comparing results for Query :" + ((i + 1) * (j + 1)) + " : " + queryString[i]);
+            LogService.getLogger().info("### Comparing results for Query :" + ((i + 1) * (j + 1)) + " : " + queryString[i]);
             compareQueryResultsWithoutAndWithIndexes(rs, 1);
-            LogWriterUtils.getLogWriter().info("### Done Comparing results for Query :" + ((i + 1) * (j + 1)) + " : " + queryString[i]);
+            LogService.getLogger().info("### Done Comparing results for Query :" + ((i + 1) * (j + 1)) + " : " + queryString[i]);
           }
         }
       }
     };
 
-    vm1.invokeAsync(executeSameQueries);
-    vm2.invokeAsync(executeSameQueries);
-    vm3.invokeAsync(executeSameQueries);
-
-    // Wait till the query execution completes.
-    vm0.invoke("validate compiled query.", () -> {
-      long compiledQueryUsedCount = -1;
-      while (true) {
-        LogWriterUtils.getLogWriter().info("### CompiledQueryUsedCount :" + compiledQueryUsedCount);
-        if (compiledQueryUsedCount == CacheClientNotifier.getInstance().getStats().getCompiledQueryUsedCount()) {
-          LogWriterUtils.getLogWriter().info("### previous and current CompiledQueryUsedCounts are same :" + compiledQueryUsedCount);
-          break;
-        } else {
-          compiledQueryUsedCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryUsedCount();
-          try {
-            Thread.currentThread().sleep(3 * 1000);
-          } catch (Exception ex) {
-            break;
-          }
-        }
-      }
-      return 0;
-    });
+    vm1.invoke("executeSameQueries", () -> executeSameQueries);
+    vm2.invoke("executeSameQueries", () -> executeSameQueries);
+    vm3.invoke("executeSameQueries", () -> executeSameQueries);
 
     // Execute client queries and validate results.
     SerializableRunnable executeQueries = new CacheSerializableRunnable("Execute queries") {
@@ -1379,7 +1343,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
         for (int j = 0; j < queryString.length; j++) {
           for (int i = 0; i < queryString.length; i++) {
             try {
-              LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
+              LogService.getLogger().info("### Executing Query :" + queryString[i]);
               Query query = qService.newQuery(queryString[i]);
               rs[0][0] = (SelectResults) query.execute(params[i]);
               Query query2 = qService.newQuery(querys[i]);
@@ -1394,29 +1358,9 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       }
     };
 
-    vm1.invokeAsync("executeQueries", () -> executeQueries);
-    vm2.invokeAsync("executeQueries", () -> executeQueries);
-    vm3.invokeAsync("executeQueries", () -> executeQueries);
-
-    // Wait till the query execution completes.
-    vm0.invoke("validate compiled query.", () -> {
-      long compiledQueryUsedCount = -1;
-      while (true) {
-        LogWriterUtils.getLogWriter().info("### previous CompiledQueryUsedCount :" + compiledQueryUsedCount);
-        if (compiledQueryUsedCount == CacheClientNotifier.getInstance().getStats().getCompiledQueryUsedCount()) {
-          LogWriterUtils.getLogWriter().info("### previous and current CompiledQueryUsedCounts are same :" + compiledQueryUsedCount);
-          break;
-        } else {
-          compiledQueryUsedCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryUsedCount();
-          try {
-            Thread.currentThread().sleep(3 * 1000);
-          } catch (Exception ex) {
-            break;
-          }
-        }
-      }
-      return 0;
-    });
+    vm1.invoke("executeQueries", () -> executeQueries);
+    vm2.invoke("executeQueries", () -> executeQueries);
+    vm3.invoke("executeQueries", () -> executeQueries);
 
     vm1.invoke("closeClient", () -> closeClient());
     vm2.invoke("closeClient", () -> closeClient());
@@ -1448,7 +1392,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       factory.setScope(Scope.LOCAL);
       createRegion(name + "1", factory.create());
       createRegion(name + "2", factory.create());
-      Wait.pause(1000);
+      //      Wait.pause(1000);
       try {
         startBridgeServer(0, false);
       } catch (Exception ex) {
@@ -1540,7 +1484,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       AttributesFactory factory = new AttributesFactory();
       factory.setScope(Scope.LOCAL);
       createRegion(name, factory.create());
-      Wait.pause(1000);
+      //      Wait.pause(1000);
       try {
         startBridgeServer(0, false);
       } catch (Exception ex) {
@@ -1556,7 +1500,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       }
     });
 
-    final int port = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("getCacheServerPort", () -> getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
     final String regionName = "/" + rootRegionName + "/" + name;
@@ -1663,8 +1607,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       Properties config = new Properties();
       config.setProperty("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
       getSystem(config);
-
-      Wait.pause(1000);
+      //      Wait.pause(1000);
       try {
         startBridgeServer(0, false);
       } catch (Exception ex) {
@@ -1684,7 +1627,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
         }
 
       });
-      Wait.pause(1000);
+      //      Wait.pause(1000);
       for (int i = 0; i < numberOfEntries; i++) {
         region1.put("key-" + i, new TestObject(i, "ibm"));
         region2.put("key-" + i, new TestObject(i, "ibm"));
@@ -1750,7 +1693,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       AttributesFactory factory = new AttributesFactory();
       factory.setScope(Scope.LOCAL);
       createRegion(name, factory.create());
-      Wait.pause(1000);
+      //      Wait.pause(1000);
       try {
         startBridgeServer(0, false);
       } catch (Exception ex) {
@@ -1892,8 +1835,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       Properties config = new Properties();
       config.setProperty("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
       getSystem(config);
-
-      Wait.pause(1000);
+      //      Wait.pause(1000);
       try {
         startBridgeServer(0, false);
       } catch (Exception ex) {
@@ -1923,9 +1865,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
 
     // Execute client queries in VM1      
     vm1.invoke("Execute queries", () -> {
-      AttributesFactory factory = new AttributesFactory();
-      factory.setScope(Scope.LOCAL);
-      final Region region1 = createRegion(name, factory.createRegionAttributes());
+      final Region region1 = ((ClientCache) getCache()).createClientRegionFactory(ClientRegionShortcut.LOCAL).create(name);
 
       String queryString = "select distinct * from " + regionName1 + " where ticker = $1";
       Object[] params = new Object[] { new String("ibm") };
@@ -2026,15 +1966,15 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       type1 = ((SelectResults) r[j][0]).getCollectionType().getElementType();
       type2 = ((SelectResults) r[j][1]).getCollectionType().getElementType();
       if ((type1.getClass().getName()).equals(type2.getClass().getName())) {
-        LogWriterUtils.getLogWriter().info("Both SelectResults are of the same Type i.e.--> "
+        LogService.getLogger().info("Both SelectResults are of the same Type i.e.--> "
             + ((SelectResults) r[j][0]).getCollectionType().getElementType());
       } else {
-        LogWriterUtils.getLogWriter().info("Classes are : " + type1.getClass().getName() + " "
+        LogService.getLogger().info("Classes are : " + type1.getClass().getName() + " "
             + type2.getClass().getName());
         fail("FAILED:Select result Type is different in both the cases");
       }
       if (((SelectResults) r[j][0]).size() == ((SelectResults) r[j][1]).size()) {
-        LogWriterUtils.getLogWriter().info("Both SelectResults are of Same Size i.e.  Size= "
+        LogService.getLogger().info("Both SelectResults are of Same Size i.e.  Size= "
             + ((SelectResults) r[j][1]).size());
       } else {
         fail("FAILED:SelectResults size is different in both the cases. Size1="
@@ -2044,7 +1984,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
       set2 = (((SelectResults) r[j][1]).asSet());
       set1 = (((SelectResults) r[j][0]).asSet());
 
-      LogWriterUtils.getLogWriter().info(" SIZE1 = " + set1.size() + " SIZE2 = " + set2.size());
+      LogService.getLogger().info(" SIZE1 = " + set1.size() + " SIZE2 = " + set2.size());
 
       //      boolean pass = true;
       itert1 = set1.iterator();
@@ -2054,10 +1994,10 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
 
         boolean exactMatch = false;
         while (itert2.hasNext()) {
-          LogWriterUtils.getLogWriter().info("### Comparing results..");
+          LogService.getLogger().info("### Comparing results..");
           Object p2 = itert2.next();
           if (p1 instanceof Struct) {
-            LogWriterUtils.getLogWriter().info("ITS a Set");
+            LogService.getLogger().info("ITS a Set");
             Object[] values1 = ((Struct) p1).getFieldValues();
             Object[] values2 = ((Struct) p2).getFieldValues();
             assertEquals(values1.length, values2.length);
@@ -2069,26 +2009,26 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
             }
             exactMatch = elementEqual;
           } else {
-            LogWriterUtils.getLogWriter().info("Not a Set p2:" + p2 + " p1: " + p1);
+            LogService.getLogger().info("Not a Set p2:" + p2 + " p1: " + p1);
             if (p2 instanceof TestObject) {
-              LogWriterUtils.getLogWriter().info("An instance of TestObject");
+              LogService.getLogger().info("An instance of TestObject");
               exactMatch = p2.equals(p1);
             } else {
-              LogWriterUtils.getLogWriter().info("Not an instance of TestObject" + p2.getClass().getCanonicalName());
+              LogService.getLogger().info("Not an instance of TestObject" + p2.getClass().getCanonicalName());
               exactMatch = p2.equals(p1);
             }
           }
           if (exactMatch) {
-            LogWriterUtils.getLogWriter().info("Exact MATCH");
+            LogService.getLogger().info("Exact MATCH");
             break;
           }
         }
         if (!exactMatch) {
-          LogWriterUtils.getLogWriter().info("NOT A MATCH");
+          LogService.getLogger().info("NOT A MATCH");
           fail("Atleast one element in the pair of SelectResults supposedly identical, is not equal ");
         }
       }
-      LogWriterUtils.getLogWriter().info("### Done Comparing results..");
+      LogService.getLogger().info("### Done Comparing results..");
     }
   }
 
@@ -2099,7 +2039,7 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     AttributesFactory factory = new AttributesFactory();
     factory.setScope(Scope.LOCAL);
     createRegion(this.regionName, this.rootRegionName, factory.create());
-    Wait.pause(1000);
+    //    Wait.pause(1000);
     try {
       startBridgeServer(0, false);
     } catch (Exception ex) {
@@ -2118,9 +2058,9 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
 
     for (int i = 0; i < queryString.length; i++) {
       try {
-        LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
+        LogService.getLogger().info("### Executing Query :" + queryString[i]);
         Query query = qService.newQuery(queryString[i]);
-        SelectResults results = (SelectResults) query.execute(params[i]);
+        query.execute(params[i]);
       } catch (Exception e) {
         Assert.fail("Failed executing " + queryString[i], e);
       }
@@ -2154,13 +2094,13 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
 
   /* Close Client */
   public void closeClient() {
-    LogWriterUtils.getLogWriter().info("### Close Client. ###");
+    LogService.getLogger().info("### Close Client. ###");
     try {
       closeCache();
     } catch (Exception ex) {
-      LogWriterUtils.getLogWriter().info("### Failed to get close client. ###");
+      LogService.getLogger().info("### Failed to get close client. ###");
     }
-    Wait.pause(2 * 1000);
+    //    Wait.pause(2 * 1000);
   }
 
   private static int getCacheServerPort() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2c2caae9/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java
index 6a719ab..fe63813 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java
@@ -23,7 +23,9 @@ import java.io.PrintWriter;
 import java.util.Arrays;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.TimeUnit;
 
+import com.jayway.awaitility.Awaitility;
 import org.apache.logging.log4j.Logger;
 
 import com.gemstone.gemfire.cache.AttributesFactory;
@@ -109,6 +111,8 @@ public class JUnit4CacheTestCase extends JUnit4DistributedTestCase implements Ca
         System.setProperty("gemfire.DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE", "true");
         Cache newCache;
         if (client) {
+          System.setProperty("gemfire.locators", "");
+          System.setProperty("gemfire.mcast-port", "0");
           newCache = (Cache)new ClientCacheFactory(getSystem().getProperties()).create();
         } else {
           if(factory == null) {
@@ -240,16 +244,9 @@ public class JUnit4CacheTestCase extends JUnit4DistributedTestCase implements Ca
       final GemFireCacheImpl gemFireCache = GemFireCacheImpl.getInstance();
       if (gemFireCache != null && !gemFireCache.isClosed()
               && gemFireCache.getCancelCriterion().cancelInProgress() != null) {
-        Wait.waitForCriterion(new WaitCriterion() { // TODO: replace with Awaitility
-          @Override
-          public boolean done() {
-            return gemFireCache.isClosed();
-          }
-          @Override
-          public String description() {
-            return "waiting for cache to close";
-          }
-        }, 30 * 1000, 300, true);
+        Awaitility.await().pollDelay(100, TimeUnit.MILLISECONDS)
+            .pollInterval(100,TimeUnit.MILLISECONDS).timeout(60,TimeUnit.SECONDS)
+            .until(() -> gemFireCache.isClosed());
       }
       if (cache == null || cache.isClosed()) {
         cache = null;


[24/36] incubator-geode git commit: GEODE-1375 When using multicast a new member needs to receive the multicast message digest

Posted by hi...@apache.org.
GEODE-1375 When using multicast a new member needs to receive the multicast message digest

This reinstates the sending of JoinResponseMessages so that the new member
can get the jgroups multicast digest.  The JoinResponseMessages are sent
after installing the new membership view, so JGroupsMessenger has been
changed to use MERGE_VIEW instead of SET_VIEW to install the digest since
it may have already received multicast messages from some members.


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

Branch: refs/heads/feature/GEODE-1372
Commit: 6dd3a580ffb68331c9c45b3e311d7f31c4cfca05
Parents: 96c67d4
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Wed May 11 15:26:08 2016 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Wed May 11 15:27:41 2016 -0700

----------------------------------------------------------------------
 .../membership/gms/membership/GMSJoinLeave.java |  17 +-
 .../gms/messenger/JGroupsMessenger.java         |  10 +-
 .../membership/gms/messenger/jgroups-mcast.xml  | 194 +++++++++----------
 .../gms/membership/GMSJoinLeaveJUnitTest.java   |   2 +-
 4 files changed, 118 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6dd3a580/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 88e4d49..41ec1ea 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -750,6 +750,13 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     return newView;
   }
 
+  private void sendJoinResponses(NetView newView, List<InternalDistributedMember> newMbrs) {
+    for (InternalDistributedMember mbr : newMbrs) {
+      JoinResponseMessage response = new JoinResponseMessage(mbr, newView);
+      services.getMessenger().send(response);
+    }
+  }
+
   private void sendRemoveMessages(List<InternalDistributedMember> removals, List<String> reasons, NetView newView, Set<InternalDistributedMember> oldIds) {
     Iterator<String> reason = reasons.iterator();
     for (InternalDistributedMember mbr : removals) {
@@ -1128,8 +1135,10 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
    */
   private void processJoinResponse(JoinResponseMessage rsp) {
     synchronized (joinResponse) {
-      joinResponse[0] = rsp;
-      joinResponse.notifyAll();
+      if (!this.isJoined) {
+        joinResponse[0] = rsp;
+        joinResponse.notifyAll();
+      }
     }
   }
 
@@ -2258,6 +2267,10 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
 
       sendView(newView, joinReqs);
 
+      // we also send a join response so that information like the multicast message digest
+      // can be transmitted to the new members w/o including it in the view message
+      sendJoinResponses(newView, joinReqs);
+
       if (markViewCreatorForShutdown && getViewCreator() != null) {
         shutdown = true;
       }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6dd3a580/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index 4a54e84..0460964 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -140,7 +140,7 @@ public class JGroupsMessenger implements Messenger {
    * reduces the amount of suspect processing initiated by IOExceptions and the
    * amount of exceptions logged
    */
-  private Set<Address> addressesWithioExceptionsProcessed = Collections.synchronizedSet(new HashSet<Address>());
+  private Set<Address> addressesWithIoExceptionsProcessed = Collections.synchronizedSet(new HashSet<Address>());
   
   static {
     // register classes that we've added to jgroups that are put on the wire
@@ -376,7 +376,7 @@ public class JGroupsMessenger implements Messenger {
     logger.trace("installing JGroups view: {}", jgv);
     this.myChannel.down(new Event(Event.VIEW_CHANGE, jgv));
 
-    addressesWithioExceptionsProcessed.clear();
+    addressesWithIoExceptionsProcessed.clear();
   }
   
 
@@ -390,10 +390,10 @@ public class JGroupsMessenger implements Messenger {
     if (services.getManager().shutdownInProgress()) { // GEODE-634 - don't log IOExceptions during shutdown
       return;
     }
-    if (addressesWithioExceptionsProcessed.contains(dest)) {
+    if (addressesWithIoExceptionsProcessed.contains(dest)) {
       return;
     }
-    addressesWithioExceptionsProcessed.add(dest);
+    addressesWithIoExceptionsProcessed.add(dest);
     NetView v = this.view;
     JGAddress jgMbr = (JGAddress)dest;
     if (jgMbr != null && v != null) {
@@ -952,7 +952,7 @@ public class JGroupsMessenger implements Messenger {
           if (digest != null) {
             logger.trace("installing JGroups message digest {}", digest);
             this.myChannel.getProtocolStack()
-                .getTopProtocol().down(new Event(Event.SET_DIGEST, digest));
+                .getTopProtocol().down(new Event(Event.MERGE_DIGEST, digest));
             jrsp.setMessengerData(null);
           }
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6dd3a580/geode-core/src/main/resources/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/jgroups-mcast.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/main/resources/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/jgroups-mcast.xml b/geode-core/src/main/resources/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/jgroups-mcast.xml
index c71f972..69048d9 100755
--- a/geode-core/src/main/resources/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/jgroups-mcast.xml
+++ b/geode-core/src/main/resources/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/jgroups-mcast.xml
@@ -1,98 +1,98 @@
-<!--
-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.
--->
-<config xmlns="urn:org:jgroups"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups.xsd">
-<com.gemstone.gemfire.distributed.internal.membership.gms.messenger.Transport
-  BIND_ADDR_SETTING
-  bind_port="MEMBERSHIP_PORT_RANGE_START"
-  port_range="MEMBERSHIP_PORT_RANGE"
-
-  mcast_addr="MCAST_ADDRESS"
-  mcast_port="MCAST_PORT"
-  tos="16"
-  ip_mcast="true"
-  ip_ttl="MCAST_TTL"
-  
-  ucast_recv_buf_size="UDP_RECV_BUFFER_SIZE"
-  ucast_send_buf_size="UDP_SEND_BUFFER_SIZE"
-  mcast_recv_buf_size="MCAST_RECV_BUFFER_SIZE"
-  mcast_send_buf_size="MCAST_SEND_BUFFER_SIZE"
-
-  enable_batching="false"
-  ignore_dont_bundle="false"
-  max_bundle_timeout="30"
-  
-  thread_naming_pattern="UDP Message Handler"
-  enable_diagnostics="false"
-  disable_loopback="false"
-  
-  timer_type="new3"
-  timer.min_threads="1"
-  timer.max_threads="4"
-  timer.keep_alive_time="3000"
-  timer.queue_max_size="500"
-
-  thread_pool.enabled="false"
-  thread_pool.min_threads="1"
-  thread_pool.max_threads="4"
-  thread_pool.keep_alive_time="5000"
-  thread_pool.queue_enabled="true"
-  thread_pool.queue_max_size="10000"
-  thread_pool.rejection_policy="discard"
-
-  oob_thread_pool.enabled="false"
-  oob_thread_pool.min_threads="1"
-  oob_thread_pool.max_threads="4"
-  oob_thread_pool.keep_alive_time="5000"
-  oob_thread_pool.queue_enabled="false"
-  oob_thread_pool.queue_max_size="100"
-  oob_thread_pool.rejection_policy="discard"/>
-
-<com.gemstone.gemfire.distributed.internal.membership.gms.messenger.AddressManager/>
-<com.gemstone.gemfire.distributed.internal.membership.gms.messenger.StatRecorder/>
-
-<pbcast.NAKACK2
-  xmit_interval="MCAST_RETRANSMIT_INTERVAL"
-  xmit_table_num_rows="100"
-  xmit_table_msgs_per_row="2000"
-  xmit_table_max_compaction_time="30000"
-  max_msg_batch_size="500"
-  use_mcast_xmit="false"
-  discard_delivered_msgs="true"/>
-<UNICAST3
-  xmit_interval="500"
-  xmit_table_num_rows="100"
-  xmit_table_msgs_per_row="2000"
-  xmit_table_max_compaction_time="60000"
-  conn_expiry_timeout="0"
-  max_msg_batch_size="500"/>
-<pbcast.STABLE
-  stability_delay="50"
-  desired_avg_gossip="2000"
-  max_bytes="400000"/>
-<UFC
-  max_credits="FC_MAX_CREDITS"
-  min_threshold="FC_THRESHOLD"
-  max_block_time="FC_MAX_BLOCK"/>
-<MFC
-  max_credits="FC_MAX_CREDITS"
-  min_threshold="FC_THRESHOLD"
-  max_block_time="FC_MAX_BLOCK"/>
-<FRAG2
-  frag_size="UDP_FRAGMENT_SIZE"/>
+<!--
+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.
+-->
+<config xmlns="urn:org:jgroups"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups.xsd">
+<com.gemstone.gemfire.distributed.internal.membership.gms.messenger.Transport
+  BIND_ADDR_SETTING
+  bind_port="MEMBERSHIP_PORT_RANGE_START"
+  port_range="MEMBERSHIP_PORT_RANGE"
+
+  mcast_addr="MCAST_ADDRESS"
+  mcast_port="MCAST_PORT"
+  tos="16"
+  ip_mcast="true"
+  ip_ttl="MCAST_TTL"
+  
+  ucast_recv_buf_size="UDP_RECV_BUFFER_SIZE"
+  ucast_send_buf_size="UDP_SEND_BUFFER_SIZE"
+  mcast_recv_buf_size="MCAST_RECV_BUFFER_SIZE"
+  mcast_send_buf_size="MCAST_SEND_BUFFER_SIZE"
+
+  enable_batching="false"
+  ignore_dont_bundle="false"
+  max_bundle_timeout="30"
+  
+  thread_naming_pattern="UDP Message Handler"
+  enable_diagnostics="false"
+  disable_loopback="false"
+  
+  timer_type="new3"
+  timer.min_threads="1"
+  timer.max_threads="4"
+  timer.keep_alive_time="3000"
+  timer.queue_max_size="500"
+
+  thread_pool.enabled="false"
+  thread_pool.min_threads="1"
+  thread_pool.max_threads="4"
+  thread_pool.keep_alive_time="5000"
+  thread_pool.queue_enabled="true"
+  thread_pool.queue_max_size="10000"
+  thread_pool.rejection_policy="discard"
+
+  oob_thread_pool.enabled="false"
+  oob_thread_pool.min_threads="1"
+  oob_thread_pool.max_threads="4"
+  oob_thread_pool.keep_alive_time="5000"
+  oob_thread_pool.queue_enabled="false"
+  oob_thread_pool.queue_max_size="100"
+  oob_thread_pool.rejection_policy="discard"/>
+
+<com.gemstone.gemfire.distributed.internal.membership.gms.messenger.AddressManager/>
+<com.gemstone.gemfire.distributed.internal.membership.gms.messenger.StatRecorder/>
+
+<pbcast.NAKACK2
+  xmit_interval="MCAST_RETRANSMIT_INTERVAL"
+  xmit_table_num_rows="100"
+  xmit_table_msgs_per_row="2000"
+  xmit_table_max_compaction_time="30000"
+  max_msg_batch_size="500"
+  use_mcast_xmit="false"
+  discard_delivered_msgs="true"/>
+<UNICAST3
+  xmit_interval="500"
+  xmit_table_num_rows="100"
+  xmit_table_msgs_per_row="2000"
+  xmit_table_max_compaction_time="60000"
+  conn_expiry_timeout="0"
+  max_msg_batch_size="500"/>
+<pbcast.STABLE
+  stability_delay="50"
+  desired_avg_gossip="2000"
+  max_bytes="400000"/>
+<UFC
+  max_credits="FC_MAX_CREDITS"
+  min_threshold="FC_THRESHOLD"
+  max_block_time="FC_MAX_BLOCK"/>
+<MFC
+  max_credits="FC_MAX_CREDITS"
+  min_threshold="FC_THRESHOLD"
+  max_block_time="FC_MAX_BLOCK"/>
+<FRAG2
+  frag_size="UDP_FRAGMENT_SIZE"/>
 </config>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6dd3a580/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
old mode 100644
new mode 100755
index 50bed13..1e1724d
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
@@ -1128,7 +1128,7 @@ public class GMSJoinLeaveJUnitTest {
       }
        
       Thread.sleep(1000);
-      System.out.println("Empty sleeps " + sleeps +  " stoppping: " + gmsJoinLeave.isStopping() );
+      System.out.println("Empty sleeps " + sleeps +  " stopping: " + gmsJoinLeave.isStopping() );
     }
   }
   


[08/36] incubator-geode git commit: GEODE-364: Amending Pool configuration to avoid the changing of connections, which could cause the test to fail.

Posted by hi...@apache.org.
GEODE-364: Amending Pool configuration to avoid the changing of connections, which could cause the test to fail.


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

Branch: refs/heads/feature/GEODE-1372
Commit: bcf7c94fb8247754eb2d73749d05be3a5011624c
Parents: f93c87f
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Wed May 11 05:47:10 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Wed May 11 05:51:44 2016 +1000

----------------------------------------------------------------------
 .../internal/cache/SingleHopStatsDUnitTest.java | 448 ++++++++-----------
 1 file changed, 198 insertions(+), 250 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bcf7c94f/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SingleHopStatsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SingleHopStatsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SingleHopStatsDUnitTest.java
index 307f18f..671bdf7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SingleHopStatsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SingleHopStatsDUnitTest.java
@@ -16,20 +16,8 @@
  */
 package com.gemstone.gemfire.internal.cache;
 
-import java.io.IOException;
-import java.util.Map;
-import java.util.Properties;
-
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.cache.AttributesFactory;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.PartitionAttributesFactory;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionAttributes;
-import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.cache.client.ClientCache;
 import com.gemstone.gemfire.cache.client.Pool;
 import com.gemstone.gemfire.cache.client.PoolManager;
 import com.gemstone.gemfire.cache.client.internal.ClientMetadataService;
@@ -37,71 +25,43 @@ import com.gemstone.gemfire.cache.client.internal.ClientPartitionAdvisor;
 import com.gemstone.gemfire.cache.server.CacheServer;
 import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.distributed.Locator;
-import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.cache.execute.data.CustId;
 import com.gemstone.gemfire.internal.cache.execute.data.OrderId;
 import com.gemstone.gemfire.internal.cache.execute.data.ShipmentId;
 import com.gemstone.gemfire.internal.cache.tier.sockets.CacheServerTestUtil;
-import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.Invoke;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
-import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.*;
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import com.jayway.awaitility.Awaitility;
+import org.junit.experimental.categories.Category;
 
-public class SingleHopStatsDUnitTest extends CacheTestCase {
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
 
-  private static final String Region_Name = "42010";
+public class SingleHopStatsDUnitTest extends CacheTestCase {
 
+  private final String Region_Name = "42010";
+  private final String ORDER_REGION_NAME = "ORDER";
+  private final String SHIPMENT_REGION_NAME = "SHIPMENT";
+  private final String CUSTOMER_REGION_NAME = "CUSTOMER";
   private VM member0 = null;
-
   private VM member1 = null;
-
   private VM member2 = null;
-
   private VM member3 = null;
 
-  private static Region region = null;
-
-  private static Region customerRegion = null;
-
-  private static Region orderRegion = null;
-
-  private static Region shipmentRegion = null;
-
-  private static Region regionWithResolver = null;
-
-  private static Cache cache = null;
-
-  private static final int locatorPort = 12345;
-
-  private static Locator locator = null;
-  
   private static long metaDataRefreshCount;
-  
   private static long nonSingleHopsCount;
-  
   private static long metaDataRefreshCount_Customer;
-  
   private static long nonSingleHopsCount_Customer;
-  
   private static long metaDataRefreshCount_Order;
-  
   private static long nonSingleHopsCount_Order;
-  
   private static long metaDataRefreshCount_Shipment;
-  
   private static long nonSingleHopsCount_Shipment;
-  
+
+
   public SingleHopStatsDUnitTest(String name) {
     super(name);
-
-    // TODO Auto-generated constructor stub
   }
 
   @Override
@@ -116,13 +76,13 @@ public class SingleHopStatsDUnitTest extends CacheTestCase {
   @Override
   public final void preTearDownCacheTestCase() throws Exception {
     // close the clients first
-    member0.invoke(() -> SingleHopStatsDUnitTest.closeCacheAndDisconnect());
-    member1.invoke(() -> SingleHopStatsDUnitTest.closeCacheAndDisconnect());
-    member2.invoke(() -> SingleHopStatsDUnitTest.closeCacheAndDisconnect());
-    member3.invoke(() -> SingleHopStatsDUnitTest.closeCacheAndDisconnect());
+    member0.invoke(() -> closeCacheAndDisconnect());
+    member1.invoke(() -> closeCacheAndDisconnect());
+    member2.invoke(() -> closeCacheAndDisconnect());
+    member3.invoke(() -> closeCacheAndDisconnect());
     closeCacheAndDisconnect();
   }
-  
+
   @Override
   public final void postTearDownCacheTestCase() throws Exception {
     try {
@@ -130,104 +90,95 @@ public class SingleHopStatsDUnitTest extends CacheTestCase {
       member1 = null;
       member2 = null;
       member3 = null;
-      cache = null;
-      Invoke.invokeInEveryVM(new SerializableRunnable() { public void run() { cache = null; } });
-
-    }
-    finally {
+    } finally {
       DistributedTestUtils.unregisterAllDataSerializersFromAllVms();
     }
   }
 
-  public static void closeCacheAndDisconnect() {
-    if (cache != null && !cache.isClosed()) {
-      cache.close();
-      cache.getDistributedSystem().disconnect();
+  private void closeCacheAndDisconnect() {
+    try {
+      Cache cache = CacheFactory.getAnyInstance();
+      if (cache != null && !cache.isClosed()) {
+        cache.close();
+        cache.getDistributedSystem().disconnect();
+      }
+    } catch (CacheClosedException e) {
     }
   }
 
   @Category(FlakyTest.class) // GEODE-364: random ports, time sensitive, waitForCriterions, magic numbers (113, 226)
   public void testClientStatsPR() {
-    VM server1 = member0;
-    VM server2 = member1;
-    VM server3 = member2;
-    VM client1 = member3;
-    
-    Integer port0 = (Integer)member0.invoke(() -> SingleHopStatsDUnitTest.createServerForStats( 0, 113,"No_Colocation"));
-    Integer port1 = (Integer)member1.invoke(() -> SingleHopStatsDUnitTest.createServerForStats( 0, 113,"No_Colocation"));
-    Integer port2 = (Integer)member2.invoke(() -> SingleHopStatsDUnitTest.createServerForStats( 0, 113,"No_Colocation"));
-     client1.invoke(() -> SingleHopStatsDUnitTest.createClient(port0, port1, port2,"No_Colocation"));
-     
+    Integer port0 = (Integer) member0.invoke(() -> createServerForStats(0, 113, "No_Colocation"));
+    Integer port1 = (Integer) member1.invoke(() -> createServerForStats(0, 113, "No_Colocation"));
+    Integer port2 = (Integer) member2.invoke(() -> createServerForStats(0, 113, "No_Colocation"));
+
+    member3.invoke(() -> createClient(port0, port1, port2, "No_Colocation"));
     createClient(port0, port1, port2, "No_Colocation");
 
-    client1.invoke(() -> SingleHopStatsDUnitTest.createPR("FirstClient", "No_Colocation"));
+    member3.invoke(() -> createPR("FirstClient", "No_Colocation"));
     createPR("SecondClient", "No_Colocation");
-    
-    client1.invoke(() -> SingleHopStatsDUnitTest.getPR("FirstClient", "No_Colocation"));
+
+    member3.invoke(() -> getPR("FirstClient", "No_Colocation"));
     getPR("SecondClient", "No_Colocation");
-    
-    client1.invoke(() -> SingleHopStatsDUnitTest.updatePR("FirstClient", "No_Colocation"));
+
+    member3.invoke(() -> updatePR("FirstClient", "No_Colocation"));
   }
-  
-  public void testClientStatsColocationPR(){
-    VM server1 = member0;
-    VM server2 = member1;
-    VM server3 = member2;
-    VM client1 = member3;
-    
-    Integer port0 = (Integer)member0.invoke(() -> SingleHopStatsDUnitTest.createServerForStats( 0, 4, "Colocation" ));
-    Integer port1 = (Integer)member1.invoke(() -> SingleHopStatsDUnitTest.createServerForStats( 0, 4, "Colocation" ));
-    Integer port2 = (Integer)member2.invoke(() -> SingleHopStatsDUnitTest.createServerForStats( 0, 4, "Colocation"));
-     client1.invoke(() -> SingleHopStatsDUnitTest.createClient(port0, port1, port2, "Colocation"));
+
+  public void testClientStatsColocationPR() {
+    Integer port0 = (Integer) member0.invoke(() -> createServerForStats(0, 4, "Colocation"));
+    Integer port1 = (Integer) member1.invoke(() -> createServerForStats(0, 4, "Colocation"));
+    Integer port2 = (Integer) member2.invoke(() -> createServerForStats(0, 4, "Colocation"));
+    member3.invoke(() -> createClient(port0, port1, port2, "Colocation"));
     createClient(port0, port1, port2, "Colocation");
 
-    client1.invoke(() -> SingleHopStatsDUnitTest.createPR("FirstClient", "Colocation"));
-    
-    client1.invoke(() -> SingleHopStatsDUnitTest.getPR("FirstClient", "Colocation"));
+    member3.invoke(() -> createPR("FirstClient", "Colocation"));
+
+    member3.invoke(() -> getPR("FirstClient", "Colocation"));
   }
 
-  
-  public static void createClient(int port0, int port1, int port2, String colocation) {
+  private void createClient(int port0, int port1, int port2, String colocation) {
     Properties props = new Properties();
     props = new Properties();
     props.setProperty("mcast-port", "0");
     props.setProperty("locators", "");
     CacheTestCase test = new SingleHopStatsDUnitTest(
         "SingleHopStatsDUnitTest");
-    DistributedSystem ds = test.getSystem(props);
-    cache = CacheFactory.create(ds);
+    DistributedSystem distributedSystem = test.getSystem(props);
+    Cache cache = CacheFactory.create(distributedSystem);
     assertNotNull(cache);
     CacheServerTestUtil.disableShufflingOfEndpoints();
     Pool p;
     try {
-      p = PoolManager.createFactory().addServer("localhost", port0).addServer(
-          "localhost", port1).addServer("localhost", port2)
+      p = PoolManager.createFactory().addServer("localhost", port0)
+          .addServer("localhost", port1).addServer("localhost", port2)
+          .setRetryAttempts(5)
+          .setMinConnections(1)
+          .setMaxConnections(1)
           .setSubscriptionEnabled(false)
           .create(Region_Name);
-    }
-    finally {
+    } finally {
       CacheServerTestUtil.enableShufflingOfEndpoints();
     }
-    createRegionInClientCache(p.getName(), colocation);
+    createRegionInClientCache(p.getName(), colocation, cache);
   }
 
-  public static int createServerForStats(int redundantCopies, int totalNoofBuckets, String colocation) {
+  private int createServerForStats(int redundantCopies, int totalNoofBuckets, String colocation) {
     CacheTestCase test = new SingleHopStatsDUnitTest(
         "SingleHopStatsDUnitTest");
-    cache = test.getCache();
+    Cache cache = test.getCache();
     CacheServer server = cache.addCacheServer();
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    server.setPort(port);
+    server.setPort(0);
     server.setHostnameForClients("localhost");
     try {
       server.start();
-    }
-    catch (IOException e) {
+    } catch (IOException e) {
       Assert.fail("Failed to start server ", e);
     }
 
+    Region region = null;
+
     if (colocation.equals("No_Colocation")) {
-      if(totalNoofBuckets == 0){ //DR
+      if (totalNoofBuckets == 0) { //DR
         AttributesFactory attr = new AttributesFactory();
         attr.setScope(Scope.DISTRIBUTED_ACK);
         attr.setDataPolicy(DataPolicy.REPLICATE);
@@ -236,27 +187,27 @@ public class SingleHopStatsDUnitTest extends CacheTestCase {
         LogWriterUtils.getLogWriter().info(
             "Distributed Region " + Region_Name + " created Successfully :"
                 + region.toString());
-      }else{
-      PartitionAttributesFactory paf = new PartitionAttributesFactory();
-      paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(
-          totalNoofBuckets);
-      AttributesFactory attr = new AttributesFactory();
-      attr.setPartitionAttributes(paf.create());
-      region = cache.createRegion(Region_Name, attr.create());
-      assertNotNull(region);
-      LogWriterUtils.getLogWriter().info(
-          "Partitioned Region " + Region_Name + " created Successfully :"
-              + region.toString());
+      } else {
+        PartitionAttributesFactory paf = new PartitionAttributesFactory();
+        paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(
+            totalNoofBuckets);
+        AttributesFactory attr = new AttributesFactory();
+        attr.setPartitionAttributes(paf.create());
+        region = cache.createRegion(Region_Name, attr.create());
+        assertNotNull(region);
+        LogWriterUtils.getLogWriter().info(
+            "Partitioned Region " + Region_Name + " created Successfully :"
+                + region.toString());
       }
-    }
-    else {
+    } else {
       PartitionAttributesFactory paf = new PartitionAttributesFactory();
       paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(
           totalNoofBuckets).setPartitionResolver(
-          new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
+          new CustomerIDPartitionResolver("CustomerIDPartitio"
+              + "nResolver"));
       AttributesFactory attr = new AttributesFactory();
       attr.setPartitionAttributes(paf.create());
-      customerRegion = cache.createRegion("CUSTOMER", attr.create());
+      Region customerRegion = cache.createRegion(CUSTOMER_REGION_NAME, attr.create());
       assertNotNull(customerRegion);
       LogWriterUtils.getLogWriter().info(
           "Partitioned Region CUSTOMER created Successfully :"
@@ -264,11 +215,11 @@ public class SingleHopStatsDUnitTest extends CacheTestCase {
 
       paf = new PartitionAttributesFactory();
       paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(
-          totalNoofBuckets).setColocatedWith("CUSTOMER").setPartitionResolver(
+          totalNoofBuckets).setColocatedWith(CUSTOMER_REGION_NAME).setPartitionResolver(
           new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
       attr = new AttributesFactory();
       attr.setPartitionAttributes(paf.create());
-      orderRegion = cache.createRegion("ORDER", attr.create());
+      Region orderRegion = cache.createRegion(ORDER_REGION_NAME, attr.create());
       assertNotNull(orderRegion);
       LogWriterUtils.getLogWriter().info(
           "Partitioned Region ORDER created Successfully :"
@@ -276,20 +227,21 @@ public class SingleHopStatsDUnitTest extends CacheTestCase {
 
       paf = new PartitionAttributesFactory();
       paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(
-          totalNoofBuckets).setColocatedWith("ORDER").setPartitionResolver(
+          totalNoofBuckets).setColocatedWith(ORDER_REGION_NAME).setPartitionResolver(
           new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
       attr = new AttributesFactory();
       attr.setPartitionAttributes(paf.create());
-      shipmentRegion = cache.createRegion("SHIPMENT", attr.create());
+      Region shipmentRegion = cache.createRegion(SHIPMENT_REGION_NAME, attr.create());
       assertNotNull(shipmentRegion);
       LogWriterUtils.getLogWriter().info(
           "Partitioned Region SHIPMENT created Successfully :"
               + shipmentRegion.toString());
     }
-    return port;
+    return server.getPort();
   }
-  
-  private static void createRegionInClientCache(String poolName, String colocation) {
+
+  private void createRegionInClientCache(String poolName, String colocation, Cache cache) {
+    Region region = null;
     if (colocation.equals("No_Colocation")) {
       AttributesFactory factory = new AttributesFactory();
       factory.setPoolName(poolName);
@@ -299,12 +251,11 @@ public class SingleHopStatsDUnitTest extends CacheTestCase {
       assertNotNull(region);
       LogWriterUtils.getLogWriter().info(
           "Region " + Region_Name + " created Successfully :" + region.toString());
-    }
-    else {
+    } else {
       AttributesFactory factory = new AttributesFactory();
       factory.setPoolName(poolName);
       RegionAttributes attrs = factory.create();
-      customerRegion = cache.createRegion("CUSTOMER", attrs);
+      Region customerRegion = cache.createRegion(CUSTOMER_REGION_NAME, attrs);
       assertNotNull(customerRegion);
       LogWriterUtils.getLogWriter().info(
           "Partitioned Region CUSTOMER created Successfully :"
@@ -313,7 +264,7 @@ public class SingleHopStatsDUnitTest extends CacheTestCase {
       factory = new AttributesFactory();
       factory.setPoolName(poolName);
       attrs = factory.create();
-      orderRegion = cache.createRegion("ORDER", attrs);
+      Region orderRegion = cache.createRegion(ORDER_REGION_NAME, attrs);
       assertNotNull(orderRegion);
       LogWriterUtils.getLogWriter().info(
           "Partitioned Region ORDER created Successfully :"
@@ -322,24 +273,27 @@ public class SingleHopStatsDUnitTest extends CacheTestCase {
       factory = new AttributesFactory();
       factory.setPoolName(poolName);
       attrs = factory.create();
-      shipmentRegion = cache.createRegion("SHIPMENT", attrs);
+      Region shipmentRegion = cache.createRegion("SHIPMENT", attrs);
       assertNotNull(shipmentRegion);
       LogWriterUtils.getLogWriter().info(
           "Partitioned Region SHIPMENT created Successfully :"
               + shipmentRegion.toString());
     }
   }
-  
-  public static void createPR(String fromClient,
-      String colocation) {
+
+  private void createPR(String fromClient, String colocation) {
+    GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
+    Region region = cache.getRegion(Region_Name);
+
+
     if (colocation.equals("No_Colocation")) {
       if (fromClient.equals("FirstClient")) {
-        
+
         System.out.println("first pass...");
         for (int i = 0; i < 113; i++) {
           region.create(new Integer(i), "create" + i);
         }
-        ClientMetadataService cms = ((GemFireCacheImpl)cache)
+        ClientMetadataService cms = ((GemFireCacheImpl) cache)
             .getClientMetadataService();
         final Map<String, ClientPartitionAdvisor> regionMetaData = cms
             .getClientPRMetadata_TEST_ONLY();
@@ -349,124 +303,121 @@ public class SingleHopStatsDUnitTest extends CacheTestCase {
         for (int i = 113; i < 226; i++) {
           region.create(new Integer(i), "create" + i);
         }
-        cms = ((GemFireCacheImpl)cache).getClientMetadataService();
+        cms = ((GemFireCacheImpl) cache).getClientMetadataService();
         // since PR metadata is fetched in a background executor thread
         // we need to wait for it to arrive for a bit
-        Wait.waitForCriterion(new WaitCriterion(){
-          public boolean done() {
-            return regionMetaData.size() == 1;
-          }
-          public String description() {
-            return "waiting for metadata to arrive: " + regionMetaData;
-          }
-          
-        }, 30000, 500, true);
+        Awaitility.await().timeout(120, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS)
+            .pollInterval(500, TimeUnit.MILLISECONDS).until(() -> {
+          return regionMetaData.size() == 1;
+        });
+
         assertTrue(regionMetaData.containsKey(region.getFullPath()));
-        ClientPartitionAdvisor prMetaData = regionMetaData.get(region
-            .getFullPath());
-        metaDataRefreshCount = ((LocalRegion)region).getCachePerfStats().getMetaDataRefreshCount();
-        nonSingleHopsCount = ((LocalRegion)region).getCachePerfStats().getNonSingleHopsCount();
+        regionMetaData.get(region.getFullPath());
+        metaDataRefreshCount = ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount();
+        nonSingleHopsCount = ((LocalRegion) region).getCachePerfStats().getNonSingleHopsCount();
         assertTrue(metaDataRefreshCount != 0); // hops are not predictable
         assertTrue(nonSingleHopsCount != 0);
-      }
-      else {
+      } else {
         for (int i = 0; i < 226; i++) {
           region.create(new Integer(i), "create" + i);
         }
-        ClientMetadataService cms = ((GemFireCacheImpl)cache)
+        ClientMetadataService cms = ((GemFireCacheImpl) cache)
             .getClientMetadataService();
         Map<String, ClientPartitionAdvisor> regionMetaData = cms
             .getClientPRMetadata_TEST_ONLY();
         assertEquals(1, regionMetaData.size());
         assertTrue(regionMetaData.containsKey(region.getFullPath()));
-        ClientPartitionAdvisor prMetaData = regionMetaData.get(region
-            .getFullPath());
-        metaDataRefreshCount = ((LocalRegion)region).getCachePerfStats().getMetaDataRefreshCount();
-        nonSingleHopsCount = ((LocalRegion)region).getCachePerfStats().getNonSingleHopsCount();
+
+        regionMetaData.get(region.getFullPath());
+        metaDataRefreshCount = ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount();
+        nonSingleHopsCount = ((LocalRegion) region).getCachePerfStats().getNonSingleHopsCount();
         assertTrue(metaDataRefreshCount != 0); // hops are not predictable
         assertTrue(nonSingleHopsCount != 0);
       }
+    } else {
+      createdColocatedPRData(cache);
     }
-    else {
-      for (int i = 0; i <= 20; i++) {
-        CustId custid = new CustId(i);
-        Customer customer = new Customer("name" + i, "Address" + i);
-        customerRegion.put(custid, customer);
-        for (int j = 1; j <= 10; j++) {
-          int oid = (i * 10) + j;
-          OrderId orderId = new OrderId(oid, custid);
-          Order order = new Order("OREDR" + oid);
-          orderRegion.put(orderId, order);
-          for (int k = 1; k <= 10; k++) {
-            int sid = (oid * 10) + k;
-            ShipmentId shipmentId = new ShipmentId(sid, orderId);
-            Shipment shipment = new Shipment("Shipment" + sid);
-            shipmentRegion.put(shipmentId, shipment);
-          }
+  }
+
+  private void createdColocatedPRData(GemFireCacheImpl cache) {
+    Region customerRegion = cache.getRegion(CUSTOMER_REGION_NAME);
+    Region orderRegion = cache.getRegion(ORDER_REGION_NAME);
+    Region shipmentRegion = cache.getRegion(SHIPMENT_REGION_NAME);
+    for (int i = 0; i <= 20; i++) {
+      CustId custid = new CustId(i);
+      Customer customer = new Customer("name" + i, "Address" + i);
+
+      customerRegion.put(custid, customer);
+      for (int j = 1; j <= 10; j++) {
+        int oid = (i * 10) + j;
+        OrderId orderId = new OrderId(oid, custid);
+        Order order = new Order(ORDER_REGION_NAME + oid);
+        orderRegion.put(orderId, order);
+        for (int k = 1; k <= 10; k++) {
+          int sid = (oid * 10) + k;
+          ShipmentId shipmentId = new ShipmentId(sid, orderId);
+          Shipment shipment = new Shipment("Shipment" + sid);
+          shipmentRegion.put(shipmentId, shipment);
         }
       }
-      ClientMetadataService cms = ((GemFireCacheImpl)cache)
-          .getClientMetadataService();
-      Map<String, ClientPartitionAdvisor> regionMetaData = cms
-          .getClientPRMetadata_TEST_ONLY();
-      assertEquals(3, regionMetaData.size());
-      assertTrue(regionMetaData.containsKey(customerRegion.getFullPath()));
-      ClientPartitionAdvisor prMetaData_Customer = regionMetaData
-          .get(customerRegion.getFullPath());
-      metaDataRefreshCount_Customer = ((LocalRegion)customerRegion).getCachePerfStats().getMetaDataRefreshCount();
-      nonSingleHopsCount_Customer = ((LocalRegion)customerRegion).getCachePerfStats().getNonSingleHopsCount();
-      assertTrue(metaDataRefreshCount_Customer != 0); // hops are not predictable
-      assertTrue(nonSingleHopsCount_Customer != 0);
-
-      ClientPartitionAdvisor prMetaData_Order = regionMetaData
-          .get(orderRegion.getFullPath());
-      metaDataRefreshCount_Order = ((LocalRegion)orderRegion).getCachePerfStats().getMetaDataRefreshCount();
-      nonSingleHopsCount_Order = ((LocalRegion)orderRegion).getCachePerfStats().getNonSingleHopsCount();
-      assertTrue(metaDataRefreshCount_Order == 0); 
-      assertTrue(nonSingleHopsCount_Order != 0);
-
-      ClientPartitionAdvisor prMetaData_Shipment = regionMetaData
-          .get(shipmentRegion.getFullPath());
-      metaDataRefreshCount_Shipment = ((LocalRegion)shipmentRegion).getCachePerfStats().getMetaDataRefreshCount();
-      nonSingleHopsCount_Shipment = ((LocalRegion)shipmentRegion).getCachePerfStats().getNonSingleHopsCount();
-      assertTrue(metaDataRefreshCount_Shipment == 0); 
-      assertTrue(nonSingleHopsCount_Shipment != 0);
     }
+    ClientMetadataService cms = cache.getClientMetadataService();
+    Map<String, ClientPartitionAdvisor> regionMetaData = cms
+        .getClientPRMetadata_TEST_ONLY();
+    assertEquals(3, regionMetaData.size());
+    assertTrue(regionMetaData.containsKey(customerRegion.getFullPath()));
+    regionMetaData.get(customerRegion.getFullPath());
+    metaDataRefreshCount_Customer = ((LocalRegion) customerRegion).getCachePerfStats().getMetaDataRefreshCount();
+    nonSingleHopsCount_Customer = ((LocalRegion) customerRegion).getCachePerfStats().getNonSingleHopsCount();
+    assertTrue(metaDataRefreshCount_Customer != 0); // hops are not predictable
+    assertTrue(nonSingleHopsCount_Customer != 0);
+
+    regionMetaData.get(orderRegion.getFullPath());
+    metaDataRefreshCount_Order = ((LocalRegion) orderRegion).getCachePerfStats().getMetaDataRefreshCount();
+    nonSingleHopsCount_Order = ((LocalRegion) orderRegion).getCachePerfStats().getNonSingleHopsCount();
+    assertTrue(metaDataRefreshCount_Order == 0);
+    assertTrue(nonSingleHopsCount_Order != 0);
+
+    regionMetaData.get(shipmentRegion.getFullPath());
+    metaDataRefreshCount_Shipment = ((LocalRegion) shipmentRegion).getCachePerfStats().getMetaDataRefreshCount();
+    nonSingleHopsCount_Shipment = ((LocalRegion) shipmentRegion).getCachePerfStats().getNonSingleHopsCount();
+    assertTrue(metaDataRefreshCount_Shipment == 0);
+    assertTrue(nonSingleHopsCount_Shipment != 0);
   }
-  
-  public static void getPR(String FromClient,
-      String colocation) {
+
+  private void getPR(String FromClient, String colocation) {
+    Cache cache = CacheFactory.getAnyInstance();
+    Region region = cache.getRegion(Region_Name);
+    Region customerRegion = cache.getRegion(CUSTOMER_REGION_NAME);
+    Region orderRegion = cache.getRegion(ORDER_REGION_NAME);
+    Region shipmentRegion = cache.getRegion("SHIPMENT");
     if (colocation.equals("No_Colocation")) {
       if (FromClient.equals("FirstClient")) {
         for (int i = 0; i < 226; i++) {
           region.get(new Integer(i));
         }
-        ClientMetadataService cms = ((GemFireCacheImpl)cache)
+        ClientMetadataService cms = ((GemFireCacheImpl) cache)
             .getClientMetadataService();
         Map<String, ClientPartitionAdvisor> regionMetaData = cms
             .getClientPRMetadata_TEST_ONLY();
         assertEquals(1, regionMetaData.size());
-        ClientPartitionAdvisor prMetaData = regionMetaData.get(region
-            .getFullPath());
-        assertEquals(metaDataRefreshCount , ((LocalRegion)region).getCachePerfStats().getMetaDataRefreshCount());
-        assertEquals(nonSingleHopsCount , ((LocalRegion)region).getCachePerfStats().getNonSingleHopsCount());
-      }
-      else {
+        regionMetaData.get(region.getFullPath());
+        assertEquals(metaDataRefreshCount, ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount());
+        assertEquals(nonSingleHopsCount, ((LocalRegion) region).getCachePerfStats().getNonSingleHopsCount());
+      } else {
         for (int i = 0; i < 226; i++) {
           region.get(new Integer(i));
         }
-        ClientMetadataService cms = ((GemFireCacheImpl)cache)
+        ClientMetadataService cms = ((GemFireCacheImpl) cache)
             .getClientMetadataService();
         Map<String, ClientPartitionAdvisor> regionMetaData = cms
             .getClientPRMetadata_TEST_ONLY();
         assertEquals(1, regionMetaData.size());
-        ClientPartitionAdvisor prMetaData = regionMetaData.get(region
-            .getFullPath());
-        assertEquals(metaDataRefreshCount , ((LocalRegion)region).getCachePerfStats().getMetaDataRefreshCount());
-        assertEquals(nonSingleHopsCount , ((LocalRegion)region).getCachePerfStats().getNonSingleHopsCount());
+        regionMetaData.get(region.getFullPath());
+        assertEquals(metaDataRefreshCount, ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount());
+        assertEquals(nonSingleHopsCount, ((LocalRegion) region).getCachePerfStats().getNonSingleHopsCount());
       }
-    }
-    else {
+    } else {
       for (int i = 0; i <= 20; i++) {
         CustId custid = new CustId(i);
         customerRegion.get(custid);
@@ -481,45 +432,42 @@ public class SingleHopStatsDUnitTest extends CacheTestCase {
           }
         }
       }
-      ClientMetadataService cms = ((GemFireCacheImpl)cache)
+      ClientMetadataService cms = ((GemFireCacheImpl) cache)
           .getClientMetadataService();
       Map<String, ClientPartitionAdvisor> regionMetaData = cms
           .getClientPRMetadata_TEST_ONLY();
       assertEquals(3, regionMetaData.size());
       assertTrue(regionMetaData.containsKey(customerRegion.getFullPath()));
-      ClientPartitionAdvisor prMetaData_Customer = regionMetaData
-          .get(customerRegion.getFullPath());
-      assertEquals(metaDataRefreshCount_Customer , ((LocalRegion)customerRegion).getCachePerfStats().getMetaDataRefreshCount());
-      assertEquals(nonSingleHopsCount_Customer , ((LocalRegion)customerRegion).getCachePerfStats().getNonSingleHopsCount());
-
-      ClientPartitionAdvisor prMetaData_Order = regionMetaData
-          .get(orderRegion.getFullPath());
-      assertEquals(metaDataRefreshCount_Order , ((LocalRegion)orderRegion).getCachePerfStats().getMetaDataRefreshCount());
-      assertEquals(nonSingleHopsCount_Order , ((LocalRegion)orderRegion).getCachePerfStats().getNonSingleHopsCount());
-
-      ClientPartitionAdvisor prMetaData_Shipment = regionMetaData
-          .get(shipmentRegion.getFullPath());
-      assertEquals(metaDataRefreshCount_Shipment , ((LocalRegion)shipmentRegion).getCachePerfStats().getMetaDataRefreshCount());
-      assertEquals(nonSingleHopsCount_Shipment , ((LocalRegion)shipmentRegion).getCachePerfStats().getNonSingleHopsCount());
+      regionMetaData.get(customerRegion.getFullPath());
+      assertEquals(metaDataRefreshCount_Customer, ((LocalRegion) customerRegion).getCachePerfStats().getMetaDataRefreshCount());
+      assertEquals(nonSingleHopsCount_Customer, ((LocalRegion) customerRegion).getCachePerfStats().getNonSingleHopsCount());
+
+      regionMetaData.get(orderRegion.getFullPath());
+      assertEquals(metaDataRefreshCount_Order, ((LocalRegion) orderRegion).getCachePerfStats().getMetaDataRefreshCount());
+      assertEquals(nonSingleHopsCount_Order, ((LocalRegion) orderRegion).getCachePerfStats().getNonSingleHopsCount());
+
+      regionMetaData.get(shipmentRegion.getFullPath());
+      assertEquals(metaDataRefreshCount_Shipment, ((LocalRegion) shipmentRegion).getCachePerfStats().getMetaDataRefreshCount());
+      assertEquals(nonSingleHopsCount_Shipment, ((LocalRegion) shipmentRegion).getCachePerfStats().getNonSingleHopsCount());
     }
   }
-  
-  public static void updatePR(String FromClient,
-      String colocation) {
+
+  private void updatePR(String FromClient, String colocation) {
+    Cache cache = CacheFactory.getAnyInstance();
+    Region region = cache.getRegion(Region_Name);
     if (colocation.equals("No_Colocation")) {
       if (FromClient.equals("FirstClient")) {
         for (int i = 0; i < 226; i++) {
           region.put(new Integer(i), "Update" + i);
         }
-        ClientMetadataService cms = ((GemFireCacheImpl)cache)
+        ClientMetadataService cms = ((GemFireCacheImpl) cache)
             .getClientMetadataService();
         Map<String, ClientPartitionAdvisor> regionMetaData = cms
             .getClientPRMetadata_TEST_ONLY();
         assertEquals(1, regionMetaData.size());
-        ClientPartitionAdvisor prMetaData = regionMetaData.get(region
-            .getFullPath());
-        assertEquals(metaDataRefreshCount , ((LocalRegion)region).getCachePerfStats().getMetaDataRefreshCount());
-        assertEquals(nonSingleHopsCount , ((LocalRegion)region).getCachePerfStats().getNonSingleHopsCount());
+        regionMetaData.get(region.getFullPath());
+        assertEquals(metaDataRefreshCount, ((LocalRegion) region).getCachePerfStats().getMetaDataRefreshCount());
+        assertEquals(nonSingleHopsCount, ((LocalRegion) region).getCachePerfStats().getNonSingleHopsCount());
       }
     }
   }


[03/36] incubator-geode git commit: GEODE-1139: mark test method as flaky

Posted by hi...@apache.org.
GEODE-1139: mark test method as flaky


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

Branch: refs/heads/feature/GEODE-1372
Commit: c33de6d598db8b36a35b21e2698a33896889e6d3
Parents: 0bf5425
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Mon May 9 17:22:13 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Mon May 9 17:23:11 2016 -0700

----------------------------------------------------------------------
 .../test/java/com/gemstone/gemfire/cache30/Bug44418JUnitTest.java   | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c33de6d5/geode-core/src/test/java/com/gemstone/gemfire/cache30/Bug44418JUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/Bug44418JUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/Bug44418JUnitTest.java
index ce46d6b..a2f92d7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/Bug44418JUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/Bug44418JUnitTest.java
@@ -66,6 +66,7 @@ public class Bug44418JUnitTest { // TODO: rename this test to non-ticket descrip
   private static final int POLL_INTERVAL_MS = 1;       // How often to check for expiration
   private static final String TEST_KEY = "key";
   
+  @Category(FlakyTest.class) // GEODE-1139: time sensitive, thread sleep, expiration
   @Test
   public void testPut() throws Exception {
 


[20/36] incubator-geode git commit: GEODE-1380: mark testRebalanceWithOfflineChildRegionTwoDiskStores as Flaky

Posted by hi...@apache.org.
GEODE-1380: mark testRebalanceWithOfflineChildRegionTwoDiskStores as Flaky


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

Branch: refs/heads/feature/GEODE-1372
Commit: 980b492d113655ba21f5a33ec191f843adba18f9
Parents: c92e5da
Author: Kirk Lund <kl...@apache.org>
Authored: Wed May 11 11:22:45 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Wed May 11 11:22:45 2016 -0700

----------------------------------------------------------------------
 .../PersistentColocatedPartitionedRegionDUnitTest.java            | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/980b492d/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java
index b7919b1..6df3dec 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java
@@ -1354,7 +1354,8 @@ public class PersistentColocatedPartitionedRegionDUnitTest extends PersistentPar
     async1.getResult();
     async2.getResult();
   }
-  
+
+  @Category(FlakyTest.class) // GEODE-1380: time sensitive, async actions with 30 sec max
   public void testRebalanceWithOfflineChildRegionTwoDiskStores() throws Throwable {
     SerializableRunnable createParentPR = new SerializableRunnable() {
       public void run() {


[09/36] incubator-geode git commit: GEODE-1373: resolve the shiro subject in JMX AccessControlContext first

Posted by hi...@apache.org.
GEODE-1373: resolve the shiro subject in JMX AccessControlContext first


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

Branch: refs/heads/feature/GEODE-1372
Commit: 9a770540795691fb16a5ef5fef6dbb64c7e5183d
Parents: bcf7c94
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Mon May 9 21:31:02 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Tue May 10 13:06:12 2016 -0700

----------------------------------------------------------------------
 .../internal/security/GeodeSecurityUtil.java    | 69 ++++++++++++++++----
 .../security/shiro/JMXShiroAuthenticator.java   | 13 +++-
 .../internal/security/shiro/ShiroPrincipal.java | 39 +++++++++++
 3 files changed, 108 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a770540/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
index 1f1f4eb..6e10f3f 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
@@ -17,12 +17,15 @@
 
 package com.gemstone.gemfire.internal.security;
 
+import java.security.AccessController;
+import java.util.Set;
 import java.util.concurrent.Callable;
 
 import com.gemstone.gemfire.cache.operations.OperationContext;
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
 import com.gemstone.gemfire.cache.operations.OperationContext.Resource;
 import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.security.shiro.ShiroPrincipal;
 import com.gemstone.gemfire.management.internal.security.ResourceOperation;
 import com.gemstone.gemfire.management.internal.security.ResourceOperationContext;
 import com.gemstone.gemfire.security.AuthenticationFailedException;
@@ -41,9 +44,15 @@ public class GeodeSecurityUtil {
 
   private static Logger logger = LogService.getLogger();
 
-  public static void login(String username, String password){
-    if(!isShiroConfigured())
-      return;
+  /**
+   *
+   * @param username
+   * @param password
+   * @return null if security is not enabled, otherwise return a shiro subject
+   */
+  public static Subject login(String username, String password){
+    if(!isSecured())
+      return null;
 
     Subject currentUser = SecurityUtils.getSubject();
 
@@ -56,13 +65,52 @@ public class GeodeSecurityUtil {
       logger.info(e.getMessage(), e);
       throw new AuthenticationFailedException(e.getMessage(), e);
     }
+
+    return currentUser;
+  }
+
+  /**
+   * It first looks the shiro subject in AccessControlContext since JMX will use multiple threads to process operations from the same client.
+   * then it looks into Shiro's thead context.
+   *
+   * @return the shiro subject, null if security is not enabled
+   */
+  public static Subject getSubject(){
+    if(!isSecured())
+      return null;
+
+    Subject currentUser = null;
+
+    // First try get the principal out of AccessControlContext instead of Shiro's Thread context
+    // since threads can be shared between JMX clients.
+    javax.security.auth.Subject jmxSubject =
+      javax.security.auth.Subject.getSubject(AccessController.getContext());
+
+    if(jmxSubject!=null){
+      Set<ShiroPrincipal> principals = jmxSubject.getPrincipals(ShiroPrincipal.class);
+      if(principals.size()>0){
+        ShiroPrincipal principal = principals.iterator().next();
+        currentUser = principal.getSubject();
+        ThreadContext.bind(currentUser);
+        return currentUser;
+      }
+    }
+
+    // in other cases like admin rest call or pulse authorization
+    currentUser = SecurityUtils.getSubject();
+
+    if(currentUser==null || currentUser.getPrincipal()==null){
+      throw new GemFireSecurityException("Error: Anonymous User");
+    }
+
+    return currentUser;
   }
 
   public static void logout(){
-    if(!isShiroConfigured())
+    Subject currentUser = getSubject();
+    if(currentUser==null)
       return;
 
-    Subject currentUser = SecurityUtils.getSubject();
     try {
       logger.info("Logging out "+currentUser.getPrincipal());
       currentUser.logout();
@@ -76,10 +124,10 @@ public class GeodeSecurityUtil {
   }
 
   public static Callable associateWith(Callable callable){
-    if(!isShiroConfigured())
+    Subject currentUser = getSubject();
+    if(currentUser==null)
       return callable;
 
-    Subject currentUser = SecurityUtils.getSubject();
     return currentUser.associateWith(callable);
   }
 
@@ -140,11 +188,10 @@ public class GeodeSecurityUtil {
     if(context.getResource()== Resource.NULL && context.getOperationCode()== OperationCode.NULL)
       return;
 
-    if(!isShiroConfigured())
+    Subject currentUser = getSubject();
+    if(currentUser==null)
       return;
 
-
-    Subject currentUser = SecurityUtils.getSubject();
     try {
       currentUser.checkPermission(context);
     }
@@ -154,7 +201,7 @@ public class GeodeSecurityUtil {
     }
   }
 
-  private static boolean isShiroConfigured(){
+  private static boolean isSecured(){
     try{
       SecurityUtils.getSecurityManager();
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a770540/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/JMXShiroAuthenticator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/JMXShiroAuthenticator.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/JMXShiroAuthenticator.java
index 4a4cc28..984a2bf 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/JMXShiroAuthenticator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/JMXShiroAuthenticator.java
@@ -18,6 +18,7 @@ package com.gemstone.gemfire.internal.security.shiro;
 
 import static com.gemstone.gemfire.management.internal.security.ResourceConstants.*;
 
+import java.security.Principal;
 import java.util.Collections;
 import java.util.Properties;
 import javax.management.Notification;
@@ -50,9 +51,17 @@ public class JMXShiroAuthenticator implements JMXAuthenticator, NotificationList
       throw new SecurityException(WRONGE_CREDENTIALS_MESSAGE);
     }
 
-    GeodeSecurityUtil.login(username, password);
+    org.apache.shiro.subject.Subject shiroSubject = GeodeSecurityUtil.login(username, password);
+    Principal principal;
 
-    return new Subject(true, Collections.singleton(new JMXPrincipal(username)), Collections.EMPTY_SET,
+    if(shiroSubject==null){
+      principal = new JMXPrincipal(username);
+    }
+    else{
+      principal = new ShiroPrincipal(shiroSubject);
+    }
+
+    return new Subject(true, Collections.singleton(principal), Collections.EMPTY_SET,
       Collections.EMPTY_SET);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a770540/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/ShiroPrincipal.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/ShiroPrincipal.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/ShiroPrincipal.java
new file mode 100644
index 0000000..8413ebb
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/ShiroPrincipal.java
@@ -0,0 +1,39 @@
+/*
+ * 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 com.gemstone.gemfire.internal.security.shiro;
+
+import java.security.Principal;
+
+import org.apache.shiro.subject.Subject;
+
+public class ShiroPrincipal implements Principal {
+  private Subject subject;
+
+  public ShiroPrincipal(Subject subject){
+    this.subject = subject;
+  }
+
+  @Override
+  public String getName() {
+    return subject.toString();
+  }
+
+  public Subject getSubject(){
+    return subject;
+  }
+}


[15/36] incubator-geode git commit: GEODE-248: remove unused BoundedLinkedHashMap

Posted by hi...@apache.org.
GEODE-248: remove unused BoundedLinkedHashMap


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

Branch: refs/heads/feature/GEODE-1372
Commit: fc943cb81e10f4121ce9a1e6ca6e8e0d3fbc10f9
Parents: 463ae16
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Tue May 10 14:15:09 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed May 11 10:13:12 2016 -0700

----------------------------------------------------------------------
 .../cache/util/BoundedLinkedHashMap.java        | 88 --------------------
 .../codeAnalysis/sanctionedSerializables.txt    |  1 -
 2 files changed, 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fc943cb8/geode-core/src/main/java/com/gemstone/gemfire/cache/util/BoundedLinkedHashMap.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/util/BoundedLinkedHashMap.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/util/BoundedLinkedHashMap.java
deleted file mode 100755
index fbb024a..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/util/BoundedLinkedHashMap.java
+++ /dev/null
@@ -1,88 +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 com.gemstone.gemfire.cache.util;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Class <code>BoundedLinkedHashMap</code> is a bounded
- * <code>LinkedHashMap</code>. The bound is the maximum
- * number of entries the <code>BoundedLinkedHashMap</code>
- * can contain.
- *
- * @since 4.2
- * @deprecated as of 5.7 create your own class that extends {@link LinkedHashMap}
- * and implement {@link LinkedHashMap#removeEldestEntry}
- * to enforce a maximum number of entries.
- */
-public class BoundedLinkedHashMap extends LinkedHashMap
-{
-  private static final long serialVersionUID = -3419897166186852692L;
-
-  /**
-   * The maximum number of entries allowed in this
-   * <code>BoundedLinkedHashMap</code>
-   */
-  protected int _maximumNumberOfEntries;
-
-  /**
-   * Constructor.
-   *
-   * @param initialCapacity The initial capacity.
-   * @param loadFactor The load factor
-   * @param maximumNumberOfEntries The maximum number of allowed entries
-   */
-  public BoundedLinkedHashMap(int initialCapacity, float loadFactor, int maximumNumberOfEntries) {
-    super(initialCapacity, loadFactor);
-    this._maximumNumberOfEntries = maximumNumberOfEntries;
-  }
-
-  /**
-   * Constructor.
-   *
-   * @param initialCapacity The initial capacity.
-   * @param maximumNumberOfEntries The maximum number of allowed entries
-   */
-  public BoundedLinkedHashMap(int initialCapacity, int maximumNumberOfEntries) {
-    super(initialCapacity);
-    this._maximumNumberOfEntries = maximumNumberOfEntries;
-  }
-
-  /**
-   * Constructor.
-   *
-   * @param maximumNumberOfEntries The maximum number of allowed entries
-   */
-  public BoundedLinkedHashMap(int maximumNumberOfEntries) {
-    super();
-    this._maximumNumberOfEntries = maximumNumberOfEntries;
-  }
-
-  /**
-   * Returns the maximum number of entries.
-   * @return the maximum number of entries
-   */
-  public int getMaximumNumberOfEntries(){
-    return this._maximumNumberOfEntries;
-  }
-
-  @Override
-  protected boolean removeEldestEntry(Map.Entry entry) {
-    return size() > this._maximumNumberOfEntries;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fc943cb8/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt b/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt
index f356bda..ed0f9fc 100755
--- a/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt
@@ -202,7 +202,6 @@ com/gemstone/gemfire/cache/query/internal/parse/GemFireAST,true,7799648022743052
 com/gemstone/gemfire/cache/query/internal/utils/PDXUtils$1,false
 com/gemstone/gemfire/cache/query/internal/utils/PDXUtils$2,false
 com/gemstone/gemfire/cache/snapshot/SnapshotOptions$SnapshotFormat,false
-com/gemstone/gemfire/cache/util/BoundedLinkedHashMap,true,-3419897166186852692,_maximumNumberOfEntries:int
 com/gemstone/gemfire/cache/util/Gateway$OrderPolicy,false
 com/gemstone/gemfire/cache/wan/GatewaySender$OrderPolicy,false
 com/gemstone/gemfire/compression/CompressionException,true,4118639654597191235