Author: jflesch
Date: 2006-07-11 16:12:37 +0000 (Tue, 11 Jul 2006)
New Revision: 9560

Modified:
   trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
   trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java
   trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java
   trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
   trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
Log:
Fixing Delaying and (again) Cancellation

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2006-07-11 13:10:40 UTC 
(rev 9559)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2006-07-11 16:12:37 UTC 
(rev 9560)
@@ -13,7 +13,7 @@
  * notify() only when progress has really changes.
  */
 public class FCPClientGet extends Observable implements Observer, 
FCPTransferQuery {
-       private final static int MAX_RETRIES = 3;
+       private final static int MAX_RETRIES = 5;
        private final static int PACKET_SIZE = 1024;
        private final static int BLOCK_SIZE = 32768;

@@ -185,6 +185,11 @@
                if(message.getMessageName().equals("ProtocolError")) {
                        Logger.debug(this, "ProtocolError !");

+                       if(message.getValue("Code").equals("15")) {
+                               Logger.debug(this, "Unknow URI ? was probably a 
stop order so no problem ...");
+                               return;
+                       }
+
                        status = "Protocol Error 
("+message.getValue("CodeDescription")+")";
                        progress = 100;
                        running = false;
@@ -201,6 +206,11 @@
                if(message.getMessageName().equals("GetFailed")) {
                        Logger.debug(this, "GetFailed !");

+                       if(!isRunning()) { /* Must be a "GetFailed: cancelled 
by caller", so we simply ignore */
+                               Logger.info(this, "Cancellation confirmed.");
+                               return;
+                       }
+
                        if(isPersistent())
                                removePersistent();

@@ -382,16 +392,41 @@
                queueManager.getQueryManager().writeMessage(stopMessage);
        }

+       public boolean pause(FCPQueueManager queryManager) {
+               Logger.info(this, "Pausing fetching of the key : 
"+getFileKey());
+               
+               if(!isRunning() || isFinished()) {
+                       Logger.info(this, "Can't stop (pause). Not running.");

+               } else {
+                       
+                       if(isPersistent()) {
+                               removePersistent();
+                       } else {
+                               Logger.warning(this, "Can't stop a 
non-persistent query, will continue in background ...");
+                       }
+               }
+
+               progress = 0;
+               successful = false;
+               running = false;
+               status = "Delayed";
+
+               
+
+               setChanged();
+               notifyObservers();
+               
+               return true;
+
+       }
+
        public boolean stop(FCPQueueManager queryManager) {
                Logger.info(this, "Stop fetching of the key : "+getFileKey());

                if(!isRunning() || isFinished()) {
                        Logger.info(this, "Can't stop. Not running -> 
considered as failed");

-                       setChanged();
-                       notifyObservers();
-
                } else {

                        if(isPersistent()) {
@@ -403,6 +438,7 @@

                progress = 100;
                successful = false;
+               running = false;
                status = "Stopped";

                setChanged();

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java  2006-07-11 13:10:40 UTC (rev 
9559)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java  2006-07-11 16:12:37 UTC (rev 
9560)
@@ -13,6 +13,7 @@
        public boolean start(FCPQueueManager queueManager);

        /**
+        * Definitive stop.
         * @param queueManger QueueManager gives access to QueryManager.
         */
        public boolean stop(FCPQueueManager queueManager);

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java  2006-07-11 13:10:40 UTC 
(rev 9559)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java  2006-07-11 16:12:37 UTC 
(rev 9560)
@@ -9,6 +9,13 @@
 public interface FCPTransferQuery extends FCPQuery {

        /**
+        * Similar to stop(), but the query knows that it will be started again 
later.
+        * @param queueManager QueueManager gives access to QueryManager;
+        */
+       public boolean pause(FCPQueueManager queueManager);
+
+
+       /**
         * Used by the QueueManager only.
         * Currently these priority are the same
         * as FCP priority, but it can change in the

Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java      
2006-07-11 13:10:40 UTC (rev 9559)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java      
2006-07-11 16:12:37 UTC (rev 9560)
@@ -134,11 +134,16 @@
                                identifier.setText(query.getIdentifier());
                        else
                                identifier.setText("N/A");
+                       attempt.setText((new 
Integer(query.getAttempt())).toString());
+
+                       
                } else {
                        progress.setValue(0);
                        progress.setString("");
                        status.setText("");
                        identifier.setText("");
+                       attempt.setText("");
+                       
                }
        }

@@ -155,14 +160,12 @@
                        key.setText(query.getFileKey());
                        path.setText(query.getPath());
                        priority.setText((new 
Integer(query.getThawPriority())).toString());
-                       attempt.setText((new 
Integer(query.getAttempt())).toString());
                } else {
                        file.setText("");
                        size.setText("");
                        key.setText("");
                        path.setText("");
                        priority.setText("");
-                       attempt.setText("");
                }

        }

Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java       
2006-07-11 13:10:40 UTC (rev 9559)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java       
2006-07-11 16:12:37 UTC (rev 9560)
@@ -232,11 +232,12 @@

                                if(e.getSource() == cancelItem) {
                                        query.stop(core.getQueueManager());
+                                       core.getQueueManager().remove(query);
                                }

                                if(e.getSource() == delayItem) {
                                        if(query.isRunning() && 
!query.isFinished()) {
-                                               
query.stop(core.getQueueManager());
+                                               
query.pause(core.getQueueManager());
                                                
core.getQueueManager().moveFromRunningToPendingQueue(query);
                                        }
                                }


Reply via email to