Search in sources :

Example 11 with DeltaTestImpl

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

the class P2PDeltaPropagationDUnitTest method getOnDeltaEnabledWithInvalidate.

public static void getOnDeltaEnabledWithInvalidate() throws Exception {
    Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    assertTrue(((DeltaTestImpl) r1.getEntry("KEY").getValue()).getIntVar() == NEW_INT);
    assertTrue(((DeltaTestImpl) r1.getEntry("KEY").getValue()).getStr().equals(NEW_STR));
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) Region(org.apache.geode.cache.Region)

Example 12 with DeltaTestImpl

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

the class P2PDeltaPropagationDUnitTest method put.

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

Example 13 with DeltaTestImpl

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

the class P2PDeltaPropagationDUnitTest method getOnDeltaEnabledWithDestroy.

public static void getOnDeltaEnabledWithDestroy() throws Exception {
    Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    assertNull(((DeltaTestImpl) r1.getEntry("KEY")));
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) Region(org.apache.geode.cache.Region)

Example 14 with DeltaTestImpl

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

the class DeltaPropagationDUnitTest method testC2S2SDeltaPropagation.

/**
   * Tests that an update on a server with full Delta object causes distribution of the full Delta
   * instance, and not its delta bits, to other peers, even if that instance's
   * <code>hasDelta()</code> returns true.
   * 
   * @throws Exception
   */
@Test
public void testC2S2SDeltaPropagation() throws Exception {
    prepareDeltas();
    VM0.invoke(() -> DeltaPropagationDUnitTest.prepareDeltas());
    VM1.invoke(() -> DeltaPropagationDUnitTest.prepareDeltas());
    DeltaTestImpl val = deltaPut[1];
    VM0.invoke(() -> DeltaPropagationDUnitTest.closeCache());
    PORT1 = ((Integer) VM0.invoke(() -> DeltaPropagationDUnitTest.createServerCache(HARegionQueue.HA_EVICTION_POLICY_MEMORY, new Integer(1), new Integer(C2S2S_SERVER_LISTENER)))).intValue();
    PORT2 = ((Integer) VM1.invoke(() -> DeltaPropagationDUnitTest.createServerCache(HARegionQueue.HA_EVICTION_POLICY_MEMORY, new Integer(1), new Integer(C2S2S_SERVER_LISTENER)))).intValue();
    createClientCache(new Integer(PORT1), new Integer(-1), "0", new Integer(NO_LISTENER));
    Region r = cache.getRegion("/" + regionName);
    assertNotNull(r);
    r.create(DELTA_KEY, deltaPut[0]);
    // Invalidate the value at both the servers.
    VM0.invoke(() -> DeltaPropagationDUnitTest.doLocalOp(INVALIDATE, regionName, DELTA_KEY));
    VM1.invoke(() -> DeltaPropagationDUnitTest.doLocalOp(INVALIDATE, regionName, DELTA_KEY));
    VM0.invoke(() -> DeltaPropagationDUnitTest.assertOp(INVALIDATE, new Integer(1)));
    VM1.invoke(() -> DeltaPropagationDUnitTest.assertOp(INVALIDATE, new Integer(1)));
    r.put(DELTA_KEY, val);
    Thread.sleep(5000);
    // Assert that VM0 distributed val as full value to VM1.
    VM1.invoke(() -> DeltaPropagationDUnitTest.assertValue(regionName, DELTA_KEY, val));
    assertTrue("Delta Propagation feature used.", !((Boolean) VM0.invoke(() -> DeltaTestImpl.deltaFeatureUsed())).booleanValue());
    assertTrue("Delta Propagation feature used.", !((Boolean) VM1.invoke(() -> DeltaTestImpl.deltaFeatureUsed())).booleanValue());
    assertTrue("Delta Propagation feature NOT used.", DeltaTestImpl.deltaFeatureUsed());
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) Region(org.apache.geode.cache.Region) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) ConflationDUnitTest(org.apache.geode.internal.cache.tier.sockets.ConflationDUnitTest) Test(org.junit.Test)

Example 15 with DeltaTestImpl

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

the class DeltaPropagationDUnitTest method prepareDeltas.

public static void prepareDeltas() {
    for (int i = 0; i < EVENTS_SIZE; i++) {
        deltaPut[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0], new TestObject1("0", 0));
    }
    deltaPut[1].setIntVar(5);
    deltaPut[2].setIntVar(5);
    deltaPut[3].setIntVar(5);
    deltaPut[4].setIntVar(5);
    deltaPut[5].setIntVar(5);
    deltaPut[2].resetDeltaStatus();
    deltaPut[2].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltaPut[3].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltaPut[4].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltaPut[5].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltaPut[3].resetDeltaStatus();
    deltaPut[3].setDoubleVar(new Double(5));
    deltaPut[4].setDoubleVar(new Double(5));
    deltaPut[5].setDoubleVar(new Double(5));
    deltaPut[4].resetDeltaStatus();
    deltaPut[4].setStr("str changed");
    deltaPut[5].setStr("str changed");
    deltaPut[5].resetDeltaStatus();
    deltaPut[5].setIntVar(100);
    deltaPut[5].setTestObj(new TestObject1("CHANGED", 100));
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) TestObject1(org.apache.geode.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1)

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