addon to svn 7880

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7882 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 7b7a196243
commit c64faf41e2

@ -44,9 +44,11 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
@ -75,12 +77,10 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import de.anomic.data.UserDB;
import de.anomic.search.Switchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverCore.Session;
import de.anomic.server.serverHandler;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.serverCore.Session;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
/**
@ -251,7 +251,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
return persistent;
}
private boolean handleYaCyHopAuthentication(final RequestHeader header, HashMap<String, Object> prop, Session session) {
private boolean handleYaCyHopAuthentication(final RequestHeader header, final HashMap<String, Object> prop, final Session session) {
// check if the user has allowed that his/her peer is used for hops
if (!allowYaCyHop(session)) return false;
@ -355,7 +355,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
public Boolean UNKNOWN(final String arg, final Session session) throws IOException {
//System.out.println("UNKNOWN " + arg);
HashMap<String, Object> prop = parseRequestLine(HeaderFramework.METHOD_GET, arg, session);
final HashMap<String, Object> prop = parseRequestLine(HeaderFramework.METHOD_GET, arg, session);
int pos;
String unknownCommand = null, args = null;
if ((pos = arg.indexOf(' ')) > 0) {
@ -582,7 +582,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
} else {
httpVersion = "HTTP/1.0";
}
HashMap<String, Object> prop = new HashMap<String, Object>();
final HashMap<String, Object> prop = new HashMap<String, Object>();
prop.put(HeaderFramework.CONNECTION_PROP_HTTP_VER, httpVersion);
// parse hostname and port
@ -620,7 +620,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
// pass to proxy
if (((allowYaCyHop(session)) && (handleYaCyHopAuthentication(header, prop, session))) ||
((allowProxy(session)) && (this.handleProxyAuthentication(header, prop, session)))) {
((allowProxy(session)) && (handleProxyAuthentication(header, prop, session)))) {
HTTPDProxyHandler.doConnect(prop, header, session.in, session.out);
} else {
// not authorized through firewall blocking (ip does not match filter)
@ -664,7 +664,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
// parsing post request bodies with a given length
if (length != -1) {
buffer = new byte[length];
int bytesRead = in.read(buffer);
final int bytesRead = in.read(buffer);
assert bytesRead == buffer.length;
// parsing post request bodies which are gzip content-encoded
} else {
@ -808,7 +808,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
final InputStream body = prepareBody(header, in);
RequestContext request = new yacyContextRequest(header, body);
final RequestContext request = new yacyContextRequest(header, body);
// check information
if (!FileUploadBase.isMultipartContent(request)) {
@ -816,7 +816,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
}
// check if we have enough memory
if (!MemoryControl.request(request.getContentLength() * 3 + 10*1024*1024, false)) {
if (request.getContentLength() > 0 && !MemoryControl.request(request.getContentLength() * 3, false)) {
throw new IOException("not enough memory available for request. request.getContentLength() = " + request.getContentLength() + ", MemoryControl.available() = " + MemoryControl.available());
}
@ -826,7 +826,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
try {
final FileUpload upload = new FileUpload(DISK_FILE_ITEM_FACTORY);
items = upload.parseRequest(request);
} catch (FileUploadException e) {
} catch (final FileUploadException e) {
throw new IOException("FileUploadException " + e.getMessage());
}
@ -913,7 +913,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
*/
// @Override
public InputStream getInputStream() throws IOException {
return inStream;
return this.inStream;
}
}

@ -81,9 +81,9 @@ public class MemoryControl {
public static long getAverageGCFree() {
long x = 0;
int y = 0;
for (int i=0; i<gcs.length; i++)
if (gcs[i] != 0) {
x += gcs[i];
for (final long gc : gcs)
if (gc != 0) {
x += gc;
y++;
}
return (y == 0) ? 0 : x / y;
@ -143,7 +143,8 @@ public class MemoryControl {
* @return whether enough memory could be freed (or is free) or not
*/
public static boolean request(final long size, final boolean force) {
boolean r = request0(size, force);
if (size <= 0) return true;
final boolean r = request0(size, force);
shortStatus = !r;
return r;
}
@ -160,7 +161,7 @@ public class MemoryControl {
// this is only called if we expect that an allocation of <size> bytes would cause the jvm to call the GC anyway
final long memBefore = avail;
boolean performedGC = gc(10000, "serverMemory.runGC(...)");
final boolean performedGC = gc(10000, "serverMemory.runGC(...)");
avail = available();
if (performedGC) {
final long freed = avail - memBefore;

Loading…
Cancel
Save