Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public DeletedBlockLogStateManager build() throws IOException {
final DeletedBlockLogStateManager impl = new DeletedBlockLogStateManagerImpl(
deletedBlocksTransactionTable, statefulServiceConfigTable, containerManager, transactionBuffer);

return scmRatisServer.getProxyHandler(new DeletedBlockLogStateManagerInvoker(impl));
return scmRatisServer.getProxyHandler(new DeletedBlockLogStateManagerInvoker(impl, scmRatisServer));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,17 @@ private Object invokeRatis(Method method, Object[] args)
if (LOG.isTraceEnabled()) {
LOG.trace("Invoking method {} on target {}", method, ratisHandler);
}

try {
switch (method.getAnnotation(Replicate.class).invocationType()) {
case CLIENT:
return invokeRatisClient(method, args);
case DIRECT:
default:
if (invoker != null) {
return invoker.invokeRatisServer(
method.getName(), method.getParameterTypes(), args);
}
Comment on lines +114 to +117
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does not help since it is after the proxy. We should do it before the proxy.

return invokeRatisServer(method, args);
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ public interface ScmInvoker<T> {
T getImpl();

Object invokeLocal(String methodName, Object[] args) throws Exception;

Object invokeRatisServer(String methodName, Class<?>[] paramTypes, Object[] args) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import org.apache.hadoop.hdds.protocol.proto.HddsProtos.DeletedBlocksTransactionSummary;
import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
import org.apache.hadoop.hdds.scm.block.DeletedBlockLogStateManager;
import org.apache.hadoop.hdds.scm.ha.SCMRatisRequest;
import org.apache.hadoop.hdds.scm.ha.SCMRatisResponse;
import org.apache.hadoop.hdds.scm.ha.SCMRatisServer;
import org.apache.hadoop.hdds.scm.ha.ScmInvoker;
import org.apache.hadoop.hdds.utils.db.Table;

Expand All @@ -29,9 +32,11 @@
*/
public class DeletedBlockLogStateManagerInvoker implements ScmInvoker<DeletedBlockLogStateManager> {
private final DeletedBlockLogStateManager impl;
private final SCMRatisServer ratisHandler;

public DeletedBlockLogStateManagerInvoker(DeletedBlockLogStateManager impl) {
public DeletedBlockLogStateManagerInvoker(DeletedBlockLogStateManager impl, SCMRatisServer ratisHandler) {
this.impl = impl;
this.ratisHandler = ratisHandler;
}

@Override
Expand Down Expand Up @@ -88,4 +93,17 @@ public Object invokeLocal(String methodName, Object[] params) throws Exception {
}
}

@Override
public Object invokeRatisServer(String methodName, Class<?>[] paramTypes,
Object[] args) throws Exception {
final SCMRatisRequest scmRatisRequest = SCMRatisRequest.of(
getType(), methodName, paramTypes, args);
final SCMRatisResponse response = ratisHandler.submitRequest(
scmRatisRequest);
if (response.isSuccess()) {
return response.getResult();
}
throw response.getException();
}

}