zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject svn commit: r706686 - in /hadoop/zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java
Date Tue, 21 Oct 2008 17:30:07 GMT
Author: phunt
Date: Tue Oct 21 10:30:07 2008
New Revision: 706686

URL: http://svn.apache.org/viewvc?rev=706686&view=rev
Log:
ZOOKEEPER-200. the magic number for snapshot and log must be different

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=706686&r1=706685&r2=706686&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Tue Oct 21 10:30:07 2008
@@ -35,6 +35,9 @@
 
   BUGFIXES: 
 
+  ZOOKEEPER-200. the magic number for snapshot and log must be different
+  (currently same) (phunt)
+
   ZOOKEEPER-199. fix log messages in persistence code (mahadev via phunt)
 
   ZOOKEEPER-197. create checksums for snapshots (mahadev via phunt)

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java?rev=706686&r1=706685&r2=706686&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java
(original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileSnap.java
Tue Oct 21 10:30:07 2008
@@ -51,11 +51,12 @@
     private static final int VERSION=2;
     private static final long dbId=-1;
     private static final Logger LOG = Logger.getLogger(FileSnap.class);
-    public final static int MAGIC = ByteBuffer.wrap("AK47".getBytes()).getInt();
+    public final static int SNAP_MAGIC
+        = ByteBuffer.wrap("ZKSN".getBytes()).getInt();
     public FileSnap(File snapDir) {
         this.snapDir = snapDir;
     }
-    
+
     /**
      * deserialize a data tree from the most recent snapshot
      * @return the zxid of the snapshot
@@ -81,7 +82,7 @@
         dt.lastProcessedZxid = Util.getZxidFromName(snap.getName(), "snapshot");
         return dt.lastProcessedZxid;
     }
-    
+
     /**
      * deserialize the datatree from an inputarchive
      * @param dt the datatree to be serialized into
@@ -95,7 +96,7 @@
         header.deserialize(ia, "fileheader");
         SerializeUtils.deserializeSnapshot(dt,ia,sessions);
     }
-    
+
     /**
      * find the most recent snapshot in the database.
      * @return the file containing the most recent snapshot
@@ -119,7 +120,7 @@
      */
     protected void serialize(DataTree dt,Map<Long, Integer> sessions,
             OutputArchive oa, FileHeader header) throws IOException {
-        // this is really a programmatic error and not something that can 
+        // this is really a programmatic error and not something that can
         // happen at runtime
         if(header==null)
             throw new IllegalStateException(
@@ -127,7 +128,7 @@
         header.serialize(oa, "fileheader");
         SerializeUtils.serializeSnapshot(dt,oa,sessions);
     }
-    
+
     /**
      * serialize the datatree and session into the file snapshot
      * @param dt the datatree to be serialized
@@ -140,7 +141,7 @@
         CheckedOutputStream crcOut = new CheckedOutputStream(sessOS, new Adler32());
         //CheckedOutputStream cout = new CheckedOutputStream()
         OutputArchive oa = BinaryOutputArchive.getArchive(crcOut);
-        FileHeader header = new FileHeader(MAGIC, VERSION, dbId);
+        FileHeader header = new FileHeader(SNAP_MAGIC, VERSION, dbId);
         serialize(dt,sessions,oa, header);
         long val = crcOut.getChecksum().getValue();
         oa.writeLong(val, "val");
@@ -149,5 +150,5 @@
         crcOut.close();
         sessOS.close();
     }
-   
+
  }
\ No newline at end of file

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java?rev=706686&r1=706685&r2=706686&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java
(original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java
Tue Oct 21 10:30:07 2008
@@ -53,7 +53,8 @@
     volatile OutputArchive oa;
     
     File logDir;
-    public final static int MAGIC = ByteBuffer.wrap("AK47".getBytes()).getInt();
+    public final static int TXNLOG_MAGIC =
+        ByteBuffer.wrap("ZKLG".getBytes()).getInt();
     public final static int VERSION = 2;
     private boolean forceSync = true;
     long dbId;
@@ -127,7 +128,7 @@
                        Long.toHexString(hdr.getZxid())));
                logStream=new FileOutputStream(logFileWrite);
                oa = BinaryOutputArchive.getArchive(logStream);
-               FileHeader fhdr = new FileHeader(MAGIC,VERSION, dbId);
+               FileHeader fhdr = new FileHeader(TXNLOG_MAGIC,VERSION, dbId);
                fhdr.serialize(oa, "fileheader");
                currentSize = logStream.getChannel().position();
                streamsToFlush.add(logStream);



Mime
View raw message