use of org.apache.geode.cache.query.data.PortfolioData in project geode by apache.
the class PRBasicIndexCreationDUnitTest method testPRMultiIndexCreationAndGetIndex.
/*
* Tests creation of multiple index creation on a partitioned region system and test
* QueryService.getIndex(Region, indexName) API.
*
* @throws Exception if any exception are generated
*/
@Test
public void testPRMultiIndexCreationAndGetIndex() throws Exception {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
VM vm3 = host.getVM(3);
setCacheInVMs(vm0, vm1, vm2, vm3);
LogWriterUtils.getLogWriter().info("PRBasicIndexCreation.testPRMultiIndexCreation Test Started");
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRAccessorCreate(name, redundancy, PortfolioData.class));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
final PortfolioData[] portfolio = createPortfolioData(cnt, cntDest);
// Putting the data into the PR's created
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfolio, cnt, cntDest));
// should create a sucessful index.
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnStatus", "p.status", null, "p"));
// creating a duplicate index should throw a IndexExistsException and if not
// will throw a RuntimeException.
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnID", "p.ID", null, "p"));
// Check all QueryService.getIndex APIS for a region.
SerializableRunnable getIndexCheck = new CacheSerializableRunnable("Get Index Check") {
@Override
public void run2() throws CacheException {
Cache cache = getCache();
// Check for ID index
Index idIndex = cache.getQueryService().getIndex(cache.getRegion(name), "PrIndexOnID");
assertNotNull(idIndex);
assertEquals("PrIndexOnID", idIndex.getName());
assertEquals("p.ID", idIndex.getIndexedExpression());
assertEquals("/" + name + " p", idIndex.getFromClause());
assertNotNull(idIndex.getStatistics());
// Check for status index
Index statusIndex = cache.getQueryService().getIndex(cache.getRegion(name), "PrIndexOnStatus");
assertNotNull(statusIndex);
assertEquals("PrIndexOnStatus", statusIndex.getName());
assertEquals("p.status", statusIndex.getIndexedExpression());
assertEquals("/" + name + " p", statusIndex.getFromClause());
assertNotNull(statusIndex.getStatistics());
// Check for all Indexes on the region.
Collection<Index> indexes = cache.getQueryService().getIndexes(cache.getRegion(name));
for (Index ind : indexes) {
assertNotNull(ind);
assertNotNull(ind.getName());
assertNotNull(ind.getIndexedExpression());
assertNotNull(ind.getFromClause());
assertNotNull(ind.getStatistics());
}
}
};
// Check getIndex() on accessor
vm0.invoke(getIndexCheck);
// Check getIndex() on datastore
vm1.invoke(getIndexCheck);
LogWriterUtils.getLogWriter().info("PRQBasicIndexCreationTest.testPRMultiIndexCreation ENDED");
}
use of org.apache.geode.cache.query.data.PortfolioData in project geode by apache.
the class PRBasicIndexCreationDUnitTest method testCreatePartitionedIndexWithNoAliasBeforePuts.
/**
* Test to see if index creation works with index creation like in serialQueryEntry.conf hydra
* test before putting the data in the partitioned region.
*/
@Test
public void testCreatePartitionedIndexWithNoAliasBeforePuts() throws Exception {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm3 = host.getVM(3);
setCacheInVMs(vm0, vm1, vm3);
LogWriterUtils.getLogWriter().info("PRBasicIndexCreationDUnitTest.testCreatePartitionedIndexWithNoAliasAfterPuts started ");
// creating all the prs
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnStatus", "status", null, ""));
// putting some data in.
final PortfolioData[] portfolio = createPortfolioData(cnt, cntDest);
// Putting the data into the PR's created
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfolio, cnt, cntDest));
vm0.invoke(PRQHelp.getCacheSerializableRunnableForIndexCreationCheck(name));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForIndexCreationCheck(name));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForIndexCreationCheck(name));
}
use of org.apache.geode.cache.query.data.PortfolioData in project geode by apache.
the class PRBasicIndexCreationDUnitTest method testCreatePartitionedRegionThroughXMLAndAPI.
/**
* Test creation of mutilple index on partitioned regions and then adding a new node to the system
* and checking it has created all the indexes already in the sytem.
*
*/
@Test
public void testCreatePartitionedRegionThroughXMLAndAPI() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
VM vm3 = host.getVM(3);
setCacheInVMs(vm0, vm1, vm2, vm3);
LogWriterUtils.getLogWriter().info("PRBasicIndexCreationDUnitTest.testCreatePartitionedRegionThroughXMLAndAPI started ");
// creating all the prs
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnStatus", "p.status", null, "p"));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnId", "p.ID", null, "p"));
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnPKID", "p.pkid", null, "p"));
// adding a new node to an already existing system.
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
// putting some data in.
final PortfolioData[] portfolio = createPortfolioData(cnt, cntDest);
// Putting the data into the PR's created
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfolio, cnt, cntDest));
vm0.invoke(PRQHelp.getCacheSerializableRunnableForIndexCreationCheck(name));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForIndexCreationCheck(name));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForIndexCreationCheck(name));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForIndexCreationCheck(name));
}
use of org.apache.geode.cache.query.data.PortfolioData in project geode by apache.
the class PRBasicIndexCreationDUnitTest method testPartitionedIndexUsageWithPRQuery.
/**
* Test index usage with query on a partitioned region with bucket indexes.
*/
@Test
public void testPartitionedIndexUsageWithPRQuery() throws Exception {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
VM vm3 = host.getVM(3);
setCacheInVMs(vm0, vm1, vm2, vm3);
LogWriterUtils.getLogWriter().info("PRBasicIndexCreationDUnitTest.testPartitionedIndexUsageWithPRQuery started ");
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnId", "p.ID", null, "p"));
final PortfolioData[] portfolio = createPortfolioData(cnt, cntDest);
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfolio, cnt, cntDest));
vm0.invoke(PRQHelp.getCacheSerializableRunnableForLocalRegionCreation(localName, PortfolioData.class));
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(localName, portfolio, cnt, cntDest));
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRQueryAndCompareResults(name, localName));
// validation on index usage with queries over a pr
vm0.invoke(PRQHelp.getCacheSerializableRunnableForIndexUsageCheck());
vm1.invoke(PRQHelp.getCacheSerializableRunnableForIndexUsageCheck());
vm2.invoke(PRQHelp.getCacheSerializableRunnableForIndexUsageCheck());
vm3.invoke(PRQHelp.getCacheSerializableRunnableForIndexUsageCheck());
LogWriterUtils.getLogWriter().info("PRBasicIndexCreationDUnitTest.testPartitionedIndexUsageWithPRQuery done ");
}
use of org.apache.geode.cache.query.data.PortfolioData in project geode by apache.
the class PRBasicIndexCreationDUnitTest method testCreateIndexFromAccessor.
/**
* Bug Fix 37201, creating index from a data accessor.
*/
@Test
public void testCreateIndexFromAccessor() throws Exception {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
VM vm3 = host.getVM(3);
setCacheInVMs(vm0, vm1, vm2, vm3);
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRAccessorCreate(name, redundancy, PortfolioData.class));
// create more vms to host data.
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
final PortfolioData[] portfolio = createPortfolioData(cnt, cntDest);
// Putting the data into the PR's created
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfolio, cnt, cntDest));
// create the index form asscessor.
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnStatus", "p.status", null, "p"));
}
Aggregations