Search in sources :

Example 16 with DeltaTestImpl

use of org.apache.geode.DeltaTestImpl in project geode by apache.

the class DeltaPropagationStatsDUnitTest method putErrorDeltaForReceiver.

public static void putErrorDeltaForReceiver(Integer keys, Long updates, Long errors) {
    Region r = cache.getRegion(REGION_NAME);
    assertTrue("Errors cannot be more than 1/3rd of total udpates", (updates * keys) / 3 > errors);
    for (int i = 0; i < keys; i++) {
        r.create(DELTA_KEY + i, new DeltaTestImpl());
    }
    for (int i = 0; i < keys; i++) {
        for (long j = 0; j < updates; j++) {
            DeltaTestImpl delta = new DeltaTestImpl();
            if (j % 3 == 1) {
                delta.setIntVar(10);
            } else if (j % 3 == 2) {
                delta.setStr("two");
                if (errors != 0) {
                    delta.setStr(DeltaTestImpl.ERRONEOUS_STRING_FOR_FROM_DELTA);
                    errors--;
                }
            } else {
                delta.setByteArr(new byte[] { 11, 22, 33, 44 });
                delta.setDoubleVar(5.7);
            }
            r.put(DELTA_KEY + i, delta);
        }
    }
    assertTrue("Error puts not exhausted", errors == 0);
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) Region(org.apache.geode.cache.Region)

Example 17 with DeltaTestImpl

use of org.apache.geode.DeltaTestImpl in project geode by apache.

the class DeltaPropagationStatsDUnitTest method putCleanDelta.

public static void putCleanDelta(Integer keys, Long updates) {
    Region r = cache.getRegion(REGION_NAME);
    for (int i = 0; i < keys; i++) {
        r.create(DELTA_KEY + i, new DeltaTestImpl());
    }
    for (int i = 0; i < keys; i++) {
        for (long j = 0; j < updates; j++) {
            DeltaTestImpl delta = new DeltaTestImpl();
            if (j % 3 == 1) {
                delta.setIntVar(10);
            } else if (j % 3 == 2) {
                delta.setStr("two");
            } else {
                delta.setByteArr(new byte[] { 11, 22, 33, 44 });
                delta.setDoubleVar(5.7);
            }
            r.put(DELTA_KEY + i, delta);
        }
    }
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) Region(org.apache.geode.cache.Region)

Example 18 with DeltaTestImpl

use of org.apache.geode.DeltaTestImpl in project geode by apache.

the class DeltaClientAuthorizationDUnitTest method setUpDeltas.

private void setUpDeltas() {
    for (int i = 0; i < 8; i++) {
        deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0], new TestObject1("0", 0));
    }
    deltas[1].setIntVar(5);
    deltas[2].setIntVar(5);
    deltas[3].setIntVar(5);
    deltas[4].setIntVar(5);
    deltas[5].setIntVar(5);
    deltas[6].setIntVar(5);
    deltas[7].setIntVar(5);
    deltas[2].resetDeltaStatus();
    deltas[2].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltas[3].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltas[4].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltas[5].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    // deltas[6].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    // deltas[7].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltas[3].resetDeltaStatus();
    deltas[3].setDoubleVar(new Double(5));
    deltas[4].setDoubleVar(new Double(5));
    deltas[5].setDoubleVar(new Double(5));
    deltas[6].setDoubleVar(new Double(5));
    deltas[7].setDoubleVar(new Double(5));
    deltas[4].resetDeltaStatus();
    deltas[4].setStr("str changed");
    deltas[5].setStr("str changed");
    deltas[6].setStr("str changed");
    // deltas[7].setStr("str changed");
    deltas[5].resetDeltaStatus();
    deltas[5].setIntVar(100);
    deltas[5].setTestObj(new TestObject1("CHANGED", 100));
    deltas[6].setTestObj(new TestObject1("CHANGED", 100));
    deltas[7].setTestObj(new TestObject1("CHANGED", 100));
    deltas[6].resetDeltaStatus();
    deltas[6].setByteArr(new byte[] { 1, 2, 3 });
    deltas[7].setByteArr(new byte[] { 1, 2, 3 });
    deltas[7].resetDeltaStatus();
    deltas[7].setStr("delta string");
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) TestObject1(org.apache.geode.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1)

Example 19 with DeltaTestImpl

use of org.apache.geode.DeltaTestImpl in project geode by apache.

the class PRDeltaPropagationDUnitTest method testDeltaPropagationReplicatedRegionPeerWithDeltaException.

/**
   * 1) Put delta objects on client feeder connected accessor bridge server. 2) From accessor to
   * data store delta gets propagated as part of <code>UpdateMessage</code> delta. 3) Exception
   * occurs when applying delta on datastore node. This invalid delta exception propagated back to
   * client through accessor. 4) Client sends full object in response.
   */
@Test
public void testDeltaPropagationReplicatedRegionPeerWithDeltaException() throws Exception {
    Object[] args1 = new Object[] { Boolean.FALSE, Boolean.TRUE };
    Object[] args2 = new Object[] { Boolean.TRUE, Boolean.FALSE };
    // server 1 with empty data policy
    Integer port1 = (Integer) dataStore1.invoke(PRDeltaPropagationDUnitTest.class, "createServerCache", args1);
    // server 2 with non empty data policy
    dataStore2.invoke(PRDeltaPropagationDUnitTest.class, "createServerCache", args2);
    createClientCache(port1, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);
    // feed delta
    DeltaTestImpl test = new DeltaTestImpl();
    deltaPR.put(DELTA_KEY, test);
    test.setIntVar(10);
    deltaPR.put(DELTA_KEY, test);
    // perform invalidate on accessor
    dataStore2.invoke(() -> PRDeltaPropagationDUnitTest.invalidateDeltaKey());
    test = new DeltaTestImpl();
    test.setStr("DELTA");
    deltaPR.put(DELTA_KEY, test);
    deltaPR.put(LAST_KEY, "");
    dataStore2.invoke(() -> PRDeltaPropagationDUnitTest.waitForLastKey());
    // check and reset isFailed flag
    dataStore2.invoke(() -> PRDeltaPropagationDUnitTest.checkIsFailed());
    dataStore2.invoke(() -> PRDeltaPropagationDUnitTest.fromDeltaCounter(new Integer(1)));
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) SerializationTest(org.apache.geode.test.junit.categories.SerializationTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) ConflationDUnitTest(org.apache.geode.internal.cache.tier.sockets.ConflationDUnitTest) Test(org.junit.Test)

Example 20 with DeltaTestImpl

use of org.apache.geode.DeltaTestImpl in project geode by apache.

the class PRDeltaPropagationDUnitTest method testCqClientConnectAccessorAndDataStore.

/**
   * 1) Put delta objects on feeder connected accessor bridge server. 2) Second client attached to
   * datastore. Register CQ. 3) Varifies that no data loss, event revcieved on second client
   */
@Test
public void testCqClientConnectAccessorAndDataStore() throws Exception {
    Object[] args1 = new Object[] { REGION_NAME, new Integer(1), new Integer(0), new Integer(8), Boolean.FALSE, null };
    Object[] args2 = new Object[] { REGION_NAME, new Integer(1), new Integer(50), new Integer(8), Boolean.FALSE, null };
    Integer port2 = (Integer) dataStore2.invoke(PRDeltaPropagationDUnitTest.class, "createCacheServerWithPR", args2);
    Integer port1 = (Integer) dataStore1.invoke(PRDeltaPropagationDUnitTest.class, "createCacheServerWithPR", args1);
    // client attached to accessor server1
    createClientCache(port1, new Boolean(false), new Boolean(true), new Boolean(false));
    // enable CQ listner validation for this test for this client
    client1.invoke(() -> PRDeltaPropagationDUnitTest.setForOldNewCQVarification(new Boolean(true)));
    // Not registering any interest but register cq server2
    client1.invoke(() -> PRDeltaPropagationDUnitTest.createClientCache(port2, new Boolean(false), new Boolean(false), new Boolean(true)));
    // check cloning is disabled
    dataStore1.invoke(() -> PRDeltaPropagationDUnitTest.checkCloning());
    dataStore2.invoke(() -> PRDeltaPropagationDUnitTest.checkCloning());
    client1.invoke(() -> PRDeltaPropagationDUnitTest.checkCloning());
    checkCloning();
    // feed delta
    DeltaTestImpl test = new DeltaTestImpl(8, "");
    deltaPR.put(DELTA_KEY, test);
    test.setIntVar(10);
    deltaPR.put(DELTA_KEY, test);
    deltaPR.put(LAST_KEY, new DeltaTestImpl(5, ""));
    // wait for last key
    client1.invoke(() -> PRDeltaPropagationDUnitTest.waitForLastKey());
    // full object, server will send full object as only CQ are registered
    client1.invoke(() -> PRDeltaPropagationDUnitTest.fromDeltaCounter(new Integer(0)));
    boolean failed = ((Boolean) client1.invoke(() -> PRDeltaPropagationDUnitTest.isFailed())).booleanValue();
    // no cq events should get miss
    assertTrue("EVENT Missed", failed == true);
    // region size should be zero in second client as no registration happens
    client1.invoke(() -> PRDeltaPropagationDUnitTest.checkRegionSize(new Integer(0)));
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) SerializationTest(org.apache.geode.test.junit.categories.SerializationTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) ConflationDUnitTest(org.apache.geode.internal.cache.tier.sockets.ConflationDUnitTest) Test(org.junit.Test)

Aggregations

DeltaTestImpl (org.apache.geode.DeltaTestImpl)38 Region (org.apache.geode.cache.Region)21 Test (org.junit.Test)10 TestObject1 (org.apache.geode.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1)9 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)9 SerializationTest (org.apache.geode.test.junit.categories.SerializationTest)9 ConflationDUnitTest (org.apache.geode.internal.cache.tier.sockets.ConflationDUnitTest)8 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)8 LocalRegion (org.apache.geode.internal.cache.LocalRegion)7 InvalidDeltaException (org.apache.geode.InvalidDeltaException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInput (java.io.DataInput)1 DataInputStream (java.io.DataInputStream)1 Properties (java.util.Properties)1 DataSerializable (org.apache.geode.DataSerializable)1 Delta (org.apache.geode.Delta)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 EntryEvent (org.apache.geode.cache.EntryEvent)1 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)1 RegionAttributes (org.apache.geode.cache.RegionAttributes)1