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