`
fffddgx
  • 浏览: 38167 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

heritrix多线程探索

阅读更多

上午说的那个方法经过试验是不起作用的。

按照上面说的配置后开始抓取网页,发现还是单线程在ACTIVE,查看了order.xml发现还是HostNamesQueueAssignmentPolicy。(后来我才知道原来是因为我是用base one existing job创建JOB的,这样对于setting中没有提供设定的属性会继承下来,由于QUEUEASSIGNMENTPOLICY这个属性在setting中没有提供配置,所以就继承了那个existing job上的配置)看来文明的是不行了,我觉定用粗鲁的方法,没错就是该HostNamesQueueAssignmentPolicy这个类的getClassKey这个方法,结果运行确实快极了,基本上达到了我这的带宽上限。

后来发现大概抓了300多网页后就开始不抓了,我一开始觉得是不是网站把我的IP给封了,重新开始一个新的JOB后发现还是下到300多时就停了,郁闷死了,网上有人说是some of your queues have, as their topmost
items, unfetchable URIs. Certain kinds of failed-fetches go into a
slow-timeout retry-cycle, and while a URI is in this cycle, nothing else
from the same queue will be tried. This is a reasonable approach when
all URIs in a queue are subject to the same network failures, but can
cause problems if the queues are mixed, and the deeper URIs would
succeed quickly, but are stuck behind topmost URIs.

过了大概不到半小时,我又惊喜的发现又继续开始抓网页了,速度也相当快,我想应该是重试一段时间还是不能下载就放弃此uri,所以过了一段时间又恢复正常。

经过了一个多小时的下载,下了2千多的网页,理论上应该是至少5千才对,经过观察发现 seed report 抛出了 Domain prerequisite failure 这个异常,有5百多个种子没有下载成功,我在想是不是种子有点多还是怎么回事....

分享到:
评论
5 楼 fffddgx 2010-10-05  
不过当时按照这个方法我确实实现了多线程下载。这点是确定的。
4 楼 java_wzf 2010-09-13  
我说的是只需要 在HostnameQueueAssignmentPolicy方法里面加上

public String getClassKey(CrawlController controller, CandidateURI cauri) {
String uri = cauri.getUURI().toString();
long hash = ELFHash(uri);
String a = Long.toString(hash % 100);
return a;
}

public long ELFHash(String str) {
long hash = 0;
long x = 0;
for (int i = 0; i < str.length(); i++) {
hash = (hash << 4) + str.charAt(i);
if ((x = hash & 0xF0000000L) != 0) {
hash ^= (x >> 24);
hash &= ~x;
}
}
return (hash & 0x7FFFFFFF);
}


就够了吗?????
还要改什么其他配置文件吗
拜托请说明白一点。
我也是很挠头、、、、
3 楼 java_wzf 2010-09-13  
粗鲁的方法,要改什么东西啊,我用粗鲁的办法还是0~一个线程
2 楼 fffddgx 2010-05-15  
网上有个用elf算法重载getClassKey() 例子你可以找一下。好久没研究过这东西了。你自己找找看吧。
1 楼 liuxiao88 2010-05-02  
我也按照你的方法修改HostnameQueueAssignmentPolicy,但是做不到,真的很希望你能告诉我哦。我也是做毕设,这方面,研究了好久了,还是没办法。希望你看到后能加我qq,490228683.谢谢啊~

相关推荐

Global site tag (gtag.js) - Google Analytics