@Override public List<THRegionLocation> getAllRegionLocations(ByteBuffer table) throws TIOError, TException { RegionLocator locator = null; try { locator = getLocator(table); return ThriftUtilities.regionLocationsFromHBase(locator.getAllRegionLocations()); } catch (IOException e) { throw getTIOError(e); } finally { if (locator != null) { try { locator.close(); } catch (IOException e) { LOG.warn("Couldn't close the locator.", e); } } } }
@Override public THRegionLocation getRegionLocation(ByteBuffer table, ByteBuffer row, boolean reload) throws TIOError, TException { RegionLocator locator = null; try { locator = getLocator(table); byte[] rowBytes = byteBufferToByteArray(row); HRegionLocation hrl = locator.getRegionLocation(rowBytes, reload); return ThriftUtilities.regionLocationFromHBase(hrl); } catch (IOException e) { throw getTIOError(e); } finally { if (locator != null) { try { locator.close(); } catch (IOException e) { LOG.warn("Couldn't close the locator.", e); } } } }
regionMap = m; LOG.error("regions: " + regionMap); regionLocator.close();
tableInfoSingle.getRegionLocator().close();
admin.close(); table.close(); rl.close(); tableToBeDisabled.close(); HTU.deleteTableIfAny(toBeDisabledTable);
assert(UTIL.getHBaseCluster().getMaster().balance() == true); assertRegionsAreBalanced(); regionLocator.close();
public static void main(String[] args) throws IOException, InterruptedException { Configuration conf = HBaseConfiguration.create(); HBaseHelper helper = HBaseHelper.getHelper(conf); helper.dropTable("testtable"); Connection connection = ConnectionFactory.createConnection(conf); Admin admin = connection.getAdmin(); // vv ServerAndRegionNameExample TableName tableName = TableName.valueOf("testtable"); HColumnDescriptor coldef1 = new HColumnDescriptor("colfam1"); HTableDescriptor desc = new HTableDescriptor(tableName) .addFamily(coldef1) .setValue("Description", "Chapter 5 - ServerAndRegionNameExample"); byte[][] regions = new byte[][] { Bytes.toBytes("ABC"), Bytes.toBytes("DEF"), Bytes.toBytes("GHI"), Bytes.toBytes("KLM"), Bytes.toBytes("OPQ"), Bytes.toBytes("TUV") }; admin.createTable(desc, regions); RegionLocator locator = connection.getRegionLocator(tableName); HRegionLocation location = locator.getRegionLocation(Bytes.toBytes("Foo")); HRegionInfo info = location.getRegionInfo(); System.out.println("Region Name: " + info.getRegionNameAsString()); System.out.println("Server Name: " + location.getServerName()); // ^^ ServerAndRegionNameExample locator.close(); admin.close(); connection.close(); } }
private static void printTableRegions(String tableName) throws IOException { // co CreateTableWithRegionsExample-1-PrintTable Helper method to print the regions of a table. System.out.println("Printing regions of table: " + tableName); TableName tn = TableName.valueOf(tableName); RegionLocator locator = connection.getRegionLocator(tn); Pair<byte[][], byte[][]> pair = locator.getStartEndKeys(); // co CreateTableWithRegionsExample-2-GetKeys Retrieve the start and end keys from the newly created table. for (int n = 0; n < pair.getFirst().length; n++) { byte[] sk = pair.getFirst()[n]; byte[] ek = pair.getSecond()[n]; System.out.println("[" + (n + 1) + "]" + " start key: " + (sk.length == 8 ? Bytes.toLong(sk) : Bytes.toStringBinary(sk)) + // co CreateTableWithRegionsExample-3-Print Print the key, but guarding against the empty start (and end) key. ", end key: " + (ek.length == 8 ? Bytes.toLong(ek) : Bytes.toStringBinary(ek))); } locator.close(); } // ^^ CreateTableWithRegionsExample
locator.close(); admin.close(); connection.close();
regionLocator.close();
locator.close(); admin.close();
public static void closeRegionLocator(RegionLocator regionLocator){ try { if(null != regionLocator) { regionLocator.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
public static void closeRegionLocator(RegionLocator regionLocator){ try { if(null != regionLocator) regionLocator.close(); } catch (IOException e) { throw DataXException.asDataXException(Hbase11xReaderErrorCode.CLOSE_HBASE_REGINLOCTOR_ERROR, e); } }
@Override public List<THRegionLocation> getAllRegionLocations(ByteBuffer table) throws TIOError, TException { RegionLocator locator = null; try { locator = getLocator(table); return ThriftUtilities.regionLocationsFromHBase(locator.getAllRegionLocations()); } catch (IOException e) { throw getTIOError(e); } finally { if (locator != null) { try { locator.close(); } catch (IOException e) { LOG.warn("Couldn't close the locator.", e); } } } }
@Override public List<THRegionLocation> getAllRegionLocations(ByteBuffer table) throws TIOError, TException { RegionLocator locator = null; try { locator = getLocator(table); return ThriftUtilities.regionLocationsFromHBase(locator.getAllRegionLocations()); } catch (IOException e) { throw getTIOError(e); } finally { if (locator != null) { try { locator.close(); } catch (IOException e) { LOG.warn("Couldn't close the locator.", e); } } } }
@Override public THRegionLocation getRegionLocation(ByteBuffer table, ByteBuffer row, boolean reload) throws TIOError, TException { RegionLocator locator = null; try { locator = getLocator(table); byte[] rowBytes = byteBufferToByteArray(row); HRegionLocation hrl = locator.getRegionLocation(rowBytes, reload); return ThriftUtilities.regionLocationFromHBase(hrl); } catch (IOException e) { throw getTIOError(e); } finally { if (locator != null) { try { locator.close(); } catch (IOException e) { LOG.warn("Couldn't close the locator.", e); } } } }
@Override public THRegionLocation getRegionLocation(ByteBuffer table, ByteBuffer row, boolean reload) throws TIOError, TException { RegionLocator locator = null; try { locator = getLocator(table); byte[] rowBytes = byteBufferToByteArray(row); HRegionLocation hrl = locator.getRegionLocation(rowBytes, reload); return ThriftUtilities.regionLocationFromHBase(hrl); } catch (IOException e) { throw getTIOError(e); } finally { if (locator != null) { try { locator.close(); } catch (IOException e) { LOG.warn("Couldn't close the locator.", e); } } } }
locations = locator.getAllRegionLocations(); } finally { locator.close();
assert(UTIL.getHBaseCluster().getMaster().balance() == true); assertRegionsAreBalanced(); regionLocator.close();