accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject svn commit: r1438700 - in /accumulo/trunk: core/src/main/java/org/apache/accumulo/core/Constants.java server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java
Date Fri, 25 Jan 2013 20:56:12 GMT
Author: ctubbsii
Date: Fri Jan 25 20:56:12 2013
New Revision: 1438700

URL: http://svn.apache.org/viewvc?rev=1438700&view=rev
Log:
ACCUMULO-751 Switched from using the release version to an explicit wire version for on-the-wire
compatibility. This will need to be manually updated when
thrift code changes between versions, or when interoperability is not possible between versions
due to functional differences.

Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/Constants.java
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/Constants.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/Constants.java?rev=1438700&r1=1438699&r2=1438700&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/Constants.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/Constants.java Fri Jan 25 20:56:12
2013
@@ -16,6 +16,8 @@
  */
 package org.apache.accumulo.core;
 
+import java.nio.charset.Charset;
+
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.Key;
@@ -28,7 +30,11 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
 
 public class Constants {
+  public static final Charset UTF8 = Charset.forName("UTF-8");
   public static final String VERSION = "1.5.0-SNAPSHOT";
+  
+  // versions should never be negative
+  public static final Integer WIRE_VERSION = 2;
   public static final int DATA_VERSION = 4;
   public static final int PREV_DATA_VERSION = 3;
   
@@ -75,7 +81,7 @@ public class Constants {
   public static final String ZNEXT_FILE = "/next_file";
   
   public static final String ZBULK_FAILED_COPYQ = "/bulk_failed_copyq";
-
+  
   public static final String ZHDFS_RESERVATIONS = "/hdfs_reservations";
   public static final String ZRECOVERY = "/recovery";
   
@@ -164,7 +170,7 @@ public class Constants {
   public static final String EXPORT_TABLE_CONFIG_FILE = "table_config.txt";
   public static final String EXPORT_FILE = "exportMetadata.zip";
   public static final String EXPORT_INFO_FILE = "accumulo_export_info.txt";
-
+  
   public static String getBaseDir(final AccumuloConfiguration conf) {
     return conf.get(Property.INSTANCE_DFS_DIR);
   }

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java?rev=1438700&r1=1438699&r2=1438700&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java
Fri Jan 25 20:56:12 2013
@@ -60,19 +60,18 @@ public class SecurityConstants {
   }
   
   private static byte[] makeSystemPassword() {
-    byte[] version = Constants.VERSION.getBytes();
-    byte[] inst = HdfsZooInstance.getInstance().getInstanceID().getBytes();
+    int wireVersion = Constants.WIRE_VERSION;
+    byte[] inst = HdfsZooInstance.getInstance().getInstanceID().getBytes(Constants.UTF8);
     try {
       confChecksum = getSystemConfigChecksum();
     } catch (NoSuchAlgorithmException e) {
       throw new RuntimeException("Failed to compute configuration checksum", e);
     }
     
-    ByteArrayOutputStream bytes = new ByteArrayOutputStream(3 * (Integer.SIZE / Byte.SIZE)
+ version.length + inst.length + confChecksum.length);
+    ByteArrayOutputStream bytes = new ByteArrayOutputStream(3 * (Integer.SIZE / Byte.SIZE)
+ inst.length + confChecksum.length);
     DataOutputStream out = new DataOutputStream(bytes);
     try {
-      out.write(version.length);
-      out.write(version);
+      out.write(wireVersion * -1);
       out.write(inst.length);
       out.write(inst);
       out.write(confChecksum.length);
@@ -101,12 +100,10 @@ public class SecurityConstants {
     ByteArrayInputStream bytes = new ByteArrayInputStream(decodedPassword);
     DataInputStream in = new DataInputStream(bytes);
     try {
+      versionFails = in.readInt() * -1 != Constants.WIRE_VERSION;
       byte[] buff = new byte[in.readInt()];
       in.readFully(buff);
-      versionFails = !Arrays.equals(buff, Constants.VERSION.getBytes());
-      buff = new byte[in.readInt()];
-      in.readFully(buff);
-      instanceFails = !Arrays.equals(buff, HdfsZooInstance.getInstance().getInstanceID().getBytes());
+      instanceFails = !Arrays.equals(buff, HdfsZooInstance.getInstance().getInstanceID().getBytes(Constants.UTF8));
       buff = new byte[in.readInt()];
       in.readFully(buff);
       confFails = !Arrays.equals(buff, getSystemConfigChecksum());
@@ -137,14 +134,14 @@ public class SecurityConstants {
       
       // seed the config with the version and instance id, so at least
       // it's not empty
-      md.update(Constants.VERSION.getBytes());
-      md.update(HdfsZooInstance.getInstance().getInstanceID().getBytes());
+      md.update(Constants.WIRE_VERSION.toString().getBytes(Constants.UTF8));
+      md.update(HdfsZooInstance.getInstance().getInstanceID().getBytes(Constants.UTF8));
       
       for (Entry<String,String> entry : ServerConfiguration.getSiteConfiguration())
{
         // only include instance properties
         if (entry.getKey().startsWith(Property.INSTANCE_PREFIX.toString())) {
-          md.update(entry.getKey().getBytes());
-          md.update(entry.getValue().getBytes());
+          md.update(entry.getKey().getBytes(Constants.UTF8));
+          md.update(entry.getValue().getBytes(Constants.UTF8));
         }
       }
       



Mime
View raw message