HBASE-22768 Revert to MPIR 2.9 (#433)
[hbase.git] / hbase-server / src / main / java / org / apache / hadoop / hbase / master / MasterRpcServicesVersionWrapper.java
bloba98f5aed2e51e73ea40263f842ca8739bf754039
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package org.apache.hadoop.hbase.master;
21 import org.apache.hadoop.hbase.client.VersionInfoUtil;
22 import org.apache.yetus.audience.InterfaceAudience;
24 import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
25 import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
27 import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos;
29 /**
30 * A wrapper class for MasterRpcServices shortcut that ensures a client version is available
31 * to the callee without a current RPC call.
33 @InterfaceAudience.Private
34 public class MasterRpcServicesVersionWrapper
35 implements RegionServerStatusProtos.RegionServerStatusService.BlockingInterface {
37 @FunctionalInterface
38 public interface ServiceCallFunction<Req, Resp>
39 extends VersionInfoUtil.ServiceCallFunction<RpcController, Req, Resp, ServiceException> {
42 private final MasterRpcServices masterRpcServices;
43 private final ServiceCallFunction<RegionServerStatusProtos.RegionServerStartupRequest,
44 RegionServerStatusProtos.RegionServerStartupResponse> startupCall;
45 private final ServiceCallFunction<RegionServerStatusProtos.RegionServerReportRequest,
46 RegionServerStatusProtos.RegionServerReportResponse> reportCall;
49 public MasterRpcServicesVersionWrapper(MasterRpcServices masterRpcServices) {
50 this.masterRpcServices = masterRpcServices;
51 this.startupCall = (c, req) -> masterRpcServices.regionServerStartup(c, req);
52 this.reportCall = (c, req) -> masterRpcServices.regionServerReport(c, req);
55 @Override
56 public RegionServerStatusProtos.RegionServerStartupResponse regionServerStartup(
57 RpcController controller, RegionServerStatusProtos.RegionServerStartupRequest request)
58 throws ServiceException {
59 return VersionInfoUtil.callWithVersion(startupCall, controller, request);
62 @Override
63 public RegionServerStatusProtos.RegionServerReportResponse regionServerReport(
64 RpcController controller, RegionServerStatusProtos.RegionServerReportRequest request)
65 throws ServiceException {
66 return VersionInfoUtil.callWithVersion(reportCall, controller, request);
69 @Override
70 public RegionServerStatusProtos.ReportRSFatalErrorResponse reportRSFatalError(
71 RpcController controller, RegionServerStatusProtos.ReportRSFatalErrorRequest request)
72 throws ServiceException {
73 return masterRpcServices.reportRSFatalError(controller, request);
76 @Override
77 public RegionServerStatusProtos.GetLastFlushedSequenceIdResponse getLastFlushedSequenceId(
78 RpcController controller, RegionServerStatusProtos.GetLastFlushedSequenceIdRequest request)
79 throws ServiceException {
80 return masterRpcServices.getLastFlushedSequenceId(controller, request);
83 @Override
84 public RegionServerStatusProtos.ReportRegionStateTransitionResponse reportRegionStateTransition(
85 RpcController controller,
86 RegionServerStatusProtos.ReportRegionStateTransitionRequest request)
87 throws ServiceException {
88 return masterRpcServices.reportRegionStateTransition(controller, request);
91 @Override
92 public RegionServerStatusProtos.RegionSpaceUseReportResponse reportRegionSpaceUse(
93 RpcController controller, RegionServerStatusProtos.RegionSpaceUseReportRequest request)
94 throws ServiceException {
95 return masterRpcServices.reportRegionSpaceUse(controller, request);
98 @Override
99 public RegionServerStatusProtos.ReportProcedureDoneResponse reportProcedureDone(
100 RpcController controller, RegionServerStatusProtos.ReportProcedureDoneRequest request)
101 throws ServiceException {
102 return masterRpcServices.reportProcedureDone(controller, request);
105 @Override
106 public RegionServerStatusProtos.FileArchiveNotificationResponse reportFileArchival(
107 RpcController controller, RegionServerStatusProtos.FileArchiveNotificationRequest request)
108 throws ServiceException {
109 return masterRpcServices.reportFileArchival(controller, request);