Author: jflesch
Date: 2007-11-29 19:54:55 +0000 (Thu, 29 Nov 2007)
New Revision: 16103
Modified:
trunk/apps/Thaw/src/thaw/core/ThawThread.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java
trunk/apps/Thaw/src/thaw/gui/GUIHelper.java
trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
Log:
The plugin QueueWatcher can now display the average speed and the ETA of each
transfer
Modified: trunk/apps/Thaw/src/thaw/core/ThawThread.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ThawThread.java 2007-11-29 19:49:37 UTC
(rev 16102)
+++ trunk/apps/Thaw/src/thaw/core/ThawThread.java 2007-11-29 19:54:55 UTC
(rev 16103)
@@ -85,9 +85,15 @@
ThawThread th = (ThawThread)it.next();
if (th != null) {
- Logger.info(null,
- "'"+th.getName()+"' "+
- "(parent:
'"+th.getParent().getClass().getName()+"')");
+ if (th.getParent() != null) {
+ Logger.info(null,
+
"'"+th.getName()+"' "+
+ "(parent:
'"+th.getParent().getClass().getName()+"')");
+ } else {
+ Logger.info(null,
+
"'"+th.getName()+"' "+
+ "(parent:
unknown)");
+ }
}
}
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-11-29 19:49:37 UTC
(rev 16102)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-11-29 19:54:55 UTC
(rev 16103)
@@ -24,7 +24,7 @@
private int maxRetries = -1;
private final static int PACKET_SIZE = 65536;
- private final static int BLOCK_SIZE = 16384;
+ public final static int BLOCK_SIZE = 16384;
private FCPQueueManager queueManager;
private FCPQueryManager duplicatedQueryManager;
@@ -44,7 +44,8 @@
private String identifier;
- private int progress; /* in pourcent */
+ private int progress = 0; /* in pourcent */
+ private long transferedBlocks = 0;
private int fromTheNodeProgress = 0;
private boolean progressReliable = false;
private long fileSize;
@@ -56,6 +57,11 @@
private boolean fatal = true;
private boolean isLockOwner = false;
+ private long initialStart = -1; /* set at first SimpleProgress message
*/
+ private long initialBlockNumber = -1;
+ private long averageSpeed = 0; /* computed at each SimpleProgress
message */
+ private long eta = 0;
+
private boolean alreadySaved = false;
private boolean noDDA = false;
@@ -110,6 +116,7 @@
this.queueManager = queueManager;
this.progress = progress;
+ this.transferedBlocks = 0;
this.status = status;
if(status == null) {
@@ -186,6 +193,7 @@
this.destinationDir = destinationDir;
progress = 0;
+ transferedBlocks = 0;
fileSize = 0;
attempt = 0;
@@ -241,6 +249,7 @@
attempt++;
running = true;
progress = 0;
+ transferedBlocks = 0;
this.queueManager = queueManager;
@@ -531,13 +540,16 @@
progress = 0;
- if((message.getValue("Total") != null)
- && (message.getValue("Succeeded") != null)) {
+ if (message.getValue("Total") != null
+ && message.getValue("Required") != null
+ && message.getValue("Succeeded") !=
null) {
fileSize =
Long.parseLong(message.getValue("Total"))*FCPClientGet.BLOCK_SIZE;
- final long required =
Long.parseLong(message.getValue("Total"));
+ final long total =
Long.parseLong(message.getValue("Total"));
+ final long required =
Long.parseLong(message.getValue("Required"));
final long succeeded =
Long.parseLong(message.getValue("Succeeded"));
- progress = (int) ((long)((succeeded * 98) /
required));
+ progress = (int) ((long)((succeeded * 98) /
total));
+ transferedBlocks = succeeded;
status = "Fetching";
@@ -548,6 +560,33 @@
successful = true;
running = true;
+
+ /* computing average speed & ETA */
+ long timeElapsed = 0;
+ long blocks = 0;
+
+ if (initialStart < 0) {
+ /* first simple progress message */
+ initialStart = (new
java.util.Date()).getTime();
+ initialBlockNumber = transferedBlocks;
+ }
+
+ if (initialStart > 0) {
+ timeElapsed = (new
java.util.Date()).getTime() - initialStart;
+ blocks = transferedBlocks -
initialBlockNumber;
+ }
+
+ if (blocks != 0 && timeElapsed != 0) {
+ averageSpeed = (blocks *
FCPClientGet.BLOCK_SIZE * 1000) / timeElapsed;
+ } else {
+ averageSpeed = 0; /* == unknown */
+ }
+
+ if (succeeded >= required || averageSpeed <= 0)
+ eta = 0; /* unknown */
+ else {
+ eta = ((required - succeeded) *
BLOCK_SIZE) / averageSpeed;
+ }
}
setChanged();
@@ -1016,6 +1055,15 @@
public int getProgression() {
return progress;
}
+
+
+ public long getAverageSpeed() {
+ return averageSpeed;
+ }
+
+ public long getETA() {
+ return eta;
+ }
public boolean isProgressionReliable() {
if((progress == 0) || (progress >= 99))
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2007-11-29 19:49:37 UTC
(rev 16102)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2007-11-29 19:54:55 UTC
(rev 16103)
@@ -44,6 +44,7 @@
private boolean getCHKOnly = false;
private int progress = 0;
+ private long transferedBlocks = 0;
private int toTheNodeProgress = 0;
private String status;
@@ -56,6 +57,11 @@
private boolean fatal = true;
private boolean sending = false;
+ private long initialStart = -1; /* set at the first SimpleProgress
message */
+ private long initialBlockNumber = -1;
+ private long averageSpeed = 0; /* recomputed at each simple progress
message */
+ private long eta = 0;
+
private FCPGenerateSSK sskGenerator;
private boolean lockOwner = false;
@@ -65,7 +71,6 @@
private SHA256Computer sha;
-
private int putFailedCode = -1;
/**
@@ -128,6 +133,7 @@
this.persistence = persistence;
status = "Waiting";
progress = 0;
+ transferedBlocks = 0;
attempt = 0;
identifier = null;
@@ -180,6 +186,7 @@
this.persistence = persistence;
this.progress = progress;
+ this.transferedBlocks = 0;
this.status = status;
running = true;
@@ -214,6 +221,7 @@
queueManager.getQueryManager().addObserver(this);
progress = 0;
+ transferedBlocks = 0;
finished = false;
successful = false;
running = true;
@@ -433,11 +441,13 @@
lockOwner = false;
sending = false;
+ progress = 0;
+ transferedBlocks = 0;
+
if(ret == true) {
successful = false;
fatal = true;
finished = false;
- progress = 0;
running = true;
if (!getCHKOnly)
@@ -452,7 +462,6 @@
} else {
successful = false;
finished = true;
- progress = 0;
running = false;
status = "Unable to send the file to the node";
@@ -799,13 +808,38 @@
final long succeeded = (new
Long(msg.getValue("Succeeded"))).longValue();
progress = (int)((succeeded * 99) /
total);
+ transferedBlocks = succeeded;
running = true;
finished = false;
successful = false;
+
+ /* computing average speed & ETA */
+ long timeElapsed = 0;
+ long blocks = 0;
+
+ if (initialStart < 0) {
+ /* first simple progress
message */
+ initialStart = (new
java.util.Date()).getTime();
+ initialBlockNumber =
transferedBlocks;
+ }
+
+ if (initialStart > 0) {
+ timeElapsed = (new
java.util.Date()).getTime() - initialStart;
+ blocks = transferedBlocks -
initialBlockNumber;
+ }
+
+ if (blocks != 0 && timeElapsed != 0) {
+ averageSpeed = (blocks *
FCPClientGet.BLOCK_SIZE * 1000) / timeElapsed;
+ } else {
+ averageSpeed = 0; /* == unknown
*/
+ }
- //if(fileSize == 0)
- // fileSize = BLOCK_SIZE *
required; // NOT RELIABLE
+ if (succeeded >= total || averageSpeed
<= 0)
+ eta = 0; /* unknown */
+ else {
+ eta = ((total - succeeded) *
FCPClientGet.BLOCK_SIZE) / averageSpeed;
+ }
if (!getCHKOnly)
status = "Inserting";
@@ -925,6 +959,14 @@
return progress;
}
+ public long getAverageSpeed() {
+ return averageSpeed;
+ }
+
+ public long getETA() {
+ return eta;
+ }
+
public boolean isProgressionReliable() {
return true;
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java 2007-11-29 19:49:37 UTC
(rev 16102)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java 2007-11-29 19:54:55 UTC
(rev 16103)
@@ -89,6 +89,15 @@
*/
public int getTransferWithTheNodeProgression();
+ /**
+ * @return in bytes / s (0 = unknown)
+ */
+ public long getAverageSpeed();
+
+ /**
+ * @return in second
+ */
+ public long getETA();
/**
* Informal.
Modified: trunk/apps/Thaw/src/thaw/gui/GUIHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/gui/GUIHelper.java 2007-11-29 19:49:37 UTC (rev
16102)
+++ trunk/apps/Thaw/src/thaw/gui/GUIHelper.java 2007-11-29 19:54:55 UTC (rev
16103)
@@ -80,7 +80,7 @@
if (seconds < 3600) {
final long min = seconds / 60;
- return ((new Long(min)).toString() + " min");
+ return ((new Long(min)).toString() + " m");
}
if (seconds < 86400) {
Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-11-29
19:49:37 UTC (rev 16102)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-11-29
19:54:55 UTC (rev 16103)
@@ -31,6 +31,8 @@
thaw.common.file=Fichier
thaw.common.files=Fichiers
thaw.common.progress=Progression
+thaw.common.speed=Vitesse
+thaw.common.eta=ETA
thaw.common.withTheNodeProgress=Thaw <-> Noeud
thaw.common.size=Taille
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-11-29 19:49:37 UTC
(rev 16102)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-11-29 19:54:55 UTC
(rev 16103)
@@ -33,6 +33,8 @@
thaw.common.file=File
thaw.common.files=Files
thaw.common.progress=Progress
+thaw.common.speed=Speed
+thaw.common.eta=ETA
thaw.common.withTheNodeProgress=Thaw <-> Node
thaw.common.size=Size
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-11-29 19:49:37 UTC
(rev 16102)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-11-29 19:54:55 UTC
(rev 16103)
@@ -31,6 +31,8 @@
thaw.common.file=Fichier
thaw.common.files=Fichiers
thaw.common.progress=Progression
+thaw.common.speed=Vitesse
+thaw.common.eta=ETA
thaw.common.withTheNodeProgress=Thaw <-> Noeud
thaw.common.size=Taille
Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
2007-11-29 19:49:37 UTC (rev 16102)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
2007-11-29 19:54:55 UTC (rev 16103)
@@ -21,6 +21,7 @@
import thaw.fcp.FCPClientGet;
import thaw.fcp.FCPClientPut;
import thaw.gui.IconBox;
+import thaw.gui.GUIHelper;
import thaw.core.PluginManager;
import thaw.plugins.TrayIcon;
@@ -61,6 +62,8 @@
columnNames.add(I18n.getMessage("thaw.common.status"));
columnNames.add(I18n.getMessage("thaw.common.progress"));
+ columnNames.add(I18n.getMessage("thaw.common.speed"));
+ columnNames.add(I18n.getMessage("thaw.common.eta"));
resetTable();
@@ -107,6 +110,7 @@
final FCPTransferQuery query =
(FCPTransferQuery)queries.get(row);
if (column == 0) {
+
if(query == null)
return null;
@@ -125,36 +129,61 @@
return IconBox.minOrange;
return " ";
- }
+ } else if(column == 1) {
- if(column == 1) {
String filename = query.getFilename();
if (filename == null)
return "(null)";
return filename;
- }
- if(column == 2)
+ } else if(column == 2) {
+
return
thaw.gui.GUIHelper.getPrintableSize(query.getFileSize());
- if(!isForInsertions && (column == 3)) {
+ } else if(!isForInsertions && (column == 3)) {
if(query.getPath() != null)
return query.getPath();
else
return
I18n.getMessage("thaw.common.unspecified");
- }
- if( (isForInsertions && (column == 3))
- || (!isForInsertions && (column == 4)) )
+ } else if( (isForInsertions && (column == 3))
+ || (!isForInsertions && (column == 4)) ) {
+
return query.getStatus();
+
+ } else if( ((isForInsertions && (column == 4))
+ || (!isForInsertions && (column == 5)) ) ) {
- if( ((isForInsertions && (column == 4))
- || (!isForInsertions && (column == 5)) ) ) {
+ return query;
- return query;
+ } else if( ((isForInsertions && (column == 5))
+ || (!isForInsertions && (column == 6)) ) ) {
+
+ if (query.isFinished())
+ return "";
+
+ long averageSpeed = query.getAverageSpeed();
+
+ if (averageSpeed <= 0)
+ return "";
+
+ return GUIHelper.getPrintableSize(averageSpeed) + "/s";
+
+ } else if( ((isForInsertions && (column == 6))
+ || (!isForInsertions && (column == 7)) ) ) {
+
+ if (query.isFinished() ||
!query.isProgressionReliable())
+ return "";
+
+ long remaining = query.getETA();
+
+ if (remaining <= 0)
+ return "";
+
+ return GUIHelper.getPrintableTime(remaining);
}
return null;
@@ -451,55 +480,75 @@
if(column == 0) { /* File name */
if(q1.getFilename() == null)
- return -1;
+ result = -1;
+ else if(q2.getFilename() == null)
+ result = 1;
+ else
+ result =
q1.getFilename().compareTo(q2.getFilename());
- if(q2.getFilename() == null)
- return 1;
+ } else if(column == 1) { /* Size */
- result =
q1.getFilename().compareTo(q2.getFilename());
- }
-
- if(column == 1) { /* Size */
result = (new
Long(q1.getFileSize())).compareTo(new Long(q2.getFileSize()));
- }
- if( ((column == 2) && !isForInsertionTable) ) { /*
localPath */
+ } else if( ((column == 2) && !isForInsertionTable) ) {
/* localPath */
+
if(q1.getPath() == null)
- return -1;
+ result = -1;
+ else if(q2.getPath() == null)
+ result = 1;
+ else
+ result =
q1.getPath().compareTo(q2.getPath());
- if(q2.getPath() == null)
- return 1;
+ } else if( ((column == 2) && isForInsertionTable)
+ || ((column == 3) &&
!isForInsertionTable) ) { /* status */
- result = q1.getPath().compareTo(q2.getPath());
- }
+ if(q1.getStatus() == null)
+ result = -1;
+ else if(q2.getStatus() == null)
+ result = 1;
+ else
+ result =
q1.getStatus().compareTo(q2.getStatus());
- if( ((column == 2) && isForInsertionTable)
- || ((column == 3) && !isForInsertionTable) ) { /*
status */
+ } else if( ((column == 3) && isForInsertionTable)
+ || ((column == 4) &&
!isForInsertionTable) ) { /* progress */
+ boolean b = false;
+
+ if((q1.getProgression() <= 0)
+ && (q2.getProgression() <= 0)) {
+
+ if(q1.isRunning() && !q2.isRunning()) {
+ result = 1;
+ b = true;
+ } else if(q2.isRunning() &&
!q1.isRunning()) {
+ result = -1;
+ b = true;
+ }
+ }
- if(q1.getStatus() == null)
- return -1;
+ if (!b)
+ result = (new
Integer(q1.getProgression())).compareTo(new Integer(q2.getProgression()));
- if(q2.getStatus() == null)
- return 1;
+ } else if( ((column == 4) && isForInsertionTable)
+ || ((column == 5) &&
!isForInsertionTable) ) { /* progress */
- result =
q1.getStatus().compareTo(q2.getStatus());
- }
+ result = (new
Long(q1.getAverageSpeed())).compareTo(new Long(q2.getAverageSpeed()));
- if( ((column == 3) && isForInsertionTable)
- || ((column == 4) && !isForInsertionTable) ) { /*
progress */
- if((q1.getProgression() <= 0)
- && (q2.getProgression() <= 0)) {
- if(q1.isRunning() && !q2.isRunning())
- return 1;
+ } else if( ((column == 5) && isForInsertionTable)
+ || ((column == 6) &&
!isForInsertionTable) ) { /* progress */
+
+ if (q1.isFinished() && !q2.isFinished())
+ result = 1;
+ else if (!q1.isFinished() && q2.isFinished())
+ result = -1;
+ else if (q1.getETA() > 0 && q2.getETA() <= 0)
+ result = 1;
+ else if (q1.getETA() <= 0 && q2.getETA() > 0)
+ result = -1;
- if(q2.isRunning() && !q1.isRunning())
- return -1;
- }
+ result = (new Long(q1.getETA())).compareTo(new
Long(q2.getETA()));
- result = (new
Integer(q1.getProgression())).compareTo(new Integer(q2.getProgression()));
}
-
if (!isSortedAsc)
result = -result;