Search in sources :

Example 1 with CountableThreadPool

use of us.codecraft.webmagic.thread.CountableThreadPool in project webmagic by code4craft.

the class Spider method initComponent.

protected void initComponent() {
    if (downloader == null) {
        this.downloader = new HttpClientDownloader();
    }
    if (pipelines.isEmpty()) {
        pipelines.add(new ConsolePipeline());
    }
    downloader.setThread(threadNum);
    if (threadPool == null || threadPool.isShutdown()) {
        if (executorService != null && !executorService.isShutdown()) {
            threadPool = new CountableThreadPool(threadNum, executorService);
        } else {
            threadPool = new CountableThreadPool(threadNum);
        }
    }
    if (startRequests != null) {
        for (Request request : startRequests) {
            addRequest(request);
        }
        startRequests.clear();
    }
    startTime = new Date();
}
Also used : HttpClientDownloader(us.codecraft.webmagic.downloader.HttpClientDownloader) ConsolePipeline(us.codecraft.webmagic.pipeline.ConsolePipeline) CountableThreadPool(us.codecraft.webmagic.thread.CountableThreadPool)

Aggregations

HttpClientDownloader (us.codecraft.webmagic.downloader.HttpClientDownloader)1 ConsolePipeline (us.codecraft.webmagic.pipeline.ConsolePipeline)1 CountableThreadPool (us.codecraft.webmagic.thread.CountableThreadPool)1