You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2013/08/15 07:35:06 UTC
svn commit: r1514162 - in /hbase/branches/0.95:
hbase-client/src/main/java/org/apache/hadoop/hbase/
hbase-server/src/main/java/org/apache/hadoop/hbase/util/
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/
Author: stack
Date: Thu Aug 15 05:35:05 2013
New Revision: 1514162
URL: http://svn.apache.org/r1514162
Log:
HBASE-9177 Cluster UUID is not properly parsable after rewriting to PB.
Modified:
hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterId.java
hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestClusterId.java
Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterId.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterId.java?rev=1514162&r1=1514161&r2=1514162&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterId.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterId.java Thu Aug 15 05:35:05 2013
@@ -43,7 +43,7 @@ public class ClusterId {
this(UUID.randomUUID().toString());
}
- ClusterId(final String uuid) {
+ public ClusterId(final String uuid) {
this.id = uuid;
}
Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1514162&r1=1514161&r2=1514162&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java Thu Aug 15 05:35:05 2013
@@ -711,7 +711,19 @@ public abstract class FSUtils {
throw new IOException("content=" + Bytes.toString(content), e);
}
// If not pb'd, make it so.
- if (!ProtobufUtil.isPBMagicPrefix(content)) rewriteAsPb(fs, rootdir, idPath, clusterId);
+ if (!ProtobufUtil.isPBMagicPrefix(content)) {
+ String cid = new String();
+ in = fs.open(idPath);
+ try {
+ cid = in.readUTF();
+ clusterId = new ClusterId(cid);
+ } catch (EOFException eof) {
+ LOG.warn("Cluster ID file " + idPath.toString() + " was empty");
+ } finally {
+ in.close();
+ }
+ rewriteAsPb(fs, rootdir, idPath, clusterId);
+ }
return clusterId;
} else {
LOG.warn("Cluster ID file does not exist at " + idPath.toString());
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestClusterId.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestClusterId.java?rev=1514162&r1=1514161&r2=1514162&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestClusterId.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestClusterId.java Thu Aug 15 05:35:05 2013
@@ -21,11 +21,19 @@ package org.apache.hadoop.hbase.regionse
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.util.UUID;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MediumTests;
+import org.apache.hadoop.hbase.master.HMaster;
+import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
import org.junit.After;
@@ -84,5 +92,29 @@ public class TestClusterId {
assertNotNull(clusterId);
assertEquals(clusterId, rst.getRegionServer().getClusterId());
}
+
+ @Test
+ public void testRewritingClusterIdToPB() throws Exception {
+ TEST_UTIL.startMiniZKCluster();
+ TEST_UTIL.startMiniDFSCluster(1);
+ TEST_UTIL.createRootDir();
+ TEST_UTIL.getConfiguration().setBoolean("hbase.replication", true);
+ Path rootDir = FSUtils.getRootDir(TEST_UTIL.getConfiguration());
+ FileSystem fs = rootDir.getFileSystem(TEST_UTIL.getConfiguration());
+ Path filePath = new Path(rootDir, HConstants.CLUSTER_ID_FILE_NAME);
+ FSDataOutputStream s = null;
+ try {
+ s = fs.create(filePath);
+ s.writeUTF(UUID.randomUUID().toString());
+ } finally {
+ if (s != null) {
+ s.close();
+ }
+ }
+ TEST_UTIL.startMiniHBaseCluster(1, 1);
+ HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
+ assertEquals(1, master.getServerManager().getOnlineServersList().size());
+ }
+
}