You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by sb...@apache.org on 2015/08/06 20:27:11 UTC

[1/4] incubator-geode git commit: Fix for GEODE-109

Repository: incubator-geode
Updated Branches:
  refs/heads/develop d0d48588c -> 1a6a0ef53


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/test/java/com/gemstone/gemfire/redis/SortedSetsJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/redis/SortedSetsJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/SortedSetsJUnitTest.java
new file mode 100755
index 0000000..4adfe07
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/SortedSetsJUnitTest.java
@@ -0,0 +1,414 @@
+package com.gemstone.gemfire.redis;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Tuple;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.GemFireCache;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class SortedSetsJUnitTest {
+  private static Jedis jedis;
+  private static GemFireRedisServer server;
+  private static GemFireCache cache;
+  private static Random rand;
+  private static int port = 6379;
+
+  @BeforeClass
+  public static void setUp() throws IOException {
+    rand = new Random();
+    CacheFactory cf = new CacheFactory();
+    //cf.set("log-file", "redis.log");
+    cf.set("log-level", "error");
+    cf.set("mcast-port", "0");
+    cf.set("locators", "");
+    cache = cf.create();
+    port = AvailablePortHelper.getRandomAvailableTCPPort();
+    server = new GemFireRedisServer("localhost", port);
+
+    server.start();
+    jedis = new Jedis("localhost", port, 10000000);
+  }
+
+  @Test
+  public void testZAddZRange() {
+    int numMembers = 10;
+    String key = randString();
+    Map<String, Double> scoreMembers = new HashMap<String, Double>();
+
+    for (int i = 0; i < numMembers; i++)
+      scoreMembers.put(randString(), rand.nextDouble());
+
+    jedis.zadd(key, scoreMembers);
+    int k = 0;
+    for (String entry: scoreMembers.keySet())
+      assertNotNull(jedis.zscore(key, entry));
+
+    Set<Tuple> results = jedis.zrangeWithScores(key, 0, -1);
+    Map<String, Double> resultMap = new HashMap<String, Double>();
+    for (Tuple t: results) {
+      resultMap.put(t.getElement(), t.getScore());
+    }
+
+    assertEquals(scoreMembers, resultMap);
+
+    for (int i = 0; i < 10; i++) {
+      int start;
+      int stop;
+      do {
+        start = rand.nextInt(numMembers);
+        stop = rand.nextInt(numMembers);
+      } while (start > stop);
+      results = jedis.zrangeWithScores(key, start, stop);
+      List<Entry<String, Double>> resultList = new ArrayList<Entry<String, Double>>();
+      for (Tuple t: results)
+        resultList.add(new AbstractMap.SimpleEntry<String, Double>(t.getElement(), t.getScore()));
+      List<Entry<String, Double>> list = new ArrayList<Entry<String, Double>>(scoreMembers.entrySet());
+      Collections.sort(list, new EntryCmp());
+      list = list.subList(start, stop + 1);
+      assertEquals(list, resultList);
+    }
+  }
+
+  @Test
+  public void testZRevRange() {
+    int numMembers = 10;
+    String key = randString();
+
+    Map<String, Double> scoreMembers = new HashMap<String, Double>();
+
+    for (int i = 0; i < numMembers; i++)
+      scoreMembers.put(randString(), rand.nextDouble());
+
+    jedis.zadd(key, scoreMembers);
+
+    Set<Tuple> results;
+
+    for (int i = 0; i < 10; i++) {
+      int start;
+      int stop;
+      do {
+        start = rand.nextInt(numMembers);
+        stop = rand.nextInt(numMembers);
+      } while (start > stop);
+      results = jedis.zrevrangeWithScores(key, start, stop);
+      List<Entry<String, Double>> resultList = new ArrayList<Entry<String, Double>>();
+      for (Tuple t: results)
+        resultList.add(new AbstractMap.SimpleEntry<String, Double>(t.getElement(), t.getScore()));
+      List<Entry<String, Double>> list = new ArrayList<Entry<String, Double>>(scoreMembers.entrySet());
+      Collections.sort(list, new EntryRevCmp());
+      list = list.subList(start, stop + 1);
+      assertEquals(list, resultList);
+    }
+  }
+
+  @Test
+  public void testZCount() {
+    int num = 10;
+    int runs = 2;
+    for (int i = 0; i < runs; i++) {
+      Double min;
+      Double max;
+      do {
+        min = rand.nextDouble();
+        max = rand.nextDouble();
+      } while (min > max);
+
+
+      int count = 0;
+
+      String key = randString();
+      Map<String, Double> scoreMembers = new HashMap<String, Double>();
+
+      for (int j = 0; j < num; j++) {
+        Double nextDouble = rand.nextDouble();
+        if (nextDouble >= min && nextDouble <= max)
+          count++;
+        scoreMembers.put(randString(), nextDouble);
+      }
+
+      jedis.zadd(key, scoreMembers);
+      Long countResult = jedis.zcount(key, min, max);
+      assertTrue(count == countResult);
+    }
+
+  }
+
+  @Test
+  public void testZIncrBy() {
+    String key = randString();
+    String member = randString();
+    Double score = 0.0;
+    for (int i = 0; i < 20; i++) {
+      Double incr = rand.nextDouble();
+      Double result = jedis.zincrby(key, incr, member);
+      score += incr;
+      assertEquals(score, result, 1.0/100000000.0);
+    }
+
+
+    jedis.zincrby(key, Double.MAX_VALUE, member);
+    Double infResult = jedis.zincrby(key, Double.MAX_VALUE, member);
+
+
+    assertEquals(infResult, Double.valueOf(Double.POSITIVE_INFINITY));
+  }
+
+  public void testZRangeByScore() {
+    Double min;
+    Double max;
+    for (int j = 0; j < 2; j++) {
+      do {
+        min = rand.nextDouble();
+        max = rand.nextDouble();
+      } while (min > max);
+      int numMembers = 500;
+      String key = randString();
+      Map<String, Double> scoreMembers = new HashMap<String, Double>();
+      List<Entry<String, Double>> expected = new ArrayList<Entry<String, Double>>();
+      for (int i = 0; i < numMembers; i++) {
+        String s = randString();
+        Double d = rand.nextDouble();
+        scoreMembers.put(s, d);
+        if (d > min && d < max)
+          expected.add(new AbstractMap.SimpleEntry<String, Double>(s, d));
+      }
+      jedis.zadd(key, scoreMembers);
+      Set<Tuple> results = jedis.zrangeByScoreWithScores(key, min, max);
+      List<Entry<String, Double>> resultList = new ArrayList<Entry<String, Double>>();
+      for (Tuple t: results)
+        resultList.add(new AbstractMap.SimpleEntry<String, Double>(t.getElement(), t.getScore()));
+      Collections.sort(expected, new EntryCmp());
+
+      assertEquals(expected, resultList);
+      jedis.del(key);
+    }
+  }
+
+  public void testZRevRangeByScore() {
+    Double min;
+    Double max;
+    for (int j = 0; j < 2; j++) {
+      do {
+        min = rand.nextDouble();
+        max = rand.nextDouble();
+      } while (min > max);
+      int numMembers = 500;
+      String key = randString();
+      Map<String, Double> scoreMembers = new HashMap<String, Double>();
+      List<Entry<String, Double>> expected = new ArrayList<Entry<String, Double>>();
+      for (int i = 0; i < numMembers; i++) {
+        String s = randString();
+        Double d = rand.nextDouble();
+        scoreMembers.put(s, d);
+        if (d > min && d < max)
+          expected.add(new AbstractMap.SimpleEntry<String, Double>(s, d));
+      }
+      jedis.zadd(key, scoreMembers);
+      Set<Tuple> results = jedis.zrevrangeByScoreWithScores(key, max, min);
+      List<Entry<String, Double>> resultList = new ArrayList<Entry<String, Double>>();
+      for (Tuple t: results)
+        resultList.add(new AbstractMap.SimpleEntry<String, Double>(t.getElement(), t.getScore()));
+      Collections.sort(expected, new EntryRevCmp());
+
+      assertEquals(expected, resultList);
+      jedis.del(key);
+    }
+  }
+
+  @Test
+  public void testZRemZScore() {
+    Double min;
+    Double max;
+    for (int j = 0; j < 2; j++) {
+      do {
+        min = rand.nextDouble();
+        max = rand.nextDouble();
+      } while (min > max);
+      int numMembers = 5000;
+      String key = randString();
+      Map<String, Double> scoreMembers = new HashMap<String, Double>();
+      List<Entry<String, Double>> expected = new ArrayList<Entry<String, Double>>();
+      for (int i = 0; i < numMembers; i++) {
+        String s = randString();
+        Double d = rand.nextDouble();
+        scoreMembers.put(s, d);
+        if (d > min && d < max)
+          expected.add(new AbstractMap.SimpleEntry<String, Double>(s, d));
+      }
+      jedis.zadd(key, scoreMembers);
+      Collections.sort(expected, new EntryCmp());
+      for (int i = expected.size(); i <= 0; i--) {
+        Entry<String, Double> remEntry = expected.remove(i);
+        String rem = remEntry.getKey();
+        Double val = remEntry.getValue();
+        assertEquals(val, jedis.zscore(key, rem));
+
+        assertTrue(jedis.zrem(key, rem) == 1);
+      }
+      String s = randString();
+      if (!expected.contains(s))
+        assertTrue(jedis.zrem(key, s) == 0);
+      jedis.del(key);
+    }
+  }
+
+  @Test
+  public void testZRank() {
+    for (int j = 0; j < 2; j++) {
+      int numMembers = 10;
+      String key = randString();
+      Map<String, Double> scoreMembers = new HashMap<String, Double>();
+      List<Entry<String, Double>> expected = new ArrayList<Entry<String, Double>>();
+      for (int i = 0; i < numMembers; i++) {
+        String s = randString();
+        Double d = rand.nextDouble();
+        scoreMembers.put(s, d);
+        expected.add(new AbstractMap.SimpleEntry<String, Double>(s, d));
+      }
+      Collections.sort(expected, new EntryCmp());
+      jedis.zadd(key, scoreMembers);
+      for (int i = 0; i < expected.size(); i++) {
+        Entry<String, Double> en = expected.get(i);
+        String field = en.getKey();
+        Long rank = jedis.zrank(key, field);
+        assertEquals(new Long(i), rank);
+      }
+      String field = randString();
+      if (!expected.contains(field))
+        assertNull(jedis.zrank(key, field));
+      jedis.del(key);
+    }
+  }
+
+  @Test
+  public void testZRevRank() {
+    for (int j = 0; j < 2; j++) {
+      int numMembers = 10;
+      String key = randString();
+      Map<String, Double> scoreMembers = new HashMap<String, Double>();
+      List<Entry<String, Double>> expected = new ArrayList<Entry<String, Double>>();
+      for (int i = 0; i < numMembers; i++) {
+        String s = randString();
+        Double d = rand.nextDouble();
+        scoreMembers.put(s, d);
+        expected.add(new AbstractMap.SimpleEntry<String, Double>(s, d));
+      }
+      Collections.sort(expected, new EntryRevCmp());
+      jedis.zadd(key, scoreMembers);
+      for (int i = 0; i < expected.size(); i++) {
+        Entry<String, Double> en = expected.get(i);
+        String field = en.getKey();
+        Long rank = jedis.zrevrank(key, field);
+        assertEquals(new Long(i), rank);
+      }
+      String field = randString();
+      if (!expected.contains(field))
+        assertNull(jedis.zrank(key, field));
+      jedis.del(key);
+    }
+  }
+
+  private class EntryCmp implements Comparator<Entry<String, Double>> {
+
+    @Override
+    public int compare(Entry<String, Double> o1, Entry<String, Double> o2) {
+      Double diff = o1.getValue() - o2.getValue();
+      if (diff == 0) 
+        return o2.getKey().compareTo(o1.getKey());
+      else
+        return diff > 0 ? 1 : -1;
+    }
+
+  }
+
+  private class EntryRevCmp implements Comparator<Entry<String, Double>> {
+
+    @Override
+    public int compare(Entry<String, Double> o1, Entry<String, Double> o2) {
+      Double diff = o2.getValue() - o1.getValue();
+      if (diff == 0) 
+        return o1.getKey().compareTo(o2.getKey());
+      else
+        return diff > 0 ? 1 : -1;
+    }
+
+  }
+
+  @Test
+  public void testZRemRangeByScore() {
+    Double min;
+    Double max;
+    for (int j = 0; j < 3; j++) {
+      do {
+        min = rand.nextDouble();
+        max = rand.nextDouble();
+      } while (min > max);
+      int numMembers = 10;
+      String key = randString();
+      Map<String, Double> scoreMembers = new HashMap<String, Double>();
+      List<Entry<String, Double>> fullList = new ArrayList<Entry<String, Double>>();
+      List<Entry<String, Double>> toRemoveList = new ArrayList<Entry<String, Double>>();
+      for (int i = 0; i < numMembers; i++) {
+        String s = randString();
+        Double d = rand.nextDouble();
+        scoreMembers.put(s, d);
+        fullList.add(new AbstractMap.SimpleEntry<String, Double>(s, d));
+        if (d > min && d < max)
+          toRemoveList.add(new AbstractMap.SimpleEntry<String, Double>(s, d));
+      }
+      jedis.zadd(key, scoreMembers);
+      Long numRemoved = jedis.zremrangeByScore(key, min, max);
+      List<Entry<String, Double>> expectedList = new ArrayList<Entry<String, Double>>(fullList);
+      expectedList.removeAll(toRemoveList);
+      Collections.sort(expectedList, new EntryCmp());
+      Set<Tuple> result = jedis.zrangeWithScores(key, 0, -1);
+      List<Entry<String, Double>> resultList = new ArrayList<Entry<String, Double>>();
+      for (Tuple t: result)
+        resultList.add(new AbstractMap.SimpleEntry<String, Double>(t.getElement(), t.getScore()));
+      assertEquals(expectedList, resultList);
+      jedis.del(key);
+    }
+  }
+
+  private String randString() {
+    return Long.toHexString(Double.doubleToLongBits(Math.random()));
+  }
+
+  @After
+  public void flushAll() {
+    jedis.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+    cache.close();
+    server.shutdown();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/test/java/com/gemstone/gemfire/redis/StringsJunitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/redis/StringsJunitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/StringsJunitTest.java
new file mode 100755
index 0000000..55ba061
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/StringsJunitTest.java
@@ -0,0 +1,296 @@
+package com.gemstone.gemfire.redis;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import redis.clients.jedis.Jedis;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.GemFireCache;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class StringsJunitTest {
+
+  private static Jedis jedis;
+  private static GemFireRedisServer server;
+  private static GemFireCache cache;
+  private static Random rand;
+  private static int port = 6379;
+
+  @BeforeClass
+  public static void setUp() throws IOException {
+    rand = new Random();
+    CacheFactory cf = new CacheFactory();
+    //cf.set("log-file", "redis.log");
+    cf.set("log-level", "error");
+    cf.set("mcast-port", "0");
+    cf.set("locators", "");
+    cache = cf.create();
+    port = AvailablePortHelper.getRandomAvailableTCPPort();
+    server = new GemFireRedisServer("localhost", port);
+
+    server.start();
+    jedis = new Jedis("localhost", port, 10000000);
+  }
+
+  @Test
+  public void testAppendAndStrlen() {
+    String key = randString();
+    int len = key.length();
+    String full = key;
+    jedis.set(key, key);
+    for (int i = 0; i < 15; i++) {
+      String rand = randString();
+      jedis.append(key, rand);
+      len += rand.length();
+      full += rand;
+    }
+    String ret = jedis.get(key);
+    assertTrue(ret.length() == len);
+    assertTrue(full.equals(ret));
+    assertTrue(full.length() == jedis.strlen(key));
+  }
+
+  @Test
+  public void testDecr() {
+    String key1 = randString();
+    String key2 = randString();
+    String key3 = randString();
+    int num1 = 100;
+    int num2 = -100;
+    jedis.set(key1, ""+num1);
+    //jedis.set(key3, "-100");
+    jedis.set(key2, ""+num2);
+
+    jedis.decr(key1);
+    jedis.decr(key3);
+    jedis.decr(key2);
+    assertTrue(jedis.get(key1).equals("" + (num1 - 1)));
+    assertTrue(jedis.get(key2).equals("" + (num2 - 1)));
+    assertTrue(jedis.get(key3).equals("" + (-1)));
+  }
+
+  @Test
+  public void testIncr() {
+    String key1 = randString();
+    String key2 = randString();
+    String key3 = randString();
+    int num1 = 100;
+    int num2 = -100;
+    jedis.set(key1, ""+num1);
+    //jedis.set(key3, "-100");
+    jedis.set(key2, ""+num2);
+
+    jedis.incr(key1);
+    jedis.incr(key3);
+    jedis.incr(key2);
+
+    assertTrue(jedis.get(key1).equals("" + (num1 + 1)));
+    assertTrue(jedis.get(key2).equals("" + (num2 + 1)));
+    assertTrue(jedis.get(key3).equals("" + (+1)));
+  }
+
+  @Test
+  public void testDecrBy() {
+    String key1 = randString();
+    String key2 = randString();
+    String key3 = randString();
+    int decr1 = rand.nextInt(100);
+    int decr2 = rand.nextInt(100);
+    Long decr3 = Long.MAX_VALUE/2;
+    int num1 = 100;
+    int num2 = -100;
+    jedis.set(key1, ""+num1);
+    jedis.set(key2, ""+num2);
+    jedis.set(key3, ""+Long.MIN_VALUE);
+
+    jedis.decrBy(key1, decr1);
+    jedis.decrBy(key2, decr2);
+
+    assertTrue(jedis.get(key1).equals("" + (num1 - decr1*1)));
+    assertTrue(jedis.get(key2).equals("" + (num2 - decr2*1)));
+
+    Exception ex= null;
+    try {
+      jedis.decrBy(key3, decr3);
+    } catch(Exception e) {
+      ex = e;
+    }
+    assertNotNull(ex);
+
+  }  
+
+  @Test
+  public void testIncrBy() {
+    String key1 = randString();
+    String key2 = randString();
+    String key3 = randString();
+    int incr1 = rand.nextInt(100);
+    int incr2 = rand.nextInt(100);
+    Long incr3 = Long.MAX_VALUE/2;
+    int num1 = 100;
+    int num2 = -100;
+    jedis.set(key1, ""+num1);
+    jedis.set(key2, ""+num2);
+    jedis.set(key3, ""+Long.MAX_VALUE);
+
+    jedis.incrBy(key1, incr1);
+    jedis.incrBy(key2, incr2);
+    assertTrue(jedis.get(key1).equals("" + (num1 + incr1*1)));
+    assertTrue(jedis.get(key2).equals("" + (num2 + incr2*1)));
+
+    Exception ex= null;
+    try {
+      jedis.incrBy(key3, incr3);
+    } catch(Exception e) {
+      ex = e;
+    }
+    assertNotNull(ex);
+  }
+
+  @Test
+  public void testGetRange() {
+    String sent = randString();
+    String contents = randString();
+    jedis.set(sent, contents);
+    for (int i = 0; i < sent.length(); i++) {
+      String range = jedis.getrange(sent, i, -1);
+      assertTrue(contents.substring(i).equals(range));
+    }
+    assertNull(jedis.getrange(sent, 2,0));
+  }
+
+  @Test
+  public void testGetSet() {
+    String key = randString();
+    String contents = randString();
+    jedis.set(key, contents);
+    String newContents = randString();
+    String oldContents = jedis.getSet(key, newContents);
+    assertTrue(oldContents.equals(contents));
+    contents = newContents;
+  }
+
+  @Test
+  public void testMSetAndGet() {
+    int r = 5;
+    String[] keyvals = new String[(r*2)];
+    String[] keys = new String[r];
+    String[] vals = new String[r];
+    for(int i = 0; i < r; i++) {
+      String key = randString();
+      String val = randString();
+      keyvals[2*i] = key;
+      keyvals[2*i+1] = val;
+      keys[i] = key;
+      vals[i] = val;
+    }
+
+    jedis.mset(keyvals);
+
+    List<String> ret = jedis.mget(keys);
+    Object[] retArray =  ret.toArray();
+
+    assertTrue(Arrays.equals(vals, retArray));
+  }
+
+  @Test
+  public void testMSetNX() {
+    Set<String> strings = new HashSet<String>();
+    for(int i = 0; i < 2 * 5; i++)
+      strings.add(randString());
+    String[] array = strings.toArray(new String[0]);
+    long response = jedis.msetnx(array);
+
+    assertTrue(response == 1);
+
+    long response2 = jedis.msetnx(array[0], randString());
+
+    assertTrue(response2 == 0);
+    assertEquals(array[1], jedis.get(array[0]));
+  }
+
+  @Test
+  public void testSetNX() {
+    String key1 = randString();
+    String key2;
+    do {
+      key2 = randString();
+    } while (key2.equals(key1));
+
+    long response1 = jedis.setnx(key1, key1);
+    long response2 = jedis.setnx(key2, key2);
+    long response3 = jedis.setnx(key1, key2);
+
+    assertTrue(response1 == 1);
+    assertTrue(response2 == 1);
+    assertTrue(response3 == 0);
+  }
+
+  @Test
+  public void testPAndSetex() {
+    Random r = new Random();
+    int setex = r.nextInt(5);
+    if (setex == 0)
+      setex = 1;
+    String key = randString();
+    jedis.setex(key, setex, randString());
+    try {
+      Thread.sleep((setex  + 5) * 1000);
+    } catch (InterruptedException e) {
+      return;
+    }
+    String result = jedis.get(key);
+    //System.out.println(result);
+    assertNull(result);
+
+    int psetex = r.nextInt(5000);
+    if (psetex == 0)
+      psetex = 1;
+    key = randString();
+    jedis.psetex(key, psetex, randString());
+    long start = System.currentTimeMillis();
+    try {
+      Thread.sleep(psetex + 5000);
+    } catch (InterruptedException e) {
+      return;
+    }
+    long stop = System.currentTimeMillis();
+    result = jedis.get(key);
+    assertTrue(stop - start >= psetex);
+    assertNull(result);
+  }
+
+  private String randString() {
+    return Long.toHexString(Double.doubleToLongBits(Math.random()));
+  }
+
+  @After
+  public void flushAll() {
+    jedis.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+    cache.close();
+    server.shutdown();
+  }
+}


[2/4] incubator-geode git commit: Fix for GEODE-109

Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByScoreExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByScoreExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByScoreExecutor.java
index ca6cd82..19356b7 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByScoreExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByScoreExecutor.java
@@ -74,7 +74,7 @@ public class ZRemRangeByScoreExecutor extends SortedSetExecutor {
     try {
       if (start == Double.NEGATIVE_INFINITY && stop == Double.POSITIVE_INFINITY && startInclusive && stopInclusive) {
         numRemoved = keyRegion.size();
-        context.getRegionCache().removeKey(key);
+        context.getRegionProvider().removeKey(key);
       } else {
         removeList = getKeys(context, key, keyRegion, start, stop, startInclusive, stopInclusive);
       }
@@ -93,7 +93,7 @@ public class ZRemRangeByScoreExecutor extends SortedSetExecutor {
         if (oldVal != null)
           numRemoved++;
         if (keyRegion.isEmpty())
-          context.getRegionCache().removeKey(key);
+          context.getRegionProvider().removeKey(key);
       }
     }
     command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numRemoved));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZScanExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZScanExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZScanExecutor.java
index 097e9be..faa8ffd 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZScanExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZScanExecutor.java
@@ -2,6 +2,7 @@ package com.gemstone.gemfire.internal.redis.executor.sortedset;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map.Entry;
 import java.util.regex.Pattern;
@@ -31,7 +32,7 @@ public class ZScanExecutor extends AbstractScanExecutor {
     }
 
     ByteArrayWrapper key = command.getKey();
-    Region<ByteArrayWrapper, DoubleWrapper> keyRegion = (Region<ByteArrayWrapper, DoubleWrapper>) context.getRegionCache().getRegion(key);
+    Region<ByteArrayWrapper, DoubleWrapper> keyRegion = (Region<ByteArrayWrapper, DoubleWrapper>) context.getRegionProvider().getRegion(key);
     checkDataType(key, RedisDataType.REDIS_SORTEDSET, context);
     if (keyRegion == null) {
       command.setResponse(Coder.getScanResponse(context.getByteBufAllocator(), new ArrayList<String>()));
@@ -96,7 +97,7 @@ public class ZScanExecutor extends AbstractScanExecutor {
       return;
     }
 
-    List<ByteArrayWrapper> returnList = (List<ByteArrayWrapper>) getIteration(keyRegion.entrySet(), matchPattern, count, cursor);
+    List<ByteArrayWrapper> returnList = (List<ByteArrayWrapper>) getIteration(new HashSet(keyRegion.entrySet()), matchPattern, count, cursor);
 
     command.setResponse(Coder.getScanResponse(context.getByteBufAllocator(), returnList));
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/AppendExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/AppendExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/AppendExecutor.java
index fa83882..fda38c8 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/AppendExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/AppendExecutor.java
@@ -17,7 +17,7 @@ public class AppendExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();;
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();;
 
     if (commandElems.size() < 3) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.APPEND));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitCountExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitCountExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitCountExecutor.java
index a4fbf95..4ac408d 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitCountExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitCountExecutor.java
@@ -18,7 +18,7 @@ public class BitCountExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() != 2 && commandElems.size() != 4) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.BITCOUNT));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitOpExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitOpExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitOpExecutor.java
index 7dd10e9..c678b79 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitOpExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitOpExecutor.java
@@ -17,7 +17,7 @@ public class BitOpExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 4) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.BITOP));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitPosExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitPosExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitPosExecutor.java
index 7a2a492..796c858 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitPosExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/BitPosExecutor.java
@@ -19,7 +19,7 @@ public class BitPosExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 3) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.BITPOS));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/DecrByExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/DecrByExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/DecrByExecutor.java
index 4bcbd8d..9dfdfed 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/DecrByExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/DecrByExecutor.java
@@ -23,7 +23,7 @@ public class DecrByExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 3) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.DECRBY));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/DecrExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/DecrExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/DecrExecutor.java
index 55b7fc5..b66160d 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/DecrExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/DecrExecutor.java
@@ -9,7 +9,7 @@ import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
 import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.RegionCache;
+import com.gemstone.gemfire.internal.redis.RegionProvider;
 
 public class DecrExecutor extends StringExecutor {
 
@@ -25,7 +25,7 @@ public class DecrExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    RegionCache rC = context.getRegionCache();
+    RegionProvider rC = context.getRegionProvider();
     Region<ByteArrayWrapper, ByteArrayWrapper> r = rC.getStringsRegion();;
 
     if (commandElems.size() < 2) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetBitExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetBitExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetBitExecutor.java
index 1035d10..928700a 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetBitExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetBitExecutor.java
@@ -17,7 +17,7 @@ public class GetBitExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 3) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.GETBIT));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetExecutor.java
index aed0f2a..86d5c75 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetExecutor.java
@@ -12,7 +12,7 @@ public class GetExecutor extends StringExecutor {
 
   @Override
   public void executeCommand(Command command, ExecutionHandlerContext context) {
-    Region<ByteArrayWrapper, ByteArrayWrapper> r= context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r= context.getRegionProvider().getStringsRegion();
 
     if (command.getProcessedCommand().size() < 2) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.GETEXECUTOR));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetRangeExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetRangeExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetRangeExecutor.java
index 20d938d..4d96c5f 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetRangeExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetRangeExecutor.java
@@ -23,7 +23,7 @@ public class GetRangeExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 4) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.GETRANGE));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetSetExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetSetExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetSetExecutor.java
index f599c96..132fdc5 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetSetExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/GetSetExecutor.java
@@ -17,7 +17,7 @@ public class GetSetExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 3) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.GETSET));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrByExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrByExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrByExecutor.java
index 8e9ca4d..02c5b1e 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrByExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrByExecutor.java
@@ -23,7 +23,7 @@ public class IncrByExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 3) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.INCRBY));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrByFloatExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrByFloatExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrByFloatExecutor.java
index 2c3c5f8..c08f709 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrByFloatExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrByFloatExecutor.java
@@ -24,7 +24,7 @@ public class IncrByFloatExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
     if (commandElems.size() < 3) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.INCRBYFLOAT));
       return;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrExecutor.java
index aafe7dd..44feb03 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/IncrExecutor.java
@@ -21,7 +21,7 @@ public class IncrExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 2) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.INCR));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MGetExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MGetExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MGetExecutor.java
index bd002ce..b063288 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MGetExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MGetExecutor.java
@@ -18,7 +18,7 @@ public class MGetExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 2) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.MGET));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MSetExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MSetExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MSetExecutor.java
index d95dc34..531895e 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MSetExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MSetExecutor.java
@@ -20,7 +20,7 @@ public class MSetExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 3 || commandElems.size() % 2 == 0) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.MSET));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MSetNXExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MSetNXExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MSetNXExecutor.java
index c7f52cd..0182f19 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MSetNXExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/MSetNXExecutor.java
@@ -22,7 +22,7 @@ public class MSetNXExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 3 || commandElems.size() % 2 == 0) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.MSETNX));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetBitExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetBitExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetBitExecutor.java
index ef8cd3e..e3e85b3 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetBitExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetBitExecutor.java
@@ -21,7 +21,7 @@ public class SetBitExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 4) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.SETBIT));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetEXExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetEXExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetEXExecutor.java
index 6ad4c90..448f912 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetEXExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetEXExecutor.java
@@ -24,7 +24,7 @@ public class SetEXExecutor extends StringExecutor implements Extendable {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 4) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), getArgsError()));
@@ -54,7 +54,7 @@ public class SetEXExecutor extends StringExecutor implements Extendable {
     checkAndSetDataType(key, context);
     r.put(key, new ByteArrayWrapper(value));
 
-    context.getRegionCache().setExpiration(key, expiration);
+    context.getRegionProvider().setExpiration(key, expiration);
 
     command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), SUCCESS));
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetExecutor.java
index c4b9b85..b6dc703 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetExecutor.java
@@ -19,7 +19,7 @@ public class SetExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 3) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.SET));
@@ -90,7 +90,7 @@ public class SetExecutor extends StringExecutor {
     }
 
     if (keyWasSet && expiration > 0L) {
-      context.getRegionCache().setExpiration(key, expiration);
+      context.getRegionProvider().setExpiration(key, expiration);
     }
 
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetNXExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetNXExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetNXExecutor.java
index 0956a6a..0daaeb9 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetNXExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetNXExecutor.java
@@ -21,7 +21,7 @@ public class SetNXExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 3) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.SETNX));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetRangeExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetRangeExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetRangeExecutor.java
index 8f00a83..1656065 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetRangeExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/SetRangeExecutor.java
@@ -19,7 +19,7 @@ public class SetRangeExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 4) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.SETRANGE));
@@ -48,7 +48,7 @@ public class SetRangeExecutor extends StringExecutor {
       int length = wrapper == null ? 0 : wrapper.toBytes().length;
       command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), length));
       if (wrapper == null)
-        context.getRegionCache().removeKey(key);
+        context.getRegionProvider().removeKey(key);
       return;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/StringExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/StringExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/StringExecutor.java
index 1f95ce6..49c81b3 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/StringExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/StringExecutor.java
@@ -9,7 +9,7 @@ import com.gemstone.gemfire.internal.redis.executor.AbstractExecutor;
 public abstract class StringExecutor extends AbstractExecutor {
   
   protected final void checkAndSetDataType(ByteArrayWrapper key, ExecutionHandlerContext context) {
-    Object oldVal = context.getRegionCache().metaPutIfAbsent(key, RedisDataType.REDIS_STRING);
+    Object oldVal = context.getRegionProvider().metaPutIfAbsent(key, RedisDataType.REDIS_STRING);
     if (oldVal == RedisDataType.REDIS_PROTECTED)
       throw new RedisDataTypeMismatchException("The key name \"" + key + "\" is protected");
     if (oldVal != null && oldVal != RedisDataType.REDIS_STRING)
@@ -17,7 +17,7 @@ public abstract class StringExecutor extends AbstractExecutor {
   }
   
   protected void checkDataType(ByteArrayWrapper key, ExecutionHandlerContext context) {
-    RedisDataType currentType = context.getRegionCache().getRedisDataType(key);
+    RedisDataType currentType = context.getRegionProvider().getRedisDataType(key);
     if (currentType == null)
       return;
     if (currentType == RedisDataType.REDIS_PROTECTED)

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/StrlenExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/StrlenExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/StrlenExecutor.java
index 8174f1c..389de5a 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/StrlenExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/string/StrlenExecutor.java
@@ -18,7 +18,7 @@ public class StrlenExecutor extends StringExecutor {
   public void executeCommand(Command command, ExecutionHandlerContext context) {
     List<byte[]> commandElems = command.getProcessedCommand();
 
-    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionCache().getStringsRegion();
+    Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
 
     if (commandElems.size() < 2) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.STRLEN));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/org/apache/hadoop/fs/GlobPattern.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/org/apache/hadoop/fs/GlobPattern.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/org/apache/hadoop/fs/GlobPattern.java
new file mode 100644
index 0000000..64a2b6b
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/org/apache/hadoop/fs/GlobPattern.java
@@ -0,0 +1,164 @@
+/**
+ * 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.redis.org.apache.hadoop.fs;
+
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+/**
+ * A class for POSIX glob pattern with brace expansions.
+ */
+public class GlobPattern {
+  private static final char BACKSLASH = '\\';
+  private Pattern compiled;
+  private boolean hasWildcard = false;
+
+  /**
+   * Construct the glob pattern object with a glob pattern string
+   * @param globPattern the glob pattern string
+   */
+  public GlobPattern(String globPattern) {
+    set(globPattern);
+  }
+
+  /**
+   * @return the compiled pattern
+   */
+  public Pattern compiled() {
+    return compiled;
+  }
+
+  /**
+   * Compile glob pattern string
+   * @param globPattern the glob pattern
+   * @return the pattern object
+   */
+  public static Pattern compile(String globPattern) {
+    return new GlobPattern(globPattern).compiled();
+  }
+
+  /**
+   * Match input against the compiled glob pattern
+   * @param s input chars
+   * @return true for successful matches
+   */
+  public boolean matches(CharSequence s) {
+    return compiled.matcher(s).matches();
+  }
+
+  /**
+   * Set and compile a glob pattern
+   * @param glob  the glob pattern string
+   */
+  public void set(String glob) {
+    StringBuilder regex = new StringBuilder();
+    int setOpen = 0;
+    int curlyOpen = 0;
+    int len = glob.length();
+    hasWildcard = false;
+
+    for (int i = 0; i < len; i++) {
+      char c = glob.charAt(i);
+
+      switch (c) {
+      case BACKSLASH:
+        if (++i >= len) {
+          error("Missing escaped character", glob, i);
+        }
+        regex.append(c).append(glob.charAt(i));
+        continue;
+      case '.':
+      case '$':
+      case '(':
+      case ')':
+      case '|':
+      case '+':
+        // escape regex special chars that are not glob special chars
+        regex.append(BACKSLASH);
+        break;
+      case '*':
+        regex.append('.');
+        hasWildcard = true;
+        break;
+      case '?':
+        regex.append('.');
+        hasWildcard = true;
+        continue;
+      case '{': // start of a group
+        regex.append("(?:"); // non-capturing
+        curlyOpen++;
+        hasWildcard = true;
+        continue;
+      case ',':
+        regex.append(curlyOpen > 0 ? '|' : c);
+        continue;
+      case '}':
+        if (curlyOpen > 0) {
+          // end of a group
+          curlyOpen--;
+          regex.append(")");
+          continue;
+        }
+        break;
+      case '[':
+        if (setOpen > 0) {
+          error("Unclosed character class", glob, i);
+        }
+        setOpen++;
+        hasWildcard = true;
+        break;
+      case '^': // ^ inside [...] can be unescaped
+        if (setOpen == 0) {
+          regex.append(BACKSLASH);
+        }
+        break;
+      case '!': // [! needs to be translated to [^
+        regex.append(setOpen > 0 && '[' == glob.charAt(i - 1) ? '^' : '!');
+        continue;
+      case ']':
+        // Many set errors like [][] could not be easily detected here,
+        // as []], []-] and [-] are all valid POSIX glob and java regex.
+        // We'll just let the regex compiler do the real work.
+        setOpen = 0;
+        break;
+      default:
+      }
+      regex.append(c);
+    }
+
+    if (setOpen > 0) {
+      error("Unclosed character class", glob, len);
+    }
+    if (curlyOpen > 0) {
+      error("Unclosed group", glob, len);
+    }
+    compiled = Pattern.compile(regex.toString());
+  }
+
+  /**
+   * @return true if this is a wildcard pattern (with special chars)
+   */
+  public boolean hasWildcard() {
+    return hasWildcard;
+  }
+
+  private static void error(String message, String pattern, int pos) {
+    throw new PatternSyntaxException(message, pattern, pos);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/redis/GemFireRedisServer.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/redis/GemFireRedisServer.java b/gemfire-core/src/main/java/com/gemstone/gemfire/redis/GemFireRedisServer.java
index 662e0a8..821ea08 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/redis/GemFireRedisServer.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/redis/GemFireRedisServer.java
@@ -46,7 +46,7 @@ import com.gemstone.gemfire.internal.redis.ByteToCommandDecoder;
 import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.RegionCache;
+import com.gemstone.gemfire.internal.redis.RegionProvider;
 import com.gemstone.gemfire.internal.redis.executor.hll.HyperLogLogPlus;
 
 /**
@@ -63,6 +63,12 @@ import com.gemstone.gemfire.internal.redis.executor.hll.HyperLogLogPlus;
  * or {@link GemFireRedisServer#STRING_REGION}. The default Region type is 
  * {@link RegionShortcut#PARTITION} although this can be changed by specifying the
  * SystemProperty {@value #DEFAULT_REGION_SYS_PROP_NAME} to a type defined by {@link RegionShortcut}.
+ * If the {@link GemFireRedisServer#NUM_THREADS_SYS_PROP_NAME} system property is set to 0,
+ * one thread per client will be created. Otherwise a worker thread pool of specified size is
+ * used or a default size of 4 * {@link Runtime#availableProcessors()} if the property is not set.
+ * <p>
+ * Setting the AUTH password requires setting the property "redis-password" just as "redis-port"
+ * would be in xml or through GFSH.
  * <p>
  * The supported commands are as follows:
  * <p>
@@ -182,7 +188,7 @@ public class GemFireRedisServer {
    */
   private LogWriter logger;
 
-  private RegionCache regionCache;
+  private RegionProvider regionCache;
 
   private final MetaCacheListener metaListener;
 
@@ -216,12 +222,6 @@ public class GemFireRedisServer {
   public static final String REDIS_META_DATA_REGION = "__ReDiS_MeTa_DaTa";
 
   /**
-   * The field that defines the name of the {@link Region} which holds all of
-   * the lists meta data. The current value of this field is {@value #LISTS_META_DATA_REGION}.
-   */
-  public static final String LISTS_META_DATA_REGION = "__LiStS_MeTa_DaTa";
-
-  /**
    * The system property name used to set the default {@link Region} creation
    * type. The property name is {@value #DEFAULT_REGION_SYS_PROP_NAME} and the
    * acceptable values are types defined by {@link RegionShortcut}, 
@@ -236,28 +236,23 @@ public class GemFireRedisServer {
   public static final String NUM_THREADS_SYS_PROP_NAME = "gemfireredis.numthreads";
 
   /**
-   * This String holds the String representation of the {@link RegionShortcut}
-   * that will be used as the default Region type for all region creation. This
-   * is set by the system property {@value #DEFAULT_REGION_SYS_PROP_NAME} and the
-   * default type is {@link RegionShortcut#PARTITION}.
-   */
-  private static final String regionType = System.getProperty(DEFAULT_REGION_SYS_PROP_NAME, "PARTITION");
-
-  /**
    * The actual {@link RegionShortcut} type specified by the system property
    * {@value #DEFAULT_REGION_SYS_PROP_NAME}.
    */
-  public static final RegionShortcut DEFAULT_REGION_TYPE = setRegion(regionType);
+  public final RegionShortcut DEFAULT_REGION_TYPE;
+
+  private boolean shutdown;
+  private boolean started;
 
   /**
    * Determine the {@link RegionShortcut} type from a String value.
    * If the String value doesn't map to a RegionShortcut type then 
    * {@link RegionShortcut#PARTITION} will be used by default.
    * 
-   * @param regionType The String representation of a {@link RegionShortcut}
    * @return {@link RegionShortcut}
    */
-  private static RegionShortcut setRegion(String regionType) {
+  private static RegionShortcut setRegionType() {
+    String regionType = System.getProperty(DEFAULT_REGION_SYS_PROP_NAME, "PARTITION");
     RegionShortcut type;
     try {
       type = RegionShortcut.valueOf(regionType);
@@ -312,9 +307,9 @@ public class GemFireRedisServer {
 
   /**
    * Constructor for {@link GemFireRedisServer} that will start the
-   * server and bind to the given address and port. Additionally the 
-   * number of threads used by the server to handle clients is specified
-   * as well as the logging level to be used by GemFire
+   * server and bind to the given address and port. Keep in mind that the
+   * log level configuration will only be set if a {@link Cache} does not already
+   * exist, if one already exists then setting that property will have no effect.
    * 
    * @param bindAddress The address to which the server will attempt to bind to
    * @param port The port the server will bind to, will use {@value #DEFAULT_REDIS_SERVER_PORT} by default if argument is less than or equal to 0
@@ -344,6 +339,9 @@ public class GemFireRedisServer {
       }
 
     });
+    this.DEFAULT_REGION_TYPE = setRegionType();
+    this.shutdown = false;
+    this.started = false;
   }
 
   /**
@@ -362,15 +360,18 @@ public class GemFireRedisServer {
    * This is function to call on a {@link GemFireRedisServer} instance
    * to start it running
    */
-  public void start() {
-    try {
-      startGemFire();
-      initializeRedis();
-      startRedisServer();
-    } catch (IOException e) {
-      throw new RuntimeException("Could not start Server", e);
-    } catch (InterruptedException e) {
-      throw new RuntimeException("Could not start Server", e);
+  public synchronized void start() {
+    if (!started) {
+      try {
+        startGemFire();
+        initializeRedis();
+        startRedisServer();
+      } catch (IOException e) {
+        throw new RuntimeException("Could not start Server", e);
+      } catch (InterruptedException e) {
+        throw new RuntimeException("Could not start Server", e);
+      }
+      started = true;
     }
   }
 
@@ -383,20 +384,24 @@ public class GemFireRedisServer {
   private void startGemFire() {
     Cache c = GemFireCacheImpl.getInstance();
     if (c == null) {
-      CacheFactory cacheFactory = new CacheFactory();
-      if (logLevel != null)
-        cacheFactory.set("log-level", logLevel);
-      this.cache = cacheFactory.create();
-    } else
-      this.cache = c;
-    this.logger = this.cache.getLogger();
+      synchronized (GemFireRedisServer.class) {
+        c = GemFireCacheImpl.getInstance();
+        if (c == null) {
+          CacheFactory cacheFactory = new CacheFactory();
+          if (logLevel != null)
+            cacheFactory.set("log-level", logLevel);
+          c = cacheFactory.create();
+        }
+      }
+    }
+    this.cache = c;
+    this.logger = c.getLogger();
   }
 
   private void initializeRedis() {
     synchronized (this.cache) {
       RegionFactory<String, RedisDataType> rfMeta = cache.createRegionFactory(RegionShortcut.REPLICATE);
       rfMeta.addCacheListener(this.metaListener);
-      RegionFactory<String, Integer> rfList = cache.createRegionFactory(RegionShortcut.REPLICATE);
       RegionFactory<ByteArrayWrapper, ByteArrayWrapper> rfString = cache.createRegionFactory(DEFAULT_REGION_TYPE);
       RegionFactory<ByteArrayWrapper, HyperLogLogPlus> rfHLL = cache.createRegionFactory(DEFAULT_REGION_TYPE);
       Region<ByteArrayWrapper, ByteArrayWrapper> stringsRegion;
@@ -408,14 +413,10 @@ public class GemFireRedisServer {
       Region<String, RedisDataType> redisMetaData;
       if ((redisMetaData = this.cache.getRegion(REDIS_META_DATA_REGION)) == null)
         redisMetaData = rfMeta.create(REDIS_META_DATA_REGION);
-      Region<String, Integer> listsMetaData;
-      if ((listsMetaData = this.cache.getRegion(LISTS_META_DATA_REGION)) == null)
-        listsMetaData = rfList.create(LISTS_META_DATA_REGION);
-      this.regionCache = new RegionCache(stringsRegion, hLLRegion, redisMetaData, listsMetaData, expirationFutures, expirationExecutor);
+      this.regionCache = new RegionProvider(stringsRegion, hLLRegion, redisMetaData, expirationFutures, expirationExecutor, this.DEFAULT_REGION_TYPE);
       redisMetaData.put(REDIS_META_DATA_REGION, RedisDataType.REDIS_PROTECTED);
       redisMetaData.put(HLL_REGION, RedisDataType.REDIS_PROTECTED);
       redisMetaData.put(STRING_REGION, RedisDataType.REDIS_PROTECTED);
-      redisMetaData.put(LISTS_META_DATA_REGION, RedisDataType.REDIS_PROTECTED);
     }
     checkForRegions();
   }
@@ -542,9 +543,9 @@ public class GemFireRedisServer {
       final String key = (String) event.getKey();
       final RedisDataType value = event.getOldValue();
       if (value != null && value != RedisDataType.REDIS_STRING && value != RedisDataType.REDIS_HLL && value != RedisDataType.REDIS_PROTECTED) {
-        Region<?, ?> r = this.regionCache.getRegion(Coder.stringToByteArrayWrapper(key));
+        ByteArrayWrapper kW = Coder.stringToByteArrayWrapper(key);
+        Region<?, ?> r = this.regionCache.getRegion(kW);
         if (r != null) { 
-          ByteArrayWrapper kW = Coder.stringToByteArrayWrapper(key);
           this.regionCache.removeRegionReferenceLocally(kW, value);
         }
       }
@@ -579,23 +580,26 @@ public class GemFireRedisServer {
    * Shutdown method for {@link GemFireRedisServer}. This closes the {@link Cache},
    * interrupts all execution and forcefully closes all connections.
    */
-  public void shutdown() {
-    if (logger.infoEnabled())
-      logger.info("GemFireRedisServer shutting down");
-    ChannelFuture closeFuture = this.serverChannel.closeFuture();
-    this.serverChannel.close();
-    Future<?> c = workerGroup.shutdownGracefully();
-    Future<?> c2 = bossGroup.shutdownGracefully();
-    c.syncUninterruptibly();
-    c2.syncUninterruptibly();
-    this.regionCache.close();
-    if (mainThread != null)
-      mainThread.interrupt();
-    for (ScheduledFuture<?> f : this.expirationFutures.values())
-      f.cancel(true);
-    this.expirationFutures.clear();
-    this.expirationExecutor.shutdownNow();
-    closeFuture.syncUninterruptibly();
+  public synchronized void shutdown() {
+    if (!shutdown) {
+      if (logger.infoEnabled())
+        logger.info("GemFireRedisServer shutting down");
+      ChannelFuture closeFuture = this.serverChannel.closeFuture();
+      Future<?> c = workerGroup.shutdownGracefully();
+      Future<?> c2 = bossGroup.shutdownGracefully();
+      this.serverChannel.close();
+      c.syncUninterruptibly();
+      c2.syncUninterruptibly();
+      this.regionCache.close();
+      if (mainThread != null)
+        mainThread.interrupt();
+      for (ScheduledFuture<?> f : this.expirationFutures.values())
+        f.cancel(true);
+      this.expirationFutures.clear();
+      this.expirationExecutor.shutdownNow();
+      closeFuture.syncUninterruptibly();
+      shutdown = true;
+    }
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ConcurrentStartTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ConcurrentStartTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ConcurrentStartTest.java
new file mode 100644
index 0000000..618aca0
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ConcurrentStartTest.java
@@ -0,0 +1,58 @@
+package com.gemstone.gemfire.redis;
+
+import static org.junit.Assert.assertFalse;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class ConcurrentStartTest {
+
+  int numServers = 10;
+  @Test
+  public void testCachelessStart() throws InterruptedException {
+    runNServers(numServers);
+    GemFireCacheImpl.getInstance().close();
+  }
+  @Test
+  public void testCachefulStart() throws InterruptedException {
+    CacheFactory cf = new CacheFactory();
+    cf.set("mcast-port", "0");
+    cf.set("locators", "");
+    Cache c = cf.create();
+    runNServers(numServers);
+    c.close();
+  }
+  
+  private void runNServers(int n) throws InterruptedException {
+    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(numServers);
+    final Thread[] threads = new Thread[n];
+    for (int i = 0; i < n; i++) {
+      final int j = i;
+      Runnable r = new Runnable() {
+
+        @Override
+        public void run() {
+          GemFireRedisServer s = new GemFireRedisServer(ports[j]);
+          s.start();
+          s.shutdown();
+        }
+      };
+      
+      Thread t = new Thread(r);
+      t.setDaemon(true);
+      t.start();
+      threads[i] = t;
+    }
+    for (Thread t : threads)
+      t.join();
+    Cache c = GemFireCacheImpl.getInstance();
+    assertFalse(c.isClosed());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/test/java/com/gemstone/gemfire/redis/HashesJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/redis/HashesJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/HashesJUnitTest.java
new file mode 100755
index 0000000..d41b656
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/HashesJUnitTest.java
@@ -0,0 +1,175 @@
+package com.gemstone.gemfire.redis;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import redis.clients.jedis.Jedis;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.GemFireCache;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class HashesJUnitTest {
+  private static Jedis jedis;
+  private static GemFireRedisServer server;
+  private static GemFireCache cache;
+  private static Random rand;
+  private static int port = 6379;
+
+  @BeforeClass
+  public static void setUp() throws IOException {
+    rand = new Random();
+    CacheFactory cf = new CacheFactory();
+    //cf.set("log-file", "redis.log");
+    cf.set("log-level", "error");
+    cf.set("mcast-port", "0");
+    cf.set("locators", "");
+    cache = cf.create();
+    port = AvailablePortHelper.getRandomAvailableTCPPort();
+    server = new GemFireRedisServer("localhost", port);
+
+    server.start();
+    jedis = new Jedis("localhost", port, 10000000);
+  }
+
+  @Test
+  public void testHMSetHSetHLen() {
+    int num = 10;
+    String key = randString();
+    Map<String, String> hash = new HashMap<String, String>();
+    for (int i = 0; i < num; i++) {
+      hash.put(randString(), randString());
+    }
+    String response = jedis.hmset(key, hash);
+    assertTrue(response.equals("OK"));
+    assertEquals(new Long(hash.size()), jedis.hlen(key));
+
+    key = randString();
+    hash = new HashMap<String, String>();
+    for (int i = 0; i < num; i++) {
+      hash.put(randString(), randString());
+    }
+    Set<String> keys = hash.keySet();
+    Long count = 1L;
+    for (String field: keys) {
+      Long res = jedis.hset(key, field, hash.get(field));
+      assertTrue(res == 1L);
+      assertEquals(count++, jedis.hlen(key));
+    }
+  }
+
+  @Test
+  public void testHMGetHDelHGetAllHVals() {
+    String key = randString();
+    Map<String, String> hash = new HashMap<String, String>();
+    for (int i = 0; i < 10; i++) {
+      String m = randString();
+      String f = randString();
+      hash.put(m, f);
+    }
+    jedis.hmset(key, hash);
+    Set<String> keys = hash.keySet();
+    String[] keyArray = keys.toArray(new String[keys.size()]);
+    List<String> retList = jedis.hmget(key, keyArray);
+
+    for (int i = 0; i < keys.size(); i++) {
+      assertEquals(retList.get(i), hash.get(keyArray[i]));
+    }
+
+    Map<String, String> retMap = jedis.hgetAll(key);
+
+    assertEquals(retMap, hash);
+
+    List<String> retVals = jedis.hvals(key);
+    Set<String> retSet = new HashSet<String>(retVals);
+
+    assertTrue(retSet.containsAll(hash.values()));
+
+    jedis.hdel(key, keyArray);
+    assertTrue(jedis.hlen(key) == 0);
+  }
+
+  @Test
+  public void testHkeys() {
+    String key = randString();
+    Map<String, String> hash = new HashMap<String, String>();
+    for (int i = 0; i < 10; i++) {
+      hash.put(randString(), randString());
+    }
+    String response = jedis.hmset(key, hash);
+
+    Set<String> keys = hash.keySet();
+    Set<String> retSet = jedis.hkeys(key);
+
+    assertTrue(retSet.containsAll(keys));
+  }
+
+  @Test
+  public void testHIncrBy() {
+    String key = randString();
+    String field = randString();
+
+    Long incr = (long) rand.nextInt(50);
+    if (incr == 0)
+      incr++;
+
+    long response1 = jedis.hincrBy(key, field, incr);
+    assertTrue(response1 == incr);
+
+    long response2 = jedis.hincrBy(randString(), randString(), incr);
+    assertTrue(response2 == incr);
+
+    long response3 = jedis.hincrBy(key, field, incr);
+    assertTrue(response3 == 2*incr);
+
+
+    String field1 = randString();
+    Exception ex = null;
+    try {
+      jedis.hincrBy(key, field1, Long.MAX_VALUE);
+      jedis.hincrBy(key, field1, incr);
+    } catch (Exception e) {
+      ex = e;
+    }
+
+    assertNotNull(ex);
+  }
+
+  private String randString() {
+    int length = rand.nextInt(8) + 5;
+    StringBuilder rString = new StringBuilder();
+    for (int i = 0; i < length; i++)
+      rString.append((char) (rand.nextInt(57) + 65));
+    return rString.toString();
+    //return Long.toHexString(Double.doubleToLongBits(Math.random()));
+  }
+
+  @After
+  public void flushAll() {
+    jedis.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+    cache.close();
+    server.shutdown();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ListsJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ListsJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ListsJUnitTest.java
new file mode 100755
index 0000000..6a00775
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ListsJUnitTest.java
@@ -0,0 +1,238 @@
+package com.gemstone.gemfire.redis;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import redis.clients.jedis.Jedis;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.GemFireCache;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class ListsJUnitTest {
+
+  private static Jedis jedis;
+  private static GemFireRedisServer server;
+  private static GemFireCache cache;
+  private static Random rand;
+  private static int port = 6379;
+
+  @BeforeClass
+  public static void setUp() throws IOException {
+    rand = new Random();
+    CacheFactory cf = new CacheFactory();
+    //cf.set("log-file", "redis.log");
+    cf.set("log-level", "error");
+    cf.set("mcast-port", "0");
+    cf.set("locators", "");
+    cache = cf.create();
+    port = AvailablePortHelper.getRandomAvailableTCPPort();
+    server = new GemFireRedisServer("localhost", port);
+
+    server.start();
+    jedis = new Jedis("localhost", port, 10000000);
+  }
+
+  @Test
+  public void testLindex() {
+    int elements = 50;
+    ArrayList<String> strings = new ArrayList<String>();
+    String key = randString();
+    for (int i = 0; i < elements; i++) {
+      String elem = randString();
+      strings.add(elem);
+    }
+    String[] stringArray = strings.toArray(new String[strings.size()]);
+    jedis.rpush(key, stringArray);
+    
+
+    for (int i = 0; i < elements; i++) {
+      String gemString = jedis.lindex(key, i);
+      String s = strings.get(i);
+      assertEquals(gemString, s);
+    }
+  }
+
+  @Test
+  public void testLPopRPush() {
+    int elements = 50;
+    ArrayList<String> strings = new ArrayList<String>();
+    String key = randString();
+    for (int i = 0; i < elements; i++) {
+      String elem = randString();
+      strings.add(elem);
+    }
+    String[] stringArray = strings.toArray(new String[strings.size()]);
+    jedis.rpush(key, stringArray);
+
+    for (int i = 0; i < elements; i++) {
+      String gemString = jedis.lpop(key);
+      String s = strings.get(i);
+      assertEquals(s, gemString);
+    }
+  }
+
+  @Test
+  public void testRPopLPush() {
+    int elements = 500;
+    ArrayList<String> strings = new ArrayList<String>();
+    String key = randString();
+    for (int i = 0; i < elements; i++) {
+      String elem = randString();
+      strings.add(elem);
+    }
+    String[] stringArray = strings.toArray(new String[strings.size()]);
+    jedis.lpush(key, stringArray);
+
+    for (int i = 0; i < elements; i++) {
+      String gemString = jedis.rpop(key);
+      String s = strings.get(i);
+      assertEquals(gemString, s);
+    }
+
+  }
+
+  @Test
+  public void testLRange() {
+    int elements = 10;
+    ArrayList<String> strings = new ArrayList<String>();
+    String key = randString();
+    for (int i = 0; i < elements; i++) {
+      String elem = randString();
+      strings.add(elem);
+    }
+    String[] stringArray = strings.toArray(new String[strings.size()]);
+    jedis.rpush(key, stringArray);
+
+    for (int i = 0; i < elements; i++) {
+      List<String> range = jedis.lrange(key, 0, i);
+      assertEquals(range, strings.subList(0, i+1));
+    }
+
+    for (int i = 0; i < elements; i++) {
+      List<String> range = jedis.lrange(key, i, -1);
+      assertEquals(range, strings.subList(i, strings.size()));
+    }
+  }
+
+  @Test
+  public void testLTrim() {
+    int elements = 5;
+    ArrayList<String> strings = new ArrayList<String>();
+    String key = randString();
+    for (int i = 0; i < elements; i++) {
+      String elem = randString();
+      strings.add(elem);
+    }
+    String[] stringArray = strings.toArray(new String[strings.size()]);
+    jedis.rpush(key, stringArray);
+    // Take off last element one at a time
+    for (int i = elements - 1; i >= 0; i--) {
+      jedis.ltrim(key, 0, i);
+      List<String> range = jedis.lrange(key, 0, -1);
+      assertEquals(range, strings.subList(0, i+1));
+    }
+    jedis.rpop(key);
+    jedis.rpush(key, stringArray);
+    // Take off first element one at a time
+    for (int i = 1; i < elements; i++) {
+      jedis.ltrim(key, 1, -1);
+      List<String> range = jedis.lrange(key, 0, -1);
+      List<String> expected = strings.subList(i, strings.size());
+      assertEquals(range, expected);
+    }
+  }
+
+  @Test
+  public void testLRPushX() {
+    String key = randString();
+    String otherKey = "Other key";
+    jedis.lpush(key, randString());
+    assertTrue(jedis.lpushx(key, randString()) > 0);
+    assertTrue(jedis.rpushx(key, randString()) > 0);
+
+    assertTrue(jedis.lpushx(otherKey, randString()) == 0);
+    assertTrue(jedis.rpushx(otherKey, randString()) == 0);
+
+    jedis.del(key);
+
+    assertTrue(jedis.lpushx(key, randString()) == 0);
+    assertTrue(jedis.rpushx(key, randString()) == 0);
+  }
+
+  @Test
+  public void testLRem() {
+    int elements = 5;
+    ArrayList<String> strings = new ArrayList<String>();
+    String key = randString();
+    for (int i = 0; i < elements; i++) {
+      String elem = randString();
+      strings.add(elem);
+    }
+    String[] stringArray = strings.toArray(new String[strings.size()]);
+    jedis.rpush(key, stringArray);
+
+    for (int i = 0; i < elements; i++) {
+      String remove = strings.remove(0);
+      jedis.lrem(key, 0, remove);
+      List<String> range = jedis.lrange(key, 0, -1);
+      assertEquals(strings, range);
+    }
+  }
+
+  @Test
+  public void testLSet() {
+    int elements = 10;
+    ArrayList<String> strings = new ArrayList<String>();
+    String key = randString();
+    for (int i = 0; i < elements; i++) {
+      String elem = randString();
+      strings.add(elem);
+    }
+    String[] stringArray = strings.toArray(new String[strings.size()]);
+    jedis.rpush(key, stringArray);
+
+    for (int i = 0; i < elements; i++) {
+      String s = randString();
+      strings.set(i, s);
+      jedis.lset(key, i, s);
+      List<String> range = jedis.lrange(key, 0, -1);
+      assertEquals(range, strings);
+    }
+  }
+
+  private String randString() {
+    int length = rand.nextInt(8) + 5;
+    StringBuilder rString = new StringBuilder();
+    for (int i = 0; i < length; i++)
+      rString.append((char) (rand.nextInt(57) + 65));
+    //return rString.toString();
+    return Long.toHexString(Double.doubleToLongBits(Math.random()));
+  }
+
+  @After
+  public void flushAll() {
+    jedis.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+    cache.close();
+    server.shutdown();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/test/java/com/gemstone/gemfire/redis/RedisDistDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/redis/RedisDistDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/RedisDistDUnitTest.java
new file mode 100644
index 0000000..858321d
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/RedisDistDUnitTest.java
@@ -0,0 +1,231 @@
+package com.gemstone.gemfire.redis;
+
+import java.util.Random;
+
+import redis.clients.jedis.Jedis;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache30.CacheTestCase;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+
+import dunit.AsyncInvocation;
+import dunit.Host;
+import dunit.SerializableCallable;
+import dunit.VM;
+
+public class RedisDistDUnitTest extends CacheTestCase {
+
+  public static final String TEST_KEY = "key";
+  public static int pushes = 200;
+  int redisPort = 6379;
+  private Host host;
+  private VM server1;
+  private VM server2;
+  private VM client1;
+  private VM client2;
+
+  private int server1Port;
+  private int server2Port;
+
+  private abstract class ClientTestBase extends SerializableCallable {
+
+    int port;
+    protected ClientTestBase (int port) {
+      this.port = port;
+    }
+
+  }
+
+  public RedisDistDUnitTest() throws Throwable {
+    super("RedisDistTest");  
+  }
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    disconnectAllFromDS();
+    host = Host.getHost(0);
+    server1 = host.getVM(0);
+    server2 = host.getVM(1);
+    client1 = host.getVM(2);
+    client2 = host.getVM(3);  
+    final SerializableCallable<Object> startRedisAdapter = new SerializableCallable<Object>() {
+
+      private static final long serialVersionUID = 1978017907725504294L;
+
+      @Override
+      public Object call() throws Exception {
+        int port = AvailablePortHelper.getRandomAvailableTCPPort();
+        CacheFactory cF = new CacheFactory();
+        cF.set("log-level", "info");
+        cF.set("redis-bind-address", "localhost");
+        cF.set("redis-port", ""+port);
+        cF.set("mcast-port", "40404");
+        cF.create();
+        return Integer.valueOf(port);
+      }
+    };
+    AsyncInvocation i = server1.invokeAsync(startRedisAdapter);
+    server2Port = (Integer) server2.invoke(startRedisAdapter);
+    try {
+      server1Port = (Integer) i.getResult();
+    } catch (Throwable e) {
+      throw new Exception(e);
+    }
+  }
+
+  @Override
+  public void tearDown2() throws Exception {
+    super.tearDown2();
+    disconnectAllFromDS();
+  }
+
+  public void testConcListOps() throws Throwable {
+    final Jedis jedis1 = new Jedis("localhost", server1Port, 10000);
+    final Jedis jedis2 = new Jedis("localhost", server2Port, 10000);
+    final int pushes = 20;
+    class ConcListOps extends ClientTestBase {
+      protected ConcListOps(int port) {
+        super(port);
+      }
+
+      @Override
+      public Object call() throws Exception {
+        Jedis jedis = new Jedis("localhost", port, 10000);
+        Random r = new Random();
+        for (int i = 0; i < pushes; i++) {
+          if (r.nextBoolean()) {
+            jedis.lpush(TEST_KEY, randString());
+          } else {
+            jedis.rpush(TEST_KEY, randString());
+          }
+        }
+        return null;
+      }
+    };
+
+    AsyncInvocation i = client1.invokeAsync(new ConcListOps(server1Port));
+    client2.invoke(new ConcListOps(server2Port));
+    i.getResult();
+    long expected = 2 * pushes;
+    long result1 = jedis1.llen(TEST_KEY);
+    long result2 = jedis2.llen(TEST_KEY);
+    assertEquals(expected, result1);
+    assertEquals(result1, result2);
+  }
+
+
+  public void testConcCreateDestroy() throws Throwable {
+    final int ops = 40;
+    final String hKey = TEST_KEY+"hash";
+    final String lKey = TEST_KEY+"list";
+    final String zKey = TEST_KEY+"zset";
+    final String sKey = TEST_KEY+"set";
+
+    class ConcCreateDestroy extends ClientTestBase{
+      protected ConcCreateDestroy(int port) {
+        super(port);
+      }
+
+      @Override
+      public Object call() throws Exception {
+        Jedis jedis = new Jedis("localhost", port, 10000);
+        Random r = new Random();
+        for (int i = 0; i < ops; i++) {
+          int n = r.nextInt(4);
+          if (n == 0) {
+            if (r.nextBoolean()) {
+              jedis.hset(hKey, randString(), randString());
+            } else {
+              jedis.del(hKey);
+            }
+          } else if (n == 1) {
+            if (r.nextBoolean()) {
+              jedis.lpush(lKey, randString());
+            } else {
+              jedis.del(lKey);
+            }
+          } else if (n == 2) {
+            if (r.nextBoolean()) {
+              jedis.zadd(zKey, r.nextDouble(), randString());
+            } else {
+              jedis.del(zKey);
+            }
+          } else {
+            if (r.nextBoolean()) {
+              jedis.sadd(sKey, randString());
+            } else {
+              jedis.del(sKey);
+            }
+          }
+        }
+        return null;
+      }
+    }
+
+    // Expect to run with no exception
+    AsyncInvocation i = client1.invokeAsync(new ConcCreateDestroy(server1Port));
+    client2.invoke(new ConcCreateDestroy(server2Port));
+    i.getResult();
+  }
+
+  /**
+   * Just make sure there are no unexpected server crashes
+   * @throws Throwable 
+   */
+  public void testConcOps() throws Throwable {
+
+    final int ops = 100;
+    final String hKey = TEST_KEY+"hash";
+    final String lKey = TEST_KEY+"list";
+    final String zKey = TEST_KEY+"zset";
+    final String sKey = TEST_KEY+"set";
+
+    class ConcOps extends ClientTestBase {
+
+      protected ConcOps(int port) {
+        super(port);
+      }
+
+      @Override
+      public Object call() throws Exception {
+        Jedis jedis = new Jedis("localhost", port, 10000);
+        Random r = new Random();
+        for (int i = 0; i < ops; i++) {
+          int n = r.nextInt(4);
+          if (n == 0) {
+            jedis.hset(hKey, randString(), randString());
+            jedis.hgetAll(hKey);
+            jedis.hvals(hKey);
+          } else if (n == 1) {
+            jedis.lpush(lKey, randString());
+            jedis.rpush(lKey, randString());
+            jedis.ltrim(lKey, 0, 100);
+            jedis.lrange(lKey, 0, -1);
+          } else if (n == 2) {
+            jedis.zadd(zKey, r.nextDouble(), randString());
+            jedis.zrangeByLex(zKey, "(a", "[z");
+            jedis.zrangeByScoreWithScores(zKey, 0, 1, 0, 100);
+            jedis.zremrangeByScore(zKey, r.nextDouble(), r.nextDouble());
+          } else {
+            jedis.sadd(sKey, randString());
+            jedis.smembers(sKey);
+            jedis.sdiff(sKey, "afd");
+            jedis.sunionstore("dst", sKey, "afds");
+          }
+        }
+        return null;
+      }
+    }
+
+    // Expect to run with no exception
+    AsyncInvocation i = client1.invokeAsync(new ConcOps(server1Port));
+    client2.invoke(new ConcOps(server2Port));
+    i.getResult();
+  }
+
+  private String randString() {
+    return Long.toHexString(Double.doubleToLongBits(Math.random()));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/test/java/com/gemstone/gemfire/redis/SetsJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/redis/SetsJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/SetsJUnitTest.java
new file mode 100755
index 0000000..abc6060
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/SetsJUnitTest.java
@@ -0,0 +1,242 @@
+package com.gemstone.gemfire.redis;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import redis.clients.jedis.Jedis;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.GemFireCache;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class SetsJUnitTest {
+
+  private static Jedis jedis;
+  private static GemFireRedisServer server;
+  private static GemFireCache cache;
+  private static Random rand;
+  private static int port = 6379;
+
+  @BeforeClass
+  public static void setUp() throws IOException {
+    rand = new Random();
+    CacheFactory cf = new CacheFactory();
+    //cf.set("log-file", "redis.log");
+    cf.set("log-level", "error");
+    cf.set("mcast-port", "0");
+    cf.set("locators", "");
+    cache = cf.create();
+    port = AvailablePortHelper.getRandomAvailableTCPPort();
+    server = new GemFireRedisServer("localhost", port);
+
+    server.start();
+    jedis = new Jedis("localhost", port, 10000000);
+  }
+
+  @Test
+  public void testSAddScard() {
+    int elements = 10;
+    Set<String> strings = new HashSet<String>();
+    String key = randString();
+    for (int i = 0; i < elements; i++) {
+      String elem = randString();
+      strings.add(elem);
+    }
+    String[] stringArray = strings.toArray(new String[strings.size()]);
+    Long response = jedis.sadd(key, stringArray);
+    assertEquals(response, new Long(strings.size()));
+
+    assertEquals(jedis.scard(key), new Long(strings.size()));
+  }
+
+  @Test
+  public void testSMembersIsMember() {
+    int elements = 10;
+    Set<String> strings = new HashSet<String>();
+    String key = randString();
+    for (int i = 0; i < elements; i++) {
+      String elem = randString();
+      strings.add(elem);
+    }
+    String[] stringArray = strings.toArray(new String[strings.size()]);
+    jedis.sadd(key, stringArray);
+
+    Set<String> returnedSet = jedis.smembers(key);
+
+    assertEquals(returnedSet, new HashSet<String>(strings));
+
+    for (String entry: strings) {
+      boolean exists = jedis.sismember(key, entry);
+      assertTrue(exists);
+    }
+  }
+
+  @Test
+  public void testSMove() {
+    String source = randString();
+    String dest = randString();
+    String test = randString();
+    int elements = 10;
+    Set<String> strings = new HashSet<String>();
+    for (int i = 0; i < elements; i++) {
+      String elem = randString();
+      strings.add(elem);
+    }
+    String[] stringArray = strings.toArray(new String[strings.size()]);
+    jedis.sadd(source, stringArray);
+
+    long i = 1;
+    for (String entry: strings) {
+      assertTrue(jedis.smove(source, dest, entry) == 1);
+      assertTrue(jedis.sismember(dest, entry));
+      assertTrue(jedis.scard(source) == strings.size() - i);
+      assertTrue(jedis.scard(dest) == i);
+      i++;
+    }
+
+    assertTrue(jedis.smove(test, dest, randString()) == 0);
+  }
+
+  @Test
+  public void testSDiffAndStore() {
+    int numSets = 3;
+    int elements = 10;
+    String[] keys = new String[numSets];
+    ArrayList<Set<String>> sets = new ArrayList<Set<String>>();
+    for (int j = 0; j < numSets; j++) {
+      keys[j] = randString();
+      Set<String> newSet = new HashSet<String>();
+      for (int i = 0; i < elements; i++)
+        newSet.add(randString());
+      sets.add(newSet);
+    }
+    
+    for (int i = 0; i < numSets; i++) {
+      Set<String> s = sets.get(i);
+      String[] stringArray = s.toArray(new String[s.size()]);
+      jedis.sadd(keys[i], stringArray);
+    }
+    
+    Set<String> result = sets.get(0);
+    for (int i = 1; i < numSets; i++)
+      result.removeAll(sets.get(i));
+    
+    assertEquals(result, jedis.sdiff(keys));
+    
+    String destination = randString();
+    
+    jedis.sdiffstore(destination, keys);
+    
+    Set<String> destResult = jedis.smembers(destination);
+    
+    assertEquals(result, destResult);
+    
+  }
+  
+  @Test
+  public void testSUnionAndStore() {
+    int numSets = 3;
+    int elements = 10;
+    String[] keys = new String[numSets];
+    ArrayList<Set<String>> sets = new ArrayList<Set<String>>();
+    for (int j = 0; j < numSets; j++) {
+      keys[j] = randString();
+      Set<String> newSet = new HashSet<String>();
+      for (int i = 0; i < elements; i++)
+        newSet.add(randString());
+      sets.add(newSet);
+    }
+    
+    for (int i = 0; i < numSets; i++) {
+      Set<String> s = sets.get(i);
+      String[] stringArray = s.toArray(new String[s.size()]);
+      jedis.sadd(keys[i], stringArray);
+    }
+    
+    Set<String> result = sets.get(0);
+    for (int i = 1; i < numSets; i++)
+      result.addAll(sets.get(i));
+    
+    assertEquals(result, jedis.sunion(keys));
+    
+    String destination = randString();
+    
+    jedis.sunionstore(destination, keys);
+    
+    Set<String> destResult = jedis.smembers(destination);
+    
+    assertEquals(result, destResult);
+    
+  }
+  
+  @Test
+  public void testSInterAndStore() {
+    int numSets = 3;
+    int elements = 10;
+    String[] keys = new String[numSets];
+    ArrayList<Set<String>> sets = new ArrayList<Set<String>>();
+    for (int j = 0; j < numSets; j++) {
+      keys[j] = randString();
+      Set<String> newSet = new HashSet<String>();
+      for (int i = 0; i < elements; i++)
+        newSet.add(randString());
+      sets.add(newSet);
+    }
+    
+    for (int i = 0; i < numSets; i++) {
+      Set<String> s = sets.get(i);
+      String[] stringArray = s.toArray(new String[s.size()]);
+      jedis.sadd(keys[i], stringArray);
+    }
+    
+    Set<String> result = sets.get(0);
+    for (int i = 1; i < numSets; i++)
+      result.retainAll(sets.get(i));
+    
+    assertEquals(result, jedis.sinter(keys));
+    
+    String destination = randString();
+    
+    jedis.sinterstore(destination, keys);
+    
+    Set<String> destResult = jedis.smembers(destination);
+    
+    assertEquals(result, destResult);
+    
+  }
+
+  private String randString() {
+    int length = rand.nextInt(8) + 5;
+    StringBuilder rString = new StringBuilder();
+    for (int i = 0; i < length; i++)
+      rString.append((char) (rand.nextInt(57) + 65));
+    return rString.toString();
+    //return Long.toHexString(Double.doubleToLongBits(Math.random()));
+  }
+
+  @After
+  public void flushAll() {
+    jedis.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+    cache.close();
+    server.shutdown();
+  }
+}


[4/4] incubator-geode git commit: Fix for GEODE-109

Posted by sb...@apache.org.
Fix for GEODE-109

1) To fix this floating meta data problem for the redis list implementation, this meta data has been moved into the list region itself
2) Sorted set query failures are fixed by using fully qualified names and also depends on GEODE-146
3) Concurrent region creation/destruction logic completely changed to use dedicated locks for synchronization, fixed distributed deadlock
4) Added integration tests
5) Add javadocs where necessary

This closes #13


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

Branch: refs/heads/develop
Commit: 1a6a0ef53acfdc3931f48881b4b90907c16dc972
Parents: d0d4858
Author: Vito Gavrilov <vg...@pivotal.io>
Authored: Tue Jul 28 09:40:42 2015 -0700
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Thu Aug 6 11:25:54 2015 -0700

----------------------------------------------------------------------
 gemfire-assembly/build.gradle                   |   3 +-
 .../internal/DistributionConfigImpl.java        |   1 -
 .../internal/redis/ByteArrayWrapper.java        |  11 +-
 .../internal/redis/ByteToCommandDecoder.java    |  57 +-
 .../gemstone/gemfire/internal/redis/Coder.java  |  24 +-
 .../gemfire/internal/redis/Command.java         |  25 +-
 .../gemfire/internal/redis/DoubleWrapper.java   |  14 +-
 .../internal/redis/ExecutionHandlerContext.java | 139 +++--
 .../gemfire/internal/redis/Executor.java        |   2 +-
 .../gemfire/internal/redis/Extendable.java      |   6 +-
 .../gemfire/internal/redis/RedisConstants.java  |   2 +-
 .../gemfire/internal/redis/RedisDataType.java   |   9 -
 .../gemfire/internal/redis/RegionCache.java     | 410 --------------
 .../internal/redis/RegionCreationException.java |   9 +-
 .../gemfire/internal/redis/RegionProvider.java  | 531 +++++++++++++++++++
 .../redis/executor/AbstractExecutor.java        |  12 +-
 .../redis/executor/AbstractScanExecutor.java    |   2 +-
 .../internal/redis/executor/DBSizeExecutor.java |   2 +-
 .../internal/redis/executor/DelExecutor.java    |   2 +-
 .../internal/redis/executor/EchoExecutor.java   |   2 +-
 .../internal/redis/executor/ExistsExecutor.java |   2 +-
 .../redis/executor/ExpirationExecutor.java      |   6 +-
 .../redis/executor/ExpireAtExecutor.java        |   4 +-
 .../internal/redis/executor/ExpireExecutor.java |   4 +-
 .../redis/executor/FlushAllExecutor.java        |  15 +-
 .../internal/redis/executor/KeysExecutor.java   |   7 +-
 .../internal/redis/executor/ListQuery.java      |  12 +-
 .../redis/executor/PersistExecutor.java         |   2 +-
 .../internal/redis/executor/PingExecutor.java   |   2 +-
 .../internal/redis/executor/QuitExecutor.java   |   2 +-
 .../internal/redis/executor/ScanExecutor.java   |   4 +-
 .../internal/redis/executor/SortedSetQuery.java |  36 +-
 .../internal/redis/executor/TTLExecutor.java    |   4 +-
 .../internal/redis/executor/TypeExecutor.java   |   2 +-
 .../internal/redis/executor/UnkownExecutor.java |   2 +-
 .../redis/executor/hash/HDelExecutor.java       |   2 +-
 .../redis/executor/hash/HGetAllExecutor.java    |   7 +-
 .../redis/executor/hash/HKeysExecutor.java      |   7 +-
 .../redis/executor/hash/HScanExecutor.java      |   5 +-
 .../redis/executor/hash/HValsExecutor.java      |   9 +-
 .../redis/executor/hash/HashExecutor.java       |   4 +-
 .../redis/executor/hll/HllExecutor.java         |   2 +-
 .../redis/executor/hll/PFAddExecutor.java       |   2 +-
 .../redis/executor/hll/PFCountExecutor.java     |   2 +-
 .../redis/executor/hll/PFMergeExecutor.java     |   4 +-
 .../redis/executor/list/LIndexExecutor.java     |   4 +-
 .../redis/executor/list/LLenExecutor.java       |   2 +-
 .../redis/executor/list/LRangeExecutor.java     |  10 +-
 .../redis/executor/list/LRemExecutor.java       |   4 +-
 .../redis/executor/list/LSetExecutor.java       |   4 +-
 .../redis/executor/list/LTrimExecutor.java      |  26 +-
 .../redis/executor/list/ListExecutor.java       |  26 +-
 .../redis/executor/list/PopExecutor.java        |  23 +-
 .../redis/executor/list/PushExecutor.java       |   2 +-
 .../redis/executor/list/PushXExecutor.java      |   2 +-
 .../org/apache/hadoop/fs/GlobPattern.java       | 164 ------
 .../redis/executor/set/SAddExecutor.java        |   2 +-
 .../redis/executor/set/SCardExecutor.java       |   2 +-
 .../redis/executor/set/SIsMemberExecutor.java   |   2 +-
 .../redis/executor/set/SMembersExecutor.java    |   7 +-
 .../redis/executor/set/SMoveExecutor.java       |   2 +-
 .../redis/executor/set/SPopExecutor.java        |   4 +-
 .../redis/executor/set/SRandMemberExecutor.java |   4 +-
 .../redis/executor/set/SRemExecutor.java        |   2 +-
 .../redis/executor/set/SScanExecutor.java       |   4 +-
 .../redis/executor/set/SetOpExecutor.java       |   9 +-
 .../executor/sortedset/SortedSetExecutor.java   |   4 +-
 .../executor/sortedset/ZRangeByLexExecutor.java |   2 -
 .../sortedset/ZRangeByScoreExecutor.java        |   3 +-
 .../redis/executor/sortedset/ZRemExecutor.java  |   2 +-
 .../sortedset/ZRemRangeByLexExecutor.java       |   3 +-
 .../sortedset/ZRemRangeByRankExecutor.java      |   4 +-
 .../sortedset/ZRemRangeByScoreExecutor.java     |   4 +-
 .../redis/executor/sortedset/ZScanExecutor.java |   5 +-
 .../redis/executor/string/AppendExecutor.java   |   2 +-
 .../redis/executor/string/BitCountExecutor.java |   2 +-
 .../redis/executor/string/BitOpExecutor.java    |   2 +-
 .../redis/executor/string/BitPosExecutor.java   |   2 +-
 .../redis/executor/string/DecrByExecutor.java   |   2 +-
 .../redis/executor/string/DecrExecutor.java     |   4 +-
 .../redis/executor/string/GetBitExecutor.java   |   2 +-
 .../redis/executor/string/GetExecutor.java      |   2 +-
 .../redis/executor/string/GetRangeExecutor.java |   2 +-
 .../redis/executor/string/GetSetExecutor.java   |   2 +-
 .../redis/executor/string/IncrByExecutor.java   |   2 +-
 .../executor/string/IncrByFloatExecutor.java    |   2 +-
 .../redis/executor/string/IncrExecutor.java     |   2 +-
 .../redis/executor/string/MGetExecutor.java     |   2 +-
 .../redis/executor/string/MSetExecutor.java     |   2 +-
 .../redis/executor/string/MSetNXExecutor.java   |   2 +-
 .../redis/executor/string/SetBitExecutor.java   |   2 +-
 .../redis/executor/string/SetEXExecutor.java    |   4 +-
 .../redis/executor/string/SetExecutor.java      |   4 +-
 .../redis/executor/string/SetNXExecutor.java    |   2 +-
 .../redis/executor/string/SetRangeExecutor.java |   4 +-
 .../redis/executor/string/StringExecutor.java   |   4 +-
 .../redis/executor/string/StrlenExecutor.java   |   2 +-
 .../redis/org/apache/hadoop/fs/GlobPattern.java | 164 ++++++
 .../gemfire/redis/GemFireRedisServer.java       | 130 ++---
 .../gemfire/redis/ConcurrentStartTest.java      |  58 ++
 .../gemstone/gemfire/redis/HashesJUnitTest.java | 175 ++++++
 .../gemstone/gemfire/redis/ListsJUnitTest.java  | 238 +++++++++
 .../gemfire/redis/RedisDistDUnitTest.java       | 231 ++++++++
 .../gemstone/gemfire/redis/SetsJUnitTest.java   | 242 +++++++++
 .../gemfire/redis/SortedSetsJUnitTest.java      | 414 +++++++++++++++
 .../gemfire/redis/StringsJunitTest.java         | 296 +++++++++++
 106 files changed, 2789 insertions(+), 958 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-assembly/build.gradle b/gemfire-assembly/build.gradle
index 0e51563..f65930d 100755
--- a/gemfire-assembly/build.gradle
+++ b/gemfire-assembly/build.gradle
@@ -112,7 +112,8 @@ def cp = {
       it.contains('spring-core') ||
       it.contains('spring-shell') ||
       it.contains('snappy-java') ||
-      it.contains('hbase')
+      it.contains('hbase') ||
+      it.contains('netty')
     }.join(' ') 
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
index b8dfeb3..3707ff3 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
@@ -30,7 +30,6 @@ import com.gemstone.gemfire.internal.ConfigSource;
 import com.gemstone.gemfire.internal.SocketCreator;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.process.ProcessLauncherContext;
-import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.memcached.GemFireMemcachedServer;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ByteArrayWrapper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ByteArrayWrapper.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ByteArrayWrapper.java
index 2d617da..fb2bc21 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ByteArrayWrapper.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ByteArrayWrapper.java
@@ -12,7 +12,7 @@ import com.gemstone.gemfire.DataSerializer;
  * This class is a wrapper for the any Regions that need to store a 
  * byte[]. The only data this an instance will store is a byte[]
  * for the data but it is also serializable and comparable so it is able to be used
- * in querying. The hash code and to string variant are created lazily
+ * in querying
  * 
  * @author Vitaliy Gavrilov
  *
@@ -97,6 +97,13 @@ public class ByteArrayWrapper implements DataSerializable, Comparable<ByteArrayW
     return this.hashCode;
   }
 
+
+  /**
+   * This equals is neither symmetric and therefore not transitive, 
+   * because a String with the same underlying bytes is considered
+   * equal. Clearly calling {@link String#equals(Object)) would not 
+   * yield the same result
+   */
   @Override
   public boolean equals(Object other) {
     if (other instanceof ByteArrayWrapper)
@@ -109,7 +116,7 @@ public class ByteArrayWrapper implements DataSerializable, Comparable<ByteArrayW
 
   /**
    * This is a byte to byte comparator, it is not lexicographical but purely compares
-   * byte values
+   * byte by byte values
    */
   @Override
   public int compareTo(ByteArrayWrapper other) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ByteToCommandDecoder.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ByteToCommandDecoder.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ByteToCommandDecoder.java
index 441ab06..7e307fe 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ByteToCommandDecoder.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ByteToCommandDecoder.java
@@ -4,14 +4,37 @@ import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.ByteToMessageDecoder;
 
-import java.nio.BufferUnderflowException;
 import java.util.ArrayList;
 import java.util.List;
 
-
+/**
+ * This is the first part of the channel pipeline for Netty. Here incoming
+ * bytes are read and a created {@link Command} is sent down the pipeline.
+ * It is unfortunate that this class is not {@link Sharable} because no state
+ * is kept in this class. State is kept by {@link ByteToMessageDecoder}, it may
+ * be worthwhile to look at a different decoder setup as to avoid allocating a decoder
+ * for every new connection.
+ * <p>
+ * The code flow of the protocol parsing may not be exactly Java like, but this is done 
+ * very intentionally. It was found that in cases where large Redis requests are sent
+ * that end up being fragmented, throwing exceptions when the command could not be fully
+ * parsed took up an enormous amount of cpu time. The simplicity of the Redis protocol
+ * allows us to just back out and wait for more data, while exceptions are left to 
+ * malformed requests which should never happen if using a proper Redis client.
+ * 
+ * @author Vitaliy Gavrilov
+ *
+ */
 public class ByteToCommandDecoder extends ByteToMessageDecoder {
 
-
+  /**
+   * Important note
+   * 
+   * Do not use '' <-- java primitive chars. Redis uses {@link Coder#CHARSET}
+   * encoding so we should not risk java handling char to byte conversions, rather 
+   * just hard code {@link Coder#CHARSET} chars as bytes
+   */
+  
   private static final byte rID = 13; // '\r';
   private static final byte nID = 10; // '\n';
   private static final byte bulkStringID = 36; // '$';
@@ -35,18 +58,7 @@ public class ByteToCommandDecoder extends ByteToMessageDecoder {
     } while (in.isReadable()); // Try to take advantage of pipelining if it is being used
   }
 
-  /**
-   * The only public method for CommandParser is parse. It will take a buffer
-   * and break up the individual pieces into a list is char[] for the caller
-   * based on the Redis protocol.
-   * 
-   * @param buffer The buffer to read the command from
-   * @return A new {@link Command} object
-   * @throws RedisCommandParserException Thrown when the command has illegal syntax
-   * @throws BufferUnderflowException Thrown when the parser runs out of chars
-   * to read when it still expects chars to remain in the command
-   */
-  public static Command parse(ByteBuf buffer) throws RedisCommandParserException {
+  private Command parse(ByteBuf buffer) throws RedisCommandParserException {
     if (buffer == null)
       throw new NullPointerException();
     if (!buffer.isReadable())
@@ -63,14 +75,7 @@ public class ByteToCommandDecoder extends ByteToMessageDecoder {
     return new Command(commandElems);
   }
 
-  /**
-   * Helper method to parse the array which contains the Redis command
-   * 
-   * @param commandElems The list to add the elements of the command to
-   * @param buffer The buffer to read from
-   * @throws RedisCommandParserException Thrown when command contains illegal syntax
-   */
-  private static boolean parseArray(ArrayList<byte[]> commandElems, ByteBuf buffer) throws RedisCommandParserException { 
+  private boolean parseArray(ArrayList<byte[]> commandElems, ByteBuf buffer) throws RedisCommandParserException { 
     byte currentChar;
     int arrayLength = parseCurrentNumber(buffer);
     if (arrayLength == Integer.MIN_VALUE || !parseRN(buffer))
@@ -100,7 +105,7 @@ public class ByteToCommandDecoder extends ByteToMessageDecoder {
    * @return byte[] representation of the Bulk String read
    * @throws RedisCommandParserException Thrown when there is illegal syntax
    */
-  private static byte[] parseBulkString(ByteBuf buffer) throws RedisCommandParserException {
+  private byte[] parseBulkString(ByteBuf buffer) throws RedisCommandParserException {
     int bulkStringLength = parseCurrentNumber(buffer);
     if (bulkStringLength == Integer.MIN_VALUE)
       return null;
@@ -126,7 +131,7 @@ public class ByteToCommandDecoder extends ByteToMessageDecoder {
    * @param buffer Buffer to read
    * @return The number found at the beginning of the buffer
    */
-  private static int parseCurrentNumber(ByteBuf buffer) {
+  private int parseCurrentNumber(ByteBuf buffer) {
     int number = 0;
     int readerIndex = buffer.readerIndex();
     byte b = 0;
@@ -153,7 +158,7 @@ public class ByteToCommandDecoder extends ByteToMessageDecoder {
    * @throws RedisCommandParserException Thrown when the next two characters
    * are not "\r\n"
    */
-  private static boolean parseRN(ByteBuf buffer) throws RedisCommandParserException {
+  private boolean parseRN(ByteBuf buffer) throws RedisCommandParserException {
     if (!buffer.isReadable(2))
       return false;
     byte b = buffer.readByte();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Coder.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Coder.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Coder.java
index 4792eec..9415cd3 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Coder.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Coder.java
@@ -10,10 +10,15 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 
 import com.gemstone.gemfire.cache.query.Struct;
 
+/**
+ * This is a safe encoder and decoder for all redis matching needs
+ * 
+ * @author Vitaliy Gavrilov
+ *
+ */
 public class Coder {
 
   /*
@@ -121,23 +126,6 @@ public class Coder {
     return response;
   }
 
-  public static final ByteBuf getBulkStringArrayResponse(ByteBufAllocator alloc, Set<String> items) {
-    Iterator<String> it = items.iterator();
-    ByteBuf response = alloc.buffer();
-    response.writeByte(ARRAY_ID);
-    response.writeBytes(intToBytes(items.size()));
-    response.writeBytes(CRLFar);
-    while(it.hasNext()) {
-      String next = it.next();
-      response.writeByte(BULK_STRING_ID);
-      response.writeBytes(intToBytes(next.length()));
-      response.writeBytes(CRLFar);
-      response.writeBytes(stringToBytes(next));
-      response.writeBytes(CRLFar);
-    }
-    return response;
-  }
-
   public static final ByteBuf getBulkStringArrayResponse(ByteBufAllocator alloc, List<String> items) {
     Iterator<String> it = items.iterator();
     ByteBuf response = alloc.buffer();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Command.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Command.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Command.java
index 368a5d7..ae5f3f7 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Command.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Command.java
@@ -9,16 +9,6 @@ import java.util.List;
  * The command class is used in holding a received Redis command. Each sent 
  * command resides in an instance of this class. This class is designed to be
  * used strictly by getter and setter methods.
- * <p>
- * The contents include the following
- * <p>
- * <li>The channel from which the command was read and to where
- * the response will be written.</li>
- * <li>The list of elements in the command. Every command is sent as an array of BulkStrings.
- * For example if the command "SADD key member1 member2 member3" was sent, the list would contain
- * {"SADD", "key", "member1", "member2", "member3"}.
- * <li>The {@link RedisCommandType}</li>
- * <li>The response to be written back to the client</li>
  * 
  * @author Vitaliy Gavrilov
  *
@@ -113,10 +103,11 @@ public class Command {
    */
   public String getStringKey() {
     if (this.commandElems.size() > 1) {
-      if (this.key == null) {
+      if (this.bytes == null) {
         this.bytes = new ByteArrayWrapper(this.commandElems.get(1));
         this.key = this.bytes.toString();
-      }
+      } else if (this.key == null)
+        this.key = this.bytes.toString();
       return this.key;
     } else 
       return null;
@@ -130,4 +121,14 @@ public class Command {
     } else 
       return null;
   }
+
+  @Override
+  public String toString() {
+    StringBuilder b = new StringBuilder();
+    for (byte[] bs : this.commandElems) {
+      b.append(Coder.bytesToString(bs));
+      b.append(' ');
+    }
+    return b.toString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/DoubleWrapper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/DoubleWrapper.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/DoubleWrapper.java
index f2b4e50..ed5fb99 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/DoubleWrapper.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/DoubleWrapper.java
@@ -7,6 +7,12 @@ import java.io.IOException;
 import com.gemstone.gemfire.DataSerializable;
 import com.gemstone.gemfire.DataSerializer;
 
+/**
+ * This is a wrapper class for doubles, similar to {@link ByteArrayWrapper}
+ * 
+ * @author Vitaliy Gavrilov
+ *
+ */
 public class DoubleWrapper implements DataSerializable, Comparable<Object> {
 
   private static final long serialVersionUID = 6946858357297398633L;
@@ -35,14 +41,6 @@ public class DoubleWrapper implements DataSerializable, Comparable<Object> {
     Double other;
     if (arg0 instanceof DoubleWrapper) {
       other = ((DoubleWrapper) arg0).score;
-    } else if (arg0 instanceof String) {
-      String arg = (String) arg0;
-      if (arg.equalsIgnoreCase("INFINITY"))
-        other = Double.POSITIVE_INFINITY;
-      else if (arg.equalsIgnoreCase("-INFINITY"))
-        other = Double.NEGATIVE_INFINITY;
-      else
-        return 0;
     } else if (arg0 instanceof Double) {
       other = (Double) arg0;
     } else

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ExecutionHandlerContext.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ExecutionHandlerContext.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ExecutionHandlerContext.java
index 5f51c35..cf20ea8 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ExecutionHandlerContext.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/ExecutionHandlerContext.java
@@ -15,17 +15,33 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheClosedException;
 import com.gemstone.gemfire.cache.CacheTransactionManager;
 import com.gemstone.gemfire.cache.RegionDestroyedException;
 import com.gemstone.gemfire.cache.TransactionException;
 import com.gemstone.gemfire.cache.TransactionId;
 import com.gemstone.gemfire.cache.UnsupportedOperationInTransactionException;
+import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
 import com.gemstone.gemfire.internal.redis.executor.transactions.TransactionExecutor;
 import com.gemstone.gemfire.redis.GemFireRedisServer;
 
+/**
+ * This class extends {@link ChannelInboundHandlerAdapter} from Netty and it is
+ * the last part of the channel pipeline. The {@link ByteToCommandDecoder} forwards a
+ * {@link Command} to this class which executes it and sends the result back to the
+ * client. Additionally, all exception handling is done by this class. 
+ * <p>
+ * Besides being part of Netty's pipeline, this class also serves as a context to the
+ * execution of a command. It abstracts transactions, provides access to the {@link RegionProvider}
+ * and anything else an executing {@link Command} may need.
+ * 
+ * @author Vitaliy Gavrilov
+ *
+ */
 public class ExecutionHandlerContext extends ChannelInboundHandlerAdapter {
 
-  private static final int MAXIMUM_NUM_RETRIES = 5;
+  private static final int WAIT_REGION_DSTRYD_MILLIS = 100;
+  private static final int MAXIMUM_NUM_RETRIES = (1000*60)/WAIT_REGION_DSTRYD_MILLIS; // 60 seconds total
 
   private final Cache cache;
   private final GemFireRedisServer server;
@@ -44,12 +60,23 @@ public class ExecutionHandlerContext extends ChannelInboundHandlerAdapter {
    * Queue of commands for a given transaction
    */
   private Queue<Command> transactionQueue;
-  private final RegionCache regionCache;
+  private final RegionProvider regionProvider;
   private final byte[] authPwd;
 
   private boolean isAuthenticated;
 
-  public ExecutionHandlerContext(Channel ch, Cache cache, RegionCache regions, GemFireRedisServer server, byte[] pwd) {
+  /**
+   * Default constructor for execution contexts. 
+   * 
+   * @param ch Channel used by this context, should be one to one
+   * @param cache The Geode cache instance of this vm
+   * @param regionProvider The region provider of this context
+   * @param server Instance of the server it is attached to, only used so that any execution can initiate a shutdwon
+   * @param pwd Authentication password for each context, can be null
+   */
+  public ExecutionHandlerContext(Channel ch, Cache cache, RegionProvider regionProvider, GemFireRedisServer server, byte[] pwd) {
+    if (ch == null || cache == null || regionProvider == null || server == null)
+      throw new IllegalArgumentException("Only the authentication password may be null");
     this.cache = cache;
     this.server = server;
     this.logger = cache.getLogger();
@@ -67,7 +94,7 @@ public class ExecutionHandlerContext extends ChannelInboundHandlerAdapter {
     this.byteBufAllocator = channel.alloc();
     this.transactionID = null;
     this.transactionQueue = null; // Lazy
-    this.regionCache = regions;
+    this.regionProvider = regionProvider;
     this.authPwd = pwd;
     this.isAuthenticated = pwd != null ? false : true;
   }
@@ -78,19 +105,25 @@ public class ExecutionHandlerContext extends ChannelInboundHandlerAdapter {
     }
   }
 
-  private void writeToChannel(Object message) {
+  private void writeToChannel(ByteBuf message) {
     channel.write(message, channel.voidPromise());
     if (!needChannelFlush.getAndSet(true)) {
       this.lastExecutor.execute(flusher);
     }
   }
 
+  /**
+   * This will handle the execution of received commands
+   */
   @Override
   public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
     Command command = (Command) msg;
     executeCommand(ctx, command);
   }
 
+  /**
+   * Exception handler for the entire pipeline
+   */
   @Override
   public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
     if (cause instanceof IOException) {
@@ -107,15 +140,16 @@ public class ExecutionHandlerContext extends ChannelInboundHandlerAdapter {
       response = Coder.getWrongTypeResponse(this.byteBufAllocator, cause.getMessage());
     else if (cause instanceof DecoderException && cause.getCause() instanceof RedisCommandParserException)
       response = Coder.getErrorResponse(this.byteBufAllocator, RedisConstants.PARSING_EXCEPTION_MESSAGE);
-    else if (cause instanceof RegionCreationException)
+    else if (cause instanceof RegionCreationException) {
+      this.logger.error(cause);
       response = Coder.getErrorResponse(this.byteBufAllocator, RedisConstants.ERROR_REGION_CREATION);
-    else if (cause instanceof InterruptedException)
+    } else if (cause instanceof InterruptedException || cause instanceof CacheClosedException)
       response = Coder.getErrorResponse(this.byteBufAllocator, RedisConstants.SERVER_ERROR_SHUTDOWN);
     else if (cause instanceof IllegalStateException) {
-      response = Coder.getErrorResponse(this.byteBufAllocator,  cause.getMessage());
+      response = Coder.getErrorResponse(this.byteBufAllocator, cause.getMessage());
     } else {
       if (this.logger.errorEnabled())
-        this.logger.error("GemFireRedisServer-Unexpected error handler", cause);
+        this.logger.error("GemFireRedisServer-Unexpected error handler for " + ctx.channel(), cause);
       response = Coder.getErrorResponse(this.byteBufAllocator, RedisConstants.SERVER_ERROR_MESSAGE);
     }
     return response;
@@ -129,17 +163,7 @@ public class ExecutionHandlerContext extends ChannelInboundHandlerAdapter {
     ctx.close();
   }
 
-  /**
-   * This method is used to execute the command. The executor is 
-   * determined by the {@link RedisCommandType} and then the execution
-   * is started.
-   * 
-   * @param command Command to be executed
-   * @param cache The Cache instance of this server
-   * @param client The client data associated with the client
-   * @throws Exception 
-   */
-  public void executeCommand(ChannelHandlerContext ctx, Command command) throws Exception {
+  private void executeCommand(ChannelHandlerContext ctx, Command command) throws Exception {
     RedisCommandType type = command.getCommandType();
     Executor exec = type.getExecutor();
     if (isAuthenticated) {
@@ -150,7 +174,7 @@ public class ExecutionHandlerContext extends ChannelInboundHandlerAdapter {
       if (hasTransaction() && !(exec instanceof TransactionExecutor))
         executeWithTransaction(ctx, exec, command);
       else
-        executeWithoutTransaction(exec, command, MAXIMUM_NUM_RETRIES); 
+        executeWithoutTransaction(exec, command); 
 
       if (hasTransaction() && command.getCommandType() != RedisCommandType.MULTI) {
         writeToChannel(Coder.getSimpleStringResponse(this.byteBufAllocator, RedisConstants.COMMAND_QUEUED));
@@ -179,31 +203,23 @@ public class ExecutionHandlerContext extends ChannelInboundHandlerAdapter {
    * 
    * @param exec Executor to use
    * @param command Command to execute
-   * @param cache Cache instance
-   * @param client Client data associated with client
-   * @param n Recursive max depth of retries
    * @throws Exception Throws exception if exception is from within execution and not to be handled
    */
-  private void executeWithoutTransaction(final Executor exec, Command command, int n) throws Exception {
-    try {
-      exec.executeCommand(command, this);
-    } catch (RegionDestroyedException e) {
-      if (n > 0)
-        executeWithoutTransaction(exec, command, n - 1);
-      else
-        throw e;
+  private void executeWithoutTransaction(final Executor exec, Command command) throws Exception {
+    Exception cause = null;
+    for (int i = 0; i < MAXIMUM_NUM_RETRIES; i++) {
+      try {
+        exec.executeCommand(command, this);
+        return;
+      } catch (Exception e) {
+        cause = e;
+        if (e instanceof RegionDestroyedException || e.getCause() instanceof QueryInvocationTargetException)
+          Thread.sleep(WAIT_REGION_DSTRYD_MILLIS);
+      }
     }
+    throw cause;
   }
 
-  /**
-   * Private method to execute a command when a transaction has been started
-   * 
-   * @param exec Executor to use
-   * @param command Command to execute
-   * @param cache Cache instance
-   * @param client Client data associated with client
-   * @throws Exception Throws exception if exception is from within execution and unrelated to transactions
-   */
   private void executeWithTransaction(ChannelHandlerContext ctx, final Executor exec, Command command) throws Exception {
     CacheTransactionManager txm = cache.getCacheTransactionManager();
     TransactionId transactionId = getTransactionID();
@@ -276,34 +292,71 @@ public class ExecutionHandlerContext extends ChannelInboundHandlerAdapter {
     return this.transactionQueue;
   }
 
+  /**
+   * {@link ByteBuf} allocator for this context. All executors
+   * must use this pooled allocator as opposed to having unpooled buffers
+   * for maximum performance
+   * 
+   * @return allocator instance
+   */
   public ByteBufAllocator getByteBufAllocator() {
     return this.byteBufAllocator;
   }
 
-  public RegionCache getRegionCache() {
-    return this.regionCache;
+  /**
+   * Gets the provider of Regions
+   * 
+   * @return Provider
+   */
+  public RegionProvider getRegionProvider() {
+    return this.regionProvider;
   }
 
+  /**
+   * Getter for manager to allow pausing and resuming transactions
+   * @return Instance
+   */
   public CacheTransactionManager getCacheTransactionManager() {
     return this.cache.getCacheTransactionManager();
   }
 
+  /**
+   * Getter for logger
+   * @return instance
+   */
   public LogWriter getLogger() {
     return this.cache.getLogger();
   }
 
+  /**
+   * Get the channel for this context
+   * @return instance
+   *
   public Channel getChannel() {
     return this.channel;
   }
+   */
 
+  /**
+   * Get the authentication password, this will be same server wide.
+   * It is exposed here as opposed to {@link GemFireRedisServer}.
+   * @return password
+   */
   public byte[] getAuthPwd() {
     return this.authPwd;
   }
 
+  /**
+   * Checker if user has authenticated themselves
+   * @return True if no authentication required or authentication complete, false otherwise
+   */
   public boolean isAuthenticated() {
     return this.isAuthenticated;
   }
 
+  /**
+   * Lets this context know the authentication is complete
+   */
   public void setAuthenticationVerified() {
     this.isAuthenticated = true;
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Executor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Executor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Executor.java
index d993589..304d19c 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Executor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Executor.java
@@ -15,7 +15,7 @@ public interface Executor {
    * a response
    * 
    * @param command The command to be executed
-   * @param context The client data associated with the client
+   * @param context The execution context by which this command is to be executed
    */
   public void executeCommand(Command command, ExecutionHandlerContext context);
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Extendable.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Extendable.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Extendable.java
index 889e5b2..f4dd122 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Extendable.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/Extendable.java
@@ -1,7 +1,7 @@
 package com.gemstone.gemfire.internal.redis;
 
 /**
- * This defines a command that can be extended,d there may need some level of abstraction
+ * This defines a command that can be extended, and there may need some level of abstraction
  * 
  * @author Vitaliy Gavrilov
  *
@@ -9,8 +9,8 @@ package com.gemstone.gemfire.internal.redis;
 public interface Extendable {
 
   /**
-   * 
-   * @return
+   * Getter for error message in case of argument arity mismatch
+   * @return Error string
    */
   public String getArgsError();
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RedisConstants.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RedisConstants.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RedisConstants.java
index 6fe77d7..9325820 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RedisConstants.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RedisConstants.java
@@ -3,7 +3,7 @@ package com.gemstone.gemfire.internal.redis;
 
 public class RedisConstants {
 
-  public static final int NUM_DEFAULT_KEYS = 4;
+  public static final int NUM_DEFAULT_KEYS = 3;
 
   /*
    * Responses

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RedisDataType.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RedisDataType.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RedisDataType.java
index 38febe2..febd371 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RedisDataType.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RedisDataType.java
@@ -23,7 +23,6 @@ public enum RedisDataType {
    * Strings Regions
    */
   REDIS_STRING {
-
     @Override
     public String toString() {
       return "string";
@@ -34,7 +33,6 @@ public enum RedisDataType {
    * Hashes Regions
    */
   REDIS_HASH {
-
     @Override
     public String toString() {
       return "hash";
@@ -45,7 +43,6 @@ public enum RedisDataType {
    * Lists Regions
    */
   REDIS_LIST {
-
     @Override
     public String toString() {
       return "list";
@@ -56,7 +53,6 @@ public enum RedisDataType {
    * Sets Regions
    */
   REDIS_SET {
-    
     @Override
     public String toString() {
       return "set";
@@ -67,7 +63,6 @@ public enum RedisDataType {
    * SortedSets Regions
    */
   REDIS_SORTEDSET {
-    
     @Override
     public String toString() {
       return "zset";
@@ -78,7 +73,6 @@ public enum RedisDataType {
    * HyperLogLog Regions
    */
   REDIS_HLL {
-    
     @Override
     public String toString() {
       return "hyperloglog";
@@ -89,7 +83,6 @@ public enum RedisDataType {
    * Regions protected from overwrite or deletion
    */
   REDIS_PROTECTED {
-    
     @Override
     public String toString() {
       return "protected";
@@ -100,8 +93,6 @@ public enum RedisDataType {
    * None
    */
   NONE {
-    
-    
     @Override
     public String toString() {
       return "none";

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionCache.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionCache.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionCache.java
deleted file mode 100644
index 68f50ba..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionCache.java
+++ /dev/null
@@ -1,410 +0,0 @@
-package com.gemstone.gemfire.internal.redis;
-
-import java.io.Closeable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-import com.gemstone.gemfire.LogWriter;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheTransactionManager;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.TransactionId;
-import com.gemstone.gemfire.cache.query.IndexNameConflictException;
-import com.gemstone.gemfire.cache.query.Query;
-import com.gemstone.gemfire.cache.query.QueryService;
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.redis.executor.ExpirationExecutor;
-import com.gemstone.gemfire.internal.redis.executor.ListQuery;
-import com.gemstone.gemfire.internal.redis.executor.SortedSetQuery;
-import com.gemstone.gemfire.internal.redis.executor.hll.HyperLogLogPlus;
-import com.gemstone.gemfire.management.cli.Result;
-import com.gemstone.gemfire.management.cli.Result.Status;
-import com.gemstone.gemfire.management.internal.cli.commands.CreateAlterDestroyRegionCommands;
-import com.gemstone.gemfire.redis.GemFireRedisServer;
-
-
-public class RegionCache implements Closeable {
-
-  private final ConcurrentHashMap<ByteArrayWrapper, Region<?, ?>> regions;
-
-  /**
-   * This is the Redis meta data {@link Region} that holds the {@link RedisDataType}
-   * information for all Regions created. The mapping is a {@link String} key which is the name
-   * of the {@link Region} created to hold the data to the RedisDataType it contains.
-   */
-  private final Region<String, RedisDataType> redisMetaRegion;
-
-  /**
-   * This is the {@link RedisDataType#REDIS_LIST} meta data {@link Region}. Here each list
-   * stores the index of the head and tail of the list
-   */
-  private final Region<String, Integer> listsMetaRegion;
-
-  /**
-   * This is the {@link RedisDataType#REDIS_STRING} {@link Region}. This is the Region
-   * that stores all string contents
-   */
-  private final Region<ByteArrayWrapper, ByteArrayWrapper> stringsRegion;
-
-  /**
-   * This is the {@link RedisDataType#REDIS_HLL} {@link Region}. This is the Region
-   * that stores all HyperLogLog contents
-   */
-  private final Region<ByteArrayWrapper, HyperLogLogPlus> hLLRegion;
-
-  private final Cache cache;
-  private final QueryService queryService;
-  private final ConcurrentMap<ByteArrayWrapper, Map<Enum<?>, Query>> preparedQueries = new ConcurrentHashMap<ByteArrayWrapper, Map<Enum<?>, Query>>();
-  private final ConcurrentMap<ByteArrayWrapper, ScheduledFuture<?>> expirationsMap;
-  private final ScheduledExecutorService expirationExecutor;
-  private static final CreateAlterDestroyRegionCommands cliCmds = new CreateAlterDestroyRegionCommands();
-
-  public RegionCache(Region<ByteArrayWrapper, ByteArrayWrapper> stringsRegion, Region<ByteArrayWrapper, HyperLogLogPlus> hLLRegion, Region<String, RedisDataType> redisMetaRegion, Region<String, Integer> listsMetaRegion, ConcurrentMap<ByteArrayWrapper, ScheduledFuture<?>> expirationsMap, ScheduledExecutorService expirationExecutor) {
-    if (stringsRegion == null || hLLRegion == null || redisMetaRegion == null || listsMetaRegion == null)
-      throw new NullPointerException();
-    this.regions = new ConcurrentHashMap<ByteArrayWrapper, Region<?, ?>>();
-    this.stringsRegion = stringsRegion;
-    this.hLLRegion = hLLRegion;
-    this.redisMetaRegion = redisMetaRegion;
-    this.listsMetaRegion = listsMetaRegion;
-    this.cache = GemFireCacheImpl.getInstance();
-    this.queryService = cache.getQueryService();
-    this.expirationsMap = expirationsMap;
-    this.expirationExecutor = expirationExecutor;
-  }
-
-  public boolean existsKey(ByteArrayWrapper key) {
-    return this.redisMetaRegion.containsKey(key.toString());
-  }
-
-  public Set<String> metaKeySet() {
-    return this.redisMetaRegion.keySet();
-  }
-
-  public Set<Map.Entry<String, RedisDataType>> metaEntrySet() {
-    return this.redisMetaRegion.entrySet();
-  }
-
-  public int getMetaSize() {
-    return this.redisMetaRegion.size() - RedisConstants.NUM_DEFAULT_KEYS;
-  }
-
-  private boolean metaRemoveEntry(ByteArrayWrapper key) {
-    return this.redisMetaRegion.remove(key.toString()) != null;
-  }
-
-  public RedisDataType metaPutIfAbsent(ByteArrayWrapper key, RedisDataType value) {
-    return this.redisMetaRegion.putIfAbsent(key.toString(), value);
-  }
-
-  public RedisDataType metaPut(ByteArrayWrapper key, RedisDataType value) {
-    return this.redisMetaRegion.put(key.toString(), value);
-  }
-
-  public RedisDataType metaGet(ByteArrayWrapper key) {
-    return this.redisMetaRegion.get(key.toString());
-  }
-
-  public Region<?, ?> getRegion(ByteArrayWrapper key) {
-    return this.regions.get(key);
-  }
-
-  public void removeRegionReferenceLocally(ByteArrayWrapper key, RedisDataType type) {
-    cancelKeyExpiration(key);
-    this.regions.remove(key);
-  }
-
-  public boolean removeKey(ByteArrayWrapper key) {
-    RedisDataType type = getRedisDataType(key);
-    return removeKey(key, type);
-  }
-
-  public boolean removeKey(ByteArrayWrapper key, RedisDataType type) {
-    return removeKey(key, type, true);
-  }
-
-  public boolean removeKey(ByteArrayWrapper key, RedisDataType type, boolean cancelExpiration) {
-    if (type == null || type == RedisDataType.REDIS_PROTECTED)
-      return false;
-    metaRemoveEntry(key);
-    try {
-      if (type == RedisDataType.REDIS_STRING) {
-        return this.stringsRegion.remove(key) != null;
-      } else if (type == RedisDataType.REDIS_HLL) {
-        return this.hLLRegion.remove(key) != null;
-      } else {
-        return destroyRegion(key, type);
-      }
-    } catch (Exception exc) {
-      return false;
-    } finally {
-      if (cancelExpiration)
-        cancelKeyExpiration(key);
-      else
-        removeKeyExpiration(key);
-    }
-  }
-
-  public Region<?, ?> getOrCreateRegion(ByteArrayWrapper key, RedisDataType type, ExecutionHandlerContext context) {
-    return getOrCreateRegion0(key, type, context, true);
-  }
-
-  public Region<?, ?> createRemoteRegionLocally(ByteArrayWrapper key, RedisDataType type) {
-    return getOrCreateRegion0(key, type, null, false);
-  }
-
-  private Region<?, ?> getOrCreateRegion0(ByteArrayWrapper key, RedisDataType type, ExecutionHandlerContext context, boolean addToMeta) {
-    checkDataType(key, type);
-    Region<?, ?> r = this.regions.get(key);
-    if (r == null) {
-      String stringKey = key.toString();
-      synchronized (stringKey) { // This object will be interned across the vm
-        r = regions.get(key);
-        if (r == null) {
-          boolean hasTransaction = context != null && context.hasTransaction(); // Can create without context
-          CacheTransactionManager txm = null;
-          TransactionId transactionId = null;
-          try {
-            if (hasTransaction) {
-              txm = cache.getCacheTransactionManager();
-              transactionId = txm.suspend();
-            }
-            r = createRegionGlobally(stringKey);
-            if (addToMeta)
-              metaPut(key, type);
-            if (type == RedisDataType.REDIS_LIST)
-              doInitializeList(key, r.getFullPath());
-            else if (type == RedisDataType.REDIS_SORTEDSET)
-              doInitializeSortedSet(key, r);
-            this.regions.put(key, r);
-          } finally {
-            if (hasTransaction)
-              txm.resume(transactionId);
-          }
-        }
-      }
-    }
-    return r;
-  }
-
-  private boolean destroyRegion(ByteArrayWrapper key, RedisDataType type) {
-    String stringKey = key.toString();
-    Region<?, ?> r = this.regions.get(key);
-    if (r != null) {
-      synchronized (stringKey) { // This object will be interned across the vm
-        try {
-          r.destroyRegion();
-        } catch (Exception e) {
-          return false;
-        } finally {
-          this.preparedQueries.remove(key);
-          metaRemoveEntry(key);
-          if (type == RedisDataType.REDIS_LIST) {
-            this.listsMetaRegion.remove(stringKey + "head");
-            this.listsMetaRegion.remove(stringKey + "tail");
-          }
-          this.regions.remove(key);
-        }
-      }
-    }
-    return true;
-  }
-
-  private void doInitializeSortedSet(ByteArrayWrapper key, Region<?, ?> r) {
-    String fullpath = r.getFullPath();
-    try {
-      queryService.createIndex("scoreIndex", "value.score", r.getFullPath() + ".entrySet entry");
-      queryService.createIndex("scoreIndex2", "value.score", r.getFullPath() + ".values value");
-    } catch (Exception e) {
-      if (!(e instanceof IndexNameConflictException)) {
-        LogWriter logger = cache.getLogger();
-        if (logger.errorEnabled()) {
-          logger.error(e);
-        }
-      }
-    }
-    HashMap<Enum<?>, Query> queryList = new HashMap<Enum<?>, Query>();
-    for (SortedSetQuery lq: SortedSetQuery.values()) {
-      String queryString = lq.getQueryString(fullpath);
-      Query query = this.queryService.newQuery(queryString);
-      queryList.put(lq, query);
-    }
-    this.preparedQueries.put(key, queryList);
-  }
-
-  private void doInitializeList(ByteArrayWrapper key, String fullpath) {
-    listsMetaRegion.put(key + "head", Integer.valueOf(0));
-    listsMetaRegion.put(key + "tail", Integer.valueOf(0));
-    HashMap<Enum<?>, Query> queryList = new HashMap<Enum<?>, Query>();
-    for (ListQuery lq: ListQuery.values()) {
-      String queryString = lq.getQueryString(fullpath);
-      Query query = this.queryService.newQuery(queryString);
-      queryList.put(lq, query);
-    }
-    this.preparedQueries.put(key, queryList);
-  }
-
-  /**
-   * This method creates a Region globally with the given name. If
-   * there is an error in the creation, a runtime exception will
-   * be thrown.
-   * 
-   * @param key Name of Region to create
-   * @return Region Region created globally
-   */
-  private Region<?, ?> createRegionGlobally(String key) {
-    Region<?, ?> r = null;
-    Result result = cliCmds.createRegion(key, GemFireRedisServer.DEFAULT_REGION_TYPE, null, null, true, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
-    r = cache.getRegion(key);
-    if (result.getStatus() == Status.ERROR && r == null) {
-      String err = "";
-      while(result.hasNextLine())
-        err += result.nextLine();
-      throw new RegionCreationException(err);
-    }
-    if (r == null)
-      throw new RegionCreationException();
-    return r;
-  }
-
-  public Query getQuery(ByteArrayWrapper key, Enum<?> query) {
-    return this.preparedQueries.get(key).get(query);
-  }
-
-  /**
-   * Checks if the given key is associated with the passed data type.
-   * If there is a mismatch, a {@link RuntimeException} is thrown
-   * 
-   * @param key Key to check
-   * @param type Type to check to
-   */
-  protected void checkDataType(ByteArrayWrapper key, RedisDataType type) {
-    RedisDataType currentType = redisMetaRegion.get(key.toString());
-    if (currentType == null)
-      return;
-    if (currentType == RedisDataType.REDIS_PROTECTED)
-      throw new RedisDataTypeMismatchException("The key name \"" + key + "\" is protected");
-    if (currentType != type)
-      throw new RedisDataTypeMismatchException("The key name \"" + key + "\" is already used by a " + currentType.toString());
-  }
-
-  public boolean regionExists(ByteArrayWrapper key) {
-    return this.regions.containsKey(key);
-  }
-
-  public Region<ByteArrayWrapper, ByteArrayWrapper> getStringsRegion() {
-    return this.stringsRegion;
-  }
-
-  public Region<String, Integer> getListsMetaRegion() {
-    return this.listsMetaRegion;
-  }
-
-  public Region<ByteArrayWrapper, HyperLogLogPlus> gethLLRegion() {
-    return this.hLLRegion;
-  }
-
-  private RedisDataType getRedisDataType(String key) {
-    return this.redisMetaRegion.get(key);
-  }
-
-  public RedisDataType getRedisDataType(ByteArrayWrapper key) {
-    return getRedisDataType(key.toString());
-  }
-
-
-  /**
-   * Sets the expiration for a key. The setting and modifying of a key expiration can only be set by a delay,
-   * which means that both expiring after a time and at a time can be done but
-   * the delay to expire at a time must be calculated before these calls. It is
-   * also important to note that the delay is always handled in milliseconds
-   * 
-   * @param key The key to set the expiration for
-   * @param delay The delay in milliseconds of the expiration
-   * @return True is expiration set, false otherwise
-   */
-  public final boolean setExpiration(ByteArrayWrapper key, long delay) {
-    RedisDataType type = getRedisDataType(key);
-    if (type == null)
-      return false;
-    ScheduledFuture<?> future = this.expirationExecutor.schedule(new ExpirationExecutor(key, type, this), delay, TimeUnit.MILLISECONDS);
-    this.expirationsMap.put(key, future);
-    return true;
-  }
-
-  /**
-   * Modifies an expiration on a key
-   * 
-   * @param key String key to modify expiration on
-   * @param delay Delay in milliseconds to reset the expiration to
-   * @return True if reset, false if not
-   */
-  public final boolean modifyExpiration(ByteArrayWrapper key, long delay) {
-    /*
-     * Attempt to cancel future task
-     */
-    boolean canceled = cancelKeyExpiration(key);
-
-    if (!canceled)
-      return false;
-
-    RedisDataType type = getRedisDataType(key);
-    if (type == null)
-      return false;
-
-    ScheduledFuture<?> future = this.expirationExecutor.schedule(new ExpirationExecutor(key, type, this), delay, TimeUnit.MILLISECONDS);
-    this.expirationsMap.put(key, future);
-    return true;
-  }
-
-  /**
-   * Removes an expiration from a key
-   * 
-   * @param key Key
-   * @param context Context
-   * @return True is expiration cancelled on the key, false otherwise
-   */
-  public final boolean cancelKeyExpiration(ByteArrayWrapper key) {
-    ScheduledFuture<?> future = expirationsMap.remove(key);
-    if (future == null)
-      return false;
-    return future.cancel(false);
-  }
-
-  private boolean removeKeyExpiration(ByteArrayWrapper key) {
-    return expirationsMap.remove(key) != null;
-  }
-
-  /**
-   * Check method if key has expiration
-   * 
-   * @param key Key
-   * @return True if key has expiration, false otherwise
-   */
-  public boolean hasExpiration(ByteArrayWrapper key) {
-    return this.expirationsMap.containsKey(key);
-  }
-
-  /**
-   * Get remaining expiration time
-   * 
-   * @param key Key
-   * @return Remaining time in milliseconds or 0 if no delay or key doesn't exist
-   */
-  public final long getExpirationDelayMillis(ByteArrayWrapper key) {
-    ScheduledFuture<?> future = this.expirationsMap.get(key);
-    return future != null ? future.getDelay(TimeUnit.MILLISECONDS) : 0L;
-  }
-
-  @Override
-  public void close() {
-    this.preparedQueries.clear();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionCreationException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionCreationException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionCreationException.java
index 55fb701..5856a0c 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionCreationException.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionCreationException.java
@@ -1,5 +1,11 @@
 package com.gemstone.gemfire.internal.redis;
 
+/**
+ * This exception is used when an error happens while creating a {@link Region} globally
+ * 
+ * @author Vitaliy Gavrilov
+ *
+ */
 public class RegionCreationException extends RuntimeException {
 
   public RegionCreationException() {}
@@ -12,9 +18,6 @@ public class RegionCreationException extends RuntimeException {
     super(err, cause);
   }
 
-  /**
-   * 
-   */
   private static final long serialVersionUID = 8416820139078312997L;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionProvider.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionProvider.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionProvider.java
new file mode 100644
index 0000000..a95f853
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/RegionProvider.java
@@ -0,0 +1,531 @@
+package com.gemstone.gemfire.internal.redis;
+
+import java.io.Closeable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheTransactionManager;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.TransactionId;
+import com.gemstone.gemfire.cache.query.IndexNameConflictException;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryInvalidException;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.RegionNotFoundException;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.redis.executor.ExpirationExecutor;
+import com.gemstone.gemfire.internal.redis.executor.ListQuery;
+import com.gemstone.gemfire.internal.redis.executor.SortedSetQuery;
+import com.gemstone.gemfire.internal.redis.executor.hll.HyperLogLogPlus;
+import com.gemstone.gemfire.management.cli.Result;
+import com.gemstone.gemfire.management.cli.Result.Status;
+import com.gemstone.gemfire.management.internal.cli.commands.CreateAlterDestroyRegionCommands;
+import com.gemstone.gemfire.redis.GemFireRedisServer;
+
+/**
+ * This class stands between {@link Executor} and {@link Cache#getRegion(String)}.
+ * This is needed because some keys for Redis represented as a {@link Region} in
+ * {@link GemFireRedisServer} come with additional state. Therefore getting, creating,
+ * or destroying a {@link Region} needs to be synchronized, which is done away with
+ * and abstracted by this class.
+ * 
+ * @author Vitaly Gavrilov
+ *
+ */
+public class RegionProvider implements Closeable {
+
+  private final ConcurrentHashMap<ByteArrayWrapper, Region<?, ?>> regions;
+
+  /**
+   * This is the Redis meta data {@link Region} that holds the {@link RedisDataType}
+   * information for all Regions created. The mapping is a {@link String} key which is the name
+   * of the {@link Region} created to hold the data to the RedisDataType it contains.
+   */
+  private final Region<String, RedisDataType> redisMetaRegion;
+
+  /**
+   * This is the {@link RedisDataType#REDIS_STRING} {@link Region}. This is the Region
+   * that stores all string contents
+   */
+  private final Region<ByteArrayWrapper, ByteArrayWrapper> stringsRegion;
+
+  /**
+   * This is the {@link RedisDataType#REDIS_HLL} {@link Region}. This is the Region
+   * that stores all HyperLogLog contents
+   */
+  private final Region<ByteArrayWrapper, HyperLogLogPlus> hLLRegion;
+
+  private final Cache cache;
+  private final QueryService queryService;
+  private final ConcurrentMap<ByteArrayWrapper, Map<Enum<?>, Query>> preparedQueries = new ConcurrentHashMap<ByteArrayWrapper, Map<Enum<?>, Query>>();
+  private final ConcurrentMap<ByteArrayWrapper, ScheduledFuture<?>> expirationsMap;
+  private final ScheduledExecutorService expirationExecutor;
+  private final RegionShortcut defaultRegionType;
+  private static final CreateAlterDestroyRegionCommands cliCmds = new CreateAlterDestroyRegionCommands();
+  private final ConcurrentHashMap<String, Lock> locks;
+  private final LogWriter logger;
+
+  public RegionProvider(Region<ByteArrayWrapper, ByteArrayWrapper> stringsRegion, Region<ByteArrayWrapper, HyperLogLogPlus> hLLRegion, Region<String, RedisDataType> redisMetaRegion, ConcurrentMap<ByteArrayWrapper, ScheduledFuture<?>> expirationsMap, ScheduledExecutorService expirationExecutor, RegionShortcut defaultShortcut) {
+    if (stringsRegion == null || hLLRegion == null || redisMetaRegion == null)
+      throw new NullPointerException();
+    this.regions = new ConcurrentHashMap<ByteArrayWrapper, Region<?, ?>>();
+    this.stringsRegion = stringsRegion;
+    this.hLLRegion = hLLRegion;
+    this.redisMetaRegion = redisMetaRegion;
+    this.cache = GemFireCacheImpl.getInstance();
+    this.queryService = cache.getQueryService();
+    this.expirationsMap = expirationsMap;
+    this.expirationExecutor = expirationExecutor;
+    this.defaultRegionType = defaultShortcut;
+    this.locks = new ConcurrentHashMap<String, Lock>();
+    this.logger = this.cache.getLogger();
+  }
+
+  public boolean existsKey(ByteArrayWrapper key) {
+    return this.redisMetaRegion.containsKey(key.toString());
+  }
+
+  public Set<String> metaKeySet() {
+    return this.redisMetaRegion.keySet();
+  }
+
+  public Set<Map.Entry<String, RedisDataType>> metaEntrySet() {
+    return this.redisMetaRegion.entrySet();
+  }
+
+  public int getMetaSize() {
+    return this.redisMetaRegion.size() - RedisConstants.NUM_DEFAULT_KEYS;
+  }
+
+  private boolean metaRemoveEntry(ByteArrayWrapper key) {
+    return this.redisMetaRegion.remove(key.toString()) != null;
+  }
+
+  public RedisDataType metaPutIfAbsent(ByteArrayWrapper key, RedisDataType value) {
+    return this.redisMetaRegion.putIfAbsent(key.toString(), value);
+  }
+
+  public RedisDataType metaPut(ByteArrayWrapper key, RedisDataType value) {
+    return this.redisMetaRegion.put(key.toString(), value);
+  }
+
+  public RedisDataType metaGet(ByteArrayWrapper key) {
+    return this.redisMetaRegion.get(key.toString());
+  }
+
+  public Region<?, ?> getRegion(ByteArrayWrapper key) {
+    return this.regions.get(key);
+  }
+
+  public void removeRegionReferenceLocally(ByteArrayWrapper key, RedisDataType type) {
+    Lock lock = this.locks.get(key.toString());
+    boolean locked = false;
+    try {
+      locked = lock.tryLock();
+      // If we cannot get the lock we ignore this remote event, this key has local event
+      // that started independently, ignore this event to prevent deadlock
+      if (locked) {
+        cancelKeyExpiration(key);
+        removeRegionState(key, type);
+      }
+    } finally {
+      if (locked) {
+        lock.unlock();
+      }
+    }
+  }
+
+  public boolean removeKey(ByteArrayWrapper key) {
+    RedisDataType type = getRedisDataType(key);
+    return removeKey(key, type);
+  }
+
+  public boolean removeKey(ByteArrayWrapper key, RedisDataType type) {
+    return removeKey(key, type, true);
+  }
+
+  public boolean removeKey(ByteArrayWrapper key, RedisDataType type, boolean cancelExpiration) {
+    if (type == null || type == RedisDataType.REDIS_PROTECTED)
+      return false;
+    Lock lock = this.locks.get(key.toString());
+    try {
+      if (lock != null)  {// Strings/hlls will not have locks
+        lock.lock();
+      }
+      metaRemoveEntry(key);
+      try {
+        if (type == RedisDataType.REDIS_STRING) {
+          return this.stringsRegion.remove(key) != null;
+        } else if (type == RedisDataType.REDIS_HLL) {
+          return this.hLLRegion.remove(key) != null;
+        } else {
+          return destroyRegion(key, type);
+        }
+      } catch (Exception exc) {
+        return false;
+      } finally {
+        if (cancelExpiration)
+          cancelKeyExpiration(key);
+        else
+          removeKeyExpiration(key);
+        if (lock != null)
+          this.locks.remove(key.toString());
+      }
+    } finally {
+      if (lock != null) {
+        lock.unlock();
+      }
+    }
+  }
+
+  public Region<?, ?> getOrCreateRegion(ByteArrayWrapper key, RedisDataType type, ExecutionHandlerContext context) {
+    return getOrCreateRegion0(key, type, context, true);
+  }
+
+  public void createRemoteRegionLocally(ByteArrayWrapper key, RedisDataType type) {
+    if (type == null || type == RedisDataType.REDIS_STRING || type == RedisDataType.REDIS_HLL)
+      return;
+    Region<?, ?> r = this.regions.get(key);
+    if (r != null)
+      return;
+    if (!this.regions.contains(key)) {
+      String stringKey = key.toString();
+      Lock lock = this.locks.get(stringKey);
+      if (lock == null) {
+        this.locks.putIfAbsent(stringKey, new ReentrantLock());
+        lock = this.locks.get(stringKey);
+      }
+      boolean locked = false;
+      try {
+        locked = lock.tryLock();
+        // If we cannot get the lock then this remote even may have been initialized
+        // independently on this machine, so if we wait on the lock it is more than
+        // likely we will deadlock just to do the same task, this even can be ignored
+        if (locked) {
+          r = cache.getRegion(key.toString());
+          if (type == RedisDataType.REDIS_LIST)
+            doInitializeList(key, r);
+          else if (type == RedisDataType.REDIS_SORTEDSET)
+            doInitializeSortedSet(key, r);
+          this.regions.put(key, r);
+        }
+      } finally {
+        if (locked) {
+          lock.unlock();
+        }
+      }
+    }
+  }
+
+  private Region<?, ?> getOrCreateRegion0(ByteArrayWrapper key, RedisDataType type, ExecutionHandlerContext context, boolean addToMeta) {
+    checkDataType(key, type);
+    Region<?, ?> r = this.regions.get(key);
+    if (r != null && r.isDestroyed()) {
+      removeKey(key, type);
+      r = null;
+    }
+    if (r == null) {
+      String stringKey = key.toString();
+      Lock lock = this.locks.get(stringKey);
+      if (lock == null) {
+        this.locks.putIfAbsent(stringKey, new ReentrantLock());
+        lock = this.locks.get(stringKey);
+      }
+
+      try {
+        lock.lock();
+        r = regions.get(key);
+        if (r == null) {
+          boolean hasTransaction = context != null && context.hasTransaction(); // Can create without context
+          CacheTransactionManager txm = null;
+          TransactionId transactionId = null;
+          try {
+            if (hasTransaction) {
+              txm = cache.getCacheTransactionManager();
+              transactionId = txm.suspend();
+            }
+            Exception concurrentCreateDestroyException = null;
+            do {
+              concurrentCreateDestroyException = null;
+              r = createRegionGlobally(stringKey);
+              try {
+                if (type == RedisDataType.REDIS_LIST)
+                  doInitializeList(key, r);
+                else if (type == RedisDataType.REDIS_SORTEDSET)
+                  doInitializeSortedSet(key, r);
+              } catch (QueryInvalidException e) {
+                if (e.getCause() instanceof RegionNotFoundException) {
+                  concurrentCreateDestroyException = e;
+                }
+              }
+            } while(concurrentCreateDestroyException != null);
+            this.regions.put(key, r);            
+            if (addToMeta) {
+              RedisDataType existingType = metaPutIfAbsent(key, type);
+              if (existingType != null && existingType != type)
+                throw new RedisDataTypeMismatchException("The key name \"" + key + "\" is already used by a " + existingType.toString());
+            }
+          } finally {
+            if (hasTransaction)
+              txm.resume(transactionId);
+          }
+        }
+      } finally {
+        lock.unlock();
+      }
+    }
+    return r;
+  }
+
+  /**
+   * SYNCHRONIZE EXTERNALLY OF this.locks.get(key.toString())!!!!!
+   * 
+   * @param key Key of region to destroy
+   * @param type Type of region to destroyu
+   * @return Flag if destroyed
+   */
+  private boolean destroyRegion(ByteArrayWrapper key, RedisDataType type) {
+    Region<?, ?> r = this.regions.get(key);
+    if (r != null) {
+      try {
+        r.destroyRegion();
+      } catch (Exception e) {
+        return false;
+      } finally {
+        removeRegionState(key, type);
+      }
+    }
+    return true;
+  }
+
+  /**
+   * Do not call this method if you are not synchronized on the lock associated with this key
+   * 
+   * @param key Key of region to remove
+   * @param type Type of key to remove all state
+   */
+  private void removeRegionState(ByteArrayWrapper key, RedisDataType type) {
+    this.preparedQueries.remove(key);
+    this.regions.remove(key);
+  }
+
+  private void doInitializeSortedSet(ByteArrayWrapper key, Region<?, ?> r) {
+    String fullpath = r.getFullPath();
+    try {
+      queryService.createIndex("scoreIndex", "entry.value.score", r.getFullPath() + ".entrySet entry");
+      queryService.createIndex("scoreIndex2", "value.score", r.getFullPath() + ".values value");
+    } catch (Exception e) {
+      if (!(e instanceof IndexNameConflictException)) {
+        if (logger.errorEnabled()) {
+          logger.error(e);
+        }
+      }
+    }
+    HashMap<Enum<?>, Query> queryList = new HashMap<Enum<?>, Query>();
+    for (SortedSetQuery lq: SortedSetQuery.values()) {
+      String queryString = lq.getQueryString(fullpath);
+      Query query = this.queryService.newQuery(queryString);
+      queryList.put(lq, query);
+    }
+    this.preparedQueries.put(key, queryList);
+  }
+
+  private void doInitializeList(ByteArrayWrapper key, Region r) {
+    r.put("head", Integer.valueOf(0));
+    r.put("tail", Integer.valueOf(0));
+    String fullpath = r.getFullPath();
+    HashMap<Enum<?>, Query> queryList = new HashMap<Enum<?>, Query>();
+    for (ListQuery lq: ListQuery.values()) {
+      String queryString = lq.getQueryString(fullpath);
+      Query query = this.queryService.newQuery(queryString);
+      queryList.put(lq, query);
+    }
+    this.preparedQueries.put(key, queryList);
+  }
+
+  /**
+   * This method creates a Region globally with the given name. If
+   * there is an error in the creation, a runtime exception will
+   * be thrown.
+   * 
+   * @param key Name of Region to create
+   * @return Region Region created globally
+   */
+  private Region<?, ?> createRegionGlobally(String key) {
+    Region<?, ?> r = null;
+    r = cache.getRegion(key);
+    if (r != null) return r;
+    do {
+      Result result = cliCmds.createRegion(key, defaultRegionType, null, null, true, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
+      r = cache.getRegion(key);
+      if (result.getStatus() == Status.ERROR && r == null) {
+        String err = "";
+        while(result.hasNextLine())
+          err += result.nextLine();
+        if (this.logger.errorEnabled()) {
+          this.logger.error("Region creation failure- "+ err);
+        }
+        throw new RegionCreationException(err);
+      }
+    } while(r == null); // The region can be null in the case that it is concurrently destroyed by
+    // a remote even triggered internally by Geode
+    return r;
+  }
+
+  public Query getQuery(ByteArrayWrapper key, Enum<?> query) {
+    return this.preparedQueries.get(key).get(query);
+    /*
+    if (query instanceof ListQuery) {
+      return this.queryService.newQuery(((ListQuery)query).getQueryString(this.regions.get(key).getFullPath()));
+    } else {
+      return this.queryService.newQuery(((SortedSetQuery)query).getQueryString(this.regions.get(key).getFullPath()));
+    }
+    */
+  }
+
+  /**
+   * Checks if the given key is associated with the passed data type.
+   * If there is a mismatch, a {@link RuntimeException} is thrown
+   * 
+   * @param key Key to check
+   * @param type Type to check to
+   */
+  protected void checkDataType(ByteArrayWrapper key, RedisDataType type) {
+    RedisDataType currentType = redisMetaRegion.get(key.toString());
+    if (currentType == null)
+      return;
+    if (currentType == RedisDataType.REDIS_PROTECTED)
+      throw new RedisDataTypeMismatchException("The key name \"" + key + "\" is protected");
+    if (currentType != type)
+      throw new RedisDataTypeMismatchException("The key name \"" + key + "\" is already used by a " + currentType.toString());
+  }
+
+  public boolean regionExists(ByteArrayWrapper key) {
+    return this.regions.containsKey(key);
+  }
+
+  public Region<ByteArrayWrapper, ByteArrayWrapper> getStringsRegion() {
+    return this.stringsRegion;
+  }
+
+  public Region<ByteArrayWrapper, HyperLogLogPlus> gethLLRegion() {
+    return this.hLLRegion;
+  }
+
+  private RedisDataType getRedisDataType(String key) {
+    return this.redisMetaRegion.get(key);
+  }
+
+  public RedisDataType getRedisDataType(ByteArrayWrapper key) {
+    return getRedisDataType(key.toString());
+  }
+
+  /**
+   * Sets the expiration for a key. The setting and modifying of a key expiration can only be set by a delay,
+   * which means that both expiring after a time and at a time can be done but
+   * the delay to expire at a time must be calculated before these calls. It is
+   * also important to note that the delay is always handled in milliseconds
+   * 
+   * @param key The key to set the expiration for
+   * @param delay The delay in milliseconds of the expiration
+   * @return True is expiration set, false otherwise
+   */
+  public final boolean setExpiration(ByteArrayWrapper key, long delay) {
+    RedisDataType type = getRedisDataType(key);
+    if (type == null)
+      return false;
+    ScheduledFuture<?> future = this.expirationExecutor.schedule(new ExpirationExecutor(key, type, this), delay, TimeUnit.MILLISECONDS);
+    this.expirationsMap.put(key, future);
+    return true;
+  }
+
+  /**
+   * Modifies an expiration on a key
+   * 
+   * @param key String key to modify expiration on
+   * @param delay Delay in milliseconds to reset the expiration to
+   * @return True if reset, false if not
+   */
+  public final boolean modifyExpiration(ByteArrayWrapper key, long delay) {
+    /*
+     * Attempt to cancel future task
+     */
+    boolean canceled = cancelKeyExpiration(key);
+
+    if (!canceled)
+      return false;
+
+    RedisDataType type = getRedisDataType(key);
+    if (type == null)
+      return false;
+
+    ScheduledFuture<?> future = this.expirationExecutor.schedule(new ExpirationExecutor(key, type, this), delay, TimeUnit.MILLISECONDS);
+    this.expirationsMap.put(key, future);
+    return true;
+  }
+
+  /**
+   * Removes an expiration from a key
+   * 
+   * @param key Key
+   * @param context Context
+   * @return True is expiration cancelled on the key, false otherwise
+   */
+  public final boolean cancelKeyExpiration(ByteArrayWrapper key) {
+    ScheduledFuture<?> future = expirationsMap.remove(key);
+    if (future == null)
+      return false;
+    return future.cancel(false);
+  }
+
+  private boolean removeKeyExpiration(ByteArrayWrapper key) {
+    return expirationsMap.remove(key) != null;
+  }
+
+  /**
+   * Check method if key has expiration
+   * 
+   * @param key Key
+   * @return True if key has expiration, false otherwise
+   */
+  public boolean hasExpiration(ByteArrayWrapper key) {
+    return this.expirationsMap.containsKey(key);
+  }
+
+  /**
+   * Get remaining expiration time
+   * 
+   * @param key Key
+   * @return Remaining time in milliseconds or 0 if no delay or key doesn't exist
+   */
+  public final long getExpirationDelayMillis(ByteArrayWrapper key) {
+    ScheduledFuture<?> future = this.expirationsMap.get(key);
+    return future != null ? future.getDelay(TimeUnit.MILLISECONDS) : 0L;
+  }
+
+  @Override
+  public void close() {
+    this.preparedQueries.clear();
+  }
+
+  public String dumpRegionsCache() {
+    StringBuilder builder = new StringBuilder();
+    for (Entry<ByteArrayWrapper, Region<?, ?>> e : this.regions.entrySet()) {
+      builder.append(e.getKey() + " --> {" + e.getValue() + "}\n");
+    }
+    return builder.toString();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/AbstractExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/AbstractExecutor.java
index 97fd4fc..d95d057 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/AbstractExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/AbstractExecutor.java
@@ -7,7 +7,7 @@ import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.Executor;
 import com.gemstone.gemfire.internal.redis.RedisDataType;
 import com.gemstone.gemfire.internal.redis.RedisDataTypeMismatchException;
-import com.gemstone.gemfire.internal.redis.RegionCache;
+import com.gemstone.gemfire.internal.redis.RegionProvider;
 import com.gemstone.gemfire.redis.GemFireRedisServer;
 
 /**
@@ -22,7 +22,7 @@ public abstract class AbstractExecutor implements Executor {
   /**
    * Number of Regions used by GemFireRedisServer internally
    */
-  public static final int NUM_DEFAULT_REGIONS = 4;
+  public static final int NUM_DEFAULT_REGIONS = 3;
 
   /**
    * Max length of a list
@@ -53,7 +53,7 @@ public abstract class AbstractExecutor implements Executor {
    * @return Region with name key
    */
   protected Region<?, ?> getOrCreateRegion(ExecutionHandlerContext context, ByteArrayWrapper key, RedisDataType type) {
-    return context.getRegionCache().getOrCreateRegion(key, type, context);
+    return context.getRegionProvider().getOrCreateRegion(key, type, context);
   }
 
   /**
@@ -65,7 +65,7 @@ public abstract class AbstractExecutor implements Executor {
    * @param context context
    */
   protected void checkDataType(ByteArrayWrapper key, RedisDataType type, ExecutionHandlerContext context) {
-    RedisDataType currentType = context.getRegionCache().getRedisDataType(key);
+    RedisDataType currentType = context.getRegionProvider().getRedisDataType(key);
     if (currentType == null)
       return;
     if (currentType == RedisDataType.REDIS_PROTECTED)
@@ -83,13 +83,13 @@ public abstract class AbstractExecutor implements Executor {
    * @return The Query of this key and QueryType
    */
   protected Query getQuery(ByteArrayWrapper key, Enum<?> type, ExecutionHandlerContext context) {
-    return context.getRegionCache().getQuery(key, type);
+    return context.getRegionProvider().getQuery(key, type);
   }
 
   protected boolean removeEntry(ByteArrayWrapper key, RedisDataType type, ExecutionHandlerContext context) {
     if (type == null || type == RedisDataType.REDIS_PROTECTED)
       return false;
-    RegionCache rC = context.getRegionCache();
+    RegionProvider rC = context.getRegionProvider();
     return rC.removeKey(key, type);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/AbstractScanExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/AbstractScanExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/AbstractScanExecutor.java
index 09b1d76..e4a9a53 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/AbstractScanExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/AbstractScanExecutor.java
@@ -4,7 +4,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.regex.Pattern;
 
-import com.gemstone.gemfire.internal.redis.executor.org.apache.hadoop.fs.GlobPattern;
+import com.gemstone.gemfire.internal.redis.org.apache.hadoop.fs.GlobPattern;
 
 
 public abstract class AbstractScanExecutor extends AbstractExecutor {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/DBSizeExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/DBSizeExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/DBSizeExecutor.java
index 954e3e0..e434a07 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/DBSizeExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/DBSizeExecutor.java
@@ -8,7 +8,7 @@ public class DBSizeExecutor extends AbstractExecutor {
 
   @Override
   public void executeCommand(Command command, ExecutionHandlerContext context) {
-    int size = context.getRegionCache().getMetaSize();
+    int size = context.getRegionProvider().getMetaSize();
     command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), size));
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/DelExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/DelExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/DelExecutor.java
index 28e5f40..7d54883 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/DelExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/DelExecutor.java
@@ -28,7 +28,7 @@ public class DelExecutor extends AbstractExecutor {
     for (int i = 1; i < commandElems.size(); i++) {
       byte[] byteKey = commandElems.get(i);
       ByteArrayWrapper key = new ByteArrayWrapper(byteKey);
-      RedisDataType type = context.getRegionCache().getRedisDataType(key); 
+      RedisDataType type = context.getRegionProvider().getRedisDataType(key); 
       if (removeEntry(key, type, context))
         numRemoved++;
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/EchoExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/EchoExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/EchoExecutor.java
index 03fa868..2d0268e 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/EchoExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/EchoExecutor.java
@@ -2,8 +2,8 @@ package com.gemstone.gemfire.internal.redis.executor;
 
 import java.util.List;
 
-import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.Coder;
+import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExistsExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExistsExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExistsExecutor.java
index ec8fef6..5adc554 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExistsExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExistsExecutor.java
@@ -22,7 +22,7 @@ public class ExistsExecutor extends AbstractExecutor {
     }
 
     ByteArrayWrapper key = command.getKey();
-    boolean exists = context.getRegionCache().existsKey(key);
+    boolean exists = context.getRegionProvider().existsKey(key);
 
     if (exists)
       command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), EXISTS));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpirationExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpirationExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpirationExecutor.java
index 3ed78d8..9fa7595 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpirationExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpirationExecutor.java
@@ -2,15 +2,15 @@ package com.gemstone.gemfire.internal.redis.executor;
 
 import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
 import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.RegionCache;
+import com.gemstone.gemfire.internal.redis.RegionProvider;
 
 
 public class ExpirationExecutor implements Runnable {
   private final ByteArrayWrapper key;
   private final RedisDataType type;
-  private final RegionCache rC;
+  private final RegionProvider rC;
 
-  public ExpirationExecutor(ByteArrayWrapper k, RedisDataType type, RegionCache rC) {
+  public ExpirationExecutor(ByteArrayWrapper k, RedisDataType type, RegionProvider rC) {
     this.key = k;
     this.type = type;
     this.rC = rC;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpireAtExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpireAtExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpireAtExecutor.java
index 695d41d..7c40ae4 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpireAtExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpireAtExecutor.java
@@ -8,7 +8,7 @@ import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.Extendable;
 import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-import com.gemstone.gemfire.internal.redis.RegionCache;
+import com.gemstone.gemfire.internal.redis.RegionProvider;
 
 public class ExpireAtExecutor extends AbstractExecutor implements Extendable {
 
@@ -28,7 +28,7 @@ public class ExpireAtExecutor extends AbstractExecutor implements Extendable {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), getArgsError()));
       return;
     }
-    RegionCache rC = context.getRegionCache();
+    RegionProvider rC = context.getRegionProvider();
     ByteArrayWrapper wKey = command.getKey();
 
     byte[] timestampByteArray = commandElems.get(TIMESTAMP_INDEX);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpireExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpireExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpireExecutor.java
index b237f01..dc5ad3d 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpireExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ExpireExecutor.java
@@ -8,7 +8,7 @@ import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.Extendable;
 import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-import com.gemstone.gemfire.internal.redis.RegionCache;
+import com.gemstone.gemfire.internal.redis.RegionProvider;
 
 public class ExpireExecutor extends AbstractExecutor implements Extendable {
 
@@ -29,7 +29,7 @@ public class ExpireExecutor extends AbstractExecutor implements Extendable {
       return;
     }
     ByteArrayWrapper wKey = command.getKey();
-    RegionCache rC = context.getRegionCache();
+    RegionProvider rC = context.getRegionProvider();
         byte[] delayByteArray = commandElems.get(SECONDS_INDEX);
     long delay;
     try {



[3/4] incubator-geode git commit: Fix for GEODE-109

Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/FlushAllExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/FlushAllExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/FlushAllExecutor.java
index 7f8d4e0..40c22b6 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/FlushAllExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/FlushAllExecutor.java
@@ -2,6 +2,7 @@ package com.gemstone.gemfire.internal.redis.executor;
 
 import java.util.Map.Entry;
 
+import com.gemstone.gemfire.cache.EntryDestroyedException;
 import com.gemstone.gemfire.cache.UnsupportedOperationInTransactionException;
 import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.Command;
@@ -15,11 +16,15 @@ public class FlushAllExecutor extends AbstractExecutor {
     if (context.hasTransaction())
       throw new UnsupportedOperationInTransactionException();
 
-    for (Entry<String, RedisDataType> e: context.getRegionCache().metaEntrySet()) {
-      String skey = e.getKey();
-      RedisDataType type = e.getValue();
-      removeEntry(Coder.stringToByteWrapper(skey), type, context);
-        
+    for (Entry<String, RedisDataType> e: context.getRegionProvider().metaEntrySet()) {
+      try {
+        String skey = e.getKey();
+        RedisDataType type = e.getValue();
+        removeEntry(Coder.stringToByteWrapper(skey), type, context);
+      } catch (EntryDestroyedException e1) {
+        continue;
+      }
+
     }
 
     command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), "OK"));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/KeysExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/KeysExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/KeysExecutor.java
index 4276e9f..2588217 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/KeysExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/KeysExecutor.java
@@ -11,7 +11,7 @@ import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.RedisConstants;
 import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
-import com.gemstone.gemfire.internal.redis.executor.org.apache.hadoop.fs.GlobPattern;
+import com.gemstone.gemfire.internal.redis.org.apache.hadoop.fs.GlobPattern;
 import com.gemstone.gemfire.redis.GemFireRedisServer;
 
 public class KeysExecutor extends AbstractExecutor {
@@ -25,7 +25,7 @@ public class KeysExecutor extends AbstractExecutor {
     }
 
     String glob = Coder.bytesToString(commandElems.get(1));
-    Set<String> allKeys = context.getRegionCache().metaKeySet();
+    Set<String> allKeys = context.getRegionProvider().metaKeySet();
     List<String> matchingKeys = new ArrayList<String>();
 
     Pattern pattern;
@@ -37,8 +37,7 @@ public class KeysExecutor extends AbstractExecutor {
     }
 
     for (String key: allKeys) {
-      if (!(key.equals(GemFireRedisServer.LISTS_META_DATA_REGION) ||
-              key.equals(GemFireRedisServer.REDIS_META_DATA_REGION) ||
+      if (!(key.equals(GemFireRedisServer.REDIS_META_DATA_REGION) ||
               key.equals(GemFireRedisServer.STRING_REGION) ||
               key.equals(GemFireRedisServer.HLL_REGION))
               && pattern.matcher(key).matches())

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ListQuery.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ListQuery.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ListQuery.java
index 3980061..4ae9990 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ListQuery.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ListQuery.java
@@ -4,19 +4,19 @@ public enum ListQuery {
 
   LINDEX {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry ORDER BY key asc LIMIT $1";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE key != 'head' AND key != 'tail' ORDER BY key asc LIMIT $1";
     }
   }, LRANGE {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry ORDER BY key asc LIMIT $1";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE key != 'head' AND key != 'tail' ORDER BY key asc LIMIT $1";
     }
   }, LREMG {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value = $1 ORDER BY key asc LIMIT $2";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value = $1 AND key != 'head' AND key != 'tail' ORDER BY key asc LIMIT $2";
     }
   }, LREML {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value = $1 ORDER BY key desc LIMIT $2";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value = $1 AND key != 'head' AND key != 'tail' ORDER BY key desc LIMIT $2";
     }
   }, LREME {
     public String getQueryString(String fullpath) {
@@ -24,11 +24,11 @@ public enum ListQuery {
     }
   }, LSET {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT * FROM " + fullpath + ".keySet key ORDER BY key asc LIMIT $1";
+      return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key != 'head' AND key != 'tail' ORDER BY key asc LIMIT $1";
     }
   }, LTRIM {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT * FROM " + fullpath + ".keySet key ORDER BY key asc LIMIT $1";
+      return "SELECT DISTINCT * FROM " + fullpath + ".keySet key WHERE key != 'head' AND key != 'tail' ORDER BY key asc LIMIT $1";
     }
   };
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PersistExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PersistExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PersistExecutor.java
index b027c9f..85ed437 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PersistExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PersistExecutor.java
@@ -25,7 +25,7 @@ public class PersistExecutor extends AbstractExecutor {
 
     ByteArrayWrapper key = command.getKey();
     
-    boolean canceled = context.getRegionCache().cancelKeyExpiration(key);
+    boolean canceled = context.getRegionProvider().cancelKeyExpiration(key);
     
     if (canceled)
       command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), TIMEOUT_REMOVED));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PingExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PingExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PingExecutor.java
index 9585b61..3387687 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PingExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/PingExecutor.java
@@ -1,7 +1,7 @@
 package com.gemstone.gemfire.internal.redis.executor;
 
-import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.Coder;
+import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 
 public class PingExecutor extends AbstractExecutor {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/QuitExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/QuitExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/QuitExecutor.java
index 88f0574..2bca4fb 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/QuitExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/QuitExecutor.java
@@ -1,9 +1,9 @@
 package com.gemstone.gemfire.internal.redis.executor;
 
+import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.RedisConstants;
-import com.gemstone.gemfire.internal.redis.Coder;
 
 public class QuitExecutor extends AbstractExecutor {
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ScanExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ScanExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ScanExecutor.java
index a87c725..9257aff 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ScanExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/ScanExecutor.java
@@ -84,7 +84,7 @@ public class ScanExecutor extends AbstractScanExecutor {
     }
 
     @SuppressWarnings("unchecked")
-    List<String> returnList = (List<String>) getIteration(context.getRegionCache().metaKeySet(), matchPattern, count, cursor);
+    List<String> returnList = (List<String>) getIteration(context.getRegionProvider().metaKeySet(), matchPattern, count, cursor);
 
     command.setResponse(Coder.getScanResponse(context.getByteBufAllocator(), returnList));
   }
@@ -98,7 +98,7 @@ public class ScanExecutor extends AbstractScanExecutor {
     int numElements = 0;
     int i = -1;
     for (String key: (Collection<String>) list) {
-      if (key.equals(GemFireRedisServer.REDIS_META_DATA_REGION) || key.equals(GemFireRedisServer.LISTS_META_DATA_REGION) || key.equals(GemFireRedisServer.STRING_REGION) || key.equals(GemFireRedisServer.HLL_REGION))
+      if (key.equals(GemFireRedisServer.REDIS_META_DATA_REGION) || key.equals(GemFireRedisServer.STRING_REGION) || key.equals(GemFireRedisServer.HLL_REGION))
         continue;
       i++;
       if (beforeCursor < cursor) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/SortedSetQuery.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/SortedSetQuery.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/SortedSetQuery.java
index 97d0398..24788dd 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/SortedSetQuery.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/SortedSetQuery.java
@@ -104,67 +104,67 @@ public enum SortedSetQuery {
     }
   }, ZRBSNINFI {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score <= $1 ORDER BY value asc LIMIT $2";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score <= $1 ORDER BY entry.value asc LIMIT $2";
     }
   }, ZRBSNINF {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score < $1 ORDER BY value asc LIMIT $2";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score < $1 ORDER BY entry.value asc LIMIT $2";
     }
   }, ZRBSPINFI {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score >= $1 ORDER BY value asc LIMIT $2";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 ORDER BY entry.value asc LIMIT $2";
     }
   }, ZRBSPINF {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score > $1 ORDER BY value asc LIMIT $2";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 ORDER BY entry.value asc LIMIT $2";
     }
   }, ZRBSSTISI {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score >= $1 AND value.score <= $2 ORDER BY value asc LIMIT $3";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 AND entry.value.score <= $2 ORDER BY entry.value asc LIMIT $3";
     }
   }, ZRBSSTI {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score >= $1 AND value.score < $2 ORDER BY value asc LIMIT $3";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 AND entry.value.score < $2 ORDER BY entry.value asc LIMIT $3";
     }
   }, ZRBSSI {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score > $1 AND value.score <= $2 ORDER BY value asc LIMIT $3";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 AND entry.value.score <= $2 ORDER BY entry.value asc LIMIT $3";
     }
   }, ZRBS {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score > $1 AND value.score < $2 ORDER BY value asc LIMIT $3";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 AND entry.value.score < $2 ORDER BY entry.value asc LIMIT $3";
     }
   }, ZREVRBSNINFI {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value <= $1 ORDER BY value desc, key desc LIMIT $2";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value <= $1 ORDER BY entry.value desc, entry.key desc LIMIT $2";
     }
   }, ZREVRBSNINF {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score < $1 ORDER BY value desc, key desc LIMIT $2";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score < $1 ORDER BY entry.value desc, entry.key desc LIMIT $2";
     }
   }, ZREVRBSPINFI {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score >= $1 ORDER BY value desc, key desc LIMIT $2";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 ORDER BY entry.value desc, entry.key desc LIMIT $2";
     }
   }, ZREVRBSPINF {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score > $1 ORDER BY value desc, key desc LIMIT $2";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 ORDER BY entry.value desc, entry.key desc LIMIT $2";
     }
   }, ZREVRBSSTISI {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score >= $1 AND value.score <= $2 ORDER BY value desc, key desc LIMIT $3";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 AND entry.value.score <= $2 ORDER BY entry.value desc, entry.key desc LIMIT $3";
     }
   }, ZREVRBSSTI {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score >= $1 AND value.score < $2 ORDER BY value desc, key desc LIMIT $3";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score >= $1 AND entry.value.score < $2 ORDER BY entry.value desc, entry.key desc LIMIT $3";
     }
   }, ZREVRBSSI {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score > $1 AND value.score <= $2 ORDER BY value desc, key desc LIMIT $3";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 AND entry.value.score <= $2 ORDER BY entry.value desc, entry.key desc LIMIT $3";
     }
   }, ZREVRBS {
     public String getQueryString(String fullpath) {
-      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE value.score > $1 AND value.score < $2 ORDER BY value desc, key desc LIMIT $3";
+      return "SELECT DISTINCT entry.key, entry.value FROM " + fullpath + ".entrySet entry WHERE entry.value.score > $1 AND entry.value.score < $2 ORDER BY entry.value desc, entry.key desc LIMIT $3";
     }
   }, ZREVRANGE {
     public String getQueryString(String fullpath) {
@@ -176,11 +176,11 @@ public enum SortedSetQuery {
     }
   }, ZRANK {
     public String getQueryString(String fullpath) {
-      return "SELECT COUNT(*) FROM " + fullpath + ".entrySet entry WHERE value < $1 OR (value = $2 AND key.compareTo($3) < 0)";
+      return "SELECT COUNT(*) FROM " + fullpath + ".entrySet entry WHERE entry.value < $1 OR (entry.value = $2 AND entry.key.compareTo($3) < 0)";
     }
   }, ZREVRANK {
     public String getQueryString(String fullpath) {
-      return "SELECT COUNT(*) FROM " + fullpath + ".entrySet entry WHERE value > $1 OR (value = $2 AND key.compareTo($3) > 0)";
+      return "SELECT COUNT(*) FROM " + fullpath + ".entrySet entry WHERE entry.value > $1 OR (entry.value = $2 AND entry.key.compareTo($3) > 0)";
     }
   };
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TTLExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TTLExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TTLExecutor.java
index 91ed98c..47f2f49 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TTLExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TTLExecutor.java
@@ -9,7 +9,7 @@ import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.Extendable;
 import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
 import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.RegionCache;
+import com.gemstone.gemfire.internal.redis.RegionProvider;
 
 public class TTLExecutor extends AbstractExecutor implements Extendable {
 
@@ -27,7 +27,7 @@ public class TTLExecutor extends AbstractExecutor implements Extendable {
     }
 
     ByteArrayWrapper key = command.getKey();
-    RegionCache rC = context.getRegionCache();
+    RegionProvider rC = context.getRegionProvider();
     boolean exists = false;
     RedisDataType val = rC.getRedisDataType(key);
     if (val != null)

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TypeExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TypeExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TypeExecutor.java
index dc4172f..75e5e53 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TypeExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/TypeExecutor.java
@@ -21,7 +21,7 @@ public class TypeExecutor extends AbstractExecutor {
 
     ByteArrayWrapper key = command.getKey();
 
-    RedisDataType type = context.getRegionCache().getRedisDataType(key);
+    RedisDataType type = context.getRegionProvider().getRedisDataType(key);
 
     if (type == null)
       command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), "none"));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/UnkownExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/UnkownExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/UnkownExecutor.java
index 524003d..fd64c39 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/UnkownExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/UnkownExecutor.java
@@ -1,9 +1,9 @@
 package com.gemstone.gemfire.internal.redis.executor;
 
+import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.RedisConstants;
-import com.gemstone.gemfire.internal.redis.Coder;
 
 public class UnkownExecutor extends AbstractExecutor {
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HDelExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HDelExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HDelExecutor.java
index bd8777b..11122fe 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HDelExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HDelExecutor.java
@@ -43,7 +43,7 @@ public class HDelExecutor extends HashExecutor {
         numDeleted++;
     }
     if (keyRegion.isEmpty()) {
-      context.getRegionCache().removeKey(key, RedisDataType.REDIS_HASH);
+      context.getRegionProvider().removeKey(key, RedisDataType.REDIS_HASH);
     }
     command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numDeleted));
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetAllExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetAllExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetAllExecutor.java
index 96eb5a9..ae8100e 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetAllExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HGetAllExecutor.java
@@ -1,16 +1,17 @@
 package com.gemstone.gemfire.internal.redis.executor.hash;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
+import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
 import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.Coder;
 
 public class HGetAllExecutor extends HashExecutor {
 
@@ -33,7 +34,7 @@ public class HGetAllExecutor extends HashExecutor {
       return;
     }
 
-    Set<Map.Entry<ByteArrayWrapper,ByteArrayWrapper>> entries = keyRegion.entrySet();
+    Collection<Map.Entry<ByteArrayWrapper,ByteArrayWrapper>> entries = new ArrayList(keyRegion.entrySet()); // This creates a CopyOnRead behavior
    
    if (entries.isEmpty()) {
      command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HKeysExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HKeysExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HKeysExecutor.java
index 988ac37..5c401ff 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HKeysExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HKeysExecutor.java
@@ -1,15 +1,16 @@
 package com.gemstone.gemfire.internal.redis.executor.hash;
 
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
+import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
+import com.gemstone.gemfire.internal.redis.RedisDataType;
 
 public class HKeysExecutor extends HashExecutor {
 
@@ -32,7 +33,7 @@ public class HKeysExecutor extends HashExecutor {
       return;
     }
 
-   Set<ByteArrayWrapper> keys = keyRegion.keySet();
+   Set<ByteArrayWrapper> keys = new HashSet(keyRegion.keySet());
    
    if (keys.isEmpty()) {
      command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HScanExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HScanExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HScanExecutor.java
index fb0ddc0..ded681a 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HScanExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HScanExecutor.java
@@ -2,6 +2,7 @@ package com.gemstone.gemfire.internal.redis.executor.hash;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map.Entry;
 import java.util.regex.Pattern;
@@ -30,7 +31,7 @@ public class HScanExecutor extends AbstractScanExecutor {
 
     ByteArrayWrapper key = command.getKey();
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = (Region<ByteArrayWrapper, ByteArrayWrapper>) context.getRegionCache().getRegion(key);
+    Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = (Region<ByteArrayWrapper, ByteArrayWrapper>) context.getRegionProvider().getRegion(key);
     checkDataType(key, RedisDataType.REDIS_HASH, context);
     if (keyRegion == null) {
       command.setResponse(Coder.getScanResponse(context.getByteBufAllocator(), new ArrayList<String>()));
@@ -100,7 +101,7 @@ public class HScanExecutor extends AbstractScanExecutor {
       return;
     }
 
-    List<Object> returnList = getIteration(keyRegion.entrySet(), matchPattern, count, cursor);
+    List<Object> returnList = getIteration(new HashSet(keyRegion.entrySet()), matchPattern, count, cursor);
 
     command.setResponse(Coder.getScanResponse(context.getByteBufAllocator(), returnList));
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HValsExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HValsExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HValsExecutor.java
index a17b054..8d5edaf 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HValsExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HValsExecutor.java
@@ -1,15 +1,16 @@
 package com.gemstone.gemfire.internal.redis.executor.hash;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
+import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
-import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
+import com.gemstone.gemfire.internal.redis.RedisDataType;
 
 public class HValsExecutor extends HashExecutor {
 
@@ -31,8 +32,8 @@ public class HValsExecutor extends HashExecutor {
       command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));
       return;
     }
-
-    Collection<ByteArrayWrapper> vals = keyRegion.values();
+    
+    Collection<ByteArrayWrapper> vals = new ArrayList(keyRegion.values());
 
     if (vals.isEmpty()) {
       command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HashExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HashExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HashExecutor.java
index 0abe42f..94b5115 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HashExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hash/HashExecutor.java
@@ -12,12 +12,12 @@ public abstract class HashExecutor extends AbstractExecutor {
   
   @SuppressWarnings("unchecked")
   protected Region<ByteArrayWrapper, ByteArrayWrapper> getOrCreateRegion(ExecutionHandlerContext context, ByteArrayWrapper key, RedisDataType type) {
-   return (Region<ByteArrayWrapper, ByteArrayWrapper>) context.getRegionCache().getOrCreateRegion(key, type, context);
+   return (Region<ByteArrayWrapper, ByteArrayWrapper>) context.getRegionProvider().getOrCreateRegion(key, type, context);
   }
   
   @SuppressWarnings("unchecked")
   protected Region<ByteArrayWrapper, ByteArrayWrapper> getRegion(ExecutionHandlerContext context, ByteArrayWrapper key) {
-   return (Region<ByteArrayWrapper, ByteArrayWrapper>) context.getRegionCache().getRegion(key);
+   return (Region<ByteArrayWrapper, ByteArrayWrapper>) context.getRegionProvider().getRegion(key);
   }
   
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/HllExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/HllExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/HllExecutor.java
index 1744f37..2f2a963 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/HllExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/HllExecutor.java
@@ -13,7 +13,7 @@ public abstract class HllExecutor extends AbstractExecutor {
   public static final Integer DEFAULT_HLL_SPARSE = 32;
   
   protected final void checkAndSetDataType(ByteArrayWrapper key, ExecutionHandlerContext context) {
-    Object oldVal = context.getRegionCache().metaPutIfAbsent(key, RedisDataType.REDIS_HLL);
+    Object oldVal = context.getRegionProvider().metaPutIfAbsent(key, RedisDataType.REDIS_HLL);
     if (oldVal == RedisDataType.REDIS_PROTECTED)
       throw new RedisDataTypeMismatchException("The key name \"" + key + "\" is protected");
     if (oldVal != null && oldVal != RedisDataType.REDIS_HLL)

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFAddExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFAddExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFAddExecutor.java
index 6177a0a..1fbe9e1 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFAddExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFAddExecutor.java
@@ -22,7 +22,7 @@ public class PFAddExecutor extends HllExecutor {
 
     ByteArrayWrapper key = command.getKey();
     checkAndSetDataType(key, context);
-    Region<ByteArrayWrapper, HyperLogLogPlus> keyRegion = context.getRegionCache().gethLLRegion();
+    Region<ByteArrayWrapper, HyperLogLogPlus> keyRegion = context.getRegionProvider().gethLLRegion();
 
     HyperLogLogPlus hll = keyRegion.get(key);
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFCountExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFCountExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFCountExecutor.java
index d056907..bdced51 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFCountExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFCountExecutor.java
@@ -22,7 +22,7 @@ public class PFCountExecutor extends HllExecutor {
       return;
     }
 
-    Region<ByteArrayWrapper, HyperLogLogPlus> keyRegion = context.getRegionCache().gethLLRegion();
+    Region<ByteArrayWrapper, HyperLogLogPlus> keyRegion = context.getRegionProvider().gethLLRegion();
 
     List<HyperLogLogPlus> hlls = new ArrayList<HyperLogLogPlus>();
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFMergeExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFMergeExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFMergeExecutor.java
index cc1ccf7..f646791 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFMergeExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/hll/PFMergeExecutor.java
@@ -24,7 +24,7 @@ public class PFMergeExecutor extends HllExecutor {
 
     ByteArrayWrapper destKey = command.getKey();
     checkAndSetDataType(destKey, context);
-    Region<ByteArrayWrapper, HyperLogLogPlus> keyRegion = context.getRegionCache().gethLLRegion();
+    Region<ByteArrayWrapper, HyperLogLogPlus> keyRegion = context.getRegionProvider().gethLLRegion();
     HyperLogLogPlus mergedHLL = keyRegion.get(destKey);
     if (mergedHLL == null)
       mergedHLL = new HyperLogLogPlus(DEFAULT_HLL_DENSE);
@@ -38,7 +38,7 @@ public class PFMergeExecutor extends HllExecutor {
         hlls.add(h);
     }
     if (hlls.isEmpty()) {
-      context.getRegionCache().removeKey(destKey);
+      context.getRegionProvider().removeKey(destKey);
       command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), "OK"));
       return;
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LIndexExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LIndexExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LIndexExecutor.java
index c2064a1..997f1af 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LIndexExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LIndexExecutor.java
@@ -38,7 +38,7 @@ public class LIndexExecutor extends ListExecutor {
       return;
     }
 
-    int listSize = keyRegion.size();
+    int listSize = keyRegion.size() - LIST_EMPTY_SIZE;
 
     Integer redisIndex;
 
@@ -90,7 +90,7 @@ public class LIndexExecutor extends ListExecutor {
 
     Query query = getQuery(key, ListQuery.LINDEX, context);
 
-    Object[] params = {new Integer(index + 1)};
+    Object[] params = {Integer.valueOf(index + 1)};
 
     SelectResults<?> results = (SelectResults<?>) query.execute(params);
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LLenExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LLenExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LLenExecutor.java
index 224cf60..63f0e1a 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LLenExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LLenExecutor.java
@@ -35,7 +35,7 @@ public class LLenExecutor extends ListExecutor {
       return;
     }
     
-    listSize = keyRegion.size();
+    listSize = keyRegion.size() - LIST_EMPTY_SIZE;
 
     command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), listSize));
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LRangeExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LRangeExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LRangeExecutor.java
index a0b9901..84b5193 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LRangeExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LRangeExecutor.java
@@ -43,7 +43,7 @@ public class LRangeExecutor extends ListExecutor {
       return;
     }
 
-    int listSize = keyRegion.size();
+    int listSize = keyRegion.size() - LIST_EMPTY_SIZE;
     if (listSize == 0) {
       command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));
       return;
@@ -70,7 +70,7 @@ public class LRangeExecutor extends ListExecutor {
     
     List<Struct> range;
     try {
-      range = getRange(context, key, redisStart, redisStop);
+      range = getRange(context, key, redisStart, redisStop, keyRegion);
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
@@ -81,14 +81,12 @@ public class LRangeExecutor extends ListExecutor {
       command.setResponse(Coder.getBulkStringArrayResponseOfValues(context.getByteBufAllocator(), range));
   }
 
-  private List<Struct> getRange(ExecutionHandlerContext context, ByteArrayWrapper key, int start, int stop) throws Exception {
+  private List<Struct> getRange(ExecutionHandlerContext context, ByteArrayWrapper key, int start, int stop, Region r) throws Exception {
 
     Query query = getQuery(key, ListQuery.LRANGE, context);
 
-    Object[] params = {new Integer(stop + 1)};
-
+    Object[] params = {Integer.valueOf(stop + 1)};
     SelectResults<Struct> results = (SelectResults<Struct>) query.execute(params);
-
     int size = results.size();
     if (results == null || size <= start) {
       return null;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LRemExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LRemExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LRemExecutor.java
index 58daba3..8a50b4f 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LRemExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LRemExecutor.java
@@ -79,10 +79,10 @@ public class LRemExecutor extends ListExecutor {
     Query query;
     if (count > 0) {
       query = getQuery(key, ListQuery.LREMG, context);
-      params = new Object[]{value, new Integer(count)};
+      params = new Object[]{value, Integer.valueOf(count)};
     } else if (count < 0) {
       query = getQuery(key, ListQuery.LREML, context);
-      params = new Object[]{value, new Integer(-count)};
+      params = new Object[]{value, Integer.valueOf(-count)};
     } else {
       query = getQuery(key, ListQuery.LREME, context);
       params = new Object[]{value};

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LSetExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LSetExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LSetExecutor.java
index ae09878..0668f02 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LSetExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LSetExecutor.java
@@ -52,7 +52,7 @@ public class LSetExecutor extends ListExecutor {
       return;
     }
 
-    int listSize = keyRegion.size();
+    int listSize = keyRegion.size() - LIST_EMPTY_SIZE;
     if (index < 0)
       index += listSize;
     if (index < 0 || index > listSize) {
@@ -79,7 +79,7 @@ public class LSetExecutor extends ListExecutor {
   private Integer getIndexKey(ExecutionHandlerContext context, ByteArrayWrapper key, int index) throws Exception {
     Query query = getQuery(key, ListQuery.LSET, context);
 
-    Object[] params = {new Integer(index + 1)};
+    Object[] params = {Integer.valueOf(index + 1)};
     
     SelectResults<Integer> results = (SelectResults<Integer>) query.execute(params);
     int size = results.size();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LTrimExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LTrimExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LTrimExecutor.java
index cb3e9a4..11ae338 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LTrimExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/LTrimExecutor.java
@@ -40,16 +40,16 @@ public class LTrimExecutor extends ListExecutor {
 
 
     checkDataType(key, RedisDataType.REDIS_LIST, context);
-    Region<Integer, ByteArrayWrapper> keyRegion = getRegion(context, key);
+    Region keyRegion = getRegion(context, key);
 
     if (keyRegion == null) {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_KEY_NOT_EXISTS));
       return;
     }
 
-    int listSize = keyRegion.size();
+    int listSize = keyRegion.size() - LIST_EMPTY_SIZE;
     if (listSize == 0) {
-      command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));
+      command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), SUCCESS));
       return;
     }
 
@@ -70,37 +70,35 @@ public class LTrimExecutor extends ListExecutor {
       command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), SUCCESS));
       return;
     } else if (redisStart == 0 && redisStop < redisStart) {
-      context.getRegionCache().removeKey(key, RedisDataType.REDIS_LIST);
+      context.getRegionProvider().removeKey(key, RedisDataType.REDIS_LIST);
       command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), SUCCESS));
       return;
     }
 
     List<Integer> keepList;
     try {
-      keepList = getRange(context, key, redisStart, redisStop);
+      keepList = getRange(context, key, redisStart, redisStop, keyRegion);
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
     
-    for (Integer keyElement: keyRegion.keySet()) {
-      if (!keepList.contains(keyElement))
+    for (Object keyElement: keyRegion.keySet()) {
+      if (!keepList.contains(keyElement) && keyElement instanceof Integer)
         keyRegion.remove(keyElement);
     }
     
     // Reset indexes in meta data region
-    Region<String, Integer> meta = context.getRegionCache().getListsMetaRegion();
-    meta.put(key + "head", keepList.get(0));
-    meta.put(key + "tail", keepList.get(keepList.size() - 1));
+    keyRegion.put("head", keepList.get(0));
+    keyRegion.put("tail", keepList.get(keepList.size() - 1));
     command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), SUCCESS));
   }
 
-  private List<Integer> getRange(ExecutionHandlerContext context, ByteArrayWrapper key, int start, int stop) throws Exception {
+  private List<Integer> getRange(ExecutionHandlerContext context, ByteArrayWrapper key, int start, int stop, Region r) throws Exception {
     Query query = getQuery(key, ListQuery.LTRIM, context);
 
-    Object[] params = {new Integer(stop + 1)};
-
+    Object[] params = {Integer.valueOf(stop + 1)};
+    
     SelectResults<Integer> results = (SelectResults<Integer>) query.execute(params);
-
     if (results == null || results.size() <= start) {
       return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/ListExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/ListExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/ListExecutor.java
index 5b8e0cc..ebb36a1 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/ListExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/ListExecutor.java
@@ -3,6 +3,7 @@ package com.gemstone.gemfire.internal.redis.executor.list;
 import java.util.List;
 
 import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionDestroyedException;
 import com.gemstone.gemfire.cache.query.QueryService;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
@@ -13,6 +14,8 @@ import com.gemstone.gemfire.internal.redis.executor.AbstractExecutor;
 
 public abstract class ListExecutor extends AbstractExecutor {
 
+  protected static final int LIST_EMPTY_SIZE = 2;
+  
   protected static enum ListDirection {LEFT, RIGHT};
 
   protected final static QueryService getQueryService() {
@@ -22,12 +25,12 @@ public abstract class ListExecutor extends AbstractExecutor {
   @SuppressWarnings("unchecked")
   @Override
   protected Region<Integer, ByteArrayWrapper> getOrCreateRegion(ExecutionHandlerContext context, ByteArrayWrapper key, RedisDataType type) {
-    return (Region<Integer, ByteArrayWrapper>) context.getRegionCache().getOrCreateRegion(key, type, context);
+    return (Region<Integer, ByteArrayWrapper>) context.getRegionProvider().getOrCreateRegion(key, type, context);
   }
   
   @SuppressWarnings("unchecked")
   protected Region<Integer, ByteArrayWrapper> getRegion(ExecutionHandlerContext context, ByteArrayWrapper key) {
-    return (Region<Integer, ByteArrayWrapper>) context.getRegionCache().getRegion(key);
+    return (Region<Integer, ByteArrayWrapper>) context.getRegionProvider().getRegion(key);
   }
 
   /**
@@ -45,14 +48,12 @@ public abstract class ListExecutor extends AbstractExecutor {
    * @param context Context of this push
    */
   protected void pushElements(ByteArrayWrapper key, List<byte[]> commandElems, int startIndex, int endIndex,
-      Region<Integer, ByteArrayWrapper> keyRegion, ListDirection pushType, ExecutionHandlerContext context) {
-    Region<String, Integer> meta = context.getRegionCache().getListsMetaRegion();
-
-    String indexKey = pushType == ListDirection.LEFT ? key + "head" : key + "tail";
-    String oppositeKey = pushType == ListDirection.RIGHT ? key + "head" : key + "tail";
-    Integer index = meta.get(indexKey);
-    Integer opp = meta.get(oppositeKey);
+      Region keyRegion, ListDirection pushType, ExecutionHandlerContext context) {
 
+    String indexKey = pushType == ListDirection.LEFT ? "head" : "tail";
+    String oppositeKey = pushType == ListDirection.RIGHT ? "head" : "tail";
+    Integer index = (Integer) keyRegion.get(indexKey);
+    Integer opp = (Integer) keyRegion.get(oppositeKey);
     if (index != opp)
       index += pushType == ListDirection.LEFT ? -1 : 1; // Subtract index if left push, add if right push
 
@@ -76,8 +77,9 @@ public abstract class ListExecutor extends AbstractExecutor {
       Object oldValue;
       do {
         oldValue = keyRegion.putIfAbsent(index, wrapper);
-        if (oldValue != null)
+        if (oldValue != null) {
           index += pushType == ListDirection.LEFT ? -1 : 1; // Subtract index if left push, add if right push
+        }
       } while (oldValue != null);
 
       /**
@@ -119,9 +121,9 @@ public abstract class ListExecutor extends AbstractExecutor {
 
       boolean indexSet = false;
       do {
-        Integer existingIndex = meta.get(indexKey);
+        Integer existingIndex = (Integer) keyRegion.get(indexKey);
         if ((pushType == ListDirection.RIGHT && existingIndex < index) || (pushType == ListDirection.LEFT && existingIndex > index))
-          indexSet = meta.replace(indexKey, existingIndex, index);
+          indexSet = keyRegion.replace(indexKey, existingIndex, index);
         else
           break;
       } while (!indexSet);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PopExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PopExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PopExecutor.java
index af3f8b0..e501de0 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PopExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PopExecutor.java
@@ -3,6 +3,7 @@ package com.gemstone.gemfire.internal.redis.executor.list;
 import java.util.List;
 
 import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionDestroyedException;
 import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
 import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.Command;
@@ -24,16 +25,15 @@ public abstract class PopExecutor extends ListExecutor implements Extendable {
     ByteArrayWrapper key = command.getKey();
 
     checkDataType(key, RedisDataType.REDIS_LIST, context);
-    Region<Integer, ByteArrayWrapper> keyRegion = getRegion(context, key);
-    Region<String, Integer> meta = context.getRegionCache().getListsMetaRegion();
+    Region keyRegion = getRegion(context, key);
 
-    if (keyRegion == null || keyRegion.size() == 0) {
+    if (keyRegion == null || keyRegion.size() == LIST_EMPTY_SIZE) {
       command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
       return;
     }
 
-    String indexKey = popType() == ListDirection.LEFT ? key + "head" : key + "tail";
-    String oppositeKey = popType() == ListDirection.RIGHT ? key + "head" : key + "tail";
+    String indexKey = popType() == ListDirection.LEFT ? "head" : "tail";
+    String oppositeKey = popType() == ListDirection.RIGHT ? "head" : "tail";
     Integer index = 0;
     int originalIndex = index;
     int incr = popType() == ListDirection.LEFT ? 1 : -1;
@@ -49,10 +49,11 @@ public abstract class PopExecutor extends ListExecutor implements Extendable {
     
     boolean indexChanged = false;
     do {
-      index = meta.get(indexKey);
-      if (index == meta.get(oppositeKey))
+      index = (Integer) keyRegion.get(indexKey);
+      Integer opp = (Integer) keyRegion.get(oppositeKey);
+      if (index.equals(opp))
         break;
-      indexChanged = meta.replace(indexKey, index, index + incr);
+      indexChanged = keyRegion.replace(indexKey, index, index + incr);
     } while(!indexChanged);
     
     /**
@@ -67,7 +68,7 @@ public abstract class PopExecutor extends ListExecutor implements Extendable {
     boolean removed = false;
     int i = 0;
     do {
-      valueWrapper = keyRegion.get(index);
+      valueWrapper = (ByteArrayWrapper) keyRegion.get(index);
       if (valueWrapper != null)
         removed = keyRegion.remove(index, valueWrapper);
       
@@ -116,12 +117,12 @@ public abstract class PopExecutor extends ListExecutor implements Extendable {
        */
       
       index += incr;
-      int metaIndex = meta.get(indexKey);
+      Integer metaIndex = (Integer) keyRegion.get(indexKey);
       if (i < 1 && (popType() == ListDirection.LEFT && metaIndex < originalIndex ||
           popType() == ListDirection.RIGHT && metaIndex > originalIndex))
         index = metaIndex;
       i++;
-    } while (!removed && keyRegion.size() != 0);
+    } while (!removed && keyRegion.size() != LIST_EMPTY_SIZE);
     if (valueWrapper != null)
       command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), valueWrapper.toBytes()));
     else

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PushExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PushExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PushExecutor.java
index 4414e0a..fdc7208 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PushExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PushExecutor.java
@@ -29,7 +29,7 @@ public abstract class PushExecutor extends PushXExecutor implements Extendable {
 
     Region<Integer, ByteArrayWrapper> keyRegion = getOrCreateRegion(context, key, RedisDataType.REDIS_LIST);
     pushElements(key, commandElems, START_VALUES_INDEX, commandElems.size(), keyRegion, pushType(), context);
-    int listSize = keyRegion.size();
+    int listSize = keyRegion.size() - LIST_EMPTY_SIZE;
     command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), listSize));
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PushXExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PushXExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PushXExecutor.java
index fbbad1e..ac89522 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PushXExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/list/PushXExecutor.java
@@ -33,7 +33,7 @@ public abstract class PushXExecutor extends ListExecutor implements Extendable {
     checkDataType(key, RedisDataType.REDIS_LIST, context);    
     pushElements(key, commandElems, 2, 3, keyRegion, pushType(), context);
     
-    int listSize = keyRegion.size();
+    int listSize = keyRegion.size() - LIST_EMPTY_SIZE;
 
     command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), listSize));
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/org/apache/hadoop/fs/GlobPattern.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/org/apache/hadoop/fs/GlobPattern.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/org/apache/hadoop/fs/GlobPattern.java
deleted file mode 100644
index b6cd906..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/org/apache/hadoop/fs/GlobPattern.java
+++ /dev/null
@@ -1,164 +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.internal.redis.executor.org.apache.hadoop.fs;
-
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-/**
- * A class for POSIX glob pattern with brace expansions.
- */
-public class GlobPattern {
-  private static final char BACKSLASH = '\\';
-  private Pattern compiled;
-  private boolean hasWildcard = false;
-
-  /**
-   * Construct the glob pattern object with a glob pattern string
-   * @param globPattern the glob pattern string
-   */
-  public GlobPattern(String globPattern) {
-    set(globPattern);
-  }
-
-  /**
-   * @return the compiled pattern
-   */
-  public Pattern compiled() {
-    return compiled;
-  }
-
-  /**
-   * Compile glob pattern string
-   * @param globPattern the glob pattern
-   * @return the pattern object
-   */
-  public static Pattern compile(String globPattern) {
-    return new GlobPattern(globPattern).compiled();
-  }
-
-  /**
-   * Match input against the compiled glob pattern
-   * @param s input chars
-   * @return true for successful matches
-   */
-  public boolean matches(CharSequence s) {
-    return compiled.matcher(s).matches();
-  }
-
-  /**
-   * Set and compile a glob pattern
-   * @param glob  the glob pattern string
-   */
-  public void set(String glob) {
-    StringBuilder regex = new StringBuilder();
-    int setOpen = 0;
-    int curlyOpen = 0;
-    int len = glob.length();
-    hasWildcard = false;
-
-    for (int i = 0; i < len; i++) {
-      char c = glob.charAt(i);
-
-      switch (c) {
-      case BACKSLASH:
-        if (++i >= len) {
-          error("Missing escaped character", glob, i);
-        }
-        regex.append(c).append(glob.charAt(i));
-        continue;
-      case '.':
-      case '$':
-      case '(':
-      case ')':
-      case '|':
-      case '+':
-        // escape regex special chars that are not glob special chars
-        regex.append(BACKSLASH);
-        break;
-      case '*':
-        regex.append('.');
-        hasWildcard = true;
-        break;
-      case '?':
-        regex.append('.');
-        hasWildcard = true;
-        continue;
-      case '{': // start of a group
-        regex.append("(?:"); // non-capturing
-        curlyOpen++;
-        hasWildcard = true;
-        continue;
-      case ',':
-        regex.append(curlyOpen > 0 ? '|' : c);
-        continue;
-      case '}':
-        if (curlyOpen > 0) {
-          // end of a group
-          curlyOpen--;
-          regex.append(")");
-          continue;
-        }
-        break;
-      case '[':
-        if (setOpen > 0) {
-          error("Unclosed character class", glob, i);
-        }
-        setOpen++;
-        hasWildcard = true;
-        break;
-      case '^': // ^ inside [...] can be unescaped
-        if (setOpen == 0) {
-          regex.append(BACKSLASH);
-        }
-        break;
-      case '!': // [! needs to be translated to [^
-        regex.append(setOpen > 0 && '[' == glob.charAt(i - 1) ? '^' : '!');
-        continue;
-      case ']':
-        // Many set errors like [][] could not be easily detected here,
-        // as []], []-] and [-] are all valid POSIX glob and java regex.
-        // We'll just let the regex compiler do the real work.
-        setOpen = 0;
-        break;
-      default:
-      }
-      regex.append(c);
-    }
-
-    if (setOpen > 0) {
-      error("Unclosed character class", glob, len);
-    }
-    if (curlyOpen > 0) {
-      error("Unclosed group", glob, len);
-    }
-    compiled = Pattern.compile(regex.toString());
-  }
-
-  /**
-   * @return true if this is a wildcard pattern (with special chars)
-   */
-  public boolean hasWildcard() {
-    return hasWildcard;
-  }
-
-  private static void error(String message, String pattern, int pos) {
-    throw new PatternSyntaxException(message, pattern, pos);
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SAddExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SAddExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SAddExecutor.java
index aa4a5f2..fd33104 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SAddExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SAddExecutor.java
@@ -25,7 +25,7 @@ public class SAddExecutor extends SetExecutor {
 
     ByteArrayWrapper key = command.getKey();
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionCache().getOrCreateRegion(key, RedisDataType.REDIS_SET, context);
+    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionProvider().getOrCreateRegion(key, RedisDataType.REDIS_SET, context);
 
     if (commandElems.size() >= 4) {
       Map<ByteArrayWrapper, Boolean> entries = new HashMap<ByteArrayWrapper, Boolean>();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SCardExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SCardExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SCardExecutor.java
index 4677565..5b8d842 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SCardExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SCardExecutor.java
@@ -26,7 +26,7 @@ public class SCardExecutor extends SetExecutor {
 
     ByteArrayWrapper key = command.getKey();
     checkDataType(key, RedisDataType.REDIS_SET, context);
-    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionCache().getRegion(key);
+    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionProvider().getRegion(key);
 
     if (keyRegion == null) {
       command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NOT_EXISTS));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SIsMemberExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SIsMemberExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SIsMemberExecutor.java
index 355f70f..33de3aa 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SIsMemberExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SIsMemberExecutor.java
@@ -30,7 +30,7 @@ public class SIsMemberExecutor extends SetExecutor {
     
     checkDataType(key, RedisDataType.REDIS_SET, context);
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionCache().getRegion(key);
+    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionProvider().getRegion(key);
 
     if (keyRegion == null) {
       command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NOT_EXISTS));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SMembersExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SMembersExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SMembersExecutor.java
index bc68033..9536fa5 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SMembersExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SMembersExecutor.java
@@ -1,15 +1,16 @@
 package com.gemstone.gemfire.internal.redis.executor.set;
 
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.internal.redis.ByteArrayWrapper;
+import com.gemstone.gemfire.internal.redis.Coder;
 import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.RedisConstants.ArityDef;
 import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.Coder;
 
 public class SMembersExecutor extends SetExecutor {
 
@@ -25,14 +26,14 @@ public class SMembersExecutor extends SetExecutor {
     ByteArrayWrapper key = command.getKey();
     checkDataType(key, RedisDataType.REDIS_SET, context);
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionCache().getRegion(key);
+    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionProvider().getRegion(key);
     
     if (keyRegion == null) {
       command.setResponse(Coder.getEmptyArrayResponse(context.getByteBufAllocator()));
       return;
     }
     
-    Set<ByteArrayWrapper> members = keyRegion.keySet();
+    Set<ByteArrayWrapper> members = new HashSet(keyRegion.keySet()); // Emulate copy on read
     
     command.setResponse(Coder.getBulkStringArrayResponse(context.getByteBufAllocator(), members));
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SMoveExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SMoveExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SMoveExecutor.java
index f7f5c86..a73bbd9 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SMoveExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SMoveExecutor.java
@@ -32,7 +32,7 @@ public class SMoveExecutor extends SetExecutor {
     checkDataType(source, RedisDataType.REDIS_SET, context);
     checkDataType(destination, RedisDataType.REDIS_SET, context);
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, Boolean> sourceRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionCache().getRegion(source);
+    Region<ByteArrayWrapper, Boolean> sourceRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionProvider().getRegion(source);
 
     if (sourceRegion == null) {
       command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NOT_MOVED));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SPopExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SPopExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SPopExecutor.java
index 73e59de..6461f34 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SPopExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SPopExecutor.java
@@ -23,7 +23,7 @@ public class SPopExecutor extends SetExecutor {
     
     ByteArrayWrapper key = command.getKey();
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionCache().getRegion(key);
+    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionProvider().getRegion(key);
     if (keyRegion == null || keyRegion.isEmpty()) {
       command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
       return;
@@ -37,7 +37,7 @@ public class SPopExecutor extends SetExecutor {
     
     keyRegion.remove(pop);
     if (keyRegion.isEmpty()) {
-      context.getRegionCache().removeKey(key);
+      context.getRegionProvider().removeKey(key);
     }
     command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), pop.toBytes()));
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SRandMemberExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SRandMemberExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SRandMemberExecutor.java
index 5494b30..34954c5 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SRandMemberExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SRandMemberExecutor.java
@@ -28,7 +28,7 @@ public class SRandMemberExecutor extends SetExecutor {
 
     ByteArrayWrapper key = command.getKey();
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionCache().getRegion(key);
+    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionProvider().getRegion(key);
 
     int count = 1;
 
@@ -49,7 +49,7 @@ public class SRandMemberExecutor extends SetExecutor {
     int members = keyRegion.size();
 
     if (members <= count && count != 1) {
-      command.setResponse(Coder.getBulkStringArrayResponse(context.getByteBufAllocator(), keyRegion.keySet()));
+      command.setResponse(Coder.getBulkStringArrayResponse(context.getByteBufAllocator(), new HashSet<ByteArrayWrapper>(keyRegion.keySet())));
       return;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SRemExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SRemExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SRemExecutor.java
index f85e095..482d83e 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SRemExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SRemExecutor.java
@@ -26,7 +26,7 @@ public class SRemExecutor extends SetExecutor {
     ByteArrayWrapper key = command.getKey();
     checkDataType(key, RedisDataType.REDIS_SET, context);
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionCache().getRegion(key);
+    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionProvider().getRegion(key);
     
     if (keyRegion == null) {
       command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NONE_REMOVED));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SScanExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SScanExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SScanExecutor.java
index 87605df..7c0133b 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SScanExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SScanExecutor.java
@@ -30,7 +30,7 @@ public class SScanExecutor extends AbstractScanExecutor {
     ByteArrayWrapper key = command.getKey();
     checkDataType(key, RedisDataType.REDIS_SET, context);
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionCache().getRegion(key);
+    Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionProvider().getRegion(key);
     if (keyRegion == null) {
       command.setResponse(Coder.getScanResponse(context.getByteBufAllocator(), new ArrayList<String>()));
       return;
@@ -96,7 +96,7 @@ public class SScanExecutor extends AbstractScanExecutor {
     }
 
     @SuppressWarnings("unchecked")
-    List<ByteArrayWrapper> returnList = (List<ByteArrayWrapper>) getIteration(keyRegion.keySet(), matchPattern, count, cursor);
+    List<ByteArrayWrapper> returnList = (List<ByteArrayWrapper>) getIteration(new ArrayList(keyRegion.keySet()), matchPattern, count, cursor);
 
     command.setResponse(Coder.getScanResponse(context.getByteBufAllocator(), returnList));
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SetOpExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SetOpExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SetOpExecutor.java
index f2cfd9d..7cd1932 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SetOpExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/set/SetOpExecutor.java
@@ -14,7 +14,7 @@ import com.gemstone.gemfire.internal.redis.Command;
 import com.gemstone.gemfire.internal.redis.ExecutionHandlerContext;
 import com.gemstone.gemfire.internal.redis.Extendable;
 import com.gemstone.gemfire.internal.redis.RedisDataType;
-import com.gemstone.gemfire.internal.redis.RegionCache;
+import com.gemstone.gemfire.internal.redis.RegionProvider;
 
 public abstract class SetOpExecutor extends SetExecutor implements Extendable {
 
@@ -27,12 +27,11 @@ public abstract class SetOpExecutor extends SetExecutor implements Extendable {
       command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), getArgsError()));
       return;
     }
-    RegionCache rC = context.getRegionCache();
+    RegionProvider rC = context.getRegionProvider();
     ByteArrayWrapper destination = null;
     if (isStorage())
       destination = command.getKey();
 
-
     ByteArrayWrapper firstSetKey = new ByteArrayWrapper(commandElems.get(setsStartIndex++));
     if (!isStorage())
       checkDataType(firstSetKey, RedisDataType.REDIS_SET, context);
@@ -53,10 +52,8 @@ public abstract class SetOpExecutor extends SetExecutor implements Extendable {
     }
     if (setList.isEmpty()) {
       if (isStorage()) {
-        if (firstSet == null) {
           command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), 0));
-          context.getRegionCache().removeKey(destination);
-        }
+          context.getRegionProvider().removeKey(destination);
       } else {
         if (firstSet == null)
           command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/SortedSetExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/SortedSetExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/SortedSetExecutor.java
index 7443019..f193727 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/SortedSetExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/SortedSetExecutor.java
@@ -12,13 +12,13 @@ public abstract class SortedSetExecutor extends AbstractExecutor {
   @Override
   protected Region<ByteArrayWrapper, DoubleWrapper> getOrCreateRegion(ExecutionHandlerContext context, ByteArrayWrapper key, RedisDataType type) {
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, DoubleWrapper> r = (Region<ByteArrayWrapper, DoubleWrapper>) context.getRegionCache().getOrCreateRegion(key, type, context);
+    Region<ByteArrayWrapper, DoubleWrapper> r = (Region<ByteArrayWrapper, DoubleWrapper>) context.getRegionProvider().getOrCreateRegion(key, type, context);
     return r;
   }
   
   protected Region<ByteArrayWrapper, DoubleWrapper> getRegion(ExecutionHandlerContext context, ByteArrayWrapper key) {
     @SuppressWarnings("unchecked")
-    Region<ByteArrayWrapper, DoubleWrapper> r = (Region<ByteArrayWrapper, DoubleWrapper>) context.getRegionCache().getRegion(key);
+    Region<ByteArrayWrapper, DoubleWrapper> r = (Region<ByteArrayWrapper, DoubleWrapper>) context.getRegionProvider().getRegion(key);
     return r;
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRangeByLexExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRangeByLexExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRangeByLexExecutor.java
index 2e91ffb..e5bb73f 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRangeByLexExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRangeByLexExecutor.java
@@ -163,9 +163,7 @@ public class ZRangeByLexExecutor extends SortedSetExecutor {
     }
     if (limit > 0)
       params[params.length - 1] =  (limit + offset);
-
     SelectResults<ByteArrayWrapper> results = (SelectResults<ByteArrayWrapper>) query.execute(params);
-
     List<ByteArrayWrapper> list = results.asList();
     int size = list.size();
     return list.subList(Math.min(size, offset), size);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRangeByScoreExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRangeByScoreExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRangeByScoreExecutor.java
index e554618..fc73713 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRangeByScoreExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRangeByScoreExecutor.java
@@ -1,6 +1,7 @@
 package com.gemstone.gemfire.internal.redis.executor.sortedset;
 
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 
 import com.gemstone.gemfire.cache.Region;
@@ -135,7 +136,7 @@ public class ZRangeByScoreExecutor extends SortedSetExecutor implements Extendab
     if (start == Double.POSITIVE_INFINITY || stop == Double.NEGATIVE_INFINITY || start > stop || (start == stop && (!startInclusive || !stopInclusive)))
       return null;
     if (start == Double.NEGATIVE_INFINITY && stop == Double.POSITIVE_INFINITY)
-      return keyRegion.entrySet();
+      return new HashSet(keyRegion.entrySet());
 
     Query query;
     Object[] params;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemExecutor.java
index c119281..d5d7a75 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemExecutor.java
@@ -42,7 +42,7 @@ public class ZRemExecutor extends SortedSetExecutor {
         numDeletedMembers++;
     }
     if (keyRegion.isEmpty())
-      context.getRegionCache().removeKey(key);
+      context.getRegionProvider().removeKey(key);
     command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numDeletedMembers));
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByLexExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByLexExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByLexExecutor.java
index 6dc7f51..2b26100 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByLexExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByLexExecutor.java
@@ -1,5 +1,6 @@
 package com.gemstone.gemfire.internal.redis.executor.sortedset;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
@@ -90,7 +91,7 @@ public class ZRemRangeByLexExecutor extends SortedSetExecutor {
 
   private Collection<ByteArrayWrapper> getRange(ByteArrayWrapper key, Region<ByteArrayWrapper, DoubleWrapper> keyRegion, ExecutionHandlerContext context, ByteArrayWrapper start, ByteArrayWrapper stop, boolean startInclusive, boolean stopInclusive) throws Exception {
     if (start.equals("-") && stop.equals("+"))
-      return keyRegion.keySet();
+      return new ArrayList<ByteArrayWrapper>(keyRegion.keySet());
     else if (start.equals("+") || stop.equals("-"))
       return null;
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a6a0ef5/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByRankExecutor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByRankExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByRankExecutor.java
index 24a4ed2..34452e3 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByRankExecutor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/redis/executor/sortedset/ZRemRangeByRankExecutor.java
@@ -69,7 +69,7 @@ public class ZRemRangeByRankExecutor extends SortedSetExecutor {
     try {
       if (startRank == 0 && stopRank == sSetSize- 1) {
         numRemoved = keyRegion.size();
-        context.getRegionCache().removeKey(key);
+        context.getRegionProvider().removeKey(key);
       } else {
         removeList = getRemoveKeys(context, key, startRank, stopRank);
       }
@@ -89,7 +89,7 @@ public class ZRemRangeByRankExecutor extends SortedSetExecutor {
           numRemoved++;
       }
       if (keyRegion.isEmpty())
-        context.getRegionCache().removeKey(key);
+        context.getRegionProvider().removeKey(key);
     }
     command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numRemoved));
   }