HBASE-17677 ServerName parsing from directory name should be more robust to errors from guava's HostAndPort

Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
Sean Busbey 2017-02-22 13:31:51 -06:00
parent 0285cb8c4d
commit 040b2f186a
2 changed files with 16 additions and 1 deletions

View File

@ -346,7 +346,7 @@ public abstract class AbstractFSWALProvider<T extends AbstractFSWAL<?>> implemen
}
try {
serverName = ServerName.parseServerName(logDirName);
} catch (IllegalArgumentException ex) {
} catch (IllegalArgumentException|IllegalStateException ex) {
serverName = null;
LOG.warn("Cannot parse a server name from path=" + logFile + "; " + ex.getMessage());
}

View File

@ -34,6 +34,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValueTestUtil;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
// imports for things that haven't moved from regionserver.wal yet.
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
@ -58,6 +59,20 @@ public class TestWALMethods {
private final HBaseTestingUtility util = new HBaseTestingUtility();
@Test
public void testServerNameFromWAL() throws Exception {
Path walPath = new Path("/hbase/WALs/regionserver-2.example.com,22101,1487767381290", "regionserver-2.example.com%2C22101%2C1487767381290.null0.1487785392316");
ServerName name = AbstractFSWALProvider.getServerNameFromWALDirectoryName(walPath);
assertEquals(ServerName.valueOf("regionserver-2.example.com", 22101, 1487767381290L), name);
}
@Test
public void testServerNameFromTestWAL() throws Exception {
Path walPath = new Path("/user/example/test-data/12ff1404-68c6-4715-a4b9-775e763842bc/WALs/TestWALRecordReader", "TestWALRecordReader.default.1487787939118");
ServerName name = AbstractFSWALProvider.getServerNameFromWALDirectoryName(walPath);
assertNull(name);
}
/**
* Assert that getSplitEditFilesSorted returns files in expected order and
* that it skips moved-aside files.