-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-25968 Request compact to compaction server (#3378)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
- Loading branch information
1 parent
6afca94
commit da0fa30
Showing
23 changed files
with
660 additions
and
33 deletions.
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
62 changes: 62 additions & 0 deletions
62
hbase-protocol-shaded/src/main/protobuf/server/Compaction.proto
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 |
---|---|---|
@@ -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 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
86 changes: 86 additions & 0 deletions
86
hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncCompactionServerService.java
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 |
---|---|---|
@@ -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 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
Oops, something went wrong.