本文整理汇总了Java中org.apache.hadoop.hbase.master.RegionState.State.OFFLINE属性的典型用法代码示例。如果您正苦于以下问题:Java State.OFFLINE属性的具体用法?Java State.OFFLINE怎么用?Java State.OFFLINE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.hadoop.hbase.master.RegionState.State
的用法示例。
在下文中一共展示了State.OFFLINE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: regionOffline
/**
* 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);
}
}
}
示例2: createRegionState
/**
* 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;
}
示例3: regionOffline
/**
* 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 void regionOffline(
final HRegionInfo hri, final State expectedState) {
Preconditions.checkArgument(expectedState == null
|| RegionState.isUnassignable(expectedState),
"Offlined region should not be " + expectedState);
if (isRegionInState(hri, State.SPLITTING_NEW, State.MERGING_NEW)) {
// Remove it from all region maps
deleteRegion(hri);
return;
}
State newState =
expectedState == null ? State.OFFLINE : expectedState;
updateRegionState(hri, newState);
String encodedName = hri.getEncodedName();
synchronized (this) {
regionsInTransition.remove(encodedName);
ServerName oldServerName = regionAssignments.remove(hri);
if (oldServerName != null && serverHoldings.containsKey(oldServerName)) {
if (newState == State.MERGED || newState == State.SPLIT
|| hri.isMetaRegion() || tableStateManager.isTableState(hri.getTable(),
ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING)) {
// Offline the region only if it's merged/split, or the table is disabled/disabling.
// Otherwise, offline it from this server only when it is online on a different server.
LOG.info("Offlined " + hri.getShortNameToLog() + " from " + oldServerName);
removeFromServerHoldings(oldServerName, hri);
removeFromReplicaMapping(hri);
} else {
// Need to remember it so that we can offline it from this
// server when it is online on a different server.
oldAssignments.put(encodedName, oldServerName);
}
}
}
}
示例4: createRegionState
/**
* 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);
regionStates.put(encodedName, 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;
}
示例5: createRegionState
/**
* Add a region to RegionStates. If the region is split
* and offline, its state will be SPLIT. Otherwise, its state will
* be OFFLINE. If it is already in RegionStates, this call has
* no effect, and the original state is returned.
*/
public synchronized RegionState createRegionState(final HRegionInfo hri) {
State newState = (hri.isOffline() && hri.isSplit()) ? State.SPLIT : State.OFFLINE;
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);
regionStates.put(encodedName, regionState);
}
return regionState;
}