You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yacy_search_server/source/de/anomic/crawler/LoaderMessage.java

104 lines
3.4 KiB

//plasmaCrawlLoaderMessage.java
//------------------------
//part of YaCy
//(C) by Michael Peter Christen; mc@yacy.net
//first published on http://www.anomic.de
//Frankfurt, Germany, 2004
//last major change: 21.04.2005 by Martin Thelian
//
//This program is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2 of the License, or
//(at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package de.anomic.crawler;
import de.anomic.http.httpDocument;
import de.anomic.server.serverSemaphore;
import de.anomic.yacy.yacyURL;
public final class LoaderMessage {
public final int crawlingPriority;
public final yacyURL url;
public final String name;
public final String referer;
public final String initiator;
public final int depth;
public final CrawlProfile.entry profile;
public final boolean acceptAllContent;
public final int timeout;
*) plasmaHTCache: - method loadResourceContent defined as deprecated. Please do not use this function to avoid OutOfMemory Exceptions when loading large files - new function getResourceContentStream to get an inputstream of a cache file - new function getResourceContentLength to get the size of a cached file *) httpc.java: - Bugfix: resource content was loaded into memory even if this was not requested *) Crawler: - new option to hold loaded resource content in memory - adding option to use the worker class without the worker pool (needed by the snippet fetcher) *) plasmaSnippetCache - snippet loader does not use a crawl-worker from pool but uses a newly created instance to avoid blocking by normal crawling activity. - now operates on streams instead of byte arrays to avoid OutOfMemory Exceptions when operating on large files - snippet loader now forces the crawl-worker to keep the loaded resource in memory to avoid IO *) plasmaCondenser: adding new function getWords that can directly operate on input streams *) Parsers - keep resource in memory whenever possible (to avoid IO) - when parsing from stream the content length must be passed to the parser function now. this length value is needed by the parsers to decide if the parsed resource content is to large to hold it in memory and must be stored to file - AbstractParser.java: new function to pass the contentLength of a resource to the parsers git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2701 6c8d7289-2bf4-0310-a012-ef5d649a1542
18 years ago
public final boolean keepInMemory;
private serverSemaphore resultSync = null;
private httpDocument result;
private String errorMessage;
// loadParallel(URL url, String referer, String initiator, int depth, plasmaCrawlProfile.entry profile) {
public LoaderMessage(
final yacyURL url,
final String name, // the name of the url, from anchor tag <a>name</a>
final String referer,
final String initiator,
final int depth,
final CrawlProfile.entry profile,
final int crawlingPriority,
final boolean acceptAllContent,
final int timeout,
final boolean keepInMemory
) {
this.url = url;
this.name = name;
this.referer = referer;
this.initiator = initiator;
this.depth = depth;
this.profile = profile;
this.crawlingPriority = crawlingPriority;
this.acceptAllContent = acceptAllContent;
this.timeout = timeout;
*) plasmaHTCache: - method loadResourceContent defined as deprecated. Please do not use this function to avoid OutOfMemory Exceptions when loading large files - new function getResourceContentStream to get an inputstream of a cache file - new function getResourceContentLength to get the size of a cached file *) httpc.java: - Bugfix: resource content was loaded into memory even if this was not requested *) Crawler: - new option to hold loaded resource content in memory - adding option to use the worker class without the worker pool (needed by the snippet fetcher) *) plasmaSnippetCache - snippet loader does not use a crawl-worker from pool but uses a newly created instance to avoid blocking by normal crawling activity. - now operates on streams instead of byte arrays to avoid OutOfMemory Exceptions when operating on large files - snippet loader now forces the crawl-worker to keep the loaded resource in memory to avoid IO *) plasmaCondenser: adding new function getWords that can directly operate on input streams *) Parsers - keep resource in memory whenever possible (to avoid IO) - when parsing from stream the content length must be passed to the parser function now. this length value is needed by the parsers to decide if the parsed resource content is to large to hold it in memory and must be stored to file - AbstractParser.java: new function to pass the contentLength of a resource to the parsers git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2701 6c8d7289-2bf4-0310-a012-ef5d649a1542
18 years ago
this.keepInMemory = keepInMemory;
this.resultSync = new serverSemaphore(0);
this.result = null;
}
public void setError(final String errorMessage) {
this.errorMessage = errorMessage;
}
public String getError() {
return this.errorMessage;
}
public void setResult(final httpDocument theResult) {
// store the result
this.result = theResult;
// notify blocking result readers
this.resultSync.V();
}
public httpDocument waitForResult() throws InterruptedException {
httpDocument theResult = null;
this.resultSync.P();
/* =====> CRITICAL SECTION <======== */
theResult = this.result;
/* =====> CRITICAL SECTION <======== */
this.resultSync.V();
return theResult;
}
}