Author: jflesch
Date: 2006-07-16 16:22:45 +0000 (Sun, 16 Jul 2006)
New Revision: 9631
Modified:
trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientHello.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
trunk/apps/Thaw/src/thaw/fcp/FCPListPersistentRequests.java
trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java
trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
Log:
Fixing insertions cancelation
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-07-16 15:49:09 UTC
(rev 9630)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-07-16 16:22:45 UTC
(rev 9631)
@@ -542,7 +542,7 @@
size = size - amount;
- if( System.currentTimeMillis() >= (startTime+1000)) {
+ if( System.currentTimeMillis() >= (startTime+3000)) {
fromTheNodeProgress = (int) (((origSize-size) *
100) / origSize);
setChanged();
notifyObservers();
@@ -613,12 +613,13 @@
public boolean stop(FCPQueueManager queryManager) {
Logger.info(this, "Stop fetching of the key : "+getFileKey());
- removeRequest();
+ if(!removeRequest()) {
+ return false;
+ }
progress = 100;
successful = false;
status = "Stopped";
-
setChanged();
notifyObservers();
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientHello.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientHello.java 2006-07-16 15:49:09 UTC
(rev 9630)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientHello.java 2006-07-16 16:22:45 UTC
(rev 9631)
@@ -141,7 +141,7 @@
* Not used.
*/
public boolean stop(FCPQueueManager queueManager) {
- return false;
+ return true;
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-07-16 15:49:09 UTC
(rev 9630)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-07-16 16:22:45 UTC
(rev 9631)
@@ -37,7 +37,7 @@
private boolean running = false;
private boolean finished = false;
private boolean successful = false;
-
+ private boolean sending = false;
private FCPGenerateSSK sskGenerator = null;
@@ -241,6 +241,7 @@
public boolean continueInsert() {
running = true; /* Here we are really running */
+ sending = true;
FCPConnection connection =
queueManager.getQueryManager().getConnection();
@@ -288,6 +289,7 @@
Logger.info(this, "File sent (or not)");
connection.unlockWriting();
+ sending = false;
if(ret == true) {
successful = false;
@@ -360,7 +362,7 @@
remaining = remaining - to_read;
- if( System.currentTimeMillis() >= (startTime+1000) ) {
+ if( System.currentTimeMillis() >= (startTime+3000) ) {
toTheNodeProgress = (int) (((origSize -
remaining) * 100) / origSize);
setChanged();
notifyObservers();
@@ -387,9 +389,8 @@
}
public boolean stop(FCPQueueManager queueManager) {
- status = "Stopped";
-
if(removeRequest()) {
+ status = "Stopped";
finished = true;
successful = false;
running = false;
@@ -606,6 +607,14 @@
setChanged();
notifyObservers();
+ if(sending) {
+ Logger.notice(this, "Can't interrupt while sending to
the node ...");
+ status = status + " (can't interrupt while sending to
the node)";
+ setChanged();
+ notifyObservers();
+ return false;
+ }
+
if(isRunning() || isFinished()) {
FCPMessage msg = new FCPMessage();
msg.setMessageName("RemovePersistentRequest");
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java 2006-07-16 15:49:09 UTC
(rev 9630)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java 2006-07-16 16:22:45 UTC
(rev 9631)
@@ -176,7 +176,12 @@
* Doesn't check the lock state ! You have to manage it yourself.
*/
public boolean rawWrite(byte[] data) {
- return bufferedOut.write(data);
+ if(bufferedOut != null)
+ return bufferedOut.write(data);
+ else {
+ Logger.notice(this, "rawWrite(), bufferedOut == null ?
Socket closed ?");
+ return false;
+ }
}
/**
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPListPersistentRequests.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPListPersistentRequests.java 2006-07-16
15:49:09 UTC (rev 9630)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPListPersistentRequests.java 2006-07-16
16:22:45 UTC (rev 9631)
@@ -17,8 +17,7 @@
}
public boolean stop(FCPQueueManager queueManager) {
-
- return false;
+ return true;
}
public int getQueryType() {
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java 2006-07-16 15:49:09 UTC (rev
9630)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java 2006-07-16 16:22:45 UTC (rev
9631)
@@ -14,6 +14,7 @@
/**
* Definitive stop. Transfer is considered as failed.
+ * @return false if really it *cannot* stop the query.
* @param queueManger QueueManager gives access to QueryManager.
*/
public boolean stop(FCPQueueManager queueManager);
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java 2006-07-16 15:49:09 UTC
(rev 9630)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java 2006-07-16 16:22:45 UTC
(rev 9631)
@@ -32,7 +32,7 @@
public boolean stop(FCPQueueManager queueManager) {
/* Ignored */
- return false;
+ return true;
}
public int getQueryType() {
Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-07-16 15:49:09 UTC (rev 9630)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-07-16 16:22:45 UTC (rev 9631)
@@ -38,7 +38,7 @@
import thaw.fcp.*;
-public class QueuePanel implements MouseListener, ActionListener,
ClipboardOwner, KeyListener {
+public class QueuePanel implements MouseListener, ActionListener, KeyListener {
private Core core;
private JLabel label;
@@ -262,33 +262,42 @@
}
- public void actionPerformed(ActionEvent e) {
- Toolkit tk = Toolkit.getDefaultToolkit();
- String keys = "";
- File dir = null;
+ private class ActionReplier implements Runnable, ClipboardOwner {
+ ActionEvent e;
+ Vector queries;
- if(e.getSource() == downloadItem) {
- FileChooser fileChooser = new FileChooser();
-
fileChooser.setTitle(I18n.getMessage("thaw.common.downloadLocally"));
- fileChooser.setDirectoryOnly(true);
- fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
- dir = fileChooser.askOneFile();
+ public ActionReplier(ActionEvent e, Vector queries) {
+ this.e = e;
+ this.queries = queries;
}
+ public void run() {
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ String keys = "";
+ File dir = null;
- for(int i = 0 ; i < selectedRows.length;i++) {
- FCPTransferQuery query =
(FCPTransferQuery)queries.get(selectedRows[i]);
+ if(e.getSource() == downloadItem) {
+ FileChooser fileChooser = new FileChooser();
+
fileChooser.setTitle(I18n.getMessage("thaw.common.downloadLocally"));
+ fileChooser.setDirectoryOnly(true);
+
fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
+ dir = fileChooser.askOneFile();
+ }
+
+
+ for(Iterator queryIt = queries.iterator() ;
queryIt.hasNext() ;) {
+ FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
if(query == null)
continue;
if(e.getSource() == removeItem) {
- query.stop(core.getQueueManager());
+ if(query.stop(core.getQueueManager())) {
- core.getQueueManager().remove(query);
-
- tableModel.removeQuery(query);
+
core.getQueueManager().remove(query);
+ tableModel.removeQuery(query);
+ }
}
if(e.getSource() == cancelItem) {
@@ -316,22 +325,44 @@
&& !query.getFileKey().equals(""))
keys = keys +
query.getFileKey() + "\n";
}
-
+
if(e.getSource() == downloadItem
&& dir != null) {
query.saveFileTo(dir.getPath());
}
+
+ } /* for i in selectedRows */
+
+
+
+ if(e.getSource() == copyKeysItem) {
+ StringSelection st = new StringSelection(keys);
+ Clipboard cp = tk.getSystemClipboard();
+ cp.setContents(st, this);
+ }
+
+ }
- } /* for i in selectedRows */
-
+ public void lostOwnership(Clipboard clipboard,
java.awt.datatransfer.Transferable contents) {
+ /* we dont care */
+ }
+ }
- if(e.getSource() == copyKeysItem) {
- StringSelection st = new StringSelection(keys);
- Clipboard cp = tk.getSystemClipboard();
- cp.setContents(st, this);
+ /**
+ * Manage it on a different thread to avoid UI freeze.
+ */
+ public void actionPerformed(ActionEvent e) {
+ Vector queries = new Vector();
+ Vector initialQueries = tableModel.getQueries();
+
+ /* Create a separate vector to avoid collisions */
+ for(int i = 0 ; i < selectedRows.length; i++) {
+ queries.add(initialQueries.get(selectedRows[i]));
}
+ Thread action = new Thread(new ActionReplier(e, queries));
+ action.start();
}
public void mouseClicked(MouseEvent e) {
@@ -362,11 +393,6 @@
}
- public void lostOwnership(Clipboard clipboard,
java.awt.datatransfer.Transferable contents) {
- /* we dont care */
- }
-
-
public void keyPressed(KeyEvent e) { }
public void keyReleased(KeyEvent e) { refresh(); }