public boolean isTableDisabled(final TableName tableName) { return getTableStateManager().isTableState(tableName, TableState.State.DISABLED, TableState.State.DISABLING); }
public boolean isTableState(TableName tableName, TableState.State... states) { try { TableState tableState = getTableState(tableName); return tableState.isInStates(states); } catch (IOException e) { LOG.error("Unable to get table " + tableName + " state", e); // XXX: is it safe to just return false here? return false; } }
if (tableStateManager.isTablePresent(desc.getTableName()) && (includeSysTables || !desc.getTableName().isSystemTable())) { htds.add(desc); if (tableStateManager.isTablePresent(s)) { TableDescriptor desc = tableDescriptors.get(s); if (desc != null) {
.queryForTableStates(this.master.getZooKeeper()).entrySet()) { if (this.master.getTableDescriptors().get(entry.getKey()) == null) { deleteZooKeeper(entry.getKey()); LOG.info("Purged table state entry from zookeepr for table not in hbase:meta: " + entry.getKey()); ts = getTableState(entry.getKey()); } catch (TableStateNotFoundException e) { LOG.info("Migrating table state from zookeeper to hbase:meta; tableName=" + entry.getKey() + ", state=" + entry.getValue()); updateMetaState(entry.getKey(), entry.getValue()); } else { LOG.warn("Table={} has no state and zookeeper state is in-between={} (neither " +
/** * Mark table state to Disabled * @param env MasterProcedureEnv */ protected static void setTableStateToDisabled(final MasterProcedureEnv env, final TableName tableName) throws IOException { // Flip the table to disabled env.getMasterServices().getTableStateManager().setTableState(tableName, TableState.State.DISABLED); LOG.info("Set {} to state={}", tableName, TableState.State.DISABLED); }
/** * Update state of the table in meta only. This is required by hbck in some situations to cleanup * stuck assign/ unassign regions procedures for the table. * * @return previous state of the table */ @Override public GetTableStateResponse setTableStateInMeta(RpcController controller, SetTableStateInMetaRequest request) throws ServiceException { TableName tn = ProtobufUtil.toTableName(request.getTableName()); try { HBaseProtos.TableState prevState = this.master.getTableStateManager().getTableState(tn).convert(); this.master.getTableStateManager().setTableState(tn, TableState.convert(tn, request.getTableState()).getState()); return GetTableStateResponse.newBuilder().setTableState(prevState).build(); } catch (Exception e) { throw new ServiceException(e); } }
new TableStateManager(this); this.tableStateManager.start();
fixTableState(new TableState(tableName, TableState.State.ENABLED)); continue; LOG.warn(tableName + " has no table state in hbase:meta, assuming ENABLED"); MetaTableAccessor.updateTableState(connection, tableName, TableState.State.ENABLED); fixTableState(new TableState(tableName, TableState.State.ENABLED)); tableName2State.put(tableName, TableState.State.ENABLED); } else { fixTableState(tableState); tableName2State.put(tableName, tableState.getState());
/** * Mark table state to Disabling * @param env MasterProcedureEnv */ private static void setTableStateToDisabling(final MasterProcedureEnv env, final TableName tableName) throws IOException { // Set table disabling flag up in zk. env.getMasterServices().getTableStateManager().setTableState(tableName, TableState.State.DISABLING); LOG.info("Set {} to state={}", tableName, TableState.State.DISABLING); }
public boolean isTableEnabled(final TableName tableName) { return getTableStateManager().isTableState(tableName, TableState.State.ENABLED); }
private boolean needSetLastPushedSequenceId(TableStateManager tsm, TableName tn) throws IOException { for (;;) { try { if (!tsm.getTableState(tn).isDisabling()) { return true; } Thread.sleep(SLEEP_INTERVAL_MS); } catch (TableStateNotFoundException e) { return false; } catch (InterruptedException e) { throw (IOException) new InterruptedIOException(e.getMessage()).initCause(e); } } }
protected static void setEnablingState(final MasterProcedureEnv env, final TableName tableName) throws IOException { // Mark the table as Enabling env.getMasterServices().getTableStateManager() .setTableState(tableName, TableState.State.ENABLING); }
private boolean waitForGroupTableOnline() { while (isMasterRunning(masterServices)) { try { TableStateManager tsm = masterServices.getTableStateManager(); if (!tsm.isTablePresent(RSGROUP_TABLE_NAME)) { createRSGroupTable(); } // try reading from the table try (Table table = conn.getTable(RSGROUP_TABLE_NAME)) { table.get(new Get(ROW_KEY)); } LOG.info( "RSGroup table=" + RSGROUP_TABLE_NAME + " is online, refreshing cached information"); RSGroupInfoManagerImpl.this.refresh(true); online = true; // flush any inconsistencies between ZK and HTable RSGroupInfoManagerImpl.this.flushConfig(); return true; } catch (Exception e) { LOG.warn("Failed to perform check", e); // 100ms is short so let's just ignore the interrupt Threads.sleepWithoutInterrupt(100); } } return false; }
MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost(); if (master.getTableStateManager().isTableState( TableName.valueOf(snapshot.getTable()), TableState.State.ENABLED)) { throw new UnsupportedOperationException("Table '" +
private boolean needReopen(TableStateManager tsm, TableName tn) throws IOException { for (;;) { try { TableState state = tsm.getTableState(tn); if (state.isEnabled()) { return true; } if (!state.isEnabling()) { return false; } Thread.sleep(SLEEP_INTERVAL_MS); } catch (TableStateNotFoundException e) { return false; } catch (InterruptedException e) { throw (IOException) new InterruptedIOException(e.getMessage()).initCause(e); } } }
/** * Mark table state to Enabled * @param env MasterProcedureEnv * @throws IOException */ protected static void setTableStateToEnabled( final MasterProcedureEnv env, final TableName tableName) throws IOException { // Flip the table to Enabled env.getMasterServices().getTableStateManager().setTableState( tableName, TableState.State.ENABLED); LOG.info("Table '" + tableName + "' was successfully enabled."); }
private void preTransitCheck(RegionStateNode regionNode, RegionState.State[] expectedStates) throws HBaseIOException { if (regionNode.getProcedure() != null) { throw new HBaseIOException(regionNode + " is currently in transition"); } if (!regionNode.isInState(expectedStates)) { throw new DoNotRetryRegionException("Unexpected state for " + regionNode); } if (getTableStateManager().isTableState(regionNode.getTable(), TableState.State.DISABLING, TableState.State.DISABLED)) { throw new DoNotRetryIOException(regionNode.getTable() + " is disabled for " + regionNode); } }
@Override public void checkTableModifiable(final TableName tableName) throws IOException, TableNotFoundException, TableNotDisabledException { if (isCatalogTable(tableName)) { throw new IOException("Can't modify catalog tables"); } checkTableExists(tableName); TableState ts = getTableStateManager().getTableState(tableName); if (!ts.isDisabled()) { throw new TableNotDisabledException("Not DISABLED; " + ts); } }
/** * Mark table state to Enabling * @param env MasterProcedureEnv * @param tableName the target table * @throws IOException */ protected static void setTableStateToEnabling( final MasterProcedureEnv env, final TableName tableName) throws IOException { // Set table disabling flag up in zk. LOG.info("Attempting to enable the table " + tableName); env.getMasterServices().getTableStateManager().setTableState( tableName, TableState.State.ENABLING); }
if (!master.getTableStateManager().isTableState(tableName, TableState.State.ENABLED)) { throw new DoNotRetryIOException("Table " + tableName + " is not enabled");