use of org.apache.geode.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1 in project geode by apache.
the class ClientToServerDeltaDUnitTest method putDeltaForCQ.
private static void putDeltaForCQ(String key, Integer numOfPuts, Integer[] cqIndices, Boolean[] satisfyQuery) {
Region region = cache.getRegion(REGION_NAME);
DeltaTestImpl val = null;
for (int j = 0; j < numOfPuts; j++) {
val = new DeltaTestImpl(0, "0", new Double(0), new byte[0], new TestObject1("0", 0));
for (int i = 0; i < cqIndices.length; i++) {
switch(i) {
case 0:
val.setStr("CASE_0");
// select *
break;
case 1:
val.setStr("CASE_1");
// select where intVar = 0
if (satisfyQuery[i]) {
val.setIntVar(0);
} else {
val.setIntVar(100);
}
break;
case 2:
val.setStr("CASE_2");
// select where intVar > 0
if (satisfyQuery[i]) {
val.setIntVar(100);
} else {
val.setIntVar(-100);
}
break;
case 3:
val.setStr("CASE_3");
// select where intVar < 0
if (satisfyQuery[i]) {
val.setIntVar(-100);
} else {
val.setIntVar(100);
}
break;
default:
break;
}
}
region.put(key, val);
}
}
use of org.apache.geode.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1 in project geode by apache.
the class ClientToServerDeltaDUnitTest method put.
/*
* put delta full cycle
*/
private static void put(String key) {
Region r = cache.getRegion(REGION_NAME);
DeltaTestImpl val = null;
for (int i = 0; i < NO_PUT_OPERATION; i++) {
switch(i) {
case 0:
val = new DeltaTestImpl(0, "0", new Double(0), new byte[0], new TestObject1("0", 0));
break;
case 1:
val = new DeltaTestImpl(0, "0", new Double(0), new byte[0], new TestObject1("0", 0));
val.setStr((String) putDelta[0]);
break;
case 2:
val = new DeltaTestImpl(0, (String) putDelta[1], new Double(0), new byte[0], new TestObject1("0", 0));
val.setIntVar(((Integer) putDelta[2]).intValue());
break;
}
r.put(key, val);
}
}
use of org.apache.geode.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1 in project geode by apache.
the class DeltaTestImpl method fromDelta.
/*
* (non-Javadoc)
*
* @see org.apache.geode.Delta#fromDelta(java.io.DataInput)
*/
public void fromDelta(DataInput in) throws IOException {
try {
fromDeltaInvokations++;
boolean tempHasDelta = false;
byte tempDeltaBits = this.deltaBits;
byte[] tempByteArr = this.byteArr;
int tempIntVar = this.intVar;
double tempDoubleVar = this.doubleVar;
String tempStr = this.str;
TestObject1 tempTestObj = this.testObj;
tempDeltaBits = DataSerializer.readByte(in);
if (tempDeltaBits != 0) {
tempHasDelta = true;
if ((tempDeltaBits & INT_MASK) == INT_MASK) {
tempIntVar = DataSerializer.readPrimitiveInt(in);
checkInvalidInt2(tempIntVar);
}
if ((tempDeltaBits & STR_MASK) == STR_MASK) {
tempStr = DataSerializer.readString(in);
// Simulates exception
checkInvalidString(tempStr);
}
if ((tempDeltaBits & DOUBLE_MASK) == DOUBLE_MASK) {
tempDoubleVar = DataSerializer.readDouble(in);
}
if ((tempDeltaBits & BYTE_ARR_MASK) == BYTE_ARR_MASK) {
tempByteArr = DataSerializer.readByteArray(in);
}
if ((tempDeltaBits & TEST_OBJ_MASK) == TEST_OBJ_MASK) {
tempTestObj = (TestObject1) DataSerializer.readObject(in);
}
if ((deltaBits | COMPLETE_MASK) != COMPLETE_MASK) {
throw new IllegalArgumentException("Unknown field code: " + tempDeltaBits);
}
}
if (tempHasDelta) {
// this.hasDelta = true;
// this.deltaBits = tempDeltaBits;
this.intVar = tempIntVar;
this.str = tempStr;
this.doubleVar = tempDoubleVar;
this.byteArr = tempByteArr;
this.testObj = tempTestObj;
}
} catch (IOException e) {
GemFireCacheImpl.getInstance().getLogger().warning("DeltaTestImpl.fromDelta(): " + e);
throw e;
} catch (IllegalArgumentException iae) {
GemFireCacheImpl.getInstance().getLogger().warning("DeltaTestImpl.fromDelta(): " + iae);
throw new InvalidDeltaException(iae);
} catch (ClassNotFoundException cnfe) {
GemFireCacheImpl.getInstance().getLogger().warning("DeltaTestImpl.fromDelta(): " + cnfe);
throw new InvalidDeltaException(cnfe);
}
}
use of org.apache.geode.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1 in project geode by apache.
the class DeltaPropagationDUnitTest method prepareErroneousDeltasForToDelta.
public static void prepareErroneousDeltasForToDelta() {
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(DeltaTestImpl.ERRONEOUS_INT_FOR_TO_DELTA);
deltaPut[4].setIntVar(5);
deltaPut[5].setIntVar(5);
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].setDoubleVar(new Double(5));
deltaPut[4].setDoubleVar(new Double(5));
deltaPut[5].setDoubleVar(new Double(5));
deltaPut[4].setStr("str changed");
deltaPut[5].setStr("str changed");
deltaPut[5].setIntVar(100);
deltaPut[5].setTestObj(new TestObject1("CHANGED", 100));
}
use of org.apache.geode.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1 in project geode by apache.
the class DeltaPropagationDUnitTest method prepareErroneousDeltasForFromDelta.
public static void prepareErroneousDeltasForFromDelta() {
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].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].setDoubleVar(new Double(5));
deltaPut[4].setDoubleVar(new Double(5));
deltaPut[5].setDoubleVar(new Double(5));
deltaPut[4].setStr("str changed");
deltaPut[5].setStr(DeltaTestImpl.ERRONEOUS_STRING_FOR_FROM_DELTA);
deltaPut[5].setIntVar(100);
deltaPut[5].setTestObj(new TestObject1("CHANGED", 100));
}
Aggregations