diff --git a/htroot/IndexTransfer_p.html b/htroot/IndexTransfer_p.html index 439aed536..548347eb7 100644 --- a/htroot/IndexTransfer_p.html +++ b/htroot/IndexTransfer_p.html @@ -16,15 +16,22 @@ Status Transfered Words -Words Range +Chunk Size: Words Range +Delete Index Remote Peer Start/Stop Transfer #(running)# -Not running +#[status]# - - + + + :: #(/stopped)# diff --git a/htroot/IndexTransfer_p.java b/htroot/IndexTransfer_p.java index 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.java index 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.Entry if ((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 index if (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");