Search in sources :

Example 6 with DeltaTestImpl

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

the class ClientToServerDeltaDUnitTest method testC2SDeltaPropagationWithOldValueInvalidatedAtServer.

@Test
public void testC2SDeltaPropagationWithOldValueInvalidatedAtServer() throws Exception {
    String key = "DELTA_KEY";
    Integer port1 = (Integer) server.invoke(() -> ClientToServerDeltaDUnitTest.createServerCache(false, false, false, true));
    createClientCache("localhost", port1, false, false, false, null, false, false);
    LocalRegion region = (LocalRegion) cache.getRegion(REGION_NAME);
    region.put(key, new DeltaTestImpl());
    server.invoke(() -> ClientToServerDeltaDUnitTest.doInvalidate(key));
    DeltaTestImpl value = new DeltaTestImpl();
    value.setStr("UPDATED_VALUE");
    region.put(key, value);
    assertTrue(region.getCachePerfStats().getDeltasSent() == 1);
    assertTrue(region.getCachePerfStats().getDeltaFullValuesSent() == 1);
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) LocalRegion(org.apache.geode.internal.cache.LocalRegion) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) SerializationTest(org.apache.geode.test.junit.categories.SerializationTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 7 with DeltaTestImpl

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

the class ClientToServerDeltaDUnitTest method putLastKeyWithDelta.

private static void putLastKeyWithDelta() {
    Region r = cache.getRegion(REGION_NAME);
    r.put(LAST_KEY, new DeltaTestImpl());
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region)

Example 8 with DeltaTestImpl

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

the class P2PDeltaPropagationDUnitTest method verifyDeltaReceived.

public static void verifyDeltaReceived(Integer updates) {
    Region region = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    CachePerfStats stats = ((DistributedRegion) cache.getRegion(REGION_NAME)).getCachePerfStats();
    long deltaFailures = stats.getDeltaFailedUpdates();
    long deltas = stats.getDeltaUpdates();
    assertTrue("Failures while processing delta at receiver.", deltaFailures == 0);
    assertTrue("Expected 2 deltas to be processed at receiver but were " + deltas + " (statistics)", deltas == 2);
    assertTrue("Expected 2 deltas to be processed at receiver but were " + DeltaTestImpl.getFromDeltaInvokations() + " (implementation counter)", DeltaTestImpl.getFromDeltaInvokations() == 2);
    assertTrue("Expected " + updates + " updates but found " + numOfUpdates, numOfUpdates == updates);
    DeltaTestImpl val = (DeltaTestImpl) region.getEntry("KEY").getValue();
    assertTrue("Latest value not received, found: " + val, NEW_STR.equals(val.getStr()));
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) Region(org.apache.geode.cache.Region)

Example 9 with DeltaTestImpl

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

the class P2PDeltaPropagationDUnitTest method getOnDeltaDisabledServer.

public static void getOnDeltaDisabledServer() throws Exception {
    Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    // should be
    assertFalse(((DeltaTestImpl) r1.getEntry("KEY").getValue()).getIntVar() == NEW_INT);
    // overwritten
    // as delta
    // is
    // disabled
    assertTrue(((DeltaTestImpl) r1.getEntry("KEY").getValue()).getStr().equals(NEW_STR));
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) Region(org.apache.geode.cache.Region)

Example 10 with DeltaTestImpl

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

the class P2PDeltaPropagationDUnitTest method create.

public static void create() throws Exception {
    Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    DeltaTestImpl test = new DeltaTestImpl();
    r1.create("KEY", test);
    test = new DeltaTestImpl();
    test.setIntVar(NEW_INT);
    r1.create("KEY1", test);
    test = new DeltaTestImpl();
    test.setStr(NEW_STR);
    r1.create("KEY2", test);
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) Region(org.apache.geode.cache.Region)

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