HBASE-451 getTableInfoPath() should be called in FSUtils.getTableInfoModtime()
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1147043 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cdc62bf6ed
commit
fdd0d9f3e3
|
@ -884,7 +884,7 @@ public class FSUtils {
|
||||||
public static long getTableInfoModtime(final FileSystem fs, final Path rootdir,
|
public static long getTableInfoModtime(final FileSystem fs, final Path rootdir,
|
||||||
final String tablename)
|
final String tablename)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Path p = getTablePath(rootdir, tablename);
|
Path p = getTableInfoPath(rootdir, tablename);
|
||||||
FileStatus [] status = fs.listStatus(p);
|
FileStatus [] status = fs.listStatus(p);
|
||||||
if (status.length < 1) throw new FileNotFoundException("No status for " + p.toString());
|
if (status.length < 1) throw new FileNotFoundException("No status for " + p.toString());
|
||||||
return status[0].getModificationTime();
|
return status[0].getModificationTime();
|
||||||
|
|
|
@ -22,6 +22,8 @@ import static org.junit.Assert.*;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
|
@ -40,6 +42,7 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class TestFSTableDescriptors {
|
public class TestFSTableDescriptors {
|
||||||
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
|
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
|
||||||
|
private static final Log LOG = LogFactory.getLog(TestFSTableDescriptors.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoves() throws IOException {
|
public void testRemoves() throws IOException {
|
||||||
|
@ -75,7 +78,7 @@ public class TestFSTableDescriptors {
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
final String name = "testHTableDescriptors";
|
final String name = "testHTableDescriptors";
|
||||||
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
|
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
|
||||||
// Cleanup old tests if any detrius laying around.
|
// Cleanup old tests if any debris laying around.
|
||||||
Path rootdir = new Path(HBaseTestingUtility.getTestDir(), name);
|
Path rootdir = new Path(HBaseTestingUtility.getTestDir(), name);
|
||||||
final int count = 10;
|
final int count = 10;
|
||||||
// Write out table infos.
|
// Write out table infos.
|
||||||
|
@ -87,7 +90,7 @@ public class TestFSTableDescriptors {
|
||||||
@Override
|
@Override
|
||||||
public HTableDescriptor get(byte[] tablename)
|
public HTableDescriptor get(byte[] tablename)
|
||||||
throws TableExistsException, FileNotFoundException, IOException {
|
throws TableExistsException, FileNotFoundException, IOException {
|
||||||
System.out.println(Bytes.toString(tablename) + ", cachehits=" + this.cachehits);
|
LOG.info(Bytes.toString(tablename) + ", cachehits=" + this.cachehits);
|
||||||
return super.get(tablename);
|
return super.get(tablename);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -97,14 +100,14 @@ public class TestFSTableDescriptors {
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
assertTrue(htds.get(Bytes.toBytes(name + i)) != null);
|
assertTrue(htds.get(Bytes.toBytes(name + i)) != null);
|
||||||
}
|
}
|
||||||
// Wait a while so mod time we write is for sure different.
|
|
||||||
Thread.sleep(1000);
|
|
||||||
// Update the table infos
|
// Update the table infos
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
HTableDescriptor htd = new HTableDescriptor(name + i);
|
HTableDescriptor htd = new HTableDescriptor(name + i);
|
||||||
htd.addFamily(new HColumnDescriptor("" + i));
|
htd.addFamily(new HColumnDescriptor("" + i));
|
||||||
FSUtils.updateHTableDescriptor(fs, rootdir, htd);
|
FSUtils.updateHTableDescriptor(fs, rootdir, htd);
|
||||||
}
|
}
|
||||||
|
// Wait a while so mod time we write is for sure different.
|
||||||
|
Thread.sleep(100);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
assertTrue(htds.get(Bytes.toBytes(name + i)) != null);
|
assertTrue(htds.get(Bytes.toBytes(name + i)) != null);
|
||||||
}
|
}
|
||||||
|
@ -113,7 +116,7 @@ public class TestFSTableDescriptors {
|
||||||
}
|
}
|
||||||
assertEquals(count * 4, htds.invocations);
|
assertEquals(count * 4, htds.invocations);
|
||||||
assertTrue("expected=" + (count * 2) + ", actual=" + htds.cachehits,
|
assertTrue("expected=" + (count * 2) + ", actual=" + htds.cachehits,
|
||||||
htds.cachehits >= (count * 2));
|
htds.cachehits == (count * 2));
|
||||||
assertTrue(htds.get(HConstants.ROOT_TABLE_NAME) != null);
|
assertTrue(htds.get(HConstants.ROOT_TABLE_NAME) != null);
|
||||||
assertEquals(htds.invocations, count * 4 + 1);
|
assertEquals(htds.invocations, count * 4 + 1);
|
||||||
assertTrue("expected=" + ((count * 2) + 1) + ", actual=" + htds.cachehits,
|
assertTrue("expected=" + ((count * 2) + 1) + ", actual=" + htds.cachehits,
|
||||||
|
|
Loading…
Reference in New Issue