Search in sources :

Example 26 with PortfolioData

use of org.apache.geode.cache.query.data.PortfolioData in project geode by apache.

the class PRBasicIndexCreationDUnitTest method testCreateIndexAndAddAnAccessor.

/**
   * Test for bug fix 37985, NullPointerException in IndexCreationMsg operateOnPartitionedRegion.
   * This bug show up when an accessor (PR with max memory = 0) vm joins the PR system when there
   * are index on the PR and an index creation message is sent to this accessor VM.
   */
@Test
public void testCreateIndexAndAddAnAccessor() 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);
    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 index from a data store.
    vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnStatus", "p.status", null, "p"));
    // create an accessor vm.
    vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRAccessorCreate(name, redundancy, PortfolioData.class));
}
Also used : VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) PortfolioData(org.apache.geode.cache.query.data.PortfolioData) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 27 with PortfolioData

use of org.apache.geode.cache.query.data.PortfolioData in project geode by apache.

the class PRBasicIndexCreationDUnitTest method testPRBasicIndexCreate.

/**
   * Tests basic index creation on a partitioned system.
   * 
   * @throws Exception if an exception is generated
   */
@Test
public void testPRBasicIndexCreate() 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.testPRBasicIndexCreate started ....");
    vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRAccessorCreate(name, redundancy, PortfolioData.class));
    // Creating the Datastores Nodes in the VM1.
    LogWriterUtils.getLogWriter().info("PRBasicIndexCreationDUnitTest : creating all the prs ");
    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));
    vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnStatus", "p.status", null, "p"));
    // creating a duplicate index, should throw a IndexExistsException and if not
    // will throw a RuntimeException.
    vm1.invoke(PRQHelp.getCacheSerializableRunnableForDuplicatePRIndexCreate(name, "PrIndexOnStatus", "p.status", null, "p"));
    vm2.invoke(PRQHelp.getCacheSerializableRunnableForDuplicatePRIndexCreate(name, "PrIndexOnStatus", "p.status", null, "p"));
    vm3.invoke(PRQHelp.getCacheSerializableRunnableForDuplicatePRIndexCreate(name, "PrIndexOnStatus", "p.status", null, "p"));
    LogWriterUtils.getLogWriter().info("PRBasicIndexCreationDUnitTest.testPRBasicIndexCreate is done ");
}
Also used : VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) PortfolioData(org.apache.geode.cache.query.data.PortfolioData) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 28 with PortfolioData

use of org.apache.geode.cache.query.data.PortfolioData in project geode by apache.

the class PRBasicIndexCreationDUnitTest method testCreatePartitionedIndexWithKeysValuesAndFunction.

/**
   * Creats partitioned index on keys and values of a bucket regions.
   */
@Test
public void testCreatePartitionedIndexWithKeysValuesAndFunction() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    setCacheInVMs(vm0, vm1);
    final String fileName = "PRIndexCreation.xml";
    LogWriterUtils.getLogWriter().info("PRBasicIndexCreation.testCreatePartitionedIndexThroughXML started");
    LogWriterUtils.getLogWriter().info("Starting and initializing partitioned regions and indexes using xml");
    LogWriterUtils.getLogWriter().info("Starting a pr asynchronously using an xml file name : " + fileName);
    vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
    final PortfolioData[] portfolio = createPortfolioData(cnt, cntDest);
    vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, PortfolioData.class));
    vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfolio, cnt, cntDest));
    vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "index8", "k", "/PartionedPortfolios.keys k", ""));
    vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "index7", "nvl(k.status.toString(),'nopes')", "/PartionedPortfolios.values k", ""));
    vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfolio, cnt, cntDest));
    LogWriterUtils.getLogWriter().info("PRBasicIndexCreation.testCreatePartitionedIndexThroughXML is done  ");
}
Also used : VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) PortfolioData(org.apache.geode.cache.query.data.PortfolioData) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 29 with PortfolioData

use of org.apache.geode.cache.query.data.PortfolioData in project geode by apache.

the class PRBasicIndexCreationDUnitTest method testPRMultiIndexCreation.

/**
   * Tests creation of multiple index creation on a partitioned region system.
   * 
   * @throws Exception if any excpetion are generated
   */
@Test
public void testPRMultiIndexCreation() 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.
    vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnStatus", "p.status", null, "p"));
    // creating a duplicate index should throw a IndexExistsException and if not
    // will throw a RuntimeException.
    vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRIndexCreate(name, "PrIndexOnID", "p.ID", null, "p"));
    LogWriterUtils.getLogWriter().info("PRQBasicIndexCreationTest.testPRMultiIndexCreation ENDED");
}
Also used : VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) PortfolioData(org.apache.geode.cache.query.data.PortfolioData) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 30 with PortfolioData

use of org.apache.geode.cache.query.data.PortfolioData in project geode by apache.

the class PRBasicIndexCreationDUnitTest method testPartitionedQueryWithIndexOnIdBug37089.

/**
   * Test for bug 37089 where if there is an index on one attribute (CompiledComparision) of the
   * where clause query produces wrong results.
   */
@Test
public void testPartitionedQueryWithIndexOnIdBug37089() 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.testPartitionedQueryWithIndexOnIdBug37089 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
    LogWriterUtils.getLogWriter().info("PRBasicIndexCreationDUnitTest.testPartitionedQueryWithIndexOnIdBug37089 done ");
}
Also used : VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) PortfolioData(org.apache.geode.cache.query.data.PortfolioData) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

PortfolioData (org.apache.geode.cache.query.data.PortfolioData)57 Test (org.junit.Test)57 Host (org.apache.geode.test.dunit.Host)52 VM (org.apache.geode.test.dunit.VM)52 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)52 Cache (org.apache.geode.cache.Cache)18 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)18 Region (org.apache.geode.cache.Region)17 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)17 CacheException (org.apache.geode.cache.CacheException)16 SelectResults (org.apache.geode.cache.query.SelectResults)14 Index (org.apache.geode.cache.query.Index)13 Query (org.apache.geode.cache.query.Query)12 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)12 ArrayList (java.util.ArrayList)11 AttributesFactory (org.apache.geode.cache.AttributesFactory)11 RegionFactory (org.apache.geode.cache.RegionFactory)11 LinkedList (java.util.LinkedList)9 List (java.util.List)9 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)9