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

The following examples show how to use com.gemstone.gemfire.cache.Region#getAttributes() . 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: DefaultPartitionTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void testDefaultPartitionWhenMultFKExists() throws SQLException,
    StandardException {
  Connection conn = getConnection();
  Statement s = conn.createStatement();
  s.execute("create schema EMP");
  Cache cache = CacheFactory.getAnyInstance();
  s.execute("create table EMP.PARTITIONTESTTABLE (ID int not null, "
      + " SECONDID int not null, THIRDID int not null, primary key (ID))");
  s
      .execute("create table EMP.PARTITIONTESTTABLE_2nd (ID_2 int not null, "
          + " SECONDID_2 int not null, THIRDID_2 int not null, primary key (SECONDID_2))");
  s
      .execute("create table EMP.PARTITIONTESTTABLE_FK (ID_FK int not null, "
          + " SECONDID_FK int not null, THIRDID_FK int not null, "
          + "foreign key (SECONDID_FK) references EMP.PARTITIONTESTTABLE_2nd(SECONDID_2),"
          + "foreign key (ID_FK) references EMP.PARTITIONTESTTABLE(ID))");
  Region regtwo = cache.getRegion("/EMP/PARTITIONTESTTABLE_FK");
  RegionAttributes rattr = regtwo.getAttributes();
  PartitionResolver pr = rattr.getPartitionAttributes()
      .getPartitionResolver();
  assertNotNull(pr);
  GfxdPartitionByExpressionResolver scpr = (GfxdPartitionByExpressionResolver)pr;
  assert(scpr.isDefaultPartitioning());
  assertEquals(1, scpr.getColumnNames().length);
  assertEquals("SECONDID_FK", scpr.getColumnNames()[0]);
}
 
Example 2
Source File: ParRegColocation.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Hydra task to verify bucket copies. This must be called repeatedly by the
 * same thread until StopSchedulingTaskOnClientOrder is thrown.
 */
public void verifyBucketCopies(Region aRegion) {
  try {
    RegionAttributes attr = aRegion.getAttributes();
    PartitionAttributes prAttr = attr.getPartitionAttributes();
    int redundantCopies = 0;
    if (prAttr != null) {
      redundantCopies = prAttr.getRedundantCopies();
    }
    // the following call throws StopSchedulingTaskOnClientOrder when
    // completed
    ParRegUtil.verifyBucketCopies(aRegion, redundantCopies);
  }
  catch (TestException e) {
    ParRegUtil.dumpAllDataStores(aRegion);
    throw new TestException(TestHelper.getStackTrace(e));
  }
}
 
Example 3
Source File: RebalanceUtil.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/** Hydra task to verify bucket copies. This must be called repeatedly
 *  by the same thread until StopSchedulingTaskOnClientOrder is thrown.
 */
public static void HydraTask_verifyBucketCopiesBatched() {
   Cache myCache = CacheHelper.getCache();
   Set<Region<?,?>> rootRegions = myCache.rootRegions();
   for (Region aRegion : rootRegions) {
      if (aRegion instanceof PartitionedRegion) {
         try {
            RegionAttributes attr = aRegion.getAttributes();
            PartitionAttributes prAttr = attr.getPartitionAttributes();
            int redundantCopies = 0;
            if (prAttr != null) { 
               redundantCopies = prAttr.getRedundantCopies();
            }
            // the following call throws StopSchedulingTaskOnClientOrder when completed
            parRegUtilInstance.verifyBucketCopiesBatched(aRegion, redundantCopies);
         } catch (TestException e) {
            // shutdownHook will cause all members to dump partitioned region info
            throw new TestException(TestHelper.getStackTrace(e));
         }
      }
   }
}
 
Example 4
Source File: CacheXml65Test.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void testPARTITION_REDUNDANT_OVERFLOW() throws CacheException {
  CacheCreation cache = new CacheCreation();
  RegionCreation root = (RegionCreation)
    cache.createRegion("rpartitionoverflow", "PARTITION_REDUNDANT_OVERFLOW");
  testXml(cache);
  GemFireCacheImpl c = (GemFireCacheImpl) getCache();
  Region r = c.getRegion("rpartitionoverflow");
  assertNotNull(r);
  RegionAttributes ra = r.getAttributes();
  assertEquals(DataPolicy.PARTITION, ra.getDataPolicy());
  assertNotNull(ra.getPartitionAttributes());
  assertEquals(1, ra.getPartitionAttributes().getRedundantCopies());
  assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes());
  assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE,
               c.getResourceManager().getEvictionHeapPercentage());
}
 
Example 5
Source File: DefaultPartitionTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void testDefaultPartitionWhenMultFKExists() throws SQLException,
    StandardException {
  Connection conn = getConnection();
  Statement s = conn.createStatement();
  s.execute("create schema EMP");
  Cache cache = CacheFactory.getAnyInstance();
  s.execute("create table EMP.PARTITIONTESTTABLE (ID int not null, "
      + " SECONDID int not null, THIRDID int not null, primary key (ID))");
  s
      .execute("create table EMP.PARTITIONTESTTABLE_2nd (ID_2 int not null, "
          + " SECONDID_2 int not null, THIRDID_2 int not null, primary key (SECONDID_2))");
  s
      .execute("create table EMP.PARTITIONTESTTABLE_FK (ID_FK int not null, "
          + " SECONDID_FK int not null, THIRDID_FK int not null, "
          + "foreign key (SECONDID_FK) references EMP.PARTITIONTESTTABLE_2nd(SECONDID_2),"
          + "foreign key (ID_FK) references EMP.PARTITIONTESTTABLE(ID))");
  Region regtwo = cache.getRegion("/EMP/PARTITIONTESTTABLE_FK");
  RegionAttributes rattr = regtwo.getAttributes();
  PartitionResolver pr = rattr.getPartitionAttributes()
      .getPartitionResolver();
  assertNotNull(pr);
  GfxdPartitionByExpressionResolver scpr = (GfxdPartitionByExpressionResolver)pr;
  assert(scpr.isDefaultPartitioning());
  assertEquals(1, scpr.getColumnNames().length);
  assertEquals("SECONDID_FK", scpr.getColumnNames()[0]);
}
 
Example 6
Source File: ParRegColocation.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Task that checks the primaries for the region
 * 
 * @param aRegion
 *                Region whose primaries has to be checked
 */
public static void verifyPrimaries(Region aRegion) {
  try {
    RegionAttributes attr = aRegion.getAttributes();
    PartitionAttributes prAttr = attr.getPartitionAttributes();
    int redundantCopies = 0;
    if (prAttr != null) {
      redundantCopies = prAttr.getRedundantCopies();
    }
    if (highAvailability) { // with HA, wait for things to settle down
      ParRegUtil.verifyPrimariesWithWait(aRegion, redundantCopies);
    }
    else {
      ParRegUtil.verifyPrimaries(aRegion, redundantCopies);
    }
  }
  catch (Exception e) {
    ParRegUtil.dumpAllDataStores(aRegion);
    throw new TestException(TestHelper.getStackTrace(e));
  }

}
 
Example 7
Source File: HDFSIntegrationUtil.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private static String getLeaderRegionPath(String regionPath,
    RegionAttributes regionAttributes, Cache cache) {
  String colocated;
  while(regionAttributes.getPartitionAttributes() != null 
      && (colocated = regionAttributes.getPartitionAttributes().getColocatedWith()) != null) {
    // Do not waitOnInitialization() for PR
    GemFireCacheImpl gfc = (GemFireCacheImpl)cache;
    Region colocatedRegion = gfc.getPartitionedRegion(colocated, false);
    if(colocatedRegion == null) {
      Assert.fail("Could not find parent region " + colocated + " for " + regionPath);
    }
    regionAttributes = colocatedRegion.getAttributes();
    regionPath = colocatedRegion.getFullPath();
  }
  return regionPath;
}
 
Example 8
Source File: ParRegUtil.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/** Verify containsValueForKey for the given region and key.
 *
 * @param aRegion The region to verify.
 * @param key The key in aRegion to verify.
 * @param expected The expected value of containsKey()
 *
 * @throws TestException if containsValueforKey() has the wrong value
 */
public static void verifyContainsValueForKey(Region aRegion, Object key, boolean expected) {
   boolean containsValueForKey = aRegion.containsValueForKey(key);
   if (containsValueForKey != expected) {
      RegionAttributes attr = aRegion.getAttributes();
      throw new TestException("Expected containsValueForKey() for " + key + " to be " + expected + 
                " in " + aRegion.getFullPath() + ", but it is " + containsValueForKey);
   }
}
 
Example 9
Source File: NewDeclarativeIndexCreationTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void test002SynchronousIndexCreatedOnRootRegion() {
  Region root = cache.getRegion("/root");
  IndexManager im = IndexUtils.getIndexManager(root, true);
  Collection coll = im.getIndexes();
  if (coll.size() > 0) {
    Assert.assertTrue(true);
    System.out.println("List of indexes= " + im.toString());
    RegionAttributes ra = root.getAttributes();
    Assert.assertTrue(ra.getIndexMaintenanceSynchronous());
  } else
    Assert
        .fail("NewDeclarativeIndexCreationTest::testAsynchronousIndexCreatedOnRoot_PortfoliosRegion:No index found in the root region");
}
 
Example 10
Source File: LRUEvictionControllerTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that a single set of eviction attributes can be used multiple times
 * (and does the right thing).
 */
public void testMultipleUsesOfEvictionAttributes()
  throws CacheException, CloneNotSupportedException {

  int threshold = 42;

  final String name = this.getUniqueName();
  AttributesFactory factory = new AttributesFactory();
  factory.setScope(Scope.LOCAL);
  factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(threshold));
  Region region =
    createRegion(name, factory.create());

  RegionAttributes ra = region.getAttributes();
  Region r2 = createRegion(name + 2, ra);
  
  factory = new AttributesFactory(ra);
  Region r3 = createRegion(name + 3, factory.create());
  
  assertEquals(region.getAttributes().getEvictionAttributes(), r2.getAttributes().getEvictionAttributes());
  assertEquals(r2.getAttributes().getEvictionAttributes(), r3.getAttributes().getEvictionAttributes());
  {
    LocalRegion lRegion = (LocalRegion) region;
    LocalRegion lr2  = (LocalRegion) r2;
    LocalRegion lr3  = (LocalRegion) r3;
    assertNotSame(lRegion.getEvictionController(), lr2.getEvictionController());
    assertEquals(lRegion.getEvictionController(), lr2.getEvictionController());
    assertNotSame(lr2.getEvictionController(), lr3.getEvictionController());
    assertEquals(lr2.getEvictionController(), lr3.getEvictionController());
  }
}
 
Example 11
Source File: CreateTableTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void testCreateTable1() throws SQLException, StandardException {
// Create a schema
Connection conn = getConnection();
Statement s = conn.createStatement();
s.execute("create schema EMP");

// Get the cache;
Cache cache = CacheFactory.getAnyInstance();

// Check for PARTITION BY COLUMN
s.execute("create table EMP.PARTITIONTESTTABLE (ID int not null, "
+ " SECONDID int not null, THIRDID int not null, primary key (SECONDID))"
+ " PARTITION BY COLUMN (ID)");

Region regtwo = cache.getRegion("/EMP/PARTITIONTESTTABLE");

RegionAttributes rattr = regtwo.getAttributes();
PartitionResolver pr = rattr.getPartitionAttributes()
.getPartitionResolver();

assertNotNull(pr);

GfxdPartitionByExpressionResolver scpr = (GfxdPartitionByExpressionResolver)pr;

assertNotNull(scpr);

assertFalse(scpr.columnsSubsetOfPrimary());

assertEquals(1, scpr.getColumnNames().length);

assertEquals("ID", scpr.getColumnNames()[0]);
}
 
Example 12
Source File: CacheXml65Test.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void testPARTITION_REDUNDANT_PERSISTENT() throws CacheException {
  CacheCreation cache = new CacheCreation();
  RegionCreation root = (RegionCreation)
    cache.createRegion("prpartition", "PARTITION_REDUNDANT_PERSISTENT");
  testXml(cache);
  GemFireCacheImpl c = (GemFireCacheImpl) getCache();
  Region r = c.getRegion("prpartition");
  assertNotNull(r);
  RegionAttributes ra = r.getAttributes();
  assertEquals(DataPolicy.PERSISTENT_PARTITION, ra.getDataPolicy());
  assertNotNull(ra.getPartitionAttributes());
  assertEquals(1, ra.getPartitionAttributes().getRedundantCopies());
}
 
Example 13
Source File: RangePartitionResolverAllTypesTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void testRanges() throws SQLException, StandardException, IOException {
  Connection conn = getConnection();
  Statement s = conn.createStatement();
  s.execute("create schema EMP");

  Cache cache = CacheFactory.getAnyInstance();
  for (int i = 0; i < Set1_CreateTableStmntDiffDataType.length; i++) {
    System.out.println("Region Name = " + Region_Names[i]);
    s.execute(Set1_CreateTableStmntDiffDataType[i]);
    Region regtwo = cache.getRegion(Region_Names[i]);
    RegionAttributes rattr = regtwo.getAttributes();
    PartitionResolver pr = rattr.getPartitionAttributes()
        .getPartitionResolver();
    GfxdRangePartitionResolver rpr = (GfxdRangePartitionResolver)pr;

    Object[] eachTypeArray = (Object[])Set1_params[i];
    for (int eachCase = 0; eachCase < eachTypeArray.length; eachCase++) {
      Object[] params = (Object[])eachTypeArray[eachCase];
      Object[] routingObjects = rpr.getRoutingObjectsForRange((DataValueDescriptor)params[0],
          ((Boolean)params[1]).booleanValue(), (DataValueDescriptor)params[2],
          ((Boolean)params[3]).booleanValue());
      Integer[] verifyRoutingObjects = (Integer[])params[4];
      if (verifyRoutingObjects == null) {
        assertNull(routingObjects);
      }
      else {
        assertEquals(verifyRoutingObjects.length, routingObjects.length);
        for (int v = 0; v < verifyRoutingObjects.length; v++) {
          assertEquals(verifyRoutingObjects[v], routingObjects[v]);
        }
      }
    }

  }
  s.close();
  conn.close();
}
 
Example 14
Source File: NewDeclarativeIndexCreationTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void test000AsynchronousIndexCreatedOnRoot_PortfoliosRegion() {
  Region root = cache.getRegion("/root/portfolios");
  IndexManager im = IndexUtils.getIndexManager(root, true);
  Collection coll = im.getIndexes();
  if (coll.size() > 0) {
    Assert.assertTrue(true);
    System.out.println("List of indexes= " + im.toString());
    RegionAttributes ra = root.getAttributes();
    Assert.assertTrue(!ra.getIndexMaintenanceSynchronous());
  } else
    Assert
        .fail("NewDeclarativeIndexCreationTest::testAsynchronousIndexCreatedOnRoot_PortfoliosRegion:No index found in the root region");
}
 
Example 15
Source File: CacheXml65Test.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void testREPLICATE_OVERFLOW() throws CacheException {
  CacheCreation cache = new CacheCreation();
  RegionCreation root = (RegionCreation)
    cache.createRegion("replicateoverflow", "REPLICATE_OVERFLOW");
  testXml(cache);
  GemFireCacheImpl c = (GemFireCacheImpl) getCache();
  Region r = c.getRegion("replicateoverflow");
  assertNotNull(r);
  RegionAttributes ra = r.getAttributes();
  assertEquals(DataPolicy.REPLICATE, ra.getDataPolicy());
  assertEquals(Scope.DISTRIBUTED_ACK, ra.getScope());
  assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes());
  assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE,
               c.getResourceManager().getEvictionHeapPercentage());
}
 
Example 16
Source File: Bug40255JUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void testResolveReplacePropertyStringForLonerCache(){
  Properties props = new Properties();
  props.setProperty("mcast-port", "0");
  props.setProperty("locators", "");
  System.setProperty("gemfirePropertyFile", BUG_40255_PROPS);
  props.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, BUG_40255_XML);
  System.setProperty(NESTED_ATTR_PROPERTY_STRING, NESTED_ATTR_PROPERTY_VALUE);
  System.setProperty(ATTR_PROPERTY_STRING, ATTR_PROPERTY_VALUE);
  System.setProperty(ELEMENT_PROPERTY_STRING, ELEMENT_PROPERTY_VALUE);
  System.setProperty(CONCAT_ELEMENT_PROPERTY_STRING, CONCAT_ELEMENT_PROPERTY_VALUE);
  
  // create the directory where data is going to be stored
  File dir = new File("persistData1");
  dir.mkdir();

  this.ds = DistributedSystem.connect(props);
  this.cache = CacheFactory.create(this.ds);

  Region exampleRegion = this.cache.getRegion("example-region");
  RegionAttributes<Object, Object> attrs = exampleRegion.getAttributes();

  //Check if disk store got same name as passed in system properties in setup().
  assertEquals(attrs.getDiskStoreName(), System.getProperty(ATTR_PROPERTY_STRING));
  assertNotNull(exampleRegion.get(ELEMENT_PROPERTY_VALUE+CONCAT_ELEMENT_PROPERTY_VALUE));
  assertEquals(exampleRegion.get(ELEMENT_PROPERTY_VALUE+CONCAT_ELEMENT_PROPERTY_VALUE), ELEMENT_KEY_VALUE);
  assertNotNull(exampleRegion.get(ELEMENT_PROPERTY_VALUE));
  assertEquals(exampleRegion.get(ELEMENT_PROPERTY_VALUE), CONCAT_ELEMENT_PROPERTY_VALUE);
}
 
Example 17
Source File: CacheXml58Test.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Tests that a region created with a named attributes set programmatically
 * for partition-resolver has the correct attributes.
 * 
 */
public void testPartitionedRegionAttributesForCustomPartitioning() throws CacheException
{
  CacheCreation cache = new CacheCreation();
  RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
  
  MonthPartitionResolver partitionResolver = new MonthPartitionResolver();
  Properties params = new Properties();
  params.setProperty("initial-index-value", "1000");
  params.setProperty("secondary-index-value", "5000");
  partitionResolver.init(params);
  
  PartitionAttributesFactory paf = new PartitionAttributesFactory();
  paf.setRedundantCopies(1);
  paf.setTotalMaxMemory(500);
  paf.setLocalMaxMemory(100);
  paf.setPartitionResolver(partitionResolver);
  
  attrs.setPartitionAttributes(paf.create());
  
  cache.createRegion("parRoot", attrs);
  
  Region r = cache.getRegion("parRoot");
  assertEquals(r.getAttributes().getPartitionAttributes().getRedundantCopies(),1);
  assertEquals(r.getAttributes().getPartitionAttributes().getLocalMaxMemory(),100);
  assertEquals(r.getAttributes().getPartitionAttributes().getTotalMaxMemory(),500);
  assertEquals(r.getAttributes().getPartitionAttributes().getPartitionResolver(),partitionResolver);
  
  testXml(cache);
  
  Cache c = getCache();
  assertNotNull(c);

  Region region = c.getRegion("parRoot");
  assertNotNull(region);

  RegionAttributes regionAttrs = region.getAttributes();
  PartitionAttributes pa = regionAttrs.getPartitionAttributes();

  assertEquals(pa.getRedundantCopies(), 1);
  assertEquals(pa.getLocalMaxMemory(), 100);
  assertEquals(pa.getTotalMaxMemory(), 500);
  assertNotNull(pa.getPartitionResolver().getClass());
  assertEquals(pa.getPartitionResolver(), partitionResolver);
}
 
Example 18
Source File: SerialCompressionTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 *
 */
private void compressionStats() {
  StringBuilder errorString = new StringBuilder();
  String regionName;
  Compressor compressor;
  CachePerfStats regionPerfStats;
  DataPolicy dataPolicy;
  long totalPreCompressedBytes;
  long totalCompressionTime;
  long totalCompressions;
  long totalPostCompressedBytes;
  long totalDecompressionTime;
  long totalDecompressions;
  for (Region aRegion : theRegions) {
    regionName = aRegion.getName();
    Log.getLogWriter().info("MDP-S-SerialCompressionTest.stats regionName = " + regionName);

    RegionAttributes attributes = aRegion.getAttributes();
    compressor = attributes.getCompressor();
    Log.getLogWriter().info("MDP-S-  Compressor=" + (compressor == null ? null : compressor.getClass().getName()));

    regionPerfStats = ((LocalRegion) aRegion).getRegionPerfStats();
    if (regionPerfStats == null) {
      continue;
    }
    totalPreCompressedBytes = regionPerfStats.getTotalPreCompressedBytes();
    totalCompressionTime = regionPerfStats.getTotalCompressionTime();
    totalCompressions = regionPerfStats.getTotalCompressions();
    totalPostCompressedBytes = regionPerfStats.getTotalPostCompressedBytes();
    totalDecompressionTime = regionPerfStats.getTotalDecompressionTime();
    totalDecompressions = regionPerfStats.getTotalDecompressions();
    Log.getLogWriter().info("\n        totalPreCompressedBytes   = " + totalPreCompressedBytes +
                            "\n        totalCompressionTime   = " + totalCompressionTime/1000000000d + " (sec)" +
                            "\nMDP-S-  totalCompressions      = " + totalCompressions +
                            "\n        totalPostCompressedBytes = " + totalPostCompressedBytes +
                            "\n        totalDecompressionTime = " + totalDecompressionTime/1000000000d + " (sec)" +
                            "\n        totalDecompressions    = " + totalDecompressions);

    dataPolicy = attributes.getDataPolicy();
    Log.getLogWriter().info("MDP-S-SerialCompressionTest.stats dataPolicy=" + dataPolicy);
    if (dataPolicy.equals(DataPolicy.EMPTY) || compressor == null) {
      if (totalCompressions != 0) {
        errorString.append("The total number of compressions for the region '" + regionName + "' should be zero.\n");
      }
      if (totalPreCompressedBytes != 0) {
        errorString.append("The total number of pre-compressed bytes for the region '" + regionName + "' should be zero.\n");
      }
      if (totalCompressionTime != 0) {
        errorString.append("The total compression time for the region '" + regionName + "' should be zero.\n");
      }
      if (totalDecompressions != 0) {
        errorString.append("The total number of decompressions for the region '" + regionName + "' should be zero.\n");
      }
      if (totalPostCompressedBytes != 0) {
        errorString.append("The total number of post-decompressed bytes for the region '" + regionName + "' should be zero.\n");
      }
      if (totalDecompressionTime != 0) {
        errorString.append("The total decompression time for the region '" + regionName + "' should be zero.\n");
      }
    } else {
      if (totalCompressions <= 0) {
        errorString.append("The total number of compressions for the region '" + regionName + "' should be greater than zero.\n");
      }
      if (totalPreCompressedBytes <= 0) {
        errorString.append("The total number of pre-compressed bytes for the region '" + regionName + "' should be greater than zero.\n");
      }
      if (totalCompressionTime <= 0) {
        errorString.append("The total compression time for the region '" + regionName + "' should be greater than zero.\n");
      }
      if (totalDecompressions <= 0) {
        errorString.append("The total number of decompressions for the region '" + regionName + "' should be greater than zero.\n");
      }
      if (totalPostCompressedBytes <= 0) {
        errorString.append("The total number of post-decompressed bytes for the region '" + regionName + "' should be greater than zero.\n");
      }
      if (totalDecompressionTime <= 0) {
        errorString.append("The total decompression time for the region '" + regionName + "' should be greater than zero.\n");
      }
    }
  }
  if (errorString.length() > 0) {
    throw new TestException("MDP9-Fail! There is a problem with the compression statistics.\n" + errorString.toString());
  }
}
 
Example 19
Source File: CreateTableTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void testCreateTable3() throws SQLException, StandardException {
  Connection conn = getConnection();
  Statement s = conn.createStatement();
  s.execute("create schema EMP");
  Cache cache = CacheFactory.getAnyInstance();
  boolean gotException = false;
  try {
    s.execute("create table EMP.PARTITIONTESTTABLE_ZERO (ID int not null, "
        + " DESCRIPTION varchar(1024) not null)"
        + "PARTITION BY LIST ( ID ) ( VALUES (10, 20 ),"
        + " VALUES (50, 60), VALUES (12, 34, 10, 45))");
  } catch (SQLException ex) {
    gotException = true;
  }
  assertTrue(gotException);
  s.execute("create table EMP.PARTITIONTESTTABLE_ZERO (ID int not null, "
      + " DESCRIPTION varchar(1024) not null)"
      + "PARTITION BY LIST ( ID ) ( VALUES (10, 20 ),"
      + " VALUES (50, 60), VALUES (12, 34, 45))");
  Region regtwo = cache.getRegion("/EMP/PARTITIONTESTTABLE_ZERO");

  RegionAttributes rattr = regtwo.getAttributes();
  PartitionResolver pr = rattr.getPartitionAttributes()
      .getPartitionResolver();
  assertNotNull(pr);

  GfxdListPartitionResolver slpr = (GfxdListPartitionResolver)pr;
  assertNotNull(slpr);

  DataValueDescriptor lowerBound = new SQLInteger(50);
  DataValueDescriptor upperBound = new SQLInteger(50);
  boolean lowerBoundInclusive = false, upperBoundInclusive = false;

  Object[] routingObjects = slpr.getRoutingObjectsForRange(lowerBound,
      lowerBoundInclusive, upperBound, upperBoundInclusive);
  assertNull(routingObjects);

  lowerBoundInclusive = true;
  routingObjects = slpr.getRoutingObjectsForRange(lowerBound,
      lowerBoundInclusive, upperBound, upperBoundInclusive);
  assertNull(routingObjects);

  upperBoundInclusive = true;
  routingObjects = slpr.getRoutingObjectsForRange(lowerBound,
      lowerBoundInclusive, upperBound, upperBoundInclusive);
  assertEquals(1, routingObjects.length);
  assertEquals(1, ((Integer)routingObjects[0]).intValue());
}
 
Example 20
Source File: CreateTableTest.java    From gemfirexd-oss with Apache License 2.0 3 votes vote down vote up
public void testCreateTable12() throws SQLException, StandardException {
// Create a schema
Connection conn = getConnection();
Statement s = conn.createStatement();
s.execute("create schema EMP");

// Get the cache;
Cache cache = CacheFactory.getAnyInstance();

// Check for PARTITION BY COLUMN
s.execute("create table EMP.PARTITIONTESTTABLE (ID int not null, "
+ " SECONDID int not null, THIRDID int not null, primary key (SECONDID))"
+ " PARTITION BY COLUMN (ID, SECONDID)");

Region regtwo = cache.getRegion("/EMP/PARTITIONTESTTABLE");

RegionAttributes rattr = regtwo.getAttributes();
PartitionResolver pr = rattr.getPartitionAttributes()
.getPartitionResolver();

assertNotNull(pr);

GfxdPartitionByExpressionResolver scpr = (GfxdPartitionByExpressionResolver)pr;

assertNotNull(scpr);

assertFalse(scpr.columnsSubsetOfPrimary());

assertEquals(2, scpr.getColumnNames().length);

assertEquals("ID", scpr.getColumnNames()[0]);

assertEquals("SECONDID", scpr.getColumnNames()[1]);
}