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

The following examples show how to use com.gemstone.gemfire.cache.Region#isEmpty() . 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: Feeder.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void populateSharedMapWithRegionData() {
  try {
    numOfRegion = TestConfig.tab().intAt(
        delta.DeltaPropagationPrms.numberOfRegions, 1);
    for (int i = 0; i < numOfRegion; i++) {
      Region region = RegionHelper.getRegion(regionName + i);

      if (region == null) {
        throw new TestException("Region created is null "
            + TestHelper.getStackTrace());
      }

      if (region.isEmpty()) {
        throw new TestException(
            " Region has no entries to copy to the SharedMap "
                + TestHelper.getStackTrace());
      }

      Iterator iterator = region.entrySet(false).iterator();
      Region.Entry entry = null;
      Object key;
      Object value;
      while (iterator.hasNext()) {
        entry = (Region.Entry)iterator.next();
        key = entry.getKey();
        value = entry.getValue();
        if (value != null) {
          DeltaPropagationBB.getBB().getSharedMap().put(key, value);
        }
      }
    }
  }
  catch (Exception e) {
    e.printStackTrace();
    throw new TestException(e.getMessage() + TestHelper.getStackTrace(e));
  }
}
 
Example 2
Source File: WANClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Reader wan site destroys all the keys in its region
 */
public static void readerDestroyAllKeysTask() {

  Region region = RegionHelper.getRegion(REGION_NAME);

  Iterator iterator = region.entrySet(false).iterator();
  Region.Entry entry = null;
  Object key = null;

  while (iterator.hasNext()) {
    entry = (Region.Entry)iterator.next();
    key = entry.getKey();

    try {
      region.destroy(key);
    }
    catch (EntryNotFoundException e) {
      Log.getLogWriter().info("Entry Not found.");
    }
  }

  if (region.isEmpty()) {
    Log.getLogWriter().info(
        "Completed the destroy operation for all the keys in the region");
  }
  else {
    throw new TestException(
        "Region is supposed to be empty but that is not the case");
  }

}
 
Example 3
Source File: WANClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Validating Reader Wan Sites
 */
public static void validateReaderWanSiteEntriesTask() {
  Log.getLogWriter().info("Sleeping for some time ..");
  hydra.MasterController.sleepForMs(100000);
  Region region = RegionHelper.getRegion(REGION_NAME);
  if (region.isEmpty()) {
    throw new TestException(" Region has no entries to validate ");
  }
  long requiredSize = WANBlackboard.getInstance().getSharedCounters().read(
      WANBlackboard.currentEntry_writer);
  checkKeyRegionEntries("writer_", requiredSize);

  Iterator iterator = region.entrySet(false).iterator();
  Region.Entry entry = null;
  Object key = null;
  Object value = null;
  while (iterator.hasNext()) {
    entry = (Region.Entry)iterator.next();
    key = entry.getKey();
    value = entry.getValue();

    if (((String)key).startsWith("reader_")) {
      if (!keyList.contains(key)) {
        throw new TestException(
            "Found reader key that is not present in the keyList");
      }
      else if (((Integer)value).intValue() != ITERATIONS) {
        String s = "Wrong value in cache at " + key + ", expected "
            + ITERATIONS + " but got " + ((Integer)value).intValue();
        throw new TestException(s);
      }

    }

  }
}
 
Example 4
Source File: WANClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Validating Writer Wan Sites
 */
public static void validateWriterWanSiteEntriesTask() {
  Log.getLogWriter().info("Sleeping for some time ..");
  hydra.MasterController.sleepForMs(100000);
  Region region = RegionHelper.getRegion(REGION_NAME);
  if (region.isEmpty()) {
    throw new TestException(" Region has no entries to validate ");
  }
  checkInvalidKeys("writer_");
  long requiredSize = WANBlackboard.getInstance().getSharedCounters().read(
      WANBlackboard.currentEntry_writer);
  checkKeyRegionEntries("writer_", requiredSize);
}
 
Example 5
Source File: WanSecurity.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether the writer sites are having empty region
 */
public static void checkWriterRegionContentsEmpty() {
  Region region = RegionHelper.getRegion(regionNames.get(0));
  if (region.isEmpty()) {
    Log.getLogWriter().info("Region is empty as expected");
  }
  else {
    throw new TestException(
        "Region content supposed to be empty but it is having size of "
            + region.size());
  }
}
 
Example 6
Source File: WanSecurity.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Reader wan site destroys all the keys in its region
 */
public static void readerDestroyAllKeysTask() {

  Region region = RegionHelper.getRegion(regionNames.get(0));

  Iterator iterator = region.entrySet(false).iterator();
  Region.Entry entry = null;
  Object key = null;

  while (iterator.hasNext()) {
    entry = (Region.Entry)iterator.next();
    key = entry.getKey();

    try {
      region.destroy(key);
    }
    catch (EntryNotFoundException e) {
      Log.getLogWriter().info("Entry Not found for key " + key + ". Expected in this test.");
    }
  }

  if (region.isEmpty()) {
    Log.getLogWriter().info(
        "Completed the destroy operation for all the keys in the region");
  }
  else {
    throw new TestException(
        "Region is supposed to be empty but that is not the case");
  }
}
 
Example 7
Source File: WanSecurity.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Validating Reader Wan Sites
 */
public static void validateReaderWanSiteEntriesTask() {
  Log.getLogWriter().info("Sleeping for some time ..");
  hydra.MasterController.sleepForMs(100000);
  Region region = RegionHelper.getRegion(regionNames.get(0));
  if (region.isEmpty()) {
    throw new TestException(" Region has no entries to validate ");
  }
  long requiredSize = WANBlackboard.getInstance().getSharedCounters().read(
      WANBlackboard.currentEntry_writer);
  checkKeyRegionEntries(region.getName(), "writer_", requiredSize);

  Iterator iterator = region.entrySet(false).iterator();
  Region.Entry entry = null;
  Object key = null;
  Object value = null;
  while (iterator.hasNext()) {
    entry = (Region.Entry)iterator.next();
    key = entry.getKey();
    value = entry.getValue();

    if (((String)key).startsWith("reader_")) {
      if (!keyList.contains(key)) {
        throw new TestException(
            "Found reader key that is not present in the keyList");
      }
      else if (((Integer)value).intValue() != ITERATIONS) {
        String s = "Wrong value in region " + region.getFullPath() + " at " + key + ", expected "
            + ITERATIONS + " but got " + ((Integer)value).intValue();
        throw new TestException(s);
      }
    }
  }
}
 
Example 8
Source File: WanSecurity.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Validating Writer Wan Sites
 */
public static void validateWriterWanSiteEntriesTask() {
  Log.getLogWriter().info("Sleeping for some time ..");
  hydra.MasterController.sleepForMs(100000);
  Region region = RegionHelper.getRegion(regionNames.get(0));
  if (region.isEmpty()) {
    throw new TestException(" Region has no entries to validate ");
  }
  checkKeys(region.getName(), "writer_");
  
  long requiredSize = WANBlackboard.getInstance().getSharedCounters().read(
      WANBlackboard.currentEntry_writer);
  checkKeyRegionEntries(region.getName(), "writer_", requiredSize);
}
 
Example 9
Source File: Feeder.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void populateSharedMapWithRegionData() {
  try {
    numOfRegion = TestConfig.tab().intAt(
        delta.DeltaPropagationPrms.numberOfRegions, 1);
    for (int i = 0; i < numOfRegion; i++) {
      Region region = RegionHelper.getRegion(regionName + i);

      if (region == null) {
        throw new TestException("Region created is null "
            + TestHelper.getStackTrace());
      }

      if (region.isEmpty()) {
        throw new TestException(
            " Region has no entries to copy to the SharedMap "
                + TestHelper.getStackTrace());
      }

      Iterator iterator = region.entrySet(false).iterator();
      Region.Entry entry = null;
      Object key;
      Object value;
      while (iterator.hasNext()) {
        entry = (Region.Entry)iterator.next();
        key = entry.getKey();
        value = entry.getValue();
        if (value != null) {
          DeltaPropagationBB.getBB().getSharedMap().put(key, value);
        }
      }
    }
  }
  catch (Exception e) {
    e.printStackTrace();
    throw new TestException(e.getMessage() + TestHelper.getStackTrace(e));
  }
}
 
Example 10
Source File: WANClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether the writer sites are having empty region
 */
public static void checkWriterRegionContentsEmpty() {

  Region region = RegionHelper.getRegion(REGION_NAME);

  if (region.isEmpty()) {
    Log.getLogWriter().info("Region is empty as expected");
  }
  else {
    throw new TestException(
        "Region content supposed to be empty but it is having size of "
            + region.size());
  }

}
 
Example 11
Source File: WANClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Reader wan site destroys all the keys in its region
 */
public static void readerDestroyAllKeysTask() {

  Region region = RegionHelper.getRegion(REGION_NAME);

  Iterator iterator = region.entrySet(false).iterator();
  Region.Entry entry = null;
  Object key = null;

  while (iterator.hasNext()) {
    entry = (Region.Entry)iterator.next();
    key = entry.getKey();

    try {
      region.destroy(key);
    }
    catch (EntryNotFoundException e) {
      Log.getLogWriter().info("Entry Not found.");
    }
  }

  if (region.isEmpty()) {
    Log.getLogWriter().info(
        "Completed the destroy operation for all the keys in the region");
  }
  else {
    throw new TestException(
        "Region is supposed to be empty but that is not the case");
  }

}
 
Example 12
Source File: WANClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Validating Reader Wan Sites
 */
public static void validateReaderWanSiteEntriesTask() {
  Log.getLogWriter().info("Sleeping for some time ..");
  hydra.MasterController.sleepForMs(100000);
  Region region = RegionHelper.getRegion(REGION_NAME);
  if (region.isEmpty()) {
    throw new TestException(" Region has no entries to validate ");
  }
  long requiredSize = WANBlackboard.getInstance().getSharedCounters().read(
      WANBlackboard.currentEntry_writer);
  checkKeyRegionEntries("writer_", requiredSize);

  Iterator iterator = region.entrySet(false).iterator();
  Region.Entry entry = null;
  Object key = null;
  Object value = null;
  while (iterator.hasNext()) {
    entry = (Region.Entry)iterator.next();
    key = entry.getKey();
    value = entry.getValue();

    if (((String)key).startsWith("reader_")) {
      if (!keyList.contains(key)) {
        throw new TestException(
            "Found reader key that is not present in the keyList");
      }
      else if (((Integer)value).intValue() != ITERATIONS) {
        String s = "Wrong value in cache at " + key + ", expected "
            + ITERATIONS + " but got " + ((Integer)value).intValue();
        throw new TestException(s);
      }

    }

  }
}
 
Example 13
Source File: WANClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether the writer sites are having empty region
 */
public static void checkWriterRegionContentsEmpty() {

  Region region = RegionHelper.getRegion(REGION_NAME);

  if (region.isEmpty()) {
    Log.getLogWriter().info("Region is empty as expected");
  }
  else {
    throw new TestException(
        "Region content supposed to be empty but it is having size of "
            + region.size());
  }

}
 
Example 14
Source File: WanSecurity.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether the writer sites are having empty region
 */
public static void checkWriterRegionContentsEmpty() {
  Region region = RegionHelper.getRegion(regionNames.get(0));
  if (region.isEmpty()) {
    Log.getLogWriter().info("Region is empty as expected");
  }
  else {
    throw new TestException(
        "Region content supposed to be empty but it is having size of "
            + region.size());
  }
}
 
Example 15
Source File: WanSecurity.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Reader wan site destroys all the keys in its region
 */
public static void readerDestroyAllKeysTask() {

  Region region = RegionHelper.getRegion(regionNames.get(0));

  Iterator iterator = region.entrySet(false).iterator();
  Region.Entry entry = null;
  Object key = null;

  while (iterator.hasNext()) {
    entry = (Region.Entry)iterator.next();
    key = entry.getKey();

    try {
      region.destroy(key);
    }
    catch (EntryNotFoundException e) {
      Log.getLogWriter().info("Entry Not found for key " + key + ". Expected in this test.");
    }
  }

  if (region.isEmpty()) {
    Log.getLogWriter().info(
        "Completed the destroy operation for all the keys in the region");
  }
  else {
    throw new TestException(
        "Region is supposed to be empty but that is not the case");
  }
}
 
Example 16
Source File: WanSecurity.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Validating Reader Wan Sites
 */
public static void validateReaderWanSiteEntriesTask() {
  Log.getLogWriter().info("Sleeping for some time ..");
  hydra.MasterController.sleepForMs(100000);
  Region region = RegionHelper.getRegion(regionNames.get(0));
  if (region.isEmpty()) {
    throw new TestException(" Region has no entries to validate ");
  }
  long requiredSize = WANBlackboard.getInstance().getSharedCounters().read(
      WANBlackboard.currentEntry_writer);
  checkKeyRegionEntries(region.getName(), "writer_", requiredSize);

  Iterator iterator = region.entrySet(false).iterator();
  Region.Entry entry = null;
  Object key = null;
  Object value = null;
  while (iterator.hasNext()) {
    entry = (Region.Entry)iterator.next();
    key = entry.getKey();
    value = entry.getValue();

    if (((String)key).startsWith("reader_")) {
      if (!keyList.contains(key)) {
        throw new TestException(
            "Found reader key that is not present in the keyList");
      }
      else if (((Integer)value).intValue() != ITERATIONS) {
        String s = "Wrong value in region " + region.getFullPath() + " at " + key + ", expected "
            + ITERATIONS + " but got " + ((Integer)value).intValue();
        throw new TestException(s);
      }
    }
  }
}
 
Example 17
Source File: WanSecurity.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Validating Writer Wan Sites
 */
public static void validateWriterWanSiteEntriesTask() {
  Log.getLogWriter().info("Sleeping for some time ..");
  hydra.MasterController.sleepForMs(100000);
  Region region = RegionHelper.getRegion(regionNames.get(0));
  if (region.isEmpty()) {
    throw new TestException(" Region has no entries to validate ");
  }
  checkKeys(region.getName(), "writer_");
  
  long requiredSize = WANBlackboard.getInstance().getSharedCounters().read(
      WANBlackboard.currentEntry_writer);
  checkKeyRegionEntries(region.getName(), "writer_", requiredSize);
}
 
Example 18
Source File: DurableClientsTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Verify the region entries with the feeder entries
 * 
 */

public static void verifyDataInRegion() {

  // hydra.MasterController.sleepForMs(50000);

  // waitForLastKeyReceivedAtClient();
  checkBlackBoardForException();
  
  int numOfRegion = TestConfig.tab().intAt(
      durableClients.DurableClientsPrms.numberOfRegions, 1);
  for (int i = 0; i < numOfRegion; i++) {
    Region region = getRegion(REGION_NAME + i);
    Log.getLogWriter().info(
        "Validating the keys of the Region " + region.getFullPath() + " ...");
    if (region.isEmpty()) {
      throw new TestException(" Region has no entries to validate ");
    }

    Iterator iterator = region.entrySet(false).iterator();
    Region.Entry entry = null;
    Object key = null;
    Object value = null;
    while (iterator.hasNext()) {
      entry = (Region.Entry)iterator.next();
      key = entry.getKey();
      value = entry.getValue();
      if (value != null) {
        if (DurableClientsBB.getBB().getSharedMap().get(key) != null) {
          if (!DurableClientsBB.getBB().getSharedMap().get(key).equals(value)) {
            throw new TestException(" expected value to be "
                + DurableClientsBB.getBB().getSharedMap().get(key)
                + " for key " + key + " but is " + value);
          }
        }
        else {
          throw new TestException(
              " expected value to be present in the shared map but it is not for key "
                  + key);
        }
      }
      else {
        if (DurableClientsBB.getBB().getSharedMap().get(key) != null) {
          throw new TestException(
              " expected value to be null but it is not so for key " + key);
        }
      }
    }
  }
}
 
Example 19
Source File: HAClientQueue.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static void verifyDataInRegion()
{
  if (TestConfig.tab().booleanAt(hct.ha.HAClientQueuePrms.putLastKey, false)) {
    waitForLastKeyReceivedAtClient();
  }
  Cache cache = CacheFactory.getAnyInstance();
  int numOfRegion = TestConfig.tab().intAt(
      hct.ha.HAClientQueuePrms.numberOfRegions, 1);
  for (int i = 0; i < numOfRegion; i++) {
    Region region = cache.getRegion(Region.SEPARATOR + REGION_NAME + i);
    Log.getLogWriter().info(
        "Validating the keys of the Region " + region.getFullPath() + " ...");
    if (region.isEmpty()){
         throw new TestException(" Region has no entries to validate ");
     }
   
    Iterator iterator = region.entrySet(false).iterator();
    Region.Entry entry = null;
    Object key = null;
    Object value = null;
    while (iterator.hasNext()) {
      entry = (Region.Entry)iterator.next();
      key = entry.getKey();
      value = entry.getValue();
      if (value != null) {
        if (HAClientQueueBB.getBB().getSharedMap().get(key) != null) {
          if (!HAClientQueueBB.getBB().getSharedMap().get(key).equals(value)) {
            throw new TestException(" expected value to be "
                + HAClientQueueBB.getBB().getSharedMap().get(key)
                + " for key " + key + " but is " + value);
          }
        }
        else {
          throw new TestException(
              " expected value to be present in the shared map but it is not for key "
                  + key);
        }
      }
      else {
        if (HAClientQueueBB.getBB().getSharedMap().get(key) != null) {
          throw new TestException(
              " expected value to be null but it is not so for key " + key);
        }
      }
    }
  }
}
 
Example 20
Source File: HAClientQueue.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static void verifyDataInRegion()
{
  if (TestConfig.tab().booleanAt(hct.ha.HAClientQueuePrms.putLastKey, false)) {
    waitForLastKeyReceivedAtClient();
  }
  Cache cache = CacheFactory.getAnyInstance();
  int numOfRegion = TestConfig.tab().intAt(
      hct.ha.HAClientQueuePrms.numberOfRegions, 1);
  for (int i = 0; i < numOfRegion; i++) {
    Region region = cache.getRegion(Region.SEPARATOR + REGION_NAME + i);
    Log.getLogWriter().info(
        "Validating the keys of the Region " + region.getFullPath() + " ...");
    if (region.isEmpty()){
         throw new TestException(" Region has no entries to validate ");
     }
   
    Iterator iterator = region.entrySet(false).iterator();
    Region.Entry entry = null;
    Object key = null;
    Object value = null;
    while (iterator.hasNext()) {
      entry = (Region.Entry)iterator.next();
      key = entry.getKey();
      value = entry.getValue();
      if (value != null) {
        if (HAClientQueueBB.getBB().getSharedMap().get(key) != null) {
          if (!HAClientQueueBB.getBB().getSharedMap().get(key).equals(value)) {
            throw new TestException(" expected value to be "
                + HAClientQueueBB.getBB().getSharedMap().get(key)
                + " for key " + key + " but is " + value);
          }
        }
        else {
          throw new TestException(
              " expected value to be present in the shared map but it is not for key "
                  + key);
        }
      }
      else {
        if (HAClientQueueBB.getBB().getSharedMap().get(key) != null) {
          throw new TestException(
              " expected value to be null but it is not so for key " + key);
        }
      }
    }
  }
}