*) Adding option which allows to do a Index-Transfer without deletion of index

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@722 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 20 years ago
parent 4036ee812a
commit beefddf0e8

@ -16,15 +16,22 @@
<tr class="TableHeader" valign="bottom"> <tr class="TableHeader" valign="bottom">
<td class="small" >Status</td> <td class="small" >Status</td>
<td class="small" >Transfered Words</td> <td class="small" >Transfered Words</td>
<td class="small" >Words Range</td> <td class="small" >Chunk Size: Words Range</td>
<td class="small" >Delete Index</td>
<td class="small" >Remote Peer</td> <td class="small" >Remote Peer</td>
<td class="small" >Start/Stop Transfer</td> <td class="small" >Start/Stop Transfer</td>
</tr> </tr>
#(running)# #(running)#
<tr valign="top" class="TableCellLight"> <tr valign="top" class="TableCellLight">
<td class="small">Not running</td> <td class="small">#[status]#</td>
<td class="small" align="center">-</td> <td class="small" align="center">-</td>
<td class="small" align="center">-</td> <td class="small" align="center">-</td>
<td class="small">
<select name="deleteIndex">
<option value="1">true</option>
<option value="0">false</option>
</select>
</td>
<td class="small"> <td class="small">
<select name="hostHash"> <select name="hostHash">
#{hosts}# #{hosts}#
@ -42,6 +49,7 @@
<td class="small"><font color="#(stopped)#green::red#(/stopped)#">#[status]#</font></td> <td class="small"><font color="#(stopped)#green::red#(/stopped)#">#[status]#</font></td>
<td class="small" align="right">#[twcount]# (#[twpercent]#%) </td> <td class="small" align="right">#[twcount]# (#[twpercent]#%) </td>
<td class="small" align="rigth">#[twchunk]# words: <tt>#[twrange]#</tt></td> <td class="small" align="rigth">#[twchunk]# words: <tt>#[twrange]#</tt></td>
<td class="small">#(deleteIndex)#false::true#(/deleteIndex)#</td>
<td class="small">#[peerName]#</td> <td class="small">#[peerName]#</td>
<td class="small">#(stopped)#<input type="submit" name="stopIndexTransfer" value="Stop Index Transfer">:: <td class="small">#(stopped)#<input type="submit" name="stopIndexTransfer" value="Stop Index Transfer">::
<input type="submit" name="newIndexTransfer" value="Start New Index Transfer">#(/stopped)#</td> <input type="submit" name="newIndexTransfer" value="Start New Index Transfer">#(/stopped)#</td>

@ -67,18 +67,25 @@ public class IndexTransfer_p {
if (post != null) { if (post != null) {
if (post.containsKey("startIndexTransfer")) { if (post.containsKey("startIndexTransfer")) {
yacySeed seed = yacyCore.seedDB.getConnected(post.get("hostHash", "")); yacySeed seed = yacyCore.seedDB.getConnected(post.get("hostHash", ""));
if (seed == null) return prop; if (seed == null) {
prop.put("running_status","Disconnected peer");
switchboard.indexDistribution.startTransferWholeIndex(seed,true); } else {
boolean deleteIndex = ((String)post.get("deleteIndex", "0")).equals("1");
switchboard.indexDistribution.startTransferWholeIndex(seed,deleteIndex);
prop.put("LOCATION","");
return prop;
}
} else if (post.containsKey("stopIndexTransfer")) { } else if (post.containsKey("stopIndexTransfer")) {
switchboard.indexDistribution.stopTransferWholeIndex(true); switchboard.indexDistribution.stopTransferWholeIndex(true);
prop.put("LOCATION","");
return prop;
} else if (post.containsKey("newIndexTransfer")) { } else if (post.containsKey("newIndexTransfer")) {
switchboard.indexDistribution.abortTransferWholeIndex(true); switchboard.indexDistribution.abortTransferWholeIndex(true);
prop.put("LOCATION","");
return prop;
} }
prop.put("LOCATION","");
return prop;
} }
@ -95,8 +102,11 @@ public class IndexTransfer_p {
prop.put("running_twpercent",Float.toString(transfThread.getTransferedIndexPercent())); prop.put("running_twpercent",Float.toString(transfThread.getTransferedIndexPercent()));
prop.put("running_twrange", transfThread.getRange()); prop.put("running_twrange", transfThread.getRange());
prop.put("running_twchunk", Integer.toString(transfThread.getChunkSize())); prop.put("running_twchunk", Integer.toString(transfThread.getChunkSize()));
prop.put("running_deleteIndex", transfThread.deleteIndex()?1:0);
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);
} else {
if (!prop.containsKey("running_status")) prop.put("running_status","Not running");
} }

@ -464,7 +464,7 @@ public class plasmaWordIndexDistribution {
private boolean delete = false; private boolean delete = false;
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 oldStartingPointHash = "------------", startPointHash = "------------"; private String oldStartingPointHash = "------------", startPointHash = "------------";
private int wordsDBSize = 0; private int wordsDBSize = 0;
private int chunkSize = 500; private int chunkSize = 500;
@ -484,11 +484,15 @@ public class plasmaWordIndexDistribution {
this.finished = true; this.finished = true;
this.join(); this.join();
} }
public boolean isFinished() { public boolean isFinished() {
return this.finished; return this.finished;
} }
public boolean deleteIndex() {
return this.delete;
}
public int getChunkSize() { public int getChunkSize() {
return this.chunkSize; return this.chunkSize;
} }
@ -526,19 +530,21 @@ public class plasmaWordIndexDistribution {
* - detected a server shutdown or user interruption * - detected a server shutdown or user interruption
* - detected a failure * - detected a failure
*/ */
long start, retryCount = 0; long start, retryCount = 0, iteration = 0;
while (!finished && !Thread.currentThread().isInterrupted()) { while (!finished && !Thread.currentThread().isInterrupted()) {
iteration++;
int idxCount = 0; int idxCount = 0;
start = System.currentTimeMillis(); start = System.currentTimeMillis();
// selecting 500 words to transfer // selecting 500 words to transfer
this.status = "Running: Selection of chunk " + iteration;
Object[] selectResult = selectTransferIndexes(startPointHash, chunkSize); Object[] selectResult = selectTransferIndexes(startPointHash, chunkSize);
plasmaWordIndexEntity[] indexEntities = (plasmaWordIndexEntity[]) selectResult[0]; plasmaWordIndexEntity[] indexEntities = (plasmaWordIndexEntity[]) selectResult[0];
HashMap urlCache = (HashMap) selectResult[1]; // String (url-hash) / plasmaCrawlLURL.Entry HashMap urlCache = (HashMap) selectResult[1]; // String (url-hash) / plasmaCrawlLURL.Entry
if ((indexEntities == null) || (indexEntities.length == 0)) { if ((indexEntities == null) || (indexEntities.length == 0)) {
plasmaWordIndexDistribution.this.log.logFine("No index available for index transfer, hash start-point " + startPointHash); plasmaWordIndexDistribution.this.log.logFine("No index available for index transfer, hash start-point " + startPointHash);
this.status = "finished."; this.status = "Finished. " + iteration + " chunks transfered.";
return; return;
} }
// count the indexes again, can be smaller as expected // count the indexes again, can be smaller as expected
@ -563,6 +569,7 @@ public class plasmaWordIndexDistribution {
if (isAborted()) return; if (isAborted()) return;
// transfering seleted words to remote peer // transfering seleted words to remote peer
this.status = "Running: Transfer of chunk " + iteration;
String error = yacyClient.transferIndex(seed, indexEntities, urlCache); String error = yacyClient.transferIndex(seed, indexEntities, urlCache);
if (error == null) { if (error == null) {
// words successfully transfered // words successfully transfered
@ -625,6 +632,7 @@ public class plasmaWordIndexDistribution {
// deleting transfered words from index // deleting transfered words from index
if (delete) { if (delete) {
this.status = "Running: Deletion of chunk " + iteration;
try { try {
if (deleteTransferIndexes(indexEntities)) { if (deleteTransferIndexes(indexEntities)) {
plasmaWordIndexDistribution.this.log.logFine("Deleted all " + indexEntities.length + " transferred whole-word indexes locally"); plasmaWordIndexDistribution.this.log.logFine("Deleted all " + indexEntities.length + " transferred whole-word indexes locally");

Loading…
Cancel
Save