use of org.apache.geode.cache.client.internal.QueueStateImpl.SequenceIdAndExpirationObject in project geode by apache.
the class ReliableMessagingDUnitTest method waitForClientAck.
/**
* Wait for acknowledgment from client, verify creation time is correct
*
* @throws Exception
*/
public static void waitForClientAck() throws Exception {
final long maxWaitTime = 30000;
final long start = System.currentTimeMillis();
Iterator iter = pool.getThreadIdToSequenceIdMap().entrySet().iterator();
SequenceIdAndExpirationObject seo = null;
if (!iter.hasNext()) {
fail("map is empty");
}
Map.Entry entry = (Map.Entry) iter.next();
seo = (SequenceIdAndExpirationObject) entry.getValue();
for (; ; ) {
if (seo.getAckSend()) {
break;
}
assertTrue("Waited over " + maxWaitTime + " for client ack ", +(System.currentTimeMillis() - start) < maxWaitTime);
sleep(1000);
}
LogWriterUtils.getLogWriter().info("seo = " + seo);
assertTrue("Creation time " + creationTime + " supposed to be same as seo " + seo.getCreationTime(), creationTime == seo.getCreationTime());
}
use of org.apache.geode.cache.client.internal.QueueStateImpl.SequenceIdAndExpirationObject in project geode by apache.
the class HAEventIdPropagationDUnitTest method assertThreadIdToSequenceIdMapHasEntryId.
/**
* function to assert that the ThreadIdtoSequence id Map is not Null and has only one entry *
*/
public static Object assertThreadIdToSequenceIdMapHasEntryId() {
Map map = pool.getThreadIdToSequenceIdMap();
assertNotNull(map);
// The map size can now be 1 or 2 because of the server thread putting
// the marker in the queue. If it is 2, the first entry is the server
// thread; the second is the client thread. If it is 1, the entry is the
// client thread. The size changes because of the map.clear call below.
assertTrue(map.size() != 0);
// Set the entry to the last entry
Map.Entry entry = null;
for (Iterator threadIdToSequenceIdMapIterator = map.entrySet().iterator(); threadIdToSequenceIdMapIterator.hasNext(); ) {
entry = (Map.Entry) threadIdToSequenceIdMapIterator.next();
}
ThreadIdentifier tid = (ThreadIdentifier) entry.getKey();
SequenceIdAndExpirationObject seo = (SequenceIdAndExpirationObject) entry.getValue();
long sequenceId = seo.getSequenceId();
EventID evId = new EventID(tid.getMembershipID(), tid.getThreadID(), sequenceId);
synchronized (map) {
map.clear();
}
return evId;
}
use of org.apache.geode.cache.client.internal.QueueStateImpl.SequenceIdAndExpirationObject in project geode by apache.
the class EventIdOptimizationDUnitTest method assertThreadIdToSequenceIdMapHasEntryId.
/**
* Function to assert that the ThreadIdtoSequence id Map is not Null and has only one entry.
*
* @return - eventID object from the ThreadIdToSequenceIdMap
*/
public static Object assertThreadIdToSequenceIdMapHasEntryId() {
Map map = pool.getThreadIdToSequenceIdMap();
assertNotNull(map);
// The map size can now be 1 or 2 because of the server thread putting
// the marker in the queue. If it is 2, the first entry is the server
// thread; the second is the client thread. If it is 1, the entry is the
// client thread. The size changes because of the map.clear call below.
assertTrue(map.size() != 0);
// Set the entry to the last entry
Map.Entry entry = null;
for (Iterator threadIdToSequenceIdMapIterator = map.entrySet().iterator(); threadIdToSequenceIdMapIterator.hasNext(); ) {
entry = (Map.Entry) threadIdToSequenceIdMapIterator.next();
}
ThreadIdentifier tid = (ThreadIdentifier) entry.getKey();
SequenceIdAndExpirationObject seo = (SequenceIdAndExpirationObject) entry.getValue();
long sequenceId = seo.getSequenceId();
EventID evId = new EventID(tid.getMembershipID(), tid.getThreadID(), sequenceId);
synchronized (map) {
map.clear();
}
return evId;
}
use of org.apache.geode.cache.client.internal.QueueStateImpl.SequenceIdAndExpirationObject in project geode by apache.
the class PutAllDUnitTest method assertThreadIdToSequenceIdMapHasEntryId.
/** function to assert that the ThreadIdtoSequence id Map is not Null and has only one entry **/
public static Object assertThreadIdToSequenceIdMapHasEntryId() {
Map map = pool.getThreadIdToSequenceIdMap();
assertNotNull(map);
// The map size can now be 1 or 2 because of the server thread putting
// the marker in the queue. If it is 2, the first entry is the server
// thread; the second is the client thread. If it is 1, the entry is the
// client thread. The size changes because of the map.clear call below.
assertTrue(map.size() != 0);
// Set the entry to the last entry
Map.Entry entry = null;
for (Iterator threadIdToSequenceIdMapIterator = map.entrySet().iterator(); threadIdToSequenceIdMapIterator.hasNext(); ) {
entry = (Map.Entry) threadIdToSequenceIdMapIterator.next();
}
ThreadIdentifier tid = (ThreadIdentifier) entry.getKey();
SequenceIdAndExpirationObject seo = (SequenceIdAndExpirationObject) entry.getValue();
long sequenceId = seo.getSequenceId();
EventID evId = new EventID(tid.getMembershipID(), tid.getThreadID(), sequenceId);
synchronized (map) {
map.clear();
}
return evId;
}
use of org.apache.geode.cache.client.internal.QueueStateImpl.SequenceIdAndExpirationObject in project geode by apache.
the class ReliableMessagingDUnitTest method setCreationTimeTidAndSeq.
public static void setCreationTimeTidAndSeq() {
final Map map = pool.getThreadIdToSequenceIdMap();
WaitCriterion ev = new WaitCriterion() {
public boolean done() {
synchronized (map) {
return map.entrySet().size() > 0;
}
}
public String description() {
return null;
}
};
Wait.waitForCriterion(ev, 10 * 1000, 200, true);
Map.Entry entry;
synchronized (map) {
Iterator iter = map.entrySet().iterator();
entry = (Map.Entry) iter.next();
}
SequenceIdAndExpirationObject seo = (SequenceIdAndExpirationObject) entry.getValue();
assertFalse(seo.getAckSend());
creationTime = seo.getCreationTime();
LogWriterUtils.getLogWriter().info("seo is " + seo.toString());
assertTrue("Creation time not set", creationTime != 0);
Object[] args = new Object[] { ((ThreadIdentifier) entry.getKey()).getMembershipID(), new Long(((ThreadIdentifier) entry.getKey()).getThreadID()), new Long(seo.getSequenceId()) };
server1.invoke(ReliableMessagingDUnitTest.class, "setTidAndSeq", args);
server2.invoke(ReliableMessagingDUnitTest.class, "setTidAndSeq", args);
}
Aggregations