|
|
@ -6,6 +6,10 @@
|
|
|
|
// Frankfurt, Germany, 2006
|
|
|
|
// Frankfurt, Germany, 2006
|
|
|
|
// created: 18.02.2006
|
|
|
|
// created: 18.02.2006
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
// $LastChangedDate$
|
|
|
|
|
|
|
|
// $LastChangedRevision$
|
|
|
|
|
|
|
|
// $LastChangedBy$
|
|
|
|
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
@ -192,10 +196,11 @@ public class plasmaDHTChunk {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int selectTransferContainersResource(String hash, boolean ram, int maxcount, int maxtime) throws InterruptedException {
|
|
|
|
private int selectTransferContainersResource(String hash, boolean ram, int maxcount, int maxtime) throws InterruptedException {
|
|
|
|
|
|
|
|
if (maxcount > 500) { maxcount = 500; } // flooding & OOM reduce
|
|
|
|
// the hash is a start hash from where the indexes are picked
|
|
|
|
// the hash is a start hash from where the indexes are picked
|
|
|
|
ArrayList tmpContainers = new ArrayList(maxcount);
|
|
|
|
final ArrayList tmpContainers = new ArrayList(maxcount);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Iterator indexContainerIterator = wordIndex.indexContainerSet(hash, ram, true, maxcount).iterator();
|
|
|
|
final Iterator indexContainerIterator = wordIndex.indexContainerSet(hash, ram, true, maxcount).iterator();
|
|
|
|
indexContainer container;
|
|
|
|
indexContainer container;
|
|
|
|
Iterator urlIter;
|
|
|
|
Iterator urlIter;
|
|
|
|
indexRWIEntryNew iEntry;
|
|
|
|
indexRWIEntryNew iEntry;
|
|
|
@ -204,8 +209,8 @@ public class plasmaDHTChunk {
|
|
|
|
int wholesize;
|
|
|
|
int wholesize;
|
|
|
|
|
|
|
|
|
|
|
|
urlCache = new HashMap();
|
|
|
|
urlCache = new HashMap();
|
|
|
|
double maximumDistance = ((double) peerRedundancy * 2) / ((double) yacyCore.seedDB.sizeConnected());
|
|
|
|
final double maximumDistance = ((double) peerRedundancy * 2) / ((double) yacyCore.seedDB.sizeConnected());
|
|
|
|
long timeout = (maxtime < 0) ? Long.MAX_VALUE : System.currentTimeMillis() + maxtime;
|
|
|
|
final long timeout = (maxtime < 0) ? Long.MAX_VALUE : System.currentTimeMillis() + maxtime;
|
|
|
|
while (
|
|
|
|
while (
|
|
|
|
(maxcount > refcount) &&
|
|
|
|
(maxcount > refcount) &&
|
|
|
|
(indexContainerIterator.hasNext()) &&
|
|
|
|
(indexContainerIterator.hasNext()) &&
|
|
|
@ -225,6 +230,9 @@ public class plasmaDHTChunk {
|
|
|
|
urlIter = container.entries();
|
|
|
|
urlIter = container.entries();
|
|
|
|
// iterate over indexes to fetch url entries and store them in the urlCache
|
|
|
|
// iterate over indexes to fetch url entries and store them in the urlCache
|
|
|
|
while ((urlIter.hasNext()) && (maxcount > refcount) && (System.currentTimeMillis() < timeout)) {
|
|
|
|
while ((urlIter.hasNext()) && (maxcount > refcount) && (System.currentTimeMillis() < timeout)) {
|
|
|
|
|
|
|
|
// CPU & IO reduce
|
|
|
|
|
|
|
|
try { Thread.sleep(50); } catch (InterruptedException e) { }
|
|
|
|
|
|
|
|
|
|
|
|
iEntry = (indexRWIEntryNew) urlIter.next();
|
|
|
|
iEntry = (indexRWIEntryNew) urlIter.next();
|
|
|
|
if ((iEntry == null) || (iEntry.urlHash() == null)) {
|
|
|
|
if ((iEntry == null) || (iEntry.urlHash() == null)) {
|
|
|
|
urlIter.remove();
|
|
|
|
urlIter.remove();
|
|
|
@ -267,7 +275,6 @@ public class plasmaDHTChunk {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.status = chunkStatus_FILLED;
|
|
|
|
this.status = chunkStatus_FILLED;
|
|
|
|
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
return refcount;
|
|
|
|
} catch (kelondroException e) {
|
|
|
|
} catch (kelondroException e) {
|
|
|
|
log.logSevere("selectTransferIndexes database corrupted: " + e.getMessage(), e);
|
|
|
|
log.logSevere("selectTransferIndexes database corrupted: " + e.getMessage(), e);
|
|
|
@ -278,7 +285,6 @@ public class plasmaDHTChunk {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public synchronized String deleteTransferIndexes() {
|
|
|
|
public synchronized String deleteTransferIndexes() {
|
|
|
|
Iterator urlIter;
|
|
|
|
Iterator urlIter;
|
|
|
|
indexRWIEntry iEntry;
|
|
|
|
indexRWIEntry iEntry;
|
|
|
|