本文整理汇总了Java中org.apache.hadoop.hbase.master.RegionState.State类的典型用法代码示例。如果您正苦于以下问题:Java State类的具体用法?Java State怎么用?Java State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
State类属于org.apache.hadoop.hbase.master.RegionState包,在下文中一共展示了State类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateRegionState
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* Update a region state. It will be put in transition if not already there.
*
* If we can't find the region info based on the region name in
* the transition, log a warning and return null.
*/
public RegionState updateRegionState(
final RegionTransition transition, final State state) {
byte [] regionName = transition.getRegionName();
HRegionInfo regionInfo = getRegionInfo(regionName);
if (regionInfo == null) {
String prettyRegionName = HRegionInfo.prettyPrint(
HRegionInfo.encodeRegionName(regionName));
LOG.warn("Failed to find region " + prettyRegionName
+ " in updating its state to " + state
+ " based on region transition " + transition);
return null;
}
return updateRegionState(regionInfo, state,
transition.getServerName());
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:RegionStates.java
示例2: getRegionByStateOfTable
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* Gets current state of all regions of the table.
* This method looks at the in-memory state. It does not go to <code>hbase:meta</code>.
* Method guaranteed to return keys for all states
* in {@link org.apache.hadoop.hbase.master.RegionState.State}
*
* @param tableName
* @return Online regions from <code>tableName</code>
*/
public synchronized Map<RegionState.State, List<HRegionInfo>>
getRegionByStateOfTable(TableName tableName) {
Map<RegionState.State, List<HRegionInfo>> tableRegions =
new HashMap<State, List<HRegionInfo>>();
for (State state : State.values()) {
tableRegions.put(state, new ArrayList<HRegionInfo>());
}
Map<String, RegionState> indexMap = regionStatesTableIndex.get(tableName);
if (indexMap == null)
return tableRegions;
for (RegionState regionState : indexMap.values()) {
tableRegions.get(regionState.getState()).add(regionState.getRegion());
}
return tableRegions;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:RegionStates.java
示例3: populatePool
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
@Override
protected void populatePool(ExecutorService pool) {
RegionStates regionStates = assignmentManager.getRegionStates();
for (HRegionInfo region: regions) {
if (regionStates.isRegionInTransition(region)
&& !regionStates.isRegionInState(region, State.FAILED_CLOSE)) {
continue;
}
final HRegionInfo hri = region;
pool.execute(Trace.wrap("DisableTableHandler.BulkDisabler",new Runnable() {
public void run() {
assignmentManager.unassign(hri, true);
}
}));
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:DisableTableHandler.java
示例4: assignMetaZkLess
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
private void assignMetaZkLess(RegionStates regionStates, RegionState regionState, long timeout,
Set<ServerName> previouslyFailedRs) throws IOException, KeeperException {
ServerName currentServer = regionState.getServerName();
if (serverManager.isServerOnline(currentServer)) {
LOG.info("Meta was in transition on " + currentServer);
assignmentManager.processRegionInTransitionZkLess();
} else {
if (currentServer != null) {
if (regionState.getRegion().getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) {
splitMetaLogBeforeAssignment(currentServer);
regionStates.logSplit(HRegionInfo.FIRST_META_REGIONINFO);
previouslyFailedRs.add(currentServer);
}
}
LOG.info("Re-assigning hbase:meta, it was on " + currentServer);
regionStates.updateRegionState(regionState.getRegion(), State.OFFLINE);
assignmentManager.assignMeta(regionState.getRegion());
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:HMaster.java
示例5: waitRegionInTransition
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
protected static void waitRegionInTransition(final MasterProcedureEnv env,
final List<HRegionInfo> regions) throws IOException, CoordinatedStateException {
final AssignmentManager am = env.getMasterServices().getAssignmentManager();
final RegionStates states = am.getRegionStates();
for (final HRegionInfo region : regions) {
ProcedureSyncWait.waitFor(env, "regions " + region.getRegionNameAsString() + " in transition",
new ProcedureSyncWait.Predicate<Boolean>() {
@Override
public Boolean evaluate() throws IOException {
if (states.isRegionInState(region, State.FAILED_OPEN)) {
am.regionOffline(region);
}
return !states.isRegionInTransition(region);
}
});
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:ProcedureSyncWait.java
示例6: setOfflineInZooKeeper
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* Set region as OFFLINED up in zookeeper
*
* @param state
* @return the version of the offline node if setting of the OFFLINE node was
* successful, -1 otherwise.
*/
private int setOfflineInZooKeeper(final RegionState state, final ServerName destination) {
if (!state.isClosed() && !state.isOffline()) {
String msg = "Unexpected state : " + state + " .. Cannot transit it to OFFLINE.";
this.server.abort(msg, new IllegalStateException(msg));
return -1;
}
regionStates.updateRegionState(state.getRegion(), State.OFFLINE);
int versionOfOfflineNode;
try {
// get the version after setting the znode to OFFLINE
versionOfOfflineNode = ZKAssign.createOrForceNodeOffline(watcher,
state.getRegion(), destination);
if (versionOfOfflineNode == -1) {
LOG.warn("Attempted to create/force node into OFFLINE state before "
+ "completing assignment but failed to do so for " + state);
return -1;
}
} catch (KeeperException e) {
server.abort("Unexpected ZK exception creating/setting node OFFLINE", e);
return -1;
}
return versionOfOfflineNode;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:AssignmentManager.java
示例7: recoverTableInDisablingState
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* 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();
}
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:AssignmentManager.java
示例8: recoverTableInEnablingState
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* 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();
}
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:AssignmentManager.java
示例9: asyncSetOfflineInZooKeeper
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* Set region as OFFLINED up in zookeeper asynchronously.
* @param state
* @return True if we succeeded, false otherwise (State was incorrect or failed
* updating zk).
*/
private boolean asyncSetOfflineInZooKeeper(final RegionState state,
final AsyncCallback.StringCallback cb, final ServerName destination) {
if (!state.isClosed() && !state.isOffline()) {
this.server.abort("Unexpected state trying to OFFLINE; " + state,
new IllegalStateException());
return false;
}
regionStates.updateRegionState(state.getRegion(), State.OFFLINE);
try {
ZKAssign.asyncCreateNodeOffline(watcher, state.getRegion(),
destination, cb, state);
} catch (KeeperException e) {
if (e instanceof NodeExistsException) {
LOG.warn("Node for " + state.getRegion() + " already exists");
} else {
server.abort("Unexpected ZK exception creating/setting node OFFLINE", e);
}
return false;
}
return true;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:AssignmentManager.java
示例10: onRegionOpen
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
private void onRegionOpen(final HRegionInfo hri, final ServerName sn, long openSeqNum) {
regionOnline(hri, sn, openSeqNum);
if (useZKForAssignment) {
try {
// Delete the ZNode if exists
ZKAssign.deleteNodeFailSilent(watcher, hri);
} catch (KeeperException ke) {
server.abort("Unexpected ZK exception deleting node " + hri, ke);
}
}
// reset the count, if any
failedOpenTracker.remove(hri.getEncodedName());
if (getTableStateManager().isTableState(hri.getTable(),
ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING)) {
invokeUnAssign(hri);
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:AssignmentManager.java
示例11: onRegionSplitReverted
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
private String onRegionSplitReverted(ServerName sn,
final HRegionInfo p, final HRegionInfo a, final HRegionInfo b) {
String s = checkInStateForSplit(sn, p, a, b);
if (!org.apache.commons.lang.StringUtils.isEmpty(s)) {
return s;
}
regionOnline(p, sn);
regionOffline(a);
regionOffline(b);
if (getTableStateManager().isTableState(p.getTable(),
ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING)) {
invokeUnAssign(p);
}
return null;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:AssignmentManager.java
示例12: assignMetaZkLess
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
private void assignMetaZkLess(RegionStates regionStates, RegionState regionState, long timeout,
Set<ServerName> previouslyFailedRs) throws IOException, KeeperException {
ServerName currentServer = regionState.getServerName();
if (serverManager.isServerOnline(currentServer)) {
LOG.info("Meta was in transition on " + currentServer);
assignmentManager.processRegionInTransitionZkLess();
} else {
if (currentServer != null) {
splitMetaLogBeforeAssignment(currentServer);
regionStates.logSplit(HRegionInfo.FIRST_META_REGIONINFO);
previouslyFailedRs.add(currentServer);
}
LOG.info("Re-assigning hbase:meta, it was on " + currentServer);
regionStates.updateRegionState(HRegionInfo.FIRST_META_REGIONINFO, State.OFFLINE);
assignmentManager.assignMeta();
}
}
开发者ID:grokcoder,项目名称:pbase,代码行数:18,代码来源:HMaster.java
示例13: waitForAssignment
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* Waits until the specified region has completed assignment.
* <p>
* If the region is already assigned, returns immediately. Otherwise, method
* blocks until the region is assigned.
* @param regionInfo region to wait on assignment for
* @throws InterruptedException
*/
public boolean waitForAssignment(HRegionInfo regionInfo)
throws InterruptedException {
while (!regionStates.isRegionOnline(regionInfo)) {
if (regionStates.isRegionInState(regionInfo, State.FAILED_OPEN)
|| this.server.isStopped()) {
return false;
}
// We should receive a notification, but it's
// better to have a timeout to recheck the condition here:
// it lowers the impact of a race condition if any
regionStates.waitForUpdate(100);
}
return true;
}
开发者ID:grokcoder,项目名称:pbase,代码行数:24,代码来源:AssignmentManager.java
示例14: onRegionOpen
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
private void onRegionOpen(
final HRegionInfo hri, final ServerName sn, long openSeqNum) {
regionOnline(hri, sn, openSeqNum);
if (useZKForAssignment) {
try {
// Delete the ZNode if exists
ZKAssign.deleteNodeFailSilent(watcher, hri);
} catch (KeeperException ke) {
server.abort("Unexpected ZK exception deleting node " + hri, ke);
}
}
// reset the count, if any
failedOpenTracker.remove(hri.getEncodedName());
if (getTableStateManager().isTableState(hri.getTable(),
ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING)) {
invokeUnAssign(hri);
}
}
开发者ID:grokcoder,项目名称:pbase,代码行数:20,代码来源:AssignmentManager.java
示例15: testForceAssignMergingRegion
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
@Test (timeout=180000)
public void testForceAssignMergingRegion() throws Exception {
// Region to use in test.
final HRegionInfo hri = HRegionInfo.FIRST_META_REGIONINFO;
// Need a mocked catalog tracker.
LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(
server.getConfiguration());
// Create an AM.
AssignmentManager am = new AssignmentManager(this.server,
this.serverManager, balancer, null, null, master.getTableLockManager());
RegionStates regionStates = am.getRegionStates();
try {
// First set the state of the region to merging
regionStates.updateRegionState(hri, RegionState.State.MERGING);
// Now, try to assign it with force new plan
am.assign(hri, true, true);
assertEquals("The region should be still in merging state",
RegionState.State.MERGING, regionStates.getRegionState(hri).getState());
} finally {
am.shutdown();
}
}
开发者ID:grokcoder,项目名称:pbase,代码行数:23,代码来源:TestAssignmentManager.java
示例16: updateRegionState
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* Update a region state. It will be put in transition if not already there.
*
* If we can't find the region info based on the region name in
* the transition, log a warning and return null.
*/
public synchronized RegionState updateRegionState(
final RegionTransition transition, final State state) {
byte [] regionName = transition.getRegionName();
HRegionInfo regionInfo = getRegionInfo(regionName);
if (regionInfo == null) {
String prettyRegionName = HRegionInfo.prettyPrint(
HRegionInfo.encodeRegionName(regionName));
LOG.warn("Failed to find region " + prettyRegionName
+ " in updating its state to " + state
+ " based on region transition " + transition);
return null;
}
return updateRegionState(regionInfo, state,
transition.getServerName());
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:22,代码来源:RegionStates.java
示例17: regionOffline
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* A region is offline, won't be in transition any more. Its state
* should be the specified expected state, which can only be
* Split/Merged/Offline/null(=Offline)/SplittingNew/MergingNew.
*/
public synchronized void regionOffline(
final HRegionInfo hri, final State expectedState) {
Preconditions.checkArgument(expectedState == null
|| RegionState.isUnassignable(expectedState),
"Offlined region should not be " + expectedState);
String encodedName = hri.getEncodedName();
State newState =
expectedState == null ? State.OFFLINE : expectedState;
updateRegionState(hri, newState);
regionsInTransition.remove(encodedName);
ServerName oldServerName = regionAssignments.remove(hri);
if (oldServerName != null) {
LOG.info("Offlined " + hri.getShortNameToLog() + " from " + oldServerName);
Set<HRegionInfo> oldRegions = serverHoldings.get(oldServerName);
oldRegions.remove(hri);
if (oldRegions.isEmpty()) {
serverHoldings.remove(oldServerName);
}
}
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:27,代码来源:RegionStates.java
示例18: testForceAssignMergingRegion
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
@Test
public void testForceAssignMergingRegion() throws Exception {
// Region to use in test.
final HRegionInfo hri = HRegionInfo.FIRST_META_REGIONINFO;
// Need a mocked catalog tracker.
CatalogTracker ct = Mockito.mock(CatalogTracker.class);
LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(
server.getConfiguration());
// Create an AM.
AssignmentManager am = new AssignmentManager(this.server,
this.serverManager, ct, balancer, null, null, master.getTableLockManager());
RegionStates regionStates = am.getRegionStates();
try {
// First set the state of the region to merging
regionStates.updateRegionState(hri, RegionState.State.MERGING);
// Now, try to assign it with force new plan
am.assign(hri, true, true);
assertEquals("The region should be still in merging state",
RegionState.State.MERGING, regionStates.getRegionState(hri).getState());
} finally {
am.shutdown();
}
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:24,代码来源:TestAssignmentManager.java
示例19: createRegionState
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* Add a region to RegionStates with the specified state.
* If the region is already in RegionStates, this call has
* no effect, and the original state is returned.
*
* @param hri the region info to create a state for
* @param newState the state to the region in set to
* @param serverName the server the region is transitioning on
* @param lastHost the last server that hosts the region
* @return the current state
*/
public synchronized RegionState createRegionState(final HRegionInfo hri,
State newState, ServerName serverName, ServerName lastHost) {
if (newState == null || (newState == State.OPEN && serverName == null)) {
newState = State.OFFLINE;
}
if (hri.isOffline() && hri.isSplit()) {
newState = State.SPLIT;
serverName = null;
}
String encodedName = hri.getEncodedName();
RegionState regionState = regionStates.get(encodedName);
if (regionState != null) {
LOG.warn("Tried to create a state for a region already in RegionStates, "
+ "used existing: " + regionState + ", ignored new: " + newState);
} else {
regionState = new RegionState(hri, newState, serverName);
putRegionState(regionState);
if (newState == State.OPEN) {
if (!serverName.equals(lastHost)) {
LOG.warn("Open region's last host " + lastHost
+ " should be the same as the current one " + serverName
+ ", ignored the last and used the current one");
lastHost = serverName;
}
lastAssignments.put(encodedName, lastHost);
regionAssignments.put(hri, lastHost);
} else if (!regionState.isUnassignable()) {
regionsInTransition.put(encodedName, regionState);
}
if (lastHost != null && newState != State.SPLIT) {
addToServerHoldings(lastHost, hri);
if (newState != State.OPEN) {
oldAssignments.put(encodedName, lastHost);
}
}
}
return regionState;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:50,代码来源:RegionStates.java
示例20: transitionOpenFromPendingOpenOrOpeningOnServer
import org.apache.hadoop.hbase.master.RegionState.State; //导入依赖的package包/类
/**
* Transition a region state to OPEN from OPENING/PENDING_OPEN
*/
public synchronized RegionState transitionOpenFromPendingOpenOrOpeningOnServer(
final RegionTransition transition, final RegionState fromState, final ServerName sn) {
if(fromState.isPendingOpenOrOpeningOnServer(sn)){
return updateRegionState(transition, State.OPEN);
}
return null;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:RegionStates.java
注:本文中的org.apache.hadoop.hbase.master.RegionState.State类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论