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

项目:ditb    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 *
 * @throws KeeperException
 * @throws org.apache.hadoop.hbase.TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState()
    throws KeeperException, IOException, CoordinatedStateException {
  Set<TableName> enablingTables = tableStateManager.
    getTablesInStates(ZooKeeperProtos.Table.State.ENABLING);
  if (enablingTables.size() != 0) {
    for (TableName tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      EnableTableHandler eth = new EnableTableHandler(this.server, tableName,
        this, tableLockManager, true);
      try {
        eth.prepare();
      } catch (TableNotFoundException e) {
        LOG.warn("Table " + tableName + " not found in hbase:meta to recover.");
        continue;
      }
      eth.process();
    }
  }
}
项目:pbase    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 *
 * @throws KeeperException
 * @throws org.apache.hadoop.hbase.TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState()
    throws KeeperException, IOException, CoordinatedStateException {
  Set<TableName> enablingTables = tableStateManager.
    getTablesInStates(ZooKeeperProtos.Table.State.ENABLING);
  if (enablingTables.size() != 0) {
    for (TableName tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      EnableTableHandler eth = new EnableTableHandler(this.server, tableName,
        this, tableLockManager, true);
      try {
        eth.prepare();
      } catch (TableNotFoundException e) {
        LOG.warn("Table " + tableName + " not found in hbase:meta to recover.");
        continue;
      }
      eth.process();
    }
  }
}
项目:HIndex    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 *
 * @throws KeeperException
 * @throws org.apache.hadoop.hbase.TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<TableName> enablingTables = ZKTable.getEnablingTables(watcher);
  if (enablingTables.size() != 0) {
    for (TableName tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      EnableTableHandler eth = new EnableTableHandler(this.server, tableName,
        catalogTracker, this, tableLockManager, true);
      try {
        eth.prepare();
      } catch (TableNotFoundException e) {
        LOG.warn("Table " + tableName + " not found in hbase:meta to recover.");
        continue;
      }
      eth.process();
    }
  }
}
项目:RStore    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 * 
 * @param enablingTables
 * @param isWatcherCreated
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState(Set<String> enablingTables,
    boolean isWatcherCreated) throws KeeperException, TableNotFoundException,
    IOException {
  if (enablingTables.size() != 0) {
    if (false == isWatcherCreated) {
      ZKUtil.listChildrenAndWatchForNewChildren(watcher,
          watcher.assignmentZNode);
    }
    for (String tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      new EnableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
}
项目:PyroDB    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 *
 * @throws KeeperException
 * @throws org.apache.hadoop.hbase.TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState()
    throws KeeperException, IOException, CoordinatedStateException {
  Set<TableName> enablingTables = tableStateManager.
    getTablesInStates(ZooKeeperProtos.Table.State.ENABLING);
  if (enablingTables.size() != 0) {
    for (TableName tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      EnableTableHandler eth = new EnableTableHandler(this.server, tableName,
        catalogTracker, this, tableLockManager, true);
      try {
        eth.prepare();
      } catch (TableNotFoundException e) {
        LOG.warn("Table " + tableName + " not found in hbase:meta to recover.");
        continue;
      }
      eth.process();
    }
  }
}
项目:c5    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 *
 * @throws KeeperException
 * @throws org.apache.hadoop.hbase.TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<TableName> enablingTables = ZKTable.getEnablingTables(watcher);
  if (enablingTables.size() != 0) {
    for (TableName tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      new EnableTableHandler(this.server, tableName,
          catalogTracker, this, tableLockManager, true).prepare().process();
    }
  }
}
项目:HBase-Research    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 * 
 * @param enablingTables
 * @param isWatcherCreated
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState(Set<String> enablingTables,
    boolean isWatcherCreated) throws KeeperException, TableNotFoundException,
    IOException {
  if (enablingTables.size() != 0) {
    if (false == isWatcherCreated) {
      ZKUtil.listChildrenAndWatchForNewChildren(watcher,
          watcher.assignmentZNode);
    }
    for (String tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      new EnableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
}
项目:hbase-0.94.8-qod    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 * 
 * @param enablingTables
 * @param isWatcherCreated
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState(Set<String> enablingTables,
    boolean isWatcherCreated) throws KeeperException, TableNotFoundException,
    IOException {
  if (enablingTables.size() != 0) {
    if (false == isWatcherCreated) {
      ZKUtil.listChildrenAndWatchForNewChildren(watcher,
          watcher.assignmentZNode);
    }
    for (String tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      new EnableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
}
项目:hbase-0.94.8-qod    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 * 
 * @param enablingTables
 * @param isWatcherCreated
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState(Set<String> enablingTables,
    boolean isWatcherCreated) throws KeeperException, TableNotFoundException,
    IOException {
  if (enablingTables.size() != 0) {
    if (false == isWatcherCreated) {
      ZKUtil.listChildrenAndWatchForNewChildren(watcher,
          watcher.assignmentZNode);
    }
    for (String tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      new EnableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
}
项目:DominoHBase    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 *
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState()
    throws KeeperException, TableNotFoundException, IOException {
  Set<String> enablingTables = ZKTable.getEnablingTables(watcher);
  if (enablingTables.size() != 0) {
    for (String tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      new EnableTableHandler(this.server, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
}
项目:hindex    文件:AssignmentManager.java   
/**
 * Recover the tables that are not fully moved to ENABLED state. These tables
 * are in ENABLING state when the master restarted/switched
 * 
 * @param enablingTables
 * @param isWatcherCreated
 * @throws KeeperException
 * @throws TableNotFoundException
 * @throws IOException
 */
private void recoverTableInEnablingState(Set<String> enablingTables,
    boolean isWatcherCreated) throws KeeperException, TableNotFoundException,
    IOException {
  if (enablingTables.size() != 0) {
    if (false == isWatcherCreated) {
      ZKUtil.listChildrenAndWatchForNewChildren(watcher,
          watcher.assignmentZNode);
    }
    for (String tableName : enablingTables) {
      // Recover by calling EnableTableHandler
      LOG.info("The table " + tableName
          + " is in ENABLING state.  Hence recovering by moving the table"
          + " to ENABLED state.");
      // enableTable in sync way during master startup,
      // no need to invoke coprocessor
      new EnableTableHandler(this.master, tableName.getBytes(),
          catalogTracker, this, true).process();
    }
  }
}
项目:LCIndex-HBase-0.94.16    文件:HMaster.java   
public void enableTable(final byte [] tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preEnableTable(tableName);
  }
  this.executorService.submit(new EnableTableHandler(this, tableName,
    catalogTracker, assignmentManager, false));

  if (cpHost != null) {
    cpHost.postEnableTable(tableName);
  }
}
项目:pbase    文件:HMaster.java   
@Override
public void enableTable(final TableName tableName) throws IOException {
    checkInitialized();
    if (cpHost != null) {
        cpHost.preEnableTable(tableName);
    }
    LOG.info(getClientIdAuditPrefix() + " enable " + tableName);
    this.service.submit(new EnableTableHandler(this, tableName,
            assignmentManager, tableLockManager, false).prepare());
    if (cpHost != null) {
        cpHost.postEnableTable(tableName);
    }
}
项目:HIndex    文件:HMaster.java   
@Override
public void enableTable(final TableName tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preEnableTable(tableName);
  }
  LOG.info(getClientIdAuditPrefix() + " enable " + tableName);
  this.executorService.submit(new EnableTableHandler(this, tableName,
    catalogTracker, assignmentManager, tableLockManager, false).prepare());
  if (cpHost != null) {
    cpHost.postEnableTable(tableName);
 }
}
项目:HIndex    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 *
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  Server server = new HMaster(HTU.getConfiguration());
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);
  try {
    // set table in enabling state.
    am.getZKTable().setEnablingTable(REGIONINFO.getTable());
    new EnableTableHandler(server, REGIONINFO.getTable(),
        am.getCatalogTracker(), am, new NullTableLockManager(), true).prepare()
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getZKTable().isEnabledTable(REGIONINFO.getTable()));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getZKTable().setEnabledTable(REGIONINFO.getTable());
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:HIndex    文件:IndexMasterObserver.java   
@Override
public void postEnableTableHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
    TableName tableName) throws IOException {
  LOG.info("Entered into postEnableTableHandler of table " + tableName);
  if (!IndexUtils.isIndexTable(tableName.getNameAsString())) {
    MasterServices master = ctx.getEnvironment().getMasterServices();
    AssignmentManager am = master.getAssignmentManager();
    TableName indexTableName = TableName.valueOf(IndexUtils.getIndexTableName(tableName));
    // Index table may not present in 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. Then no need to call enable for index table
    // because it will be created as part of preMasterInitialization and enable.
    // 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 enable is progress for user table then index table should be in disabled state.
      // If disable is progress for index table wait until table disabled.
      if (waitUntilTableDisabled(timeout, indexTableName, am.getZKTable())) {
        new EnableTableHandler(master, indexTableName, master.getCatalogTracker(), am,
            master.getTableLockManager(), false).prepare().process();
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Table " + indexTableName + " not in DISABLED state to enable.");
        }
      }
    }
  }
  LOG.info("Exiting from postEnableTableHandler of table " + tableName);

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

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

  if (cpHost != null) {
    cpHost.postEnableTable(tableName);
  }
}
项目:PyroDB    文件:HMaster.java   
@Override
public void enableTable(final TableName tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preEnableTable(tableName);
  }
  LOG.info(getClientIdAuditPrefix() + " enable " + tableName);
  this.service.submit(new EnableTableHandler(this, tableName,
    catalogTracker, assignmentManager, tableLockManager, false).prepare());
  if (cpHost != null) {
    cpHost.postEnableTable(tableName);
 }
}
项目:PyroDB    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 *
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
    HTU.getConfiguration());
  Server server = new HMaster(HTU.getConfiguration(), csm);
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);
  try {
    // set table in enabling state.
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLING);
    new EnableTableHandler(server, REGIONINFO.getTable(),
        am.getCatalogTracker(), am, new NullTableLockManager(), true).prepare()
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getTableStateManager().isTableState(REGIONINFO.getTable(),
          Table.State.ENABLED));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLED);
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:c5    文件:HMaster.java   
@Override
public void enableTable(final TableName tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preEnableTable(tableName);
  }
  LOG.info(getClientIdAuditPrefix() + " enable " + tableName);
  this.executorService.submit(new EnableTableHandler(this, tableName,
    catalogTracker, assignmentManager, tableLockManager, false).prepare());
  if (cpHost != null) {
    cpHost.postEnableTable(tableName);
 }
}
项目:c5    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 *
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  Server server = new HMaster(HTU.getConfiguration());
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);
  try {
    // set table in enabling state.
    am.getZKTable().setEnablingTable(REGIONINFO.getTable());
    new EnableTableHandler(server, REGIONINFO.getTable(),
        am.getCatalogTracker(), am, new NullTableLockManager(), true).prepare()
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getZKTable().isEnabledTable(REGIONINFO.getTable()));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getZKTable().setEnabledTable(REGIONINFO.getTable());
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:HBase-Research    文件:HMaster.java   
public void enableTable(final byte [] tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preEnableTable(tableName);
  }
  this.executorService.submit(new EnableTableHandler(this, tableName,
    catalogTracker, assignmentManager, false));

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

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

  if (cpHost != null) {
    cpHost.postEnableTable(tableName);
  }
}
项目:DominoHBase    文件:HMaster.java   
@Override
public void enableTable(final byte[] tableName) throws IOException {
  checkInitialized();
  if (cpHost != null) {
    cpHost.preEnableTable(tableName);
  }
  this.executorService.submit(new EnableTableHandler(this, tableName,
    catalogTracker, assignmentManager, false));
  if (cpHost != null) {
    cpHost.postEnableTable(tableName);
 }
}
项目:DominoHBase    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 * 
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  Server server = new HMaster(HTU.getConfiguration());
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);
  try {
    // set table in enabling state.
    am.getZKTable().setEnablingTable(REGIONINFO.getTableNameAsString());
    new EnableTableHandler(server, REGIONINFO.getTableName(), am.getCatalogTracker(), am, true)
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getZKTable().isEnabledTable(REGIONINFO.getTableNameAsString()));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getZKTable().setEnabledTable(REGIONINFO.getTableNameAsString());
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:hindex    文件:IndexMasterObserver.java   
@Override
public void postEnableTableHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
    byte[] tableName) throws IOException {
  LOG.info("Entered into postEnableTableHandler of table " + Bytes.toString(tableName));
  if (false == IndexUtils.isIndexTable(Bytes.toString(tableName))) {
    MasterServices master = ctx.getEnvironment().getMasterServices();
    AssignmentManager am = master.getAssignmentManager();
    String indexTableName = IndexUtils.getIndexTableName(tableName);
    // Index table may not present in 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. Then no need to call enable for index table
    // because it will be created as part of preMasterInitialization and enable.
    // 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 enable is progress for user table then index table should be in disabled state.
      // If disable is progress for index table wait until table disabled.
      if (waitUntilTableDisabled(timeout, indexTableName, am.getZKTable())) {
        new EnableTableHandler(master, Bytes.toBytes(indexTableName), master.getCatalogTracker(),
            am, false).process();
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Table " + indexTableName + " not in DISABLED state to enable.");
        }
      }
    }
  }
  LOG.info("Exiting from postEnableTableHandler of table " + Bytes.toString(tableName));

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

  if (cpHost != null) {
    cpHost.postEnableTable(tableName);
  }
}
项目:pbase    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 *
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test (timeout=180000)
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
    HTU.getConfiguration());
  Server server = new HMaster(HTU.getConfiguration(), csm);
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);

  Whitebox.setInternalState(server, "metaTableLocator", Mockito.mock(MetaTableLocator.class));

  // Make it so we can get a catalogtracker from servermanager.. .needed
  // down in guts of server shutdown handler.
  Whitebox.setInternalState(server, "clusterConnection", am.getConnection());

  try {
    // set table in enabling state.
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLING);
    new EnableTableHandler(server, REGIONINFO.getTable(),
        am, new NullTableLockManager(), true).prepare()
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getTableStateManager().isTableState(REGIONINFO.getTable(),
          Table.State.ENABLED));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLED);
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}