GuozhongCrawler系列教程 (5) TransactionRequest具體解釋
阿新 • • 發佈:2017-06-05
crawler 是個 回調 指定 ng- shc util line page
為了實現和維護並發抓取的屬性信息提供線程安全的事務請求。TransactionRequest是一個抽象類自己不能設置Processor,卻須要實現 TransactionCallBack接口。TransactionRequest是個復合的BasicRequest。他能夠將多個PageRequest、BinaryRequest甚至TransactionRequest 自己的對象加入到child集合中,在下載過程中首先下載TransactionRequest中的全部childRequest。每一個childRequest下載完畢後使用notify方式逐步向上通知。 直到全部的child下載完畢TransactionRequest回調 TransactionCallBack的callBack方法通知業務層這個TransactionRequest下載完畢。
方法具體資料
-
getPipeline
public Pipeline getPipeline()
-
setPipeline
public void setPipeline(Pipeline pipeline)
-
addAttribute
public BasicRequest addAttribute(java.lang.String attribute, java.lang.Object value)
從類復制的說明:BasicRequest
設置屬性- 指定者:
addAttribute
在類中BasicRequest
- 返回:
- 返回BasicRequest對象自身
-
getAttribute
public java.lang.Object getAttribute(java.lang.String attribute)
從類復制的說明:BasicRequest
取得屬性- 指定者:
getAttribute
在類中BasicRequest
- 返回:
- 返回attribute屬性相應的value。沒有則返回null
-
addChildRequest
public void addChildRequest(BasicRequest request)
加入一個BasicRequest到TransactionRequest的child中- 參數:
request
-
- 參數:
-
iteratorChildRequests
public java.util.Iterator<BasicRequest> iteratorChildRequests()
返回這個TransactionRequest全部child的叠代器- 返回:
-
notify
public void notify(int hashcode)
從類復制的說明:BasicRequest
當子url或者當前url完畢的時候回調- 覆蓋:
notify
在類中BasicRequest
- 參數:
hashcode
- 實際Request的hashCode
-
checkComplete
public void checkComplete()
檢查是否全部的Request標記都不是false。假設是那麽全部的Request已經請求完畢和處理。
GuozhongCrawler系列教程 (5) TransactionRequest具體解釋