use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class PRQueryDUnitHelper method getCacheSerializableRunnableForPRRandomOps.
/**
* This function puts portfolio objects into the created Region (PR or RR). Also, other operation
* like, invalidate, destroy and create are performed in random manner based on
* {@link Random#nextInt(int)}.
*
* @param regionName
* @param to
* @param from
* @return cacheSerializable object
*/
public CacheSerializableRunnable getCacheSerializableRunnableForPRRandomOps(final String regionName, final int from, final int to) {
SerializableRunnable prPuts = new CacheSerializableRunnable("PRPuts") {
@Override
public void run2() throws CacheException {
Cache cache = getCache();
Region region = cache.getRegion(regionName);
for (int i = 0; i < 3; i++) {
for (int j = from; j < to; j++) {
int op = new Random().nextInt(4);
try {
switch(op) {
case 0:
// Put operation
region.put(new Integer(j), new Portfolio(j));
break;
case 1:
// invalidate
if (region.containsKey(new Integer(j))) {
region.invalidate(new Integer(j));
}
break;
case 2:
if (region.containsKey(new Integer(j))) {
region.destroy(new Integer(j));
}
break;
case 3:
if (!region.containsKey(new Integer(j))) {
region.create(new Integer(j), null);
}
break;
default:
break;
}
} catch (EntryExistsException e) {
// Do nothing let it go
org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("EntryExistsException was thrown for key " + j);
} catch (EntryNotFoundException e) {
// Do nothing let it go
org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("EntryNotFoundException was thrown for key " + j);
}
}
}
}
};
return (CacheSerializableRunnable) prPuts;
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class PRQueryDUnitTest method testPRDAckCreationAndQueryingWithOrderBy.
/**
* This test does the following using full queries with projections and drill-down<br>
* 1. Creates PR regions on 4 VMs (all datastores) with scope = D_ACK <br>
* 2. Creates a Local region on one of the VM's <br>
* 3. Puts in the same data both in PR region & the Local Region <br>
* 4. Queries the data both in local & PR <br>
* 5. Verfies the size ,type , contents of both the resultSets Obtained
*
* @throws Exception
*/
@Test
public void testPRDAckCreationAndQueryingWithOrderBy() throws Exception {
int dataSize = 10;
int step = 2;
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Querying PR Test with DACK Started*****");
Class valueConstraint = Portfolio.class;
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);
// Creating PR's on the participating VM's
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Creating PR's on VM0, VM1 , VM2 , VM3");
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Successfully Created PR's on VM0, VM1 , VM2 , VM3");
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Creating Local region on VM0 to compare result Sets");
// creating a local region on one of the JVM's
vm0.invoke(PRQHelp.getCacheSerializableRunnableForLocalRegionCreation(localName, valueConstraint));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Successfully Created Local Region on VM0");
// Generating portfolio object array to be populated across the PR's & Local
// Regions
final Portfolio[] portfoliosAndPositions = createPortfoliosAndPositions(totalDataSize);
// Putting the data into the PR's created
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, 0, step));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, step, (2 * step)));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, (2 * step), (3 * step)));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, (3 * (step)), dataSize));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Inserted Portfolio data across PR's");
// Putting the same data in the local region created
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(localName, portfoliosAndPositions, i, dataSize));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Inserted Portfolio data over Local Region on VM0");
// querying the VM for data
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPROrderByQueryAndCompareResults(name, localName));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : *Querying PR's with DACK Test ENDED*****");
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class PRQueryDUnitTest method testPRDAckCreationAndQueryingWithOrderByVerifyOrder.
/**
* This test does the following using full queries with projections and drill-down<br>
* 1. Creates PR regions on 4 VMs (all datastores) with scope = D_ACK <br>
* 2. Creates a Local region on one of the VM's <br>
* 3. Puts in the same data both in PR region & the Local Region <br>
* 4. Queries the data both in local & PR <br>
* 5. Verfies the size ,type , contents of both the resultSets Obtained
*
* @throws Exception
*/
@Test
public void testPRDAckCreationAndQueryingWithOrderByVerifyOrder() throws Exception {
int dataSize = 10;
int step = 2;
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Querying PR Test with DACK Started*****");
Class valueConstraint = Portfolio.class;
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);
// Creating PR's on the participating VM's
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Creating PR's on VM0, VM1 , VM2 , VM3");
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Successfully Created PR's on VM0, VM1 , VM2 , VM3");
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Creating Local region on VM0 to compare result Sets");
// creating a local region on one of the JVM's
vm0.invoke(PRQHelp.getCacheSerializableRunnableForLocalRegionCreation(localName, valueConstraint));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Successfully Created Local Region on VM0");
// Generating portfolio object array to be populated across the PR's & Local
// Regions
final Portfolio[] portfoliosAndPositions = createPortfoliosAndPositions(totalDataSize);
// Putting the data into the PR's created
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, 0, step));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, step, (2 * step)));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, (2 * step), (3 * step)));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, (3 * (step)), dataSize));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Inserted Portfolio data across PR's");
// Putting the same data in the local region created
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(localName, portfoliosAndPositions, i, dataSize));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Inserted Portfolio data over Local Region on VM0");
// querying the VM for data
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPROrderByQueryAndVerifyOrder(name, localName));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : *Querying PR's with DACK Test ENDED*****");
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class PRQueryDUnitTest method testPRDAckCreationAndQueryingFull.
/**
* This test does the following using full queries with projections and drill-down<br>
* 1. Creates PR regions on 4 VMs (all datastores) with scope = D_ACK <br>
* 2. Creates a Local region on one of the VM's <br>
* 3. Puts in the same data both in PR region & the Local Region <br>
* 4. Queries the data both in local & PR <br>
* 5. Verfies the size ,type , contents of both the resultSets Obtained
*
* @throws Exception
*/
@Test
public void testPRDAckCreationAndQueryingFull() throws Exception {
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Querying PR Test with DACK Started*****");
Class valueConstraint = Portfolio.class;
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);
// Creating PR's on the participating VM's
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Creating PR's on VM0, VM1 , VM2 , VM3");
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Successfully Created PR's on VM0, VM1 , VM2 , VM3");
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Creating Local region on VM0 to compare result Sets");
// creating a local region on one of the JVM's
vm0.invoke(PRQHelp.getCacheSerializableRunnableForLocalRegionCreation(localName, valueConstraint));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Successfully Created Local Region on VM0");
// Generating portfolio object array to be populated across the PR's & Local
// Regions
final Portfolio[] portfoliosAndPositions = createPortfoliosAndPositions(totalDataSize);
// Putting the data into the PR's created
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfoliosAndPositions, 0, stepSize));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfoliosAndPositions, stepSize, (2 * stepSize)));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfoliosAndPositions, (2 * stepSize), (3 * stepSize)));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(name, portfoliosAndPositions, (3 * (stepSize)), totalDataSize));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Inserted Portfolio data across PR's");
// Putting the same data in the local region created
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPuts(localName, portfoliosAndPositions, i, totalDataSize));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Inserted Portfolio data over Local Region on VM0");
// querying the VM for data
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRQueryAndCompareResults(name, localName, true));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : *Querying PR's with DACK Test ENDED*****");
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class PRQueryDUnitTest method testPRDAckCreationAndQueryingWithOrderByLimit.
@Test
public void testPRDAckCreationAndQueryingWithOrderByLimit() throws Exception {
int dataSize = 10;
int step = 2;
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Querying PR Test with DACK Started*****");
Class valueConstraint = Portfolio.class;
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);
// Creating PR's on the participating VM's
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Creating PR's on VM0, VM1 , VM2 , VM3");
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRCreate(name, redundancy, valueConstraint));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Successfully Created PR's on VM0, VM1 , VM2 , VM3");
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Creating Local region on VM0 to compare result Sets");
// creating a local region on one of the JVM's
vm0.invoke(PRQHelp.getCacheSerializableRunnableForLocalRegionCreation(localName, valueConstraint));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Successfully Created Local Region on VM0");
// Generating portfolio object array to be populated across the PR's & Local
// Regions
final Portfolio[] portfoliosAndPositions = createPortfoliosAndPositions(totalDataSize);
// Putting the data into the PR's created
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, 0, step));
vm1.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, step, (2 * step)));
vm2.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, (2 * step), (3 * step)));
vm3.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(name, portfoliosAndPositions, (3 * (step)), dataSize));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Inserted Portfolio data across PR's");
// Putting the same data in the local region created
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPRPutsKeyValue(localName, portfoliosAndPositions, i, dataSize));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : Inserted Portfolio data over Local Region on VM0");
// querying the VM for data
vm0.invoke(PRQHelp.getCacheSerializableRunnableForPROrderByQueryWithLimit(name, localName));
LogWriterUtils.getLogWriter().info("PRQueryDUnitTest#testPRDAckCreationAndQuerying : *Querying PR's with DACK Test ENDED*****");
}
Aggregations