Java 类org.apache.hadoop.hbase.thrift.generated.TRegionInfo 实例源码

项目:ditb    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
项目:ditb    文件:TestThriftServer.java   
public static void doTestGetRegionInfo(Hbase.Iface handler) throws Exception {
  // Create tableA and add two columns to rowA
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    handler.mutateRow(tableAname, rowAname, getMutations(), null);
    byte[] searchRow = HRegionInfo.createRegionName(
        TableName.valueOf(tableAname.array()), rowAname.array(),
        HConstants.NINES, false);
    TRegionInfo regionInfo = handler.getRegionInfo(ByteBuffer.wrap(searchRow));
    assertTrue(Bytes.toStringBinary(regionInfo.getName()).startsWith(
          Bytes.toStringBinary(tableAname)));
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
项目:LCIndex-HBase-0.94.16    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
项目:HIndex    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
项目:HIndex    文件:TestThriftServer.java   
public static void doTestGetRegionInfo(Hbase.Iface handler) throws Exception {
  // Create tableA and add two columns to rowA
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    handler.mutateRow(tableAname, rowAname, getMutations(), null);
    byte[] searchRow = HRegionInfo.createRegionName(
        TableName.valueOf(tableAname.array()), rowAname.array(),
        HConstants.NINES, false);
    TRegionInfo regionInfo = handler.getRegionInfo(ByteBuffer.wrap(searchRow));
    assertTrue(Bytes.toStringBinary(regionInfo.getName()).startsWith(
          Bytes.toStringBinary(tableAname)));
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
项目:IRIndex    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
项目:hbase    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(0, handler.getTableNames().size());
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(1, handler.getTableNames().size());
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, 1, regionCount);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, 0, regionCount);
}
项目:hbase    文件:TestThriftServer.java   
public static void doTestGetRegionInfo(Hbase.Iface handler) throws Exception {
  // Create tableA and add two columns to rowA
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    handler.mutateRow(tableAname, rowAname, getMutations(), null);
    byte[] searchRow = HRegionInfo.createRegionName(
        TableName.valueOf(tableAname.array()), rowAname.array(),
        HConstants.NINES, false);
    TRegionInfo regionInfo = handler.getRegionInfo(ByteBuffer.wrap(searchRow));
    assertTrue(Bytes.toStringBinary(regionInfo.getName()).startsWith(
          Bytes.toStringBinary(tableAname)));
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
项目:RStore    文件:ThriftServer.java   
@Override
public List<TRegionInfo> getTableRegions(ByteBuffer tableName)
throws IOError {
  try{
    List<HRegionInfo> hris = this.admin.getTableRegions(tableName.array());
    List<TRegionInfo> regions = new ArrayList<TRegionInfo>();

    if (hris != null) {
      for (HRegionInfo regionInfo : hris){
        TRegionInfo region = new TRegionInfo();
        region.startKey = ByteBuffer.wrap(regionInfo.getStartKey());
        region.endKey = ByteBuffer.wrap(regionInfo.getEndKey());
        region.id = regionInfo.getRegionId();
        region.name = ByteBuffer.wrap(regionInfo.getRegionName());
        region.version = regionInfo.getVersion();
        regions.add(region);
      }
    }
    return regions;
  } catch (IOException e){
    throw new IOError(e.getMessage());
  }
}
项目:PyroDB    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
项目:PyroDB    文件:TestThriftServer.java   
public static void doTestGetRegionInfo(Hbase.Iface handler) throws Exception {
  // Create tableA and add two columns to rowA
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    handler.mutateRow(tableAname, rowAname, getMutations(), null);
    byte[] searchRow = HRegionInfo.createRegionName(
        TableName.valueOf(tableAname.array()), rowAname.array(),
        HConstants.NINES, false);
    TRegionInfo regionInfo = handler.getRegionInfo(ByteBuffer.wrap(searchRow));
    assertTrue(Bytes.toStringBinary(regionInfo.getName()).startsWith(
          Bytes.toStringBinary(tableAname)));
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
项目:HBase-Research    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
项目:hbase-0.94.8-qod    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
项目:hbase-0.94.8-qod    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
项目:DominoHBase    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
项目:hindex    文件:TestThriftServer.java   
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
项目:ditb    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    byte[] row = getBytes(searchRow);
    Result startRowResult =
        getRowOrBefore(TableName.META_TABLE_NAME.getName(), row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in "+ TableName.META_TABLE_NAME+", row="
                            + Bytes.toStringBinary(row));
    }

    // find region start and end keys
    HRegionInfo regionInfo = HRegionInfo.getHRegionInfo(startRowResult);
    if (regionInfo == null) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toStringBinary(row));
    }
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    ServerName serverName = HRegionInfo.getServerName(startRowResult);
    if (serverName != null) {
      region.setServerName(Bytes.toBytes(serverName.getHostname()));
      region.port = serverName.getPort();
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  }
}
项目:HIndex    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    HTable table = getTable(TableName.META_TABLE_NAME.getName());
    byte[] row = getBytes(searchRow);
    Result startRowResult = table.getRowOrBefore(
      row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in "+ TableName.META_TABLE_NAME+", row="
                            + Bytes.toStringBinary(row));
    }

    // find region start and end keys
    HRegionInfo regionInfo = HRegionInfo.getHRegionInfo(startRowResult);
    if (regionInfo == null) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toStringBinary(row));
    }
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    ServerName serverName = HRegionInfo.getServerName(startRowResult);
    if (serverName != null) {
      region.setServerName(Bytes.toBytes(serverName.getHostname()));
      region.port = serverName.getPort();
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(e.getMessage());
  }
}
项目:hbase    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    byte[] row = getBytes(searchRow);
    Result startRowResult = getReverseScanResult(TableName.META_TABLE_NAME.getName(), row,
      HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in "+ TableName.META_TABLE_NAME+", row="
                            + Bytes.toStringBinary(row));
    }

    // find region start and end keys
    RegionInfo regionInfo = MetaTableAccessor.getRegionInfo(startRowResult);
    if (regionInfo == null) {
      throw new IOException("RegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toStringBinary(row));
    }
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = HREGION_VERSION; // version not used anymore, PB encoding used.

    // find region assignment to server
    ServerName serverName = MetaTableAccessor.getServerName(startRowResult, 0);
    if (serverName != null) {
      region.setServerName(Bytes.toBytes(serverName.getHostname()));
      region.port = serverName.getPort();
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw getIOError(e);
  }
}
项目:PyroDB    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    HTable table = getTable(TableName.META_TABLE_NAME.getName());
    byte[] row = getBytes(searchRow);
    Result startRowResult = table.getRowOrBefore(
      row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in "+ TableName.META_TABLE_NAME+", row="
                            + Bytes.toStringBinary(row));
    }

    // find region start and end keys
    HRegionInfo regionInfo = HRegionInfo.getHRegionInfo(startRowResult);
    if (regionInfo == null) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toStringBinary(row));
    }
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    ServerName serverName = HRegionInfo.getServerName(startRowResult);
    if (serverName != null) {
      region.setServerName(Bytes.toBytes(serverName.getHostname()));
      region.port = serverName.getPort();
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(e.getMessage());
  }
}
项目:DominoHBase    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    HTable table = getTable(HConstants.META_TABLE_NAME);
    byte[] row = getBytes(searchRow);
    Result startRowResult = table.getRowOrBefore(
      row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in .META., row="
                            + Bytes.toStringBinary(row));
    }

    // find region start and end keys
    HRegionInfo regionInfo = HRegionInfo.getHRegionInfo(startRowResult);
    if (regionInfo == null) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toStringBinary(row));
    }
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    ServerName serverName = HRegionInfo.getServerName(startRowResult);
    if (serverName != null) {
      region.setServerName(Bytes.toBytes(serverName.getHostname()));
      region.port = serverName.getPort();
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(e.getMessage());
  }
}
项目:DominoHBase    文件:TestThriftServer.java   
public static void doTestGetRegionInfo(Hbase.Iface handler) throws Exception {
  // Create tableA and add two columns to rowA
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    handler.mutateRow(tableAname, rowAname, getMutations(), null);
    byte[] searchRow = HRegionInfo.createRegionName(
        tableAname.array(), rowAname.array(), HConstants.NINES, false);
    TRegionInfo regionInfo = handler.getRegionInfo(ByteBuffer.wrap(searchRow));
    assertTrue(Bytes.toStringBinary(regionInfo.getName()).startsWith(
          Bytes.toStringBinary(tableAname)));
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
项目:LCIndex-HBase-0.94.16    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    HTable table = getTable(HConstants.META_TABLE_NAME);
    byte[] row = toBytes(searchRow);
    Result startRowResult = table.getRowOrBefore(
      row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in .META., row="
                            + Bytes.toString(searchRow.array()));
    }

    // find region start and end keys
    byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                           HConstants.REGIONINFO_QUALIFIER);
    if (value == null || value.length == 0) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toString(row));
    }
    HRegionInfo regionInfo = Writables.getHRegionInfo(value);
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                    HConstants.SERVER_QUALIFIER);
    if (value != null && value.length > 0) {
      String hostAndPort = Bytes.toString(value);
      region.setServerName(Bytes.toBytes(
          Addressing.parseHostname(hostAndPort)));
      region.port = Addressing.parsePort(hostAndPort);
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(e.getMessage());
  }
}
项目:IRIndex    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    HTable table = getTable(HConstants.META_TABLE_NAME);
    byte[] row = toBytes(searchRow);
    Result startRowResult = table.getRowOrBefore(
      row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in .META., row="
                            + Bytes.toString(searchRow.array()));
    }

    // find region start and end keys
    byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                           HConstants.REGIONINFO_QUALIFIER);
    if (value == null || value.length == 0) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toString(row));
    }
    HRegionInfo regionInfo = Writables.getHRegionInfo(value);
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                    HConstants.SERVER_QUALIFIER);
    if (value != null && value.length > 0) {
      String hostAndPort = Bytes.toString(value);
      region.setServerName(Bytes.toBytes(
          Addressing.parseHostname(hostAndPort)));
      region.port = Addressing.parsePort(hostAndPort);
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(e.getMessage());
  }
}
项目:HBase-Research    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    HTable table = getTable(HConstants.META_TABLE_NAME);
    byte[] row = toBytes(searchRow);
    Result startRowResult = table.getRowOrBefore(
      row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in .META., row="
                            + Bytes.toString(searchRow.array()));
    }

    // find region start and end keys
    byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                           HConstants.REGIONINFO_QUALIFIER);
    if (value == null || value.length == 0) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toString(row));
    }
    HRegionInfo regionInfo = Writables.getHRegionInfo(value);
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                    HConstants.SERVER_QUALIFIER);
    if (value != null && value.length > 0) {
      String hostAndPort = Bytes.toString(value);
      region.setServerName(Bytes.toBytes(
          Addressing.parseHostname(hostAndPort)));
      region.port = Addressing.parsePort(hostAndPort);
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(e.getMessage());
  }
}
项目:hbase-0.94.8-qod    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    HTable table = getTable(HConstants.META_TABLE_NAME);
    byte[] row = toBytes(searchRow);
    Result startRowResult = table.getRowOrBefore(
      row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in .META., row="
                            + Bytes.toString(searchRow.array()));
    }

    // find region start and end keys
    byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                           HConstants.REGIONINFO_QUALIFIER);
    if (value == null || value.length == 0) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toString(row));
    }
    HRegionInfo regionInfo = Writables.getHRegionInfo(value);
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                    HConstants.SERVER_QUALIFIER);
    if (value != null && value.length > 0) {
      String hostAndPort = Bytes.toString(value);
      region.setServerName(Bytes.toBytes(
          Addressing.parseHostname(hostAndPort)));
      region.port = Addressing.parsePort(hostAndPort);
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(e.getMessage());
  }
}
项目:hbase-0.94.8-qod    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    HTable table = getTable(HConstants.META_TABLE_NAME);
    byte[] row = toBytes(searchRow);
    Result startRowResult = table.getRowOrBefore(
      row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in .META., row="
                            + Bytes.toString(searchRow.array()));
    }

    // find region start and end keys
    byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                           HConstants.REGIONINFO_QUALIFIER);
    if (value == null || value.length == 0) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toString(row));
    }
    HRegionInfo regionInfo = Writables.getHRegionInfo(value);
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                    HConstants.SERVER_QUALIFIER);
    if (value != null && value.length > 0) {
      String hostAndPort = Bytes.toString(value);
      region.setServerName(Bytes.toBytes(
          Addressing.parseHostname(hostAndPort)));
      region.port = Addressing.parsePort(hostAndPort);
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(e.getMessage());
  }
}
项目:hindex    文件:ThriftServerRunner.java   
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    HTable table = getTable(HConstants.META_TABLE_NAME);
    byte[] row = toBytes(searchRow);
    Result startRowResult = table.getRowOrBefore(
      row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in .META., row="
                            + Bytes.toString(searchRow.array()));
    }

    // find region start and end keys
    byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                           HConstants.REGIONINFO_QUALIFIER);
    if (value == null || value.length == 0) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toString(row));
    }
    HRegionInfo regionInfo = Writables.getHRegionInfo(value);
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
                                    HConstants.SERVER_QUALIFIER);
    if (value != null && value.length > 0) {
      String hostAndPort = Bytes.toString(value);
      region.setServerName(Bytes.toBytes(
          Addressing.parseHostname(hostAndPort)));
      region.port = Addressing.parsePort(hostAndPort);
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(e.getMessage());
  }
}