hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Yu <yuzhih...@gmail.com>
Subject code review: HBASE-3251
Date Wed, 24 Nov 2010 23:45:06 GMT
Hi,
I wanted to automate the manual deletion of dangling row(s) in .META. table.
Please kindly comment on the following modification to HMaster.createTable()
which is base on 0.20.6 codebase:

    long scannerid = srvr.openScanner(metaRegionName, scan);
    try {
        HashSet<byte[]> regions = new HashSet<byte[]>();
        boolean cleanTable = false,        // whether the table has a row in
.META. whose start key is empty
                exists = false;
        Result data = srvr.next(scannerid);
        while (data != null) {
            if (data != null && data.size() > 0) {
                HRegionInfo info = Writables.getHRegionInfo(
                        data.getValue(CATALOG_FAMILY,
REGIONINFO_QUALIFIER));
                if (info.getTableDesc().getNameAsString().equals(tableName))
{
                    exists = true;
                    if (info.getStartKey().length == 0) {
                        cleanTable = true;
                    } else {
                        regions.add(info.getRegionName());
                    }
                }
            }
            data = srvr.next(scannerid);
        }
        if (exists) {
            if (!cleanTable) {
                HTable meta = new HTable(HConstants.META_TABLE_NAME);
                for (byte[] region : regions) {
                    Delete d = new Delete(region);
                    meta.delete(d);
                    LOG.info("dangling row " + Bytes.toString(region) + "
deleted from .META.");
                }
            } else {
                // A region for this table already exists. Ergo table
exists.
                throw new TableExistsException(tableName);
            }
        }
    } finally {
      srvr.close(scannerid);
    }

Thanks

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message