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);
}
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);
}
}
}
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");
}
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)));
}
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)));
}
Aggregations