added a submenu ConfigHTCache_p.html to set the size of the HTCache separately from the proxy configuration.
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7291 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
parent
85c65475fa
commit
445619f3ec
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>YaCy '#[clientname]#': Indexing with Proxy</title>
|
||||
#%env/templates/metas.template%#
|
||||
</head>
|
||||
<body id="ConfigHTCache">
|
||||
#%env/templates/header.template%#
|
||||
#%env/templates/submenuConfig.template%#
|
||||
<h2>Hypertext Cache Configuration</h2>
|
||||
<p>
|
||||
The HTCache stores content retrieved by the HTTP and FTP protocol. Documents from smb:// and file:// locations are not cached.
|
||||
The cache is a rotating cache: if it is full, then the oldest entries are deleted and new one can fill the space.
|
||||
</p>
|
||||
|
||||
<form action="ConfigHTCache_p.html" method="post" enctype="multipart/form-data">
|
||||
<fieldset><legend>HTCache Configuration</legend>
|
||||
<dl>
|
||||
<dt><label for="HTCachePath">The path where the cache is stored</label></dt>
|
||||
<dd><input name="HTCachePath" id="HTCachePath" type="text" size="20" maxlength="300" value="#[HTCachePath]#" /></dd>
|
||||
<dt><label for="actualCacheSize">The current size of the cache</label></dt>
|
||||
<dd>#[actualCacheSize]# MB</dd>
|
||||
<dt><label for="maxCacheSize">The maximum size of the cache</label></dt>
|
||||
<dd><input name="maxCacheSize" id="maxCacheSize" type="text" size="8" maxlength="24" value="#[maxCacheSize]#" /> MB</dd>
|
||||
<dt> </dt>
|
||||
<dd><input type="submit" name="set" value="Set" /></dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
#%env/templates/footer.template%#
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,76 @@
|
||||
// ConfigHTCache_p.java
|
||||
// ---------------------------
|
||||
// (C) by Michael Peter Christen; mc@yacy.net
|
||||
// first published on http://www.anomic.de
|
||||
// Frankfurt, Germany, 2004
|
||||
//
|
||||
// $LastChangedDate: 2010-09-02 21:24:22 +0200 (Do, 02 Sep 2010) $
|
||||
// $LastChangedRevision: 7092 $
|
||||
// $LastChangedBy: orbiter $
|
||||
//
|
||||
// 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
|
||||
|
||||
// You must compile this file with
|
||||
// javac -classpath .:../classes ProxyIndexingMonitor_p.java
|
||||
// if the shell's current path is HTROOT
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.kelondro.logging.Log;
|
||||
|
||||
import de.anomic.http.client.Cache;
|
||||
import de.anomic.search.SwitchboardConstants;
|
||||
import de.anomic.server.serverObjects;
|
||||
import de.anomic.server.serverSwitch;
|
||||
|
||||
public class ConfigHTCache_p {
|
||||
|
||||
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
||||
// return variable that accumulates replacements
|
||||
final serverObjects prop = new serverObjects();
|
||||
|
||||
String oldProxyCachePath, newProxyCachePath;
|
||||
int newProxyCacheSize;
|
||||
|
||||
if (post != null && post.containsKey("set")) try {
|
||||
|
||||
// proxyCache - check and create the directory
|
||||
oldProxyCachePath = env.getConfig(SwitchboardConstants.HTCACHE_PATH, SwitchboardConstants.HTCACHE_PATH_DEFAULT);
|
||||
newProxyCachePath = post.get("HTCachePath", SwitchboardConstants.HTCACHE_PATH_DEFAULT);
|
||||
newProxyCachePath = newProxyCachePath.replace('\\', '/');
|
||||
if (newProxyCachePath.endsWith("/")) {
|
||||
newProxyCachePath = newProxyCachePath.substring(0, newProxyCachePath.length() - 1);
|
||||
}
|
||||
env.setConfig(SwitchboardConstants.HTCACHE_PATH, newProxyCachePath);
|
||||
final File cache = env.getDataPath(SwitchboardConstants.HTCACHE_PATH, oldProxyCachePath);
|
||||
if (!cache.isDirectory() && !cache.isFile()) cache.mkdirs();
|
||||
|
||||
// proxyCacheSize
|
||||
newProxyCacheSize = post.getInt("maxCacheSize", 64);
|
||||
if (newProxyCacheSize < 4) { newProxyCacheSize = 4; }
|
||||
env.setConfig(SwitchboardConstants.PROXY_CACHE_SIZE, newProxyCacheSize);
|
||||
Cache.setMaxCacheSize(newProxyCacheSize * 1024 * 1024);
|
||||
} catch (final Exception e) {
|
||||
Log.logException(e);
|
||||
}
|
||||
|
||||
prop.put("HTCachePath", env.getConfig(SwitchboardConstants.HTCACHE_PATH, SwitchboardConstants.HTCACHE_PATH_DEFAULT));
|
||||
prop.put("actualCacheSize", (Cache.getActualCacheSize() / 1024 / 1024));
|
||||
prop.put("maxCacheSize", env.getConfigLong(SwitchboardConstants.PROXY_CACHE_SIZE, 64));
|
||||
// return rewrite properties
|
||||
return prop;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue