Java Code Examples for com.gemstone.gemfire.cache.Region#getAll()

The following examples show how to use com.gemstone.gemfire.cache.Region#getAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GetCommand.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private ByteBuffer processAsciiCommand(RequestReader request, Cache cache) {
  ByteBuffer buffer = request.getRequest();
  CharBuffer flb = getFirstLineBuffer();
  getAsciiDecoder().reset();
  getAsciiDecoder().decode(buffer, flb, false);
  flb.flip();
  String firstLine = getFirstLine();
  String[] firstLineElements = firstLine.split(" ");
  
  boolean isGets = firstLineElements[0].equals("gets");
  Set<String> keys = new HashSet<String>();
  for (int i=1; i<firstLineElements.length; i++) {
    keys.add(stripNewline(firstLineElements[i]));
  }
  
  Region<Object, ValueWrapper> r = getMemcachedRegion(cache);
  Map<Object, ValueWrapper> results = r.getAll(keys);
  
  return composeReply(results, isGets);
}
 
Example 2
Source File: GetCommand.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private ByteBuffer processAsciiCommand(RequestReader request, Cache cache) {
  ByteBuffer buffer = request.getRequest();
  CharBuffer flb = getFirstLineBuffer();
  getAsciiDecoder().reset();
  getAsciiDecoder().decode(buffer, flb, false);
  flb.flip();
  String firstLine = getFirstLine();
  String[] firstLineElements = firstLine.split(" ");
  
  boolean isGets = firstLineElements[0].equals("gets");
  Set<String> keys = new HashSet<String>();
  for (int i=1; i<firstLineElements.length; i++) {
    keys.add(stripNewline(firstLineElements[i]));
  }
  
  Region<Object, ValueWrapper> r = getMemcachedRegion(cache);
  Map<Object, ValueWrapper> results = r.getAll(keys);
  
  return composeReply(results, isGets);
}
 
Example 3
Source File: RegionWithHDFSBasicDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
protected void checkWithGetAll(String uniqueName, ArrayList arrayl) {
  Region r = getRootRegion(uniqueName);
  Map map = r.getAll(arrayl);
  getCache().getLogger().info("Read entries " + map.size());
  for (Object e : map.keySet()) {
    String v = e.toString().replaceFirst("K", "V");
    assertTrue( "Reading entries failed for key " + e + " where value = " + map.get(e), v.equals(map.get(e)));
  }
}
 
Example 4
Source File: PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void putAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));

  }
  catch (Exception e) {
    fail("Test failed after the put operation", e);

  }
}
 
Example 5
Source File: PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void getAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));

  }
  catch (Exception e) {
    fail("Test failed after the put operation", e);

  }
}
 
Example 6
Source File: PRClientServerRegionFunctionExecutionSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void putAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));
    
  }catch(Exception e){
    fail("Test failed after the put operation", e);
    
  }
}
 
Example 7
Source File: PRClientServerRegionFunctionExecutionSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void getAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));
    
  }catch(Exception e){
    fail("Test failed after the put operation", e);
    
  }
}
 
Example 8
Source File: PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void putAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));

  }
  catch (Exception e) {
    fail("Test failed after the put operation", e);

  }
}
 
Example 9
Source File: PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void getAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));

  }
  catch (Exception e) {
    fail("Test failed after the put operation", e);

  }
}
 
Example 10
Source File: ColocatedRegionWithHDFSDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void checkWithGetAll(String uniqueName, ArrayList arrayl) {
  Region r1= getRootRegion(uniqueName + "-r1");
  Region r2= getRootRegion(uniqueName + "-r2");
  Map map1 = r1.getAll(arrayl);
  Map map2 = r2.getAll(arrayl);
  for (Object e : map1.keySet()) {
    String v = e.toString().replaceFirst("K", "V");
    assertTrue( "Reading entries failed for key " + e + " where value = " + map1.get(e), v.equals(map1.get(e)));
    assertTrue( "Reading entries failed for key " + e + " where value = " + map2.get(e), v.equals(map2.get(e)));
  }
}
 
Example 11
Source File: RegionWithHDFSBasicDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
protected void checkWithGetAll(String uniqueName, ArrayList arrayl) {
  Region r = getRootRegion(uniqueName);
  Map map = r.getAll(arrayl);
  getCache().getLogger().info("Read entries " + map.size());
  for (Object e : map.keySet()) {
    String v = e.toString().replaceFirst("K", "V");
    assertTrue( "Reading entries failed for key " + e + " where value = " + map.get(e), v.equals(map.get(e)));
  }
}
 
Example 12
Source File: ColocatedRegionWithHDFSDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void checkWithGetAll(String uniqueName, ArrayList arrayl) {
  Region r1= getRootRegion(uniqueName + "-r1");
  Region r2= getRootRegion(uniqueName + "-r2");
  Map map1 = r1.getAll(arrayl);
  Map map2 = r2.getAll(arrayl);
  for (Object e : map1.keySet()) {
    String v = e.toString().replaceFirst("K", "V");
    assertTrue( "Reading entries failed for key " + e + " where value = " + map1.get(e), v.equals(map1.get(e)));
    assertTrue( "Reading entries failed for key " + e + " where value = " + map2.get(e), v.equals(map2.get(e)));
  }
}
 
Example 13
Source File: PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void putAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));

  }
  catch (Exception e) {
    fail("Test failed after the put operation", e);

  }
}
 
Example 14
Source File: PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void getAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));

  }
  catch (Exception e) {
    fail("Test failed after the put operation", e);

  }
}
 
Example 15
Source File: PRClientServerRegionFunctionExecutionSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void putAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));
    
  }catch(Exception e){
    fail("Test failed after the put operation", e);
    
  }
}
 
Example 16
Source File: PRClientServerRegionFunctionExecutionSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void getAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));
    
  }catch(Exception e){
    fail("Test failed after the put operation", e);
    
  }
}
 
Example 17
Source File: PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void putAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));

  }
  catch (Exception e) {
    fail("Test failed after the put operation", e);

  }
}
 
Example 18
Source File: PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void getAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));

  }
  catch (Exception e) {
    fail("Test failed after the put operation", e);

  }
}
 
Example 19
Source File: SingleHopGetAllPutAllDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void putAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final Map keysValuesMap = new HashMap();
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
    keysValuesMap.put("execKey-" + i, "values-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    // check if the client meta-data is in synch

    // check if the function was routed to pruned nodes
    region.putAll(keysValuesMap);
    // check the listener
    // check how the function was executed
    pause(2000);
    region.putAll(keysValuesMap);
    
    // check if the client meta-data is in synch
    verifyMetadata();
    
    // check if the function was routed to pruned nodes
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(keysValuesMap));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(keysValuesMap));
  }
  catch (Exception e) {
    fail("Test failed after the putAll operation", e);
  }
}
 
Example 20
Source File: SingleHopGetAllPutAllDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void getAll() {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final List testKeysList = new ArrayList();
  for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) {
    testKeysList.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  try {
    int j = 0;
    Map origVals = new HashMap();
    for (Iterator i = testKeysList.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      Object key = i.next();
      origVals.put(key, val);
      region.put(key, val);
    }

    // check if the client meta-data is in synch
    verifyMetadata();
    
    // check if the function was routed to pruned nodes
    Map resultMap = region.getAll(testKeysList);
    assertTrue(resultMap.equals(origVals));
    pause(2000);
    Map secondResultMap = region.getAll(testKeysList);
    assertTrue(secondResultMap.equals(origVals));
  }
  catch (Exception e) {
    fail("Test failed after the getAll operation", e);
  }
}