-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-23313 [hbck2] setRegionState should update Master in-memory sta… #864
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e3fc279
HBASE-23313 [hbck2] setRegionState should update Master in-memory sta…
wchevreuil 303e61b
addressing checkstyles complaints from previous build; Added related …
wchevreuil 8127ba2
another attempt to address checkstyle complaints about order of impor…
wchevreuil e540f14
changed to receive list of several RegionStates in a single RPC
wchevreuil 47b34bc
addressing the whitespace checkstyle issues
wchevreuil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ | |
import org.apache.hadoop.hbase.UnknownRegionException; | ||
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; | ||
import org.apache.hadoop.hbase.client.MasterSwitchType; | ||
import org.apache.hadoop.hbase.client.Put; | ||
import org.apache.hadoop.hbase.client.RegionInfo; | ||
import org.apache.hadoop.hbase.client.RegionInfoBuilder; | ||
import org.apache.hadoop.hbase.client.Table; | ||
|
@@ -197,6 +198,7 @@ | |
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProcedureResultResponse; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProceduresRequest; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProceduresResponse; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetRegionStateInMetaResponse; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetSchemaAlterStatusResponse; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableDescriptorsRequest; | ||
|
@@ -276,6 +278,7 @@ | |
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningResponse; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaResponse; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetRegionStateInMetaRequest; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos | ||
.SetSnapshotCleanupRequest; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos | ||
|
@@ -2465,6 +2468,42 @@ public GetTableStateResponse setTableStateInMeta(RpcController controller, | |
} | ||
} | ||
|
||
/** | ||
* Update state of the region in meta only. This is required by hbck in some situations to cleanup | ||
* stuck assign/ unassign regions procedures for the table. | ||
* | ||
* @return previous states of the regions | ||
*/ | ||
@Override | ||
public GetRegionStateInMetaResponse setRegionStateInMeta(RpcController controller, | ||
SetRegionStateInMetaRequest request) throws ServiceException { | ||
final GetRegionStateInMetaResponse.Builder builder = GetRegionStateInMetaResponse.newBuilder(); | ||
for(ClusterStatusProtos.RegionState s : request.getStatesList()) { | ||
try { | ||
RegionInfo info = this.master.getAssignmentManager(). | ||
loadRegionFromMeta(s.getRegionInfo().getRegionEncodedName()); | ||
LOG.trace("region info loaded from meta table: {}", info); | ||
RegionState prevState = this.master.getAssignmentManager().getRegionStates(). | ||
getRegionState(info); | ||
RegionState newState = RegionState.convert(s); | ||
LOG.info("{} set region={} state from {} to {}", master.getClientIdAuditPrefix(), info, | ||
prevState.getState(), newState.getState()); | ||
Put metaPut = MetaTableAccessor.makePutFromRegionInfo(info, System.currentTimeMillis()); | ||
metaPut.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER, | ||
Bytes.toBytes(newState.getState().name())); | ||
List<Put> putList = new ArrayList<>(); | ||
putList.add(metaPut); | ||
MetaTableAccessor.putsToMetaTable(this.master.getConnection(), putList); | ||
//Loads from meta again to refresh AM cache with the new region state | ||
this.master.getAssignmentManager().loadRegionFromMeta(info.getEncodedName()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
builder.addStates(prevState.convert()); | ||
} catch (Exception e) { | ||
throw new ServiceException(e); | ||
} | ||
} | ||
return builder.build(); | ||
} | ||
|
||
/** | ||
* Get RegionInfo from Master using content of RegionSpecifier as key. | ||
* @return RegionInfo found by decoding <code>rs</code> or null if none found | ||
|
@@ -2834,4 +2873,5 @@ private boolean shouldSubmitSCP(ServerName serverName) { | |
} | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is odd... That we didn't have this already?