Fixed thread name consistency for improved monitoring.

Some tasks were modifying the current thread name without restoring it
once finished as it is effectively done elsewhere.
pull/93/head
luccioman 8 years ago
parent eec5779889
commit 3092a8ced5

@ -677,6 +677,7 @@ public class HTTPClient {
assert !hrequest.expectContinue();
}
final String initialThreadName = Thread.currentThread().getName();
Thread.currentThread().setName("HTTPClient-" + httpUriRequest.getURI());
final long time = System.currentTimeMillis();
try {
@ -711,6 +712,9 @@ public class HTTPClient {
throw new IOException("Client can't execute: "
+ (e.getCause() == null ? e.getMessage() : e.getCause().getMessage())
+ " duration=" + Long.toString(System.currentTimeMillis() - time) + " for url " + httpUriRequest.getURI().toString());
} finally {
/* Restore the thread initial name */
Thread.currentThread().setName(initialThreadName);
}
}

@ -71,7 +71,9 @@ public final class Condenser extends Tokenizer {
) {
super(document.dc_source(), indexText ? document.getTextString() : "", meaningLib, doAutotagging, scraper);
final String initialThreadName = Thread.currentThread().getName();
Thread.currentThread().setName("condenser-" + document.dc_identifier()); // for debugging
// if addMedia == true, then all the media links are also parsed and added to the words
// added media words are flagged with the appropriate media flag
this.dates_in_content = new LinkedHashSet<Date>();
@ -208,6 +210,9 @@ public final class Condenser extends Tokenizer {
this.fuzzy_signature = EnhancedTextProfileSignature.getSignatureLong(fuzzySignatureFactory);
this.fuzzy_signature_text = fuzzySignatureFactory.getSignatureText().toString();
this.exact_signature = EnhancedTextProfileSignature.getSignatureLong(text);
/* Restore the current thread initial name */
Thread.currentThread().setName(initialThreadName);
}
private void insertTextToWords(

@ -231,11 +231,14 @@ public final class yacyRelease extends yacyVersion {
// parsing the content and filtering+parsing links
// returns the version info if successful, null otherwise
Document scraper;
final String initialThreadName = Thread.currentThread().getName();
try {
final DigestURL uri = location.getLocationURL();
Thread.currentThread().setName("allReleaseFrom - host " + uri.getHost()); // makes it more easy to see which release blocks process in thread dump
scraper = Switchboard.getSwitchboard().loader.loadDocument(uri, CacheStrategy.NOCACHE, null, ClientIdentification.yacyInternetCrawlerAgent);
} catch (final IOException e) {
/* Restore the thread initial name */
Thread.currentThread().setName(initialThreadName);
return null;
}
@ -260,6 +263,9 @@ public final class yacyRelease extends yacyVersion {
}
}
Switchboard.getSwitchboard().setConfig("update.time.lookup", System.currentTimeMillis());
/* Restore the thread initial name */
Thread.currentThread().setName(initialThreadName);
return new DevAndMainVersions(devReleases, mainReleases);
}

Loading…
Cancel
Save