-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-25968 Request compact to compaction server #3378
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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
62 changes: 62 additions & 0 deletions
62
hbase-protocol-shaded/src/main/protobuf/server/Compaction.proto
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| syntax = "proto2"; | ||
|
|
||
| // This file contains protocol buffers that are used for CompactionManagerProtocol. | ||
| package hbase.pb; | ||
|
|
||
| option java_package = "org.apache.hadoop.hbase.shaded.protobuf.generated"; | ||
| option java_outer_classname = "CompactionProtos"; | ||
| option java_generic_services = true; | ||
| option java_generate_equals_and_hash = true; | ||
| option optimize_for = SPEED; | ||
|
|
||
| import "HBase.proto"; | ||
| import "server/ClusterStatus.proto"; | ||
| import "server/ErrorHandling.proto"; | ||
|
|
||
| message CompactRequest { | ||
| required ServerName server = 1; | ||
| required RegionInfo region_info = 2; | ||
| required ColumnFamilySchema family = 3; | ||
| required bool major = 4; | ||
| required int32 priority = 5; | ||
| repeated ServerName favored_nodes = 6; | ||
| } | ||
|
|
||
| message CompactResponse { | ||
| } | ||
|
|
||
| message CompleteCompactionRequest { | ||
| required RegionInfo region_info = 1; | ||
| required ColumnFamilySchema family = 2; | ||
| repeated string selected_files = 3; | ||
| repeated string new_files = 4; | ||
| required bool new_force_major = 5; | ||
| } | ||
|
|
||
| message CompleteCompactionResponse { | ||
| required bool success = 1; | ||
| } | ||
|
|
||
| service CompactionService { | ||
| /** Called when a region server request compact a column of a region. */ | ||
| rpc RequestCompaction(CompactRequest) | ||
| returns(CompactResponse); | ||
|
|
||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
86 changes: 86 additions & 0 deletions
86
hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncCompactionServerService.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.hadoop.hbase.client; | ||
|
|
||
| import java.util.concurrent.CompletableFuture; | ||
| import org.apache.hadoop.hbase.ServerName; | ||
| import org.apache.hadoop.hbase.ipc.HBaseRpcController; | ||
| import org.apache.yetus.audience.InterfaceAudience; | ||
|
|
||
| import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback; | ||
| import org.apache.hbase.thirdparty.com.google.protobuf.RpcController; | ||
|
|
||
| import org.apache.hadoop.hbase.shaded.protobuf.generated.CompactionProtos.CompactRequest; | ||
| import org.apache.hadoop.hbase.shaded.protobuf.generated.CompactionProtos.CompactResponse; | ||
| import org.apache.hadoop.hbase.shaded.protobuf.generated.CompactionProtos.CompactionService; | ||
|
|
||
|
|
||
| /** | ||
| * A simple wrapper of the {@link CompactionService} for a compaction server, which returns a | ||
| * {@link CompletableFuture}. This is easier to use, as if you use the raw protobuf interface, you | ||
| * need to get the result from the {@link RpcCallback}, and if there is an exception, you need to | ||
| * get it from the {@link RpcController} passed in. | ||
| * <p/> | ||
| * Notice that there is no retry, and this is intentional. We have different retry for different | ||
| * usage for now, if later we want to unify them, we can move the retry logic into this class. | ||
| */ | ||
| @InterfaceAudience.Private | ||
| public class AsyncCompactionServerService { | ||
|
|
||
| private final ServerName server; | ||
|
|
||
| private final AsyncClusterConnectionImpl conn; | ||
|
|
||
| AsyncCompactionServerService(ServerName server, AsyncClusterConnectionImpl conn) { | ||
| this.server = server; | ||
| this.conn = conn; | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| private interface RpcCall<RESP> { | ||
| void call(CompactionService.Interface stub, HBaseRpcController controller, | ||
| RpcCallback<RESP> done); | ||
| } | ||
|
|
||
| // TODO: eliminate duplicate code in AsyncRegionServerAdmin and maybe we could also change the | ||
| // way on how to do regionServerReport | ||
| private <RESP> CompletableFuture<RESP> call(RpcCall<RESP> rpcCall) { | ||
| CompletableFuture<RESP> future = new CompletableFuture<>(); | ||
| HBaseRpcController controller = conn.rpcControllerFactory.newController(); | ||
| try { | ||
| rpcCall.call(conn.createCompactionServerStub(server), controller, new RpcCallback<RESP>() { | ||
| @Override | ||
| public void run(RESP resp) { | ||
| if (controller.failed()) { | ||
| future.completeExceptionally(controller.getFailed()); | ||
| } else { | ||
| future.complete(resp); | ||
| } | ||
| } | ||
| }); | ||
| } catch (Exception e) { | ||
| future.completeExceptionally(e); | ||
| } | ||
| return future; | ||
| } | ||
|
|
||
| public CompletableFuture<CompactResponse> requestCompaction(CompactRequest request) { | ||
| return call((stub, controller, done) -> stub.requestCompaction(controller, request, done)); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
We do not have a common method in ConnectionUtils?
Uh oh!
There was an error while loading. Please reload this page.
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.
yes, the
callmethod inConnectionUtilsagainstClientService.InterfaceThere 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.
Oh, the one in ConnectionUtils is not suitable here as it requires ClientService.Interface. But we do have another version in AsyncRegionServerAdmin which has almost the same code. Should find a way to share the code in the future.
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.
And this one is a call to master? If we want to follow the pattern here, maybe we could also change the way on how to do regionServerReport...
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.
Recorded in TODO