use of org.apache.geode.internal.cache.EventTracker.EventSeqnoHolder in project geode by apache.
the class EventStateHelper method toData.
/**
* Post 7.1, if changes are made to this method make sure that it is backwards compatible by
* creating toDataPreXX methods. Also make sure that the callers to this method are backwards
* compatible by creating toDataPreXX methods for them even if they are not changed. <br>
* Callers for this method are: <br>
* {@link CreateRegionReplyMessage#toData(DataOutput)} <br>
* {@link RegionStateMessage#toData(DataOutput)} <br>
*/
@SuppressWarnings("synthetic-access")
public static void toData(DataOutput dop, Map eventState, boolean isHARegion) throws IOException {
// For HARegionQueues, the event state map is uses different values
// than a regular region :(
InternalDistributedMember myId = InternalDistributedSystem.getAnyInstance().getDistributedMember();
Map<MemberIdentifier, Map<ThreadIdentifier, Object>> groupedThreadIds = groupThreadIds(eventState);
List<MemberIdentifier> orderedIds = new LinkedList();
Map<MemberIdentifier, Integer> seenIds = new HashMap();
// added in 7.0 for version tag processing in fromData
myId.writeEssentialData(dop);
for (MemberIdentifier memberId : groupedThreadIds.keySet()) {
if (!seenIds.containsKey(memberId)) {
orderedIds.add(memberId);
seenIds.put(memberId, Integer.valueOf(seenIds.size()));
}
}
dop.writeInt(seenIds.size());
for (MemberIdentifier memberId : orderedIds) {
DataSerializer.writeByteArray(memberId.bytes, dop);
}
dop.writeInt(groupedThreadIds.size());
for (Map.Entry<MemberIdentifier, Map<ThreadIdentifier, Object>> memberIdEntry : groupedThreadIds.entrySet()) {
MemberIdentifier memberId = memberIdEntry.getKey();
dop.writeInt(seenIds.get(memberId).intValue());
Map<ThreadIdentifier, Object> threadIdMap = memberIdEntry.getValue();
dop.writeInt(threadIdMap.size());
for (Object next : threadIdMap.entrySet()) {
Map.Entry entry = (Map.Entry) next;
ThreadIdentifier key = (ThreadIdentifier) entry.getKey();
dop.writeLong(key.getThreadID());
if (isHARegion) {
DispatchedAndCurrentEvents value = (DispatchedAndCurrentEvents) entry.getValue();
InternalDataSerializer.invokeToData(value, dop);
} else {
EventSeqnoHolder value = (EventSeqnoHolder) entry.getValue();
InternalDataSerializer.invokeToData(value, dop);
}
}
}
}
use of org.apache.geode.internal.cache.EventTracker.EventSeqnoHolder in project geode by apache.
the class EventStateHelper method fromData.
/**
* Post 7.1, if changes are made to this method make sure that it is backwards compatible by
* creating fromDataPreXX methods. Also make sure that the callers to this method are backwards
* compatible by creating fromDataPreXX methods for them even if they are not changed. <br>
* Callers for this method are: <br>
* {@link CreateRegionReplyMessage#fromData(DataInput)} <br>
* {@link RegionStateMessage#fromData(DataInput)} <br>
*/
public static Map fromData(DataInput dip, boolean isHARegion) throws IOException, ClassNotFoundException {
InternalDistributedMember senderId = InternalDistributedMember.readEssentialData(dip);
int numIds = dip.readInt();
Map<Integer, byte[]> numberToMember = new HashMap();
for (int i = 0; i < numIds; i++) {
numberToMember.put(Integer.valueOf(i), DataSerializer.readByteArray(dip));
}
int size = dip.readInt();
HashMap eventState = new HashMap(size);
for (int i = 0; i < size; i++) {
int idNumber = dip.readInt();
int subMapSize = dip.readInt();
for (int j = 0; j < subMapSize; j++) {
long threadId = dip.readLong();
ThreadIdentifier key = new ThreadIdentifier(numberToMember.get(idNumber), threadId);
if (isHARegion) {
DispatchedAndCurrentEvents value = new DispatchedAndCurrentEvents();
InternalDataSerializer.invokeFromData(value, dip);
eventState.put(key, value);
} else {
EventSeqnoHolder value = new EventSeqnoHolder();
InternalDataSerializer.invokeFromData(value, dip);
eventState.put(key, value);
if (value.versionTag != null) {
value.versionTag.replaceNullIDs(senderId);
}
}
}
}
return eventState;
}
Aggregations