giving threads name so its easier to see whats happening during

debugging and within a thread dump
pull/1/head
Michael Peter Christen 13 years ago
parent 03280fb161
commit 0c345d1559

@ -103,6 +103,7 @@ public final class Cache {
Thread startupCleanup = new Thread() {
@Override
public void run() {
Thread.currentThread().setName("Cache startupCleanup");
// enumerate the responseHeaderDB and find out all entries that are not inside the fileDBunbuffered
BlockingQueue<byte[]> q = responseHeaderDB.keyQueue(1000);
final HandleSet delkeys = new HandleSet(Word.commonHashLength, Base64Order.enhancedCoder, 1);
@ -146,7 +147,7 @@ public final class Cache {
public static void commit() {
fileDB.flushAll();
}
/**
* clear the cache
*/

@ -185,6 +185,7 @@ public final class CrawlStacker {
new Thread() {
@Override
public void run() {
Thread.currentThread().setName("enqueueEntriesAsynchronous");
enqueueEntries(initiator, profileHandle, hyperlinks, true);
}
}.start();
@ -240,6 +241,7 @@ public final class CrawlStacker {
new Thread() {
@Override
public void run() {
Thread.currentThread().setName("enqueueEntriesFTP");
BlockingQueue<FTPClient.entryInfo> queue;
try {
queue = FTPClient.sitelist(host, port);

@ -746,6 +746,7 @@ public class Domains {
new Thread() {
@Override
public void run() {
Thread.currentThread().setName("Domains: init");
// try to get local addresses from interfaces
try {
final Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();

@ -237,6 +237,7 @@ public class FTPClient {
super();
}
@Override
public synchronized Class<?> loadClass(final String classname, final boolean resolve) throws ClassNotFoundException {
Class<?> c = findLoadedClass(classname);
if (c == null) {
@ -945,8 +946,8 @@ public class FTPClient {
return true;
}
final String[] name = this.currentLocalPath.list();
for (int n = 0; n < name.length; ++n) {
log.info(ls(new File(this.currentLocalPath, name[n])));
for (String element : name) {
log.info(ls(new File(this.currentLocalPath, element)));
}
return true;
}
@ -2539,6 +2540,7 @@ public class FTPClient {
@Override
public void run() {
try {
Thread.currentThread().setName("FTP.sitelist(" + host + ":" + port + ")");
sitelist(ftpClient, "/", queue);
ftpClient.quit();
} catch (final Exception e) {} finally {
@ -2757,8 +2759,10 @@ public class FTPClient {
this.password = p;
}
@Override
public final void run() {
try {
Thread.currentThread().setName("FTP.pt(" + this.host + ")");
put(this.host, this.localFile, this.remotePath, this.remoteName, this.account, this.password);
} catch (final IOException e) {
log.error(e, e);

@ -130,6 +130,7 @@ public class SRURSSConnector extends Thread implements SearchAccumulator {
final Thread job = new Thread() {
@Override
public void run() {
Thread.currentThread().setName("searchSRURSS:" + urlBase);
int startRecord = 0;
RSSMessage message;
int maximumRecords = maximumRecordsInit;

@ -55,10 +55,10 @@ public class Files {
InputStream is = new BufferedInputStream(new FileInputStream(f));
if (f.toString().endsWith(".bz2")) is = new BZip2CompressorInputStream(is);
if (f.toString().endsWith(".gz")) is = new GZIPInputStream(is);
return is;
}
/**
* reading a file line by line should be done with two concurrent processes
* - one reading the file and doing IO operations
@ -80,7 +80,9 @@ public class Files {
final InputStream is = read(f);
final BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
Thread t = new Thread() {
public void run() {
@Override
public void run() {
Thread.currentThread().setName("Files.concurrentLineReader:" + f);
String line;
try {
while ((line = br.readLine()) != null) {
@ -111,7 +113,7 @@ public class Files {
t.start();
return q;
}
/**
* copy a file or a complete directory
* @param from the source file or directory

@ -179,6 +179,7 @@ public class PhpBB3Dao implements Dao {
Thread dbreader = new Thread() {
@Override
public void run() {
Thread.currentThread().setName("PhpBB3Dao.toQueue");
Statement stmt = null;
ResultSet rs = null;
try {

@ -142,6 +142,7 @@ public class pdfParser extends AbstractParser implements Parser {
final Thread t = new Thread() {
@Override
public void run() {
Thread.currentThread().setName("pdfParser.getText:" + location);
try {
writer.append(stripper.getText(pdfDoc));
} catch (final Throwable e) {}

@ -2,7 +2,7 @@
* YaCyApp
* Copyright 2010 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
* First released 05.08.2010 at http://yacy.net
*
*
* $LastChangedDate$
* $LastChangedRevision$
* $LastChangedBy$
@ -11,12 +11,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program in the file lgpl21.txt
* If not, see <http://www.gnu.org/licenses/>.
@ -48,7 +48,7 @@ import net.yacy.gui.framework.Switchboard;
import org.apache.log4j.Logger;
public class YaCyApp {
public static Logger log = Logger.getLogger(YaCyApp.class);
private static JFrame app;
private static Operation operation;
@ -70,33 +70,34 @@ public class YaCyApp {
public splashCanvas(ImageObserver obs) { this.obs = obs; }
@Override
public void paint(Graphics g) {
if (splashImg != null) g.drawImage(splashImg, 0, 0, obs);
if (splashImg != null) g.drawImage(splashImg, 0, 0, this.obs);
}
}
public static class Op implements Operation {
JFrame app;
final String host;
final int port;
public Op(JFrame app, String host, int port) {
this.app = app;
this.host = host;
this.port = port;
}
@Override
public void closeAndExit() {
if (app != null) app.setVisible(false); // fake closing
if (this.app != null) this.app.setVisible(false); // fake closing
//Browser.openBrowser("http://" + host + ":" + port + "/Steering.html?shutdown=");
net.yacy.search.Switchboard.getSwitchboard().terminate(10, "shutdown request from gui");
Switchboard.shutdown();
//System.exit(0);
}
}
public static void start(String host, int port) {
Switchboard.startInfoUpdater();
operation = new Op(app, host, port);
@ -108,6 +109,7 @@ public class YaCyApp {
OpenItem.setEnabled(false);
JMenuItem QuitItem = new JMenuItem("Quit");
QuitItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
operation.closeAndExit();
}
@ -115,7 +117,7 @@ public class YaCyApp {
FileMenu.add(OpenItem);
FileMenu.add(QuitItem);
menues.add(FileMenu);
// the edit menu
JMenu EditMenu = new JMenu("Edit");
JMenuItem CutItem = new JMenuItem("Cut");
@ -128,12 +130,13 @@ public class YaCyApp {
EditMenu.add(CopyItem);
EditMenu.add(PasteItem);
menues.add(EditMenu);
// registering shutdown hook
log.info("Registering Shutdown Hook");
Thread t = new Thread() {
@Override
public void run() {
Thread.currentThread().setName("YaCyApp");
app = new Application("YaCy GUI", operation, menues, new InfoPage("localhost", 8090));
app.setLocationRelativeTo(null);
app.setVisible(true);
@ -142,12 +145,12 @@ public class YaCyApp {
Switchboard.addShutdownHook(t, net.yacy.yacy.shutdownSemaphore);
SwingUtilities.invokeLater(t);
}
public static void main(String[] args) {
if (args.length > 0) Switchboard.load(new File(args[0]));
start("localhost", 8090);
}
}

@ -525,6 +525,7 @@ public class MapHeap implements Map<byte[], Map<String, String>> {
(new Thread() {
@Override
public void run() {
Thread.currentThread().setName("MapHeap.keyQueue:" + size);
try {
final Iterator<byte[]> i = MapHeap.this.blob.keys(true, false);
while (i.hasNext())

@ -217,6 +217,7 @@ public final class WordReferenceRow extends AbstractReference implements WordRef
this.worker[i] = new Thread() {
@Override
public void run() {
Thread.currentThread().setName("WordReferenceRow.ExternalParser:" + concurrency);
String s;
try {
while ((s = ExternalParser.this.in.take()) != PIN) {

@ -227,6 +227,7 @@ public class SplitTable implements Index, Iterable<Row.Entry> {
final Thread p = new Thread() {
@Override
public void run() {
Thread.currentThread().setName("SplitTable.warmUp");
a.warmUp();
}
};

@ -339,6 +339,7 @@ public final class Switchboard extends serverSwitch
new Thread() {
@Override
public void run() {
Thread.currentThread().setName("LibraryProvider.initialize");
LibraryProvider.initialize(Switchboard.this.dictionariesPath);
}
}.start();
@ -662,6 +663,7 @@ public final class Switchboard extends serverSwitch
new Thread() {
@Override
public void run() {
Thread.currentThread().setName("Switchboard.initBookmarks");
try {
initBookmarks();
} catch ( final IOException e ) {
@ -1157,8 +1159,8 @@ public final class Switchboard extends serverSwitch
final int wordCacheMaxCount =
(int) getConfigLong(SwitchboardConstants.WORDCACHE_MAX_COUNT, 20000);
final long fileSizeMax =
(OS.isWindows) ? sb.getConfigLong("filesize.max.win", (long) Integer.MAX_VALUE) : sb
.getConfigLong("filesize.max.other", (long) Integer.MAX_VALUE);
(OS.isWindows) ? sb.getConfigLong("filesize.max.win", Integer.MAX_VALUE) : sb
.getConfigLong("filesize.max.other", Integer.MAX_VALUE);
final int redundancy = (int) sb.getConfigLong("network.unit.dhtredundancy.senior", 1);
final int partitionExponent = (int) sb.getConfigLong("network.unit.dht.partitionExponent", 0);
final String networkName = getConfig(SwitchboardConstants.NETWORK_NAME, "");
@ -2727,9 +2729,10 @@ public final class Switchboard extends serverSwitch
final Request request = this.loader.request(url, true, true);
final CrawlProfile profile = sb.crawler.getActive(ASCII.getBytes(request.profileHandle()));
final String acceptedError = this.crawlStacker.checkAcceptance(url, profile, 0);
final String urls = url.toNormalform(false, false);
if ( acceptedError != null ) {
this.log.logWarning("addToIndex: cannot load "
+ url.toNormalform(false, false)
+ urls
+ ": "
+ acceptedError);
return;
@ -2737,6 +2740,7 @@ public final class Switchboard extends serverSwitch
new Thread() {
@Override
public void run() {
Thread.currentThread().setName("Switchboard.addToIndex:" + urls);
try {
final Response response =
Switchboard.this.loader.load(request, CacheStrategy.IFFRESH, true);
@ -2795,6 +2799,7 @@ public final class Switchboard extends serverSwitch
this.reference = reference;
}
@Override
public void run() {
final long t = System.currentTimeMillis();
final Map<String, String> response =
@ -3109,6 +3114,7 @@ public final class Switchboard extends serverSwitch
new Thread() {
@Override
public void run() {
Thread.currentThread().setName("Switchboard.heuristicSite:" + host);
String r = host;
if ( r.indexOf("//", 0) < 0 ) {
r = "http://" + r;
@ -3161,6 +3167,7 @@ public final class Switchboard extends serverSwitch
public void run() {
QueryParams query = searchEvent.getQuery();
String queryString = query.queryString(true);
Thread.currentThread().setName("Switchboard.heuristicRSS:" + queryString);
final int meta = queryString.indexOf("heuristic:", 0);
if ( meta >= 0 ) {
final int q = queryString.indexOf(' ', meta);

@ -163,6 +163,7 @@ public final class SearchEvent
new Thread() {
@Override
public void run() {
Thread.currentThread().setName("SearchEvent.primaryRemoteSearches");
RemoteSearch.primaryRemoteSearches(
SearchEvent.this.primarySearchThreadsL,
QueryParams.hashSet2hashString(SearchEvent.this.query.queryHashes),
@ -553,6 +554,7 @@ public final class SearchEvent
new Thread() {
@Override
public void run() {
Thread.currentThread().setName("SearchEvent.paddAbstract:" + wordhash);
for ( final Map.Entry<String, StringBuilder> oneref : singleAbstract.entrySet() ) {
final String urlhash = oneref.getKey();
final StringBuilder peerlistNew = oneref.getValue();

Loading…
Cancel
Save