*/
@Override
public void preCreateTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
HTableDescriptor desc, HRegionInfo[] regions) throws IOException {
LOG.info("Entered into preCreateTable.");
MasterServices master = ctx.getEnvironment().getMasterServices();
if (desc instanceof IndexedHTableDescriptor) {
Map<Column, Pair<ValueType, Integer>> indexColDetails =
new HashMap<Column, Pair<ValueType, Integer>>();
String tableName = desc.getNameAsString();
checkEndsWithIndexSuffix(tableName);
String indexTableName = IndexUtils.getIndexTableName(tableName);
List<IndexSpecification> indices = ((IndexedHTableDescriptor) desc).getIndices();
// Even if indices list is empty,it will create index table also.
if (indices.isEmpty()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Empty indices. Index table may not created"
+ " if master goes down in between user table creation");
}
}
LOG.trace("Checking whether column families in "
+ "index specification are in actual table column familes.");
for (IndexSpecification iSpec : indices) {
checkColumnsForValidityAndConsistency(desc, iSpec, indexColDetails);
}
LOG.trace("Column families in index specifications " + "are in actual table column familes.");
boolean isTableExists = MetaReader.tableExists(master.getCatalogTracker(), tableName);
boolean isIndexTableExists =
MetaReader.tableExists(master.getCatalogTracker(), indexTableName);
if (isTableExists && isIndexTableExists) {
throw new TableExistsException("Table " + tableName + " already exist.");
} else if (isIndexTableExists) {
disableAndDeleteTable(master, indexTableName);