more generics

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4380 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 4e70dff8cf
commit 9e7cd4fdbb

@ -83,7 +83,7 @@ public class yacyCore {
public static final ThreadGroup publishThreadGroup = new ThreadGroup("publishThreadGroup");
public static yacySeedDB seedDB = null;
public static yacyNewsPool newsPool = null;
public static final HashMap seedUploadMethods = new HashMap();
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;
@ -291,10 +291,10 @@ public class yacyCore {
private int added;
private yacySeed seed;
private final serverSemaphore sync;
private final List syncList;
private final List<Thread> syncList;
public publishThread(ThreadGroup tg, yacySeed seed,
serverSemaphore sync, List syncList) throws InterruptedException {
serverSemaphore sync, List<Thread> syncList) throws InterruptedException {
super(tg, "PublishSeed_" + seed.getName());
this.sync = sync;
@ -369,24 +369,24 @@ public class yacyCore {
// probed until we get a valid response.
// init yacyHello-process
Map seeds; // hash/yacySeed relation
Map<String, yacySeed> seeds; // hash/yacySeed relation
int attempts = seedDB.sizeConnected();
// getting a list of peers to contact
if (seedDB.mySeed().get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN).equals(yacySeed.PEERTYPE_VIRGIN)) {
if (attempts > PING_INITIAL) { attempts = PING_INITIAL; }
Map ch = plasmaSwitchboard.getSwitchboard().clusterhashes;
Map<String, String> ch = plasmaSwitchboard.getSwitchboard().clusterhashes;
seeds = seedDB.seedsByAge(true, attempts - ((ch == null) ? 0 : ch.size())); // best for fast connection
// add also all peers from cluster if this is a public robinson cluster
if (plasmaSwitchboard.getSwitchboard().clusterhashes != null) {
Iterator i = ch.entrySet().iterator();
Iterator<Map.Entry<String, String>> i = ch.entrySet().iterator();
String hash;
Map.Entry entry;
Map.Entry<String, String> entry;
yacySeed seed;
while (i.hasNext()) {
entry = (Map.Entry) i.next();
hash = (String) entry.getKey();
entry = i.next();
hash = entry.getKey();
seed = (yacySeed) seeds.get(hash);
if (seed == null) {
seed = seedDB.get(hash);
@ -411,7 +411,7 @@ public class yacyCore {
if (seeds.size() < attempts) { attempts = seeds.size(); }
// This will try to get Peers that are not currently in amIAccessibleDB
Iterator si = seeds.values().iterator();
Iterator<yacySeed> si = seeds.values().iterator();
yacySeed seed;
// include a YaCyNews record to my seed
@ -434,7 +434,7 @@ public class yacyCore {
//if (seeds.length > 1) {
// holding a reference to all started threads
int contactedSeedCount = 0;
final List syncList = Collections.synchronizedList(new LinkedList()); // memory for threads
final List<Thread> syncList = Collections.synchronizedList(new LinkedList<Thread>()); // memory for threads
final serverSemaphore sync = new serverSemaphore(attempts);
// going through the peer list and starting a new publisher thread for each peer
@ -493,7 +493,7 @@ public class yacyCore {
final int dbSize;
synchronized (amIAccessibleDB) {
dbSize = amIAccessibleDB.size();
Iterator ai = amIAccessibleDB.keySet().iterator();
Iterator<String> ai = amIAccessibleDB.keySet().iterator();
while (ai.hasNext()) {
yacyAccessible ya = (yacyAccessible) amIAccessibleDB.get(ai.next());
if (ya.lastUpdated < cutofftime) {
@ -611,9 +611,10 @@ public class yacyCore {
}
}
public static HashMap getSeedUploadMethods() {
@SuppressWarnings("unchecked")
public static HashMap<String, String> getSeedUploadMethods() {
synchronized (yacyCore.seedUploadMethods) {
return (HashMap) yacyCore.seedUploadMethods.clone();
return (HashMap<String, String>) yacyCore.seedUploadMethods.clone();
}
}
@ -627,7 +628,7 @@ public class yacyCore {
if (className == null) { return null; }
try {
final Class uploaderClass = Class.forName(className);
final Class<?> uploaderClass = Class.forName(className);
final Object uploader = uploaderClass.newInstance();
return (yacySeedUploader) uploader;
} catch (Exception e) {
@ -636,7 +637,7 @@ public class yacyCore {
}
public static void loadSeedUploadMethods() {
final HashMap availableUploaders = new HashMap();
final HashMap<String, String> availableUploaders = new HashMap<String, String>();
try {
final String uploadersPkgName = yacyCore.class.getPackage().getName() + ".seedUpload";
final String packageURI = yacyCore.class.getResource("/" + uploadersPkgName.replace('.', '/')).toString();
@ -661,7 +662,7 @@ public class yacyCore {
final String className = uploaderClasses[uploaderNr].substring(0, uploaderClasses[uploaderNr].indexOf(".class"));
final String fullClassName = uploadersPkgName + "." + className;
try {
final Class uploaderClass = Class.forName(fullClassName);
final Class<?> uploaderClass = Class.forName(fullClassName);
final Object theUploader = uploaderClass.newInstance();
if (!(theUploader instanceof yacySeedUploader)) { continue; }
final String[] neededLibx = ((yacySeedUploader)theUploader).getLibxDependencies();

@ -69,6 +69,7 @@ import de.anomic.http.httpc;
import de.anomic.http.httpd;
import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexRWIRowEntry;
import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroDyn;
@ -552,7 +553,7 @@ public final class yacy {
// load words
serverLog.logInfo("GEN-WORDSTAT", "loading words...");
HashMap words = loadWordMap(new File(homePath, "yacy.words"));
HashMap<String, String> words = loadWordMap(new File(homePath, "yacy.words"));
// find all hashes
serverLog.logInfo("GEN-WORDSTAT", "searching all word-hash databases...");
@ -570,10 +571,10 @@ public final class yacy {
// list the hashes in reverse order
serverLog.logInfo("GEN-WORDSTAT", "listing words in reverse size order...");
String w;
Iterator i = hs.scores(false);
Iterator<String> i = hs.scores(false);
while (i.hasNext()) {
h = (String) i.next();
w = (String) words.get(h);
h = i.next();
w = words.get(h);
if (w == null) System.out.print("# " + h); else System.out.print(w);
System.out.println(" - " + hs.getScore(h));
}
@ -607,7 +608,7 @@ public final class yacy {
if (cacheMem < 2048000) throw new OutOfMemoryError("Not enough memory available to start clean up.");
plasmaWordIndex wordIndex = new plasmaWordIndex(indexPrimaryRoot, indexSecondaryRoot, 10000, log);
Iterator indexContainerIterator = wordIndex.wordContainers("AAAAAAAAAAAA", false, false);
Iterator<indexContainer> indexContainerIterator = wordIndex.wordContainers("AAAAAAAAAAAA", false, false);
long urlCounter = 0, wordCounter = 0;
long wordChunkStart = System.currentTimeMillis(), wordChunkEnd = 0;
@ -617,10 +618,10 @@ public final class yacy {
indexContainer wordIdxContainer = null;
try {
wordCounter++;
wordIdxContainer = (indexContainer) indexContainerIterator.next();
wordIdxContainer = indexContainerIterator.next();
// the combined container will fit, read the container
Iterator wordIdxEntries = wordIdxContainer.entries();
Iterator<indexRWIRowEntry> wordIdxEntries = wordIdxContainer.entries();
indexRWIEntry iEntry;
while (wordIdxEntries.hasNext()) {
iEntry = (indexRWIEntry) wordIdxEntries.next();
@ -684,13 +685,13 @@ public final class yacy {
* @param wordlist File where the words are stored.
* @return HashMap with the hash-word - relation.
*/
private static HashMap loadWordMap(File wordlist) {
private static HashMap<String, String> loadWordMap(File wordlist) {
// returns a hash-word - Relation
HashMap wordmap = new HashMap();
HashMap<String, String> wordmap = new HashMap<String, String>();
try {
String word;
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(wordlist)));
while ((word = br.readLine()) != null) wordmap.put(plasmaCondenser.word2hash(word),word);
while ((word = br.readLine()) != null) wordmap.put(plasmaCondenser.word2hash(word), word);
br.close();
} catch (IOException e) {}
return wordmap;
@ -712,7 +713,7 @@ public final class yacy {
serverLog.logConfig("CLEAN-WORDLIST", "START");
String word;
TreeSet wordset = new TreeSet();
TreeSet<String> wordset = new TreeSet<String>();
int count = 0;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(wordlist)));
@ -795,7 +796,7 @@ public final class yacy {
log.logInfo("STARTING CREATION OF RWI-HASHLIST");
File root = new File(homePath);
try {
Iterator indexContainerIterator = null;
Iterator<indexContainer> indexContainerIterator = null;
if (resource.equals("all")) {
WordIndex = new plasmaWordIndex(indexPrimaryRoot, indexSecondaryRoot, 3000, log);
indexContainerIterator = WordIndex.wordContainers(wordChunkStartHash, false, false);
@ -810,7 +811,7 @@ public final class yacy {
bos.putNextEntry(zipEntry);
while (indexContainerIterator.hasNext()) {
counter++;
container = (indexContainer) indexContainerIterator.next();
container = indexContainerIterator.next();
bos.write((container.getWordHash()).getBytes());
bos.write(serverCore.CRLF);
if (counter % 500 == 0) {
@ -825,7 +826,7 @@ public final class yacy {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
while (indexContainerIterator.hasNext()) {
counter++;
container = (indexContainer) indexContainerIterator.next();
container = indexContainerIterator.next();
bos.write((container.getWordHash()).getBytes());
bos.write(serverCore.CRLF);
if (counter % 500 == 0) {
@ -862,7 +863,7 @@ public final class yacy {
kelondroMapObjects.mapIterator it;
it = db.maps(true, false);
while (it.hasNext()) {
Map dna = (Map) it.next();
Map<String, String> dna = it.next();
String peerHash = (String) dna.get("key");
if (peerHash.length() < yacySeedDB.commonHashLength) {
String peerName = (String) dna.get("Name");

Loading…
Cancel
Save