*) 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> </table></p>
:: ::
<tr class="TableCellLight"> <tr class="TableCellLight">
<td>#[status]#</td> <td><font color="#(stopped)#green::red#(/stopped)#">#[status]#</font></td>
<td align="right">#[twcount]# (#[twpercent]#%) </td> <td align="right">#[twcount]# (#[twpercent]#%) </td>
<td align="rigth"><tt>#[twrange]#</tt></td> <td align="rigth"><tt>#[twrange]#</tt></td>
<td>#[peerName]#</td> <td>#[peerName]#</td>

@ -69,10 +69,13 @@ public class IndexTransfer_p {
switchboard.indexDistribution.startTransferWholeIndex(seed,true); switchboard.indexDistribution.startTransferWholeIndex(seed,true);
} else if (post.containsKey("stopIndexTransfer")) { } else if (post.containsKey("stopIndexTransfer")) {
switchboard.indexDistribution.stopTransferWholeIndex(); switchboard.indexDistribution.stopTransferWholeIndex(true);
} else if (post.containsKey("newIndexTransfer")) { } 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(); int transferedIdxCount = transfThread.getTransferedIndexCount();
prop.put("running_status",transfThread.getStatus()); prop.put("running_status",transfThread.getStatus());
prop.put("running_twcount",transferedIdxCount); 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_twrange", transfThread.getRange());
prop.put("running_peerName",transfThread.getSeed().getName()); prop.put("running_peerName",transfThread.getSeed().getName());
prop.put("running_stopped",(transfThread.isFinished()) || (!transfThread.isAlive())?1:0); prop.put("running_stopped",(transfThread.isFinished()) || (!transfThread.isAlive())?1:0);

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

Loading…
Cancel
Save