nutch2.3.1 updatejob时错误url导致崩溃
2016-11-01 15:21
253 查看
原因可能是错误的html解析出来的
在DbUpdateMapper.java的map时加个trycatch
在DbUpdateMapper.java的map时加个trycatch
55 @Override 56 public void map(String key, WebPage page, Context context) 57 throws IOException, InterruptedException { 58 if (Mark.GENERATE_MARK.checkMark(page) == null) { 59 if (LOG.isDebugEnabled()) { 60 LOG.debug("Skipping " + TableUtil.unreverseUrl(key) 61 + "; not generated yet"); 62 } 63 return; 64 } 65 66 String url = TableUtil.unreverseUrl(key); 67 68 scoreData.clear(); 69 Map<CharSequence, CharSequence> outlinks = page.getOutlinks(); 70 if (outlinks != null) { 71 for (Entry<CharSequence, CharSequence> e : outlinks.entrySet()) { 72 int depth = Integer.MAX_VALUE; 73 CharSequence depthUtf8 = page.getMarkers().get(DbUpdaterJob.DISTANCE); 74 if (depthUtf8 != null) 75 depth = Integer.parseInt(depthUtf8.toString()); // add here to filter error url 76 try { 77 String testUrl = TableUtil.reverseUrl(e.getKey().toString()); 78 } catch (MalformedURLException ex) { 79 LOG.warn("dbupdate,error url:" + e.getKey().toString()); 80 continue; 81 } 82 scoreData.add(new ScoreDatum(0.0f, e.getKey().toString(), e.getValue() 83 .toString(), depth)); 84 } 85 } 86 87 // TODO: Outlink filtering (i.e. "only keep the first n outlinks") 88 try { 89 scoringFilters.distributeScoreToOutlinks(url, page, scoreData, 90 (outlinks == null ? 0 : outlinks.size())); 91 } catch (ScoringFilterException e) { 92 LOG.warn("Distributing score failed for URL: " + key + " exception:" 93 + StringUtils.stringifyException(e)); 94 } 95 96 urlWithScore.setUrl(key); 97 urlWithScore.setScore(Float.MAX_VALUE); 98 pageWritable.setWebPage(page); 99 nutchWritable.set(pageWritable); 100 context.write(urlWithScore, nutchWritable); 101 102 for (ScoreDatum scoreDatum : scoreData) { 103 String reversedOut = TableUtil.reverseUrl(scoreDatum.getUrl()); 104 scoreDatum.setUrl(url); 105 urlWithScore.setUrl(reversedOut); 106 urlWithScore.setScore(scoreDatum.getScore()); 107 nutchWritable.set(scoreDatum); 108 context.write(urlWithScore, nutchWritable); 109 } 110 }
相关文章推荐
- QSqlDatabase 数据库操作没有removeDatabase 导致程序崩溃(此文极有可能是错误的,仅作个人留档参考)
- [Flex]Flex Builder中网络监视器导致“访问URL时遇到安全性错误”
- 在iOS10中使用stringWithUTF8String时字符串部分显示错误,转换失败导致string为空,程序崩溃
- Spring MVC的Rest URL 被错误解析成jsp, 导致404错误(XML方式下@Controller和@RestController需要配置<mvc:annotation-driving/>)
- tableView的indexPath值错误导致删除崩溃
- 消息映射函数接口错误,导致release版崩溃!
- 关于错误android.os.TransactionTooLargeException导致的崩溃
- 内核模块里的一点错误直接导致系统崩溃
- Android常见的错误(1)——获得控件导致程序崩溃
- java.net.MalformedURLException: unknown protocol: c 这个错一般有两种原因导致: 1、URL协议、格式或者路径错误,
- [Flex]Flex Builder中网络监视器导致“访问URL时遇到安全性错误”
- URL错误导致WebLogic配置JDBC时找不到合适的驱动。
- 使用gdb调试内存重复释放导致的malloc_error_break错误崩溃
- Google Chrome 错误 (和诺顿冲突导致崩溃)
- 有个应用程序一运行就崩溃,查找是什么样的编程错误导致程序崩溃,该如何逐一测试每种错误
- [转]android 2.3.3底层错误导致js调用java程序崩溃
- django uwsgi 崩溃 导致502错误 超时导致504错误
- iOS :url中含有特殊字符导致访问错误怎么办
- nutch2.3.1 SolrDeleteDuplicates.java 去重时空指针崩溃
- 解决服务器返回错误数据格式导致Json解析出错造成app崩溃