2012-06-28 14:27:29 +02:00
|
|
|
// IndexShare_p.java
|
2005-04-07 21:19:42 +02:00
|
|
|
// -----------------------
|
|
|
|
// part of the AnomicHTTPD caching proxy
|
2008-07-20 19:14:51 +02:00
|
|
|
// (C) by Michael Peter Christen; mc@yacy.net
|
2005-04-07 21:19:42 +02:00
|
|
|
// first published on http://www.anomic.de
|
|
|
|
// Frankfurt, Germany, 2004
|
|
|
|
// last change: 24.08.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
|
|
|
|
|
2005-05-12 19:50:45 +02:00
|
|
|
// You must compile this file with
|
2005-04-07 21:19:42 +02:00
|
|
|
// javac -classpath .:../classes IndexShare_p.java
|
|
|
|
// if the shell's current path is HTROOT
|
|
|
|
|
|
|
|
//import java.util.*;
|
|
|
|
//import java.net.*;
|
|
|
|
//import java.io.*;
|
|
|
|
//import de.anomic.tools.*;
|
2010-08-23 14:32:02 +02:00
|
|
|
import net.yacy.cora.protocol.RequestHeader;
|
2011-09-25 18:59:06 +02:00
|
|
|
import net.yacy.search.Switchboard;
|
|
|
|
import net.yacy.search.SwitchboardConstants;
|
|
|
|
import net.yacy.search.index.Segment;
|
2012-09-21 15:48:16 +02:00
|
|
|
import net.yacy.server.serverObjects;
|
|
|
|
import net.yacy.server.serverSwitch;
|
2005-04-07 21:19:42 +02:00
|
|
|
|
|
|
|
public class IndexShare_p {
|
|
|
|
|
2012-07-05 09:14:04 +02:00
|
|
|
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
2006-12-20 00:55:52 +01:00
|
|
|
// return variable that accumulates replacements
|
2009-10-09 16:44:20 +02:00
|
|
|
final Switchboard sb = (Switchboard) env;
|
2008-08-20 09:54:56 +02:00
|
|
|
final serverObjects prop = new serverObjects();
|
2005-04-07 21:19:42 +02:00
|
|
|
|
2009-10-09 16:44:20 +02:00
|
|
|
// get segment
|
2012-06-28 14:27:29 +02:00
|
|
|
Segment indexSegment = sb.index;
|
|
|
|
|
2008-08-20 09:54:56 +02:00
|
|
|
if (post == null) {
|
2009-10-09 16:44:20 +02:00
|
|
|
prop.put("linkfreq", sb.getConfigLong("defaultLinkReceiveFrequency",30));
|
|
|
|
prop.put("wordfreq", sb.getConfigLong("defaultWordReceiveFrequency",10));
|
2005-04-07 21:19:42 +02:00
|
|
|
prop.put("dtable", "");
|
|
|
|
prop.put("rtable", "");
|
2012-08-31 13:03:00 +02:00
|
|
|
prop.putNum("wcount", indexSegment.RWICount());
|
2013-02-22 15:45:15 +01:00
|
|
|
prop.putNum("ucount", indexSegment.fulltext().collectionSize());
|
2005-04-07 21:19:42 +02:00
|
|
|
return prop; // be save
|
|
|
|
}
|
2012-06-28 14:27:29 +02:00
|
|
|
|
2005-04-07 21:19:42 +02:00
|
|
|
if (post.containsKey("indexsharesetting")) {
|
2011-03-15 02:03:35 +01:00
|
|
|
sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, post.containsKey("distribute"));
|
|
|
|
sb.setConfig("allowReceiveIndex", post.containsKey("receive"));
|
|
|
|
sb.setConfig("defaultLinkReceiveFrequency", post.getInt("linkfreq", 30));
|
|
|
|
sb.setConfig("defaultWordReceiveFrequency", post.getInt("wordfreq", 10));
|
2005-04-07 21:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// insert constants
|
2012-08-31 13:03:00 +02:00
|
|
|
prop.putNum("wcount", indexSegment.RWICount());
|
2013-02-22 15:45:15 +01:00
|
|
|
prop.putNum("ucount", indexSegment.fulltext().collectionSize());
|
2012-06-28 14:27:29 +02:00
|
|
|
|
2006-12-20 00:55:52 +01:00
|
|
|
// return rewrite properties
|
|
|
|
return prop;
|
2005-04-07 21:19:42 +02:00
|
|
|
}
|
|
|
|
}
|