Skip to content

Commit

Permalink
HBASE-451 getTableInfoPath() should be called in FSUtils.getTableInfo…
Browse files Browse the repository at this point in the history
…Modtime()

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1147043 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Zhihong Yu committed Jul 15, 2011
1 parent 619596f commit 7406d29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
Expand Up @@ -884,7 +884,7 @@ private static Path getTableInfoPath(Path rootdir, String tablename) {
public static long getTableInfoModtime(final FileSystem fs, final Path rootdir,
final String tablename)
throws IOException {
Path p = getTablePath(rootdir, tablename);
Path p = getTableInfoPath(rootdir, tablename);
FileStatus [] status = fs.listStatus(p);
if (status.length < 1) throw new FileNotFoundException("No status for " + p.toString());
return status[0].getModificationTime();
Expand Down
Expand Up @@ -22,6 +22,8 @@
import java.io.FileNotFoundException;
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.Path;
import org.apache.hadoop.hbase.HBaseTestingUtility;
Expand All @@ -40,6 +42,7 @@
*/
public class TestFSTableDescriptors {
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static final Log LOG = LogFactory.getLog(TestFSTableDescriptors.class);

@Test
public void testRemoves() throws IOException {
Expand Down Expand Up @@ -75,7 +78,7 @@ private void createHTDInFS(final FileSystem fs, Path rootdir,
throws IOException, InterruptedException {
final String name = "testHTableDescriptors";
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);
final int count = 10;
// Write out table infos.
Expand All @@ -87,7 +90,7 @@ private void createHTDInFS(final FileSystem fs, Path rootdir,
@Override
public HTableDescriptor get(byte[] tablename)
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);
}
};
Expand All @@ -97,14 +100,14 @@ public HTableDescriptor get(byte[] tablename)
for (int i = 0; i < count; i++) {
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
for (int i = 0; i < count; i++) {
HTableDescriptor htd = new HTableDescriptor(name + i);
htd.addFamily(new HColumnDescriptor("" + i));
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++) {
assertTrue(htds.get(Bytes.toBytes(name + i)) != null);
}
Expand All @@ -113,7 +116,7 @@ public HTableDescriptor get(byte[] tablename)
}
assertEquals(count * 4, htds.invocations);
assertTrue("expected=" + (count * 2) + ", actual=" + htds.cachehits,
htds.cachehits >= (count * 2));
htds.cachehits == (count * 2));
assertTrue(htds.get(HConstants.ROOT_TABLE_NAME) != null);
assertEquals(htds.invocations, count * 4 + 1);
assertTrue("expected=" + ((count * 2) + 1) + ", actual=" + htds.cachehits,
Expand Down

0 comments on commit 7406d29

Please sign in to comment.