*) Complete Index Transfer

See: http://www.yacy-forum.de/viewtopic.php?p=9622

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@711 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 20 years ago
parent f783061414
commit 3c00c5f6c7

@ -39,7 +39,7 @@
</table></p>
::
<tr class="TableCellLight">
<td>#[status]#</td>
<td><font color="#(stopped)#green::red#(/stopped)#">#[status]#</font></td>
<td align="right">#[twcount]# (#[twpercent]#%) </td>
<td align="rigth"><tt>#[twrange]#</tt></td>
<td>#[peerName]#</td>

@ -69,10 +69,13 @@ public class IndexTransfer_p {
switchboard.indexDistribution.startTransferWholeIndex(seed,true);
} else if (post.containsKey("stopIndexTransfer")) {
switchboard.indexDistribution.stopTransferWholeIndex();
switchboard.indexDistribution.stopTransferWholeIndex(true);
} else if (post.containsKey("newIndexTransfer")) {
switchboard.indexDistribution.abortTransferWholeIndex();
switchboard.indexDistribution.abortTransferWholeIndex(true);
}
prop.put("LOCATION","");
return prop;
}
@ -86,7 +89,7 @@ public class IndexTransfer_p {
int transferedIdxCount = transfThread.getTransferedIndexCount();
prop.put("running_status",transfThread.getStatus());
prop.put("running_twcount",transferedIdxCount);
prop.put("running_twpercent",Float.toString(transferedIdxCount*100/wcount));
prop.put("running_twpercent",Float.toString(transfThread.getTransferedIndexPercent()));
prop.put("running_twrange", transfThread.getRange());
prop.put("running_peerName",transfThread.getSeed().getName());
prop.put("running_stopped",(transfThread.isFinished()) || (!transfThread.isAlive())?1:0);

@ -67,7 +67,7 @@ public class plasmaWordIndexDistribution {
public void close() {
closed = true;
if (transferIdxThread != null) {
stopTransferWholeIndex();
stopTransferWholeIndex(false);
}
}
@ -400,15 +400,20 @@ public class plasmaWordIndexDistribution {
}
}
public void stopTransferWholeIndex() {
if ((transferIdxThread != null) && (!transferIdxThread.isFinished())) {
this.transferIdxThread.stopIt();
public void stopTransferWholeIndex(boolean wait) {
if ((transferIdxThread != null) && (transferIdxThread.isAlive()) && (!transferIdxThread.isFinished())) {
try {
this.transferIdxThread.stopIt(wait);
} catch (InterruptedException e) { }
}
}
public void abortTransferWholeIndex() {
public void abortTransferWholeIndex(boolean wait) {
if (transferIdxThread != null) {
if (!transferIdxThread.isFinished()) this.transferIdxThread.stopIt();
if (!transferIdxThread.isFinished())
try {
this.transferIdxThread.stopIt(wait);
} catch (InterruptedException e) { }
transferIdxThread = null;
}
}
@ -421,19 +426,22 @@ public class plasmaWordIndexDistribution {
private boolean finished = false;
private int transferedIndexCount = 0;
private String status = "running";
private String startPointHash = "------------";
private String oldStartingPointHash = "------------", startPointHash = "------------";
private int wordsDBSize = 0;
public transferIndexThread(yacySeed seed, boolean delete) {
this.seed = seed;
this.delete = delete;
this.wordsDBSize = plasmaSwitchboard.getSwitchboard().wordIndex.size();
}
public void run() {
performTransferWholeIndex();
}
public void stopIt() {
public void stopIt(boolean wait) throws InterruptedException {
this.finished = true;
this.join();
}
public boolean isFinished() {
@ -444,6 +452,11 @@ public class plasmaWordIndexDistribution {
return this.transferedIndexCount;
}
public float getTransferedIndexPercent() {
if (wordsDBSize == 0) return 100;
else return (float)(this.transferedIndexCount*100/wordsDBSize);
}
public yacySeed getSeed() {
return this.seed;
}
@ -453,7 +466,7 @@ public class plasmaWordIndexDistribution {
}
public String getRange() {
return "[------------ .. " + startPointHash + "]";
return "[" + oldStartingPointHash + " .. " + startPointHash + "]";
}
public void performTransferWholeIndex() {
@ -485,6 +498,7 @@ public class plasmaWordIndexDistribution {
}
// find start point for DHT-selection
oldStartingPointHash = startPointHash;
startPointHash = indexEntities[indexEntities.length - 1].wordHash(); // DHT targets must have greater hashes
String error;

Loading…
Cancel
Save