Search in sources :

Example 71 with QueryObserver

use of org.apache.geode.cache.query.internal.QueryObserver in project geode by apache.

the class IndexTrackingQueryObserverDUnitTest method verifyQueryVerboseData.

private AsyncInvocation verifyQueryVerboseData(VM vm, final int results) {
    SerializableRunnable testQueryVerbose = new SerializableRunnable("Test Query Verbose Data") {

        public void run() {
            // Query VERBOSE has to be true for the test
            assertTrue(DefaultQuery.QUERY_VERBOSE);
            // Get TestHook from observer.
            QueryObserver observer = QueryObserverHolder.getInstance();
            assertTrue(QueryObserverHolder.hasObserver());
            final IndexTrackingTestHook th = (IndexTrackingTestHook) ((IndexTrackingQueryObserver) observer).getTestHook();
            Wait.waitForCriterion(new WaitCriterion() {

                public boolean done() {
                    if (th.getRegionMap() != null) {
                        return th.getRegionMap().getResults() != null;
                    }
                    return false;
                }

                public String description() {
                    return null;
                }
            }, 60 * 1000, 200, true);
            IndexInfo regionMap = th.getRegionMap();
            Collection<Integer> rslts = regionMap.getResults().values();
            int totalResults = 0;
            for (Integer i : rslts) {
                totalResults += i.intValue();
            }
            LogWriterUtils.getLogWriter().fine("Index Info result size is " + totalResults);
            assertEquals(results, totalResults);
        }
    };
    AsyncInvocation asyncInv = vm.invokeAsync(testQueryVerbose);
    return asyncInv;
}
Also used : IndexTrackingQueryObserver(org.apache.geode.cache.query.internal.IndexTrackingQueryObserver) QueryObserver(org.apache.geode.cache.query.internal.QueryObserver) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) IndexInfo(org.apache.geode.cache.query.internal.IndexTrackingQueryObserver.IndexInfo) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation)

Aggregations

QueryObserver (org.apache.geode.cache.query.internal.QueryObserver)71 SelectResults (org.apache.geode.cache.query.SelectResults)55 Test (org.junit.Test)48 Region (org.apache.geode.cache.Region)47 Query (org.apache.geode.cache.query.Query)42 Portfolio (org.apache.geode.cache.query.data.Portfolio)42 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)41 QueryObserverAdapter (org.apache.geode.cache.query.internal.QueryObserverAdapter)38 Index (org.apache.geode.cache.query.Index)31 QueryService (org.apache.geode.cache.query.QueryService)25 LocalRegion (org.apache.geode.internal.cache.LocalRegion)23 Collection (java.util.Collection)17 Cache (org.apache.geode.cache.Cache)13 AttributesFactory (org.apache.geode.cache.AttributesFactory)12 Position (org.apache.geode.cache.query.data.Position)9 Iterator (java.util.Iterator)8 RegionAttributes (org.apache.geode.cache.RegionAttributes)8 Set (java.util.Set)7 Host (org.apache.geode.test.dunit.Host)7 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)7