Author: jflesch
Date: 2006-08-16 14:44:42 +0000 (Wed, 16 Aug 2006)
New Revision: 10119

Modified:
   trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
   trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
   trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
Log:
Fix progression display

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2006-08-16 13:48:59 UTC 
(rev 10118)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2006-08-16 14:44:42 UTC 
(rev 10119)
@@ -318,7 +318,7 @@
                        if(message.getValue("Total") != null
                           && message.getValue("Succeeded") != null) {
                                fileSize = ((new 
Long(message.getValue("Total"))).longValue())*BLOCK_SIZE;
-                               long required = (new 
Long(message.getValue("Total"))).longValue();
+                               long required = (new 
Long(message.getValue("Required"))).longValue();
                                long succeeded = (new 
Long(message.getValue("Succeeded"))).longValue();

                                progress = (int)((succeeded * 99) / required);
@@ -541,6 +541,8 @@
                long origSize = size;
                long startTime = System.currentTimeMillis();

+               boolean success = true;
+
                while(size > 0) {

                        int packet = PACKET_SIZE;
@@ -555,8 +557,9 @@
                        amount = connection.read(packet, read);

                        if(amount <= -1) {
-                               Logger.error(this, "Socket closed ?!");
+                               Logger.error(this, "Socket closed, damn !");
                                status = "Read error";
+                               success = false;
                                break;
                        }

@@ -573,6 +576,7 @@
                        size = size - amount;

                        if( System.currentTimeMillis() >= (startTime+3000)) {
+                               status = "Writing to disk";
                                fromTheNodeProgress = (int) (((origSize-size) * 
100) / origSize);
                                setChanged();
                                notifyObservers();
@@ -586,6 +590,10 @@
                if(reallyWrite) {
                        try {
                                fileWriter.close();
+                               
+                               if(!success)
+                                       newFile.delete();
+
                        } catch(java.io.IOException e) {
                                Logger.notice(this, "Unable to close correctly 
file on disk !? : "+e.toString());
                        }

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java     2006-08-16 13:48:59 UTC 
(rev 10118)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java     2006-08-16 14:44:42 UTC 
(rev 10119)
@@ -237,6 +237,7 @@
                        return bufferedOut.write(data);
                else {
                        Logger.notice(this, "rawWrite(), bufferedOut == null ? 
Socket closed ?");
+                       disconnect();
                        return false;
                }
        }
@@ -324,21 +325,27 @@

        /**
         * @param lng Obsolete.
+        * @return -1 Disconnection.
         */
        public synchronized int read(int lng, byte[] buf) {
                int rdBytes = 0;
                try {
                        rdBytes = reader.read(buf);

+                       if(rdBytes < 0) {
+                               Logger.error(this, "Error while reading on the 
socket => disconnection");
+                               disconnect();
+                       }
+                               
                        rawBytesWaiting = rawBytesWaiting - rdBytes;

                        //Logger.verbose(this, "Remaining: "+rawBytesWaiting);

                        return rdBytes;
                } catch(java.io.IOException e) {
-                       Logger.error(this, "IOException while reading raw bytes 
on socket, will probably cause troubles");
+                       Logger.error(this, "IOException while reading raw bytes 
on socket => disconnection");
                        Logger.error(this, e.getMessage() + ":" +e.getCause());
-                       System.exit(3);
+                       disconnect();
                        return -2; /* -1 can mean eof */
                }


Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java  
2006-08-16 13:48:59 UTC (rev 10118)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java  
2006-08-16 14:44:42 UTC (rev 10119)
@@ -172,15 +172,19 @@
        }

        public synchronized void reloadQueue() {
-               resetTable();
-               
-               addQueries(queueManager.getRunningQueue());
-                               
-               Vector[] pendings = queueManager.getPendingQueues();
-               
-               for(int i = 0;i < pendings.length ; i++)
-                       addQueries(pendings[i]);
-               
+               try {
+                       resetTable();
+
+                       addQueries(queueManager.getRunningQueue());
+                       
+                       Vector[] pendings = queueManager.getPendingQueues();
+                       
+                       for(int i = 0;i < pendings.length ; i++)
+                               addQueries(pendings[i]);
+               } catch(java.util.ConcurrentModificationException e) {
+                       Logger.warning(this, "reloadQueue: Collision !");
+                       reloadQueue();
+               }               
        }

        public synchronized void addQueries(Vector queries) {


Reply via email to