You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2016/01/26 11:05:03 UTC

svn commit: r1726758 - in /qpid/java/branches/6.0.x: ./ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java

Author: kwall
Date: Tue Jan 26 10:05:03 2016
New Revision: 1726758

URL: http://svn.apache.org/viewvc?rev=1726758&view=rev
Log:
QPID-7021: [Java Broker] BDB backup - copy from the consistent set of file handle, rather than trying to open another

Merged from trunk with command:

svn merge -c 1726646,1726755 ^/qpid/java/trunk

svn merge -c 1726646,1726755 ^/qpid/java/trunk

Modified:
    qpid/java/branches/6.0.x/   (props changed)
    qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java

Propchange: qpid/java/branches/6.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 10:05:03 2016
@@ -9,5 +9,5 @@
 /qpid/branches/java-broker-vhost-refactor/java:1493674-1494547
 /qpid/branches/java-network-refactor/qpid/java:805429-821809
 /qpid/branches/qpid-2935/qpid/java:1061302-1072333
-/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720664,1721151,1721198,1722019,1722246,1722339,1723064,1723194,1723563,1724216,1724251,1724257,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295,1725569,1726244,1726246,1726358,1726436,1726449,1726456,1726653
+/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720664,1721151,1721198,1722019,1722246,1722339,1723064,1723194,1723563,1724216,1724251,1724257,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295,1725569,1726244,1726246,1726358,1726436,1726449,1726456,1726646,1726653,1726755
 /qpid/trunk/qpid:796646-796653

Modified: qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java?rev=1726758&r1=1726757&r2=1726758&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java (original)
+++ qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java Tue Jan 26 10:05:03 2016
@@ -25,6 +25,8 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FilenameFilter;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Properties;
@@ -68,7 +70,7 @@ import org.apache.qpid.util.FileUtils;
  * backup as a standalone utility against log files, when a broker is not running, using the {@link #takeBackup(String,
  *String,com.sleepycat.je.Environment)} method.
  * <p>
- * A seperate backup machanism is provided by the {@link #takeBackupNoLock(String,String)} method which can take a
+ * A separate backup machanism is provided by the {@link #takeBackupNoLock(String,String)} method which can take a
  * hot backup against a running broker. This works by finding out the set of files to copy, and then opening them all to
  * read, and repeating this process until a consistent set of open files is obtained. This is done to avoid the
  * situation where the BDB cleanup thread deletes a file, between the directory listing and opening of the file to copy.
@@ -94,7 +96,7 @@ public class BDBBackup
             { "todir", "The path to the directory to save the backed up bdb log files to.", "dir", "true" }
         };
 
-    /** Defines the timeout to terminate the backup operation on if it fails to complete. One minte. */
+    /** Defines the timeout to terminate the backup operation on if it fails to complete. One minute. */
     public static final long TIMEOUT = 60000;
 
     /**
@@ -243,13 +245,17 @@ public class BDBBackup
                         }
                     });
 
+            if (fileSet == null || fileSet.length == 0)
+            {
+                throw new StoreException("There are no BDB log files to backup in the '" + fromdir + "' directory.");
+            }
+
+            // The files must be copied in alphabetical order (numerical in effect)
+            Arrays.sort(fileSet);
+
             // Open them all for reading.
             fileInputStreams = new FileInputStream[fileSet.length];
 
-            if (fileSet.length == 0)
-            {
-                throw new StoreException("There are no BDB log files to backup in the " + fromdir + " directory.");
-            }
 
             for (int i = 0; i < fileSet.length; i++)
             {
@@ -280,7 +286,7 @@ public class BDBBackup
                     break;
                 }
 
-                // A consistent set has been opened if all files were sucesfully opened for reading.
+                // A consistent set has been opened if all files were successfully opened for reading.
                 if (i == (fileSet.length - 1))
                 {
                     consistentSet = true;
@@ -303,19 +309,11 @@ public class BDBBackup
             File destFile = new File(todir + File.separator + fileSet[j].getName());
             try
             {
-                FileUtils.copy(fileSet[j], destFile);
+                Files.copy(fileInputStreams[j], destFile.toPath());
             }
-            catch (RuntimeException re)
+            catch (IOException ioe)
             {
-                Throwable cause = re.getCause();
-                if ((cause != null) && (cause instanceof IOException))
-                {
-                    throw new StoreException(re.getMessage() + " fromDir:" + fromdir + " toDir:" + toDirFile, cause);
-                }
-                else
-                {
-                    throw re;
-                }
+                throw new StoreException(ioe.getMessage() + " fromDir:" + fromdir + " toDir:" + toDirFile, ioe);
             }
 
             backedUpFileNames.add(destFile.getName());



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org