下面列出了java.util.concurrent.ConcurrentLinkedDeque#addAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* addAll(null) throws NPE
*/
public void testAddAll1() {
ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
try {
q.addAll(null);
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* addAll(this) throws IAE
*/
public void testAddAllSelf() {
ConcurrentLinkedDeque q = populatedDeque(SIZE);
try {
q.addAll(q);
shouldThrow();
} catch (IllegalArgumentException success) {}
}
/**
* addAll of a collection with null elements throws NPE
*/
public void testAddAll2() {
ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
try {
q.addAll(Arrays.asList(new Integer[SIZE]));
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* addAll of a collection with any null elements throws NPE after
* possibly adding some elements
*/
public void testAddAll3() {
ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
Integer[] ints = new Integer[SIZE];
for (int i = 0; i < SIZE - 1; ++i)
ints[i] = new Integer(i);
try {
q.addAll(Arrays.asList(ints));
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* addAll(null) throws NPE
*/
public void testAddAll1() {
ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
try {
q.addAll(null);
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* addAll(this) throws IAE
*/
public void testAddAllSelf() {
ConcurrentLinkedDeque q = populatedDeque(SIZE);
try {
q.addAll(q);
shouldThrow();
} catch (IllegalArgumentException success) {}
}
/**
* addAll of a collection with null elements throws NPE
*/
public void testAddAll2() {
ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
try {
q.addAll(Arrays.asList(new Integer[SIZE]));
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* addAll of a collection with any null elements throws NPE after
* possibly adding some elements
*/
public void testAddAll3() {
ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
Integer[] ints = new Integer[SIZE];
for (int i = 0; i < SIZE - 1; ++i)
ints[i] = new Integer(i);
try {
q.addAll(Arrays.asList(ints));
shouldThrow();
} catch (NullPointerException success) {}
}
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);
}
}
public ConcurrentLinkedDeque<DedupValue> getDedupValuesInConcurrentLinkedDeque() {
ConcurrentLinkedDeque<DedupValue> result = new ConcurrentLinkedDeque<DedupValue>();
result.addAll(this.getDedupValues());
return result;
}