Author: j16sdiz
Date: 2008-12-16 07:59:13 +0000 (Tue, 16 Dec 2008)
New Revision: 24379
Modified:
trunk/plugins/XMLSpider/XMLSpider.java
Log:
write index file only when you ask it to
Modified: trunk/plugins/XMLSpider/XMLSpider.java
===================================================================
--- trunk/plugins/XMLSpider/XMLSpider.java 2008-12-16 07:50:05 UTC (rev
24378)
+++ trunk/plugins/XMLSpider/XMLSpider.java 2008-12-16 07:59:13 UTC (rev
24379)
@@ -169,10 +169,7 @@
private Vector<String> indices;
private int match;
private long time_taken;
-/*
- * minTimeBetweenEachIndexRewriting in seconds
- */
- private static final int minTimeBetweenEachIndexRewriting = 600;
+
/**
* directory where the generated indices are stored.
* Needs to be created before it can be used
@@ -465,7 +462,7 @@
* @throws IOException
* @throws NoSuchAlgorithmException
*/
- private synchronized void makeMainIndex() throws
IOException,NoSuchAlgorithmException {
+ private void makeMainIndex() throws IOException,
NoSuchAlgorithmException {
// Produce the main index file.
Logger.minor(this, "Producing top index...");
@@ -582,7 +579,7 @@
* of the hash code of the words
* @throws Exception
*/
- private synchronized void makeSubIndices() throws Exception{
+ private void makeSubIndices() throws Exception {
Logger.normal(this, "Generating index...");
Query query = db.query();
@@ -623,7 +620,7 @@
}
- private synchronized void generateSubIndex(int p, List<String> list)
throws Exception {
+ private void generateSubIndex(int p, List<String> list) throws
Exception {
boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
/*
* if the list is less than max allowed entries in a file then
directly generate the xml
@@ -678,7 +675,7 @@
* @param prefix number of matching bits of md5
* @throws Exception
*/
- protected synchronized void generateXML(List<String> list, int prefix)
throws TooBigIndexException, Exception
+ protected void generateXML(List<String> list, int prefix) throws
TooBigIndexException, Exception
{
String p = list.get(0).substring(0, prefix);
indices.add(p);
@@ -1021,7 +1018,6 @@
Thread.sleep(30 * 1000); // Let the
node start up
} catch (InterruptedException e){}
startSomeRequests();
- scheduleMakeIndex();
}
}, "Spider Plugin Starter");
}
@@ -1069,6 +1065,18 @@
HTMLNode pageNode = pageMaker.getPageNode(pluginName, null);
HTMLNode contentNode = pageMaker.getContentNode(pageNode);
+ if (request.isPartSet("createIndex")) {
+ synchronized (this) {
+ if (!writingIndex) {
+ scheduleMakeIndex();
+
+ HTMLNode infobox =
pageMaker.getInfobox("infobox infobox-success", "Scheduled Creating Index");
+ infobox.addChild("%", "Index will start
create soon.");
+ contentNode.addChild(infobox);
+ }
+ }
+ }
+
String addURI = request.getPartAsString("addURI", 512);
if (addURI != null && addURI.length() != 0) {
// Adding URI manually
@@ -1150,17 +1158,33 @@
nextTableCell = overviewTableRow.addChild("td", "class",
"second");
HTMLNode mainBox = pageMaker.getInfobox("Main");
HTMLNode mainContent = pageMaker.getContentNode(mainBox);
- HTMLNode form = mainContent.addChild("form", //
+ HTMLNode addForm = mainContent.addChild("form", //
new String[] { "action", "method" }, //
new String[] { "plugins.XMLSpider.XMLSpider", "post" });
- form.addChild("label", "for", "addURI", "Add URI:");
- form.addChild("input", new String[] { "name", "style" }, new
String[] { "addURI", "width: 20em;" });
- form.addChild("input", //
+ addForm.addChild("label", "for", "addURI", "Add URI:");
+ addForm.addChild("input", new String[] { "name", "style" }, new
String[] { "addURI", "width: 20em;" });
+ addForm.addChild("input", //
new String[] { "name", "type", "value" },//
new String[] { "formPassword", "hidden",
core.formPassword });
- form.addChild("input", "type", "submit");
+ addForm.addChild("input", "type", "submit");
nextTableCell.addChild(mainBox);
+ HTMLNode indexBox = pageMaker.getInfobox("Create Index");
+ HTMLNode indexContent = pageMaker.getContentNode(indexBox);
+ HTMLNode indexForm = indexContent.addChild("form", //
+ new String[] { "action", "method" }, //
+ new String[] { "plugins.XMLSpider.XMLSpider", "post" });
+ indexForm.addChild("input", //
+ new String[] { "name", "type", "value" },//
+ new String[] { "formPassword", "hidden",
core.formPassword });
+ indexForm.addChild("input", //
+ new String[] { "name", "type", "value" },//
+ new String[] { "createIndex", "hidden", "createIndex"
});
+ indexForm.addChild("input", //
+ new String[] { "type", "value" }, //
+ new String[] { "submit", "Create Index Now" });
+ nextTableCell.addChild(indexBox);
+
HTMLNode runningBox = pageMaker.getInfobox("Running URI");
runningBox.addAttribute("style", "right: 0;");
HTMLNode runningContent = pageMaker.getContentNode(runningBox);
@@ -1315,8 +1339,6 @@
tProducedIndex = System.currentTimeMillis();
} finally {
- if (!stopped)
- scheduleMakeIndex();
synchronized (this) {
writingIndex = false;
notifyAll();
@@ -1338,7 +1360,7 @@
return NativeThread.LOW_PRIORITY;
}
- }, minTimeBetweenEachIndexRewriting * 1000);
+ }, 1);
}
public void onFoundEdition(long l, USK key){
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs