Iterator<String> sequenceKeyIterator = sequences.keySet().iterator();
while (sequenceKeyIterator.hasNext()) {
String key = sequenceKeyIterator.next();
AbstractSequence sequence = sequences.get(key);
if (shouldRemove(sequence)) {
LOGGER.config(LocalizationMessages.WSRM_1152_REMOVING_SEQUENCE(sequence.getId()));
sequenceKeyIterator.remove();
PersistentSequenceData.remove(cm, uniqueEndpointId, sequence.getId());
if (boundSequences.containsKey(sequence.getId())) {
boundSequences.remove(sequence.getId());
}
if (localIDManager != null) {
// In RM_LOCALIDS table, mark all the LocalIDs tied with sequence as terminated
// In future, consider add some config/logic to purege those long been terminated
localIDManager.markSequenceTermination(sequence.getId());
}
} else if (shouldTeminate(sequence)) {
LOGGER.config(LocalizationMessages.WSRM_1153_TERMINATING_SEQUENCE(sequence.getId()));
tryTerminateSequence(sequence.getId());
}
}
}
return continueMaintenance;