this.assignmentManager = assignmentManager;
String tableName = this.table.getTableName();
this.conf = server.getConfiguration();
// Check if table exists
if (FMetaReader.tableExists(conf, tableName)) {
throw new TableExistsException(tableName);
}
// If we have multiple client threads trying to create the table at the
// same time, given the async nature of the operation, the table
// could be in a state where .META. table hasn't been updated yet in
// the process() function.
// Use enabling state to tell if there is already a request for the same
// table in progress. This will introduce a new zookeeper call. Given
// createTable isn't a frequent operation, that should be ok.
try {
this.tableLockManager = fMasterServices.getTableLockManager();
if (tableLockManager.lockTable(tableName)) {
LOG.info("lock table '" + tableName + "' by CreateIndexHandler");
} else {
throw new TableLockedException(tableName + " has been locked. ");
}
try {
if (!this.assignmentManager.getZKTable().checkAndSetEnablingTable(
tableName))
throw new TableExistsException(tableName);
} catch (KeeperException e) {
tableLockManager.unlockTable(tableName);
throw new IOException("Unable to ensure that the table will be"
+ " enabling because of a ZooKeeper issue", e);
}