You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by Shrijeet Paliwal <sh...@rocketfuel.com> on 2011/12/23 00:01:05 UTC

isRegionName logic in HBaseAdmin

Context : HBASE-5041

While working on HBASE-5041 I realized our logic to check if the name
is a regionname or tablename is designed to be as follows:
tl;dr: If it is not an existing table, its should be a region.

 /**
   * @param tableNameOrRegionName Name of a table or name of a region.
   * @return True if <code>tableNameOrRegionName</code> is *possibly* a region
   * name else false if a verified tablename (we call {@link
#tableExists(byte[])};
   * else we throw an exception.
   * @throws IOException
   */
  private boolean isRegionName(final byte [] tableNameOrRegionName)
  throws IOException {
    if (tableNameOrRegionName == null) {
      throw new IllegalArgumentException("Pass a table name or region name");
    }
    return !tableExists(tableNameOrRegionName);
  }

My plan was to modify majorCompact function's else block to check if
the table exist and throw TableNotFoundException if it does not.
But because of name logic one will never reach 'else' part and a
compaction request will be registered assuming it must be a region.

What do others think about changing this logic? I do not have enough
insight to propose an alternative.

Re: isRegionName logic in HBaseAdmin

Posted by Shrijeet Paliwal <sh...@rocketfuel.com>.
Stack,
We took the discussion here  HBASE-5041
I uploaded a patch . Could you please review?

On Thu, Dec 22, 2011 at 8:27 PM, Stack <st...@duboce.net> wrote:
> On Thu, Dec 22, 2011 at 3:01 PM, Shrijeet Paliwal
> <sh...@rocketfuel.com> wrote:
>>  private boolean isRegionName(final byte [] tableNameOrRegionName)
>>  throws IOException {
>>    if (tableNameOrRegionName == null) {
>>      throw new IllegalArgumentException("Pass a table name or region name");
>>    }
>>    return !tableExists(tableNameOrRegionName);
>>  }
>>
>
> The above is a bit crass for sure; if not a table name, it MUST BE a
> region name.
>
>> What do others think about changing this logic? I do not have enough
>> insight to propose an alternative.
>
> Should we next go look for a region in .META.?  Or do this optionally?
>  Make new methods isTableName and isRegionName with each doing looksee
> if table/region exists?
>
> Open to any suggestion....
>
> St.Ack

Re: isRegionName logic in HBaseAdmin

Posted by Stack <st...@duboce.net>.
On Thu, Dec 22, 2011 at 3:01 PM, Shrijeet Paliwal
<sh...@rocketfuel.com> wrote:
>  private boolean isRegionName(final byte [] tableNameOrRegionName)
>  throws IOException {
>    if (tableNameOrRegionName == null) {
>      throw new IllegalArgumentException("Pass a table name or region name");
>    }
>    return !tableExists(tableNameOrRegionName);
>  }
>

The above is a bit crass for sure; if not a table name, it MUST BE a
region name.

> What do others think about changing this logic? I do not have enough
> insight to propose an alternative.

Should we next go look for a region in .META.?  Or do this optionally?
 Make new methods isTableName and isRegionName with each doing looksee
if table/region exists?

Open to any suggestion....

St.Ack