- patch for bad profiles

- time-out when deleting profiles

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4793 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 0f7449840e
commit dd75b3cabc

@ -91,7 +91,7 @@ public class CrawlProfileEditor_p {
if (entry != null) sb.profilesPassiveCrawls.newEntry(entry.map());
sb.profilesActiveCrawls.removeEntry(handle);
// delete all entries from the crawl queue that are deleted here
sb.crawlQueues.noticeURL.removeByProfileHandle(handle);
sb.crawlQueues.noticeURL.removeByProfileHandle(handle, 10000);
}
if (post.containsKey("delete")) {
// deletion of a terminated crawl profile

@ -167,7 +167,7 @@ public class Balancer {
return new CrawlEntry(entry);
}
public synchronized int removeAllByProfileHandle(String profileHandle) throws IOException {
public synchronized int removeAllByProfileHandle(String profileHandle, long timeout) throws IOException {
// removes all entries with a specific profile hash.
// this may last some time
// returns number of deletions
@ -177,7 +177,8 @@ public class Balancer {
HashSet<String> urlHashes = new HashSet<String>();
kelondroRow.Entry rowEntry;
CrawlEntry crawlEntry;
while (i.hasNext()) {
long terminate = (timeout > 0) ? System.currentTimeMillis() + timeout : Long.MAX_VALUE;
while (i.hasNext() && (System.currentTimeMillis() < terminate)) {
rowEntry = (kelondroRow.Entry) i.next();
crawlEntry = new CrawlEntry(rowEntry);
if (crawlEntry.profileHandle().equals(profileHandle)) {

@ -72,7 +72,7 @@ public class CrawlProfile {
profileTable = new kelondroMapObjects(dyn, 500);
}
void resetDatabase() {
public void resetDatabase() {
// deletes the profile database and creates a new one
if (profileTable != null) profileTable.close();
if (!(profileTableFile.delete())) throw new RuntimeException("cannot delete crawl profile database");

@ -174,11 +174,11 @@ public class NoticedURL {
return false;
}
public int removeByProfileHandle(String handle) {
public int removeByProfileHandle(String handle, long timeout) {
int removed = 0;
try {removed += coreStack.removeAllByProfileHandle(handle);} catch (IOException e) {}
try {removed += limitStack.removeAllByProfileHandle(handle);} catch (IOException e) {}
try {removed += remoteStack.removeAllByProfileHandle(handle);} catch (IOException e) {}
try {removed += coreStack.removeAllByProfileHandle(handle, timeout);} catch (IOException e) {}
try {removed += limitStack.removeAllByProfileHandle(handle, timeout);} catch (IOException e) {}
try {removed += remoteStack.removeAllByProfileHandle(handle, timeout);} catch (IOException e) {}
return removed;
}

@ -1475,16 +1475,27 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<plasmaSwitchbo
Iterator<CrawlProfile.entry> i = this.profilesActiveCrawls.profiles(true);
CrawlProfile.entry profile;
String name;
while (i.hasNext()) {
profile = i.next();
name = profile.name();
if (name.equals(CRAWL_PROFILE_PROXY)) this.defaultProxyProfile = profile;
if (name.equals(CRAWL_PROFILE_REMOTE)) this.defaultRemoteProfile = profile;
if (name.equals(CRAWL_PROFILE_SNIPPET_LOCAL_TEXT)) this.defaultTextSnippetLocalProfile = profile;
if (name.equals(CRAWL_PROFILE_SNIPPET_GLOBAL_TEXT)) this.defaultTextSnippetGlobalProfile = profile;
if (name.equals(CRAWL_PROFILE_SNIPPET_LOCAL_MEDIA)) this.defaultMediaSnippetLocalProfile = profile;
if (name.equals(CRAWL_PROFILE_SNIPPET_GLOBAL_MEDIA)) this.defaultMediaSnippetGlobalProfile = profile;
try {
while (i.hasNext()) {
profile = i.next();
name = profile.name();
if (name.equals(CRAWL_PROFILE_PROXY)) this.defaultProxyProfile = profile;
if (name.equals(CRAWL_PROFILE_REMOTE)) this.defaultRemoteProfile = profile;
if (name.equals(CRAWL_PROFILE_SNIPPET_LOCAL_TEXT)) this.defaultTextSnippetLocalProfile = profile;
if (name.equals(CRAWL_PROFILE_SNIPPET_GLOBAL_TEXT)) this.defaultTextSnippetGlobalProfile = profile;
if (name.equals(CRAWL_PROFILE_SNIPPET_LOCAL_MEDIA)) this.defaultMediaSnippetLocalProfile = profile;
if (name.equals(CRAWL_PROFILE_SNIPPET_GLOBAL_MEDIA)) this.defaultMediaSnippetGlobalProfile = profile;
}
} catch (Exception e) {
this.profilesActiveCrawls.resetDatabase();
this.defaultProxyProfile = null;
this.defaultRemoteProfile = null;
this.defaultTextSnippetLocalProfile = null;
this.defaultTextSnippetGlobalProfile = null;
this.defaultMediaSnippetLocalProfile = null;
this.defaultMediaSnippetGlobalProfile = null;
}
if (this.defaultProxyProfile == null) {
// generate new default entry for proxy crawling
this.defaultProxyProfile = this.profilesActiveCrawls.newEntry("proxy", null, ".*", ".*",

Loading…
Cancel
Save