📄 frontier.html
字号:
<a name="152" href="#152">152</a> <em>/**<em>*</em></em><a name="153" href="#153">153</a> <em> * Returns true if the frontier contains no more URIs to crawl.</em><a name="154" href="#154">154</a> <em> *</em><a name="155" href="#155">155</a> <em> * <p>That is to say that there are no more URIs either currently availible</em><a name="156" href="#156">156</a> <em> * (ready to be emitted), URIs belonging to deferred hosts or pending URIs</em><a name="157" href="#157">157</a> <em> * in the Frontier. Thus this method may return false even if there is no</em><a name="158" href="#158">158</a> <em> * currently availible URI.</em><a name="159" href="#159">159</a> <em> *</em><a name="160" href="#160">160</a> <em> * @return true if the frontier contains no more URIs to crawl.</em><a name="161" href="#161">161</a> <em> */</em><a name="162" href="#162">162</a> <strong>boolean</strong> isEmpty();<a name="163" href="#163">163</a> <a name="164" href="#164">164</a> <em>/**<em>*</em></em><a name="165" href="#165">165</a> <em> * Schedules a CandidateURI.</em><a name="166" href="#166">166</a> <em> *</em><a name="167" href="#167">167</a> <em> * <p>This method accepts one URI and schedules it immediately. This has</em><a name="168" href="#168">168</a> <em> * nothing to do with the priority of the URI being scheduled. Only that</em><a name="169" href="#169">169</a> <em> * it will be placed in it's respective queue at once. For priority</em><a name="170" href="#170">170</a> <em> * scheduling see {@link CandidateURI#setSchedulingDirective(int)}</em><a name="171" href="#171">171</a> <em> *</em><a name="172" href="#172">172</a> <em> * <p>This method should be synchronized in all implementing classes.</em><a name="173" href="#173">173</a> <em> *</em><a name="174" href="#174">174</a> <em> * @param caURI The URI to schedule.</em><a name="175" href="#175">175</a> <em> *</em><a name="176" href="#176">176</a> <em> * @see CandidateURI#setSchedulingDirective(int)</em><a name="177" href="#177">177</a> <em> */</em><a name="178" href="#178">178</a> <strong>public</strong> <strong>void</strong> schedule(<a href="../../../../org/archive/crawler/datamodel/CandidateURI.html">CandidateURI</a> caURI);<a name="179" href="#179">179</a> <a name="180" href="#180">180</a> <em>/**<em>*</em></em><a name="181" href="#181">181</a> <em> * Report a URI being processed as having finished processing.</em><a name="182" href="#182">182</a> <em> *</em><a name="183" href="#183">183</a> <em> * <p>ToeThreads will invoke this method once they have completed work on</em><a name="184" href="#184">184</a> <em> * their assigned URI.</em><a name="185" href="#185">185</a> <em> *</em><a name="186" href="#186">186</a> <em> * <p>This method is synchronized.</em><a name="187" href="#187">187</a> <em> *</em><a name="188" href="#188">188</a> <em> * @param cURI The URI that has finished processing.</em><a name="189" href="#189">189</a> <em> */</em><a name="190" href="#190">190</a> <strong>public</strong> <strong>void</strong> finished(<a href="../../../../org/archive/crawler/datamodel/CrawlURI.html">CrawlURI</a> cURI);<a name="191" href="#191">191</a> <a name="192" href="#192">192</a> <em>/**<em>*</em></em><a name="193" href="#193">193</a> <em> * Number of <i>discovered</i> URIs.</em><a name="194" href="#194">194</a> <em> *</em><a name="195" href="#195">195</a> <em> * <p>That is any URI that has been confirmed be within 'scope'</em><a name="196" href="#196">196</a> <em> * (i.e. the Frontier decides that it should be processed). This</em><a name="197" href="#197">197</a> <em> * includes those that have been processed, are being processed</em><a name="198" href="#198">198</a> <em> * and have finished processing. Does not include URIs that have</em><a name="199" href="#199">199</a> <em> * been 'forgotten' (deemed out of scope when trying to fetch,</em><a name="200" href="#200">200</a> <em> * most likely due to operator changing scope definition).</em><a name="201" href="#201">201</a> <em> *</em><a name="202" href="#202">202</a> <em> * <p><b>Note:</b> This only counts discovered URIs. Since the same</em><a name="203" href="#203">203</a> <em> * URI can (at least in most frontiers) be fetched multiple times, this</em><a name="204" href="#204">204</a> <em> * number may be somewhat lower then the combined <i>queued</i>,</em><a name="205" href="#205">205</a> <em> * <i>in process</i> and <i>finished</i> items combined due to duplicate</em><a name="206" href="#206">206</a> <em> * URIs being queued and processed. This variance is likely to be especially</em><a name="207" href="#207">207</a> <em> * high in Frontiers implementing 'revist' strategies.</em><a name="208" href="#208">208</a> <em> *</em><a name="209" href="#209">209</a> <em> * @return Number of discovered URIs.</em><a name="210" href="#210">210</a> <em> */</em><a name="211" href="#211">211</a> <strong>public</strong> <strong>long</strong> discoveredUriCount();<a name="212" href="#212">212</a> <a name="213" href="#213">213</a> <em>/**<em>*</em></em><a name="214" href="#214">214</a> <em> * Number of URIs <i>queued</i> up and waiting for processing.</em><a name="215" href="#215">215</a> <em> *</em><a name="216" href="#216">216</a> <em> * <p>This includes any URIs that failed but will be retried. Basically this</em><a name="217" href="#217">217</a> <em> * is any <i>discovered</i> URI that has not either been processed or is</em><a name="218" href="#218">218</a> <em> * being processed. The same discovered URI can be queued multiple times.</em><a name="219" href="#219">219</a> <em> *</em><a name="220" href="#220">220</a> <em> * @return Number of queued URIs.</em><a name="221" href="#221">221</a> <em> */</em><a name="222" href="#222">222</a> <strong>public</strong> <strong>long</strong> queuedUriCount();<a name="223" href="#223">223</a> <a name="224" href="#224">224</a> <strong>public</strong> <strong>long</strong> deepestUri(); <em class="comment">// aka longest queue</em><a name="225" href="#225">225</a> <strong>public</strong> <strong>long</strong> averageDepth(); <em class="comment">// aka average queue length</em><a name="226" href="#226">226</a> <strong>public</strong> <strong>float</strong> congestionRatio(); <em class="comment">// multiple of threads needed for max progress</em><a name="227" href="#227">227</a> <a name="228" href="#228">228</a> <em>/**<em>*</em></em><a name="229" href="#229">229</a> <em> * Number of URIs that have <i>finished</i> processing.</em><a name="230" href="#230">230</a> <em> *</em><a name="231" href="#231">231</a> <em> * <p>Includes both those that were processed successfully and failed to be</em><a name="232" href="#232">232</a> <em> * processed (excluding those that failed but will be retried). Does not</em><a name="233" href="#233">233</a> <em> * include those URIs that have been 'forgotten' (deemed out of scope when</em><a name="234" href="#234">234</a> <em> * trying to fetch, most likely due to operator changing scope definition).</em><a name="235" href="#235">235</a> <em> *</em><a name="236" href="#236">236</a> <em> * @return Number of finished URIs.</em><a name="237" href="#237">237</a> <em> */</em><a name="238" href="#238">238</a> <strong>public</strong> <strong>long</strong> finishedUriCount();<a name="239" href="#239">239</a> <a name="240" href="#240">240</a> <em>/**<em>*</em></em><a name="241" href="#241">241</a> <em> * Number of <i>successfully</i> processed URIs.</em><a name="242" href="#242">242</a> <em> *</em><a name="243" href="#243">243</a> <em> * <p>Any URI that was processed successfully. This includes URIs that</em><a name="244" href="#244">244</a> <em> * returned 404s and other error codes that do not originate within the</em><a name="245" href="#245">245</a> <em> * crawler.</em><a name="246" href="#246">246</a> <em> *</em><a name="247" href="#247">247</a> <em> * @return Number of <i>successfully</i> processed URIs.</em><a name="248" href="#248">248</a> <em> */</em><a name="249" href="#249">249</a> <strong>public</strong> <strong>long</strong> succeededFetchCount();<a name="250" href="#250">250</a> <a name="251" href="#251">251</a> <em>/**<em>*</em></em><a name="252" href="#252">252</a> <em> * Number of URIs that <i>failed</i> to process.</em><a name="253" href="#253">253</a> <em> *</em><a name="254" href="#254">254</a> <em> * <p>URIs that could not be processed because of some error or failure in</em><a name="255" href="#255">255</a> <em> * the processing chain. Can include failure to acquire prerequisites, to</em><a name="256" href="#256">256</a> <em> * establish a connection with the host and any number of other problems.</em><a name="257" href="#257">257</a> <em> * Does not count those that will be retried, only those that have</em><a name="258" href="#258">258</a> <em> * permenantly failed.</em><a name="259" href="#259">259</a> <em> *</em><a name="260" href="#260">260</a> <em> * @return Number of URIs that failed to process.</em><a name="261" href="#261">261</a> <em> */</em><a name="262" href="#262">262</a> <strong>public</strong> <strong>long</strong> failedFetchCount();<a name="263" href="#263">263</a> <a name="264" href="#264">264</a> <em>/**<em>*</em></em><a name="265" href="#265">265</a> <em> * Number of URIs that were scheduled at one point but have been</em><a name="266" href="#266">266</a> <em> * <i>disregarded</i>.</em><a name="267" href="#267">267</a> <em> *</em><a name="268" href="#268">268</a> <em> * <p>Counts any URI that is scheduled only to be disregarded</em><a name="269" href="#269">269</a> <em> * because it is determined to lie outside the scope of the crawl. Most</em><a name="270" href="#270">270</a> <em> * commonly this will be due to robots.txt exclusions.</em><a name="271" href="#271">271</a> <em> *</em><a name="272" href="#272">272</a> <em> * @return The number of URIs that have been disregarded.</em><a name="273" href="#273">273</a> <em> */</em><a name="274" href="#274">274</a> <strong>public</strong> <strong>long</strong> disregardedUriCount();<a name="275" href="#275">275</a> <a name="276" href="#276">276</a> <em>/**<em>*</em></em><a name="277" href="#277">277</a> <em> * Total number of bytes contained in all URIs that have been processed.</em><a name="278" href="#278">278</a> <em> *</em><a name="279" href="#279">279</a> <em> * @return The total amounts of bytes in all processed URIs.</em><a name="280" href="#280">280</a> <em> */</em><a name="281" href="#281">281</a> <strong>public</strong> <strong>long</strong> totalBytesWritten();<a name="282" href="#282">282</a> <a name="283" href="#283">283</a> <em>/**<em>*</em></em><a name="284" href="#284">284</a> <em> * Recover earlier state by reading a recovery log.</em><a name="285" href="#285">285</a> <em> *</em><a name="286" href="#286">286</a> <em> * <p>Some Frontiers are able to write detailed logs that can be loaded</em><a name="287" href="#287">287</a> <em> * after a system crash to recover the state of the Frontier prior to the</em><a name="288" href="#288">288</a> <em> * crash. This method is the one used to achive this.</em><a name="289" href="#289">289</a> <em> *</em><a name="290" href="#290">290</a> <em> * @param pathToLog The name (with full path) of the recover log.</em><a name="291" href="#291">291</a> <em> * @param retainFailures If true, failures in log should count as </em><a name="292" href="#292">292</a> <em> * having been included. (If false, failures will be ignored, meaning</em><a name="293" href="#293">293</a> <em> * the corresponding URIs will be retried in the recovered crawl.)</em><a name="294" href="#294">294</a> <em> * @throws IOException If problems occur reading the recover log.</em><a name="295" href="#295">295</a> <em> */</em><a name="296" href="#296">296</a> <strong>public</strong> <strong>void</strong> importRecoverLog(String pathToLog, <strong>boolean</strong> retainFailures)<a name="297" href="#297">297</a> throws IOException;<a name="298" href="#298">298</a> <a name="299" href="#299">299</a> <em>/**<em>*</em></em><a name="300" href="#300">300</a> <em> * Get a <code>URIFrontierMarker</code> initialized with the given</em><a name="301" href="#301">301</a> <em> * regular expression at the 'start' of the Frontier.</em><a name="302" href="#302">302</a> <em> * @param regexpr The regular expression that URIs within the frontier must</em><a name="303" href="#303">303</a> <em> * match to be considered within the scope of this marker</em><a name="304" href="#304">304</a> <em> * @param inCacheOnly If set to true, only those URIs within the frontier</em><a name="305" href="#305">305</a> <em> * that are stored in cache (usually this means in memory</em><a name="306" href="#306">306</a> <em> * rather then on disk, but that is an implementation</em><a name="307" href="#307">307</a> <em> * detail) will be considered. Others will be entierly</em><a name="308" href="#308">308</a> <em> * ignored, as if they dont exist. This is usefull for quick</em><a name="309" href="#309">309</a> <em> * peeks at the top of the URI list.</em><a name="310" href="#310">310</a> <em> * @return A URIFrontierMarker that is set for the 'start' of the frontier's</em><a name="311" href="#311">311</a> <em> * URI list.</em>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -