ArrayList<HColumnDescriptor> columns) throws HBaseRestException {
HTableDescriptor htc = null;
try {
htc = this.admin.getTableDescriptor(Bytes.toBytes(tableName));
} catch (IOException e) {
throw new HBaseRestException("Table does not exist");
}
for (HColumnDescriptor column : columns) {
if (htc.hasFamily(Bytes.toBytes(column.getNameAsString()))) {
try {
this.admin.disableTable(tableName);
this.admin.modifyColumn(tableName, column.getNameAsString(), column);
this.admin.enableTable(tableName);
} catch (IOException e) {
throw new HBaseRestException("unable to modify column "
+ column.getNameAsString(), e);
}
} else {
try {
this.admin.disableTable(tableName);
this.admin.addColumn(tableName, column);
this.admin.enableTable(tableName);
} catch (IOException e) {
throw new HBaseRestException("unable to add column "
+ column.getNameAsString(), e);
}
}
}