use of org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor in project hbase by apache.
the class ThriftHBaseServiceHandler method modifyTable.
@Override
public void modifyTable(TTableDescriptor desc) throws TIOError, TException {
try {
TableDescriptor descriptor = tableDescriptorFromThrift(desc);
connectionCache.getAdmin().modifyTable(descriptor);
} catch (IOException e) {
throw getTIOError(e);
}
}
use of org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor in project hbase by apache.
the class ThriftHBaseServiceHandler method getTableDescriptor.
@Override
public TTableDescriptor getTableDescriptor(TTableName table) throws TIOError, TException {
try {
TableName tableName = ThriftUtilities.tableNameFromThrift(table);
TableDescriptor tableDescriptor = connectionCache.getAdmin().getDescriptor(tableName);
return tableDescriptorFromHBase(tableDescriptor);
} catch (IOException e) {
throw getTIOError(e);
}
}
use of org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor in project hbase by apache.
the class ThriftHBaseServiceHandler method createTable.
@Override
public void createTable(TTableDescriptor desc, List<ByteBuffer> splitKeys) throws TIOError, TException {
try {
TableDescriptor descriptor = tableDescriptorFromThrift(desc);
byte[][] split = splitKeyFromThrift(splitKeys);
if (split != null) {
connectionCache.getAdmin().createTable(descriptor, split);
} else {
connectionCache.getAdmin().createTable(descriptor);
}
} catch (IOException e) {
throw getTIOError(e);
}
}
use of org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor in project hbase by apache.
the class TestThrift2HttpServer method talkToThriftServer.
@Override
protected void talkToThriftServer(String url, int customHeaderSize) throws Exception {
THttpClient httpClient = new THttpClient(url);
httpClient.open();
if (customHeaderSize > 0) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < customHeaderSize; i++) {
sb.append("a");
}
httpClient.setCustomHeader("User-Agent", sb.toString());
}
try {
TProtocol prot;
prot = new TBinaryProtocol(httpClient);
THBaseService.Client client = new THBaseService.Client(prot);
TTableName tTableName = new TTableName();
tTableName.setNs(Bytes.toBytes(""));
tTableName.setQualifier(Bytes.toBytes(TABLENAME));
if (!tableCreated) {
Assert.assertTrue(!client.tableExists(tTableName));
TTableDescriptor tTableDescriptor = new TTableDescriptor();
tTableDescriptor.setTableName(tTableName);
TColumnFamilyDescriptor columnFamilyDescriptor = new TColumnFamilyDescriptor();
columnFamilyDescriptor.setName(Bytes.toBytes(TABLENAME));
tTableDescriptor.addToColumns(columnFamilyDescriptor);
client.createTable(tTableDescriptor, new ArrayList<>());
tableCreated = true;
}
Assert.assertTrue(client.tableExists(tTableName));
} finally {
httpClient.close();
}
}
use of org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor in project hbase by apache.
the class ThriftAdmin method createTable.
@Override
public void createTable(TableDescriptor desc, byte[][] splitKeys) throws IOException {
TTableDescriptor tTableDescriptor = ThriftUtilities.tableDescriptorFromHBase(desc);
List<ByteBuffer> splitKeyInBuffer = ThriftUtilities.splitKeyFromHBase(splitKeys);
try {
client.createTable(tTableDescriptor, splitKeyInBuffer);
} catch (TException e) {
throw new IOException(e);
}
}
Aggregations