Java AtomicInteger getFailedMiddlePartNumbers(PartListing partListing)

Here you can find the source of getFailedMiddlePartNumbers(PartListing partListing)

Description

get Failed Middle Part Numbers

License

Apache License

Declaration

static Set<Integer> getFailedMiddlePartNumbers(PartListing partListing) 

Method Source Code

    //package com.java2s;
    //License from project: Apache License 

    import com.amazonaws.services.s3.model.PartListing;
    import com.amazonaws.services.s3.model.PartSummary;

    import java.util.Set;
    import java.util.concurrent.atomic.AtomicInteger;
    import java.util.stream.Collectors;
    import java.util.stream.IntStream;

    public class Main {
        static Set<Integer> getFailedMiddlePartNumbers(PartListing partListing) {
    AtomicInteger lastPartNumber = new AtomicInteger(0);
    Set<Integer> uploadedParts = partListing.getParts().stream()
            .map(PartSummary::getPartNumber)
            .peek(n -> {//  w  ww.  ja  v a 2s  .  c  om
                if (lastPartNumber.get() < n) {
                    lastPartNumber.set(n);
                }
            })
            .collect(Collectors.toSet());

    return IntStream.range(1, lastPartNumber.get())
            .filter(n -> !uploadedParts.contains(n))
            .boxed()
            .collect(Collectors.toSet());
}
    }

Related

  1. getAllocationFailureCount()
  2. getAndResetInvocationCount()
  3. getAndResetInvocationCount()
  4. getCriticalExceptionCount()
  5. getExceptionCountMap()
  6. getGetPendingWrTransaction()
  7. getGuid(Object clazz)
  8. getId()
  9. getInstanceCounter(String name)