Revert "pageCount修改"

This reverts commit 9a71f0ac92.
pull/993/head
Sutra Zhou 4 years ago
parent 30daec4803
commit ab6ff7f809

@ -24,7 +24,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAdder;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
@ -103,7 +102,7 @@ public class Spider implements Runnable, Task {
private List<SpiderListener> spiderListeners;
private final LongAdder pageCount = new LongAdder();
private final AtomicLong pageCount = new AtomicLong(0);
private Date startTime;
@ -324,7 +323,7 @@ public class Spider implements Runnable, Task {
onError(request);
logger.error("process request " + request + " error", e);
} finally {
pageCount.increment();
pageCount.incrementAndGet();
signalNewUrl();
}
}
@ -336,7 +335,7 @@ public class Spider implements Runnable, Task {
if (destroyWhenExit) {
close();
}
logger.info("Spider {} closed! {} pages downloaded.", getUUID(), pageCount.sumThenReset());
logger.info("Spider {} closed! {} pages downloaded.", getUUID(), pageCount.get());
}
protected void onError(Request request) {
@ -651,7 +650,7 @@ public class Spider implements Runnable, Task {
* @since 0.4.1
*/
public long getPageCount() {
return pageCount.sum();
return pageCount.get();
}
/**

Loading…
Cancel
Save