Search in sources :

Example 36 with PartitionedRegion

use of org.apache.geode.internal.cache.PartitionedRegion in project geode by apache.

the class StreamingPartitionOperationOneDUnitTest method testStreamingPartitionOneProviderNoExceptions.

@Test
public void testStreamingPartitionOneProviderNoExceptions() throws Exception {
    // final String name = this.getUniqueName();
    // ask another VM to connect to the distributed system
    // this will be the data provider, and get their member id at the same time
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    // get the other member id that connected
    InternalDistributedMember otherId = (InternalDistributedMember) vm0.invoke(new IDGetter(), "getMemberId");
    vm0.invoke(createPrRegionWithDS_DACK);
    // also create the PR here so we can get the regionId
    createPrRegionWithDS_DACK.run2();
    int regionId = ((PartitionedRegion) getCache().getRegion("PR1")).getPRId();
    Set setOfIds = Collections.singleton(otherId);
    TestStreamingPartitionOperationOneProviderNoExceptions streamOp = new TestStreamingPartitionOperationOneProviderNoExceptions(getSystem(), regionId);
    try {
        streamOp.getPartitionedDataFrom(setOfIds);
    } catch (VirtualMachineError e) {
        SystemFailure.initiateFailure(e);
        throw e;
    } catch (Throwable t) {
        Assert.fail("getPartitionedDataFrom failed", t);
    }
    assertTrue(streamOp.dataValidated);
}
Also used : Set(java.util.Set) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 37 with PartitionedRegion

use of org.apache.geode.internal.cache.PartitionedRegion in project geode by apache.

the class PersistentPartitionedRegionTestBase method moveBucket.

protected boolean moveBucket(final int bucketId, VM source, VM target) {
    SerializableCallable getId = new SerializableCallable("Get Id") {

        public Object call() throws Exception {
            Cache cache = getCache();
            return cache.getDistributedSystem().getDistributedMember();
        }
    };
    final InternalDistributedMember sourceId = (InternalDistributedMember) source.invoke(getId);
    SerializableCallable move = new SerializableCallable("move bucket") {

        public Object call() {
            Cache cache = getCache();
            PartitionedRegion region = (PartitionedRegion) cache.getRegion(PR_REGION_NAME);
            return region.getDataStore().moveBucket(bucketId, sourceId, false);
        }
    };
    return (Boolean) target.invoke(move);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Cache(org.apache.geode.cache.Cache)

Example 38 with PartitionedRegion

use of org.apache.geode.internal.cache.PartitionedRegion in project geode by apache.

the class FixedPartitioningTestBase method putShipmentPartitionedRegion_Persistence.

public static void putShipmentPartitionedRegion_Persistence(String partitionedRegionName) {
    assertNotNull(cache);
    Region partitionedregion = cache.getRegion(Region.SEPARATOR + partitionedRegionName);
    assertNotNull(partitionedregion);
    for (int i = 1; i <= 20; i++) {
        CustId custid = new CustId(i);
        for (int j = 1; j <= 10; j++) {
            int oid = (i * 10) + j;
            OrderId orderId = new OrderId(oid, custid);
            for (int k = 1; k <= 10; k++) {
                int sid = (oid * 10) + k;
                ShipmentId shipmentId = new ShipmentId(sid, orderId);
                Shipment shipment = new Shipment("Shipment" + sid);
                try {
                    partitionedregion.put(shipmentId, shipment);
                } catch (Exception e) {
                    org.apache.geode.test.dunit.Assert.fail("putShipmentPartitionedRegion : failed while doing put operation in ShipmentPartitionedRegion ", e);
                }
                LogWriterUtils.getLogWriter().info("Shipment :- { " + shipmentId + " : " + shipment + " }");
            }
        }
    }
}
Also used : ShipmentId(org.apache.geode.internal.cache.execute.data.ShipmentId) CustId(org.apache.geode.internal.cache.execute.data.CustId) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) HARegion(org.apache.geode.internal.cache.HARegion) Region(org.apache.geode.cache.Region) Shipment(org.apache.geode.internal.cache.execute.data.Shipment) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) ParseException(java.text.ParseException) IOException(java.io.IOException)

Example 39 with PartitionedRegion

use of org.apache.geode.internal.cache.PartitionedRegion in project geode by apache.

the class FixedPartitioningTestBase method getForColocation.

public static void getForColocation(String customerRegion, String order, String shipment) {
    Region region_Cust = (PartitionedRegion) cache.getRegion(customerRegion);
    assertNotNull(region_Cust);
    for (int i = 1; i <= 20; i++) {
        CustId custid = new CustId(i);
        Customer customer = new Customer("name" + i, "Address" + i);
        try {
            assertEquals(customer, region_Cust.get(custid));
        } catch (Exception e) {
            org.apache.geode.test.dunit.Assert.fail("getForColocation : failed while doing get operation in CustomerPartitionedRegion ", e);
        }
    }
    Region region_Ord = (PartitionedRegion) cache.getRegion(order);
    assertNull(region_Ord);
    Region region_Ship = (PartitionedRegion) cache.getRegion(shipment);
    assertNull(region_Ship);
}
Also used : CustId(org.apache.geode.internal.cache.execute.data.CustId) Customer(org.apache.geode.internal.cache.execute.data.Customer) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) HARegion(org.apache.geode.internal.cache.HARegion) Region(org.apache.geode.cache.Region) ParseException(java.text.ParseException) IOException(java.io.IOException)

Example 40 with PartitionedRegion

use of org.apache.geode.internal.cache.PartitionedRegion in project geode by apache.

the class FixedPartitioningTestBase method putCustomerPartitionedRegion_Persistence2.

public static void putCustomerPartitionedRegion_Persistence2(String partitionedRegionName) {
    assertNotNull(cache);
    Region partitionedregion = cache.getRegion(Region.SEPARATOR + partitionedRegionName);
    assertNotNull(partitionedregion);
    for (int i = 1; i <= 20; i++) {
        if (i % 2 == 1) {
            CustId custid = new CustId(i);
            Customer customer = new Customer("name" + i, "Address" + i);
            try {
                partitionedregion.put(custid, customer);
            } catch (Exception e) {
                org.apache.geode.test.dunit.Assert.fail("putCustomerPartitionedRegion : failed while doing put operation in CustomerPartitionedRegion ", e);
            }
            LogWriterUtils.getLogWriter().info("Customer :- { " + custid + " : " + customer + " }");
        }
    }
}
Also used : CustId(org.apache.geode.internal.cache.execute.data.CustId) Customer(org.apache.geode.internal.cache.execute.data.Customer) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) HARegion(org.apache.geode.internal.cache.HARegion) Region(org.apache.geode.cache.Region) ParseException(java.text.ParseException) IOException(java.io.IOException)

Aggregations

PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)367 Test (org.junit.Test)135 Region (org.apache.geode.cache.Region)115 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)112 HashSet (java.util.HashSet)105 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)104 AttributesFactory (org.apache.geode.cache.AttributesFactory)86 VM (org.apache.geode.test.dunit.VM)86 Host (org.apache.geode.test.dunit.Host)85 ArrayList (java.util.ArrayList)77 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)75 Set (java.util.Set)69 IOException (java.io.IOException)66 Function (org.apache.geode.cache.execute.Function)66 FunctionException (org.apache.geode.cache.execute.FunctionException)63 List (java.util.List)62 RegionAttributes (org.apache.geode.cache.RegionAttributes)61 Iterator (java.util.Iterator)60 IgnoredException (org.apache.geode.test.dunit.IgnoredException)59 Cache (org.apache.geode.cache.Cache)56