Refine search
@Override public KinesisMessageId getNextFailedMessageToRetry() { KinesisMessageId result = null; // return the first message to be retried from the set. It will return the message with the earliest retry time <= current time if (!retryMessageSet.isEmpty() ) { result = retryMessageSet.first(); if (!(retryTimes.get(result) <= System.nanoTime())) { result = null; } } LOG.debug("Returning {} to spout for retrying.", result); return result; }
/** * Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in * this range. */ public boolean containsAll(Iterable<? extends C> values) { if (Iterables.isEmpty(values)) { return true; } // this optimizes testing equality of two range-backed sets if (values instanceof SortedSet) { SortedSet<? extends C> set = cast(values); Comparator<?> comparator = set.comparator(); if (Ordering.natural().equals(comparator) || comparator == null) { return contains(set.first()) && contains(set.last()); } } for (C value : values) { if (!contains(value)) { return false; } } return true; }
public static void main(String[] args) { SortedSet<Integer> set=new TreeSet<>(); for(int i=0; i < args.length; i++) { set.add(Integer.parseInt(args[i])); } int low=set.first(), high=set.last(); System.out.println("input has " + set.size() + " numbers, low=" + low + ", high=" + high); Set<Integer> correct_set=new HashSet<>(); for(int i=low; i < high; i++) { correct_set.add(i); } correct_set.removeAll(set); System.out.println("missing seqnos: " + correct_set); } }
public void commitState() { try { long lastOffset = 0; if (pendingOffsets.isEmpty() || pendingOffsets.size() <= 0) { lastOffset = emittingOffset; } else { lastOffset = pendingOffsets.first(); } if (lastOffset != lastCommittedOffset) { Map<Object, Object> data = new HashMap<Object, Object>(); data.put("topology", stormConf.get(Config.TOPOLOGY_NAME)); data.put("offset", lastOffset); data.put("partition", partition); data.put("broker", ImmutableMap.of("host", consumer.getLeaderBroker().host(), "port", consumer.getLeaderBroker().port())); data.put("topic", config.topic); zkState.writeJSON(zkPath(), data); lastCommittedOffset = lastOffset; } } catch (Exception e) { LOG.error(e.getMessage(), e); } }
@Override protected SortedSet<Integer> create(Integer[] elements) { SortedSet<Integer> set = nullCheckedTreeSet(elements); if (set.isEmpty()) { /* * The (tooLow + 1, tooHigh) arguments below would be invalid because tooLow would be * greater than tooHigh. */ return ContiguousSet.create(Range.openClosed(0, 1), DiscreteDomain.integers()).subSet(0, 1); } int tooHigh = set.last() + 1; int tooLow = set.first() - 1; set.add(tooHigh); set.add(tooLow); return checkedCreate(set).subSet(tooLow + 1, tooHigh); } }
public String department() { int numberOfDepartments = Math.max(faker.random().nextInt(4), 1); SortedSet<String> departments = new TreeSet<String>(); while (departments.size() < numberOfDepartments) { departments.add(faker.fakeValuesService().resolve("commerce.department", this, faker)); } if (departments.size() > 1) { String lastDepartment = departments.last(); return StringUtils.join(departments.headSet(lastDepartment), ", ") + " & " + lastDepartment; } else { return departments.first(); } }
/** * Returns the value which matches the given destination or null if there is * no matching value. If there are multiple values, the results are sorted * and the last item (the biggest) is returned. * * @param destination the destination to find the value for * @return the largest matching value or null if no value matches */ @SuppressWarnings({"rawtypes", "unchecked"}) public DestinationMapEntry chooseValue(final ActiveMQDestination destination) { Set<DestinationMapEntry> set = get(destination); if (set == null || set.isEmpty()) { return null; } //Comparator to sort in order - we want to pick the exact match by destination or the //closest parent that applies final Comparator<DestinationMapEntry> comparator = new Comparator<DestinationMapEntry>() { @Override public int compare(DestinationMapEntry entry1, DestinationMapEntry entry2) { return destination.equals(entry1.destination) ? -1 : (destination.equals(entry2.destination) ? 1 : entry1.compareTo(entry2)); } }; //Sort and filter out any children and non matching entries final SortedSet<DestinationMapEntry> sortedSet = set.stream() .filter(entry -> isMatchOrParent(destination, (DestinationMapEntry)entry)) .collect(Collectors.toCollection(() -> new TreeSet<DestinationMapEntry>(comparator))); return sortedSet.size() > 0 ? sortedSet.first() : null; }
/** * Returns the minimal range that {@linkplain Range#contains(Comparable) contains} all of the * given values. The returned range is {@linkplain BoundType#CLOSED closed} on both ends. * * @throws ClassCastException if the values are not mutually comparable * @throws NoSuchElementException if {@code values} is empty * @throws NullPointerException if any of {@code values} is null * @since 14.0 */ public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) { checkNotNull(values); if (values instanceof SortedSet) { SortedSet<? extends C> set = cast(values); Comparator<?> comparator = set.comparator(); if (Ordering.natural().equals(comparator) || comparator == null) { return closed(set.first(), set.last()); } } Iterator<C> valueIterator = values.iterator(); C min = checkNotNull(valueIterator.next()); C max = min; while (valueIterator.hasNext()) { C value = checkNotNull(valueIterator.next()); min = Ordering.natural().min(min, value); max = Ordering.natural().max(max, value); } return closed(min, max); }
if (deleteVersionMvccs != null) { SortedSet<Long> tail = deleteVersionMvccs.tailSet(cell.getSequenceId()); if (!tail.isEmpty()) { deleteMvcc = tail.first(); .subMap(cell.getSequenceId(), true, Math.min(duplicateMvcc, deleteMvcc), true); for (Map.Entry<Long, SortedSet<Long>> seg : subMap.entrySet()) { if (seg.getValue().size() >= maxVersions) { return DeleteResult.VERSION_MASKED;
public Configuration(Set<Pipeline> pipelines) { if (pipelines.isEmpty()) { initialStage = extent[0] = extent[1] = 0; return; } pipelines.forEach(pipeline -> { // skip pipelines without any stages, they don't contribute any rules to run final SortedSet<Stage> stages = pipeline.stages(); if (stages.isEmpty()) { return; } extent[0] = Math.min(extent[0], stages.first().stage()); extent[1] = Math.max(extent[1], stages.last().stage()); stages.forEach(stage -> stageMultimap.put(stage.stage(), stage)); }); if (extent[0] == Integer.MIN_VALUE) { throw new IllegalArgumentException("First stage cannot be at " + Integer.MIN_VALUE); } // the stage before the first stage. initialStage = extent[0] - 1; }
@Test(groups = "fast") public void testUnpaidInvoices() { final BillingStateCalculator calc = createBSCalc(); final SortedSet<Invoice> invoices = calc.unpaidInvoicesForAccount(new UUID(0L, 0L), internalCallContext); Assert.assertEquals(invoices.size(), 3); Assert.assertEquals(BigDecimal.ZERO.compareTo(invoices.first().getBalance()), 0); Assert.assertEquals(new BigDecimal("100.0").compareTo(invoices.last().getBalance()), 0); }
if (st != null && st.size() != 0) { sec = st.first(); } else { sec = seconds.first(); if (st != null && st.size() != 0) { t = min; min = st.first(); } else { min = minutes.first(); if (st != null && st.size() != 0) { t = hr; hr = st.first(); } else { hr = hours.first(); } else if (st != null && st.size() != 0) { t = day; day = st.first(); if (st != null && st.size() > 0) { dow = st.first(); if (st != null && st.size() != 0) { t = mon; mon = st.first(); } else { mon = months.first();
/** * Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in * this range. */ public boolean containsAll(Iterable<? extends C> values) { if (Iterables.isEmpty(values)) { return true; } // this optimizes testing equality of two range-backed sets if (values instanceof SortedSet) { SortedSet<? extends C> set = cast(values); Comparator<?> comparator = set.comparator(); if (Ordering.natural().equals(comparator) || comparator == null) { return contains(set.first()) && contains(set.last()); } } for (C value : values) { if (!contains(value)) { return false; } } return true; }
public Integer getNextMatch(int currentSecond) { if (this.scheduleExpressionType == ScheduleExpressionType.WILDCARD) { return currentSecond; } if (this.absoluteValues.isEmpty()) { return null; } for (Integer second : this.absoluteValues) { if (currentSecond == second) { return currentSecond; } if (second > currentSecond) { return second; } } return this.absoluteValues.first(); }