HBASE-8867 HLogUtils#getServerNameFromHLogDirectoryName does not take into account the -splitting extension
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1499923 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b12a1c3e1b
commit
2f6599ef01
|
@ -159,14 +159,8 @@ public class HLogUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String serverName = serverNameAndFile.substring(0,
|
Path p = new Path(path);
|
||||||
serverNameAndFile.indexOf('/') - 1);
|
return getServerNameFromHLogDirectoryName(p);
|
||||||
|
|
||||||
if (!ServerName.isFullServerName(serverName)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ServerName.parseServerName(serverName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -704,24 +704,31 @@ public class TestHLog {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetServerNameFromHLogDirectoryName() throws IOException {
|
public void testGetServerNameFromHLogDirectoryName() throws IOException {
|
||||||
String hl = FSUtils.getRootDir(conf) + "/"+
|
ServerName sn = new ServerName("hn", 450, 1398);
|
||||||
HLogUtil.getHLogDirectoryName(new ServerName("hn", 450, 1398).toString());
|
String hl = FSUtils.getRootDir(conf) + "/" + HLogUtil.getHLogDirectoryName(sn.toString());
|
||||||
|
|
||||||
// Must not throw exception
|
// Must not throw exception
|
||||||
Assert.assertNull(HLogUtil.getServerNameFromHLogDirectoryName(conf, null));
|
Assert.assertNull(HLogUtil.getServerNameFromHLogDirectoryName(conf, null));
|
||||||
Assert.assertNull(HLogUtil.getServerNameFromHLogDirectoryName(conf,
|
Assert.assertNull(HLogUtil.getServerNameFromHLogDirectoryName(conf,
|
||||||
FSUtils.getRootDir(conf).toUri().toString()));
|
FSUtils.getRootDir(conf).toUri().toString()));
|
||||||
Assert.assertNull( HLogUtil.getServerNameFromHLogDirectoryName(conf, "") );
|
Assert.assertNull(HLogUtil.getServerNameFromHLogDirectoryName(conf, ""));
|
||||||
Assert.assertNull( HLogUtil.getServerNameFromHLogDirectoryName(conf, " ") );
|
Assert.assertNull(HLogUtil.getServerNameFromHLogDirectoryName(conf, " "));
|
||||||
Assert.assertNull( HLogUtil.getServerNameFromHLogDirectoryName(conf, hl) );
|
Assert.assertNull(HLogUtil.getServerNameFromHLogDirectoryName(conf, hl));
|
||||||
Assert.assertNull( HLogUtil.getServerNameFromHLogDirectoryName(conf, hl+"qdf") );
|
Assert.assertNull(HLogUtil.getServerNameFromHLogDirectoryName(conf, hl + "qdf"));
|
||||||
Assert.assertNull( HLogUtil.getServerNameFromHLogDirectoryName(conf, "sfqf"+hl+"qdf") );
|
Assert.assertNull(HLogUtil.getServerNameFromHLogDirectoryName(conf, "sfqf" + hl + "qdf"));
|
||||||
|
|
||||||
Assert.assertNotNull( HLogUtil.getServerNameFromHLogDirectoryName(conf,
|
ServerName parsed = HLogUtil.getServerNameFromHLogDirectoryName(conf,
|
||||||
FSUtils.getRootDir(conf).toUri().toString() +
|
FSUtils.getRootDir(conf).toUri().toString() +
|
||||||
"/.logs/localhost,32984,1343316388997/localhost%2C32984%2C1343316388997.1343316390417"
|
"/.logs/" + sn + "/localhost%2C32984%2C1343316388997.1343316390417");
|
||||||
));
|
Assert.assertEquals("standard", sn, parsed);
|
||||||
Assert.assertNotNull( HLogUtil.getServerNameFromHLogDirectoryName(conf, hl+"/qdf") );
|
|
||||||
|
parsed = HLogUtil.getServerNameFromHLogDirectoryName(conf, hl + "/qdf");
|
||||||
|
Assert.assertEquals("subdir", sn, parsed);
|
||||||
|
|
||||||
|
parsed = HLogUtil.getServerNameFromHLogDirectoryName(conf,
|
||||||
|
FSUtils.getRootDir(conf).toUri().toString() +
|
||||||
|
"/.logs/" + sn + "-splitting/localhost%3A57020.1340474893931");
|
||||||
|
Assert.assertEquals("split", sn, parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue