?? bdbfrontier.html
字號:
<a name="228" href="#228">228</a> <strong>boolean</strong> inCacheOnly) {<a name="229" href="#229">229</a> <strong>return</strong> pendingUris.getInitialMarker(regexpr);<a name="230" href="#230">230</a> }<a name="231" href="#231">231</a> <a name="232" href="#232">232</a> <em>/**<em>*</em></em><a name="233" href="#233">233</a> <em> * Return list of urls.</em><a name="234" href="#234">234</a> <em> * @param marker</em><a name="235" href="#235">235</a> <em> * @param numberOfMatches</em><a name="236" href="#236">236</a> <em> * @param verbose </em><a name="237" href="#237">237</a> <em> * @return List of URIs (strings).</em><a name="238" href="#238">238</a> <em> */</em><a name="239" href="#239">239</a> <strong>public</strong> ArrayList<String> getURIsList(<a href="../../../../org/archive/crawler/framework/FrontierMarker.html">FrontierMarker</a> marker, <a name="240" href="#240">240</a> <strong>int</strong> numberOfMatches, <strong>final</strong> <strong>boolean</strong> verbose) {<a name="241" href="#241">241</a> List curis;<a name="242" href="#242">242</a> <strong>try</strong> {<a name="243" href="#243">243</a> curis = pendingUris.getFrom(marker, numberOfMatches);<a name="244" href="#244">244</a> } <strong>catch</strong> (DatabaseException e) {<a name="245" href="#245">245</a> e.printStackTrace();<a name="246" href="#246">246</a> <strong>throw</strong> <strong>new</strong> RuntimeException(e);<a name="247" href="#247">247</a> }<a name="248" href="#248">248</a> ArrayList<String> results = <strong>new</strong> ArrayList<String>(curis.size());<a name="249" href="#249">249</a> Iterator iter = curis.iterator();<a name="250" href="#250">250</a> <strong>while</strong>(iter.hasNext()) {<a name="251" href="#251">251</a> <a href="../../../../org/archive/crawler/datamodel/CrawlURI.html">CrawlURI</a> curi = (CrawlURI) iter.next();<a name="252" href="#252">252</a> results.add(<span class="string">"["</span>+curi.getClassKey()+<span class="string">"] "</span>+curi.singleLineReport());<a name="253" href="#253">253</a> }<a name="254" href="#254">254</a> <strong>return</strong> results;<a name="255" href="#255">255</a> }<a name="256" href="#256">256</a> <a name="257" href="#257">257</a> <strong>protected</strong> <strong>void</strong> initQueue() throws IOException {<a name="258" href="#258">258</a> <strong>try</strong> {<a name="259" href="#259">259</a> <strong>this</strong>.pendingUris = createMultipleWorkQueues();<a name="260" href="#260">260</a> } <strong>catch</strong>(DatabaseException e) {<a name="261" href="#261">261</a> <strong>throw</strong> (IOException)<strong>new</strong> IOException(e.getMessage()).initCause(e);<a name="262" href="#262">262</a> }<a name="263" href="#263">263</a> }<a name="264" href="#264">264</a> <a name="265" href="#265">265</a> <strong>protected</strong> <strong>void</strong> closeQueue() {<a name="266" href="#266">266</a> <strong>if</strong> (<strong>this</strong>.pendingUris != <strong>null</strong>) {<a name="267" href="#267">267</a> <strong>this</strong>.pendingUris.close();<a name="268" href="#268">268</a> <strong>this</strong>.pendingUris = <strong>null</strong>;<a name="269" href="#269">269</a> }<a name="270" href="#270">270</a> }<a name="271" href="#271">271</a> <a name="272" href="#272">272</a> <strong>protected</strong> <a href="../../../../org/archive/crawler/frontier/BdbMultipleWorkQueues.html">BdbMultipleWorkQueues</a> getWorkQueues() {<a name="273" href="#273">273</a> <strong>return</strong> pendingUris;<a name="274" href="#274">274</a> }<a name="275" href="#275">275</a> <a name="276" href="#276">276</a> <strong>protected</strong> <strong>boolean</strong> workQueueDataOnDisk() {<a name="277" href="#277">277</a> <strong>return</strong> <strong>true</strong>;<a name="278" href="#278">278</a> }<a name="279" href="#279">279</a> <a name="280" href="#280">280</a> <strong>public</strong> <strong>void</strong> initialize(<a href="../../../../org/archive/crawler/framework/CrawlController.html">CrawlController</a> c)<a name="281" href="#281">281</a> throws FatalConfigurationException, IOException {<a name="282" href="#282">282</a> <strong>super</strong>.initialize(c);<a name="283" href="#283">283</a> <strong>if</strong> (c.isCheckpointRecover()) {<a name="284" href="#284">284</a> <em class="comment">// If a checkpoint recover, copy old values from serialized</em><a name="285" href="#285">285</a> <em class="comment">// instance into this Frontier instance. Do it this way because </em><a name="286" href="#286">286</a> <em class="comment">// though its possible to serialize BdbFrontier, its currently not</em><a name="287" href="#287">287</a> <em class="comment">// possible to set/remove frontier attribute plugging the</em><a name="288" href="#288">288</a> <em class="comment">// deserialized object back into the settings system.</em><a name="289" href="#289">289</a> <em class="comment">// The below copying over is error-prone because its easy</em><a name="290" href="#290">290</a> <em class="comment">// to miss a value. Perhaps there's a better way? Introspection?</em><a name="291" href="#291">291</a> <a href="../../../../org/archive/crawler/frontier/BdbFrontier.html">BdbFrontier</a> f = <strong>null</strong>;<a name="292" href="#292">292</a> <strong>try</strong> {<a name="293" href="#293">293</a> f = (BdbFrontier)CheckpointUtils.<a name="294" href="#294">294</a> readObjectFromFile(<strong>this</strong>.getClass(),<a name="295" href="#295">295</a> <strong>this</strong>.controller.getCheckpointRecover().getDirectory());<a name="296" href="#296">296</a> } <strong>catch</strong> (FileNotFoundException e) {<a name="297" href="#297">297</a> <strong>throw</strong> <strong>new</strong> <a href="../../../../org/archive/crawler/framework/exceptions/FatalConfigurationException.html">FatalConfigurationException</a>(<span class="string">"Failed checkpoint "</span> +<a name="298" href="#298">298</a> <span class="string">"recover: "</span> + e.getMessage());<a name="299" href="#299">299</a> } <strong>catch</strong> (IOException e) {<a name="300" href="#300">300</a> <strong>throw</strong> <strong>new</strong> <a href="../../../../org/archive/crawler/framework/exceptions/FatalConfigurationException.html">FatalConfigurationException</a>(<span class="string">"Failed checkpoint "</span> +<a name="301" href="#301">301</a> <span class="string">"recover: "</span> + e.getMessage());<a name="302" href="#302">302</a> } <strong>catch</strong> (ClassNotFoundException e) {<a name="303" href="#303">303</a> <strong>throw</strong> <strong>new</strong> <a href="../../../../org/archive/crawler/framework/exceptions/FatalConfigurationException.html">FatalConfigurationException</a>(<span class="string">"Failed checkpoint "</span> +<a name="304" href="#304">304</a> <span class="string">"recover: "</span> + e.getMessage());<a name="305" href="#305">305</a> }<a name="306" href="#306">306</a> <a name="307" href="#307">307</a> <strong>this</strong>.nextOrdinal = f.nextOrdinal;<a name="308" href="#308">308</a> <strong>this</strong>.totalProcessedBytes = f.totalProcessedBytes;<a name="309" href="#309">309</a> <strong>this</strong>.disregardedUriCount = f.disregardedUriCount;<a name="310" href="#310">310</a> <strong>this</strong>.failedFetchCount = f.failedFetchCount;<a name="311" href="#311">311</a> <strong>this</strong>.processedBytesAfterLastEmittedURI =<a name="312" href="#312">312</a> f.processedBytesAfterLastEmittedURI;<a name="313" href="#313">313</a> <strong>this</strong>.queuedUriCount = f.queuedUriCount;<a name="314" href="#314">314</a> <strong>this</strong>.succeededFetchCount = f.succeededFetchCount;<a name="315" href="#315">315</a> <strong>this</strong>.lastMaxBandwidthKB = f.lastMaxBandwidthKB;<a name="316" href="#316">316</a> <strong>this</strong>.readyClassQueues = f.readyClassQueues;<a name="317" href="#317">317</a> <strong>this</strong>.inactiveQueues = f.inactiveQueues;<a name="318" href="#318">318</a> <strong>this</strong>.retiredQueues = f.retiredQueues;<a name="319" href="#319">319</a> <strong>this</strong>.snoozedClassQueues = f.snoozedClassQueues;<a name="320" href="#320">320</a> <strong>this</strong>.inProcessQueues = f.inProcessQueues;<a name="321" href="#321">321</a> wakeQueues();<a name="322" href="#322">322</a> }<a name="323" href="#323">323</a> }<a name="324" href="#324">324</a> <a name="325" href="#325">325</a> <strong>public</strong> <strong>void</strong> crawlCheckpoint(File checkpointDir) throws Exception {<a name="326" href="#326">326</a> <strong>super</strong>.crawlCheckpoint(checkpointDir);<a name="327" href="#327">327</a> logger.fine(<span class="string">"Started serializing already seen as part "</span><a name="328" href="#328">328</a> + <span class="string">"of checkpoint. Can take some time."</span>);<a name="329" href="#329">329</a> <em class="comment">// An explicit sync on the any deferred write dbs is needed to make the</em><a name="330" href="#330">330</a> <em class="comment">// db recoverable. Sync'ing the environment doesn't work.</em><a name="331" href="#331">331</a> <strong>if</strong> (<strong>this</strong>.pendingUris != <strong>null</strong>) {<a name="332" href="#332">332</a> <strong>this</strong>.pendingUris.sync();<a name="333" href="#333">333</a> }<a name="334" href="#334">334</a> <a href="../../../../org/archive/crawler/util/CheckpointUtils.html">CheckpointUtils</a> .writeObjectToFile(<strong>this</strong>.alreadyIncluded, checkpointDir);<a name="335" href="#335">335</a> logger.fine(<span class="string">"Finished serializing already seen as part "</span><a name="336" href="#336">336</a> + <span class="string">"of checkpoint."</span>);<a name="337" href="#337">337</a> <em class="comment">// Serialize ourselves.</em><a name="338" href="#338">338</a> CheckpointUtils.writeObjectToFile(<strong>this</strong>, checkpointDir);<a name="339" href="#339">339</a> }<a name="340" href="#340">340</a> }</pre><hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -