本文整理汇总了Java中org.apache.hadoop.hbase.rest.client.RemoteAdmin.isTableAvailable方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteAdmin.isTableAvailable方法的具体用法?Java RemoteAdmin.isTableAvailable怎么用?Java RemoteAdmin.isTableAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.rest.client.RemoteAdmin
的用法示例。
在下文中一共展示了RemoteAdmin.isTableAvailable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTable
import org.apache.hadoop.hbase.rest.client.RemoteAdmin; //导入方法依赖的package包/类
/**
* 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());
}
}
示例2: tablesExists
import org.apache.hadoop.hbase.rest.client.RemoteAdmin; //导入方法依赖的package包/类
/**
* 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;
}
示例3: checkTable
import org.apache.hadoop.hbase.rest.client.RemoteAdmin; //导入方法依赖的package包/类
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;
}
示例4: checkTable
import org.apache.hadoop.hbase.rest.client.RemoteAdmin; //导入方法依赖的package包/类
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;
}