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.
164 lines
8.3 KiB
164 lines
8.3 KiB
18 years ago
|
import java.text.SimpleDateFormat;
|
||
19 years ago
|
import java.util.ArrayList;
|
||
|
import java.util.Date;
|
||
18 years ago
|
import java.util.Iterator;
|
||
19 years ago
|
import java.util.Locale;
|
||
|
|
||
17 years ago
|
import de.anomic.crawler.CrawlEntry;
|
||
17 years ago
|
import de.anomic.crawler.IndexingStack;
|
||
17 years ago
|
import de.anomic.crawler.NoticedURL;
|
||
16 years ago
|
import de.anomic.http.httpRequestHeader;
|
||
16 years ago
|
import de.anomic.kelondro.kelondroException;
|
||
19 years ago
|
import de.anomic.plasma.plasmaSwitchboard;
|
||
17 years ago
|
import de.anomic.plasma.plasmaSwitchboardConstants;
|
||
19 years ago
|
import de.anomic.server.serverObjects;
|
||
|
import de.anomic.server.serverSwitch;
|
||
|
import de.anomic.yacy.yacySeed;
|
||
|
|
||
|
public class queues_p {
|
||
|
|
||
18 years ago
|
public static final String STATE_RUNNING = "running";
|
||
|
public static final String STATE_PAUSED = "paused";
|
||
|
|
||
19 years ago
|
private static SimpleDateFormat dayFormatter = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
|
||
17 years ago
|
private static String daydate(final Date date) {
|
||
19 years ago
|
if (date == null) return "";
|
||
|
return dayFormatter.format(date);
|
||
|
}
|
||
|
|
||
16 years ago
|
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
|
||
19 years ago
|
// return variable that accumulates replacements
|
||
17 years ago
|
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
|
||
19 years ago
|
//wikiCode wikiTransformer = new wikiCode(switchboard);
|
||
17 years ago
|
final serverObjects prop = new serverObjects();
|
||
17 years ago
|
if (post == null || !post.containsKey("html"))
|
||
|
prop.setLocalized(false);
|
||
|
prop.put("rejected", "0");
|
||
19 years ago
|
//int showRejectedCount = 10;
|
||
|
|
||
|
yacySeed initiator;
|
||
|
|
||
17 years ago
|
//indexing queue
|
||
17 years ago
|
prop.putNum("indexingSize", sb.getThread(plasmaSwitchboardConstants.INDEXER).getJobCount() + sb.webIndex.queuePreStack.getActiveQueueSize());
|
||
|
prop.putNum("indexingMax", (int) sb.getConfigLong(plasmaSwitchboardConstants.INDEXER_SLOTS, 30));
|
||
17 years ago
|
prop.putNum("urlpublictextSize", sb.webIndex.countURL());
|
||
|
prop.putNum("rwipublictextSize", sb.webIndex.size());
|
||
|
if ((sb.webIndex.queuePreStack.size() == 0) && (sb.webIndex.queuePreStack.getActiveQueueSize() == 0)) {
|
||
17 years ago
|
prop.put("list", "0"); //is empty
|
||
19 years ago
|
} else {
|
||
17 years ago
|
IndexingStack.QueueEntry pcentry;
|
||
19 years ago
|
long totalSize = 0;
|
||
|
int i=0; //counter
|
||
18 years ago
|
|
||
|
// getting all entries that are currently in process
|
||
17 years ago
|
final ArrayList<IndexingStack.QueueEntry> entryList = new ArrayList<IndexingStack.QueueEntry>();
|
||
17 years ago
|
entryList.addAll(sb.webIndex.queuePreStack.getActiveQueueEntries());
|
||
17 years ago
|
final int inProcessCount = entryList.size();
|
||
18 years ago
|
|
||
|
// getting all enqueued entries
|
||
17 years ago
|
if ((sb.webIndex.queuePreStack.size() > 0)) {
|
||
17 years ago
|
final Iterator<IndexingStack.QueueEntry> i1 = sb.webIndex.queuePreStack.entryIterator(false);
|
||
16 years ago
|
while (i1.hasNext()) try {
|
||
|
entryList.add(i1.next());
|
||
|
} catch (kelondroException e) {
|
||
|
e.printStackTrace();
|
||
|
}
|
||
18 years ago
|
}
|
||
|
|
||
|
int size = (post == null) ? entryList.size() : post.getInt("num", entryList.size());
|
||
|
if (size > entryList.size()) size = entryList.size();
|
||
|
|
||
|
int ok = 0;
|
||
|
for (i = 0; i < size; i++) {
|
||
17 years ago
|
final boolean inProcess = i < inProcessCount;
|
||
17 years ago
|
pcentry = entryList.get(i);
|
||
|
if ((pcentry != null) && (pcentry.url() != null)) {
|
||
17 years ago
|
final long entrySize = pcentry.size();
|
||
18 years ago
|
totalSize += entrySize;
|
||
17 years ago
|
initiator = sb.webIndex.seedDB.getConnected(pcentry.initiator());
|
||
18 years ago
|
prop.put("list-indexing_"+i+"_profile", (pcentry.profile() != null) ? pcentry.profile().name() : "deleted");
|
||
16 years ago
|
prop.putHTML("list-indexing_"+i+"_initiator", ((initiator == null) ? "proxy" : initiator.getName()));
|
||
18 years ago
|
prop.put("list-indexing_"+i+"_depth", pcentry.depth());
|
||
|
prop.put("list-indexing_"+i+"_modified", pcentry.getModificationDate());
|
||
16 years ago
|
prop.putXML("list-indexing_"+i+"_anchor", (pcentry.anchorName()==null) ? "" : pcentry.anchorName());
|
||
|
prop.putXML("list-indexing_"+i+"_url", pcentry.url().toNormalform(false, true));
|
||
17 years ago
|
prop.putNum("list-indexing_"+i+"_size", entrySize);
|
||
|
prop.put("list-indexing_"+i+"_inProcess", (inProcess) ? "1" : "0");
|
||
18 years ago
|
prop.put("list-indexing_"+i+"_hash", pcentry.urlHash());
|
||
|
ok++;
|
||
19 years ago
|
}
|
||
18 years ago
|
}
|
||
|
prop.put("list-indexing", ok);
|
||
19 years ago
|
}
|
||
|
|
||
17 years ago
|
//loader queue
|
||
|
prop.put("loaderSize", Integer.toString(sb.crawlQueues.size()));
|
||
16 years ago
|
prop.put("loaderMax", sb.getConfigLong(plasmaSwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, 10));
|
||
17 years ago
|
if (sb.crawlQueues.size() == 0) {
|
||
17 years ago
|
prop.put("list-loader", "0");
|
||
19 years ago
|
} else {
|
||
17 years ago
|
final CrawlEntry[] w = sb.crawlQueues.activeWorkerEntries();
|
||
17 years ago
|
int count = 0;
|
||
|
for (int i = 0; i < w.length; i++) {
|
||
|
if (w[i] == null) continue;
|
||
|
prop.put("list-loader_"+count+"_profile", w[i].profileHandle());
|
||
17 years ago
|
initiator = sb.webIndex.seedDB.getConnected(w[i].initiator());
|
||
16 years ago
|
prop.putHTML("list-loader_"+count+"_initiator", ((initiator == null) ? "proxy" : initiator.getName()));
|
||
17 years ago
|
prop.put("list-loader_"+count+"_depth", w[i].depth());
|
||
16 years ago
|
prop.putXML("list-loader_"+count+"_url", w[i].url().toString());
|
||
19 years ago
|
count++;
|
||
|
}
|
||
17 years ago
|
prop.put("list-loader", count);
|
||
19 years ago
|
}
|
||
|
|
||
17 years ago
|
//local crawl queue
|
||
17 years ago
|
prop.putNum("localCrawlSize", Integer.toString(sb.getThread(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL).getJobCount()));
|
||
|
prop.put("localCrawlState", sb.crawlJobIsPaused(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL) ? STATE_PAUSED : STATE_RUNNING);
|
||
17 years ago
|
int stackSize = sb.crawlQueues.noticeURL.stackSize(NoticedURL.STACK_TYPE_CORE);
|
||
|
addNTable(sb, prop, "list-local", sb.crawlQueues.noticeURL.top(NoticedURL.STACK_TYPE_CORE, Math.min(10, stackSize)));
|
||
17 years ago
|
|
||
17 years ago
|
//global crawl queue
|
||
17 years ago
|
prop.putNum("limitCrawlSize", Integer.toString(sb.crawlQueues.limitCrawlJobSize()));
|
||
|
prop.put("limitCrawlState", STATE_RUNNING);
|
||
17 years ago
|
stackSize = sb.crawlQueues.noticeURL.stackSize(NoticedURL.STACK_TYPE_LIMIT);
|
||
17 years ago
|
|
||
|
//global crawl queue
|
||
17 years ago
|
prop.putNum("remoteCrawlSize", Integer.toString(sb.getThread(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount()));
|
||
|
prop.put("remoteCrawlState", sb.crawlJobIsPaused(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? STATE_PAUSED : STATE_RUNNING);
|
||
17 years ago
|
stackSize = sb.crawlQueues.noticeURL.stackSize(NoticedURL.STACK_TYPE_LIMIT);
|
||
17 years ago
|
|
||
19 years ago
|
if (stackSize == 0) {
|
||
17 years ago
|
prop.put("list-remote", "0");
|
||
19 years ago
|
} else {
|
||
17 years ago
|
addNTable(sb, prop, "list-remote", sb.crawlQueues.noticeURL.top(NoticedURL.STACK_TYPE_LIMIT, Math.min(10, stackSize)));
|
||
19 years ago
|
}
|
||
|
|
||
|
// return rewrite properties
|
||
|
return prop;
|
||
|
}
|
||
|
|
||
18 years ago
|
|
||
17 years ago
|
public static final void addNTable(final plasmaSwitchboard sb, final serverObjects prop, final String tableName, final ArrayList<CrawlEntry> crawlerList) {
|
||
18 years ago
|
|
||
|
int showNum = 0;
|
||
17 years ago
|
CrawlEntry urle;
|
||
18 years ago
|
yacySeed initiator;
|
||
17 years ago
|
for (int i = 0; i < crawlerList.size(); i++) {
|
||
|
urle = crawlerList.get(i);
|
||
18 years ago
|
if ((urle != null) && (urle.url() != null)) {
|
||
17 years ago
|
initiator = sb.webIndex.seedDB.getConnected(urle.initiator());
|
||
18 years ago
|
prop.put(tableName + "_" + showNum + "_profile", urle.profileHandle());
|
||
18 years ago
|
prop.put(tableName + "_" + showNum + "_initiator", ((initiator == null) ? "proxy" : initiator.getName()));
|
||
|
prop.put(tableName + "_" + showNum + "_depth", urle.depth());
|
||
|
prop.put(tableName + "_" + showNum + "_modified", daydate(urle.loaddate()));
|
||
16 years ago
|
prop.putXML(tableName + "_" + showNum + "_anchor", urle.name());
|
||
|
prop.putXML(tableName + "_" + showNum + "_url", urle.url().toNormalform(false, true));
|
||
17 years ago
|
prop.put(tableName + "_" + showNum + "_hash", urle.url().hash());
|
||
18 years ago
|
showNum++;
|
||
|
}
|
||
|
}
|
||
|
prop.put(tableName, showNum);
|
||
|
|
||
|
}
|
||
19 years ago
|
}
|