use of org.apache.geode.internal.cache.EventID in project geode by apache.
the class HARQAddOperationJUnitTest method testQueueAddOperationWithoutConflation.
/**
* Add operation without conflation : 1) Region should have an entry containing counter vs
* Conflatable object. 2) Events Map should have size as 1 with one ThreadIdentifer objecta s key
* & Last DispatchedWrapper as value. 3) This wrapper should have a set with size 1. 4) The
* available IDs set shoudl have size 1. 5) Put another object by same thread. 6) The wrapper set
* & availableIs List should have size 2 .
*/
@Test
public void testQueueAddOperationWithoutConflation() throws Exception {
this.logWriter.info("HARegionQueueJUnitTest : testQueueAddOperationWithoutConflation BEGIN");
this.rq = createHARegionQueue("testQueueAddOperationWithConflation");
EventID id1 = new EventID(new byte[] { 1 }, 1, 1);
EventID id2 = new EventID(new byte[] { 1 }, 1, 2);
ConflatableObject c1 = new ConflatableObject(KEY1, VALUE1, id1, false, "region1");
ConflatableObject c2 = new ConflatableObject(KEY2, VALUE2, id2, false, "region1");
this.rq.put(c1);
assertNull(rq.getConflationMapForTesting().get("region1"));
assertEquals(1, rq.getAvalaibleIds().size());
assertEquals(1, rq.getCurrentCounterSet(id1).size());
this.rq.put(c2);
assertNull(rq.getConflationMapForTesting().get("region1"));
assertEquals(2, rq.getAvalaibleIds().size());
assertEquals(2, rq.getCurrentCounterSet(id1).size());
Iterator iter = rq.getCurrentCounterSet(id1).iterator();
if (iter.hasNext()) {
Long cntr = (Long) iter.next();
ConflatableObject co = (ConflatableObject) this.rq.getRegion().get(cntr);
assertEquals(KEY1, co.getKeyToConflate());
assertEquals(VALUE1, co.getValueToConflate());
}
if (iter.hasNext()) {
Long cntr = (Long) iter.next();
ConflatableObject co = (ConflatableObject) this.rq.getRegion().get(cntr);
assertEquals(KEY2, co.getKeyToConflate());
assertEquals(VALUE2, co.getValueToConflate());
}
this.logWriter.info("HARegionQueueJUnitTest : testQueueAddOperationWithoutConflation END");
}
use of org.apache.geode.internal.cache.EventID in project geode by apache.
the class HARQAddOperationJUnitTest method testQueueAddOperationWithConflation.
/**
* Add operation with conflation : 1) Add Key1 Val1 & then Key1 Val2. 2) At the end of second
* operation , Region should contain the entry correspodning to value 2 3) Available IDs , Last
* DispatchedWrapper Set & Conflation Map should have size 1. 4) Conflation Map ,
* LastDispatchedWrapper Set & Available IDs should have counter corresponding to second operation
*/
@Test
public void testQueueAddOperationWithConflation() throws Exception {
this.logWriter.info("HARegionQueueJUnitTest : testQueueAddOperationWithConflation BEGIN");
this.rq = createHARegionQueue("testQueueAddOperationWithConflation");
EventID id1 = new EventID(new byte[] { 1 }, 1, 1);
EventID id2 = new EventID(new byte[] { 1 }, 1, 2);
ConflatableObject c1 = new ConflatableObject(KEY1, VALUE1, id1, true, "region1");
ConflatableObject c2 = new ConflatableObject(KEY1, VALUE2, id2, true, "region1");
this.rq.put(c1);
this.rq.put(c2);
Map conflationMap = (Map) rq.getConflationMapForTesting().get("region1");
assertEquals(1, conflationMap.size());
Long cntr = (Long) conflationMap.get(KEY1);
ConflatableObject retValue = (ConflatableObject) rq.getRegion().get(cntr);
assertEquals(VALUE2, retValue.getValueToConflate());
assertEquals(1, rq.getAvalaibleIds().size());
assertEquals(1, rq.getCurrentCounterSet(id1).size());
this.logWriter.info("HARegionQueueJUnitTest : testQueueAddOperationWithConflation END");
}
use of org.apache.geode.internal.cache.EventID in project geode by apache.
the class HARQAddOperationJUnitTest method testNoExpiryOnThreadIdentifier.
/**
* Add operation which creates the LastDispatchedAndCurrentEvents object should also add it to the
* Region with Threaddentifer as key & sequence as the value for Expiry. Validate that expiry on
* ThreadIdentifier does not removes itself from Events Map as data is lying & it resets the self
* expiry. Validate the data present in Queue experiences expiry. After the expiry of the data ,
* AvaialbleIds size should be 0, entry removed from Region, LastDispatchedWrapperSet should have
* size 0.
*/
@Test
public void testNoExpiryOnThreadIdentifier() {
try {
HARegionQueueAttributes hqa = new HARegionQueueAttributes();
hqa.setExpiryTime(8);
HARegionQueue regionqueue = createHARegionQueue("testing", hqa);
EventID id1 = new EventID(new byte[] { 1 }, 1, 1);
EventID id2 = new EventID(new byte[] { 1 }, 1, 2);
ConflatableObject c1 = new ConflatableObject(KEY1, VALUE1, id1, true, "region1");
ConflatableObject c2 = new ConflatableObject(KEY1, VALUE2, id2, true, "region1");
ThreadIdentifier threadId = new ThreadIdentifier(c1.getEventId().getMembershipID(), c1.getEventId().getThreadID());
regionqueue.put(c1);
Object o = regionqueue.take();
assertNotNull(o);
// wait for some time and put second object
Thread.sleep(3000);
regionqueue.put(c2);
// wait for some more time so that C2 has not expired
Thread.sleep(4000);
Map eventsMap = regionqueue.getEventsMapForTesting();
// verify that ThreadIdentifier does not remove itself as data is
// lying
assertNotNull("ThreadIdentifier removed itself through expiry even though data was lying in the queue", eventsMap.get(threadId));
// wait for some more time to allow expiry on data
Thread.sleep(16000);
// After the expiry of the data , AvaialbleIds size should be 0,
// entry
// removed from Region, LastDispatchedWrapperSet should have size 0.
assertEquals(0, regionqueue.getRegion().entrySet(false).size());
assertEquals(0, regionqueue.getAvalaibleIds().size());
assertNull(regionqueue.getCurrentCounterSet(id1));
} catch (Exception e) {
e.printStackTrace();
fail(" test failed due to " + e);
}
}
use of org.apache.geode.internal.cache.EventID in project geode by apache.
the class ClearPropagationDUnitTest method acquireConnectionsAndClear.
public static void acquireConnectionsAndClear(String host) {
try {
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r1);
String poolName = r1.getAttributes().getPoolName();
assertNotNull(poolName);
PoolImpl pool = (PoolImpl) PoolManager.find(poolName);
assertNotNull(pool);
Connection conn1 = pool.acquireConnection(new ServerLocation(host, PORT2));
assertNotNull(conn1);
assertEquals(PORT2, conn1.getServer().getPort());
ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
srp.clearOnForTestsOnly(conn1, new EventID(new byte[] { 1 }, 1, 1), null);
} catch (Exception ex) {
ex.printStackTrace();
fail("while setting acquireConnections " + ex);
}
}
use of org.apache.geode.internal.cache.EventID in project geode by apache.
the class Bug36269DUnitTest method acquireConnectionsAndDestroyRegion.
public static void acquireConnectionsAndDestroyRegion(String host) {
try {
Connection desCon = pool.acquireConnection(new ServerLocation(host, PORT2));
ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
srp.destroyRegionOnForTestsOnly(desCon, new EventID(new byte[] { 1 }, 1, 1), null);
} catch (Exception ex) {
Assert.fail("while setting acquireConnections", ex);
}
}
Aggregations