use of org.apache.geode.internal.cache.ha.HARegionQueue.MapWrapper in project geode by apache.
the class HARQAddOperationJUnitTest method testDispatchedMsgsMapUpdateOnTakes.
/*
* This test does the following:<br> 1)Create a blocking HARegionQueue<br> 2)Add some events to
* the queue with same ThreadIdentifier<br> 3)Do take() operations to drain the queue<br> 4)Verify
* that dispatchedMessagesMap is not null<br> 5)Verify that size of the dispatchedMessagesMap is 1
* as one regionqueue is created in this test<br> 6)Verify that the map contains an entry for the
* queue-region name<br> 7)Verify that the size of wrapper-map is 1 as all events had same
* ThreadId<br> 8)Verify that the sequenceId against the ThreadId in the wrapper-map is same as
* that of the last event taken<br>
*/
/**
* Behaviour of take() has been changed for relaible messaging feature. Region queue take()
* operation will no longer add to the Dispatch Message Map. Hence disabling the test - SUYOG
*/
@Ignore
@Test
public void testDispatchedMsgsMapUpdateOnTakes() throws Exception {
this.logWriter.info("HARQAddOperationJUnitTest : testDispatchedEventsMapUpdateOnTakes BEGIN");
String regionName = "testDispatchedEventsMapUpdateOnTakes";
HARegionQueue rq = createHARegionQueue(regionName);
Conflatable cf = null;
EventID id = null;
int totalEvents = 10;
for (int i = 0; i < totalEvents; i++) {
id = new EventID(new byte[] { 1 }, 1, i);
cf = new ConflatableObject("key" + i, "value" + i, id, false, "testing");
rq.put(cf);
}
for (int i = 0; i < totalEvents; i++) {
rq.take();
}
Map dispatchedMsgMap = HARegionQueue.getDispatchedMessagesMapForTesting();
// verify that map is not null
assertNotNull("dispatchedMessagesMap found null", dispatchedMsgMap);
// size of the dispatchedMessagesMap should be 1 as one regionqueue is
// created in this test
assertEquals("size of dispatched msgs should be 1", 1, dispatchedMsgMap.size());
// verify that the map contains an entry for the queue-region name
MapWrapper wrapper = (MapWrapper) dispatchedMsgMap.get(regionName);
assertNotNull("dispatchedMsgMap should contain an entry with queueregion name as key", wrapper);
Map dispatchedData = wrapper.map;
assertEquals("size of wrapper-map should be 1 as all events had same ThreadId", 1, dispatchedData.size());
ThreadIdentifier tid = new ThreadIdentifier(new byte[] { 1 }, 1);
Long seqId = (Long) dispatchedData.get(tid);
assertEquals("sequenceId against the ThreadId in the wrapper-map should be that of the last event taken.", id.getSequenceID(), seqId.longValue());
this.logWriter.info("HARQAddOperationJUnitTest : testDispatchedEventsMapUpdateOnTakes END");
}
Aggregations