Java 类org.apache.hadoop.hbase.rest.client.RemoteAdmin 实例源码

项目:aws-big-data-blog    文件:HBaseUtils.java   
/**
 * Helper method to create an HBase table in an Amazon EMR cluster with HBase installed
 * 
 * @param tableName - name for table to create
 * @param dnsId - Amazon EMR master node public DNS
 * @param hbaseRestPort - HBase Rest port
 */
public static void createTable(String tableName, String dnsId, int hbaseRestPort) {
    Configuration config = HBaseConfiguration.create();
    RemoteAdmin admin = new RemoteAdmin(new Client(new Cluster().add(dnsId, hbaseRestPort)), config);
    String [] families = {"user", "address", "contact", "likes"};
    try {
        if (admin.isTableAvailable(tableName)) {
            LOG.info("table already exists!");
            return;
        } else {
            HTableDescriptor tableDesc = new HTableDescriptor(tableName);
            for (int i = 0; i < families.length; i++) {
                tableDesc.addFamily(new HColumnDescriptor(families[i]));
            }
            admin.createTable(tableDesc);
            isTableAvailable = true;
            LOG.info("create table " + tableName + " ok.");
        } 

    } catch (IOException e) {
        LOG.error(e, e.getCause()); 
    }

}
项目:aws-big-data-blog    文件:HBaseUtils.java   
/**
 * Helper method that checks if a table exists in HBase
 * 
 * @param tableName - table to check
 * @param dnsId - Amazon EMR master node public DNS
 * @param hbaseRestPort - HBase Rest port
 * @return
 */
public static boolean tablesExists(String tableName, String dnsId, int hbaseRestPort) {
    Configuration config = HBaseConfiguration.create();
    RemoteAdmin admin = new RemoteAdmin(new Client(new Cluster().add(dnsId, hbaseRestPort)), config);
    try {
        if (admin.isTableAvailable(tableName)) {
            LOG.info("table already exists!");
            System.out.println("table already exists!");
            return true;
        }

    } catch (IOException e) {
        e.printStackTrace();
        LOG.error(e, e.getCause()); 
    }
    return false;
}
项目:ditb    文件:PerformanceEvaluation.java   
private void runNIsMoreThanOne(final Class<? extends Test> cmd)
throws IOException, InterruptedException, ClassNotFoundException {
  RemoteAdmin remoteAdmin = new RemoteAdmin(new Client(cluster), getConf());
  checkTable(remoteAdmin);
  if (nomapred) {
    doMultipleClients(cmd);
  } else {
    doMapReduce(cmd);
  }
}
项目:LCIndex-HBase-0.94.16    文件:PerformanceEvaluation.java   
private boolean checkTable() throws IOException {
  HTableDescriptor tableDescriptor = getTableDescriptor();
  RemoteAdmin admin = new RemoteAdmin(new Client(cluster), conf);
  if (!admin.isTableAvailable(tableDescriptor.getName())) {
    admin.createTable(tableDescriptor);
    return true;
  }
  return false;
}
项目:HIndex    文件:PerformanceEvaluation.java   
private void runNIsMoreThanOne(final Class<? extends Test> cmd)
throws IOException, InterruptedException, ClassNotFoundException {
  RemoteAdmin remoteAdmin = new RemoteAdmin(new Client(cluster), getConf());
  checkTable(remoteAdmin);
  if (nomapred) {
    doMultipleClients(cmd);
  } else {
    doMapReduce(cmd);
  }
}
项目:mesos-hbase    文件:TestConnectToHbaseRest.java   
public static void main(String[] args) throws Exception
{
  Cluster cluster = new Cluster();
  for (String arg : args)
    cluster.add(arg, 8088);

  Client client = new Client(cluster);
  RemoteAdmin remoteAdmin = new RemoteAdmin(client, new Configuration());
  VersionModel restVersion = remoteAdmin.getRestVersion();
  System.out.println(restVersion.toString());
}
项目:IRIndex    文件:PerformanceEvaluation.java   
private boolean checkTable() throws IOException {
  HTableDescriptor tableDescriptor = getTableDescriptor();
  RemoteAdmin admin = new RemoteAdmin(new Client(cluster), conf);
  if (!admin.isTableAvailable(tableDescriptor.getName())) {
    admin.createTable(tableDescriptor);
    return true;
  }
  return false;
}
项目:hbase    文件:PerformanceEvaluation.java   
private void runNIsMoreThanOne(final Class<? extends Test> cmd)
throws IOException, InterruptedException, ClassNotFoundException {
  RemoteAdmin remoteAdmin = new RemoteAdmin(new Client(cluster), getConf());
  checkTable(remoteAdmin);
  if (nomapred) {
    doMultipleClients(cmd);
  } else {
    doMapReduce(cmd);
  }
}
项目:PyroDB    文件:PerformanceEvaluation.java   
private void runNIsMoreThanOne(final Class<? extends Test> cmd)
throws IOException, InterruptedException, ClassNotFoundException {
  RemoteAdmin remoteAdmin = new RemoteAdmin(new Client(cluster), getConf());
  checkTable(remoteAdmin);
  if (nomapred) {
    doMultipleClients(cmd);
  } else {
    doMapReduce(cmd);
  }
}
项目:c5    文件:PerformanceEvaluation.java   
private boolean checkTable() throws IOException {
  HTableDescriptor tableDescriptor = getTableDescriptor();
  RemoteAdmin admin = new RemoteAdmin(new Client(cluster), conf);
  if (!admin.isTableAvailable(tableDescriptor.getTableName().getName())) {
    admin.createTable(tableDescriptor);
    return true;
  }
  return false;
}
项目:HBase-Research    文件:PerformanceEvaluation.java   
private boolean checkTable() throws IOException {
  HTableDescriptor tableDescriptor = getTableDescriptor();
  RemoteAdmin admin = new RemoteAdmin(new Client(cluster), conf);
  if (!admin.isTableAvailable(tableDescriptor.getName())) {
    admin.createTable(tableDescriptor);
    return true;
  }
  return false;
}
项目:hbase-0.94.8-qod    文件:PerformanceEvaluation.java   
private boolean checkTable() throws IOException {
  HTableDescriptor tableDescriptor = getTableDescriptor();
  RemoteAdmin admin = new RemoteAdmin(new Client(cluster), conf);
  if (!admin.isTableAvailable(tableDescriptor.getName())) {
    admin.createTable(tableDescriptor);
    return true;
  }
  return false;
}
项目:hbase-0.94.8-qod    文件:PerformanceEvaluation.java   
private boolean checkTable() throws IOException {
  HTableDescriptor tableDescriptor = getTableDescriptor();
  RemoteAdmin admin = new RemoteAdmin(new Client(cluster), conf);
  if (!admin.isTableAvailable(tableDescriptor.getName())) {
    admin.createTable(tableDescriptor);
    return true;
  }
  return false;
}
项目:DominoHBase    文件:PerformanceEvaluation.java   
private boolean checkTable() throws IOException {
  HTableDescriptor tableDescriptor = getTableDescriptor();
  RemoteAdmin admin = new RemoteAdmin(new Client(cluster), conf);
  if (!admin.isTableAvailable(tableDescriptor.getName())) {
    admin.createTable(tableDescriptor);
    return true;
  }
  return false;
}
项目:hindex    文件:PerformanceEvaluation.java   
private boolean checkTable() throws IOException {
  HTableDescriptor tableDescriptor = getTableDescriptor();
  RemoteAdmin admin = new RemoteAdmin(new Client(cluster), conf);
  if (!admin.isTableAvailable(tableDescriptor.getName())) {
    admin.createTable(tableDescriptor);
    return true;
  }
  return false;
}