Java 类org.apache.hadoop.hbase.rest.model.TableModel 实例源码

项目:LCIndex-HBase-0.94.16    文件:TestRemoteAdmin.java   
@Test
public void testListTables() throws Exception {

  remoteAdmin.createTable(DESC_2);
  List<TableModel> tableList = remoteAdmin.getTableList().getTables();
  System.out.println("List of tables is: ");
  boolean found = false;
  for (TableModel tm : tableList) {

    if (tm.getName().equals(TABLE_2)) {
      found = true;
      break;
    }
  }
  assertTrue("Table " + TABLE_2 + " was not found by get request to '/'",
      found);
}
项目:IRIndex    文件:TestRemoteAdmin.java   
@Test
public void testListTables() throws Exception {

  remoteAdmin.createTable(DESC_2);
  List<TableModel> tableList = remoteAdmin.getTableList().getTables();
  System.out.println("List of tables is: ");
  boolean found = false;
  for (TableModel tm : tableList) {

    if (tm.getName().equals(TABLE_2)) {
      found = true;
      break;
    }
  }
  assertTrue("Table " + TABLE_2 + " was not found by get request to '/'",
      found);
}
项目:HBase-Research    文件:TestRemoteAdmin.java   
@Test
public void testListTables() throws Exception {

  remoteAdmin.createTable(DESC_2);
  List<TableModel> tableList = remoteAdmin.getTableList().getTables();
  System.out.println("List of tables is: ");
  boolean found = false;
  for (TableModel tm : tableList) {

    if (tm.getName().equals(TABLE_2)) {
      found = true;
      break;
    }
  }
  assertTrue("Table " + TABLE_2 + " was not found by get request to '/'",
      found);
}
项目:hbase-0.94.8-qod    文件:TestRemoteAdmin.java   
@Test
public void testListTables() throws Exception {

  remoteAdmin.createTable(DESC_2);
  List<TableModel> tableList = remoteAdmin.getTableList().getTables();
  System.out.println("List of tables is: ");
  boolean found = false;
  for (TableModel tm : tableList) {

    if (tm.getName().equals(TABLE_2)) {
      found = true;
      break;
    }
  }
  assertTrue("Table " + TABLE_2 + " was not found by get request to '/'",
      found);
}
项目:hbase-0.94.8-qod    文件:TestRemoteAdmin.java   
@Test
public void testListTables() throws Exception {

  remoteAdmin.createTable(DESC_2);
  List<TableModel> tableList = remoteAdmin.getTableList().getTables();
  System.out.println("List of tables is: ");
  boolean found = false;
  for (TableModel tm : tableList) {

    if (tm.getName().equals(TABLE_2)) {
      found = true;
      break;
    }
  }
  assertTrue("Table " + TABLE_2 + " was not found by get request to '/'",
      found);
}
项目:hindex    文件:TestRemoteAdmin.java   
@Test
public void testListTables() throws Exception {

  remoteAdmin.createTable(DESC_2);
  List<TableModel> tableList = remoteAdmin.getTableList().getTables();
  System.out.println("List of tables is: ");
  boolean found = false;
  for (TableModel tm : tableList) {

    if (tm.getName().equals(TABLE_2)) {
      found = true;
      break;
    }
  }
  assertTrue("Table " + TABLE_2 + " was not found by get request to '/'",
      found);
}
项目:ditb    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  TableName[] tableNames = servlet.getAdmin().listTableNames();
  for (TableName name: tableNames) {
    tableList.add(new TableModel(name.getNameAsString()));
  }
  return tableList;
}
项目:ditb    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE.getNameAsString())) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:ditb    文件:TestNamespacesInstanceResource.java   
private void checkNamespaceTables(List<TableModel> namespaceTables, List<String> testTables){
  assertEquals(namespaceTables.size(), testTables.size());
  for(int i = 0 ; i < namespaceTables.size() ; i++){
    String tableName = ((TableModel) namespaceTables.get(i)).getName();
    assertTrue(testTables.contains(tableName));
  }
}
项目:LCIndex-HBase-0.94.16    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  String[] tableNames = servlet.getAdmin().getTableNames();
  for (String name: tableNames) {
    tableList.add(new TableModel(name));
  }
  return tableList;
}
项目:LCIndex-HBase-0.94.16    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE)) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:HIndex    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  TableName[] tableNames = servlet.getAdmin().listTableNames();
  for (TableName name: tableNames) {
    tableList.add(new TableModel(name.getNameAsString()));
  }
  return tableList;
}
项目:HIndex    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE)) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:IRIndex    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  String[] tableNames = servlet.getAdmin().getTableNames();
  for (String name: tableNames) {
    tableList.add(new TableModel(name));
  }
  return tableList;
}
项目:IRIndex    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE)) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:hbase    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  TableName[] tableNames = servlet.getAdmin().listTableNames();
  for (TableName name: tableNames) {
    tableList.add(new TableModel(name.getNameAsString()));
  }
  return tableList;
}
项目:hbase    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE.getNameAsString())) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:hbase    文件:TestNamespacesInstanceResource.java   
private void checkNamespaceTables(List<TableModel> namespaceTables, List<String> testTables){
  assertEquals(namespaceTables.size(), testTables.size());
  for(int i = 0 ; i < namespaceTables.size() ; i++){
    String tableName = ((TableModel) namespaceTables.get(i)).getName();
    assertTrue(testTables.contains(tableName));
  }
}
项目:RStore    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
  HTableDescriptor[] list = admin.listTables();
  for (HTableDescriptor htd: list) {
    tableList.add(new TableModel(htd.getNameAsString()));
  }
  return tableList;
}
项目:PyroDB    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  TableName[] tableNames = servlet.getAdmin().listTableNames();
  for (TableName name: tableNames) {
    tableList.add(new TableModel(name.getNameAsString()));
  }
  return tableList;
}
项目:PyroDB    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE)) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:c5    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  TableName[] tableNames = servlet.getAdmin().listTableNames();
  for (TableName name: tableNames) {
    tableList.add(new TableModel(name.getNameAsString()));
  }
  return tableList;
}
项目:c5    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE)) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:HBase-Research    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  HTableDescriptor[] list = servlet.getAdmin().listTables();
  for (HTableDescriptor htd: list) {
    tableList.add(new TableModel(htd.getNameAsString()));
  }
  return tableList;
}
项目:HBase-Research    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE)) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:hbase-0.94.8-qod    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  HTableDescriptor[] list = servlet.getAdmin().listTables();
  for (HTableDescriptor htd: list) {
    tableList.add(new TableModel(htd.getNameAsString()));
  }
  return tableList;
}
项目:hbase-0.94.8-qod    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE)) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:hbase-0.94.8-qod    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  HTableDescriptor[] list = servlet.getAdmin().listTables();
  for (HTableDescriptor htd: list) {
    tableList.add(new TableModel(htd.getNameAsString()));
  }
  return tableList;
}
项目:hbase-0.94.8-qod    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE)) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:DominoHBase    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  HTableDescriptor[] list = servlet.getAdmin().listTables();
  for (HTableDescriptor htd: list) {
    tableList.add(new TableModel(htd.getNameAsString()));
  }
  return tableList;
}
项目:DominoHBase    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE)) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:hindex    文件:RootResource.java   
private final TableListModel getTableList() throws IOException {
  TableListModel tableList = new TableListModel();
  HTableDescriptor[] list = servlet.getAdmin().listTables();
  for (HTableDescriptor htd: list) {
    tableList.add(new TableModel(htd.getNameAsString()));
  }
  return tableList;
}
项目:hindex    文件:TestTableResource.java   
private static void checkTableList(TableListModel model) {
  boolean found = false;
  Iterator<TableModel> tables = model.getTables().iterator();
  assertTrue(tables.hasNext());
  while (tables.hasNext()) {
    TableModel table = tables.next();
    if (table.getName().equals(TABLE)) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
项目:ditb    文件:TestTableResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
      TableModel.class,
      TableInfoModel.class,
      TableListModel.class,
      TableRegionModel.class);
  Admin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
  admin.createTable(htd);
  byte[] k = new byte[3];
  byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN));
  List<Put> puts = new ArrayList<>();
  for (byte b1 = 'a'; b1 < 'z'; b1++) {
    for (byte b2 = 'a'; b2 < 'z'; b2++) {
      for (byte b3 = 'a'; b3 < 'z'; b3++) {
        k[0] = b1;
        k[1] = b2;
        k[2] = b3;
        Put put = new Put(k);
        put.setDurability(Durability.SKIP_WAL);
        put.add(famAndQf[0], famAndQf[1], k);
        puts.add(put);
      }
    }
  }
  Connection connection = TEST_UTIL.getConnection();

  Table table =  connection.getTable(TABLE);
  table.put(puts);
  table.close();
  // get the initial layout (should just be one region)

  RegionLocator regionLocator = connection.getRegionLocator(TABLE);
  List<HRegionLocation> m = regionLocator.getAllRegionLocations();
  assertEquals(m.size(), 1);
  // tell the master to split the table
  admin.split(TABLE);
  // give some time for the split to happen

  long timeout = System.currentTimeMillis() + (15 * 1000);
  while (System.currentTimeMillis() < timeout && m.size()!=2){
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      LOG.warn(StringUtils.stringifyException(e));
    }
    // check again
    m = regionLocator.getAllRegionLocations();
  }

  // should have two regions now
  assertEquals(m.size(), 2);
  regionMap = m;
  LOG.info("regions: " + regionMap);
  regionLocator.close();
}
项目:LCIndex-HBase-0.94.16    文件:TestTableResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
  client = new Client(new Cluster().add("localhost", 
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
      TableModel.class,
      TableInfoModel.class,
      TableListModel.class,
      TableRegionModel.class);
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
  admin.createTable(htd);
  HTable table = new HTable(TEST_UTIL.getConfiguration(), TABLE);
  byte[] k = new byte[3];
  byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN));
  for (byte b1 = 'a'; b1 < 'z'; b1++) {
    for (byte b2 = 'a'; b2 < 'z'; b2++) {
      for (byte b3 = 'a'; b3 < 'z'; b3++) {
        k[0] = b1;
        k[1] = b2;
        k[2] = b3;
        Put put = new Put(k);
        put.setWriteToWAL(false);
        put.add(famAndQf[0], famAndQf[1], k);
        table.put(put);
      }
    }
  }
  table.flushCommits();
  // get the initial layout (should just be one region)
  Map<HRegionInfo,HServerAddress> m = table.getRegionsInfo();
  assertEquals(m.size(), 1);
  // tell the master to split the table
  admin.split(TABLE);
  // give some time for the split to happen

  long timeout = System.currentTimeMillis() + (15 * 1000);
  while (System.currentTimeMillis() < timeout && m.size()!=2){
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      LOG.warn(StringUtils.stringifyException(e));
    }
    // check again
    m = table.getRegionsInfo();
  }

  // should have two regions now
  assertEquals(m.size(), 2);
  regionMap = m;
  LOG.info("regions: " + regionMap);
  table.close();
}
项目:HIndex    文件:TestTableResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
  client = new Client(new Cluster().add("localhost", 
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
      TableModel.class,
      TableInfoModel.class,
      TableListModel.class,
      TableRegionModel.class);
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE));
  htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
  admin.createTable(htd);
  HTable table = new HTable(TEST_UTIL.getConfiguration(), TABLE);
  byte[] k = new byte[3];
  byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN));
  for (byte b1 = 'a'; b1 < 'z'; b1++) {
    for (byte b2 = 'a'; b2 < 'z'; b2++) {
      for (byte b3 = 'a'; b3 < 'z'; b3++) {
        k[0] = b1;
        k[1] = b2;
        k[2] = b3;
        Put put = new Put(k);
        put.setDurability(Durability.SKIP_WAL);
        put.add(famAndQf[0], famAndQf[1], k);
        table.put(put);
      }
    }
  }
  table.flushCommits();
  // get the initial layout (should just be one region)
  Map<HRegionInfo, ServerName> m = table.getRegionLocations();
  assertEquals(m.size(), 1);
  // tell the master to split the table
  admin.split(TABLE);
  // give some time for the split to happen

  long timeout = System.currentTimeMillis() + (15 * 1000);
  while (System.currentTimeMillis() < timeout && m.size()!=2){
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      LOG.warn(StringUtils.stringifyException(e));
    }
    // check again
    m = table.getRegionLocations();
  }

  // should have two regions now
  assertEquals(m.size(), 2);
  regionMap = m;
  LOG.info("regions: " + regionMap);
  table.close();
}
项目:IRIndex    文件:TestTableResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
  client = new Client(new Cluster().add("localhost", 
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
      TableModel.class,
      TableInfoModel.class,
      TableListModel.class,
      TableRegionModel.class);
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
  admin.createTable(htd);
  HTable table = new HTable(TEST_UTIL.getConfiguration(), TABLE);
  byte[] k = new byte[3];
  byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN));
  for (byte b1 = 'a'; b1 < 'z'; b1++) {
    for (byte b2 = 'a'; b2 < 'z'; b2++) {
      for (byte b3 = 'a'; b3 < 'z'; b3++) {
        k[0] = b1;
        k[1] = b2;
        k[2] = b3;
        Put put = new Put(k);
        put.setWriteToWAL(false);
        put.add(famAndQf[0], famAndQf[1], k);
        table.put(put);
      }
    }
  }
  table.flushCommits();
  // get the initial layout (should just be one region)
  Map<HRegionInfo,HServerAddress> m = table.getRegionsInfo();
  assertEquals(m.size(), 1);
  // tell the master to split the table
  admin.split(TABLE);
  // give some time for the split to happen

  long timeout = System.currentTimeMillis() + (15 * 1000);
  while (System.currentTimeMillis() < timeout && m.size()!=2){
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      LOG.warn(StringUtils.stringifyException(e));
    }
    // check again
    m = table.getRegionsInfo();
  }

  // should have two regions now
  assertEquals(m.size(), 2);
  regionMap = m;
  LOG.info("regions: " + regionMap);
  table.close();
}
项目:hbase    文件:TestTableResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
      TableModel.class,
      TableInfoModel.class,
      TableListModel.class,
      TableRegionModel.class);
  Admin admin = TEST_UTIL.getAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
  admin.createTable(htd);
  byte[] k = new byte[3];
  byte [][] famAndQf = CellUtil.parseColumn(Bytes.toBytes(COLUMN));
  List<Put> puts = new ArrayList<>();
  for (byte b1 = 'a'; b1 < 'z'; b1++) {
    for (byte b2 = 'a'; b2 < 'z'; b2++) {
      for (byte b3 = 'a'; b3 < 'z'; b3++) {
        k[0] = b1;
        k[1] = b2;
        k[2] = b3;
        Put put = new Put(k);
        put.setDurability(Durability.SKIP_WAL);
        put.addColumn(famAndQf[0], famAndQf[1], k);
        puts.add(put);
      }
    }
  }
  Connection connection = TEST_UTIL.getConnection();

  Table table =  connection.getTable(TABLE);
  table.put(puts);
  table.close();
  // get the initial layout (should just be one region)

  RegionLocator regionLocator = connection.getRegionLocator(TABLE);
  List<HRegionLocation> m = regionLocator.getAllRegionLocations();
  assertEquals(1, m.size());
  // tell the master to split the table
  admin.split(TABLE);
  // give some time for the split to happen

  TestEndToEndSplitTransaction.blockUntilRegionSplit(TEST_UTIL.getConfiguration(), 60000,
    m.get(0).getRegionInfo().getRegionName(), true);
  long timeout = System.currentTimeMillis() + (15 * 1000);
  while (System.currentTimeMillis() < timeout && m.size()!=2){
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      LOG.warn(StringUtils.stringifyException(e));
    }
    // check again
    m = regionLocator.getAllRegionLocations();
  }

  // should have two regions now
  assertEquals(2, m.size());
  regionMap = m;
  LOG.info("regions: " + regionMap);
  regionLocator.close();
}
项目:PyroDB    文件:TestTableResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
  client = new Client(new Cluster().add("localhost", 
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
      TableModel.class,
      TableInfoModel.class,
      TableListModel.class,
      TableRegionModel.class);
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE));
  htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
  admin.createTable(htd);
  HTable table = new HTable(TEST_UTIL.getConfiguration(), TABLE);
  byte[] k = new byte[3];
  byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN));
  for (byte b1 = 'a'; b1 < 'z'; b1++) {
    for (byte b2 = 'a'; b2 < 'z'; b2++) {
      for (byte b3 = 'a'; b3 < 'z'; b3++) {
        k[0] = b1;
        k[1] = b2;
        k[2] = b3;
        Put put = new Put(k);
        put.setDurability(Durability.SKIP_WAL);
        put.add(famAndQf[0], famAndQf[1], k);
        table.put(put);
      }
    }
  }
  table.flushCommits();
  // get the initial layout (should just be one region)
  Map<HRegionInfo, ServerName> m = table.getRegionLocations();
  assertEquals(m.size(), 1);
  // tell the master to split the table
  admin.split(TABLE);
  // give some time for the split to happen

  long timeout = System.currentTimeMillis() + (15 * 1000);
  while (System.currentTimeMillis() < timeout && m.size()!=2){
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      LOG.warn(StringUtils.stringifyException(e));
    }
    // check again
    m = table.getRegionLocations();
  }

  // should have two regions now
  assertEquals(m.size(), 2);
  regionMap = m;
  LOG.info("regions: " + regionMap);
  table.close();
}
项目:c5    文件:TestTableResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
  client = new Client(new Cluster().add("localhost", 
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
      TableModel.class,
      TableInfoModel.class,
      TableListModel.class,
      TableRegionModel.class);
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE));
  htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
  admin.createTable(htd);
  HTable table = new HTable(TEST_UTIL.getConfiguration(), TABLE);
  byte[] k = new byte[3];
  byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN));
  for (byte b1 = 'a'; b1 < 'z'; b1++) {
    for (byte b2 = 'a'; b2 < 'z'; b2++) {
      for (byte b3 = 'a'; b3 < 'z'; b3++) {
        k[0] = b1;
        k[1] = b2;
        k[2] = b3;
        Put put = new Put(k);
        put.setDurability(Durability.SKIP_WAL);
        put.add(famAndQf[0], famAndQf[1], k);
        table.put(put);
      }
    }
  }
  table.flushCommits();
  // get the initial layout (should just be one region)
  Map<HRegionInfo, ServerName> m = table.getRegionLocations();
  assertEquals(m.size(), 1);
  // tell the master to split the table
  admin.split(TABLE);
  // give some time for the split to happen

  long timeout = System.currentTimeMillis() + (15 * 1000);
  while (System.currentTimeMillis() < timeout && m.size()!=2){
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      LOG.warn(StringUtils.stringifyException(e));
    }
    // check again
    m = table.getRegionLocations();
  }

  // should have two regions now
  assertEquals(m.size(), 2);
  regionMap = m;
  LOG.info("regions: " + regionMap);
  table.close();
}