Search in sources :

Example 61 with LogWriter

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);
}
Also used : LogWriter(org.apache.geode.LogWriter) Cache(org.apache.geode.cache.Cache)

Example 62 with LogWriter

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();
        }
    };
}
Also used : PartitionedIndex(org.apache.geode.cache.query.internal.index.PartitionedIndex) Set(java.util.Set) StructSetOrResultsSet(org.apache.geode.cache.query.functional.StructSetOrResultsSet) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) LogWriter(org.apache.geode.LogWriter) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Iterator(java.util.Iterator) Index(org.apache.geode.cache.query.Index) PartitionedIndex(org.apache.geode.cache.query.internal.index.PartitionedIndex) Map(java.util.Map) Cache(org.apache.geode.cache.Cache)

Example 63 with LogWriter

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;
}
Also used : IndexExistsException(org.apache.geode.cache.query.IndexExistsException) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) LogWriter(org.apache.geode.LogWriter) QueryService(org.apache.geode.cache.query.QueryService) IndexNameConflictException(org.apache.geode.cache.query.IndexNameConflictException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) Cache(org.apache.geode.cache.Cache)

Example 64 with LogWriter

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;
}
Also used : PartitionedIndex(org.apache.geode.cache.query.internal.index.PartitionedIndex) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) QueryService(org.apache.geode.cache.query.QueryService) LogWriter(org.apache.geode.LogWriter) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) Iterator(java.util.Iterator) Collection(java.util.Collection) Cache(org.apache.geode.cache.Cache)

Example 65 with LogWriter

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;
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) QueryService(org.apache.geode.cache.query.QueryService) LogWriter(org.apache.geode.LogWriter) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) Index(org.apache.geode.cache.query.Index) PartitionedIndex(org.apache.geode.cache.query.internal.index.PartitionedIndex) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryExistsException(org.apache.geode.cache.EntryExistsException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) CancelException(org.apache.geode.CancelException) QueryInvalidException(org.apache.geode.cache.query.QueryInvalidException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) FunctionException(org.apache.geode.cache.execute.FunctionException) CacheClosedException(org.apache.geode.cache.CacheClosedException) MultiIndexCreationException(org.apache.geode.cache.query.MultiIndexCreationException) TestException(util.TestException) CacheException(org.apache.geode.cache.CacheException) ReplyException(org.apache.geode.distributed.internal.ReplyException) QueryException(org.apache.geode.cache.query.QueryException) IndexNameConflictException(org.apache.geode.cache.query.IndexNameConflictException) IndexExistsException(org.apache.geode.cache.query.IndexExistsException) Cache(org.apache.geode.cache.Cache)

Aggregations

LogWriter (org.apache.geode.LogWriter)87 Test (org.junit.Test)34 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)18 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)17 Host (org.apache.geode.test.dunit.Host)17 Region (org.apache.geode.cache.Region)15 DistributedSystem (org.apache.geode.distributed.DistributedSystem)15 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)15 VM (org.apache.geode.test.dunit.VM)13 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)12 Iterator (java.util.Iterator)11 Set (java.util.Set)11 Cache (org.apache.geode.cache.Cache)11 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)11 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)10 LocalRegion (org.apache.geode.internal.cache.LocalRegion)9 Properties (java.util.Properties)8 InternalLogWriter (org.apache.geode.internal.logging.InternalLogWriter)8 IOException (java.io.IOException)7 HashSet (java.util.HashSet)7