[ 
https://issues.apache.org/jira/browse/HBASE-11032?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13975371#comment-13975371
 ] 

Gustavo Anatoly commented on HBASE-11032:
-----------------------------------------

Hi, Ted.

Thanks for report this bug, but I think that occurs because the parent path of 
{{{color:blue}path{color}}}
is renamed to {{{color:blue}newPath{color}}}. So when 
{{{color:blue}HLogFactory.createWALWriter(fs, path, conf);{color}}} is called 
inside on try block, it will be created because {{overwrite=false}} throws 
error only the path already exist otherwise IOException explode.

{code}
@Test
public void testFailedToCreateHLogIfParentRenamed() throws IOException {
  FSHLog log = (FSHLog)HLogFactory.createHLog(
    fs, hbaseDir, "testFailedToCreateHLogIfParentRenamed", conf);
  long filenum = System.currentTimeMillis();
  Path path = log.computeFilename(filenum);
  HLogFactory.createWALWriter(fs, path, conf);
  Path parent = path.getParent();
  path = log.computeFilename(filenum + 1);
  Path newPath = new Path(parent.getParent(), parent.getName() + "-splitting");
  fs.rename(parent, newPath);
  try {
    HLogFactory.createWALWriter(fs, path, conf); <<< path is new at this point, 
it will be created.
    fail("It should fail to create the new WAL");
  } catch (IOException ioe) {
    // expected, good.
  }
}
{code}
So I change the method to:

{code}
@Test(expected=IOException.class)
public void testFailedToCreateHLogIfParentRenamed() throws IOException {
  FSHLog log = (FSHLog)HLogFactory.createHLog(
    fs, hbaseDir, "testFailedToCreateHLogIfParentRenamed", conf);
  long filenum = System.currentTimeMillis();
  Path path = log.computeFilename(filenum);
  HLogFactory.createWALWriter(fs, path, conf);
  Path parent = path.getParent();
  path = log.computeFilename(filenum + 1);
  Path newPath = new Path(parent.getParent(), parent.getName() + "-splitting");
  fs.rename(parent, newPath);
  assertFalse(fs.exists(parent));
  assertTrue(fs.exists(newPath));
  LOG.debug("Parent HLog Path: " + parent.toUri().toString());
  LOG.debug("Parent HLog Path Renamed to: " + newPath.toUri().toString());
  HLogFactory.createWALWriter(fs, newPath, conf);
  fail("It should fail to create the new WAL");
}
{code}

Could you please review this changes and if it is correct it will be put on a 
new issue? I ask, because I could generate a specific patch to the new issue.

Thanks.

> Replace deprecated methods in FileSystem with their replacements
> ----------------------------------------------------------------
>
>                 Key: HBASE-11032
>                 URL: https://issues.apache.org/jira/browse/HBASE-11032
>             Project: HBase
>          Issue Type: Task
>            Reporter: Ted Yu
>            Assignee: Gustavo Anatoly
>            Priority: Minor
>             Fix For: 0.99.0
>
>         Attachments: HBASE-11032.patch
>
>
> FileStatus#isDir() is deprecated.
> FileStatus#isDirectory() should be called instead.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to