use of org.apache.geode.LogWriter in project geode by apache.
the class CommandModes method logException.
private void logException(Exception e) {
Cache cache = CacheFactory.getAnyInstance();
LogWriter logger = cache.getLogger();
logger.warning("Error parsing command mode descriptor", e);
}
use of org.apache.geode.LogWriter in project geode by apache.
the class PRQueryDUnitHelper method getCacheSerializableRunnableForIndexCreationCheck.
public CacheSerializableRunnable getCacheSerializableRunnableForIndexCreationCheck(final String name) {
return new CacheSerializableRunnable("PrIndexCreationCheck") {
@Override
public void run2() {
Cache cache1 = getCache();
LogWriter logger = cache1.getLogger();
PartitionedRegion region = (PartitionedRegion) cache1.getRegion(name);
Map indexMap = region.getIndex();
Set indexSet = indexMap.entrySet();
Iterator it = indexSet.iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Index index = (Index) entry.getValue();
logger.info("the partitioned index created on this region " + " " + index);
logger.info("Current number of buckets indexed : " + "" + ((PartitionedIndex) index).getNumberOfIndexedBuckets());
}
JUnit4CacheTestCase.closeCache();
JUnit4DistributedTestCase.disconnectFromDS();
}
};
}
use of org.apache.geode.LogWriter in project geode by apache.
the class PRQueryDUnitHelper method getCacheSerializableRunnableForDuplicatePRIndexCreate.
/**
* This function creates a duplicate index should throw an IndexNameConflictException and if not
* the test should fail.
*/
public CacheSerializableRunnable getCacheSerializableRunnableForDuplicatePRIndexCreate(final String prRegionName, final String indexName, final String indexedExpression, final String fromClause, final String alias) {
SerializableRunnable prIndexCreator = new CacheSerializableRunnable("DuplicatePartitionedIndexCreator") {
@Override
public void run2() {
Cache cache = getCache();
LogWriter logger = cache.getLogger();
QueryService qs = cache.getQueryService();
Region region = cache.getRegion(prRegionName);
try {
if (null != fromClause) {
qs.createIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, fromClause);
throw new RuntimeException("Should throw an exception because " + "the index with name : " + indexName + " should already exists");
} else {
qs.createIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, region.getFullPath() + " " + alias);
throw new RuntimeException("Should throw an exception because " + "the index with name : " + indexName + " should already exists");
}
} catch (IndexExistsException e) {
logger.info("Index Exists Excetpiont righteously throw ", e);
} catch (IndexNameConflictException ex) {
logger.info("Gott the right exception");
} catch (RegionNotFoundException exx) {
// TODO Auto-generated catch block
Assert.fail("Region Not found in this vm ", exx);
}
}
};
return (CacheSerializableRunnable) prIndexCreator;
}
use of org.apache.geode.LogWriter in project geode by apache.
the class PRQueryDUnitHelper method getCacheSerializableRunnableForIndexUsageCheck.
/**
* Insure queries on a pr is using index if not fail.
*/
public CacheSerializableRunnable getCacheSerializableRunnableForIndexUsageCheck() {
SerializableRunnable PrIndexCheck = new CacheSerializableRunnable("PrIndexCheck") {
@Override
public void run2() {
Cache cache = getCache();
QueryService qs = cache.getQueryService();
LogWriter logger = cache.getLogger();
Collection indexes = qs.getIndexes();
Iterator it = indexes.iterator();
while (it.hasNext()) {
PartitionedIndex ind = (PartitionedIndex) it.next();
/*
* List bucketIndex = ind.getBucketIndexes(); int k = 0;
* logger.info("Total number of bucket index : "+bucketIndex.size()); while ( k <
* bucketIndex.size() ){ Index bukInd = (Index)bucketIndex.get(k);
* logger.info("Buket Index "+bukInd+" usage : "+bukInd.getStatistics().getTotalUses());
* // if number of quries on pr change in
* getCacheSerializableRunnableForPRQueryAndCompareResults // literal 6 should change.
* //Asif : With the optmization of Range Queries a where clause // containing something
* like ID > 4 AND ID < 9 will be evaluated //using a single index lookup, so accordingly
* modifying the //assert value from 7 to 6 // Anil : With aquiringReadLock during
* Index.getSizeEstimate(), the // Index usage in case of "ID = 0 OR ID = 1" is increased
* by 3. int indexUsageWithSizeEstimation = 3; int expectedUse = 6; long indexUse =
* bukInd.getStatistics().getTotalUses(); // Anil : With chnages to use single index for
* PR query evaluation, once the index // is identified the same index is used on other PR
* buckets, the sieEstimation is // done only once, which adds additional index use for
* only one bucket index. if (!(indexUse == expectedUse || indexUse == (expectedUse +
* indexUsageWithSizeEstimation))){ fail
* ("Index usage is not as expected, expected it to be either " + expectedUse + " or " +
* (expectedUse + indexUsageWithSizeEstimation) + " it is: " + indexUse);
* //assertIndexDetailsEquals(6 + indexUsageWithSizeEstimation,
* bukInd.getStatistics().getTotalUses()); } k++; }
*/
// Shobhit: Now we dont need to check stats per bucket index,
// stats are accumulated in single pr index stats.
// Anil : With aquiringReadLock during Index.getSizeEstimate(), the
// Index usage in case of "ID = 0 OR ID = 1" is increased by 3.
int indexUsageWithSizeEstimation = 3;
logger.info("index uses for " + ind.getNumberOfIndexedBuckets() + " index " + ind.getName() + ": " + ind.getStatistics().getTotalUses());
assertEquals(6, ind.getStatistics().getTotalUses());
}
}
};
return (CacheSerializableRunnable) PrIndexCheck;
}
use of org.apache.geode.LogWriter in project geode by apache.
the class PRQueryDUnitHelper method getCacheSerializableRunnableForRRIndexCreate.
public CacheSerializableRunnable getCacheSerializableRunnableForRRIndexCreate(final String rrRegionName, final String indexName, final String indexedExpression, final String fromClause, final String alias) {
SerializableRunnable prIndexCreator = new CacheSerializableRunnable("ReplicatedRegionIndexCreator") {
public void run2() {
try {
Cache cache = getCache();
QueryService qs = cache.getQueryService();
Region region = cache.getRegion(rrRegionName);
LogWriter logger = cache.getLogger();
if (null != fromClause) {
logger.info("Test Creating index with Name : [ " + indexName + " ] " + "IndexedExpression : [ " + indexedExpression + " ] Alias : [ " + alias + " ] FromClause : [ " + fromClause + " " + alias + " ] ");
Index parIndex = qs.createIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, fromClause);
logger.info("Index creted on replicated region : " + parIndex);
} else {
logger.info("Test Creating index with Name : [ " + indexName + " ] " + "IndexedExpression : [ " + indexedExpression + " ] Alias : [ " + alias + " ] FromClause : [ " + region.getFullPath() + " " + alias + " ] ");
Index parIndex = qs.createIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, region.getFullPath() + " " + alias);
logger.info("Index creted on replicated region : " + parIndex);
}
} catch (Exception ex) {
Assert.fail("Creating Index in this vm failed : ", ex);
}
}
};
return (CacheSerializableRunnable) prIndexCreator;
}
Aggregations