refactoring (initialized static fields, removed empty if/else, serialized some fields in serializable classes)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4755 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
danielr 17 years ago
parent 19ca452666
commit d4bce6affd

@ -77,10 +77,10 @@ import de.anomic.yacy.yacyURL;
public class Bookmarks {
private static serverObjects prop;
private static plasmaSwitchboard switchboard;
private static userDB.Entry user;
private static boolean isAdmin;
private static final serverObjects prop = new serverObjects();
private static plasmaSwitchboard switchboard = null;
private static userDB.Entry user = null;
private static boolean isAdmin = false;
final static int SORT_ALPHA = 1;
final static int SORT_SIZE = 2;
@ -95,7 +95,7 @@ public class Bookmarks {
String tagName = "";
String username="";
prop = new serverObjects();
prop.clear();
switchboard = (plasmaSwitchboard) env;
user = switchboard.userDB.getUser(header);
isAdmin=(switchboard.verifyAuthentication(header, true) || user!= null && user.hasRight(userDB.Entry.BOOKMARK_RIGHT));
@ -177,8 +177,8 @@ public class Bookmarks {
}
bookmark.setTags(tags, true);
switchboard.bookmarksDB.saveBookmark(bookmark);
}else{
//ERROR
//}else{
//ERROR
}
}else if(post.containsKey("edit")){
String urlHash=(String) post.get("edit");

@ -220,8 +220,8 @@ public class CacheAdmin_p {
prop.put("info_empty", "0");
final TreeSet<String> dList = new TreeSet<String>();
final TreeSet<String> fList = new TreeSet<String>();
int size = list.length - 1, i = size;
for (; i >= 0 ; i--) { // Rueckwaerts ist schneller
int size = list.length - 1, i;
for (i = size; i >= 0 ; i--) { // Rueckwaerts ist schneller
if (new File(dir, list[i]).isDirectory())
dList.add(list[i]);
else

@ -51,8 +51,8 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class IndexCleaner_p {
private static indexRepositoryReference.BlacklistCleaner urldbCleanerThread;
private static plasmaWordIndex.ReferenceCleaner indexCleanerThread;
private static indexRepositoryReference.BlacklistCleaner urldbCleanerThread = null;
private static plasmaWordIndex.ReferenceCleaner indexCleanerThread = null;
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch<?> env) {
serverObjects prop = new serverObjects();

@ -157,8 +157,8 @@ public class LogStatistics_p {
String[] names = ((HashSet<String>) r.get(LogParserPLASMA.DHT_REJECTED_PEERS_NAME)).toArray(new String[1]);
String[] hashes = ((HashSet<String>) r.get(LogParserPLASMA.DHT_REJECTED_PEERS_HASH)).toArray(new String[1]);
int i = 0;
for (; i<names.length && i<hashes.length; i++) {
int i;
for (i = 0; i<names.length && i<hashes.length; i++) {
prop.put(RESULTS + "useDHTRejectPeers_DHTRejectPeers_" + i + "_name", names[i]);
prop.put(RESULTS + "useDHTRejectPeers_DHTRejectPeers_" + i + "_hash", hashes[i]);
}
@ -168,8 +168,7 @@ public class LogStatistics_p {
names = ((HashSet<String>)r.get(LogParserPLASMA.DHT_SENT_PEERS_NAME)).toArray(new String[1]);
hashes = ((HashSet<String>)r.get(LogParserPLASMA.DHT_SENT_PEERS_HASH)).toArray(new String[1]);
i = 0;
for (; i<names.length && i<hashes.length; i++) {
for (i = 0; i<names.length && i<hashes.length; i++) {
prop.put(RESULTS + "useDHTPeers_DHTPeers_" + i + "_name", names[i]);
prop.put(RESULTS + "useDHTPeers_DHTPeers_" + i + "_hash", hashes[i]);
}

@ -120,9 +120,7 @@ public class News {
prop.put("page", tableID + 1);
prop.put("table_page", tableID + 1);
if (yacyCore.seedDB == null) {
} else {
if (yacyCore.seedDB != null) {
int maxCount = Math.min(1000, yacyCore.newsPool.size(tableID));
Iterator<yacyNewsRecord> recordIterator = yacyCore.newsPool.recordIterator(tableID, false);
yacyNewsRecord record;

@ -77,7 +77,7 @@ import de.anomic.yacy.yacySeedUploader;
public class SettingsAck_p {
private static boolean nothingChanged;
private static boolean nothingChanged = false;
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch<?> env) {
// return variable that accumulates replacements

@ -65,12 +65,12 @@ import java.io.IOException;
public class Threaddump_p {
private static serverObjects prop;
private static plasmaSwitchboard sb;
private static final serverObjects prop = new serverObjects();
private static plasmaSwitchboard sb = null;
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch<?> env) {
prop = new serverObjects();
prop.clear();
sb = (plasmaSwitchboard) env;
StringBuffer buffer = new StringBuffer(1000);

@ -10,15 +10,15 @@ import de.anomic.server.serverSwitch;
public class xbel {
private static serverObjects prop;
private static plasmaSwitchboard switchboard;
private static boolean isAdmin;
private static final serverObjects prop = new serverObjects();
private static plasmaSwitchboard switchboard = null;
private static boolean isAdmin = false;
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch<?> env) {
int count = 0;;
prop = new serverObjects();
prop.clear();
switchboard = (plasmaSwitchboard) env;
isAdmin=switchboard.verifyAuthentication(header, true);

@ -77,10 +77,10 @@ import de.anomic.yacy.yacyURL;
public class ymarks {
private static serverObjects prop;
private static plasmaSwitchboard switchboard;
private static userDB.Entry user;
private static boolean isAdmin;
private static final serverObjects prop = new serverObjects();
private static plasmaSwitchboard switchboard = null;
private static userDB.Entry user = null;
private static boolean isAdmin = false;
final static int SORT_ALPHA = 1;
final static int SORT_SIZE = 2;
@ -95,7 +95,7 @@ public class ymarks {
String tagName = "";
String username="";
prop = new serverObjects();
prop.clear();
switchboard = (plasmaSwitchboard) env;
user = switchboard.userDB.getUser(header);
isAdmin=(switchboard.verifyAuthentication(header, true) || user!= null && user.hasRight(userDB.Entry.BOOKMARK_RIGHT));
@ -177,7 +177,7 @@ public class ymarks {
}
bookmark.setTags(tags, true);
switchboard.bookmarksDB.saveBookmark(bookmark);
}else{
//}else{
//ERROR
}
}else if(post.containsKey("edit")){

@ -67,8 +67,8 @@ import de.anomic.server.serverCore;
// The Naming of the functions is a bit strange...
public class listManager {
public static plasmaSwitchboard switchboard;
public static File listsPath;
public static plasmaSwitchboard switchboard = null;
public static File listsPath = null;
/**
* Get ListSet from configuration file and return it as a unified Set.

@ -116,7 +116,7 @@ public class translator {
splitted = line.split("==", 2);
if(splitted.length == 2){
translationList.put(splitted[0], splitted[1]);
}else{ //Invalid line
//}else{ //Invalid line
}
}else if(line.startsWith("#File: ")){
if(!forFile.equals("")){
@ -212,7 +212,7 @@ public class translator {
, translationLists.get(relativePath))){
serverLog.logSevere("TRANSLATOR", "File error while translating file "+relativePath);
}
}else{
//}else{
//serverLog.logInfo("TRANSLATOR", "No translation for file: "+relativePath);
}
}

@ -140,14 +140,14 @@ public final class userDB {
String[] tmp=auth.split(":");
if(tmp.length == 2){
entry=this.passwordAuth(tmp[0], tmp[1]);
if(entry != null){
// if(entry != null){
//return entry;
}else{ //wrong/no auth, so auth is removed from browser
// }else{ //wrong/no auth, so auth is removed from browser
/*FIXME: This cannot work
try{
entry.setProperty(Entry.LOGGED_OUT, "false");
}catch(IOException e){}*/
}
// }
return entry;
}
return null;

@ -191,11 +191,11 @@ public class knwikiParser implements wikiParser {
while (m.find()) try {
//System.out.print("found " + st.getClass().getSimpleName() + ": " +
// m.group().replaceAll("\n", "\\\\n").replaceAll("\t", " ") + ", ");
if (st.setText(m.group(), j)) {
// System.out.println("usable");
} else {
if (!st.setText(m.group(), j)) {
// System.out.println("not usable");
continue;
//} else {
// System.out.println("usable");
}
m.appendReplacement(sb, (st.getMarkup() == null) ? m.group() : st.getMarkup());
} catch (wikiParserException e) {

@ -69,11 +69,10 @@ import de.anomic.yacy.yacyURL;
public class htmlFilterContentScraper extends htmlFilterAbstractScraper implements htmlFilterScraper {
// statics: for initialization of the HTMLFilterAbstractScraper
private static HashSet<String> linkTags0;
private static HashSet<String> linkTags1;
private static final HashSet<String> linkTags0 = new HashSet<String>(9,0.99f);
private static final HashSet<String> linkTags1 = new HashSet<String>(7,0.99f);
static {
linkTags0 = new HashSet<String>();
linkTags0.add("img");
linkTags0.add("base");
linkTags0.add("frame");
@ -83,7 +82,6 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemen
linkTags0.add("embed"); //added by [MN]
linkTags0.add("param"); //added by [MN]
linkTags1 = new HashSet<String>();
linkTags1.add("a");
linkTags1.add("h1");
linkTags1.add("h2");

@ -59,21 +59,19 @@ import de.anomic.server.serverCharBuffer;
public class htmlFilterContentTransformer extends htmlFilterAbstractTransformer implements htmlFilterTransformer {
// statics: for initialisation of the HTMLFilterAbstractTransformer
private static TreeSet<String> linkTags0;
private static TreeSet<String> linkTags1;
private static final Collator insensitiveCollator = Collator.getInstance(Locale.US);
private static final TreeSet<String> linkTags0 = new TreeSet<String>(insensitiveCollator);;
private static final TreeSet<String> linkTags1 = new TreeSet<String>(insensitiveCollator);;
static {
insensitiveCollator.setStrength(Collator.SECONDARY);
insensitiveCollator.setDecomposition(Collator.NO_DECOMPOSITION);
}
static {
linkTags0 = new TreeSet<String>(insensitiveCollator);
linkTags0.add("img");
linkTags0.add("input");
linkTags1 = new TreeSet<String>(insensitiveCollator);
linkTags1.add("a");
}
@ -134,6 +132,7 @@ public class htmlFilterContentTransformer extends htmlFilterAbstractTransformer
serverByteBuffer[] sbbs = httpTemplate.splitQuotations(sbb);
//sbb = new serverByteBuffer();
for (int i = 0; i < sbbs.length; i++) {
// TODO: avoid empty if statements
if (sbbs[i].isWhitespace(true)) {
//sbb.append(sbbs[i]);
} else if ((sbbs[i].byteAt(0) == httpTemplate.hash) ||

@ -38,14 +38,13 @@ import de.anomic.server.logging.serverLog;
*/
public abstract class HttpClient {
private static final String systemOST;
static {
// provide system information for client identification
final String loc = generateLocation();
systemOST = System.getProperty("os.arch", "no-os-arch") + " " + System.getProperty("os.name", "no-os-name") +
/**
* provide system information for client identification
*/
private static final String systemOST =
System.getProperty("os.arch", "no-os-arch") + " " + System.getProperty("os.name", "no-os-name") +
" " + System.getProperty("os.version", "no-os-version") + "; " + "java " +
System.getProperty("java.version", "no-java-version") + "; " + loc;
}
System.getProperty("java.version", "no-java-version") + "; " + generateLocation();
/**
* generating the location string

@ -89,13 +89,13 @@ public class httpdByteCountOutputStream extends BufferedOutputStream {
}
/** @see java.io.OutputStream#write(byte[], int, int) */
public void write(byte[] b, int off, int len) throws IOException {
public synchronized void write(byte[] b, int off, int len) throws IOException {
super.write(b, off, len);
this.byteCount += len;
}
/** @see java.io.OutputStream#write(int) */
public void write(int b) throws IOException {
public synchronized void write(int b) throws IOException {
super.write(b);
this.byteCount++;
}

@ -117,8 +117,9 @@ public final class httpdFileHandler {
private static final boolean safeServletsMode = false; // if true then all servlets are called synchronized
private static final Properties mimeTable = new Properties();
private static final serverClassLoader provider;
private static serverSwitch<?> switchboard;
// create a class loader
private static final serverClassLoader provider = new serverClassLoader(/*this.getClass().getClassLoader()*/);
private static serverSwitch<?> switchboard = null;
private static plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();
private static File htRootPath = null;
@ -134,20 +135,15 @@ public final class httpdFileHandler {
public static boolean useTemplateCache = false;
//private Properties connectionProperties = null;
private static serverLog theLogger;
// creating a logger
private static final serverLog theLogger = new serverLog("FILEHANDLER");
static {
serverSwitch<?> switchboard = plasmaSwitchboard.getSwitchboard();
final serverSwitch<?> switchboard = plasmaSwitchboard.getSwitchboard();
useTemplateCache = switchboard.getConfig("enableTemplateCache","true").equalsIgnoreCase("true");
templateCache = (useTemplateCache)? new HashMap<File, SoftReference<byte[]>>() : new HashMap<File, SoftReference<byte[]>>(0);
templateMethodCache = (useTemplateCache) ? new HashMap<File, SoftReference<Method>>() : new HashMap<File, SoftReference<Method>>(0);
// create a class loader
provider = new serverClassLoader(/*this.getClass().getClassLoader()*/);
// creating a logger
theLogger = new serverLog("FILEHANDLER");
if (httpdFileHandler.switchboard == null) {
httpdFileHandler.switchboard = switchboard;
@ -217,7 +213,7 @@ public final class httpdFileHandler {
if (htLocalePath == null) htLocalePath = switchboard.getConfigPath("locale.translated_html","DATA/LOCALE/htroot");
if (!(localeSelection.equals("default"))) {
File localePath = new File(htLocalePath, localeSelection + "/" + path);
File localePath = new File(htLocalePath, localeSelection + '/' + path);
if (localePath.exists()) // avoid "NoSuchFile" troubles if the "localeSelection" is misspelled
return localePath;
}

@ -123,10 +123,10 @@ public final class httpdProxyHandler {
private static int timeout = 30000;
private static boolean yacyTrigger = true;
public static boolean isTransparentProxy = false;
private static Process redirectorProcess;
private static boolean redirectorEnabled=false;
private static PrintWriter redirectorWriter;
private static BufferedReader redirectorReader;
private static Process redirectorProcess = null;
private static boolean redirectorEnabled = false;
private static PrintWriter redirectorWriter = null;
private static BufferedReader redirectorReader = null;
private static htmlFilterTransformer transformer = null;
/**
@ -137,7 +137,8 @@ public final class httpdProxyHandler {
private static File htRootPath = null;
//private Properties connectionProperties = null;
private static serverLog theLogger;
// creating a logger
private static final serverLog theLogger = new serverLog("PROXY");
private static boolean doAccessLogging = false;
/**
@ -191,8 +192,6 @@ public final class httpdProxyHandler {
switchboard = plasmaSwitchboard.getSwitchboard();
if (switchboard != null) {
// creating a logger
theLogger = new serverLog("PROXY");
isTransparentProxy = Boolean.valueOf(switchboard.getConfig("isTransparentProxy","false")).booleanValue();
@ -696,7 +695,7 @@ public final class httpdProxyHandler {
writeContent(res, new BufferedWriter(hfos));
if (hfos instanceof htmlFilterWriter) ((htmlFilterWriter) hfos).finalize();
if (sizeBeforeDelete == -1) {
/*if (sizeBeforeDelete == -1) {
// no old file and no load. just data passing
//cacheEntry.status = plasmaHTCache.CACHE_PASSING;
//cacheManager.push(cacheEntry);
@ -704,7 +703,7 @@ public final class httpdProxyHandler {
// before we came here we deleted a cache entry
//cacheEntry.status = plasmaHTCache.CACHE_STALE_NO_RELOAD;
//cacheManager.push(cacheEntry);
}
}*/
conProp.setProperty(httpHeader.CONNECTION_PROP_PROXY_RESPOND_CODE,"TCP_MISS");
}

@ -59,7 +59,7 @@ public class kelondroHandle implements Comparable<kelondroHandle> {
public boolean equals(Object h) {
assert (index != NUL);
assert (((kelondroHandle) h).index != NUL);
return (this.index == ((kelondroHandle) h).index);
return (h instanceof kelondroHandle && this.index == ((kelondroHandle) h).index);
}
public int compare(kelondroHandle h0, kelondroHandle h1) {

@ -125,9 +125,8 @@ public final class kelondroMScoreCluster<E> {
}
}
private static byte[] plainByteArray;
private static final byte[] plainByteArray = new byte[256];
static {
plainByteArray = new byte[256];
for (int i = 0; i < 32; i++) plainByteArray[i] = (byte) i;
for (int i = 32; i < 96; i++) plainByteArray[i] = (byte) (i - 32);
for (int i = 96; i < 128; i++) plainByteArray[i] = (byte) (i - 64);

@ -874,7 +874,7 @@ public class kelondroRowCollection {
if (b == 0) return a; else return a / b;
}
private static Random random;
private static Random random = null;
private static String randomHash() {
return
kelondroBase64Order.enhancedCoder.encodeLong(random.nextLong(), 4) +
@ -940,9 +940,9 @@ public class kelondroRowCollection {
System.out.println("uniq d : " + (t6 - t5) + " nanoseconds, " + d(testsize, (t6 - t5)) + " entries/nanoseconds");
random = new Random(0);
kelondroRowSet e = new kelondroRowSet(r, testsize);
for (int i = 0; i < testsize; i++) {
/*for (int i = 0; i < testsize; i++) {
//e.put(r.newEntry(randomHash().getBytes()));
}
}*/
long t7 = System.nanoTime();
System.out.println("create e : " + (t7 - t6) + " nanoseconds, " + d(testsize, (t7 - t6)) + " entries/nanoseconds");
e.sort();

@ -235,8 +235,8 @@ public class ftpc {
ret = (((Boolean) getClass().getMethod(cmd[0].toUpperCase(), new Class[0]).invoke(this, new Object[0]))
.booleanValue());
} catch (final InvocationTargetException e) {
if (e.getMessage() == null) {
} else if (notConnected()) {
if (e.getMessage() != null) {
if (notConnected()) {
// the error was probably caused because there is no
// connection
errPrintln("not connected. no effect.");
@ -246,6 +246,7 @@ public class ftpc {
errPrintln("ftp internal exception: target exception " + e);
return ret;
}
}
} catch (final IllegalAccessException e) {
errPrintln("ftp internal exception: wrong access " + e);
return ret;
@ -304,7 +305,7 @@ public class ftpc {
super();
}
public Class<?> loadClass(final String classname, final boolean resolve) throws ClassNotFoundException {
public synchronized Class<?> loadClass(final String classname, final boolean resolve) throws ClassNotFoundException {
Class<?> c = findLoadedClass(classname);
if (c == null) {
try {
@ -394,8 +395,7 @@ public class ftpc {
errPrintln("no \"public static main(String args[])\" in " + obj);
} catch (final InvocationTargetException e) {
final Throwable orig = e.getTargetException();
if (orig.getMessage() == null) {
} else {
if (orig.getMessage() != null) {
errPrintln("Exception from " + obj + ": " + orig.getMessage());
orig.printStackTrace(err);
}

@ -173,36 +173,38 @@ public class plasmaDbImporter extends AbstractImporter implements dbImporter {
if (isAborted()) break;
String urlHash = urlIter.next();
if (importedUrlBuffer.contains(urlHash)) {
// already known url
} else if (unknownUrlBuffer.contains(urlHash)) {
// url known as unknown
unknownUrlBuffer.add(urlHash);
notBoundEntryCounter++;
newContainer.remove(urlHash);
continue;
} else {
// we need to import the url
// getting the url entry
indexURLReference urlEntry = this.importWordIndex.getURL(urlHash, null, 0);
if (urlEntry != null) {
/* write it into the home url db */
homeWordIndex.putURL(urlEntry);
importedUrlBuffer.add(urlHash);
this.urlCounter++;
if (this.urlCounter % 500 == 0) {
this.log.logFine(this.urlCounter + " URLs processed so far.");
}
} else {
if (!importedUrlBuffer.contains(urlHash)) {
if (unknownUrlBuffer.contains(urlHash)) {
// url known as unknown
unknownUrlBuffer.add(urlHash);
notBoundEntryCounter++;
newContainer.remove(urlHash);
continue;
} else {
// we need to import the url
// getting the url entry
indexURLReference urlEntry = this.importWordIndex.getURL(urlHash, null, 0);
if (urlEntry != null) {
/* write it into the home url db */
homeWordIndex.putURL(urlEntry);
importedUrlBuffer.add(urlHash);
this.urlCounter++;
if (this.urlCounter % 500 == 0) {
this.log.logFine(this.urlCounter + " URLs processed so far.");
}
} else {
unknownUrlBuffer.add(urlHash);
notBoundEntryCounter++;
newContainer.remove(urlHash);
continue;
}
}
//} else {
// already known url
}
this.entryCounter++;
}

@ -693,7 +693,7 @@ public final class plasmaCondenser {
char c, lc = ' '; // starting with ' ' as last character prevents that the result string starts with a ' '
// find sentence end
for (;;) {
while (true) {
nextChar = reader.read();
//System.out.print((char) nextChar); // DEBUG
if (nextChar < 0) {

@ -279,6 +279,7 @@ public final class plasmaCrawlStacker extends Thread {
private void deleteDB() {
if (this.dbtype == QUEUE_DB_TYPE_RAM) {
// do nothing..
return;
}
if (this.dbtype == QUEUE_DB_TYPE_ECO) {
new File(cacheStacksPath, stackfile).delete();

@ -101,13 +101,13 @@ public final class plasmaHTCache {
private static final ConcurrentLinkedQueue<Entry> cacheStack = new ConcurrentLinkedQueue<Entry>();
private static final ConcurrentHashMap<String, File> cacheAge = new ConcurrentHashMap<String, File>(); // a <date+hash, cache-path> - relation
public static long curCacheSize = 0;
public static long maxCacheSize;
public static File cachePath;
public static long maxCacheSize = 0l;
public static File cachePath = null;
public static final serverLog log = new serverLog("HTCACHE");
private static long lastcleanup = System.currentTimeMillis();
private static ResourceInfoFactory objFactory = new ResourceInfoFactory();
private static serverThread cacheScanThread;
private static serverThread cacheScanThread = null;
// doctypes:
public static final char DT_PDFPS = 'p';

@ -670,9 +670,7 @@ public final class plasmaSearchEvent {
}
*/
TreeMap<String, String> abstractJoin = (rcAbstracts.size() == query.queryHashes.size()) ? kelondroMSetTools.joinConstructive(rcAbstracts.values(), true) : new TreeMap<String, String>();
if (abstractJoin.size() == 0) {
//System.out.println("DEBUG-INDEXABSTRACT: no success using index abstracts from remote peers");
} else {
if (abstractJoin.size() != 0) {
//System.out.println("DEBUG-INDEXABSTRACT: index abstracts delivered " + abstractJoin.size() + " additional results for secondary search");
// generate query for secondary search
TreeMap<String, String> secondarySearchURLs = new TreeMap<String, String>(); // a (peerhash:urlhash-liststring) mapping
@ -717,6 +715,8 @@ public final class plasmaSearchEvent {
query.ranking, query.constraint, preselectedPeerHashes);
}
//} else {
//System.out.println("DEBUG-INDEXABSTRACT: no success using index abstracts from remote peers");
}
}

@ -86,9 +86,9 @@ public class plasmaSnippetCache {
public static final int ERROR_PARSER_NO_LINES = 15;
public static final int ERROR_NO_MATCH = 16;
private static int snippetsScoreCounter;
private static kelondroMScoreCluster<String> snippetsScore;
private static HashMap<String, String> snippetsCache;
private static int snippetsScoreCounter = 0;
private static kelondroMScoreCluster<String> snippetsScore = null;
private static final HashMap<String, String> snippetsCache = new HashMap<String, String>();
/**
* a cache holding URLs to favicons specified by the page content, e.g. by using the html link-tag. e.g.
@ -96,9 +96,9 @@ public class plasmaSnippetCache {
* &lt;link rel="shortcut icon" type="image/x-icon" href="../src/favicon.ico"&gt;
* </pre>
*/
private static HashMap<String, yacyURL> faviconCache;
private static plasmaParser parser;
private static serverLog log;
private static final HashMap<String, yacyURL> faviconCache = new HashMap<String, yacyURL>();
private static plasmaParser parser = null;
private static serverLog log = null;
public static void init(
plasmaParser parserx,
@ -108,8 +108,8 @@ public class plasmaSnippetCache {
log = logx;
snippetsScoreCounter = 0;
snippetsScore = new kelondroMScoreCluster<String>();
snippetsCache = new HashMap<String, String>();
faviconCache = new HashMap<String, yacyURL>();
snippetsCache.clear();
faviconCache.clear();
}
public static class TextSnippet {
@ -477,7 +477,7 @@ public class plasmaSnippetCache {
if (snippetsScoreCounter == java.lang.Integer.MAX_VALUE) {
snippetsScoreCounter = 0;
snippetsScore = new kelondroMScoreCluster<String>();
snippetsCache = new HashMap<String, String>();
snippetsCache.clear();
}
// flush cache if cache is full

@ -184,7 +184,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<plasmaSwitchbo
public static TreeSet<String> badwords = null;
public static TreeSet<String> blueList = null;
public static TreeSet<String> stopwords = null;
public static indexReferenceBlacklist urlBlacklist;
public static indexReferenceBlacklist urlBlacklist = null;
public static wikiParser wikiParser = null;
@ -207,7 +207,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<plasmaSwitchbo
public wikiBoard wikiDB;
public blogBoard blogDB;
public blogBoardComments blogCommentDB;
public static plasmaCrawlRobotsTxt robots;
public static plasmaCrawlRobotsTxt robots = null;
public plasmaCrawlProfile profilesActiveCrawls, profilesPassiveCrawls;
public plasmaCrawlProfile.entry defaultProxyProfile;
public plasmaCrawlProfile.entry defaultRemoteProfile;
@ -836,7 +836,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<plasmaSwitchbo
public Hashtable<String, Object[]> crawlJobsStatus = new Hashtable<String, Object[]>();
private static plasmaSwitchboard sb;
private static plasmaSwitchboard sb = null;
public plasmaSwitchboard(File rootPath, String initPath, String configPath, boolean applyPro) {
super(rootPath, initPath, configPath, applyPro);
@ -1627,9 +1627,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<plasmaSwitchbo
}
// work off unwritten files
if (entry.cacheArray() == null) {
//this.log.logFine("EXISTING FILE (" + entry.cacheFile.length() + " bytes) for " + entry.cacheFile);
} else {
if (entry.cacheArray() != null) {
String error = entry.shallStoreCacheForProxy();
if (error == null) {
plasmaHTCache.writeResourceContent(entry.url(), entry.cacheArray());
@ -1637,6 +1635,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<plasmaSwitchbo
} else {
if (this.log.isFine()) this.log.logFine("WRITE OF FILE " + entry.cacheFile() + " FORBIDDEN: " + error);
}
//} else {
//this.log.logFine("EXISTING FILE (" + entry.cacheFile.length() + " bytes) for " + entry.cacheFile);
}
}

@ -62,7 +62,7 @@ public final class ConsoleOutHandler extends StreamHandler{
flush();
}
public void close() {
public synchronized void close() {
flush();
}
}

@ -94,10 +94,10 @@ public class serverPortForwardingSch implements serverPortForwarding{
private String localHost;
private int localHostPort;
private static Session session;
private static serverInstantBusyThread sessionWatcher;
private static Session session = null;
private static serverInstantBusyThread sessionWatcher = null;
private serverLog log;
private final serverLog log;
public serverPortForwardingSch() {
super();

@ -121,7 +121,7 @@ public class serverCachedFileOutputStream extends ByteArrayOutputStream {
return this.isFallback;
}
public void write(int b) {
public synchronized void write(int b) {
if (checkFallback(++this.size)) try {
this.fallback.write(b);
} catch (IOException e) {
@ -131,7 +131,7 @@ public class serverCachedFileOutputStream extends ByteArrayOutputStream {
}
}
public void write(byte[] b, int off, int len) {
public synchronized void write(byte[] b, int off, int len) {
if (checkFallback(this.size += len)) try {
this.fallback.write(b, off, len);
} catch (IOException e) {

@ -834,33 +834,31 @@ public final class serverCore extends serverAbstractBusyThread implements server
//announceMoreExecTime(commandStart - System.currentTimeMillis()); // shall be negative!
//log.logDebug("* session " + handle + " completed command '" + request + "'. time = " + (System.currentTimeMillis() - handle));
this.out.flush();
if (result == null) {
/*
log(2, true, "(NULL RETURNED/STREAM PASSED)");
*/
} else if (result instanceof Boolean) {
if (((Boolean) result).equals(TERMINATE_CONNECTION)) break;
/*
* setting timeout to a very high level.
* this is needed because of persistent connection
* support.
*/
if (!this.controlSocket.isClosed()) this.controlSocket.setSoTimeout(30*60*1000);
} else if (result instanceof String) {
if (((String) result).startsWith("!")) {
result = ((String) result).substring(1);
terminate = true;
}
writeLine((String) result);
} else if (result instanceof InputStream) {
String tmp = send(this.out, (InputStream) result);
if ((tmp.length() > 4) && (tmp.toUpperCase().startsWith("PASS"))) {
log(true, "PASS ********");
} else {
log(true, tmp);
if (result != null) {
if (result instanceof Boolean) {
if (((Boolean) result).equals(TERMINATE_CONNECTION)) break;
/*
* setting timeout to a very high level.
* this is needed because of persistent connection
* support.
*/
if (!this.controlSocket.isClosed()) this.controlSocket.setSoTimeout(30*60*1000);
} else if (result instanceof String) {
if (((String) result).startsWith("!")) {
result = ((String) result).substring(1);
terminate = true;
}
writeLine((String) result);
} else if (result instanceof InputStream) {
String tmp = send(this.out, (InputStream) result);
if ((tmp.length() > 4) && (tmp.toUpperCase().startsWith("PASS"))) {
log(true, "PASS ********");
} else {
log(true, tmp);
}
tmp = null;
}
tmp = null;
}
if (terminate) break;

@ -117,7 +117,7 @@ public class serverCoreSocket extends Socket {
break;
}
this.isSSL = true;
} else {
//} else {
// maybe SSL_2, but we can not be sure
}

@ -441,23 +441,20 @@ public final class serverDate {
private static Calendar thisCalendar = Calendar.getInstance();
// pre-calculation of time tables
private final static long[] dimnormalacc, dimleapacc;
private static long[] utimeyearsacc;
private final static long[] dimnormalacc = new long[12], dimleapacc = new long[12];
private final static long[] utimeyearsacc = new long[67];
static {
long millis = 0;
utimeyearsacc = new long[67];
for (int i = 0; i < 67; i++) {
utimeyearsacc[i] = millis;
millis += ((i & 3) == 0) ? leapyearMillis : normalyearMillis;
}
millis = 0;
dimnormalacc = new long[12];
for (int i = 0; i < 12; i++) {
dimnormalacc[i] = millis;
millis += (dayMillis * dimnormal[i]);
}
millis = 0;
dimleapacc = new long[12];
for (int i = 0; i < 12; i++) {
dimleapacc[i] = millis;
millis += (dayMillis * dimleap[i]);

@ -39,7 +39,7 @@ public class serverMemory {
private static final long[] gcs = new long[5];
private static int gcs_pos = 0;
private static long lastGC;
private static long lastGC = 0l;
/**
* Runs the garbage collector if last garbage collection is more than last millis ago

@ -33,17 +33,15 @@ import java.util.concurrent.ConcurrentLinkedQueue;
public class serverProfiling extends Thread {
private static Map<String, ConcurrentLinkedQueue<Event>> historyMaps; // key=name of history, value=TreeMap of Long/Event
private static Map<String, Integer> eventCounter; // key=name of history, value=Integer of event counter
private static serverProfiling systemProfiler;
static {
// initialize profiling
historyMaps = new ConcurrentHashMap<String, ConcurrentLinkedQueue<Event>>();
eventCounter = new ConcurrentHashMap<String, Integer>();
//lastCompleteCleanup = System.currentTimeMillis();
systemProfiler = null;
}
/**
* key=name of history, value=TreeMap of Long/Event
*/
private static final Map<String, ConcurrentLinkedQueue<Event>> historyMaps = new ConcurrentHashMap<String, ConcurrentLinkedQueue<Event>>();;
/**
* key=name of history, value=Integer of event counter
*/
private static final Map<String, Integer> eventCounter = new ConcurrentHashMap<String, Integer>();
private static serverProfiling systemProfiler = null;
public static void startSystemProfiling() {
systemProfiler = new serverProfiling(1000);

@ -295,32 +295,33 @@ public final class serverSystem {
try {
String cmd;
Process p;
if (systemOS == systemUnknown) {
} else if (systemOS == systemMacOSC) {
if ((isMacArchitecture) && (macMRJFileUtils != null)) {
macOpenURL.invoke(null, new Object[] {url});
}
} else if (systemOS == systemMacOSX) {
p = Runtime.getRuntime().exec(new String[] {"/usr/bin/osascript", "-e", "open location \"" + url + "\""});
p.waitFor();
if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));
} else if (systemOS == systemUnix) {
cmd = app + " -remote openURL(" + url + ") &";
p = Runtime.getRuntime().exec(cmd);
p.waitFor();
if (p.exitValue() != 0) {
cmd = app + " " + url + " &";
p = Runtime.getRuntime().exec(cmd);
p.waitFor();
}
if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));
} else if (systemOS == systemWindows) {
// see forum at http://forum.java.sun.com/thread.jsp?forum=57&thread=233364&message=838441
cmd = "rundll32 url.dll,FileProtocolHandler " + url;
//cmd = "cmd.exe /c start javascript:document.location='" + url + "'";
p = Runtime.getRuntime().exec(cmd);
p.waitFor();
if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));
if (systemOS != systemUnknown) {
if (systemOS == systemMacOSC) {
if ((isMacArchitecture) && (macMRJFileUtils != null)) {
macOpenURL.invoke(null, new Object[] {url});
}
} else if (systemOS == systemMacOSX) {
p = Runtime.getRuntime().exec(new String[] {"/usr/bin/osascript", "-e", "open location \"" + url + "\""});
p.waitFor();
if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));
} else if (systemOS == systemUnix) {
cmd = app + " -remote openURL(" + url + ") &";
p = Runtime.getRuntime().exec(cmd);
p.waitFor();
if (p.exitValue() != 0) {
cmd = app + " " + url + " &";
p = Runtime.getRuntime().exec(cmd);
p.waitFor();
}
if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));
} else if (systemOS == systemWindows) {
// see forum at http://forum.java.sun.com/thread.jsp?forum=57&thread=233364&message=838441
cmd = "rundll32 url.dll,FileProtocolHandler " + url;
//cmd = "cmd.exe /c start javascript:document.location='" + url + "'";
p = Runtime.getRuntime().exec(cmd);
p.waitFor();
if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));
}
}
} catch (Exception e) {
System.out.println("please start your browser and open the following location: " + url);

@ -41,9 +41,14 @@
package de.anomic.tools;
import java.io.Serializable;
import java.util.LinkedList;
public class disorderHeap {
public class disorderHeap implements Serializable {
/**
* generated with svn4743 on 2008-04-28
*/
private static final long serialVersionUID = -1576632540870640019L;
LinkedList<String> list;

@ -937,9 +937,9 @@ public final class yacyClient {
final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), targetSeed.hash, salt);
// enabling gzip compression for post request body
if ((gzipBody) && (targetSeed.getVersion() >= yacyVersion.YACY_SUPPORTS_GZIP_POST_REQUESTS)) {
/*if ((gzipBody) && (targetSeed.getVersion() >= yacyVersion.YACY_SUPPORTS_GZIP_POST_REQUESTS)) {
// TODO generate gzip-Header (and stream?)
}
}*/
post.add(new StringPart("wordc", Integer.toString(indexes.length)));
int indexcount = 0;
@ -995,9 +995,9 @@ public final class yacyClient {
final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), targetSeed.hash, salt);
// enabling gzip compression for post request body
if ((gzipBody) && (targetSeed.getVersion() >= yacyVersion.YACY_SUPPORTS_GZIP_POST_REQUESTS)) {
/*if ((gzipBody) && (targetSeed.getVersion() >= yacyVersion.YACY_SUPPORTS_GZIP_POST_REQUESTS)) {
// TODO generate gzip-Header (and stream?)
}
}*/
String resource = "";
int urlc = 0;

@ -88,11 +88,11 @@ public class yacyCore {
public static final HashMap<String, String> seedUploadMethods = new HashMap<String, String>();
public static yacyPeerActions peerActions = null;
public static yacyDHTAction dhtAgent = null;
public static serverLog log;
public static final serverLog log = new serverLog("YACY");
public static long lastOnlineTime = 0;
/** pseudo-random key derived from a time-interval while YaCy startup*/
public static long speedKey = 0;
public static File yacyDBPath;
public static File yacyDBPath = null;
public static final Map<String, yacyAccessible> amIAccessibleDB = Collections.synchronizedMap(new HashMap<String, yacyAccessible>()); // Holds PeerHash / yacyAccessible Relations
// constants for PeerPing behaviour
private static final int PING_INITIAL = 10;
@ -131,9 +131,6 @@ public class yacyCore {
peernews.setMaxsize(1000);
peernews.addMessage(new RSSMessage("YaCy started", ""));
// set log level
log = new serverLog("YACY");
// create a yacy db
yacyDBPath = sb.getConfigPath("yacyDB", "DATA/YACYDB");
if (!yacyDBPath.exists()) { yacyDBPath.mkdir(); }
@ -590,9 +587,9 @@ public class yacyCore {
for (int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++) {
Thread currentThread = threadList[currentThreadIdx];
if (currentThread.isAlive()) {
/*if (currentThread.isAlive()) {
// TODO: this object should care of all open clien connections within this class and close them here
}
}*/
}
// we need to use a timeout here because of missing interruptable session threads ...

@ -254,9 +254,8 @@ public class yacyNewsPool {
CATEGORY_BLOG_ADD,
CATEGORY_BLOG_DEL
};
public static HashSet<String> categories;
public static final HashSet<String> categories = new HashSet<String>();
static {
categories = new HashSet<String>();
for (int i = 0; i < category.length; i++) categories.add(category[i]);
}

@ -322,9 +322,9 @@ public class yacyPeerActions {
return false;
}
if (connectedSeed.getName() != seed.getName()) {
/*if (connectedSeed.getName() != seed.getName()) {
// TODO: update seed name lookup cache
}
}*/
} catch (NumberFormatException e) {
yacyCore.log.logFine("connect: rejecting wrong peer '" + seed.getName() + "' from " + seed.getPublicAddress() + ". Cause: " + e.getMessage());
return false;

@ -28,6 +28,7 @@ package de.anomic.yacy;
// and to prevent that java.net.URL usage causes DNS queries which are used in java.net.
import java.io.File;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.util.Iterator;
import java.util.TreeSet;
@ -40,14 +41,17 @@ import de.anomic.server.serverDomains;
import de.anomic.tools.Punycode;
import de.anomic.tools.Punycode.PunycodeException;
public class yacyURL {
public class yacyURL implements Serializable {
/**
* generated with svn4751 on 2008-05-01
*/
private static final long serialVersionUID = -1173233022912141884L;
public static final int TLD_any_zone_filter = 255; // from TLD zones can be filtered during search; this is the catch-all filter
public static String dummyHash;
public static String dummyHash = "";
static {
// create a dummy hash
dummyHash = "";
for (int i = 0; i < yacySeedDB.commonHashLength; i++) dummyHash += "-";
}

@ -154,8 +154,12 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya
}
public boolean equals(Object obj) {
yacyVersion v = (yacyVersion) obj;
return (this.svn == v.svn) && (this.url.toNormalform(true, true).equals(v.url.toNormalform(true, true)));
if(obj instanceof yacyVersion) {
yacyVersion v = (yacyVersion) obj;
return (this.svn == v.svn) && (this.url.toNormalform(true, true).equals(v.url.toNormalform(true, true)));
} else {
return false;
}
}
public int hashCode() {

@ -140,7 +140,7 @@ public final class yacy {
// static objects
public static final String vString = "@REPL_VERSION@";
public static double version = 0.1;
public static boolean pro;
public static boolean pro = false;
public static final String vDATE = "@REPL_DATE@";
public static final String copyright = "[ YaCy v" + vString + ", build " + vDATE + " by Michael Christen / www.yacy.net ]";

Loading…
Cancel
Save