Rollback issue #130 because the remove from the inflight is done by MapDBSessionsStore.inFlightAck
This commit is contained in:
@@ -23,7 +23,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IMessagesStore implementation backed by MapDB.
|
* IMessagesStore implementation backed by MapDB.
|
||||||
@@ -37,7 +36,7 @@ class MapDBMessagesStore implements IMessagesStore {
|
|||||||
private DB m_db;
|
private DB m_db;
|
||||||
|
|
||||||
//map clientID <-> set of currently in flight packet identifiers
|
//map clientID <-> set of currently in flight packet identifiers
|
||||||
private Map<String, AtomicLong> m_inFlightIds;
|
private Map<String, Set<Integer>> m_inFlightIds;
|
||||||
//maps clientID -> guid
|
//maps clientID -> guid
|
||||||
private ConcurrentMap<String, String> m_retainedStore;
|
private ConcurrentMap<String, String> m_retainedStore;
|
||||||
//maps guid to message, it's message store
|
//maps guid to message, it's message store
|
||||||
@@ -116,19 +115,20 @@ class MapDBMessagesStore implements IMessagesStore {
|
|||||||
* */
|
* */
|
||||||
@Override
|
@Override
|
||||||
public int nextPacketID(String clientID) {
|
public int nextPacketID(String clientID) {
|
||||||
AtomicLong atomicLong = this.m_inFlightIds.get(clientID);
|
Set<Integer> inFlightForClient = this.m_inFlightIds.get(clientID);
|
||||||
if (atomicLong == null) {
|
if (inFlightForClient == null) {
|
||||||
AtomicLong messageId = new AtomicLong(1);
|
int nextPacketId = 1;
|
||||||
this.m_inFlightIds.put(clientID, messageId);
|
inFlightForClient = new HashSet<>();
|
||||||
return 1;
|
inFlightForClient.add(nextPacketId);
|
||||||
}
|
this.m_inFlightIds.put(clientID, inFlightForClient);
|
||||||
int incrementAndGet = (int) atomicLong.incrementAndGet();
|
return nextPacketId;
|
||||||
if (incrementAndGet == 0XFFFF) {
|
|
||||||
atomicLong.set(1);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return incrementAndGet;
|
int maxId = inFlightForClient.isEmpty() ? 0 : Collections.max(inFlightForClient);
|
||||||
|
int nextPacketId = (maxId + 1) % 0xFFFF;
|
||||||
|
inFlightForClient.add(nextPacketId);
|
||||||
|
return nextPacketId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user