some more generics

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4338 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent dc26d6262b
commit a0f7f2faad

@ -67,12 +67,12 @@ public final class plasmaSearchEvent {
private plasmaSearchQuery query; private plasmaSearchQuery query;
private plasmaWordIndex wordIndex; private plasmaWordIndex wordIndex;
private plasmaSearchRankingProcess rankedCache; // ordered search results, grows dynamically as all the query threads enrich this container private plasmaSearchRankingProcess rankedCache; // ordered search results, grows dynamically as all the query threads enrich this container
private Map rcAbstracts; // cache for index abstracts; word:TreeMap mapping where the embedded TreeMap is a urlhash:peerlist relation private Map<String, TreeMap<String, String>> rcAbstracts; // cache for index abstracts; word:TreeMap mapping where the embedded TreeMap is a urlhash:peerlist relation
private yacySearch[] primarySearchThreads, secondarySearchThreads; private yacySearch[] primarySearchThreads, secondarySearchThreads;
private Thread localSearchThread; private Thread localSearchThread;
private TreeMap preselectedPeerHashes; private TreeMap preselectedPeerHashes;
//private Object[] references; //private Object[] references;
public TreeMap IAResults; public TreeMap<String, String> IAResults;
public TreeMap<String, Integer> IACount; public TreeMap<String, Integer> IACount;
public String IAmaxcounthash, IAneardhthash; public String IAmaxcounthash, IAneardhthash;
private int localcount; private int localcount;
@ -92,12 +92,12 @@ public final class plasmaSearchEvent {
this.eventTime = System.currentTimeMillis(); // for lifetime check this.eventTime = System.currentTimeMillis(); // for lifetime check
this.wordIndex = wordIndex; this.wordIndex = wordIndex;
this.query = query; this.query = query;
this.rcAbstracts = (query.queryHashes.size() > 1) ? new TreeMap() : null; // generate abstracts only for combined searches this.rcAbstracts = (query.queryHashes.size() > 1) ? new TreeMap<String, TreeMap<String, String>>() : null; // generate abstracts only for combined searches
this.primarySearchThreads = null; this.primarySearchThreads = null;
this.secondarySearchThreads = null; this.secondarySearchThreads = null;
this.preselectedPeerHashes = preselectedPeerHashes; this.preselectedPeerHashes = preselectedPeerHashes;
this.IAResults = new TreeMap(); this.IAResults = new TreeMap<String, String>();
this.IACount = new TreeMap(); this.IACount = new TreeMap<String, Integer>();
this.IAmaxcounthash = null; this.IAmaxcounthash = null;
this.IAneardhthash = null; this.IAneardhthash = null;
this.localcount = 0; this.localcount = 0;

@ -95,7 +95,7 @@ public final class yacyClient {
// but they appear to be another peer by comparisment of the other peer's hash // but they appear to be another peer by comparisment of the other peer's hash
// this works of course only if we know the other peer's hash. // this works of course only if we know the other peer's hash.
HashMap result = null; HashMap<String, String> result = null;
final serverObjects post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), null); final serverObjects post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), null);
for (int retry = 0; retry < 3; retry++) try { for (int retry = 0; retry < 3; retry++) try {
// generate request // generate request
@ -244,7 +244,7 @@ public final class yacyClient {
// send request // send request
try { try {
final HashMap result = nxTools.table( final HashMap<String, String> result = nxTools.table(
httpc.wput(new yacyURL("http://" + target.getClusterAddress() + "/yacy/query.html", null), httpc.wput(new yacyURL("http://" + target.getClusterAddress() + "/yacy/query.html", null),
target.getHexHash() + ".yacyh", target.getHexHash() + ".yacyh",
8000, 8000,
@ -274,7 +274,7 @@ public final class yacyClient {
// send request // send request
try { try {
final HashMap result = nxTools.table( final HashMap<String, String> result = nxTools.table(
httpc.wput(new yacyURL("http://" + target.getClusterAddress() + "/yacy/query.html", null), httpc.wput(new yacyURL("http://" + target.getClusterAddress() + "/yacy/query.html", null),
target.getHexHash() + ".yacyh", target.getHexHash() + ".yacyh",
8000, 8000,
@ -306,7 +306,7 @@ public final class yacyClient {
// send request // send request
try { try {
final HashMap result = nxTools.table( final HashMap<String, String> result = nxTools.table(
httpc.wput(new yacyURL("http://" + target.getClusterAddress() + "/yacy/query.html", null), httpc.wput(new yacyURL("http://" + target.getClusterAddress() + "/yacy/query.html", null),
target.getHexHash() + ".yacyh", target.getHexHash() + ".yacyh",
6000, 6000,
@ -386,7 +386,7 @@ public final class yacyClient {
yacySeed target, yacySeed target,
plasmaWordIndex wordIndex, plasmaWordIndex wordIndex,
plasmaSearchRankingProcess containerCache, plasmaSearchRankingProcess containerCache,
Map abstractCache, Map<String, TreeMap<String, String>> abstractCache,
plasmaURLPattern blacklist, plasmaURLPattern blacklist,
plasmaSearchRankingProfile rankingProfile, plasmaSearchRankingProfile rankingProfile,
kelondroBitfield constraint kelondroBitfield constraint
@ -426,7 +426,7 @@ public final class yacyClient {
final long timestamp = System.currentTimeMillis(); final long timestamp = System.currentTimeMillis();
// send request // send request
HashMap result = null; HashMap<String, String> result = null;
try { try {
result = nxTools.table( result = nxTools.table(
httpc.wput(new yacyURL("http://" + target.getClusterAddress() + "/yacy/search.html", null), httpc.wput(new yacyURL("http://" + target.getClusterAddress() + "/yacy/search.html", null),
@ -585,7 +585,7 @@ public final class yacyClient {
if (((String) entry.getKey()).startsWith("indexabstract.")) { if (((String) entry.getKey()).startsWith("indexabstract.")) {
wordhash = ((String) entry.getKey()).substring(14); wordhash = ((String) entry.getKey()).substring(14);
synchronized (abstractCache) { synchronized (abstractCache) {
singleAbstract = (TreeMap) abstractCache.get(wordhash); // a mapping from url-hashes to a string of peer-hashes singleAbstract = (TreeMap<String, String>) abstractCache.get(wordhash); // a mapping from url-hashes to a string of peer-hashes
if (singleAbstract == null) singleAbstract = new TreeMap(); if (singleAbstract == null) singleAbstract = new TreeMap();
ci = new serverByteBuffer(((String) entry.getValue()).getBytes()); ci = new serverByteBuffer(((String) entry.getValue()).getBytes());
//System.out.println("DEBUG-ABSTRACTFETCH: for word hash " + wordhash + " received " + ci.toString()); //System.out.println("DEBUG-ABSTRACTFETCH: for word hash " + wordhash + " received " + ci.toString());
@ -632,7 +632,7 @@ public final class yacyClient {
// send request // send request
try { try {
final HashMap result = nxTools.table( final HashMap<String, String> result = nxTools.table(
httpc.wput(new yacyURL("http://" + targetAddress(targetHash) + "/yacy/message.html", null), httpc.wput(new yacyURL("http://" + targetAddress(targetHash) + "/yacy/message.html", null),
yacySeed.b64Hash2hexHash(targetHash)+ ".yacyh", yacySeed.b64Hash2hexHash(targetHash)+ ".yacyh",
8000, 8000,
@ -667,7 +667,7 @@ public final class yacyClient {
// send request // send request
try { try {
final HashMap result = nxTools.table( final HashMap<String, String> result = nxTools.table(
httpc.wput(new yacyURL("http://" + targetAddress(targetHash) + "/yacy/message.html", null), httpc.wput(new yacyURL("http://" + targetAddress(targetHash) + "/yacy/message.html", null),
yacySeed.b64Hash2hexHash(targetHash)+ ".yacyh", yacySeed.b64Hash2hexHash(targetHash)+ ".yacyh",
20000, 20000,
@ -712,7 +712,7 @@ public final class yacyClient {
// send request // send request
try { try {
final yacyURL url = new yacyURL("http://" + targetAddress + "/yacy/transfer.html", null); final yacyURL url = new yacyURL("http://" + targetAddress + "/yacy/transfer.html", null);
final HashMap result = nxTools.table( final HashMap<String, String> result = nxTools.table(
httpc.wput(url, httpc.wput(url,
url.getHost(), url.getHost(),
6000, 6000,
@ -747,7 +747,7 @@ public final class yacyClient {
// send request // send request
try { try {
final yacyURL url = new yacyURL("http://" + targetAddress + "/yacy/transfer.html", null); final yacyURL url = new yacyURL("http://" + targetAddress + "/yacy/transfer.html", null);
final HashMap result = nxTools.table( final HashMap<String, String> result = nxTools.table(
httpc.wput(url, httpc.wput(url,
url.getHost(), url.getHost(),
20000, 20000,
@ -790,7 +790,7 @@ public final class yacyClient {
return "wrong protocol: " + protocol; return "wrong protocol: " + protocol;
} }
public static HashMap crawlReceipt(yacySeed target, String process, String result, String reason, indexURLEntry entry, String wordhashes) { public static HashMap<String, String> crawlReceipt(yacySeed target, String process, String result, String reason, indexURLEntry entry, String wordhashes) {
assert (target != null); assert (target != null);
assert (yacyCore.seedDB.mySeed() != null); assert (yacyCore.seedDB.mySeed() != null);
assert (yacyCore.seedDB.mySeed() != target); assert (yacyCore.seedDB.mySeed() != target);
@ -868,14 +868,14 @@ public final class yacyClient {
} }
// transfer the RWI without the URLs // transfer the RWI without the URLs
HashMap in = transferRWI(targetSeed, indexes, gzipBody, timeout); HashMap<String, String> in = transferRWI(targetSeed, indexes, gzipBody, timeout);
resultObj.put("resultTransferRWI", in); resultObj.put("resultTransferRWI", in);
if (in == null) { if (in == null) {
resultObj.put("result", "no_connection_1"); resultObj.put("result", "no_connection_1");
return resultObj; return resultObj;
} }
if (in.containsKey("indexPayloadSize")) payloadSize += ((Integer)in.get("indexPayloadSize")).intValue(); if (in.containsKey("indexPayloadSize")) payloadSize += Integer.parseInt(in.get("indexPayloadSize"));
String result = (String) in.get("result"); String result = (String) in.get("result");
if (result == null) { if (result == null) {
@ -916,7 +916,7 @@ public final class yacyClient {
resultObj.put("result","no_connection_2"); resultObj.put("result","no_connection_2");
return resultObj; return resultObj;
} }
if (in.containsKey("urlPayloadSize")) payloadSize += ((Integer)in.get("urlPayloadSize")).intValue(); if (in.containsKey("urlPayloadSize")) payloadSize += Integer.parseInt(in.get("urlPayloadSize"));
result = (String) in.get("result"); result = (String) in.get("result");
if (result == null) { if (result == null) {
@ -975,9 +975,9 @@ public final class yacyClient {
} }
post.put("entryc", indexcount); post.put("entryc", indexcount);
post.put("indexes", entrypost.toString()); post.put("indexes", entrypost.toString());
try { try {
final ArrayList v = nxTools.strings( final ArrayList<String> v = nxTools.strings(
httpc.wput( httpc.wput(
new yacyURL("http://" + address + "/yacy/transferRWI.html", null), new yacyURL("http://" + address + "/yacy/transferRWI.html", null),
targetSeed.getHexHash() + ".yacyh", targetSeed.getHexHash() + ".yacyh",
@ -993,9 +993,9 @@ public final class yacyClient {
yacyCore.seedDB.mySeed().incSI(indexcount); yacyCore.seedDB.mySeed().incSI(indexcount);
} }
final HashMap result = nxTools.table(v); final HashMap<String, String> result = nxTools.table(v);
// return the transfered index data in bytes (for debugging only) // return the transfered index data in bytes (for debugging only)
result.put("indexPayloadSize", new Integer(entrypost.length())); result.put("indexPayloadSize", Integer.toString(entrypost.length()));
return result; return result;
} catch (Exception e) { } catch (Exception e) {
yacyCore.log.logSevere("yacyClient.transferRWI error:" + e.getMessage()); yacyCore.log.logSevere("yacyClient.transferRWI error:" + e.getMessage());
@ -1003,7 +1003,7 @@ public final class yacyClient {
} }
} }
private static HashMap transferURL(yacySeed targetSeed, indexURLEntry[] urls, boolean gzipBody, int timeout) { private static HashMap<String, String> transferURL(yacySeed targetSeed, indexURLEntry[] urls, boolean gzipBody, int timeout) {
// this post a message to the remote message board // this post a message to the remote message board
final String address = targetSeed.getPublicAddress(); final String address = targetSeed.getPublicAddress();
if (address == null) { return null; } if (address == null) { return null; }
@ -1031,7 +1031,7 @@ public final class yacyClient {
} }
post.put("urlc", urlc); post.put("urlc", urlc);
try { try {
final ArrayList v = nxTools.strings( final ArrayList<String> v = nxTools.strings(
httpc.wput( httpc.wput(
new yacyURL("http://" + address + "/yacy/transferURL.html", null), new yacyURL("http://" + address + "/yacy/transferURL.html", null),
targetSeed.getHexHash() + ".yacyh", targetSeed.getHexHash() + ".yacyh",
@ -1047,9 +1047,9 @@ public final class yacyClient {
yacyCore.seedDB.mySeed().incSU(urlc); yacyCore.seedDB.mySeed().incSU(urlc);
} }
HashMap result = nxTools.table(v); HashMap<String, String> result = nxTools.table(v);
// return the transfered url data in bytes (for debugging only) // return the transfered url data in bytes (for debugging only)
result.put("urlPayloadSize", new Integer(urlPayloadSize)); result.put("urlPayloadSize", Integer.toString(urlPayloadSize));
return result; return result;
} catch (Exception e) { } catch (Exception e) {
yacyCore.log.logSevere("yacyClient.transferURL error:" + e.getMessage()); yacyCore.log.logSevere("yacyClient.transferURL error:" + e.getMessage());
@ -1057,7 +1057,7 @@ public final class yacyClient {
} }
} }
public static HashMap getProfile(yacySeed targetSeed) { public static HashMap<String, String> getProfile(yacySeed targetSeed) {
// this post a message to the remote message board // this post a message to the remote message board
final serverObjects post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), targetSeed.hash); final serverObjects post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), targetSeed.hash);
@ -1102,7 +1102,7 @@ public final class yacyClient {
(sb.remoteProxyConfig.useProxy()) && (sb.remoteProxyConfig.useProxy()) &&
(sb.remoteProxyConfig.useProxy4Yacy()); (sb.remoteProxyConfig.useProxy4Yacy());
final HashMap result = nxTools.table( final HashMap<String, String> result = nxTools.table(
httpc.wget( httpc.wget(
new yacyURL("http://" + target.getPublicAddress() + "/yacy/search.html" + new yacyURL("http://" + target.getPublicAddress() + "/yacy/search.html" +
"?myseed=" + yacyCore.seedDB.mySeed().genSeedStr(null) + "?myseed=" + yacyCore.seedDB.mySeed().genSeedStr(null) +

@ -91,7 +91,7 @@ public class yacyCore {
/** pseudo-random key derived from a time-interval while YaCy startup*/ /** pseudo-random key derived from a time-interval while YaCy startup*/
public static long speedKey = 0; public static long speedKey = 0;
public static File yacyDBPath; public static File yacyDBPath;
public static final Map amIAccessibleDB = Collections.synchronizedMap(new HashMap()); // Holds PeerHash / yacyAccessible Relations public static final Map<String, yacyAccessible> amIAccessibleDB = Collections.synchronizedMap(new HashMap<String, yacyAccessible>()); // Holds PeerHash / yacyAccessible Relations
// constants for PeerPing behaviour // constants for PeerPing behaviour
private static final int PING_INITIAL = 10; private static final int PING_INITIAL = 10;
private static final int PING_MAX_RUNNING = 3; private static final int PING_MAX_RUNNING = 3;

@ -66,7 +66,7 @@ public class yacySearch extends Thread {
final private int partitions; final private int partitions;
final private plasmaWordIndex wordIndex; final private plasmaWordIndex wordIndex;
final private plasmaSearchRankingProcess containerCache; final private plasmaSearchRankingProcess containerCache;
final private Map abstractCache; final private Map<String, TreeMap<String, String>> abstractCache;
final private plasmaURLPattern blacklist; final private plasmaURLPattern blacklist;
final private yacySeed targetPeer; final private yacySeed targetPeer;
private String[] urls; private String[] urls;
@ -77,7 +77,8 @@ public class yacySearch extends Thread {
public yacySearch(String wordhashes, String excludehashes, String urlhashes, String prefer, String filter, int count, int maxDistance, public yacySearch(String wordhashes, String excludehashes, String urlhashes, String prefer, String filter, int count, int maxDistance,
boolean global, int partitions, yacySeed targetPeer, plasmaWordIndex wordIndex, boolean global, int partitions, yacySeed targetPeer, plasmaWordIndex wordIndex,
plasmaSearchRankingProcess containerCache, Map abstractCache, plasmaSearchRankingProcess containerCache,
Map<String, TreeMap<String, String>> abstractCache,
plasmaURLPattern blacklist, plasmaURLPattern blacklist,
plasmaSearchRankingProfile rankingProfile, plasmaSearchRankingProfile rankingProfile,
kelondroBitfield constraint) { kelondroBitfield constraint) {
@ -247,10 +248,13 @@ public class yacySearch extends Thread {
String wordhashes, String excludehashes, String urlhashes, String wordhashes, String excludehashes, String urlhashes,
String prefer, String filter, int count, int maxDist, String prefer, String filter, int count, int maxDist,
plasmaWordIndex wordIndex, plasmaWordIndex wordIndex,
plasmaSearchRankingProcess containerCache, Map abstractCache, plasmaSearchRankingProcess containerCache,
int targets, plasmaURLPattern blacklist, Map<String, TreeMap<String, String>> abstractCache,
int targets,
plasmaURLPattern blacklist,
plasmaSearchRankingProfile rankingProfile, plasmaSearchRankingProfile rankingProfile,
kelondroBitfield constraint, TreeMap clusterselection) { kelondroBitfield constraint,
TreeMap clusterselection) {
// check own peer status // check own peer status
if (yacyCore.seedDB.mySeed() == null || yacyCore.seedDB.mySeed().getPublicAddress() == null) { return null; } if (yacyCore.seedDB.mySeed() == null || yacyCore.seedDB.mySeed().getPublicAddress() == null) { return null; }
@ -283,7 +287,7 @@ public class yacySearch extends Thread {
if (targetPeer == null) return null; if (targetPeer == null) return null;
if (clusterselection != null) targetPeer.setAlternativeAddress((String) clusterselection.get(targetPeer.hash)); if (clusterselection != null) targetPeer.setAlternativeAddress((String) clusterselection.get(targetPeer.hash));
yacySearch searchThread = new yacySearch(wordhashes, excludehashes, urlhashes, "", "", 0, 9999, true, 0, targetPeer, yacySearch searchThread = new yacySearch(wordhashes, excludehashes, urlhashes, "", "", 0, 9999, true, 0, targetPeer,
wordIndex, containerCache, new TreeMap(), blacklist, rankingProfile, constraint); wordIndex, containerCache, new TreeMap<String, TreeMap<String, String>>(), blacklist, rankingProfile, constraint);
searchThread.start(); searchThread.start();
return searchThread; return searchThread;
} }

Loading…
Cancel
Save