Java 类org.apache.hadoop.hbase.master.handler.DisableTableHandler 实例源码

项目:ditb    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 *
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInDisablingState()
    throws KeeperException, IOException, CoordinatedStateException {
  Set<TableName> disablingTables =
    tableStateManager.getTablesInStates(ZooKeeperProtos.Table.State.DISABLING);
  if (disablingTables.size() != 0) {
    for (TableName tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.server, tableName,
          this, tableLockManager, true).prepare().process();
    }
  }
}
项目:LCIndex-HBase-0.94.16    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 * 
 * @param disablingTables
 * @return
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private boolean recoverTableInDisablingState(Set<String> disablingTables)
    throws KeeperException, TableNotFoundException, IOException {
  boolean isWatcherCreated = false;
  if (disablingTables.size() != 0) {
    // Create a watcher on the zookeeper node
    ZKUtil.listChildrenAndWatchForNewChildren(watcher,
        watcher.assignmentZNode);
    isWatcherCreated = true;
    for (String tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
  return isWatcherCreated;
}
项目:pbase    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 *
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInDisablingState()
    throws KeeperException, IOException, CoordinatedStateException {
  Set<TableName> disablingTables =
    tableStateManager.getTablesInStates(ZooKeeperProtos.Table.State.DISABLING);
  if (disablingTables.size() != 0) {
    for (TableName tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.server, tableName,
          this, tableLockManager, true).prepare().process();
    }
  }
}
项目:HIndex    文件:IndexMasterObserver.java   
private void disableAndDeleteTable(MasterServices master, TableName tableName) throws IOException {
  LOG.error(tableName + " already exists.  Disabling and deleting table " + tableName + '.');
  boolean disabled = master.getAssignmentManager().getZKTable().isDisabledTable(tableName);
  if (false == disabled) {
    LOG.info("Disabling table " + tableName + '.');
    new DisableTableHandler(master, tableName, master.getCatalogTracker(),
        master.getAssignmentManager(), master.getTableLockManager(), false).prepare().process();
    if (false == master.getAssignmentManager().getZKTable().isDisabledTable(tableName)) {
      throw new DoNotRetryIOException("Table " + tableName + " not disabled.");
    }
  }
  LOG.info("Disabled table " + tableName + '.');
  LOG.info("Deleting table " + tableName + '.');
  new DeleteTableHandler(tableName, master, master).prepare().process();
  if (true == MetaReader.tableExists(master.getCatalogTracker(), tableName)) {
    throw new DoNotRetryIOException("Table " + tableName + " not  deleted.");
  }
  LOG.info("Deleted table " + tableName + '.');
}
项目:IRIndex    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 * 
 * @param disablingTables
 * @return
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private boolean recoverTableInDisablingState(Set<String> disablingTables)
    throws KeeperException, TableNotFoundException, IOException {
  boolean isWatcherCreated = false;
  if (disablingTables.size() != 0) {
    // Create a watcher on the zookeeper node
    ZKUtil.listChildrenAndWatchForNewChildren(watcher,
        watcher.assignmentZNode);
    isWatcherCreated = true;
    for (String tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
  return isWatcherCreated;
}
项目:RStore    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 * 
 * @param disablingTables
 * @return
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private boolean recoverTableInDisablingState(Set<String> disablingTables)
    throws KeeperException, TableNotFoundException, IOException {
  boolean isWatcherCreated = false;
  if (disablingTables.size() != 0) {
    // Create a watcher on the zookeeper node
    ZKUtil.listChildrenAndWatchForNewChildren(watcher,
        watcher.assignmentZNode);
    isWatcherCreated = true;
    for (String tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
  return isWatcherCreated;
}
项目:PyroDB    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 *
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInDisablingState()
    throws KeeperException, IOException, CoordinatedStateException {
  Set<TableName> disablingTables =
    tableStateManager.getTablesInStates(ZooKeeperProtos.Table.State.DISABLING);
  if (disablingTables.size() != 0) {
    for (TableName tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.server, tableName, catalogTracker,
          this, tableLockManager, true).prepare().process();
    }
  }
}
项目:HBase-Research    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 * 
 * @param disablingTables
 * @return
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private boolean recoverTableInDisablingState(Set<String> disablingTables)
    throws KeeperException, TableNotFoundException, IOException {
  boolean isWatcherCreated = false;
  if (disablingTables.size() != 0) {
    // Create a watcher on the zookeeper node
    ZKUtil.listChildrenAndWatchForNewChildren(watcher,
        watcher.assignmentZNode);
    isWatcherCreated = true;
    for (String tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
  return isWatcherCreated;
}
项目:hbase-0.94.8-qod    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 * 
 * @param disablingTables
 * @return
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private boolean recoverTableInDisablingState(Set<String> disablingTables)
    throws KeeperException, TableNotFoundException, IOException {
  boolean isWatcherCreated = false;
  if (disablingTables.size() != 0) {
    // Create a watcher on the zookeeper node
    ZKUtil.listChildrenAndWatchForNewChildren(watcher,
        watcher.assignmentZNode);
    isWatcherCreated = true;
    for (String tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
  return isWatcherCreated;
}
项目:hbase-0.94.8-qod    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 * 
 * @param disablingTables
 * @return
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private boolean recoverTableInDisablingState(Set<String> disablingTables)
    throws KeeperException, TableNotFoundException, IOException {
  boolean isWatcherCreated = false;
  if (disablingTables.size() != 0) {
    // Create a watcher on the zookeeper node
    ZKUtil.listChildrenAndWatchForNewChildren(watcher,
        watcher.assignmentZNode);
    isWatcherCreated = true;
    for (String tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
  return isWatcherCreated;
}
项目:hindex    文件:IndexMasterObserver.java   
private void disableAndDeleteTable(MasterServices master, String tableName) throws IOException {
  byte[] tableNameInBytes = Bytes.toBytes(tableName);
  LOG.error(tableName + " already exists.  Disabling and deleting table " + tableName + '.');
  boolean disabled = master.getAssignmentManager().getZKTable().isDisabledTable(tableName);
  if (false == disabled) {
    LOG.info("Disabling table " + tableName + '.');
    new DisableTableHandler(master, tableNameInBytes, master.getCatalogTracker(),
        master.getAssignmentManager(), false).process();
    if (false == master.getAssignmentManager().getZKTable().isDisabledTable(tableName)) {
      throw new IOException("Table " + tableName + " not disabled.");
    }
  }
  LOG.info("Disabled table " + tableName + '.');
  LOG.info("Deleting table " + tableName + '.');
  new DeleteTableHandler(tableNameInBytes, master, master).process();
  if (true == MetaReader.tableExists(master.getCatalogTracker(), tableName)) {
    throw new IOException("Table " + tableName + " not  deleted.");
  }
  LOG.info("Deleted table " + tableName + '.');
}
项目:hindex    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 * 
 * @param disablingTables
 * @return
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private boolean recoverTableInDisablingState(Set<String> disablingTables)
    throws KeeperException, TableNotFoundException, IOException {
  boolean isWatcherCreated = false;
  if (disablingTables.size() != 0) {
    // Create a watcher on the zookeeper node
    ZKUtil.listChildrenAndWatchForNewChildren(watcher,
        watcher.assignmentZNode);
    isWatcherCreated = true;
    for (String tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
  return isWatcherCreated;
}
项目:LCIndex-HBase-0.94.16    文件:HMaster.java   
public void disableTable(final byte [] tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  this.executorService.submit(new DisableTableHandler(this, tableName,
      catalogTracker, assignmentManager, false));

  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:pbase    文件:HMaster.java   
@Override
public void disableTable(final TableName tableName) throws IOException {
    checkInitialized();
    if (cpHost != null) {
        cpHost.preDisableTable(tableName);
    }
    LOG.info(getClientIdAuditPrefix() + " disable " + tableName);
    this.service.submit(new DisableTableHandler(this, tableName,
            assignmentManager, tableLockManager, false).prepare());
    if (cpHost != null) {
        cpHost.postDisableTable(tableName);
    }
}
项目:HIndex    文件:HMaster.java   
@Override
public void disableTable(final TableName tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  LOG.info(getClientIdAuditPrefix() + " disable " + tableName);
  this.executorService.submit(new DisableTableHandler(this, tableName,
    catalogTracker, assignmentManager, tableLockManager, false).prepare());
  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:HIndex    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 *
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInDisablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<TableName> disablingTables = ZKTable.getDisablingTables(watcher);
  if (disablingTables.size() != 0) {
    for (TableName tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.server, tableName, catalogTracker,
          this, tableLockManager, true).prepare().process();
    }
  }
}
项目:HIndex    文件:IndexMasterObserver.java   
@Override
public void postDisableTableHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
    TableName tableName) throws IOException {
  LOG.info("Entered into postDisableTableHandler of table " + tableName);
  MasterServices master = ctx.getEnvironment().getMasterServices();
  AssignmentManager am = master.getAssignmentManager();
  try {
    if (!IndexUtils.isIndexTable(tableName.getNameAsString())) {
      TableName indexTableName = TableName.valueOf(IndexUtils.getIndexTableName(tableName));
      // Index table may not present following three cases.
      // 1) Index details are not specified during table creation then index table wont be
      // created.
      // 2) Even we specify index details if master restarted in the middle of user table creation
      // corresponding index table wont be created. But without creating index table user table
      // wont
      // be disabled. No need to call disable for index table at that time.
      // 3) Index table may be deleted but this wont happen without deleting user table.
      if (am.getZKTable().isTablePresent(indexTableName)) {
        long timeout =
            master.getConfiguration().getLong("hbase.bulk.assignment.waiton.empty.rit",
              5 * 60 * 1000);
        // Both user table and index table should not be in enabling/disabling state at a time.
        // If disable is progress for user table then index table should be in ENABLED state.
        // If enable is progress for index table wait until table enabled.
        if (waitUntilTableEnabled(timeout, indexTableName, am.getZKTable())) {
          new DisableTableHandler(master, indexTableName, master.getCatalogTracker(), am,
              master.getTableLockManager(), false).process();
        } else {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Table " + indexTableName + " not in ENABLED state to disable.");
          }
        }
      }
    }
  } finally {
    // clear user table region plans in secondary index load balancer.
    clearRegionPlans((HMaster) master, tableName.getNamespaceAsString());
  }
  LOG.info("Exiting from postDisableTableHandler of table " + tableName);
}
项目:IRIndex    文件:HMaster.java   
public void disableTable(final byte [] tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  this.executorService.submit(new DisableTableHandler(this, tableName,
      catalogTracker, assignmentManager, false));

  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:RStore    文件:HMaster.java   
public void disableTable(final byte [] tableName) throws IOException {
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  this.executorService.submit(new DisableTableHandler(this, tableName,
    catalogTracker, assignmentManager, false));

  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:PyroDB    文件:HMaster.java   
@Override
public void disableTable(final TableName tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  LOG.info(getClientIdAuditPrefix() + " disable " + tableName);
  this.service.submit(new DisableTableHandler(this, tableName,
    catalogTracker, assignmentManager, tableLockManager, false).prepare());
  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:c5    文件:HMaster.java   
@Override
public void disableTable(final TableName tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  LOG.info(getClientIdAuditPrefix() + " disable " + tableName);
  this.executorService.submit(new DisableTableHandler(this, tableName,
    catalogTracker, assignmentManager, tableLockManager, false).prepare());
  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:c5    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 *
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInDisablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<TableName> disablingTables = ZKTable.getDisablingTables(watcher);
  if (disablingTables.size() != 0) {
    for (TableName tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.server, tableName, catalogTracker,
          this, tableLockManager, true).prepare().process();
    }
  }
}
项目:HBase-Research    文件:HMaster.java   
public void disableTable(final byte [] tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  this.executorService.submit(new DisableTableHandler(this, tableName,
      catalogTracker, assignmentManager, false));

  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:hbase-0.94.8-qod    文件:HMaster.java   
public void disableTable(final byte [] tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  this.executorService.submit(new DisableTableHandler(this, tableName,
      catalogTracker, assignmentManager, false));

  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:hbase-0.94.8-qod    文件:HMaster.java   
public void disableTable(final byte [] tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  this.executorService.submit(new DisableTableHandler(this, tableName,
      catalogTracker, assignmentManager, false));

  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:DominoHBase    文件:HMaster.java   
@Override
public void disableTable(final byte[] tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  this.executorService.submit(new DisableTableHandler(this, tableName,
    catalogTracker, assignmentManager, false));
  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:DominoHBase    文件:AssignmentManager.java   
/**
 * Recover the tables that were not fully moved to DISABLED state. These
 * tables are in DISABLING state when the master restarted/switched.
 *
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInDisablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<String> disablingTables = ZKTable.getDisablingTables(watcher);
  if (disablingTables.size() != 0) {
    for (String tableName : disablingTables) {
      // Recover by calling DisableTableHandler
      LOG.info("The table " + tableName
          + " is in DISABLING state.  Hence recovering by moving the table"
          + " to DISABLED state.");
      new DisableTableHandler(this.server, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
}
项目:hindex    文件:IndexMasterObserver.java   
/**
 * @param IndexedHTableDescriptor iDesc
 * @param HRegionInfo [] regions
 * @param MasterServices master
 * @throws NotAllMetaRegionsOnlineException
 * @throws IOException
 */
private void createSecondaryIndexTable(IndexedHTableDescriptor iDesc, byte[][] splitKeys,
    MasterServices master, boolean disableTable) throws NotAllMetaRegionsOnlineException,
    IOException {
  String indexTableName = IndexUtils.getIndexTableName(iDesc.getNameAsString());
  LOG.info("Creating secondary index table " + indexTableName + " for table "
      + iDesc.getNameAsString() + '.');
  HTableDescriptor indexTableDesc = new HTableDescriptor(indexTableName);
  HColumnDescriptor columnDescriptor = new HColumnDescriptor(Constants.IDX_COL_FAMILY);
  String dataBlockEncodingAlgo =
      master.getConfiguration().get("index.data.block.encoding.algo", "NONE");
  DataBlockEncoding[] values = DataBlockEncoding.values();

  for (DataBlockEncoding dataBlockEncoding : values) {
    if (dataBlockEncoding.toString().equals(dataBlockEncodingAlgo)) {
      columnDescriptor.setDataBlockEncoding(dataBlockEncoding);
    }
  }

  indexTableDesc.addFamily(columnDescriptor);
  indexTableDesc.setValue(HTableDescriptor.SPLIT_POLICY,
    ConstantSizeRegionSplitPolicy.class.getName());
  indexTableDesc.setMaxFileSize(Long.MAX_VALUE);
  LOG.info("Setting the split policy for the Index Table " + indexTableName
      + " as ConstantSizeRegionSplitPolicy with maxFileSize as " + Long.MAX_VALUE + '.');
  HRegionInfo[] newRegions = getHRegionInfos(indexTableDesc, splitKeys);
  new CreateTableHandler(master, master.getMasterFileSystem(), master.getServerManager(),
      indexTableDesc, master.getConfiguration(), newRegions, master.getCatalogTracker(),
      master.getAssignmentManager()).process();
  // Disable the index table so that when we enable the main table both can be enabled
  if (disableTable) {
    new DisableTableHandler(master, Bytes.toBytes(indexTableName), master.getCatalogTracker(),
        master.getAssignmentManager(), false).process();
  }
  LOG.info("Created secondary index table " + indexTableName + " for table "
      + iDesc.getNameAsString() + '.');

}
项目:hindex    文件:HMaster.java   
public void disableTable(final byte [] tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preDisableTable(tableName);
  }
  this.executorService.submit(new DisableTableHandler(this, tableName,
      catalogTracker, assignmentManager, false));

  if (cpHost != null) {
    cpHost.postDisableTable(tableName);
  }
}
项目:HIndex    文件:IndexMasterObserver.java   
/**
 * @param HTableDescriptor desc
 * @param HRegionInfo [] regions
 * @param MasterServices master
 * @throws NotAllMetaRegionsOnlineException
 * @throws IOException
 */
private void createSecondaryIndexTable(HTableDescriptor desc, byte[][] splitKeys,
    MasterServices master, boolean disableTable) throws NotAllMetaRegionsOnlineException,
    IOException {
  TableName indexTableName =
      TableName.valueOf(IndexUtils.getIndexTableName(desc.getNameAsString()));
  LOG.info("Creating secondary index table " + indexTableName + " for table "
      + desc.getNameAsString() + '.');
  HTableDescriptor indexTableDesc = new HTableDescriptor(indexTableName);
  HColumnDescriptor columnDescriptor = new HColumnDescriptor(Constants.IDX_COL_FAMILY);
  String dataBlockEncodingAlgo =
      master.getConfiguration().get("index.data.block.encoding.algo", "NONE");
  DataBlockEncoding[] values = DataBlockEncoding.values();

  for (DataBlockEncoding dataBlockEncoding : values) {
    if (dataBlockEncoding.toString().equals(dataBlockEncodingAlgo)) {
      columnDescriptor.setDataBlockEncoding(dataBlockEncoding);
    }
  }

  // TODO read this data from a config file??
  columnDescriptor.setBlocksize(8 * 1024);// 8KB

  indexTableDesc.addFamily(columnDescriptor);
  indexTableDesc.setValue(HTableDescriptor.SPLIT_POLICY, IndexRegionSplitPolicy.class.getName());
  LOG.info("Setting the split policy for the Index Table " + indexTableName + " as "
      + IndexRegionSplitPolicy.class.getName() + '.');
  HRegionInfo[] newRegions = getHRegionInfos(indexTableDesc, splitKeys);
  CreateTableHandler tableHandler =
      new CreateTableHandler(master, master.getMasterFileSystem(), indexTableDesc,
          master.getConfiguration(), newRegions, master);
  tableHandler.prepare();
  tableHandler.process();
  // Disable the index table so that when we enable the main table both can be enabled
  if (disableTable) {
    new DisableTableHandler(master, indexTableName, master.getCatalogTracker(),
        master.getAssignmentManager(), master.getTableLockManager(), false).prepare().process();
  }
  LOG.info("Created secondary index table " + indexTableName + " for table "
      + desc.getNameAsString() + '.');
}
项目:hindex    文件:IndexMasterObserver.java   
@Override
public void postDisableTableHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
    byte[] tableName) throws IOException {
  LOG.info("Entered into postDisableTableHandler of table " + Bytes.toString(tableName));
  MasterServices master = ctx.getEnvironment().getMasterServices();
  AssignmentManager am = master.getAssignmentManager();
  try {
    if (false == IndexUtils.isIndexTable(Bytes.toString(tableName))) {
      String indexTableName = IndexUtils.getIndexTableName(tableName);
      // Index table may not present following three cases.
      // 1) Index details are not specified during table creation then index table wont be
      // created.
      // 2) Even we specify index details if master restarted in the middle of user table creation
      // corresponding index table wont be created. But without creating index table user table
      // wont
      // be disabled. No need to call disable for index table at that time.
      // 3) Index table may be deleted but this wont happen without deleting user table.
      if (true == am.getZKTable().isTablePresent(indexTableName)) {
        long timeout =
            master.getConfiguration().getLong("hbase.bulk.assignment.waiton.empty.rit",
              5 * 60 * 1000);
        // Both user table and index table should not be in enabling/disabling state at a time.
        // If disable is progress for user table then index table should be in ENABLED state.
        // If enable is progress for index table wait until table enabled.
        waitUntilTableEnabled(timeout, indexTableName, am.getZKTable());
        if (waitUntilTableEnabled(timeout, indexTableName, am.getZKTable())) {
          new DisableTableHandler(master, Bytes.toBytes(indexTableName),
              master.getCatalogTracker(), am, false).process();
        } else {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Table " + indexTableName + " not in ENABLED state to disable.");
          }
        }
      }
    }
  } finally {
    // clear user table region plans in secondary index load balancer.
    clearRegionPlans((HMaster) master, Bytes.toString(tableName));
  }
  LOG.info("Exiting from postDisableTableHandler of table " + Bytes.toString(tableName));
}