Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) Adding option which allows to do a Index-Transfer without deletion of index
thelibeefddf0e89c
diff --git a/htroot/IndexTransfer_p.html b/htroot/IndexTransfer_p.htmlindex 439aed536..548347eb7 100644--- a/htroot/IndexTransfer_p.html+++ b/htroot/IndexTransfer_p.html@@ -16,15 +16,22 @@<tr class="TableHeader" valign="bottom"><td class="small" >Status</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" >Start/Stop Transfer</td></tr>#(running)#<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">+ <select name="deleteIndex">+ <option value="1">true</option>+ <option value="0">false</option>+ </select>+</td><td class="small"><select name="hostHash">#{hosts}#@@ -42,6 +49,7 @@<td class="small"><font color="#(stopped)#green::red#(/stopped)#">#[status]#</font></td><td class="small" align="right">#[twcount]# (#[twpercent]#%) </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">#(stopped)#<input type="submit" name="stopIndexTransfer" value="Stop Index Transfer">::<input type="submit" name="newIndexTransfer" value="Start New Index Transfer">#(/stopped)#</td>diff --git a/htroot/IndexTransfer_p.java b/htroot/IndexTransfer_p.javaindex 7b9f261f5..34a160bf4 100644--- a/htroot/IndexTransfer_p.java+++ b/htroot/IndexTransfer_p.java@@ -67,18 +67,25 @@ public class IndexTransfer_p {if (post != null) {if (post.containsKey("startIndexTransfer")) {- yacySeed seed = yacyCore.seedDB.getConnected(post.get("hostHash", ""));- if (seed == null) return prop;-- switchboard.indexDistribution.startTransferWholeIndex(seed,true);+ yacySeed seed = yacyCore.seedDB.getConnected(post.get("hostHash", ""));+ if (seed == null) {+ prop.put("running_status","Disconnected peer");+ } 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")) {switchboard.indexDistribution.stopTransferWholeIndex(true);+ prop.put("LOCATION","");+ return prop;} else if (post.containsKey("newIndexTransfer")) {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_twrange", transfThread.getRange());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_stopped",(transfThread.isFinished()) || (!transfThread.isAlive())?1:0);+ } else {+ if (!prop.containsKey("running_status")) prop.put("running_status","Not running");}diff --git a/source/de/anomic/plasma/plasmaWordIndexDistribution.java b/source/de/anomic/plasma/plasmaWordIndexDistribution.javaindex add29070b..d247076ee 100644--- a/source/de/anomic/plasma/plasmaWordIndexDistribution.java+++ b/source/de/anomic/plasma/plasmaWordIndexDistribution.java@@ -464,7 +464,7 @@ public class plasmaWordIndexDistribution {private boolean delete = false;private boolean finished = false;private int transferedIndexCount = 0;- private String status = "running";+ private String status = "Running";private String oldStartingPointHash = "------------", startPointHash = "------------";private int wordsDBSize = 0;private int chunkSize = 500;@@ -484,11 +484,15 @@ public class plasmaWordIndexDistribution {this.finished = true;this.join();}-+public boolean isFinished() {return this.finished;}+ public boolean deleteIndex() {+ return this.delete;+ }+public int getChunkSize() {return this.chunkSize;}@@ -526,19 +530,21 @@ public class plasmaWordIndexDistribution {* - detected a server shutdown or user interruption* - detected a failure*/- long start, retryCount = 0;+ long start, retryCount = 0, iteration = 0;while (!finished && !Thread.currentThread().isInterrupted()) {+ iteration++;int idxCount = 0;start = System.currentTimeMillis();// selecting 500 words to transfer+ this.status = "Running: Selection of chunk " + iteration;Object[] selectResult = selectTransferIndexes(startPointHash, chunkSize);plasmaWordIndexEntity[] indexEntities = (plasmaWordIndexEntity[]) selectResult[0];HashMap urlCache = (HashMap) selectResult[1]; // String (url-hash) / plasmaCrawlLURL.Entryif ((indexEntities == null) || (indexEntities.length == 0)) {plasmaWordIndexDistribution.this.log.logFine("No index available for index transfer, hash start-point " + startPointHash);- this.status = "finished.";+ this.status = "Finished. " + iteration + " chunks transfered.";return;}// count the indexes again, can be smaller as expected@@ -563,6 +569,7 @@ public class plasmaWordIndexDistribution {if (isAborted()) return;// transfering seleted words to remote peer+ this.status = "Running: Transfer of chunk " + iteration;String error = yacyClient.transferIndex(seed, indexEntities, urlCache);if (error == null) {// words successfully transfered@@ -625,6 +632,7 @@ public class plasmaWordIndexDistribution {// deleting transfered words from indexif (delete) {+ this.status = "Running: Deletion of chunk " + iteration;try {if (deleteTransferIndexes(indexEntities)) {plasmaWordIndexDistribution.this.log.logFine("Deleted all " + indexEntities.length + " transferred whole-word indexes locally");