From 01f09c10366ac917ca04b3a84ee8a6f430f5586a Mon Sep 17 00:00:00 2001 From: Jim Kellerman Date: Wed, 12 Nov 2008 20:11:31 +0000 Subject: [PATCH] HBASE-602 HBase Crash when network card has a IPv6 address git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@713488 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 ++- .../apache/hadoop/hbase/HServerAddress.java | 1 + .../hbase/master/ProcessServerShutdown.java | 16 ++++++------ .../hadoop/hbase/regionserver/HLog.java | 25 +++++++++++++++++++ .../hbase/regionserver/HRegionServer.java | 5 +--- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6c75e1690a0..f68c823436f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -70,7 +70,8 @@ Release 0.19.0 - Unreleased HBASE-964, HBASE-678 provide for safe-mode without locking up HBase "waiting for root region" HBASE-990 NoSuchElementException in flushSomeRegions - + HBASE-602 HBase Crash when network card has a IPv6 address + IMPROVEMENTS HBASE-901 Add a limit to key length, check key and value length on client side HBASE-890 Alter table operation and also related changes in REST interface diff --git a/src/java/org/apache/hadoop/hbase/HServerAddress.java b/src/java/org/apache/hadoop/hbase/HServerAddress.java index d95e3b5fbaa..cd6a3f39f39 100644 --- a/src/java/org/apache/hadoop/hbase/HServerAddress.java +++ b/src/java/org/apache/hadoop/hbase/HServerAddress.java @@ -30,6 +30,7 @@ import java.net.InetSocketAddress; * HServerAddress is a "label" for a HBase server that combines the host * name and port number. */ +@SuppressWarnings("unchecked") public class HServerAddress implements WritableComparable { private InetSocketAddress address; String stringValue; diff --git a/src/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java b/src/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java index 7cbb9f9bebf..aba38d23862 100644 --- a/src/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java +++ b/src/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java @@ -77,13 +77,8 @@ class ProcessServerShutdown extends RegionServerOperation { this.rootRegionServer = rootRegionServer; this.logSplit = false; this.rootRescanned = false; - StringBuilder dirName = new StringBuilder("log_"); - dirName.append(deadServer.getBindAddress()); - dirName.append("_"); - dirName.append(serverInfo.getStartCode()); - dirName.append("_"); - dirName.append(deadServer.getPort()); - this.oldLogDir = new Path(master.rootdir, dirName.toString()); + this.oldLogDir = + new Path(master.rootdir, HLog.getHLogDirectoryName(serverInfo)); } @Override @@ -257,8 +252,11 @@ class ProcessServerShutdown extends RegionServerOperation { } if (!rootAvailable()) { - // Get root region assigned now that log has been split - master.regionManager.reassignRootRegion(); + if (rootRegionServer) { + // Get root region assigned now that log has been split and if the + // dead server was serving the root region + master.regionManager.reassignRootRegion(); + } // Return true so that worker does not put this request back on the // toDoQueue. diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HLog.java b/src/java/org/apache/hadoop/hbase/regionserver/HLog.java index 3e165762672..b0fe94d1af8 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HLog.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HLog.java @@ -22,6 +22,8 @@ package org.apache.hadoop.hbase.regionserver; import java.io.EOFException; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Collections; import java.util.Map; import java.util.SortedMap; @@ -40,6 +42,7 @@ import org.apache.hadoop.fs.Syncable; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.HServerInfo; import org.apache.hadoop.hbase.HStoreKey; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.RemoteExceptionHandler; @@ -752,6 +755,28 @@ public class HLog implements HConstants, Syncable { LOG.info("log file splitting completed for " + srcDir.toString()); } + /** + * Construct the HLog directory name + * + * @param info HServerInfo for server + * @return the HLog directory name + */ + public static String getHLogDirectoryName(HServerInfo info) { + StringBuilder dirName = new StringBuilder("log_"); + try { + dirName.append(URLEncoder.encode( + info.getServerAddress().getBindAddress(), UTF8_ENCODING)); + } catch (UnsupportedEncodingException e) { + LOG.error("Error encoding '" + info.getServerAddress().getBindAddress() + + "'", e); + } + dirName.append("_"); + dirName.append(info.getStartCode()); + dirName.append("_"); + dirName.append(info.getServerAddress().getPort()); + return dirName.toString(); + } + private static void usage() { System.err.println("Usage: java org.apache.hbase.HLog" + " {--dump ... | --split ...}"); diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index a18c581e111..929be0c8af4 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -585,10 +585,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable { private HLog setupHLog() throws RegionServerRunningException, IOException { - Path logdir = new Path(rootDir, "log" + "_" + - serverInfo.getServerAddress().getBindAddress() + "_" + - this.serverInfo.getStartCode() + "_" + - this.serverInfo.getServerAddress().getPort()); + Path logdir = new Path(rootDir, HLog.getHLogDirectoryName(serverInfo)); if (LOG.isDebugEnabled()) { LOG.debug("Log dir " + logdir); }