made class methods static where possible

pull/1/head
Michael Peter Christen 13 years ago
parent 5bd3c90907
commit b0c408788b

@ -33,10 +33,10 @@ org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning

@ -109,7 +109,7 @@ public class BlacklistCleaner_p {
final Map<String, BlacklistError> illegalEntries = getIllegalEntries(blacklistToUse, Switchboard.urlBlacklist, allowRegex);
prop.put(RESULTS + "blList", blacklistToUse);
prop.put(RESULTS + "entries", illegalEntries.size());
prop.putHTML(RESULTS + "blEngine", Switchboard.urlBlacklist.getEngineInfo());
prop.putHTML(RESULTS + "blEngine", Blacklist.getEngineInfo());
prop.put(RESULTS + "disabled", (illegalEntries.isEmpty()) ? "1" : "0");
if (!illegalEntries.isEmpty()) {
prop.put(RESULTS + DISABLED + "entries", illegalEntries.size());
@ -255,7 +255,7 @@ public class BlacklistCleaner_p {
}
legalEntries.add(element);
err = blEngine.checkError(element, properties);
err = Blacklist.checkError(element, properties);
if (err.getInt() > 0) {
illegalEntries.put(element, err);

@ -37,6 +37,7 @@ import java.util.TreeMap;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.util.FileUtils;
import net.yacy.peers.Seed;
import net.yacy.repository.Blacklist;
import net.yacy.search.Switchboard;
import de.anomic.data.ListManager;
import de.anomic.server.serverObjects;
@ -57,7 +58,7 @@ public class BlacklistImpExp_p {
String blacklistToUse = null;
final serverObjects prop = new serverObjects();
prop.putHTML("blacklistEngine", Switchboard.urlBlacklist.getEngineInfo());
prop.putHTML("blacklistEngine", Blacklist.getEngineInfo());
// if we have not chosen a blacklist until yet we use the first file
if (blacklistToUse == null && dirlist != null && !dirlist.isEmpty()) {

@ -34,6 +34,7 @@ import java.net.MalformedURLException;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.repository.Blacklist;
import net.yacy.repository.Blacklist.BlacklistType;
import net.yacy.search.Switchboard;
import de.anomic.data.ListManager;
@ -49,7 +50,7 @@ public class BlacklistTest_p {
ListManager.listsPath = new File(ListManager.switchboard.getDataPath(),ListManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
final serverObjects prop = new serverObjects();
prop.putHTML("blacklistEngine", Switchboard.urlBlacklist.getEngineInfo());
prop.putHTML("blacklistEngine", Blacklist.getEngineInfo());
// do all post operations
if(post != null && post.containsKey("testList")) {

@ -70,7 +70,7 @@ public class Blacklist_p {
String blacklistToUse = null;
final serverObjects prop = new serverObjects();
prop.putHTML("blacklistEngine", Switchboard.urlBlacklist.getEngineInfo());
prop.putHTML("blacklistEngine", Blacklist.getEngineInfo());
// do all post operations
if (post != null) {

@ -75,7 +75,7 @@ public final class Connections_p {
// waiting for all threads to finish
int idx = 0, numActiveRunning = 0, numActivePending = 0;
boolean dark = true;
for (final Session s: ((serverCore) httpd).getJobList()) {
for (final Session s: serverCore.getJobList()) {
if (!s.isAlive()) continue;
// get the session runtime

@ -122,7 +122,7 @@ public class Network {
prop.put("table_my-dhtreceive", seed.getFlagAcceptRemoteIndex() ? 1 : 0);
prop.put("table_my-nodestate", seed.getFlagRootNode() ? 1 : 0);
myppm = sb.currentPPM();
myppm = Switchboard.currentPPM();
myqph = 60d * sb.averageQPM();
prop.put("table_my-version", seed.get(Seed.VERSION, "-"));
prop.put("table_my-utc", seed.get(Seed.UTC, "-"));

@ -51,7 +51,7 @@ public class status_p {
prop.put("rejected", "0");
sb.updateMySeed();
final int cacheMaxSize = (int) sb.getConfigLong(SwitchboardConstants.WORDCACHE_MAX_COUNT, 10000);
prop.putNum("ppm", sb.currentPPM());
prop.putNum("ppm", Switchboard.currentPPM());
prop.putNum("qpm", sb.peers.mySeed().getQPM());
prop.putNum("wordCacheSize", segment.termIndex().getBufferSize());
prop.putNum("wordCacheMaxSize", cacheMaxSize);

@ -104,7 +104,7 @@ public class yacysearch {
final UserDB.Entry user = sb.userDB.getUser(header);
authenticated = (user != null && user.hasRight(UserDB.AccessRight.EXTENDED_SEARCH_RIGHT));
}
final boolean localhostAccess = sb.accessFromLocalhost(header);
final boolean localhostAccess = Switchboard.accessFromLocalhost(header);
final String promoteSearchPageGreeting =
(env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) ? env.getConfig(
"network.unit.description",

@ -541,7 +541,7 @@ public class CrawlQueues {
* @param url
* @return
*/
private String urlToString(final DigestURI url) {
private static String urlToString(final DigestURI url) {
return (url == null ? "null" : url.toNormalform(true, false));
}

@ -130,7 +130,7 @@ public final class CrawlStacker {
clear();
}
private boolean prefetchHost(final String host) {
private static boolean prefetchHost(final String host) {
// returns true when the host was known in the dns cache.
// If not, the host is stacked on the fetch stack and false is returned
try {

@ -553,7 +553,7 @@ public final class CrawlSwitchboard
* @param file DB file
* @return crawl profile data
*/
private MapHeap loadFromDB(final File file) {
private static MapHeap loadFromDB(final File file) {
MapHeap ret;
try {
ret = new MapHeap(file, Word.commonHashLength, NaturalOrder.naturalOrder, 1024 * 64, 500, ' ');

@ -308,7 +308,7 @@ public class NoticedURL {
}
}
private Request pop(final Balancer balancer, final boolean delay, final CrawlSwitchboard cs, final RobotsTxt robots) throws IOException {
private static Request pop(final Balancer balancer, final boolean delay, final CrawlSwitchboard cs, final RobotsTxt robots) throws IOException {
// this is a filo - pop
int s;
Request entry;

@ -211,6 +211,7 @@ public class WikiCode extends AbstractWikiParser implements WikiParser {
* @return HTML fragment.
* @throws IOException in case input from reader can not be read.
*/
@Override
protected String transform(final String hostport, final BufferedReader reader, final int length)
throws IOException {
final StringBuilder out = new StringBuilder(length);
@ -345,7 +346,7 @@ public class WikiCode extends AbstractWikiParser implements WikiParser {
* @param properties String which may contain several table properties and/or junk.
* @return String containing only table properties.
*/
private StringBuilder filterTableProperties(final String properties) {
private static StringBuilder filterTableProperties(final String properties) {
final String[] values = properties.replaceAll("&quot;", EMPTY).split("[= ]"); //splitting the string at = and blanks
final StringBuilder stringBuilder = new StringBuilder(properties.length());
String key, value;
@ -376,7 +377,7 @@ public class WikiCode extends AbstractWikiParser implements WikiParser {
* @param stringBuilder this is what key/value are appended to.
* @return
*/
private StringBuilder appendKeyValuePair(final String key, final String value, final StringBuilder stringBuilder) {
private static StringBuilder appendKeyValuePair(final String key, final String value, final StringBuilder stringBuilder) {
return stringBuilder.append(" ").append(key).append("=\"").append(value).append("\"");
}
@ -577,7 +578,7 @@ public class WikiCode extends AbstractWikiParser implements WikiParser {
* @param line line of text to be transformed from wiki code to HTML
* @return HTML fragment
*/
private String processLinksAndImages(final String hostport, String line) {
private static String processLinksAndImages(final String hostport, String line) {
// create links
String kl, kv, alt, align;
@ -1009,7 +1010,7 @@ public class WikiCode extends AbstractWikiParser implements WikiParser {
}
private String processMetadata(String line) {
private static String processMetadata(String line) {
int p, q, s = 0;
while ((p = line.indexOf(WIKI_OPEN_METADATA, s)) >= 0 && (q = line.indexOf(WIKI_CLOSE_METADATA, p + 1)) >= 0) {
s = q; // continue with next position

@ -222,7 +222,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
* @param prop
* @return <code>true</code> if a persistent connection was requested or <code>false</code> otherwise
*/
private boolean handlePersistentConnection(final RequestHeader header, final HashMap<String, Object> prop) {
private static boolean handlePersistentConnection(final RequestHeader header, final HashMap<String, Object> prop) {
if (!keepAliveSupport) {
prop.put(HeaderFramework.CONNECTION_PROP_PERSISTENT,"close");
@ -256,7 +256,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
return persistent;
}
private boolean handleYaCyHopAuthentication(final RequestHeader header, final HashMap<String, Object> prop) {
private static boolean handleYaCyHopAuthentication(final RequestHeader header, final HashMap<String, Object> prop) {
// check if the user has allowed that his/her peer is used for hops
if (!allowYaCyHop()) return false;
@ -425,7 +425,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
}
}
private void logUnexpectedError(final Exception e, final String address) {
private static void logUnexpectedError(final Exception e, final String address) {
if (e instanceof InterruptedException) {
log.logInfo("Interruption detected");
} else {

@ -445,7 +445,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
this.log.logConfig("* terminated");
}
public List<Session> getJobList() {
public static List<Session> getJobList() {
final Thread[] threadList = new Thread[sessionThreadGroup.activeCount()];
serverCore.sessionThreadGroup.enumerate(threadList, false);
final ArrayList<Session> l = new ArrayList<Session>();
@ -477,7 +477,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
}
// idle sensor: the thread is idle if there are no sessions running
public boolean idle() {
public static boolean idle() {
// idleThreadCheck();
final Thread[] threadList = new Thread[sessionThreadGroup.activeCount()];
serverCore.sessionThreadGroup.enumerate(threadList, false);
@ -1086,7 +1086,8 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
sslsock.addHandshakeCompletedListener(
new HandshakeCompletedListener() {
public void handshakeCompleted(
@Override
public void handshakeCompleted(
final HandshakeCompletedEvent event) {
System.out.println("Handshake finished!");
System.out.println(

@ -96,6 +96,9 @@ public class serverCoreSocket extends Socket {
case 2:
this.sslType = "TLS_1_1";
break;
default:
this.sslType = "SSL_3";
break;
}
this.isSSL = true;
//} else {
@ -106,35 +109,43 @@ public class serverCoreSocket extends Socket {
((PushbackInputStream) in).unread(preRead);
}
@Override
public InetAddress getInetAddress() {
return this.sock.getInetAddress();
}
@Override
public InetAddress getLocalAddress() {
return this.sock.getLocalAddress();
}
@Override
public int getPort() {
return this.sock.getPort();
}
@Override
public int getLocalPort() {
return this.sock.getLocalPort();
}
@Override
public SocketAddress getRemoteSocketAddress() {
return this.sock.getRemoteSocketAddress();
}
@Override
public SocketAddress getLocalSocketAddress() {
return this.sock.getLocalSocketAddress();
}
@Override
public SocketChannel getChannel() {
return this.sock.getChannel();
}
@Override
public InputStream getInputStream() throws IOException {
if (this.input == null) {
this.input = new PushbackInputStream(this.sock.getInputStream(),100);
@ -142,47 +153,58 @@ public class serverCoreSocket extends Socket {
return this.input;
}
@Override
public OutputStream getOutputStream() throws IOException {
return this.sock.getOutputStream();
}
@Override
public synchronized void close() throws IOException {
this.sock.close();
}
@Override
public void shutdownInput() throws IOException {
this.sock.shutdownInput();
}
@Override
public void shutdownOutput() throws IOException {
this.sock.shutdownOutput();
}
@Override
public String toString() {
return this.sock.toString();
}
@Override
public boolean isConnected() {
return this.sock.isConnected();
}
@Override
public boolean isBound() {
return this.sock.isBound();
}
@Override
public boolean isClosed() {
return this.sock.isClosed();
}
@Override
public boolean isInputShutdown() {
return this.sock.isInputShutdown();
}
@Override
public boolean isOutputShutdown() {
return this.sock.isOutputShutdown();
}
@Override
public synchronized void setSoTimeout(final int timeout) throws SocketException {
this.sock.setSoTimeout(timeout);
}

@ -466,7 +466,7 @@ public class serverSwitch
final List<String> list = new ArrayList<String>();
final WorkflowThread st = getThread(threadName);
for ( final Session s : ((serverCore) st).getJobList() ) {
for ( final Session s : serverCore.getJobList() ) {
if ( !s.isAlive() ) {
continue;
}
@ -483,7 +483,7 @@ public class serverSwitch
}
final WorkflowThread st = getThread(threadName);
for ( final Session s : ((serverCore) st).getJobList() ) {
for ( final Session s : serverCore.getJobList() ) {
if ( (s.isAlive()) && (s.getName().equals(sessionName)) ) {
// try to stop session
s.setStopped(true);

@ -50,8 +50,9 @@ public class YaCySearchClient {
* YaCy Search Results are produced in Opensearch format which is basically RSS.
* The YaCy Search Result API Client is therefore implemented as a simple RSS reader.
*/
private String host, query;
private int port, offset;
private final String host, query;
private final int port;
private int offset;
public YaCySearchClient(final String host, final int port, final String query) {
this.host = host;
@ -71,13 +72,13 @@ public class YaCySearchClient {
URL url;
Document doc;
String u = new StringBuilder(120).append("http://")
.append(host)
.append(YaCySearchClient.this.host)
.append(":")
.append(port)
.append(YaCySearchClient.this.port)
.append("/yacysearch.rss?verify=false&startRecord=")
.append(offset)
.append(YaCySearchClient.this.offset)
.append("&maximumRecords=10&resource=local&query=")
.append(query.replaceAll(" ", "+")).toString();
.append(YaCySearchClient.this.query.replaceAll(" ", "+")).toString();
try { url = new URL(u); } catch (MalformedURLException e) { throw new IOException (e); }
try { doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(url.openStream()); }
catch (ParserConfigurationException e) { throw new IOException (e); }
@ -98,11 +99,11 @@ public class YaCySearchClient {
public static class RSSEntry {
String title, link, snippet;
public RSSEntry(Element element) {
title = val(element, "title", "");
link = val(element, "link", "");
snippet = val(element, "description", "");
this.title = val(element, "title", "");
this.link = val(element, "link", "");
this.snippet = val(element, "description", "");
}
private String val(Element parent, String label, String dflt) {
private static String val(Element parent, String label, String dflt) {
Element e = (Element) parent.getElementsByTagName(label).item(0);
Node child = e.getFirstChild();
return (child instanceof CharacterData) ?
@ -112,11 +113,11 @@ public class YaCySearchClient {
@Override
public String toString() {
return new StringBuilder(80).append("Title : ")
.append(title)
.append(this.title)
.append("\nLink : ")
.append(link)
.append(this.link)
.append("\nDescription: ")
.append(snippet)
.append(this.snippet)
.append("\n").toString();
}
}

@ -45,7 +45,7 @@ public class JSONTokener {
private int index;
private int line;
private char previous;
private Reader reader;
private final Reader reader;
private boolean usePrevious;
@ -82,7 +82,7 @@ public class JSONTokener {
* the next number or identifier.
*/
public void back() throws JSONException {
if (usePrevious || index <= 0) {
if (this.usePrevious || this.index <= 0) {
throw new JSONException("Stepping back two steps is not supported");
}
this.index -= 1;
@ -112,7 +112,7 @@ public class JSONTokener {
}
public boolean end() {
return eof && !usePrevious;
return this.eof && !this.usePrevious;
}
@ -356,6 +356,8 @@ public class JSONTokener {
case '(':
back();
return new JSONArray(this);
default:
break;
}
/*
@ -395,11 +397,11 @@ public class JSONTokener {
int startIndex = this.index;
int startCharacter = this.character;
int startLine = this.line;
reader.mark(Integer.MAX_VALUE);
this.reader.mark(Integer.MAX_VALUE);
do {
c = next();
if (c == 0) {
reader.reset();
this.reader.reset();
this.index = startIndex;
this.character = startCharacter;
this.line = startLine;
@ -433,6 +435,6 @@ public class JSONTokener {
*/
@Override
public String toString() {
return " at " + index + " [character " + this.character + " line " + this.line + "]";
return " at " + this.index + " [character " + this.character + " line " + this.line + "]";
}
}

@ -609,7 +609,7 @@ public class HTTPClient {
}
}
private byte[] getByteArray(final HttpEntity entity, final int maxBytes) throws IOException {
private static byte[] getByteArray(final HttpEntity entity, final int maxBytes) throws IOException {
final InputStream instream = entity.getContent();
if (instream == null) {
return null;
@ -657,7 +657,7 @@ public class HTTPClient {
httpParams.setParameter(HTTP.TARGET_HOST, this.host);
}
private void setProxy(final HttpParams httpParams) {
private static void setProxy(final HttpParams httpParams) {
if (ProxySettings.use)
ConnRouteParams.setDefaultProxy(httpParams, ProxySettings.getProxyHost());
// TODO find a better way for this

@ -145,7 +145,7 @@ public class DCEntry extends TreeMap<String, String> {
}
}
private String bestU(String[] urls) {
private static String bestU(String[] urls) {
for (String uu: urls) {
if (uu.startsWith("http://") && (uu.endsWith(".html") || uu.endsWith(".htm") || uu.endsWith(".pdf") || uu.endsWith(".doc") || uu.endsWith(".rss") || uu.endsWith(".xml"))) return uu;
}
@ -250,7 +250,7 @@ public class DCEntry extends TreeMap<String, String> {
return Double.parseDouble(t);
}
private String stripCDATA(String s) {
private static String stripCDATA(String s) {
if (s == null) return null;
s = s.trim();
if (s.startsWith("<![CDATA[")) s = s.substring(9);

@ -82,7 +82,7 @@ public class GeoLocation extends IntegerGeoPoint implements Comparable<GeoLocati
return 0;
}
private long ph(int population) {
private static long ph(int population) {
if (population > 10000) population -= 10000;
return population;
}

@ -57,7 +57,7 @@ public class AugmentParser extends AbstractParser implements Parser {
return retDocs;
}
private Document analyze (Document alreadyParsedDocument, DigestURI url,
private static Document analyze (Document alreadyParsedDocument, DigestURI url,
String mimeType, String charset) {
Document newDoc = new Document(url, mimeType, charset, null, null, null, "", "",

@ -80,7 +80,7 @@ public class csvParser extends AbstractParser implements Parser {
false)};
}
private String concatRow(String[] columns) {
private static String concatRow(String[] columns) {
final StringBuilder sb = new StringBuilder(80);
for (final String column : columns) {
if (sb.length() > 0) sb.append(' ');
@ -90,7 +90,7 @@ public class csvParser extends AbstractParser implements Parser {
return sb.toString();
}
private List<String[]> getTable(String charset, InputStream source) {
private static List<String[]> getTable(String charset, InputStream source) {
final List<String[]> rows = new ArrayList<String[]>();
BufferedReader reader;
try {

@ -95,12 +95,12 @@ public class bmpParser {
public INFOHEADER(final byte[] s, final int offset) {
// read info-header
biWidth = DWORD(s, offset + 4);
biHeight = DWORD(s, offset + 8);
biBitCount = WORD(s, offset + 14);
biCompression = WORD(s, offset + 16);
biSizeImage = DWORD(s, offset + 20);
biClrUsed = DWORD(s, offset + 32);
this.biWidth = DWORD(s, offset + 4);
this.biHeight = DWORD(s, offset + 8);
this.biBitCount = WORD(s, offset + 14);
this.biCompression = WORD(s, offset + 16);
this.biSizeImage = DWORD(s, offset + 20);
this.biClrUsed = DWORD(s, offset + 32);
}
}
@ -111,28 +111,28 @@ public class bmpParser {
public COLORTABLE(final byte[] s, final int offset, final INFOHEADER infoheader) {
// read colortable
colorbytes = 0; // for consistency check
this.colorbytes = 0; // for consistency check
if (infoheader.biClrUsed == 0 || infoheader.biClrUsed > 1024) {
if ((infoheader.biBitCount == 1) || (infoheader.biBitCount == 4) || (infoheader.biBitCount == 8)) {
colorindex = new int[1 << infoheader.biBitCount];
colorbytes = 4 * colorindex.length;
this.colorindex = new int[1 << infoheader.biBitCount];
this.colorbytes = 4 * this.colorindex.length;
int color;
for (int i = 0; i < colorindex.length; i++) {
for (int i = 0; i < this.colorindex.length; i++) {
// translate BGR into RGB color Scheme
color = 0xffffff & DWORD(s, offset + 4 * i);
colorindex[i] = color;
this.colorindex[i] = color;
}
} else {
colorindex = null;
this.colorindex = null;
}
} else {
colorindex = new int[infoheader.biClrUsed]; // OOM DANGER!
colorbytes = 4 * colorindex.length;
this.colorindex = new int[infoheader.biClrUsed]; // OOM DANGER!
this.colorbytes = 4 * this.colorindex.length;
int color;
for (int i = 0; i < colorindex.length; i++) {
for (int i = 0; i < this.colorindex.length; i++) {
// translate BGR into RGB color Scheme
color = 0xffffff & DWORD(s, offset + 4 * i);
colorindex[i] = color;
this.colorindex[i] = color;
//if (debugmode) System.out.println("Color " + i + " = " + Integer.toHexString(colorindex[i]));
}
}
@ -146,7 +146,7 @@ public class bmpParser {
public IMAGEMAP(final byte[] s, final int offset, final int width, final int height, final int compression, final int bitcount, final COLORTABLE colortable) {
// parse picture content
if ((width != 0) && (height != 0)) {
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
this.image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
if (compression == BI_RGB) {
if (bitcount == 1) parseBMP1(s, offset, width, height, colortable);
@ -169,14 +169,14 @@ public class bmpParser {
if (offset + n >= s.length) return; // emergency break
b = (s[offset + n] & 0xff);
n++;
image.setRGB(columns, (height - rows - 1), colortable.colorindex[(b & 0x80) >> 7]);
image.setRGB(columns + 1, (height - rows - 1), colortable.colorindex[(b & 0x40) >> 6]);
image.setRGB(columns + 2, (height - rows - 1), colortable.colorindex[(b & 0x20) >> 5]);
image.setRGB(columns + 3, (height - rows - 1), colortable.colorindex[(b & 0x10) >> 4]);
image.setRGB(columns + 4, (height - rows - 1), colortable.colorindex[(b & 0x08) >> 3]);
image.setRGB(columns + 5, (height - rows - 1), colortable.colorindex[(b & 0x04) >> 2]);
image.setRGB(columns + 6, (height - rows - 1), colortable.colorindex[(b & 0x02) >> 1]);
image.setRGB(columns + 7, (height - rows - 1), colortable.colorindex[ b & 0x01]);
this.image.setRGB(columns, (height - rows - 1), colortable.colorindex[(b & 0x80) >> 7]);
this.image.setRGB(columns + 1, (height - rows - 1), colortable.colorindex[(b & 0x40) >> 6]);
this.image.setRGB(columns + 2, (height - rows - 1), colortable.colorindex[(b & 0x20) >> 5]);
this.image.setRGB(columns + 3, (height - rows - 1), colortable.colorindex[(b & 0x10) >> 4]);
this.image.setRGB(columns + 4, (height - rows - 1), colortable.colorindex[(b & 0x08) >> 3]);
this.image.setRGB(columns + 5, (height - rows - 1), colortable.colorindex[(b & 0x04) >> 2]);
this.image.setRGB(columns + 6, (height - rows - 1), colortable.colorindex[(b & 0x02) >> 1]);
this.image.setRGB(columns + 7, (height - rows - 1), colortable.colorindex[ b & 0x01]);
}
n += fill4(n);
}
@ -190,8 +190,8 @@ public class bmpParser {
if (offset + n >= s.length) return; // emergency break
b = (s[offset + n] & 0xff);
n++;
image.setRGB(columns, (height - rows - 1), colortable.colorindex[(b & 0xf0) >> 4]);
image.setRGB(columns + 1, (height - rows - 1), colortable.colorindex[b & 0xf]);
this.image.setRGB(columns, (height - rows - 1), colortable.colorindex[(b & 0xf0) >> 4]);
this.image.setRGB(columns + 1, (height - rows - 1), colortable.colorindex[b & 0xf]);
}
n += fill4(n);
}
@ -202,7 +202,7 @@ public class bmpParser {
for (int rows = 0; rows < height; rows++) {
for (int columns = 0; columns < width; columns++) {
if (offset + n >= s.length) return; // emergency break
image.setRGB(columns, (height - rows - 1), colortable.colorindex[(s[offset + n] & 0xff)]);
this.image.setRGB(columns, (height - rows - 1), colortable.colorindex[(s[offset + n] & 0xff)]);
n++;
}
n += fill4(n);
@ -214,7 +214,7 @@ public class bmpParser {
for (int rows = 0; rows < height; rows++) {
for (int columns = 0; columns < width; columns++) {
if (offset + n + 3 >= s.length) return; // emergency break
image.setRGB(columns, (height - rows - 1), 0xffffff & DWORD(s, offset + n));
this.image.setRGB(columns, (height - rows - 1), 0xffffff & DWORD(s, offset + n));
n += 3;
}
n += fill4(n);
@ -226,13 +226,13 @@ public class bmpParser {
for (int rows = 0; rows < height; rows++) {
for (int columns = 0; columns < width; columns++) {
if (offset + n + 3 >= s.length) return; // emergency break
image.setRGB(columns, (height - rows - 1), 0xffffff & DWORD(s, offset + n));
this.image.setRGB(columns, (height - rows - 1), 0xffffff & DWORD(s, offset + n));
n += 4;
}
}
}
private final int fill4(final int x) {
private final static int fill4(final int x) {
final int r = x % 4;
if (r == 0) return 0;
return 4 - r;

@ -130,7 +130,7 @@ public class psParser extends AbstractParser implements Parser {
}
}
private void parseUsingJava(final File inputFile, final File outputFile) throws Exception {
private static void parseUsingJava(final File inputFile, final File outputFile) throws Exception {
BufferedReader reader = null;
BufferedWriter writer = null;

@ -65,7 +65,7 @@ public class RDFaParser extends AbstractParser implements Parser {
return htmlDocs;
}
private Document parseRDFa(DigestURI url, String mimeType,
private static Document parseRDFa(DigestURI url, String mimeType,
String charset, InputStream source) {
RDFaTripleImpl triple;
IRDFaTriple[] allTriples = null;
@ -108,7 +108,7 @@ public class RDFaParser extends AbstractParser implements Parser {
return htmlDocs;
}
private Document convertAllTriplesToDocument(DigestURI url,
private static Document convertAllTriplesToDocument(DigestURI url,
String mimeType, String charset, IRDFaTriple[] allTriples) {
//Set<String> languages = new HashSet<String>(2);
@ -142,7 +142,7 @@ public class RDFaParser extends AbstractParser implements Parser {
return doc;
}
private void addNotEmptyValuesToSet(Set<String> set, String value) {
private static void addNotEmptyValuesToSet(Set<String> set, String value) {
if (value != null) {
set.add(value);
}

@ -93,7 +93,7 @@ public class MapColumnIndex implements Serializable {
}
}
private void indexupdate(final byte[] primarykey, final Map<String, Collection<byte[]>> valueIdxMap, final String value) {
private static void indexupdate(final byte[] primarykey, final Map<String, Collection<byte[]>> valueIdxMap, final String value) {
Collection<byte[]> indexes = valueIdxMap.get(value);
if (indexes == null) {
// create a new index entry
@ -120,7 +120,7 @@ public class MapColumnIndex implements Serializable {
}
}
private void indexdelete(final byte[] index, final Map<String, Collection<byte[]>> valueIdxMap) {
private static void indexdelete(final byte[] index, final Map<String, Collection<byte[]>> valueIdxMap) {
Iterator<Map.Entry<String, Collection<byte[]>>> i = valueIdxMap.entrySet().iterator();
Map.Entry<String, Collection<byte[]>> ref;
while (i.hasNext()) {

@ -346,8 +346,9 @@ public class DigestURI extends MultiProtocolURI implements Serializable {
return 14;
case 3:
return 20;
default:
return 20;
}
return 20;
}
public static int domLengthNormalized(final byte[] urlHashBytes) {

@ -137,7 +137,7 @@ public final class HandleMap implements Iterable<Row.Entry> {
return new int[]{keym, this.rowdef.width(1) - valm};
}
private final int eq(final byte[] a, final byte[] b) {
private final static int eq(final byte[] a, final byte[] b) {
for (int i = 0; i < a.length; i++) {
if (a[i] != b[i]) return i;
}

@ -456,6 +456,8 @@ public final class Row implements Serializable {
break;
case Column.encoder_bytes:
throw new kelondroException("ROW", "setColLong of celltype bytes not applicable");
default:
throw new kelondroException("ROW", "setColLong has celltype none, no encoder given");
}
}
@ -473,8 +475,9 @@ public final class Row implements Serializable {
l = c + NaturalOrder.decodeLong(this.rowinstance, this.offset + colstrt, cellwidth);
NaturalOrder.encodeLong(l, this.rowinstance, this.offset + colstrt, cellwidth);
return l;
default:
throw new kelondroException("ROW", "addCol did not find appropriate encoding");
}
throw new kelondroException("ROW", "addCol did not find appropriate encoding");
}
public final byte[] getPrimaryKeyBytes() {
@ -560,8 +563,9 @@ public final class Row implements Serializable {
return NaturalOrder.decodeLong(this.rowinstance, this.offset + clstrt, length);
case Column.encoder_bytes:
throw new kelondroException("ROW", "getColLong of celltype bytes not applicable");
default:
throw new kelondroException("ROW", "getColLong did not find appropriate encoding");
}
throw new kelondroException("ROW", "getColLong did not find appropriate encoding");
}
public final byte getColByte(final int column) {

@ -101,7 +101,7 @@ public final class CachedRecords {
// open an existing table file
try {
raf = new RandomAccessFile(tablefile,"rw");
this.raf = new RandomAccessFile(tablefile,"rw");
} catch (final FileNotFoundException e) {
// should never happen
Log.logException(e);
@ -167,7 +167,7 @@ public final class CachedRecords {
* @throws IOException
*/
private final long filesize() throws IOException {
return raf.length() / recordsize;
return this.raf.length() / this.recordsize;
}
/**
@ -229,8 +229,8 @@ public final class CachedRecords {
if (this.cachecount == 0) return;
// copy records from file to cache
raf.seek(this.recordsize * index);
raf.readFully(this.cache, 0, this.recordsize * this.cachecount);
this.raf.seek(this.recordsize * index);
this.raf.readFully(this.cache, 0, this.recordsize * this.cachecount);
}
/**
@ -238,8 +238,8 @@ public final class CachedRecords {
*/
public final void flushBuffer() {
try {
raf.seek(raf.length());
raf.write(this.buffer, 0, this.recordsize * this.buffercount);
this.raf.seek(this.raf.length());
this.raf.write(this.buffer, 0, this.recordsize * this.buffercount);
} catch (final IOException e) {
Log.logException(e);
}
@ -250,8 +250,8 @@ public final class CachedRecords {
flushBuffer();
// then close the file
if (raf != null) try {
raf.close();
if (this.raf != null) try {
this.raf.close();
} catch (final IOException e) {
Log.logException(e);
}
@ -308,8 +308,8 @@ public final class CachedRecords {
if (p >= 0) {
// write entry to the cache and to the file
System.arraycopy(b, start, this.cache, p * this.recordsize, this.recordsize);
raf.seek(index * this.recordsize);
raf.write(b, start, this.recordsize);
this.raf.seek(index * this.recordsize);
this.raf.write(b, start, this.recordsize);
return;
}
if (q >= 0) {
@ -337,8 +337,8 @@ public final class CachedRecords {
} else {
// write the record directly to the file,
// do not care about the cache; this case was checked before
raf.seek(index * this.recordsize);
raf.write(b, start, this.recordsize);
this.raf.seek(index * this.recordsize);
this.raf.write(b, start, this.recordsize);
}
}
@ -371,7 +371,7 @@ public final class CachedRecords {
assert this.buffercount <= this.buffer.length / this.recordsize;
}
private final boolean isClean(final byte[] b, final int offset, final int length) {
private final static boolean isClean(final byte[] b, final int offset, final int length) {
for (int i = 0; i < length; i++) {
if (b[i + offset] != 0) return false;
}
@ -419,19 +419,19 @@ public final class CachedRecords {
final int q = (p >= 0) ? -1 : inBuffer(index);
if (p >= 0) {
// write zero bytes to the cache and to the file
System.arraycopy(zero, 0, this.cache, p * this.recordsize, this.recordsize);
raf.seek(index * this.recordsize);
raf.write(zero, 0, this.recordsize);
System.arraycopy(this.zero, 0, this.cache, p * this.recordsize, this.recordsize);
this.raf.seek(index * this.recordsize);
this.raf.write(this.zero, 0, this.recordsize);
return;
}
if (q >= 0) {
// write zero to the buffer
System.arraycopy(zero, 0, this.buffer, q * this.recordsize, this.recordsize);
System.arraycopy(this.zero, 0, this.buffer, q * this.recordsize, this.recordsize);
return;
}
raf.seek(index * this.recordsize);
raf.write(zero, 0, this.recordsize);
this.raf.seek(index * this.recordsize);
this.raf.write(this.zero, 0, this.recordsize);
}
/**

@ -41,7 +41,7 @@ public final class RandomAccessIO {
}
public final synchronized long length() throws IOException {
return ra.length();
return this.ra.length();
}
public final synchronized void readFully(long pos, final byte[] b, int off, int len) throws IOException {
@ -57,7 +57,7 @@ public final class RandomAccessIO {
}
public final String name() {
return name;
return this.name;
}
public final synchronized byte readByte(final long pos) throws IOException {
@ -134,7 +134,7 @@ public final class RandomAccessIO {
}
}
private final byte[] space(int count) {
private final static byte[] space(int count) {
byte[] s = new byte[count];
while (count-- > 0) s[count] = 0;
return s;
@ -144,6 +144,7 @@ public final class RandomAccessIO {
if (this.ra != null) this.ra.close();
}
@Override
protected final void finalize() throws Throwable {
if (this.ra != null) this.close();
super.finalize();

@ -97,7 +97,7 @@ public final class Records {
// open an existing table file
try {
raf = new RandomAccessFile(tablefile,"rw");
this.raf = new RandomAccessFile(tablefile,"rw");
} catch (final FileNotFoundException e) {
// should never happen
Log.logException(e);
@ -160,7 +160,7 @@ public final class Records {
long records = 0;
try {
records = raf.length() / recordsize;
records = this.raf.length() / this.recordsize;
} catch (NullPointerException e) {
// This may happen on shutdown while still something is moving on
Log.logException(e);
@ -188,10 +188,10 @@ public final class Records {
* write buffer to end of file
*/
protected final synchronized void flushBuffer() {
if (raf == null) return;
if (this.raf == null) return;
try {
raf.seek(raf.length());
raf.write(this.buffer, 0, this.recordsize * this.buffercount);
this.raf.seek(this.raf.length());
this.raf.write(this.buffer, 0, this.recordsize * this.buffercount);
} catch (final IOException e) {
Log.logException(e);
}
@ -200,9 +200,9 @@ public final class Records {
public final synchronized void close() {
// close the file
if (raf != null) try {
if (this.raf != null) try {
flushBuffer();
raf.close();
this.raf.close();
} catch (final IOException e) {
Log.logException(e);
}
@ -223,8 +223,8 @@ public final class Records {
final int q = inBuffer(index);
if (q < 0) {
// copy records from file to given buffer
raf.seek(this.recordsize * index);
raf.readFully(b, start, this.recordsize);
this.raf.seek(this.recordsize * index);
this.raf.readFully(b, start, this.recordsize);
return;
}
// read entry from the buffer
@ -269,8 +269,8 @@ public final class Records {
} else {
// write the record directly to the file,
// do not care about the cache; this case was checked before
raf.seek(index * this.recordsize);
raf.write(b, start, this.recordsize);
this.raf.seek(index * this.recordsize);
this.raf.write(b, start, this.recordsize);
}
}
@ -303,7 +303,7 @@ public final class Records {
assert this.buffercount <= this.buffer.length / this.recordsize;
}
private final boolean isClean(final byte[] b, final int offset, final int length) {
private final static boolean isClean(final byte[] b, final int offset, final int length) {
for (int i = 0; i < length; i++) {
if (b[i + offset] != 0) return false;
}
@ -319,8 +319,8 @@ public final class Records {
return isClean(this.buffer, q * this.recordsize, this.recordsize);
}
byte[] b = new byte[this.recordsize];
raf.seek(index * this.recordsize);
raf.readFully(b, 0, this.recordsize);
this.raf.seek(index * this.recordsize);
this.raf.readFully(b, 0, this.recordsize);
return isClean(b, 0, this.recordsize);
}
@ -341,12 +341,12 @@ public final class Records {
final int q = inBuffer(index);
if (q >= 0) {
// write zero to the buffer
System.arraycopy(zero, 0, this.buffer, q * this.recordsize, this.recordsize);
System.arraycopy(this.zero, 0, this.buffer, q * this.recordsize, this.recordsize);
return;
}
raf.seek(index * this.recordsize);
raf.write(zero, 0, this.recordsize);
this.raf.seek(index * this.recordsize);
this.raf.write(this.zero, 0, this.recordsize);
}
/**
@ -386,12 +386,12 @@ public final class Records {
}
// read entry from the file
final long endpos = this.raf.length() - this.recordsize;
raf.seek(endpos);
raf.readFully(b, start, this.recordsize);
this.raf.seek(endpos);
this.raf.readFully(b, start, this.recordsize);
// write zero bytes to the cache and to the file
this.raf.seek(endpos);
this.raf.write(zero, 0, this.recordsize);
this.raf.write(this.zero, 0, this.recordsize);
// shrink file
this.raf.setLength(endpos);
@ -420,7 +420,7 @@ public final class Records {
return;
}
// shrink file
this.raf.setLength(raf.length() - this.recordsize);
this.raf.setLength(this.raf.length() - this.recordsize);
}
public final void deleteOnExit() {

@ -72,7 +72,7 @@ public class GuiHandler extends Handler {
this.size = parseSize(sizeString);
}
private int parseSize(final String sizeString) {
private static int parseSize(final String sizeString) {
int newSize = DEFAULT_SIZE;
try {
newSize = Integer.parseInt(sizeString);
@ -82,7 +82,7 @@ public class GuiHandler extends Handler {
return newSize;
}
private Filter makeFilter(final String name) {
private static Filter makeFilter(final String name) {
if (name == null) return null;
Filter f = null;
@ -95,7 +95,7 @@ public class GuiHandler extends Handler {
return f;
}
private Formatter makeFormatter(final String name) {
private static Formatter makeFormatter(final String name) {
if (name == null) return null;
Formatter f = null;
@ -119,6 +119,7 @@ public class GuiHandler extends Handler {
return this.size;
}
@Override
public final void publish(final LogRecord record) {
if (!isLoggable(record)) return;
@ -204,10 +205,12 @@ public class GuiHandler extends Handler {
}
}
@Override
public void flush() {
}
@Override
public synchronized void close() throws SecurityException {
// Nothing implement here
}

@ -248,121 +248,121 @@ public final class LogParser {
public final int parse(final String logLevel, final String logLine) {
final long start = System.currentTimeMillis();
if ("INFO".equals(logLevel)){
m = i1.matcher (logLine);
if (m.find () && m.groupCount() >= 3) {
urlSum += Integer.parseInt(m.group(1));
urlTimeSum += Integer.parseInt(m.group(2));
blockedURLSum += Integer.parseInt(m.group(3));
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
this.m = i1.matcher (logLine);
if (this.m.find () && this.m.groupCount() >= 3) {
this.urlSum += Integer.parseInt(this.m.group(1));
this.urlTimeSum += Integer.parseInt(this.m.group(2));
this.blockedURLSum += Integer.parseInt(this.m.group(3));
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i2.matcher (logLine);
if (m.find () && m.groupCount() >= 6) {
rwiSum += Integer.parseInt(m.group(1));
wordsSum += Integer.parseInt(m.group(2));
rwiTimeSum += Integer.parseInt(m.group(3));
urlReqSum += Integer.parseInt(m.group(4));
blockedRWISum += Integer.parseInt(m.group(6));
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
this.m = i2.matcher (logLine);
if (this.m.find () && this.m.groupCount() >= 6) {
this.rwiSum += Integer.parseInt(this.m.group(1));
this.wordsSum += Integer.parseInt(this.m.group(2));
this.rwiTimeSum += Integer.parseInt(this.m.group(3));
this.urlReqSum += Integer.parseInt(this.m.group(4));
this.blockedRWISum += Integer.parseInt(this.m.group(6));
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i2_2.matcher (logLine);
if (m.find () && m.groupCount() >= 6) {
rwiSum += Integer.parseInt(m.group(1));
wordsSum += Integer.parseInt(m.group(2));
rwiTimeSum += Integer.parseInt(m.group(3));
urlReqSum += Integer.parseInt(m.group(4));
blockedRWISum += Integer.parseInt(m.group(6));
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
this.m = i2_2.matcher (logLine);
if (this.m.find () && this.m.groupCount() >= 6) {
this.rwiSum += Integer.parseInt(this.m.group(1));
this.wordsSum += Integer.parseInt(this.m.group(2));
this.rwiTimeSum += Integer.parseInt(this.m.group(3));
this.urlReqSum += Integer.parseInt(this.m.group(4));
this.blockedRWISum += Integer.parseInt(this.m.group(6));
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i3.matcher (logLine);
if (m.find () && m.groupCount() >= 6) {
DHTSendTraffic += Integer.parseInt(m.group(6));
DHTPeerNames.add(m.group(2));
DHTPeerHashs.add(m.group(3));
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
this.m = i3.matcher (logLine);
if (this.m.find () && this.m.groupCount() >= 6) {
this.DHTSendTraffic += Integer.parseInt(this.m.group(6));
this.DHTPeerNames.add(this.m.group(2));
this.DHTPeerHashs.add(this.m.group(3));
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i4.matcher (logLine);
if (m.find () && m.groupCount() >= 8) {
DHTSendTraffic += Integer.parseInt(m.group(8));
DHTSendURLs += Integer.parseInt(m.group(3));
DHTPeerNames.add(m.group(4));
DHTPeerHashs.add(m.group(5));
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
this.m = i4.matcher (logLine);
if (this.m.find () && this.m.groupCount() >= 8) {
this.DHTSendTraffic += Integer.parseInt(this.m.group(8));
this.DHTSendURLs += Integer.parseInt(this.m.group(3));
this.DHTPeerNames.add(this.m.group(4));
this.DHTPeerHashs.add(this.m.group(5));
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i5.matcher (logLine);
if (m.find () && m.groupCount() >= 4) {
minDHTDist = Math.min(minDHTDist, Math.min(Long.parseLong(m.group(3)), Long.parseLong(m.group(4))));
maxDHTDist = Math.max(maxDHTDist, Math.max(Long.parseLong(m.group(3)), Long.parseLong(m.group(4))));
avgDHTDist += Long.parseLong(m.group(3));
DHTSelectionTargetCount++;
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
this.m = i5.matcher (logLine);
if (this.m.find () && this.m.groupCount() >= 4) {
this.minDHTDist = Math.min(this.minDHTDist, Math.min(Long.parseLong(this.m.group(3)), Long.parseLong(this.m.group(4))));
this.maxDHTDist = Math.max(this.maxDHTDist, Math.max(Long.parseLong(this.m.group(3)), Long.parseLong(this.m.group(4))));
this.avgDHTDist += Long.parseLong(this.m.group(3));
this.DHTSelectionTargetCount++;
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i6.matcher (logLine);
if (m.find () && m.groupCount() >= 2) {
RWIRejectPeerNames.add(m.group(2));
RWIRejectPeerHashs.add(m.group(1));
RWIRejectCount++;
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
this.m = i6.matcher (logLine);
if (this.m.find () && this.m.groupCount() >= 2) {
this.RWIRejectPeerNames.add(this.m.group(2));
this.RWIRejectPeerHashs.add(this.m.group(1));
this.RWIRejectCount++;
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i7.matcher (logLine);
this.m = i7.matcher (logLine);
if (m.find ()) {
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
if (this.m.find ()) {
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i8.matcher (logLine);
this.m = i8.matcher (logLine);
if (m.find () && m.groupCount() >= 2) {
DHTSelectionWordsCount += Float.parseFloat(m.group(1));
DHTSelectionWordsTimeCount += Float.parseFloat(m.group(2));
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
if (this.m.find () && this.m.groupCount() >= 2) {
this.DHTSelectionWordsCount += Float.parseFloat(this.m.group(1));
this.DHTSelectionWordsTimeCount += Float.parseFloat(this.m.group(2));
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i9.matcher (logLine);
this.m = i9.matcher (logLine);
if (m.find () && m.groupCount() >= 1) {
rankingDistributionCount++;
rankingDistributionTime += Integer.parseInt(m.group(1));
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
if (this.m.find () && this.m.groupCount() >= 1) {
this.rankingDistributionCount++;
this.rankingDistributionTime += Integer.parseInt(this.m.group(1));
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i10.matcher (logLine);
this.m = i10.matcher (logLine);
if (m.find ()) {
rankingDistributionFailCount++;
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
if (this.m.find ()) {
this.rankingDistributionFailCount++;
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = i11.matcher (logLine);
this.m = i11.matcher (logLine);
if (m.find ()) {
busyPeerCount++;
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
if (this.m.find ()) {
this.busyPeerCount++;
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
// m = i12.matcher (logLine);
@ -370,166 +370,166 @@ public final class LogParser {
// if (m.find ()) {
// return 3;
// }
m = i13.matcher (logLine);
this.m = i13.matcher (logLine);
if (m.find ()) {
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
if (this.m.find ()) {
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = adv1.matcher (logLine);
if (m.find() && m.groupCount() >= 8) {
indexedSites++;
indexedWordSum += Integer.parseInt(m.group(1));
indexedSiteSizeSum += Integer.parseInt(m.group(5));
indexedAnchorsCount += Integer.parseInt(m.group(6));
indexedLinkStorageTime += Integer.parseInt(m.group(7));
indexedIndexStorageTime += Integer.parseInt(m.group(8));
this.m = adv1.matcher (logLine);
if (this.m.find() && this.m.groupCount() >= 8) {
this.indexedSites++;
this.indexedWordSum += Integer.parseInt(this.m.group(1));
this.indexedSiteSizeSum += Integer.parseInt(this.m.group(5));
this.indexedAnchorsCount += Integer.parseInt(this.m.group(6));
this.indexedLinkStorageTime += Integer.parseInt(this.m.group(7));
this.indexedIndexStorageTime += Integer.parseInt(this.m.group(8));
// indexedStackingTime += Integer.parseInt(m.group(7));
// indexedParsingTime += Integer.parseInt(m.group(8));
// indexedIndexingTime += Integer.parseInt(m.group(9));
// indexedStorageTime += Integer.parseInt(m.group(10));
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
} else if ("WARNING".equals(logLevel)){
m = w1.matcher (logLine);
this.m = w1.matcher (logLine);
if (m.find ()) {
notEnoughDHTPeers++;
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
if (this.m.find ()) {
this.notEnoughDHTPeers++;
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = w2.matcher (logLine);
this.m = w2.matcher (logLine);
if (m.find ()) {
failedIndexDistributionCount++;
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
if (this.m.find ()) {
this.failedIndexDistributionCount++;
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
} else if ("SEVERE".equals(logLevel)){
m = e1.matcher (logLine);
this.m = e1.matcher (logLine);
if (m.find () && m.groupCount() >= 1) {
if ("leftchild".equals(m.group(1))) leftChildTwiceCount++;
else if ("rightchild".equals(m.group(1))) rightChildTwiceCount++;
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
if (this.m.find () && this.m.groupCount() >= 1) {
if ("leftchild".equals(this.m.group(1))) this.leftChildTwiceCount++;
else if ("rightchild".equals(this.m.group(1))) this.rightChildTwiceCount++;
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
m = e2.matcher (logLine);
this.m = e2.matcher (logLine);
if (m.find ()) {
malformedURLCount++;
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
if (this.m.find ()) {
this.malformedURLCount++;
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return 0;
}
}
totalParserTime += (System.currentTimeMillis() - start);
totalParserRuns++;
this.totalParserTime += (System.currentTimeMillis() - start);
this.totalParserRuns++;
return -1;
}
public final Map<String, Object> getResults() {
final Map<String, Object> results = new HashMap<String, Object>();
results.put(PARSER_VERSION , Float.valueOf(parserVersion));
results.put(URLS_RECEIVED , Integer.valueOf(urlSum));
results.put(URLS_REQUESTED , Integer.valueOf(urlReqSum));
results.put(URLS_BLOCKED , Integer.valueOf(blockedURLSum));
results.put(WORDS_RECEIVED , Integer.valueOf(wordsSum));
results.put(RWIS_RECEIVED , Integer.valueOf(rwiSum));
results.put(RWIS_BLOCKED , Integer.valueOf(blockedRWISum));
results.put(URLS_RECEIVED_TIME , Long.valueOf(urlTimeSum));
results.put(RWIS_RECEIVED_TIME , Long.valueOf(rwiTimeSum));
results.put(DHT_TRAFFIC_SENT , Long.valueOf(DHTSendTraffic));
results.put(DHT_URLS_SENT , Integer.valueOf(DHTSendURLs));
results.put(DHT_REJECTED , Integer.valueOf(RWIRejectCount));
results.put(DHT_REJECTED_PEERS_NAME , RWIRejectPeerNames);
results.put(DHT_REJECTED_PEERS_HASH , RWIRejectPeerHashs);
results.put(DHT_SENT_PEERS_NAME , DHTPeerNames);
results.put(DHT_SENT_PEERS_HASH , DHTPeerHashs);
results.put(DHT_SELECTED , Integer.valueOf(DHTSelectionTargetCount));
results.put(DHT_WORDS_SELECTED , Integer.valueOf(DHTSelectionWordsCount));
results.put(DHT_WORDS_SELECTED_TIME , Integer.valueOf(DHTSelectionWordsTimeCount));
results.put(DHT_DISTANCE_MIN , Long.valueOf(minDHTDist));
results.put(DHT_DISTANCE_MAX , Long.valueOf(maxDHTDist));
results.put(DHT_DISTANCE_AVERAGE , Long.valueOf(avgDHTDist / DHTSelectionTargetCount / Long.MAX_VALUE)); //FIXME: broken avg
results.put(PEERS_BUSY , Integer.valueOf(busyPeerCount));
results.put(PEERS_TOO_LESS , Integer.valueOf(notEnoughDHTPeers));
results.put(DHT_SENT_FAILED , Integer.valueOf(failedIndexDistributionCount));
results.put(ERROR_CHILD_TWICE_LEFT , Integer.valueOf(leftChildTwiceCount));
results.put(ERROR_CHILD_TWICE_RIGHT , Integer.valueOf(rightChildTwiceCount));
results.put(RANKING_DIST , Integer.valueOf(rankingDistributionCount));
results.put(RANKING_DIST_TIME , Integer.valueOf(rankingDistributionTime));
results.put(RANKING_DIST_FAILED , Integer.valueOf(rankingDistributionFailCount));
results.put(ERROR_MALFORMED_URL , Integer.valueOf(malformedURLCount));
results.put(INDEXED_SITES , Integer.valueOf(indexedSites));
results.put(INDEXED_WORDS , Integer.valueOf(indexedWordSum));
results.put(INDEXED_SITES_SIZE , Integer.valueOf(indexedSiteSizeSum));
results.put(INDEXED_ANCHORS , Integer.valueOf(indexedAnchorsCount));
results.put(URLS_RECEIVED , Integer.valueOf(this.urlSum));
results.put(URLS_REQUESTED , Integer.valueOf(this.urlReqSum));
results.put(URLS_BLOCKED , Integer.valueOf(this.blockedURLSum));
results.put(WORDS_RECEIVED , Integer.valueOf(this.wordsSum));
results.put(RWIS_RECEIVED , Integer.valueOf(this.rwiSum));
results.put(RWIS_BLOCKED , Integer.valueOf(this.blockedRWISum));
results.put(URLS_RECEIVED_TIME , Long.valueOf(this.urlTimeSum));
results.put(RWIS_RECEIVED_TIME , Long.valueOf(this.rwiTimeSum));
results.put(DHT_TRAFFIC_SENT , Long.valueOf(this.DHTSendTraffic));
results.put(DHT_URLS_SENT , Integer.valueOf(this.DHTSendURLs));
results.put(DHT_REJECTED , Integer.valueOf(this.RWIRejectCount));
results.put(DHT_REJECTED_PEERS_NAME , this.RWIRejectPeerNames);
results.put(DHT_REJECTED_PEERS_HASH , this.RWIRejectPeerHashs);
results.put(DHT_SENT_PEERS_NAME , this.DHTPeerNames);
results.put(DHT_SENT_PEERS_HASH , this.DHTPeerHashs);
results.put(DHT_SELECTED , Integer.valueOf(this.DHTSelectionTargetCount));
results.put(DHT_WORDS_SELECTED , Integer.valueOf(this.DHTSelectionWordsCount));
results.put(DHT_WORDS_SELECTED_TIME , Integer.valueOf(this.DHTSelectionWordsTimeCount));
results.put(DHT_DISTANCE_MIN , Long.valueOf(this.minDHTDist));
results.put(DHT_DISTANCE_MAX , Long.valueOf(this.maxDHTDist));
results.put(DHT_DISTANCE_AVERAGE , Long.valueOf(this.avgDHTDist / this.DHTSelectionTargetCount / Long.MAX_VALUE)); //FIXME: broken avg
results.put(PEERS_BUSY , Integer.valueOf(this.busyPeerCount));
results.put(PEERS_TOO_LESS , Integer.valueOf(this.notEnoughDHTPeers));
results.put(DHT_SENT_FAILED , Integer.valueOf(this.failedIndexDistributionCount));
results.put(ERROR_CHILD_TWICE_LEFT , Integer.valueOf(this.leftChildTwiceCount));
results.put(ERROR_CHILD_TWICE_RIGHT , Integer.valueOf(this.rightChildTwiceCount));
results.put(RANKING_DIST , Integer.valueOf(this.rankingDistributionCount));
results.put(RANKING_DIST_TIME , Integer.valueOf(this.rankingDistributionTime));
results.put(RANKING_DIST_FAILED , Integer.valueOf(this.rankingDistributionFailCount));
results.put(ERROR_MALFORMED_URL , Integer.valueOf(this.malformedURLCount));
results.put(INDEXED_SITES , Integer.valueOf(this.indexedSites));
results.put(INDEXED_WORDS , Integer.valueOf(this.indexedWordSum));
results.put(INDEXED_SITES_SIZE , Integer.valueOf(this.indexedSiteSizeSum));
results.put(INDEXED_ANCHORS , Integer.valueOf(this.indexedAnchorsCount));
// results.put(INDEXED_STACK_TIME , new Integer(indexedStackingTime));
// results.put(INDEXED_PARSE_TIME , new Integer(indexedParsingTime));
// results.put(INDEXED_INDEX_TIME , new Integer(indexedIndexingTime));
// results.put(INDEXED_STORE_TIME , new Integer(indexedStorageTime));
results.put(INDEXED_LINKSTORE_TIME , Integer.valueOf(indexedLinkStorageTime));
results.put(INDEXED_INDEXSTORE_TIME, Integer.valueOf(indexedIndexStorageTime));
results.put(TOTAL_PARSER_TIME , Long.valueOf(totalParserTime));
results.put(TOTAL_PARSER_RUNS , Integer.valueOf(totalParserRuns));
results.put(INDEXED_LINKSTORE_TIME , Integer.valueOf(this.indexedLinkStorageTime));
results.put(INDEXED_INDEXSTORE_TIME, Integer.valueOf(this.indexedIndexStorageTime));
results.put(TOTAL_PARSER_TIME , Long.valueOf(this.totalParserTime));
results.put(TOTAL_PARSER_RUNS , Integer.valueOf(this.totalParserRuns));
return results;
}
public final String getParserType() {
public final static String getParserType() {
return parserType;
}
public final double getParserVersion() {
public final static double getParserVersion() {
return parserVersion;
}
public final void printResults() {
if(rankingDistributionCount == 0) rankingDistributionCount = 1;
if(DHTSelectionWordsTimeCount == 0) DHTSelectionWordsTimeCount = 1;
if(indexedSites != 0) indexedSites++;
System.out.println("INDEXER: Indexed " + indexedSites + " sites in " + (indexedLinkStorageTime + indexedIndexStorageTime) + " milliseconds.");
System.out.println("INDEXER: Indexed " + indexedWordSum + " words on " + indexedSites + " sites. (avg. words per site: " + (indexedWordSum / indexedSites) + ").");
System.out.println("INDEXER: Total Size of indexed sites: " + indexedSiteSizeSum + " bytes (avg. size per site: " + (indexedSiteSizeSum / indexedSites) + " bytes).");
System.out.println("INDEXER: Total Number of Anchors found: " + indexedAnchorsCount + "(avg. Anchors per site: " + (indexedAnchorsCount / indexedSites) + ").");
System.out.println("INDEXER: Total LinkStorageTime: " + indexedLinkStorageTime + " milliseconds (avg. StorageTime: " + (indexedLinkStorageTime / indexedSites) + " milliseconds).");
System.out.println("INDEXER: Total indexStorageTime: " + indexedIndexStorageTime + " milliseconds (avg. StorageTime: " + (indexedIndexStorageTime / indexedSites) + " milliseconds).");
if(this.rankingDistributionCount == 0) this.rankingDistributionCount = 1;
if(this.DHTSelectionWordsTimeCount == 0) this.DHTSelectionWordsTimeCount = 1;
if(this.indexedSites != 0) this.indexedSites++;
System.out.println("INDEXER: Indexed " + this.indexedSites + " sites in " + (this.indexedLinkStorageTime + this.indexedIndexStorageTime) + " milliseconds.");
System.out.println("INDEXER: Indexed " + this.indexedWordSum + " words on " + this.indexedSites + " sites. (avg. words per site: " + (this.indexedWordSum / this.indexedSites) + ").");
System.out.println("INDEXER: Total Size of indexed sites: " + this.indexedSiteSizeSum + " bytes (avg. size per site: " + (this.indexedSiteSizeSum / this.indexedSites) + " bytes).");
System.out.println("INDEXER: Total Number of Anchors found: " + this.indexedAnchorsCount + "(avg. Anchors per site: " + (this.indexedAnchorsCount / this.indexedSites) + ").");
System.out.println("INDEXER: Total LinkStorageTime: " + this.indexedLinkStorageTime + " milliseconds (avg. StorageTime: " + (this.indexedLinkStorageTime / this.indexedSites) + " milliseconds).");
System.out.println("INDEXER: Total indexStorageTime: " + this.indexedIndexStorageTime + " milliseconds (avg. StorageTime: " + (this.indexedIndexStorageTime / this.indexedSites) + " milliseconds).");
// System.out.println("INDEXER: Total StackingTime: " + indexedStackingTime + " milliseconds (avg. StackingTime: " + (indexedStackingTime / indexedSites) + " milliseconds).");
// System.out.println("INDEXER: Total ParsingTime: " + indexedParsingTime + " milliseconds (avg. ParsingTime: " + (indexedParsingTime / indexedSites) + " milliseconds).");
// System.out.println("INDEXER: Total IndexingTime: " + indexedIndexingTime + " milliseconds (avg. IndexingTime: " + (indexedIndexingTime / indexedSites) + " milliseconds).");
// System.out.println("INDEXER: Total StorageTime: " + indexedStorageTime + " milliseconds (avg. StorageTime: " + (indexedStorageTime / indexedSites) + " milliseconds).");
if(urlSum != 0) urlSum++;
System.out.println("DHT: Recieved " + urlSum + " Urls in " + urlTimeSum + " ms. Blocked " + blockedURLSum + " URLs.");
System.out.println("DHT: " + urlTimeSum / urlSum + " milliseconds per URL.");
if(rwiSum != 0) rwiSum++;
System.out.println("DHT: Recieved " + rwiSum + " RWIs from " + wordsSum + " Words in " + rwiTimeSum + " ms. " + urlReqSum + " requested URLs.");
System.out.println("DHT: Blocked " + blockedRWISum + " RWIs before requesting URLs, because URL-Hash was blacklisted.");
System.out.println("DHT: " + rwiTimeSum / rwiSum + " milliseconds per RWI.");
System.out.println("DHT: Rejected " + RWIRejectCount + " Indextransfers from " + RWIRejectPeerNames.size() + " PeerNames with " + RWIRejectPeerHashs.size() + " PeerHashs.");
System.out.println("DHT: " + DHTSendTraffic/(1024*1024l) + " MegaBytes (" + DHTSendTraffic + " Bytes) of DHT-Transfertraffic.");
System.out.println("DHT: Sended " + DHTSendURLs + " URLs via DHT.");
System.out.println("DHT: DHT Transfers send to " + DHTPeerNames.size() + " Peernames with " + DHTPeerHashs.size() + " Peerhashs.");
System.out.println("DHT: Totally selected " + DHTSelectionWordsCount + " words in " + DHTSelectionWordsTimeCount + " seconds (" + (float)DHTSelectionWordsCount/DHTSelectionWordsTimeCount + " words/s)");
System.out.println("DHT: Selected " + DHTSelectionTargetCount + " possible DHT Targets (min. Distance: " + minDHTDist + " max. Distance: " + maxDHTDist + " avg. Distance: " + (avgDHTDist/DHTSelectionTargetCount));
System.out.println("DHT: " + busyPeerCount + " times a targetpeer was too busy to accept a transfer.");
System.out.println("DHT: " + notEnoughDHTPeers + " times there were not enought targetpeers for the selected DHTChunk");
System.out.println("DHT: IndexDistribution failed " + failedIndexDistributionCount + " times.");
System.out.println("RANKING: Transmitted " + rankingDistributionCount + " Rankingfiles in " + rankingDistributionTime + " seconds (" + rankingDistributionTime/rankingDistributionCount + " seconds/file)");
System.out.println("RANKING: RankingDistribution failed " + rankingDistributionFailCount + " times.");
if (leftChildTwiceCount != 0)
System.out.println("ERRORS: tried " + leftChildTwiceCount + " times to create leftchild node twice in db");
if (rightChildTwiceCount != 0)
System.out.println("ERRORS: tried " + rightChildTwiceCount + " times to create rightchild node twice in db");
if (malformedURLCount != 0)
System.out.println("ERRORS: " + malformedURLCount + " MalformedURLExceptions accord.");
if(this.urlSum != 0) this.urlSum++;
System.out.println("DHT: Recieved " + this.urlSum + " Urls in " + this.urlTimeSum + " ms. Blocked " + this.blockedURLSum + " URLs.");
System.out.println("DHT: " + this.urlTimeSum / this.urlSum + " milliseconds per URL.");
if(this.rwiSum != 0) this.rwiSum++;
System.out.println("DHT: Recieved " + this.rwiSum + " RWIs from " + this.wordsSum + " Words in " + this.rwiTimeSum + " ms. " + this.urlReqSum + " requested URLs.");
System.out.println("DHT: Blocked " + this.blockedRWISum + " RWIs before requesting URLs, because URL-Hash was blacklisted.");
System.out.println("DHT: " + this.rwiTimeSum / this.rwiSum + " milliseconds per RWI.");
System.out.println("DHT: Rejected " + this.RWIRejectCount + " Indextransfers from " + this.RWIRejectPeerNames.size() + " PeerNames with " + this.RWIRejectPeerHashs.size() + " PeerHashs.");
System.out.println("DHT: " + this.DHTSendTraffic/(1024*1024l) + " MegaBytes (" + this.DHTSendTraffic + " Bytes) of DHT-Transfertraffic.");
System.out.println("DHT: Sended " + this.DHTSendURLs + " URLs via DHT.");
System.out.println("DHT: DHT Transfers send to " + this.DHTPeerNames.size() + " Peernames with " + this.DHTPeerHashs.size() + " Peerhashs.");
System.out.println("DHT: Totally selected " + this.DHTSelectionWordsCount + " words in " + this.DHTSelectionWordsTimeCount + " seconds (" + (float)this.DHTSelectionWordsCount/this.DHTSelectionWordsTimeCount + " words/s)");
System.out.println("DHT: Selected " + this.DHTSelectionTargetCount + " possible DHT Targets (min. Distance: " + this.minDHTDist + " max. Distance: " + this.maxDHTDist + " avg. Distance: " + (this.avgDHTDist/this.DHTSelectionTargetCount));
System.out.println("DHT: " + this.busyPeerCount + " times a targetpeer was too busy to accept a transfer.");
System.out.println("DHT: " + this.notEnoughDHTPeers + " times there were not enought targetpeers for the selected DHTChunk");
System.out.println("DHT: IndexDistribution failed " + this.failedIndexDistributionCount + " times.");
System.out.println("RANKING: Transmitted " + this.rankingDistributionCount + " Rankingfiles in " + this.rankingDistributionTime + " seconds (" + this.rankingDistributionTime/this.rankingDistributionCount + " seconds/file)");
System.out.println("RANKING: RankingDistribution failed " + this.rankingDistributionFailCount + " times.");
if (this.leftChildTwiceCount != 0)
System.out.println("ERRORS: tried " + this.leftChildTwiceCount + " times to create leftchild node twice in db");
if (this.rightChildTwiceCount != 0)
System.out.println("ERRORS: tried " + this.rightChildTwiceCount + " times to create rightchild node twice in db");
if (this.malformedURLCount != 0)
System.out.println("ERRORS: " + this.malformedURLCount + " MalformedURLExceptions accord.");
}
}

@ -48,6 +48,7 @@ public final class LogalizerHandler extends Handler {
debug = "true".equalsIgnoreCase(manager.getProperty(className + ".debug"));
}
@Override
public final void publish(final LogRecord record) {
if (enabled) {
final LogParser temp = new LogParser();
@ -59,13 +60,15 @@ public final class LogalizerHandler extends Handler {
flush();
}
public final Map<String, Object> getParserResults(final LogParser parsername) {
public final static Map<String, Object> getParserResults(final LogParser parsername) {
return (parsername == null) ? null : parsername.getResults();
}
@Override
public final void close() throws SecurityException {
}
@Override
public final void flush() {
}
}

@ -34,14 +34,14 @@ public class MemoryControl {
private static MemoryStrategy strategy;
private static MemoryStrategy getStrategy() {
if (strategy == null || strategy.hasError()) {
if (strategy == null || MemoryStrategy.hasError()) {
if (!usingStandardStrategy) {
strategy = new GenerationMemoryStrategy();
// if (strategy.hasError()) { // perhaps we do have a G1
// strategy = new G1MemoryStrategy();
// }
// fall back if error detected
if (strategy.hasError()) {
if (MemoryStrategy.hasError()) {
usingStandardStrategy = true;
strategy = new StandardMemoryStrategy();
}
@ -63,7 +63,8 @@ public class MemoryControl {
* @return the name of the used strategy
*/
public final static String getStrategyName() {
return getStrategy().getName();
getStrategy();
return MemoryStrategy.getName();
}
/**

@ -31,20 +31,20 @@ public abstract class MemoryStrategy {
protected final static Log log = new Log("MEMORY");
protected static long lastGC = 0l;
protected static boolean error = true;
protected static boolean error = true;
protected static String name;
/**
* @return if an error has been detected
*/
protected final boolean hasError() {
protected final static boolean hasError() {
return error;
}
/**
* @return an identifying name
*/
protected final String getName() {
protected final static String getName() {
return name;
}

@ -49,7 +49,6 @@ public class StandardMemoryStrategy extends MemoryStrategy {
* @param last time which must be passed since lased gc
* @param info additional info for log
*/
@Override
protected final synchronized boolean gc(final int last, final String info) { // thq
assert last >= 10000; // too many forced GCs will cause bad execution performance
final long elapsed = System.currentTimeMillis() - lastGC;

@ -398,7 +398,7 @@ public class NewsPool {
return pc;
}
private boolean automaticProcessP(final SeedDB seedDB, final NewsDB.Record record) {
private static boolean automaticProcessP(final SeedDB seedDB, final NewsDB.Record record) {
if (record == null) return false;
if (record.category() == null) return true;
final long created = record.created().getTime();
@ -467,8 +467,9 @@ public class NewsPool {
case PROCESSED_DB: return this.processedNews.get(id);
case OUTGOING_DB: return this.outgoingNews.get(id);
case PUBLISHED_DB: return this.publishedNews.get(id);
default:
return null;
}
return null;
}
private NewsQueue switchQueue(final int dbKey) {
@ -477,8 +478,8 @@ public class NewsPool {
case PROCESSED_DB: return this.processedNews;
case OUTGOING_DB: return this.outgoingNews;
case PUBLISHED_DB: return this.publishedNews;
}
return null;
default: return null;
}
}
public void clear(final int dbKey) {
@ -488,7 +489,8 @@ public class NewsPool {
case PROCESSED_DB: this.processedNews.clear(); break;
case OUTGOING_DB: this.outgoingNews.clear(); break;
case PUBLISHED_DB: this.publishedNews.clear(); break;
}
default: return;
}
}
public void moveOff(final int dbKey, final String id) throws IOException, RowSpaceExceededException {
@ -499,7 +501,8 @@ public class NewsPool {
case PROCESSED_DB: moveOff(this.processedNews, null,id); break;
case OUTGOING_DB: moveOff(this.outgoingNews, this.publishedNews, id); break;
case PUBLISHED_DB: moveOff(this.publishedNews, null, id); break;
}
default: return;
}
}
private boolean moveOff(final NewsQueue fromqueue, final NewsQueue toqueue, final String id) throws IOException, RowSpaceExceededException {
@ -527,7 +530,7 @@ public class NewsPool {
}
}
private int moveOffAll(final NewsQueue fromqueue, final NewsQueue toqueue) throws IOException, RowSpaceExceededException {
private static int moveOffAll(final NewsQueue fromqueue, final NewsQueue toqueue) throws IOException, RowSpaceExceededException {
// move off all news from a specific queue to another queue
final Iterator<NewsDB.Record> i = fromqueue.iterator();
NewsDB.Record record;

@ -306,7 +306,7 @@ public final class SeedDB implements AlternativeDomainNames {
return sizeConnected() <= dhtActivityMagic;
}
private synchronized MapDataMining openSeedTable(final File seedDBFile) {
private synchronized static MapDataMining openSeedTable(final File seedDBFile) {
final File parentDir = new File(seedDBFile.getParent());
if (!parentDir.exists()) {
if(!parentDir.mkdirs())
@ -817,7 +817,7 @@ public final class SeedDB implements AlternativeDomainNames {
return log;
}
private Iterator<String> downloadSeedFile(final DigestURI seedURL) throws IOException {
private static Iterator<String> downloadSeedFile(final DigestURI seedURL) throws IOException {
// Configure http headers
final RequestHeader reqHeader = new RequestHeader();
reqHeader.put(HeaderFramework.PRAGMA, "no-cache");
@ -850,7 +850,7 @@ public final class SeedDB implements AlternativeDomainNames {
}
}
private String checkCache(final ArrayList<String> uv, final Iterator<String> check) {
private static String checkCache(final ArrayList<String> uv, final Iterator<String> check) {
if ((check == null) || (uv == null)) {
if (Log.isFine("YACY")) Log.logFine("YACY", "SaveSeedList: Local and uploades seed-list are different");
return "Entry count is different: uv.size() = " + ((uv == null) ? "null" : Integer.toString(uv.size()));

@ -51,6 +51,7 @@ public class yacySeedUploadScp implements yacySeedUploader {
public static final String CONFIG_SCP_PASSWORD = "seedScpPassword";
public static final String CONFIG_SCP_PATH = "seedScpPath";
@Override
public String uploadSeedFile(final serverSwitch sb, final File seedFile) throws Exception {
try {
if (sb == null) throw new NullPointerException("Reference to serverSwitch nut not be null.");
@ -85,6 +86,7 @@ public class yacySeedUploadScp implements yacySeedUploader {
}
}
@Override
public String[] getConfigurationOptions() {
return new String[] {CONFIG_SCP_SERVER,CONFIG_SCP_SERVER_PORT,CONFIG_SCP_ACCOUNT,CONFIG_SCP_PASSWORD,CONFIG_SCP_PATH};
}
@ -219,24 +221,29 @@ implements UserInfo, UIKeyboardInteractive {
this.passwd = password;
}
@Override
public String getPassword() {
return this.passwd;
}
@Override
public boolean promptYesNo(final String str){
System.err.println("User was prompted from: " + str);
return true;
}
@Override
public String getPassphrase() {
return null;
}
@Override
public boolean promptPassphrase(final String message) {
System.out.println("promptPassphrase : " + message);
return false;
}
@Override
public boolean promptPassword(final String message) {
System.out.println("promptPassword : " + message);
return true;
@ -245,10 +252,12 @@ implements UserInfo, UIKeyboardInteractive {
/**
* @see com.jcraft.jsch.UserInfo#showMessage(java.lang.String)
*/
@Override
public void showMessage(final String message) {
System.out.println("Sch has tried to show the following message to the user: " + message);
}
@Override
public String[] promptKeyboardInteractive(final String destination,
final String name,
final String instruction,
@ -266,7 +275,7 @@ implements UserInfo, UIKeyboardInteractive {
return new String[]{};
}
String arrayToString2(final String[] a, final String separator) {
static String arrayToString2(final String[] a, final String separator) {
final StringBuilder result = new StringBuilder();// start with first element
if (a.length > 0) {
result.append(a[0]);
@ -278,7 +287,7 @@ implements UserInfo, UIKeyboardInteractive {
return result.toString();
}
String arrayToString2(final boolean[] a, final String separator) {
static String arrayToString2(final boolean[] a, final String separator) {
final StringBuilder result = new StringBuilder();// start with first element
if (a.length > 0) {
result.append(a[0]);

@ -372,7 +372,7 @@ public class Blacklist {
return (m1.matcher(host).matches() || m2.matcher(host).matches() || m3.matcher(host).matches());
}
public String getEngineInfo() {
public static String getEngineInfo() {
return "Default YaCy Blacklist Engine";
}
@ -457,7 +457,7 @@ public class Blacklist {
return matched;
}
public BlacklistError checkError(final String element, final Map<String, String> properties) {
public static BlacklistError checkError(final String element, final Map<String, String> properties) {
final boolean allowRegex = (properties != null) && properties.get("allowRegex").equalsIgnoreCase("true");
int slashPos;

@ -394,7 +394,7 @@ public final class LoaderDispatcher {
return Document.getHyperlinks(documents);
}
public synchronized void cleanupAccessTimeTable(final long timeout) {
public synchronized static void cleanupAccessTimeTable(final long timeout) {
final Iterator<Map.Entry<String, Long>> i = accessTime.entrySet().iterator();
Map.Entry<String, Long> e;
while (i.hasNext()) {

@ -2868,7 +2868,7 @@ public final class Switchboard extends serverSwitch
}
}
public boolean accessFromLocalhost(final RequestHeader requestHeader) {
public static boolean accessFromLocalhost(final RequestHeader requestHeader) {
// authorization for localhost, only if flag is set to grant localhost access as admin
final String clientIP = requestHeader.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "");
@ -3299,7 +3299,7 @@ public final class Switchboard extends serverSwitch
}.start();
}
public int currentPPM() {
public static int currentPPM() {
return EventTracker.countEvents(EventTracker.EClass.INDEX, 20000) * 3;
}

@ -52,12 +52,8 @@ import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.yacy.upnp.Discovery;
import net.yacy.upnp.devices.UPNPDevice;
import net.yacy.upnp.devices.UPNPRootDevice;
@ -69,6 +65,9 @@ import net.yacy.upnp.messages.UPNPMessageFactory;
import net.yacy.upnp.messages.UPNPResponseException;
import net.yacy.upnp.services.UPNPService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class can be used to access some funtionalities on the
* InternetGatewayDevice on your network without having to know
@ -81,7 +80,7 @@ public class InternetGatewayDevice {
private final static Log log = LogFactory.getLog( InternetGatewayDevice.class );
private UPNPRootDevice igd;
private final UPNPRootDevice igd;
private UPNPMessageFactory msgFactory;
public InternetGatewayDevice( UPNPRootDevice igd ) throws UnsupportedOperationException {
@ -107,9 +106,9 @@ public class InternetGatewayDevice {
}
if ( wanIPSrv != null && wanPPPSrv == null ) {
msgFactory = UPNPMessageFactory.getNewInstance( wanIPSrv );
this.msgFactory = UPNPMessageFactory.getNewInstance( wanIPSrv );
} else if ( wanPPPSrv != null && wanIPSrv == null ) {
msgFactory = UPNPMessageFactory.getNewInstance( wanPPPSrv );
this.msgFactory = UPNPMessageFactory.getNewInstance( wanPPPSrv );
} else {
// Unable to test the following code since no router implementing both IP and PPP connection on hands..
/*// discover the active WAN interface using the WANCommonInterfaceConfig specs
@ -149,19 +148,19 @@ public class InternetGatewayDevice {
}*/
// Doing a tricky test with external IP address, the unactive interface should return a null value or none
if ( testWANInterface( wanIPSrv ) ) {
msgFactory = UPNPMessageFactory.getNewInstance( wanIPSrv );
this.msgFactory = UPNPMessageFactory.getNewInstance( wanIPSrv );
} else if( testWANInterface( wanPPPSrv ) ) {
msgFactory = UPNPMessageFactory.getNewInstance( wanPPPSrv );
this.msgFactory = UPNPMessageFactory.getNewInstance( wanPPPSrv );
}
if ( msgFactory == null ) {
if ( this.msgFactory == null ) {
// Nothing found using WANCommonInterfaceConfig! IP by default
log.warn( "Unable to detect active WANIPConnection, dfaulting to urn:schemas-upnp-org:service:WANIPConnection:1" );
msgFactory = UPNPMessageFactory.getNewInstance( wanIPSrv );
this.msgFactory = UPNPMessageFactory.getNewInstance( wanIPSrv );
}
}
}
private boolean testWANInterface( UPNPService srv ) {
private static boolean testWANInterface( UPNPService srv ) {
UPNPMessageFactory tmp = UPNPMessageFactory.getNewInstance( srv );
ActionMessage msg = tmp.getMessage( "GetExternalIPAddress" );
@ -189,7 +188,7 @@ public class InternetGatewayDevice {
* @return the UNPNRootDevie object bound to this object
*/
public UPNPRootDevice getIGDRootDevice() {
return igd;
return this.igd;
}
/**
@ -255,9 +254,9 @@ public class InternetGatewayDevice {
if ( devices != null ) {
Set <InternetGatewayDevice> valid = new HashSet<InternetGatewayDevice>();
for ( int i = 0; i < devices.length; i++ ) {
for (UPNPRootDevice device : devices) {
try {
valid.add( new InternetGatewayDevice( devices[i], WANIPConnection, WANPPPConnection ) );
valid.add( new InternetGatewayDevice( device, WANIPConnection, WANPPPConnection ) );
} catch ( UnsupportedOperationException ex ) {
// the device is either not IP or PPP
if ( log.isDebugEnabled() ) log.debug( "UnsupportedOperationException during discovery " + ex.getMessage() );
@ -268,8 +267,8 @@ public class InternetGatewayDevice {
}
rtrVal = new InternetGatewayDevice[valid.size()];
int i = 0;
for ( Iterator<InternetGatewayDevice> itr = valid.iterator(); itr.hasNext(); ) {
rtrVal[i++] = itr.next();
for (InternetGatewayDevice internetGatewayDevice : valid) {
rtrVal[i++] = internetGatewayDevice;
}
}
@ -283,7 +282,7 @@ public class InternetGatewayDevice {
* @throws IOException if some error occurs during communication with the device
*/
public String getExternalIPAddress() throws UPNPResponseException, IOException {
ActionMessage msg = msgFactory.getMessage( "GetExternalIPAddress" );
ActionMessage msg = this.msgFactory.getMessage( "GetExternalIPAddress" );
return msg.service().getOutActionArgumentValue( "NewExternalIPAddress" );
}
@ -298,7 +297,7 @@ public class InternetGatewayDevice {
*/
public ActionResponse getGenericPortMappingEntry( int newPortMappingIndex ) throws IOException, UPNPResponseException {
ActionMessage msg = msgFactory.getMessage( "GetGenericPortMappingEntry" );
ActionMessage msg = this.msgFactory.getMessage( "GetGenericPortMappingEntry" );
msg.setInputParameter( "NewPortMappingIndex", newPortMappingIndex );
try {
@ -328,7 +327,7 @@ public class InternetGatewayDevice {
checkPortMappingProtocol( protocol );
checkPortRange( externalPort );
ActionMessage msg = msgFactory.getMessage( "GetSpecificPortMappingEntry" );
ActionMessage msg = this.msgFactory.getMessage( "GetSpecificPortMappingEntry" );
msg.setInputParameter( "NewRemoteHost", remoteHost )
.setInputParameter( "NewExternalPort", externalPort )
.setInputParameter( "NewProtocol", protocol );
@ -377,7 +376,7 @@ public class InternetGatewayDevice {
description = description == null ? "" : description;
if ( leaseDuration < 0 ) throw new IllegalArgumentException( "Invalid leaseDuration (" + leaseDuration + ") value" );
ActionMessage msg = msgFactory.getMessage( "AddPortMapping" );
ActionMessage msg = this.msgFactory.getMessage( "AddPortMapping" );
msg.setInputParameter( "NewRemoteHost", remoteHost )
.setInputParameter( "NewExternalPort", externalPort )
.setInputParameter( "NewProtocol", protocol )
@ -411,7 +410,7 @@ public class InternetGatewayDevice {
remoteHost = remoteHost == null ? "" : remoteHost;
checkPortMappingProtocol( protocol );
checkPortRange( externalPort );
ActionMessage msg = msgFactory.getMessage( "DeletePortMapping" );
ActionMessage msg = this.msgFactory.getMessage( "DeletePortMapping" );
msg.setInputParameter( "NewRemoteHost", remoteHost )
.setInputParameter( "NewExternalPort", externalPort )
.setInputParameter( "NewProtocol", protocol );
@ -435,7 +434,7 @@ public class InternetGatewayDevice {
public Integer getNatMappingsCount() throws IOException, UPNPResponseException {
Integer rtrval = null;
StateVariableMessage natTableSize = msgFactory.getStateVariableMessage( "PortMappingNumberOfEntries" );
StateVariableMessage natTableSize = this.msgFactory.getStateVariableMessage( "PortMappingNumberOfEntries" );
try {
StateVariableResponse resp = natTableSize.service();
rtrval = new Integer( resp.getStateVariableValue() );
@ -494,12 +493,12 @@ public class InternetGatewayDevice {
return new Integer( size );
}
private void checkPortMappingProtocol( String prot ) throws IllegalArgumentException {
private static void checkPortMappingProtocol( String prot ) throws IllegalArgumentException {
if ( prot == null || ( !prot.equals( "TCP" ) && !prot.equals( "UDP" ) ) )
throw new IllegalArgumentException( "PortMappingProtocol must be either TCP or UDP" );
}
private void checkPortRange( int port ) throws IllegalArgumentException {
private static void checkPortRange( int port ) throws IllegalArgumentException {
if ( port < 1 || port > 65535 )
throw new IllegalArgumentException( "Port range must be between 1 and 65535" );
}

Loading…
Cancel
Save