Author: jflesch
Date: 2006-07-14 23:58:21 +0000 (Fri, 14 Jul 2006)
New Revision: 9619
Modified:
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/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
Log:
Add a progress bar to show transfer progressions between Thaw and the node
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-07-14 23:37:51 UTC
(rev 9618)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-07-14 23:58:21 UTC
(rev 9619)
@@ -33,6 +33,7 @@
private String identifier;
private int progress; /* in pourcent */
+ private int fromTheNodeProgress = 0; /* I'm not sure that it's correct
english ... */
private boolean progressReliable = false;
private long fileSize;
@@ -51,6 +52,7 @@
setParameters(parameters);
progressReliable = false;
+ fromTheNodeProgress = 0;
/* If isPersistent(), then start() won't be called, so must
relisten the
queryManager by ourself */
@@ -58,7 +60,7 @@
this.queueManager.getQueryManager().deleteObserver(this);
this.queueManager.getQueryManager().addObserver(this);
}
-
+
}
@@ -83,6 +85,11 @@
successful = true;
running = true;
+
+ if(progress < 100)
+ fromTheNodeProgress = 0;
+ else
+ fromTheNodeProgress = 100;
}
@@ -101,8 +108,8 @@
globalQueue = false; /* else protocol error */
progressReliable = false;
+ fromTheNodeProgress = 0;
-
this.key = key;
this.priority = priority;
this.persistence = persistence;
@@ -404,7 +411,7 @@
}
public synchronized boolean saveFileTo(String dir) {
-
+ fromTheNodeProgress = 0;
if(dir == null) {
Logger.warning(this, "saveFileTo() : Can't save to
null.");
return false;
@@ -495,7 +502,11 @@
}
/* size == bytes remaining on socket */
+ long origSize = size;
+ long startTime = System.currentTimeMillis();
+
while(size > 0) {
+
int packet = PACKET_SIZE;
byte[] read;
int amount;
@@ -525,8 +536,17 @@
size = size - amount;
+ if( System.currentTimeMillis() >= (startTime+1000)) {
+ fromTheNodeProgress = (int) (((origSize-size) *
100) / origSize);
+ setChanged();
+ notifyObservers();
+ startTime = System.currentTimeMillis();
+ }
+
}
+ fromTheNodeProgress = 100;
+
if(reallyWrite) {
try {
fileWriter.close();
@@ -738,4 +758,8 @@
public boolean isGlobal() {
return globalQueue;
}
+
+ public int getTransferWithTheNodeProgression() {
+ return fromTheNodeProgress;
+ }
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-07-14 23:37:51 UTC
(rev 9618)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-07-14 23:58:21 UTC
(rev 9619)
@@ -26,6 +26,7 @@
private int persistence = 2;
private int progress = 0;
+ private int toTheNodeProgress = 0;
private String status = null;
private int attempt = 0;
@@ -101,6 +102,8 @@
int priority, int persistence, boolean global,
String srcFile, String status, int progress,
FCPQueueManager queueManager) {
+ toTheNodeProgress = 100;
+
this.queueManager = queueManager;
this.identifier = identifier;
@@ -222,6 +225,8 @@
public boolean startInsert() {
FCPConnection connection =
queueManager.getQueryManager().getConnection();
+ toTheNodeProgress= 0;
+
status = "Waiting socket availability";
Logger.info(this, "Another file is being uploaded ... waiting
...");
@@ -323,8 +328,10 @@
Logger.error(this, "FileNotFoundException ?! ohoh,
problems ...");
return false;
}
-
+ long startTime = System.currentTimeMillis();
+ long origSize = remaining;
+
while(remaining > 0) {
int to_read = PACKET_SIZE;
@@ -350,9 +357,19 @@
remaining = remaining - to_read;
+ if( System.currentTimeMillis() >= (startTime+1000) ) {
+ toTheNodeProgress = (int) (((origSize -
remaining) * 100) / origSize);
+ setChanged();
+ notifyObservers();
+ startTime = System.currentTimeMillis();
+ }
+
//Logger.verbose(this, "Remaining: "+(new
Long(remaining)).toString());
}
+
+ toTheNodeProgress = 100;
+
try {
if(in.available() > 0) {
Logger.error(this, "File not send completly
?!");
@@ -769,4 +786,8 @@
public boolean saveFileTo(String dir) {
return false;
}
+
+ public int getTransferWithTheNodeProgression() {
+ return toTheNodeProgress;
+ }
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java 2006-07-14 23:37:51 UTC
(rev 9618)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java 2006-07-14 23:58:21 UTC
(rev 9619)
@@ -6,7 +6,7 @@
* Transfer query == fetch / insert query. These queries must be able to
* give more informations than the other.
* Functions returning status of the request may be call frequently, so try to
make them fast.
- *
+ * Some methods are only useful for downloads, and some for insertions, so
check getQueryType() before calling them.
*/
public interface FCPTransferQuery extends FCPQuery {
@@ -49,13 +49,19 @@
/**
* Informal.
+ * Is about the transfer on the network.
* In pourcents.
*/
public int getProgression();
public boolean isProgressionReliable();
+ /**
+ * Is about the transfer between the node and thaw.
+ */
+ public int getTransferWithTheNodeProgression();
+
/**
* Informal.
* Gives *public* final key only.
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-07-14 23:37:51 UTC
(rev 9618)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-07-14 23:58:21 UTC
(rev 9619)
@@ -19,6 +19,7 @@
thaw.common.file=File
thaw.common.progress=Progress
+thaw.common.withTheNodeProgress=Thaw <-> Node
thaw.common.size=Size
thaw.common.localPath=Local path
Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
2006-07-14 23:37:51 UTC (rev 9618)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
2006-07-14 23:58:21 UTC (rev 9619)
@@ -31,6 +31,7 @@
private JTextField file = new JTextField();
private JTextField size = new JTextField();
private JProgressBar progress = new JProgressBar(0, 100);
+ private JProgressBar withTheNodeProgress = new JProgressBar(0, 100);
private JTextField status = new JTextField();
private JTextField key = new JTextField();
private JTextField path = new JTextField();
@@ -42,7 +43,7 @@
private FCPTransferQuery query = null;
- private final static Dimension dim = new Dimension(300, 375);
+ private final static Dimension dim = new Dimension(300, 400);
public DetailPanel(Core core) {
@@ -54,6 +55,7 @@
String[] fieldNames = { I18n.getMessage("thaw.common.file"),
I18n.getMessage("thaw.common.size"),
I18n.getMessage("thaw.common.progress"),
+
I18n.getMessage("thaw.common.withTheNodeProgress"),
I18n.getMessage("thaw.common.status"),
I18n.getMessage("thaw.common.key"),
I18n.getMessage("thaw.common.localPath"),
@@ -81,13 +83,18 @@
progress.setString("");
progress.setStringPainted(true);
break;
- case(3): field = status;
status.setEditable(false); break;
- case(4): field = key;
key.setEditable(false);break;
- case(5): field = path; path.setEditable(false);
break;
- case(6): field = priority;
priority.setEditable(false); break;
- case(7): field = attempt;
attempt.setEditable(false); break;
- case(8): field = identifier;
identifier.setEditable(false); break;
- case(9): field = globalQueue;
globalQueue.setEditable(false); break;
+ case(3):
+ field = withTheNodeProgress;
+ withTheNodeProgress.setString("");
+
withTheNodeProgress.setStringPainted(true);
+ break;
+ case(4): field = status;
status.setEditable(false); break;
+ case(5): field = key;
key.setEditable(false);break;
+ case(6): field = path; path.setEditable(false);
break;
+ case(7): field = priority;
priority.setEditable(false); break;
+ case(8): field = attempt;
attempt.setEditable(false); break;
+ case(9): field = identifier;
identifier.setEditable(false); break;
+ case(10): field = globalQueue;
globalQueue.setEditable(false); break;
default: Logger.error(this, "Gouli goula ? ...
is going to crash :p"); break;
}
@@ -127,10 +134,10 @@
public void refresh() {
if(query != null) {
+ withTheNodeProgress.setValue((new
Integer(query.getTransferWithTheNodeProgression())).intValue());
+ withTheNodeProgress.setString((new
Integer(query.getTransferWithTheNodeProgression())).toString() + "%");
+
progress.setValue(query.getProgression());
-
-
-
if(!query.isFinished() || query.isSuccessful()) {
String progression = (new
Integer(query.getProgression())).toString() + "%";
@@ -164,6 +171,8 @@
priority.setText(I18n.getMessage("thaw.common.unknown"));
} else {
+ withTheNodeProgress.setValue(0);
+ withTheNodeProgress.setString("");
progress.setValue(0);
progress.setString("");
status.setText("");