-
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-24982 Disassemble the method replicateWALEntry from AdminServic…
…e to a new interface ReplicationServerService (#2360) Signed-off-by: Wellington Chevreuil <[email protected]>
- Loading branch information
Showing
15 changed files
with
294 additions
and
230 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
32 changes: 32 additions & 0 deletions
32
hbase-protocol-shaded/src/main/protobuf/server/replication/ReplicationServer.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,32 @@ | ||
/** | ||
* 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"; | ||
package hbase.pb; | ||
|
||
option java_package = "org.apache.hadoop.hbase.shaded.protobuf.generated"; | ||
option java_outer_classname = "ReplicationServerProtos"; | ||
option java_generic_services = true; | ||
option java_generate_equals_and_hash = true; | ||
option optimize_for = SPEED; | ||
|
||
import "server/region/Admin.proto"; | ||
|
||
service ReplicationServerService { | ||
rpc ReplicateWALEntry(ReplicateWALEntryRequest) | ||
returns(ReplicateWALEntryResponse); | ||
} |
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
80 changes: 80 additions & 0 deletions
80
hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncReplicationServerAdmin.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,80 @@ | ||
/** | ||
* 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.io.IOException; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.apache.hadoop.hbase.CellScanner; | ||
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.hadoop.hbase.shaded.protobuf.generated.AdminProtos; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationServerProtos.ReplicationServerService; | ||
|
||
/** | ||
* A simple wrapper of the {@link ReplicationServerService} for a replication server. | ||
* <p/> | ||
* Notice that there is no retry, and this is intentional. | ||
*/ | ||
@InterfaceAudience.Private | ||
public class AsyncReplicationServerAdmin { | ||
|
||
private final ServerName server; | ||
|
||
private final AsyncConnectionImpl conn; | ||
|
||
AsyncReplicationServerAdmin(ServerName server, AsyncConnectionImpl conn) { | ||
this.server = server; | ||
this.conn = conn; | ||
} | ||
|
||
@FunctionalInterface | ||
private interface RpcCall<RESP> { | ||
void call(ReplicationServerService.Interface stub, HBaseRpcController controller, | ||
RpcCallback<RESP> done); | ||
} | ||
|
||
private <RESP> CompletableFuture<RESP> call(RpcCall<RESP> rpcCall, CellScanner cellScanner) { | ||
CompletableFuture<RESP> future = new CompletableFuture<>(); | ||
HBaseRpcController controller = conn.rpcControllerFactory.newController(cellScanner); | ||
try { | ||
rpcCall.call(conn.getReplicationServerStub(server), controller, resp -> { | ||
if (controller.failed()) { | ||
future.completeExceptionally(controller.getFailed()); | ||
} else { | ||
future.complete(resp); | ||
} | ||
}); | ||
} catch (IOException e) { | ||
future.completeExceptionally(e); | ||
} | ||
return future; | ||
} | ||
|
||
public CompletableFuture<AdminProtos.ReplicateWALEntryResponse> replicateWALEntry( | ||
AdminProtos.ReplicateWALEntryRequest request, CellScanner cellScanner, int timeout) { | ||
return call((stub, controller, done) -> { | ||
controller.setCallTimeout(timeout); | ||
stub.replicateWALEntry(controller, request, done); | ||
}, cellScanner); | ||
} | ||
} |
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.