Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
import org.apache.hadoop.hbase.tool.BulkLoadHFiles;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
Expand Down Expand Up @@ -360,6 +361,10 @@ public static <T> Long getMinValue(Map<T, Long> map) {
* @return host name
*/
public static String parseHostFromOldLog(Path p) {
// Skip master wals
if (p.getName().endsWith(MasterRegionFactory.ARCHIVED_WAL_SUFFIX)) {
return null;
}
try {
String n = p.getName();
int idx = n.lastIndexOf(LOGNAME_SEPARATOR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.backup.util.BackupUtils;
import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Addressing;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.security.UserGroupInformation;
import org.junit.Assert;
import org.junit.ClassRule;
Expand All @@ -45,7 +51,7 @@ public class TestBackupUtils {
protected static Configuration conf = TEST_UTIL.getConfiguration();

@Test
public void TestGetBulkOutputDir() {
public void testGetBulkOutputDir() {
// Create a user who is not the current user
String fooUserName = "foo1234";
String fooGroupName = "group1";
Expand Down Expand Up @@ -78,4 +84,24 @@ public Path run() {
// Make sure the directory is in foo1234's home directory
Assert.assertTrue(bulkOutputDir.toString().startsWith(fooHomeDirectory.toString()));
}

@Test
public void testFilesystemWalHostNameParsing() throws IOException {
String host = "localhost";
int port = 60030;
ServerName serverName = ServerName.valueOf(host, port, 1234);
Path walRootDir = CommonFSUtils.getWALRootDir(conf);
Path oldLogDir = new Path(walRootDir, HConstants.HREGION_OLDLOGDIR_NAME);

Path testWalPath = new Path(oldLogDir,
serverName.toString() + BackupUtils.LOGNAME_SEPARATOR + EnvironmentEdgeManager.currentTime());
Path testMasterWalPath =
new Path(oldLogDir, testWalPath.getName() + MasterRegionFactory.ARCHIVED_WAL_SUFFIX);

String parsedHost = BackupUtils.parseHostFromOldLog(testMasterWalPath);
Assert.assertNull(parsedHost);

parsedHost = BackupUtils.parseHostFromOldLog(testWalPath);
Assert.assertEquals(parsedHost, host + Addressing.HOSTNAME_PORT_SEPARATOR + port);
}
}