/** * Given a collection of MSentryChange instances sorted by ID return true if and only if IDs are sequential (do not contain holes) * <p> * e.g: * <li> Input: [MSentryChange(1), MSentryChange(2), MSentryChange(3), MSentryChange(5), MSentryChange(7)] </li> * <li> Output: False </li> * <li> Input: [MSentryChange(1), MSentryChange(2), MSentryChange(3), MSentryChange(4), MSentryChange(5)] </li> * <li> Output: True </li> * </p> * @param changes List of {@link MSentryChange} * @return True if all the ids are sequential otherwise returns False */ public static boolean isConsecutive(List<? extends MSentryChange> changes) { int size = changes.size(); return (size <= 1) || (changes.get(size - 1).getChangeID() - changes.get(0).getChangeID() + 1 == size); }
/** * Given a collection of MSentryChange's, retrieve the change id's associated and return as a list * <p> * e.g: * <li> Input: [MSentryChange(1), MSentryChange(2), MSentryChange(3), MSentryChange(5), MSentryChange(7)] </li> * <li> Output: [1, 2, 3, 5 ,7] </li> * </p> * @param changes List of {@link MSentryChange} * @return List of changeID's */ private static List<Long> getChangeIds(Collection<? extends MSentryChange> changes) { List<Long> ids = changes.isEmpty() ? Collections.<Long>emptyList() : new ArrayList<Long>(changes.size()); for (MSentryChange change : changes) { ids.add(change.getChangeID()); } return ids; }
if (changes.get(0).getChangeID() != changeID) { LOGGER.debug(String.format("Starting delta change from %s is off from the requested id. " + "Requested changeID: %s, Missing delta count: %s", changes.get(0).getClass().getCanonicalName(), changeID, changes.get(0).getChangeID() - changeID)); return false;