See: http://www.yacy-forum.de/viewtopic.php?p=9622 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@707 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
parent
595ec6faf1
commit
2cb084d426
@ -0,0 +1,55 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>YaCy '#[clientname]#': Index Control</title>
|
||||
#[metas]#
|
||||
</head>
|
||||
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
|
||||
#[header]#
|
||||
<br><br>
|
||||
<h2>Index Transfer</h2>
|
||||
|
||||
<form action="IndexTransfer_p.html" method="post" enctype="multipart/form-data">
|
||||
<p>The local index currently consists of (at least) #[wcount]# reverse word indexes and #[ucount]# URL references</p>
|
||||
<p>
|
||||
<table border="0" cellpadding="2" cellspacing="1">
|
||||
<tr class="TableHeader" valign="bottom">
|
||||
<td class="small" >Status</td>
|
||||
<td class="small" >Transfered Words</td>
|
||||
<td class="small" >Words Range</td>
|
||||
<td class="small" >Remote Peer</td>
|
||||
<td class="small" >Start/Stop Transfer</td>
|
||||
</tr>
|
||||
#(running)#
|
||||
<tr valign="top" class="TableCellLight">
|
||||
<td>Not running</td>
|
||||
<td align="center">-</td>
|
||||
<td align="center">-</td>
|
||||
<td>
|
||||
<select name="hostHash">
|
||||
#{hosts}#
|
||||
<option value="#[hosthash]#">#[hostname]#</option>
|
||||
#{/hosts}#
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="startIndexTransfer" value="Start Index Transfer">
|
||||
</td>
|
||||
</tr>
|
||||
</table></p>
|
||||
::
|
||||
<tr class="TableCellLight">
|
||||
<td>#[status]#</td>
|
||||
<td align="right">#[twcount]# (#[twpercent]#%) </td>
|
||||
<td align="rigth"><tt>#[twrange]#</tt></td>
|
||||
<td>#[peerName]#</td>
|
||||
<td>#(stopped)#<input type="submit" name="stopIndexTransfer" value="Stop Index Transfer">::
|
||||
<input type="submit" name="newIndexTransfer" value="Start New Index Transfer">#(/stopped)#</td>
|
||||
</tr>
|
||||
#(/running)#
|
||||
</table>
|
||||
</form>
|
||||
|
||||
#[footer]#
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,126 @@
|
||||
//IndexControl_p.java
|
||||
//-----------------------
|
||||
//part of the AnomicHTTPD caching proxy
|
||||
//(C) by Michael Peter Christen; mc@anomic.de
|
||||
//first published on http://www.anomic.de
|
||||
//Frankfurt, Germany, 2004
|
||||
//last change: 02.05.2004
|
||||
//
|
||||
//This program is free software; you can redistribute it and/or modify
|
||||
//it under the terms of the GNU General Public License as published by
|
||||
//the Free Software Foundation; either version 2 of the License, or
|
||||
//(at your option) any later version.
|
||||
//
|
||||
//This program 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 General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU General Public License
|
||||
//along with this program; if not, write to the Free Software
|
||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
//Using this software in any meaning (reading, learning, copying, compiling,
|
||||
//running) means that you agree that the Author(s) is (are) not responsible
|
||||
//for cost, loss of data or any harm that may be caused directly or indirectly
|
||||
//by usage of this softare or this documentation. The usage of this software
|
||||
//is on your own risk. The installation and usage (starting/running) of this
|
||||
//software may allow other people or application to access your computer and
|
||||
//any attached devices and is highly dependent on the configuration of the
|
||||
//software which must be done by the user of the software; the author(s) is
|
||||
//(are) also not responsible for proper configuration and usage of the
|
||||
//software, even if provoked by documentation provided together with
|
||||
//the software.
|
||||
//
|
||||
//Any changes to this file according to the GPL as documented in the file
|
||||
//gpl.txt aside this file in the shipment you received can be done to the
|
||||
//lines that follows this copyright notice here, but changes must not be
|
||||
//done inside the copyright notive above. A re-distribution must contain
|
||||
//the intact and unchanged copyright notice.
|
||||
//Contributions and changes to the program code must be marked as such.
|
||||
|
||||
//You must compile this file with
|
||||
//javac -classpath .:../Classes IndexControl_p.java
|
||||
//if the shell's current path is HTROOT
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import de.anomic.http.httpHeader;
|
||||
import de.anomic.plasma.plasmaSwitchboard;
|
||||
import de.anomic.plasma.plasmaWordIndexDistribution;
|
||||
import de.anomic.server.serverObjects;
|
||||
import de.anomic.server.serverSwitch;
|
||||
import de.anomic.yacy.yacyCore;
|
||||
import de.anomic.yacy.yacySeed;
|
||||
|
||||
public class IndexTransfer_p {
|
||||
|
||||
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
||||
// return variable that accumulates replacements
|
||||
plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
|
||||
serverObjects prop = new serverObjects();
|
||||
|
||||
if (post != null) {
|
||||
if (post.containsKey("startIndexTransfer")) {
|
||||
yacySeed seed = yacyCore.seedDB.getConnected(post.get("hostHash", ""));
|
||||
if (seed == null) return prop;
|
||||
|
||||
switchboard.indexDistribution.startTransferWholeIndex(seed,true);
|
||||
} else if (post.containsKey("stopIndexTransfer")) {
|
||||
switchboard.indexDistribution.stopTransferWholeIndex();
|
||||
} else if (post.containsKey("newIndexTransfer")) {
|
||||
switchboard.indexDistribution.abortTransferWholeIndex();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// insert constants
|
||||
plasmaWordIndexDistribution.transferIndexThread transfThread = switchboard.indexDistribution.transferIdxThread;
|
||||
int wcount = 0, ucount = 0;
|
||||
prop.put("wcount", Integer.toString(wcount = switchboard.wordIndex.size()));
|
||||
prop.put("ucount", Integer.toString(ucount = switchboard.urlPool.loadedURL.size()));
|
||||
prop.put("running",(transfThread==null)?0:1);
|
||||
if (transfThread != null) {
|
||||
int transferedIdxCount = transfThread.getTransferedIndexCount();
|
||||
prop.put("running_status",transfThread.getStatus());
|
||||
prop.put("running_twcount",transferedIdxCount);
|
||||
prop.put("running_twpercent",Float.toString(transferedIdxCount*100/wcount));
|
||||
prop.put("running_twrange", transfThread.getRange());
|
||||
prop.put("running_peerName",transfThread.getSeed().getName());
|
||||
prop.put("running_stopped",(transfThread.isFinished()) || (!transfThread.isAlive())?1:0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//List known hosts
|
||||
yacySeed seed;
|
||||
int hc = 0;
|
||||
if ((yacyCore.seedDB != null) && (yacyCore.seedDB.sizeConnected() > 0)) {
|
||||
Enumeration e = yacyCore.dhtAgent.getAcceptRemoteIndexSeeds("------------");
|
||||
TreeMap hostList = new TreeMap();
|
||||
while (e.hasMoreElements()) {
|
||||
seed = (yacySeed) e.nextElement();
|
||||
if (seed != null) hostList.put(seed.get("Name", "nameless"),seed.hash);
|
||||
}
|
||||
|
||||
String hostName = null;
|
||||
try {
|
||||
while ((hostName = (String) hostList.firstKey()) != null) {
|
||||
prop.put("running_hosts_" + hc + "_hosthash", hostList.get(hostName));
|
||||
prop.put("running_hosts_" + hc + "_hostname", /*seed.hash + " " +*/ hostName);
|
||||
hc++;
|
||||
hostList.remove(hostName);
|
||||
}
|
||||
} catch (NoSuchElementException ex) {}
|
||||
prop.put("running_hosts", Integer.toString(hc));
|
||||
} else {
|
||||
prop.put("running_hosts", "0");
|
||||
}
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in new issue