Author: jflesch
Date: 2008-01-05 01:04:36 +0000 (Sat, 05 Jan 2008)
New Revision: 16901

Modified:
   trunk/apps/Thaw/src/thaw/core/Main.java
   trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
   trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
   trunk/apps/Thaw/src/thaw/fcp/FCPQueryManager.java
   trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
   trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java
   trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.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/IndexBrowser.java
   trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
Log:
Factoring of a port of the FCP implementation + improvement of the computation 
of the average speed and ETA of each transfer (will need testing)

Modified: trunk/apps/Thaw/src/thaw/core/Main.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Main.java     2008-01-05 00:11:32 UTC (rev 
16900)
+++ trunk/apps/Thaw/src/thaw/core/Main.java     2008-01-05 01:04:36 UTC (rev 
16901)
@@ -185,6 +185,7 @@
                        e.printStackTrace();
                }

+               //Logger.warning(this, "Will try to continue anyway");
                System.exit(1);
        }


Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2008-01-05 00:11:32 UTC 
(rev 16900)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2008-01-05 01:04:36 UTC 
(rev 16901)
@@ -12,19 +12,10 @@
 import thaw.core.ThawRunnable;


-public class FCPClientGet extends Observable
-       implements Observer, FCPTransferQuery {
+public class FCPClientGet extends FCPTransferQuery implements Observer {

-       public final static int DEFAULT_PRIORITY = 4;
-       public final static int DEFAULT_MAX_RETRIES = -1;
-       public final static int PERSISTENCE_FOREVER           = 0;
-       public final static int PERSISTENCE_UNTIL_NODE_REBOOT = 1;
-       public final static int PERSISTENCE_UNTIL_DISCONNECT  = 2;
-
-
        private int maxRetries = -1;
        private final static int PACKET_SIZE = 65536;
-       public final static int BLOCK_SIZE = 16384;

        private FCPQueueManager queueManager;
        private FCPQueryManager duplicatedQueryManager;
@@ -33,8 +24,6 @@
        private String filename = null; /* Extract from the key */
        private int priority = DEFAULT_PRIORITY;
        private int persistence = PERSISTENCE_FOREVER;
-       private long startupTime = -1;
-       private long completionTime = -1;
        private boolean globalQueue = true;
        private String destinationDir = null;
        private String finalPath = null;
@@ -44,24 +33,14 @@

        private String identifier;

-       private int progress = 0; /* in pourcent */
-       private long transferedBlocks = 0;
        private int fromTheNodeProgress = 0;
-       private boolean progressReliable = false;
        private long fileSize;
        private long maxSize = 0;

-       private boolean running = false;
-       private boolean successful = true;
        private boolean writingSuccessful = true;
        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;
@@ -80,10 +59,11 @@
         * See setParameters().
         */
        public FCPClientGet(final FCPQueueManager queueManager, final HashMap 
parameters) {
+               super(false);
+               
                this.queueManager = queueManager;
                setParameters(parameters);

-               progressReliable = false;
                fromTheNodeProgress = 0;

                /* If isPersistent(), then start() won't be called, so must 
relisten the
@@ -103,20 +83,16 @@
         *                       (path determined only when the file is 
availabed ;
         *                       this file will be deleted on jvm exit)
         */
-       public FCPClientGet(final String id, final String key, final int 
priority,
+       protected FCPClientGet(final String id, final String key, final int 
priority,
                            final int persistence, final boolean globalQueue,
-                           final String destinationDir, String status, final 
int progress,
+                           final String destinationDir, String status,
                            final int maxRetries,
                            final FCPQueueManager queueManager) {

                this(key, priority, persistence, globalQueue, maxRetries, 
destinationDir);

-               progressReliable = false;
-
                this.queueManager = queueManager;

-               this.progress = progress;
-               this.transferedBlocks = 0;
                this.status = status;

                if(status == null) {
@@ -140,17 +116,7 @@
                }
                /* /FIX */

-
-               successful = true;
-               running = true;
-
-               if(progress < 100) {
-                       fromTheNodeProgress = 0;
-               } else {
-                       fromTheNodeProgress = 100;
-                       progressReliable = true;
-               }
-
+               setStatus(true, false, false);
        }


@@ -177,12 +143,11 @@
                            final int persistence, boolean globalQueue,
                            final int maxRetries,
                            String destinationDir) {
+               super(false);

-
                if (globalQueue && (persistence >= 
PERSISTENCE_UNTIL_DISCONNECT))
                        globalQueue = false; /* else protocol error */

-               progressReliable = false;
                fromTheNodeProgress = 0;

                this.maxRetries = maxRetries;
@@ -192,8 +157,6 @@
                this.globalQueue = globalQueue;
                this.destinationDir = destinationDir;

-               progress = 0;
-               transferedBlocks = 0;
                fileSize = 0;
                attempt  = 0;

@@ -247,9 +210,8 @@

        public boolean start(final FCPQueueManager queueManager) {
                attempt++;
-               running = true;
-               progress = 0;
-               transferedBlocks = 0;
+               
+               setStatus(true, false, false);

                this.queueManager = queueManager;

@@ -364,16 +326,13 @@
                                                            && 
!(queueManager.getQueryManager().getConnection().isLocalSocket() && !noDDA)
                                                            && 
queueManager.getQueryManager().getConnection().getAutoDownload()) {
                                                                status = 
"Requesting file from the node";
-                                                               progress = 99;
-                                                               running = true;
-                                                               successful = 
true;
+                                                               
                                                                
writingSuccessful = false;
                                                                
saveFileTo(destinationDir, false);
+
                                                        } else {
                                                                status = 
"Available";
-                                                               progress = 100;
-                                                               running = false;
-                                                               successful = 
true;
+                                                               
setStatus(false, true, true);
                                                                
writingSuccessful = true;
                                                                
Logger.info(this, "File already existing. Not rewrited");
                                                        }
@@ -384,8 +343,7 @@
                                        }
                                }

-                               setChanged();
-                               notifyObservers();
+                               notifyChange();
                        }

                        return;
@@ -397,8 +355,7 @@
                        identifier = null;
                        start(queueManager);

-                       setChanged();
-                       this.notifyObservers();
+                       notifyChange();

                        return;
                }
@@ -436,9 +393,9 @@
                        protocolErrorCode = 
Integer.parseInt(message.getValue("Code"));

                        status = "Protocol Error 
("+message.getValue("CodeDescription")+")";
-                       progress = 100;
-                       running = false;
-                       successful = false;
+
+                       setStatus(false, true, false);
+
                        fatal = true;

                        if((message.getValue("Fatal") != null) &&
@@ -453,8 +410,7 @@
                                isLockOwner= false;
                        }

-                       setChanged();
-                       notifyObservers();
+                       notifyChange();

                        queueManager.getQueryManager().deleteObserver(this);

@@ -476,9 +432,7 @@
                        status = "Removed";

                        if (!isFinished()) {
-                               progress = 100;
-                               running = false;
-                               successful = false;
+                               setStatus(false, true, false);
                                fatal = true;
                        }

@@ -486,8 +440,7 @@
                        queueManager.getQueryManager().deleteObserver(this);
                        queueManager.remove(this);

-                       setChanged();
-                       notifyObservers();
+                       notifyChange();
                        return;
                }

@@ -527,9 +480,7 @@
                        getFailedCode = 
Integer.parseInt(message.getValue("Code"));

                        status = "Failed 
("+message.getValue("CodeDescription")+")";
-                       progress = 100;
-                       running = false;
-                       successful = false;
+                       setStatus(false, true, false);

                        fatal = true;

@@ -539,8 +490,7 @@
                                status = status + " (non-fatal)";
                        }

-                       setChanged();
-                       this.notifyObservers();
+                       notifyChange();

                        return;
                }
@@ -548,59 +498,32 @@
                if ("SimpleProgress".equals(message.getMessageName())) {
                        Logger.debug(this, "SimpleProgress !");

-                       progress = 0;
-
                        if (message.getValue("Total") != null
                                        && message.getValue("Required") != null
                                        && message.getValue("Succeeded") != 
null) {
+
                                fileSize = 
Long.parseLong(message.getValue("Total"))*FCPClientGet.BLOCK_SIZE;
+
                                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) / 
total));
-                               transferedBlocks = succeeded;
-
-                               status = "Fetching";
-
+                               boolean progressReliable = false;
+                               
                                if((message.getValue("FinalizedTotal") != null) 
&&
-                                  
message.getValue("FinalizedTotal").equals("true")) {
+                                                  
message.getValue("FinalizedTotal").equals("true")) {
                                        progressReliable = true;
                                }

-                               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;
-                               }
+                               status = "Fetching";
+                               setBlockNumbers(required, total, succeeded, 
progressReliable);
+                               setStatus(true, false, false);
+
+                       } else {
+                               setBlockNumbers(-1, -1, -1, false);
                        }

-                       setChanged();
-                       this.notifyObservers();
+                       notifyChange();

                        return;
                }
@@ -610,42 +533,33 @@

                        fileSize = message.getAmountOfDataWaiting();

-                       running = true;
-                       successful = true;
-                       progress = 99;
-                       startupTime = 
Long.valueOf(message.getValue("StartupTime")).longValue();
-                       completionTime = 
Long.valueOf(message.getValue("CompletionTime")).longValue();
+                       setStatus(true, false, false);
+                       
setStartupTime(Long.valueOf(message.getValue("StartupTime")).longValue());
+                       
setCompletionTime(Long.valueOf(message.getValue("CompletionTime")).longValue());
+
                        status = "Writing to disk";
                        Logger.info(this, "Receiving file ...");

-                       setChanged();
-                       this.notifyObservers();
+                       notifyChange();

-                       successful = true;
-
                        if(fetchDirectly(queryManager.getConnection(), 
fileSize, true)) {
+                               Logger.info(this, "File received");
+
                                writingSuccessful = true;
-                               successful = true;
                                status = "Available";
                        } else {
                                Logger.warning(this, "Unable to fetch correctly 
the file. This may create problems on socket");
-                               if (writingSuccessful) { /* if we forgot to set 
the correct values */
-                                       writingSuccessful = false;
-                                       successful = false;
-                                       status = "Error while receveing the 
file";
-                               }
+                               writingSuccessful = false;
+                               status = "Error while receveing the file";
                        }

-                       Logger.info(this, "File received");
-
                        if (duplicatedQueryManager != null)
                                
duplicatedQueryManager.getConnection().removeFromWriterQueue();

                        isLockOwner= false;
+                       
+                       setStatus(false, true, writingSuccessful);

-                       running = false;
-                       progress = 100;
-
                        queryManager.deleteObserver(this);

                        if (queryManager != queueManager.getQueryManager()) {
@@ -654,20 +568,11 @@
                                duplicatedQueryManager = null;
                        }

-                       setChanged();
-                       notifyObservers();
+                       notifyChange();

-
                        return;
                }

-               if ("PersistentGet".equals(message.getMessageName())) {
-                       Logger.debug(this, "PersistentGet !");
-                       setChanged();
-                       notifyObservers();
-                       return;
-               }
-
                Logger.warning(this, "Unknow message : 
"+message.getMessageName() + " !");
        }

@@ -768,12 +673,12 @@

                Logger.info(this, "Waiting for socket  ...");
                status = "Waiting for socket availability ...";
-               progress = 99;
-               running = true;
+               fromTheNodeProgress = 1; /* display issue */
+               
+               setStatus(true, false, false);

-               setChanged();
-               this.notifyObservers();
-
+               notifyChange();
+               
                UnlockWaiter uw = new UnlockWaiter(this, 
duplicatedQueryManager.getConnection(), dir);

                final Thread fork = new ThawThread(uw,
@@ -793,11 +698,11 @@
                destinationDir = dir;

                status = "Requesting file";
-               progress = 99;
-               running = true;
-               setChanged();
-               this.notifyObservers();
+               fromTheNodeProgress = 1; /* display issue */
+               setStatus(true, false, false);

+               notifyChange();
+               
                if(destinationDir == null) {
                        Logger.warning(this, "saveFileTo() : Wtf ?");
                }
@@ -880,7 +785,7 @@
                                Logger.error(this, "Socket closed, damn !");
                                status = "Unable to read data from the node";
                                writingSuccessful = false;
-                               successful = false;
+                               setStatus(false, true, false);
                                try {
                                        outputStream.close();
                                } catch(java.io.IOException ex) {
@@ -898,7 +803,7 @@
                                        Logger.error(this, "Unable to write 
file on disk ... out of space ? : "+e.toString());
                                        status = "Unable to fetch / disk 
probably full !";
                                        writingSuccessful = false;
-                                       successful = false;
+                                       setStatus(false, true, false);
                                        try {
                                                outputStream.close();
                                        } catch(java.io.IOException ex) {
@@ -915,8 +820,12 @@
                        if( System.currentTimeMillis() >= (startTime+3000)) {
                                status = "Writing to disk";
                                fromTheNodeProgress = (int) (((origSize-size) * 
100) / origSize);
-                               setChanged();
-                               this.notifyObservers();
+                               
+                               if (fromTheNodeProgress <= 0) /* display issue 
*/
+                                       fromTheNodeProgress = 1;
+
+                               notifyChange();
+
                                startTime = System.currentTimeMillis();
                        }

@@ -969,7 +878,7 @@

                queueManager.getQueryManager().writeMessage(stopMessage);

-               running = false;
+               setStatus(false, isFinished(), isSuccessful());

                return true;
        }
@@ -981,14 +890,12 @@
                Logger.info(this, "Pausing fetching of the key : 
"+getFileKey());

                removeRequest();
+               
+               setStatus(false, false, false);

-               progress = 0;
-               running = false;
-               successful = false;
                status = "Delayed";

-               setChanged();
-               this.notifyObservers();
+               notifyChange();

                return true;

@@ -1001,18 +908,14 @@
                        return false;

                boolean wasFinished = isFinished();
+               
+               setStatus(false, true, isSuccessful());

-               if (progress < 100)
-                       successful = false;
-
-               progress = 100;
-               running = false;
                fatal = true;
                status = "Stopped";

                if (!restartIfFailed && !wasFinished) {
-                       setChanged();
-                       this.notifyObservers();
+                       notifyChange();
                }

                return true;
@@ -1051,8 +954,7 @@

                priority = prio;

-               setChanged();
-               this.notifyObservers();
+               notifyChange();
        }

        public int getQueryType() {
@@ -1063,26 +965,6 @@
                return status;
        }

-       public int getProgression() {
-               return progress;
-       }
-       
-       
-       public long getAverageSpeed() {
-               return averageSpeed;
-       }
-       
-       public long getETA() {
-               return eta;
-       }
-
-       public boolean isProgressionReliable() {
-               if((progress == 0) || (progress >= 99))
-                       return true;
-
-               return progressReliable;
-       }
-
        public String getFileKey() {
                // TODO : It's fix due to Frost
                //        => to remove when it will become unneeded
@@ -1096,13 +978,6 @@
                return key;
        }

-       public boolean isFinished() {
-               if(progress >= 100)
-                       return true;
-
-               return false;
-       }
-
        public long getFileSize() {
                return fileSize;
        }
@@ -1136,7 +1011,7 @@

                if(x == 0) {
                        /* We suppose it's a restart */
-                       progress = 0;
+                       setBlockNumbers(-1, -1, -1, false);
                }
        }

@@ -1144,22 +1019,14 @@
                return maxRetries;
        }

-       public boolean isSuccessful() {
-               return successful;
-       }
-
        public boolean isWritingSuccessful() {
                return writingSuccessful;
        }

        public boolean isFatallyFailed() {
-               return ((!successful) && fatal);
+               return ((!isSuccessful()) && fatal);
        }

-       public boolean isRunning() {
-               return running;
-       }
-
        public HashMap getParameters() {
                final HashMap result = new HashMap();

@@ -1174,10 +1041,9 @@
                result.put("status", status);

                        result.put("Identifier", identifier);
-               result.put("Progress", Integer.toString(progress));
                result.put("FileSize", Long.toString(fileSize));
-               result.put("Running", Boolean.toString(running));
-               result.put("Successful", Boolean.toString(successful));
+               result.put("Running", Boolean.toString(isRunning()));
+               result.put("Successful", Boolean.toString(isSuccessful()));
                result.put("MaxRetries", Integer.toString(maxRetries));

                return result;
@@ -1199,16 +1065,16 @@
                identifier     = (String)parameters.get("Identifier");

                Logger.info(this, "Resuming id : "+identifier);
-
-               progress       = 
Integer.parseInt((String)parameters.get("Progress"));
                fileSize       = 
Long.parseLong((String)parameters.get("FileSize"));
-               running        = 
Boolean.valueOf((String)parameters.get("Running")).booleanValue();
-               successful     = 
Boolean.valueOf((String)parameters.get("Successful")).booleanValue();
+               boolean running        = 
Boolean.valueOf((String)parameters.get("Running")).booleanValue();
+               boolean successful     = 
Boolean.valueOf((String)parameters.get("Successful")).booleanValue();
                maxRetries     = 
Integer.parseInt((String)parameters.get("MaxRetries"));
+               
+               setStatus(running, !running, successful);

                if((persistence == PERSISTENCE_UNTIL_DISCONNECT) && 
!isFinished()) {
-                       progress = 0;
-                       running = false;
+                       setStatus(false, false, false);
+                       setBlockNumbers(-1, -1, -1, false);
                        status = "Waiting";
                }

@@ -1236,11 +1102,6 @@
                return fromTheNodeProgress;
        }

-       public void notifyChange() {
-               setChanged();
-               notifyObservers();
-       }
-
        public int getGetFailedCode() {
                return getFailedCode;
        }
@@ -1249,13 +1110,4 @@
                return protocolErrorCode;
        }

-
-       public long getCompletionTime() {
-               return completionTime;
-       }
-
-
-       public long getStartupTime() {
-               return startupTime;
-       }
 }

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java      2008-01-05 00:11:32 UTC 
(rev 16900)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java      2008-01-05 01:04:36 UTC 
(rev 16901)
@@ -16,17 +16,8 @@
 /**
  * Allow to insert a simple file.
  */
-public class FCPClientPut extends Observable implements FCPTransferQuery, 
Observer {
-       public final static int DEFAULT_PRIORITY = 4;
+public class FCPClientPut extends FCPTransferQuery implements Observer {

-       public final static int KEY_TYPE_CHK = 0;
-       public final static int KEY_TYPE_KSK = 1;
-       public final static int KEY_TYPE_SSK = 2; /* also USK */
-
-       public final static int PERSISTENCE_FOREVER           = 0;
-       public final static int PERSISTENCE_UNTIL_NODE_REBOOT = 1;
-       public final static int PERSISTENCE_UNTIL_DISCONNECT  = 2;
-
        private FCPQueueManager queueManager;

        private File localFile;
@@ -37,31 +28,19 @@
        private String privateKey; /* must finish by '/' (cf SSKKeypair) */
        private String publicKey; /* publicKey contains the filename etc */
        private int priority = DEFAULT_PRIORITY;
-       private long startupTime = -1;
-       private long completionTime = -1;
        private boolean global = true;
        private int persistence = PERSISTENCE_FOREVER;
        private boolean getCHKOnly = false;

-       private int progress = 0;
-       private long transferedBlocks = 0;
        private int toTheNodeProgress = 0;
        private String status;

        private int attempt = 0;
        private String identifier;

-       private boolean running = false;
-       private boolean finished = false;
-       private boolean successful = false;
        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;

@@ -77,6 +56,8 @@
         * To resume query from file. (see core.QueueKeeper)
         */
        public FCPClientPut(final FCPQueueManager queueManager, final HashMap 
parameters) {
+               super(true);
+
                this.queueManager = queueManager;
                setParameters(parameters);
        }
@@ -104,6 +85,8 @@
                            final String privateKey, final int priority,
                            final boolean global, final int persistence,
                            final boolean getCHKOnly) {
+               super(true);
+
                this.getCHKOnly = getCHKOnly;
                localFile = file;

@@ -132,15 +115,11 @@
                this.global = global;
                this.persistence = persistence;
                status = "Waiting";
-               progress = 0;
-               transferedBlocks = 0;
+               setStatus(false, false, false);
+               setBlockNumbers(-1, -1, -1, true);
                attempt = 0;

                identifier = null;
-
-               running = false;
-               finished = false;
-               successful = false;
                fatal = true;

        }
@@ -149,12 +128,12 @@
         * Used for resuming from a PersistentPut.
         * @param publicKey : Complete key (with filename, etc)
         */
-       public FCPClientPut(final String identifier, final String publicKey,
+       protected FCPClientPut(final String identifier, final String publicKey,
                            final int priority, final int persistence, final 
boolean global,
                            final String filePath, final String fileName, final 
String status, final int progress,
                            final long fileSize, final FCPQueueManager 
queueManager) {
+               super(true);

-
                if(fileSize > 0)
                        this.fileSize = fileSize;

@@ -184,14 +163,11 @@
                this.global = global;

                this.persistence = persistence;
-
-               this.progress = progress;
-               this.transferedBlocks = 0;
-
+               
+               setBlockNumbers(-1, -1, -1, true);
+               setStatus(true, false, false);
+               
                this.status = status;
-               running = true;
-               finished = false;
-               successful = false;
                fatal = true;
        }

@@ -205,27 +181,22 @@
                        Logger.warning(this, "Empty or unreachable 
file:"+localFile.getPath());

                        status = "EMPTY OR UNREACHABLE FILE";
+                       
+                       setStatus(false, true, false);

-                       successful = false;
                        fatal = true;
-                       finished = true;
-                       running = false;

-                       setChanged();
-                       this.notifyObservers();
-
+                       notifyChange();
+                       
                        return false;
                }


                queueManager.getQueryManager().addObserver(this);
+               
+               setBlockNumbers(-1, -1, -1, false);
+               setStatus(true, false, false);

-               progress = 0;
-               transferedBlocks = 0;
-               finished = false;
-               successful = false;
-               running = true;
-
                sha = null;

                if 
(queueManager.getQueryManager().getConnection().isLocalSocket() && localFile != 
null) {
@@ -352,7 +323,8 @@
        }

        public boolean continueInsert() {
-               running = true; /* Here we are really running */
+               setStatus(true, false, false);
+
                sending = true;

                final FCPConnection connection = 
queueManager.getQueryManager().getConnection();
@@ -440,34 +412,28 @@
                connection.removeFromWriterQueue();
                lockOwner = false;
                sending = false;
-
-               progress = 0;
-               transferedBlocks = 0;

+               setBlockNumbers(-1, -1, -1, true);
+               
                if(ret == true) {
-                       successful = false;
+                       setStatus(true, false, false);
                        fatal = true;
-                       finished = false;
-                       running = true;

                        if (!getCHKOnly)
                                status = "Inserting";
                        else
                                status = "Computing";

-                       setChanged();
-                       this.notifyObservers();
+                       notifyChange();

                        return true;
                } else {
-                       successful = false;
-                       finished = true;
-                       running = false;
+                       setStatus(false, true, false);

                        status = "Unable to send the file to the node";
-                       setChanged();
-                       this.notifyObservers();

+                       notifyChange();
+
                        return false;
                }

@@ -554,16 +520,15 @@

                        status = "Stopped";

-                       if (!finished)
-                               successful = false;
+                       if (wasFinished)
+                               setStatus(false, true, false);
+                       else
+                               setStatus(false, true, isSuccessful());

-                       finished = true;
                        fatal= true;
-                       running = false;

                        if (!wasFinished) {
-                               setChanged();
-                               this.notifyObservers();
+                               notifyChange();
                        }

                        return true;
@@ -576,8 +541,13 @@
                if (o == sha) {
                        if(sha.isFinished())
                                startProcess();
-                       else
-                               progress = sha.getProgression();
+                       else {
+                               status = "Computing hash";
+                               setBlockNumbers(100, 100, sha.getProgression(), 
true);
+                       }
+                       
+                       notifyChange();
+                       
                        return;
                }

@@ -585,8 +555,7 @@
                        privateKey = sskGenerator.getPrivateKey();
                        publicKey = sskGenerator.getPublicKey() + "/" + name;

-                       setChanged();
-                       notifyObservers();
+                       notifyChange();

                        startInsert();
                        return;
@@ -602,9 +571,7 @@

                        if("URIGenerated".equals( msg.getMessageName() )
                           || "PutFetchable".equals( msg.getMessageName() )) {
-                               running = true;
-                               finished = false;
-                               successful = false;
+                               setStatus(true, false, false);

                                publicKey = msg.getValue("URI");

@@ -614,17 +581,14 @@

                                if(getCHKOnly) {
                                        status = "CHK";
+                                       
+                                       setStatus(false, true, true);

-                                       progress = 100;
                                        toTheNodeProgress = 100;
-                                       running = false;
-                                       finished = true;
-                                       successful = true;
                                        fatal = false;
                                        sending = false;

-                                       setChanged();
-                                       this.notifyObservers();
+                                       notifyChange();
                                        
queueManager.getQueryManager().deleteObserver(this);
                                        return;
                                }
@@ -637,12 +601,10 @@
                        }

                        if("PutSuccessful".equals(msg.getMessageName())) {
-                               successful = true;
-                               finished = true;
-                               running = false;
+                               setStatus(false, true, true);

-                               startupTime = 
Long.valueOf(msg.getValue("StartupTime")).longValue();
-                               completionTime = 
Long.valueOf(msg.getValue("CompletionTime")).longValue();
+                               
setStartupTime(Long.valueOf(msg.getValue("StartupTime")).longValue());
+                               
setCompletionTime(Long.valueOf(msg.getValue("CompletionTime")).longValue());
                                publicKey = msg.getValue("URI");

                                if (publicKey == null) {
@@ -667,8 +629,6 @@

                                status = "Finished";

-                               progress = 100;
-
                                setChanged();
                                this.notifyObservers();
                                return;
@@ -685,9 +645,7 @@

                        if 
("PersistentRequestRemoved".equals(msg.getMessageName())) {
                                if (!isFinished()) {
-                                       successful = false;
-                                       running = false;
-                                       finished = true;
+                                       setStatus(false, true, false);
                                        fatal = true;
                                        status = "Removed";
                                }
@@ -696,17 +654,13 @@
                                
queueManager.getQueryManager().deleteObserver(this);
                                queueManager.remove(this);

-                               setChanged();
-                               notifyObservers();
+                               notifyChange();
                                return;
                        }


                        if ("PutFailed".equals( msg.getMessageName() )) {
-
-                               successful = false;
-                               running = false;
-                               finished = true;
+                               setStatus(false, true, false);
                                fatal = true;

                                putFailedCode = 
Integer.parseInt(msg.getValue("Code"));
@@ -725,17 +679,13 @@
                                        Logger.warning(this, "Insertion error : 
collision");
                                Logger.notice(this, msg.toString());

-                               setChanged();
-                               this.notifyObservers();
+                               notifyChange();
                                return;
                        }

                        if("ProtocolError".equals( msg.getMessageName() )) {
-
-                               successful = false;
-                               running = false;
+                               setStatus(false, true, false);
                                fatal = true;
-                               finished = true;

                                if(lockOwner) {
                                        lockOwner = false;
@@ -750,111 +700,78 @@
                                        fatal = false;
                                }

-                               setChanged();
-                               this.notifyObservers();
+                               notifyChange();

                                return;
                        }

-                       if(msg.getMessageName().equals("IdentifierCollision")) {
+                       if("IdentifierCollision".equals(msg.getMessageName())) {
                                status = "Identifier collision";
                                start(queueManager); /* et hop ca repart :) */
                                return;
                        }


-                       if(msg.getMessageName().equals("PersistentPut")) {
+                       if("PersistentPut".equals(msg.getMessageName())) {
                                status = "Inserting";
                                //publicKey = msg.getValue("URI");
                                return;
                        }

-                       if(msg.getMessageName().equals("StartedCompression")) {
+                       if("StartedCompression".equals(msg.getMessageName())) {
                                status = "Compressing";
+                               
+                               notifyChange();

-                               setChanged();
-                               this.notifyObservers();
-
                                return;
                        }

-                       if(msg.getMessageName().equals("FinishedCompression")) {
+                       if("FinishedCompression".equals(msg.getMessageName())) {
                                status = "Inserting";

                                if((msg.getValue("OrigSize") == null)
                                   || (msg.getValue("CompressedSize") == null)) 
{
-                                       setChanged();
-                                       this.notifyObservers();
+                                       notifyChange();
                                        return;
                                }

                                final int rate = (int)( ((new 
Long(msg.getValue("OrigSize"))).longValue() * 100) / (new 
Long(msg.getValue("CompressedSize"))).longValue() );

-                               Logger.info(this, "Compression: "+ 
Integer.toString(rate));
+                               Logger.notice(this, "Compression rate: "+ 
Integer.toString(rate)+" %");

-                               setChanged();
-                               this.notifyObservers();
+                               notifyChange();

                                return;
                        }

-                       if(msg.getMessageName().equals("SimpleProgress")) {
+                       if("SimpleProgress".equals(msg.getMessageName())) {

                                if((msg.getValue("Total") != null)
                                   && (msg.getValue("Succeeded") != null)) {

                                        final long total = (new 
Long(msg.getValue("Total"))).longValue();
-                                       //long required = (new 
Long(msg.getValue("Required"))).longValue();
+                                       long required = (new 
Long(msg.getValue("Required"))).longValue();
                                        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 
*/
-                                       }
+                                       setBlockNumbers(required, total, 
succeeded, true);
+                                       setStatus(true, false, false);

-                                       if (succeeded >= total || averageSpeed 
<= 0)
-                                               eta = 0; /* unknown */
-                                       else {
-                                               eta = ((total - succeeded) * 
FCPClientGet.BLOCK_SIZE) / averageSpeed;
-                                       }
-
                                        if (!getCHKOnly)
                                                status = "Inserting";
                                        else
                                                status = "Computing";

-                                       setChanged();
-                                       this.notifyObservers();
+                                       notifyChange();
                                }

                                return;
                        }


-                       Logger.notice(this, "Unknow message.");
+                       if (msg.getMessageName() == null)
+                               Logger.notice(this, "Unknow message (name == 
null)");
+                       else
+                               Logger.notice(this, "Unkwown message: 
"+msg.getMessageName());                  

                        return;
                }
@@ -867,28 +784,26 @@
        }

        public boolean pause(final FCPQueueManager queueManager) {
-               progress = 0;
+               /*
+                * TODO : lower priority ?
+                */
+               
+               setStatus(false, false, false);
                status = "Delayed";

-               running = false;
-               successful = false;
-               finished = false;
                fatal = true;

                removeRequest();
+               notifyChange();
+               
                return false;
        }


        public boolean removeRequest() {
-               setChanged();
-               this.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();
-                       this.notifyObservers();
                        return false;
                }

@@ -904,7 +819,7 @@

                        queueManager.getQueryManager().writeMessage(msg);

-                       running = false;
+                       setStatus(false, false, false);

                        queueManager.getQueryManager().deleteObserver(this);
                } else {
@@ -945,8 +860,7 @@

                priority = prio;

-               setChanged();
-               this.notifyObservers();
+               notifyChange();
        }


@@ -955,22 +869,6 @@
                return status;
        }

-       public int getProgression() {
-               return progress;
-       }
-
-       public long getAverageSpeed() {
-               return averageSpeed;
-       }
-       
-       public long getETA() {
-               return eta;
-       }
-       
-       public boolean isProgressionReliable() {
-               return true;
-       }
-
        /**
         * @return public key
         */
@@ -1048,20 +946,8 @@
                return -1;
        }

-       public boolean isRunning() {
-               return running;
-       }
-
-       public boolean isFinished() {
-               return finished;
-       }
-
-       public boolean isSuccessful() {
-               return successful;
-       }
-
        public boolean isFatallyFailed() {
-               return ((!successful) && fatal);
+               return ((!isSuccessful()) && fatal);
        }

        public HashMap getParameters() {
@@ -1079,16 +965,14 @@
                result.put("global", Boolean.toString(global));
                result.put("persistence", Integer.toString(persistence));

-               result.put("progress", Integer.toString(progress));
-
                result.put("status", status);

                result.put("attempt", Integer.toString(attempt));
                if(identifier != null)
                        result.put("identifier", identifier);
-               result.put("running", Boolean.toString(running));
-               result.put("successful", Boolean.toString(successful));
-               result.put("finished", Boolean.toString(finished));
+               result.put("running", Boolean.toString(isRunning()));
+               result.put("successful", Boolean.toString(isSuccessful()));
+               result.put("finished", Boolean.toString(isFinished()));

                return result;
        }
@@ -1117,7 +1001,6 @@
                global = 
Boolean.valueOf((String)parameters.get("global")).booleanValue();

                persistence = 
Integer.parseInt((String)parameters.get("persistence"));
-               progress = 
Integer.parseInt(((String)parameters.get("progress")));
                status = (String)parameters.get("status");
                attempt = Integer.parseInt((String)parameters.get("attempt"));

@@ -1125,12 +1008,14 @@
                if((identifier == null) || identifier.equals(""))
                        identifier = null;

-               running = 
Boolean.valueOf((String)parameters.get("running")).booleanValue();
-               successful = 
Boolean.valueOf((String)parameters.get("successful")).booleanValue();
-               finished = 
Boolean.valueOf((String)parameters.get("finished")).booleanValue();
+               boolean running = 
Boolean.valueOf((String)parameters.get("running")).booleanValue();
+               boolean successful = 
Boolean.valueOf((String)parameters.get("successful")).booleanValue();
+               boolean finished = 
Boolean.valueOf((String)parameters.get("finished")).booleanValue();
+               
+               setStatus(running, finished, successful);

                if ((persistence == PERSISTENCE_UNTIL_DISCONNECT) && 
!isFinished()) {
-                       progress = 0;
+                       setStatus(false, false, false);
                        status = "Waiting";
                }

@@ -1189,12 +1074,6 @@
        }


-       public void notifyChange() {
-               setChanged();
-               notifyObservers();
-       }
-
-
        /**
         * @return -1 if none
         */
@@ -1202,11 +1081,4 @@
                return putFailedCode;
        }

-       public long getStartupTime() {
-               return startupTime;
-       }
-
-       public long getCompletionTime() {
-               return completionTime;
-       }
 }

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueryManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueryManager.java   2008-01-05 00:11:32 UTC 
(rev 16900)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueryManager.java   2008-01-05 01:04:36 UTC 
(rev 16901)
@@ -86,7 +86,7 @@

                result.loadFromRawMessage(whatsUp);

-               if(withData) {
+               if(withData && result.getValue("DataLength") != null) {
                        final long dataWaiting = (new 
Long(result.getValue("DataLength"))).longValue();
                        connection.setRawDataWaiting(dataWaiting);
                        Logger.info(this, "Achtung data: "+(new 
Long(dataWaiting)).toString());

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java    2008-01-05 00:11:32 UTC 
(rev 16900)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java    2008-01-05 01:04:36 UTC 
(rev 16901)
@@ -74,7 +74,7 @@
                        final FCPClientGet clientGet = new 
FCPClientGet(msg.getValue("Identifier"),
                                                                        
msg.getValue("URI"), // key
                                                                        
priority, persistence, global,
-                                                                       
destinationDir, "Fetching", 0,
+                                                                       
destinationDir, "Fetching",
                                                                        -1, 
queueManager);

                        if(queueManager.addQueryToTheRunningQueue(clientGet, 
false))

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java   2008-01-05 00:11:32 UTC 
(rev 16900)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java   2008-01-05 01:04:36 UTC 
(rev 16901)
@@ -385,7 +385,7 @@
        }


-       public void schedule() {
+       private void schedule() {
                        /* We count the running query to see if there is an 
empty slot */

                        int runningInsertions = 0;
@@ -448,6 +448,17 @@
                        }

        }
+       
+       
+       private void updateStats()
+       {
+               synchronized(runningQueries) {
+                       for (Iterator it = runningQueries.iterator(); 
it.hasNext(); ) {
+                               FCPTransferQuery query = 
(FCPTransferQuery)it.next();
+                               query.updateStats();
+                       }
+               }
+       }


        public void run() {
@@ -459,7 +470,7 @@

                while(!stopThread) {
                        try {
-                               Thread.sleep(500);
+                               Thread.sleep(1000);
                        } catch(final java.lang.InterruptedException e) {
                                /* We don't care */
                        }
@@ -472,7 +483,12 @@
                                           && 
!queryManager.getConnection().isWriting()
                                           && queueCompleted)
                                                schedule();
+                                       
+                                       
if(queryManager.getConnection().isConnected()
+                                          && 
!queryManager.getConnection().isWriting())
+                                               updateStats();

+
                                } catch(final Exception e) {
                                        Logger.error(this, "EXCEPTION FROM FCP 
SCHEDULER : "+e.toString()+ " ; "+e.getMessage());
                                        e.printStackTrace();

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java  2008-01-05 00:11:32 UTC 
(rev 16900)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java  2008-01-05 01:04:36 UTC 
(rev 16901)
@@ -1,6 +1,7 @@
 package thaw.fcp;

 import java.util.HashMap;
+import java.util.Observable;

 /**
  * Transfer query == fetch / insert query. These queries must be able to
@@ -8,19 +9,261 @@
  * 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 {
+public abstract class FCPTransferQuery extends Observable implements FCPQuery {
+       public final static int BLOCK_SIZE = 16384;
+       public final static int KEY_TYPE_CHK = 0;
+       public final static int KEY_TYPE_KSK = 1;
+       public final static int KEY_TYPE_SSK = 2; /* also USK */
+       
+       public final static int DEFAULT_PRIORITY = 4;
+       public final static int DEFAULT_MAX_RETRIES = -1;
+       public final static int PERSISTENCE_FOREVER           = 0;
+       public final static int PERSISTENCE_UNTIL_NODE_REBOOT = 1;
+       public final static int PERSISTENCE_UNTIL_DISCONNECT  = 2;
+       
+       private boolean insertion = false;
+       
+       /* last known values */
+       private long requiredBlocks = -1;
+       private long totalBlocks = -1;
+       private long transferedBlocks = -1;
+       private boolean reliable = false;
+       
+       /* reminder to do the maths */
+       public final static int NMB_REMINDERS = 60; /* one per seconde, so 1 
minute here */
+       private long[] requiredBlocksPast = new long[NMB_REMINDERS];
+       private long[] totalBlocksPast = new long[NMB_REMINDERS];
+       private long[] transferedBlocksPast = new long[NMB_REMINDERS];
+       private int currentReadCursor = 0; /* read Cursor in the *past arrays */
+       private int currentWriteCursor = 0; /* write Cursor in the *past arrays 
*/
+       
+       private boolean running = false;
+       private boolean finished = false;
+       private boolean successful = false;
+       
+       private long averageSpeed = 0;
+       private long ETA = 0;
+       
+       private long startupTime = -1;
+       private long completionTime = -1;
+       
+       
+       public FCPTransferQuery(boolean insertion) {
+               this.insertion = insertion;

+               reliable = insertion;
+               
+               for (int i = 0 ; i < NMB_REMINDERS ; i++) {
+                       requiredBlocksPast[i]   = -1;
+                       totalBlocksPast[i]      = -1;
+                       transferedBlocksPast[i] = -1;
+               }
+       }
+       
+       protected void setBlockNumbers(long required, long total, long 
transfered, boolean reliable) {
+               synchronized(this) {
+                       requiredBlocks = required;
+                       totalBlocks = total;
+                       transferedBlocks = transfered;
+                       this.reliable = reliable;
+               }
+       }
+       
+       protected void setStatus(boolean running, boolean finished, boolean 
successful) {
+               this.running = running;
+               this.finished = ((!running) ? finished : false);
+               this.successful = (finished ? successful : false);
+       }
+       
        /**
+        * Called about each second by the queueManager. Used to make the 
average speed and the ETA
+        * as precise as possible
+        */
+       protected void updateStats()
+       {
+               synchronized(this) {
+                       /* computing average speed & ETA */
+                       
+                       if (completionTime >= 0 && startupTime >= 0 && finished)
+                       { /* wooch, final values ! :) */
+                               long blocks = (insertion) ? totalBlocks : 
requiredBlocks;
+                               long diffTime = (completionTime - startupTime) 
/ 1000;
+                               
+                               if (blocks <= 0 || diffTime <= 0)
+                                       return;
+                               
+                               averageSpeed = (blocks * BLOCK_SIZE) / 
diffTime;                        
+                               ETA = diffTime; /* ok, it's a little bit icky, 
but it does the trick :) */
+                               
+                               return;
+                       }
+                       
+                       
+                       if (!running || finished)
+                               return;
+
+                       if (currentReadCursor != currentWriteCursor) {
+                               /* reminder : we have one second between each 
slot of the *Past arrays */
+                               long diffTimeSec = ((currentWriteCursor < 
currentReadCursor) ? currentWriteCursor+NMB_REMINDERS : currentWriteCursor) - 
currentReadCursor;
+                               long diffBlocks = transferedBlocks - 
transferedBlocksPast[currentReadCursor];
+                               long remainingBlocks = (insertion ? 
(totalBlocks - transferedBlocks) : (requiredBlocks - transferedBlocks));
+                               
+                               if (diffTimeSec <= 0 /* we never know */ || 
diffBlocks <= 0 || remainingBlocks == 0) {
+                                       averageSpeed = 0;
+                                       ETA = 0;
+                               } else {
+                                       double averageSpeedInBlocksPerSecond = 
diffBlocks / diffTimeSec;
+                                       
+                                       averageSpeed = 
(long)(averageSpeedInBlocksPerSecond * (double)BLOCK_SIZE);
+                                       ETA = (long)(((double)remainingBlocks) 
/ averageSpeedInBlocksPerSecond);
+                               }
+                               
+                               if (currentWriteCursor == currentReadCursor-1
+                                               || (currentWriteCursor == 
NMB_REMINDERS-1 && currentReadCursor == 0)) {
+                                       /* the currentWriteCursor will push the 
currentReadCursor */
+                                       currentReadCursor++;
+                                       if (currentReadCursor >= NMB_REMINDERS)
+                                               currentReadCursor = 0;
+                               }
+                               
+                               notifyChange();
+                       }
+
+                       /* updating known values */
+                       
+                       requiredBlocksPast[currentWriteCursor] = requiredBlocks;
+                       totalBlocksPast[currentWriteCursor] = totalBlocks;
+                       transferedBlocksPast[currentWriteCursor] = 
transferedBlocks;
+
+                       currentWriteCursor++;
+                       
+                       if (currentWriteCursor >= NMB_REMINDERS)
+                               currentWriteCursor = 0;
+               }
+       }
+       
+       
+       /**
+        * @return in bytes / s (0 = unknown)
+        */
+       public long getAverageSpeed()
+       {
+               return averageSpeed;
+       }
+       
+       /**
+        * @return in second
+        */
+       public long getETA()
+       {
+               return ETA;
+       }
+
+       /**
+        *  When did the request start ?
+        */
+       public long getStartupTime()
+       {
+               return startupTime;
+       }
+       
+       protected void setStartupTime(long startupTime)
+       {
+               this.startupTime = startupTime;
+       }
+
+       /**
+        * When did the request finish ?
+        * @return -1 if not finished
+        */
+       public long getCompletionTime()
+       {
+               return completionTime;
+       }
+       
+       protected void setCompletionTime(long time)
+       {
+               this.completionTime = time;
+       }
+
+       /**
+        * Informal.
+        * Is about the transfer on the network.
+        * In pourcents.
+        */
+       public int getProgression()
+       {
+               if (finished)
+                       return 100;
+               
+               if (transferedBlocks < 0)
+                       return 0;
+                       
+               if (insertion) {
+                       if (totalBlocks <= 0) return 0;
+                       
+                       return (int)(transferedBlocks * 100 / totalBlocks);
+               } else {
+                       if (requiredBlocks <= 0) return 0;
+                       
+                       return (int)(transferedBlocks * 100 / requiredBlocks);
+               }
+       }
+
+       public boolean isProgressionReliable()
+       {
+               if (getProgression() == 0)
+                       return true;
+
+               return reliable;
+       }
+
+       
+       public boolean isRunning()
+       {
+               return running;
+       }
+
+       public boolean isFinished()
+       {
+               return finished;
+       }
+
+       /**
+        * If unknow, return false.
+        * Query is considered as a failure is isFinished() && !isSuccesful()
+        */
+       public boolean isSuccessful()
+       {
+               return successful;
+       }
+
+       public void notifyChange() {
+               setChanged();
+               notifyObservers();
+       }
+       
+       
+       /**** To implement : ****/
+       
+       
+       
+
+       /**
         * Stop the transfer, but don't consider it as failed.
         * @param queueManager QueueManager gives access to QueryManager;
         */
-       public boolean pause(FCPQueueManager queueManager);
+       public abstract boolean pause(FCPQueueManager queueManager);

+       /**
+        * Should only be called if isFinished() == true && isSuccessful() == 
false
+        */
+       public abstract boolean isFatallyFailed();

        /**
         * Only if persistent. Remove it from the queue.
         */
-       public boolean removeRequest();
+       public abstract boolean removeRequest();

        /**
         * Used by the QueueManager only.
@@ -30,35 +273,25 @@
         * -1 = No priority
         * Always between -1 and 6.
         */
-       public int getThawPriority();
+       public abstract int getThawPriority();

        /**
         * Currently the same than Thaw priority.
         */
-       public int getFCPPriority();
+       public abstract int getFCPPriority();

-       /**
-        *  When did the request start ?
-        */
-       public long getStartupTime();

        /**
-        * When did the request finish ?
-        * @return -1 if not finished
-        */
-       public long getCompletionTime();
-
-       /**
         * call updatePersistentRequest() after to apply the change (Please 
note that the change
         * will be visible even if you don't call it).
         */
-       public void setFCPPriority(int prio);
+       public abstract void setFCPPriority(int prio);

        /**
         * you can call it after saveFileTo() to update the clientToken.
         * @param clientToken tell if the clientToken must be updated or just 
the priority
         */
-       public void updatePersistentRequest(boolean clientToken);
+       public abstract void updatePersistentRequest(boolean clientToken);

        /**
         * Informal.
@@ -66,102 +299,75 @@
         * status of the query.
         * @return can be null (== "Waiting")
         */
-       public String getStatus();
+       public abstract String getStatus();


        /**
         * For persistent request only.
         * @param dir Directory
         */
-       public boolean saveFileTo(String dir);
+       public abstract boolean saveFileTo(String dir);

-       /**
-        * 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();
+       public abstract int getTransferWithTheNodeProgression();

-       /**
-        * @return in bytes / s (0 = unknown)
-        */
-       public long getAverageSpeed();

-       /**
-        * @return in second
-        */
-       public long getETA();

        /**
         * Informal.
         * Gives *public* final key only.
         * @return can be null
         */
-       public String getFileKey();
+       public abstract String getFileKey();

        /**
         * Informal. In bytes.
         * @return can be -1
         */
-       public long getFileSize();
+       public abstract long getFileSize();

        /**
         * Where is the file on the disk.
         */
-       public String getPath();
+       public abstract String getPath();

        /**
         * @return can return -1
         */
-       public int getAttempt();
+       public abstract int getAttempt();

-       public void setAttempt(int x);
+       public abstract void setAttempt(int x);

        /**
         * @return can return -1
         */
-       public int getMaxAttempt();
+       public abstract int getMaxAttempt();

-       public boolean isRunning();

-       public boolean isFinished();
-
        /**
-        * If unknow, return false.
-        * Query is considered as a failure is isFinished() && !isSuccesful()
-        */
-       public boolean isSuccessful();
-       public boolean isFatallyFailed();
-
-       /**
         * Use to save the query in an XML file / a database / whatever.
         * @return A HashMap : String (parameter name) -> String (parameter 
value) or null.
         */
-       public HashMap getParameters();
+       public abstract HashMap getParameters();

        /**
         * Opposite of getParameters().
         * @return true if successful (or ignored) ; false if not.
         */
-       public boolean setParameters(HashMap parameters);
+       public abstract boolean setParameters(HashMap parameters);


-       public boolean isPersistent();
-       public boolean isGlobal();
+       public abstract boolean isPersistent();
+       public abstract boolean isGlobal();

        /**
         * @return can be null (if non active, or meaningless).
         */
-       public String getIdentifier();
+       public abstract String getIdentifier();

-       public String getFilename();
+       public abstract String getFilename();

-       public void notifyChange();
 }

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2008-01-05 
00:11:32 UTC (rev 16900)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2008-01-05 
01:04:36 UTC (rev 16901)
@@ -167,6 +167,7 @@
 thaw.plugin.queueWatcher.downloadFailed=Le t?l?chargement de 'X' a ?chou?
 thaw.plugin.queueWatcher.insertionSuccessful='X' ins?r? avec succ?s
 thaw.plugin.queueWatcher.insertionFailed=L'insertion de 'X' a ?chou?
+thaw.plugin.queueWatcher.totalTime=Temps total:

 thaw.plugin.insert.fileToInsert=Fichier ? ins?rer
 thaw.plugin.insert.filesToInsert=Fichier(s) ? ins?rer

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2008-01-05 00:11:32 UTC 
(rev 16900)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2008-01-05 01:04:36 UTC 
(rev 16901)
@@ -166,8 +166,8 @@
 thaw.plugin.queueWatcher.downloadFailed=Download of 'X' has failed
 thaw.plugin.queueWatcher.insertionSuccessful='X' successfully inserted
 thaw.plugin.queueWatcher.insertionFailed=Insertion of 'X' has failed
+thaw.plugin.queueWatcher.totalTime=Total time:

-
 thaw.plugin.insert.fileToInsert=File to insert
 thaw.plugin.insert.filesToInsert=File(s) to insert
 thaw.plugin.insert.selectKey=Select the kind of key wanted

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2008-01-05 00:11:32 UTC 
(rev 16900)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2008-01-05 01:04:36 UTC 
(rev 16901)
@@ -167,6 +167,7 @@
 thaw.plugin.queueWatcher.downloadFailed=Le t\u00e9l\u00e9chargement de 'X' a 
\u00e9chou\u00e9
 thaw.plugin.queueWatcher.insertionSuccessful='X' ins\u00e9r\u00e9 avec 
succ\u00e8s
 thaw.plugin.queueWatcher.insertionFailed=L'insertion de 'X' a \u00e9chou\u00e9
+thaw.plugin.queueWatcher.totalTime=Temps total:

 thaw.plugin.insert.fileToInsert=Fichier \u00e0 ins\u00e9rer
 thaw.plugin.insert.filesToInsert=Fichier(s) \u00e0 ins\u00e9rer

Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java  2008-01-05 00:11:32 UTC 
(rev 16900)
+++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java  2008-01-05 01:04:36 UTC 
(rev 16901)
@@ -24,12 +24,12 @@
                /* Thaw index */
                "USK at p-uFAWUomLm37MCQLu3r67-B8e6yF1kS4q2v0liM1Vk,"+
                "h0MWqM~lF0Bec-AIv445PLn06ams9-RFbnwO6Cm2Snc,AQACAAE"+
-               "/Thaw/2/Thaw.frdx",
+               "/Thaw/12/Thaw.frdx",

                /* publicly writable index */
                "USK at 61m2WMJEA9pyQQQ-hjGN8lIM2xToNJHyacJ8ZPB9JCQ,"+
                "5aEPJBhwIV~HpGIG8YTpKSB39WCGgd0BUNWZ012745Y,AQACAAE"+
-               "/Publicly%20writable%20index/35/Publicly writable index.frdx"
+               "/Publicly%20writable%20index/102/Publicly writable index.frdx"
        };

        private Core core;

Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java  
2008-01-05 00:11:32 UTC (rev 16900)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java  
2008-01-05 01:04:36 UTC (rev 16901)
@@ -175,7 +175,7 @@
                } else if( ((isForInsertions && (column == 6))
                             || (!isForInsertions && (column == 7)) ) ) {

-                       if (query.isFinished() || 
!query.isProgressionReliable())
+                       if (!query.isProgressionReliable())
                                return "";

                        long remaining = query.getETA();
@@ -183,7 +183,10 @@
                        if (remaining <= 0)
                                return "";

-                       return GUIHelper.getPrintableTime(remaining);
+                       if (!query.isFinished())
+                               return GUIHelper.getPrintableTime(remaining);
+                       else
+                               return 
I18n.getMessage("thaw.plugin.queueWatcher.totalTime") + " 
"+GUIHelper.getPrintableSize(remaining);
                }

                return null;


Reply via email to