private void onSuccess(ProducerJob job, List<String[]> results, LinkedBlockingDeque<String[]> responseQueue, ConcurrentLinkedDeque<ProducerJob> pagesToRetry) { int size = results.size(); if (size == GoogleWebmasterClient.API_ROW_LIMIT) { List<? extends ProducerJob> granularJobs = job.partitionJobs(); if (granularJobs.isEmpty()) { //The job is not divisible //TODO: 99.99% cases we are good. But what if it happens, what can we do? log.warn(String.format( "There might be more query data for your job %s. Currently, downloading more than the Google API limit '%d' is not supported.", job, GoogleWebmasterClient.API_ROW_LIMIT)); } else { log.info(String.format("Partition current job %s", job)); pagesToRetry.addAll(granularJobs); return; } } log.debug(String.format("Finished %s. Current Queue size: %d. Record size: %d.", job, responseQueue.size(), size)); try { for (String[] r : results) { responseQueue.put(r); } } catch (InterruptedException e) { log.error(e.getMessage()); throw new RuntimeException(e); } } }
allPages.addAll(pages);
.max(Integer::compareTo) .orElse(0); receivedUpdates.addAll(updates);
@Override default ConcurrentLinkedDeque<T> get(Collection<T> collection) { ConcurrentLinkedDeque<T> ret = new ConcurrentLinkedDeque<T>(); if(collection!=null){ ret.addAll(collection); } return ret; }
@Override default ConcurrentLinkedDeque<T> get(Collection<T> collection) { ConcurrentLinkedDeque<T> ret = new ConcurrentLinkedDeque<T>(); if(collection!=null){ ret.addAll(collection); } return ret; }
@Override public boolean addAll(Collection<? extends SourceRecord> c) { waitForCapacity(c.size()); return super.addAll(c); }
public ConcurrentLinkedDeque<DedupValue> getDedupValuesInConcurrentLinkedDeque() { ConcurrentLinkedDeque<DedupValue> result = new ConcurrentLinkedDeque<DedupValue>(); result.addAll(this.getDedupValues()); return result; }
private void onSuccess(ProducerJob job, List<String[]> results, LinkedBlockingDeque<String[]> responseQueue, ConcurrentLinkedDeque<ProducerJob> pagesToRetry) { int size = results.size(); if (size == GoogleWebmasterClient.API_ROW_LIMIT) { List<? extends ProducerJob> granularJobs = job.partitionJobs(); if (granularJobs.isEmpty()) { //The job is not divisible //TODO: 99.99% cases we are good. But what if it happens, what can we do? log.warn(String.format( "There might be more query data for your job %s. Currently, downloading more than the Google API limit '%d' is not supported.", job, GoogleWebmasterClient.API_ROW_LIMIT)); } else { log.info(String.format("Partition current job %s", job)); pagesToRetry.addAll(granularJobs); return; } } log.debug(String.format("Finished %s. Current Queue size: %d. Record size: %d.", job, responseQueue.size(), size)); try { for (String[] r : results) { responseQueue.put(r); } } catch (InterruptedException e) { log.error(e.getMessage()); throw new RuntimeException(e); } } }
allPages.addAll(pages);
private static void scanMembers( final File root, final ConcurrentLinkedDeque<MemberDescriptor> deque) throws IOException { final ASMReflector reflector = ASMReflector.getInstance(); reflector.scanClasses( root, (file, name, in) -> { ClassReader read = new ClassReader(in); String className = name; if (root.isDirectory()) { // path to package Set<File> roots = Collections.singleton(root); Optional<String> s = FileUtils.convertPathToClass(roots, file); if (s.isPresent()) { className = s.get(); } } ClassAnalyzeVisitor visitor = new ClassAnalyzeVisitor(className, name, false, false); read.accept(visitor, 0); List<MemberDescriptor> members = visitor.getMembers().stream() .filter(m -> m.isPublic() && m.isStatic()) .collect(Collectors.toList()); if (!members.isEmpty()) { deque.addAll(members); } }); }
/** * Instantiates a new Recycle bin. */ protected RecycleBin() { super(); purgeFreq = 10; RecycleBin.getGarbageTruck().scheduleAtFixedRate(() -> { buckets.forEach((k, v) -> { ObjectWrapper poll; ArrayList<ObjectWrapper> young = new ArrayList<>(); while (null != (poll = v.poll())) { if (poll.age() > purgeFreq) { T obj = poll.obj.get(); if (obj != null) { freeItem(obj, k); } } else { young.add(poll); } } v.addAll(young); }); }, purgeFreq, purgeFreq, TimeUnit.SECONDS); }
@Override public void run() { int index = hostIndex[random.nextInt(3)]; AlertStreamEvent e1 = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host" + index, String.format("testPolicy-host%s-01", index), states[random.nextInt(3)], 0, 0 }); List<AlertStreamEvent> result = deduplicator.dedup(e1); if (result != null) { System.out.println(">>>" + Joiner.on(",").join(result)); nonDedupResult.addAll(result); } else { System.out.println(">>>" + result); } }
@Override public void run() { int index = hostIndex[random.nextInt(3)]; AlertStreamEvent e1 = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host" + index, String.format("testPolicy-host%s-01", index), states[random.nextInt(3)], 0, 0 }); List<AlertStreamEvent> result = deduplicator.dedup(e1); if (result != null) { System.out.println(">>>" + Joiner.on(",").join(result)); nonDedupResult.addAll(result); } else { System.out.println(">>>" + result); } }
.max(Integer::compareTo) .orElse(0); receivedUpdates.addAll(updates);