[Jboss-cvs] JBossAS SVN: r55901 - trunk/cluster/src/main/org/jboss/ha/framework/server

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 14 11:33:51 EDT 2006


Author: scottmarlownovell
Date: 2006-08-14 11:33:50 -0400 (Mon, 14 Aug 2006)
New Revision: 55901

Modified:
   trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterFileTransfer.java
   trunk/cluster/src/main/org/jboss/ha/framework/server/FarmMemberService.java
Log:
Handle farm deployments where the temp folder is on a different file
system than the farm folder.


Modified: trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterFileTransfer.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterFileTransfer.java	2006-08-14 15:13:31 UTC (rev 55900)
+++ trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterFileTransfer.java	2006-08-14 15:33:50 UTC (rev 55901)
@@ -139,9 +139,9 @@
 
          }
          tempFile.setLastModified(lastModification);
-         if (!tempFile.renameTo(target))
+         if (!localMove(tempFile,target))
          {
-            throw new ClusterFileTransferException("Could not rename " + tempFile + " to " + target);
+            throw new ClusterFileTransferException("Could not move " + tempFile + " to " + target);
          }
          log.info("Finished cluster pull of file " + file.getName() + " to "+ target.getName());
       }
@@ -334,9 +334,9 @@
                      logMessage("Could not delete target file " + target);
 
                tempFile.setLastModified(fileChunk.lastModified());
-               if (!tempFile.renameTo(target))
+               if (!localMove(tempFile,target))
                {
-                  logMessage("Could not rename " + tempFile + " to " + target);
+                  logMessage("Could not move " + tempFile + " to " + target);
                }
             }
          }
@@ -615,6 +615,27 @@
       private int mByteCount;
    }
 
+   public static boolean localMove(File source, File destination) throws FileNotFoundException, IOException {
+      if(source.renameTo(destination))  // if we can simply rename the file
+         return true;                   // return success
+      // otherwise, copy source to destination
+      OutputStream out = new FileOutputStream(destination);
+      InputStream in = new FileInputStream(source);
+      byte buffer[] = new byte[32*1024];
+      int bytesRead = 0;
+      while(bytesRead > -1) {  // until we hit end of source file
+         bytesRead = in.read(buffer);
+         if(bytesRead > 0) {
+            out.write(buffer,0, bytesRead);
+         }
+      }
+      in.close();
+      out.close();
+      if(!source.delete())
+         logMessage("Could not delete file "+ source);
+      return true;
+   }
+
    /**
     * Exception wrapper class
     */

Modified: trunk/cluster/src/main/org/jboss/ha/framework/server/FarmMemberService.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/FarmMemberService.java	2006-08-14 15:13:31 UTC (rev 55900)
+++ trunk/cluster/src/main/org/jboss/ha/framework/server/FarmMemberService.java	2006-08-14 15:33:50 UTC (rev 55901)
@@ -167,6 +167,7 @@
                "HAPartition"
             );
          }
+         
          lHAPartition.registerRPCHandler( SERVICE_NAME, this );
 
          mFileTransfer = new ClusterFileTransfer(lHAPartition, buildParentFolderMapping());
@@ -340,9 +341,9 @@
             }
             tempFile.setLastModified( date.getTime() );
 
-            if(! tempFile.renameTo( lFarmFile ))
+            if(! ClusterFileTransfer.localMove(tempFile,lFarmFile ))
             {
-               log.info("Could not rename "+tempFile+" to " + lFarmFile);
+               log.info("Could not move "+tempFile+" to " + lFarmFile);
             }
          }
          else




More information about the jboss-cvs-commits mailing list