/** * Set table state to provided. Caller should lock table on write. * @param tableName table to change state for * @param newState new state */ public void setTableState(TableName tableName, TableState.State newState) throws IOException { ReadWriteLock lock = tnLock.getLock(tableName); lock.writeLock().lock(); try { updateMetaState(tableName, newState); } finally { lock.writeLock().unlock(); } }
/** * Set table state to provided but only if table not in specified states Caller should lock table * on write. * @param tableName table to change state for * @param newState new state * @param states states to check against */ public boolean setTableStateIfNotInStates(TableName tableName, TableState.State newState, TableState.State... states) throws IOException { ReadWriteLock lock = tnLock.getLock(tableName); lock.writeLock().lock(); try { TableState currentState = readMetaState(tableName); if (currentState == null) { throw new TableNotFoundException(tableName); } if (!currentState.inStates(states)) { updateMetaState(tableName, newState); return true; } else { return false; } } finally { lock.writeLock().unlock(); } }
/** * Set table state to provided but only if table in specified states Caller should lock table on * write. * @param tableName table to change state for * @param newState new state * @param states states to check against * @return null if succeed or table state if failed */ public TableState setTableStateIfInStates(TableName tableName, TableState.State newState, TableState.State... states) throws IOException { ReadWriteLock lock = tnLock.getLock(tableName); lock.writeLock().lock(); try { TableState currentState = readMetaState(tableName); if (currentState == null) { throw new TableNotFoundException(tableName); } if (currentState.inStates(states)) { updateMetaState(tableName, newState); return null; } else { return currentState; } } finally { lock.writeLock().unlock(); } }
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 " +