HDFS-4393. Make empty request and responses in protocol translators can be static final members. Contributed by Brandon Li.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1434844 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2013-01-17 18:21:29 +00:00
parent db17fadd38
commit 8f70a25b1c
15 changed files with 199 additions and 132 deletions

View File

@ -491,6 +491,9 @@ Release 2.0.3-alpha - Unreleased
HDFS-4392. Use NetUtils#getFreeSocketPort in MiniDFSCluster.
(Andrew Purtell via suresh)
HDFS-4393. Make empty request and responses in protocol translators can be
static final members. (Brandon Li via suresh)
OPTIMIZATIONS
HDFS-3429. DataNode reads checksums even if client does not need them (todd)

View File

@ -77,7 +77,7 @@ public class ClientDatanodeProtocolTranslatorPB implements
/** RpcController is not used and hence is set to null */
private final static RpcController NULL_CONTROLLER = null;
private final ClientDatanodeProtocolPB rpcProxy;
private final static RefreshNamenodesRequestProto REFRESH_NAMENODES =
private final static RefreshNamenodesRequestProto VOID_REFRESH_NAMENODES =
RefreshNamenodesRequestProto.newBuilder().build();
public ClientDatanodeProtocolTranslatorPB(DatanodeID datanodeid,
@ -170,7 +170,7 @@ public long getReplicaVisibleLength(ExtendedBlock b) throws IOException {
@Override
public void refreshNamenodes() throws IOException {
try {
rpcProxy.refreshNamenodes(NULL_CONTROLLER, REFRESH_NAMENODES);
rpcProxy.refreshNamenodes(NULL_CONTROLLER, VOID_REFRESH_NAMENODES);
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}

View File

@ -148,6 +148,78 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
ClientNamenodeProtocolPB {
final private ClientProtocol server;
private static final CreateResponseProto VOID_CREATE_RESPONSE =
CreateResponseProto.newBuilder().build();
private static final AppendResponseProto VOID_APPEND_RESPONSE =
AppendResponseProto.newBuilder().build();
private static final SetPermissionResponseProto VOID_SET_PERM_RESPONSE =
SetPermissionResponseProto.newBuilder().build();
private static final SetOwnerResponseProto VOID_SET_OWNER_RESPONSE =
SetOwnerResponseProto.newBuilder().build();
private static final AbandonBlockResponseProto VOID_ADD_BLOCK_RESPONSE =
AbandonBlockResponseProto.newBuilder().build();
private static final ReportBadBlocksResponseProto VOID_REP_BAD_BLOCK_RESPONSE =
ReportBadBlocksResponseProto.newBuilder().build();
private static final ConcatResponseProto VOID_CONCAT_RESPONSE =
ConcatResponseProto.newBuilder().build();
private static final Rename2ResponseProto VOID_RENAME2_RESPONSE =
Rename2ResponseProto.newBuilder().build();
private static final GetListingResponseProto VOID_GETLISTING_RESPONSE =
GetListingResponseProto.newBuilder().build();
private static final RenewLeaseResponseProto VOID_RENEWLEASE_RESPONSE =
RenewLeaseResponseProto.newBuilder().build();
private static final SaveNamespaceResponseProto VOID_SAVENAMESPACE_RESPONSE =
SaveNamespaceResponseProto.newBuilder().build();
private static final RefreshNodesResponseProto VOID_REFRESHNODES_RESPONSE =
RefreshNodesResponseProto.newBuilder().build();
private static final FinalizeUpgradeResponseProto VOID_FINALIZEUPGRADE_RESPONSE =
FinalizeUpgradeResponseProto.newBuilder().build();
private static final MetaSaveResponseProto VOID_METASAVE_RESPONSE =
MetaSaveResponseProto.newBuilder().build();
private static final GetFileInfoResponseProto VOID_GETFILEINFO_RESPONSE =
GetFileInfoResponseProto.newBuilder().build();
private static final GetFileLinkInfoResponseProto VOID_GETFILELINKINFO_RESPONSE =
GetFileLinkInfoResponseProto.newBuilder().build();
private static final SetQuotaResponseProto VOID_SETQUOTA_RESPONSE =
SetQuotaResponseProto.newBuilder().build();
private static final FsyncResponseProto VOID_FSYNC_RESPONSE =
FsyncResponseProto.newBuilder().build();
private static final SetTimesResponseProto VOID_SETTIMES_RESPONSE =
SetTimesResponseProto.newBuilder().build();
private static final CreateSymlinkResponseProto VOID_CREATESYMLINK_RESPONSE =
CreateSymlinkResponseProto.newBuilder().build();
private static final UpdatePipelineResponseProto
VOID_UPDATEPIPELINE_RESPONSE =
UpdatePipelineResponseProto.newBuilder().build();
private static final CancelDelegationTokenResponseProto
VOID_CANCELDELEGATIONTOKEN_RESPONSE =
CancelDelegationTokenResponseProto.newBuilder().build();
private static final SetBalancerBandwidthResponseProto
VOID_SETBALANCERBANDWIDTH_RESPONSE =
SetBalancerBandwidthResponseProto.newBuilder().build();
/**
* Constructor
*
@ -192,9 +264,6 @@ public GetServerDefaultsResponseProto getServerDefaults(
}
static final CreateResponseProto VOID_CREATE_RESPONSE =
CreateResponseProto.newBuilder().build();
@Override
public CreateResponseProto create(RpcController controller,
CreateRequestProto req) throws ServiceException {
@ -209,9 +278,6 @@ public CreateResponseProto create(RpcController controller,
return VOID_CREATE_RESPONSE;
}
static final AppendResponseProto NULL_APPEND_RESPONSE =
AppendResponseProto.newBuilder().build();
@Override
public AppendResponseProto append(RpcController controller,
AppendRequestProto req) throws ServiceException {
@ -221,7 +287,7 @@ public AppendResponseProto append(RpcController controller,
return AppendResponseProto.newBuilder()
.setBlock(PBHelper.convert(result)).build();
}
return NULL_APPEND_RESPONSE;
return VOID_APPEND_RESPONSE;
} catch (IOException e) {
throw new ServiceException(e);
}
@ -240,9 +306,6 @@ public SetReplicationResponseProto setReplication(RpcController controller,
}
static final SetPermissionResponseProto VOID_SET_PERM_RESPONSE =
SetPermissionResponseProto.newBuilder().build();
@Override
public SetPermissionResponseProto setPermission(RpcController controller,
SetPermissionRequestProto req) throws ServiceException {
@ -254,9 +317,6 @@ public SetPermissionResponseProto setPermission(RpcController controller,
return VOID_SET_PERM_RESPONSE;
}
static final SetOwnerResponseProto VOID_SET_OWNER_RESPONSE =
SetOwnerResponseProto.newBuilder().build();
@Override
public SetOwnerResponseProto setOwner(RpcController controller,
SetOwnerRequestProto req) throws ServiceException {
@ -270,9 +330,6 @@ public SetOwnerResponseProto setOwner(RpcController controller,
return VOID_SET_OWNER_RESPONSE;
}
static final AbandonBlockResponseProto VOID_ADD_BLOCK_RESPONSE =
AbandonBlockResponseProto.newBuilder().build();
@Override
public AbandonBlockResponseProto abandonBlock(RpcController controller,
AbandonBlockRequestProto req) throws ServiceException {
@ -338,9 +395,6 @@ public CompleteResponseProto complete(RpcController controller,
}
}
static final ReportBadBlocksResponseProto VOID_REP_BAD_BLOCK_RESPONSE =
ReportBadBlocksResponseProto.newBuilder().build();
@Override
public ReportBadBlocksResponseProto reportBadBlocks(RpcController controller,
ReportBadBlocksRequestProto req) throws ServiceException {
@ -354,9 +408,6 @@ public ReportBadBlocksResponseProto reportBadBlocks(RpcController controller,
return VOID_REP_BAD_BLOCK_RESPONSE;
}
static final ConcatResponseProto VOID_CONCAT_RESPONSE =
ConcatResponseProto.newBuilder().build();
@Override
public ConcatResponseProto concat(RpcController controller,
ConcatRequestProto req) throws ServiceException {
@ -380,9 +431,6 @@ public RenameResponseProto rename(RpcController controller,
}
}
static final Rename2ResponseProto VOID_RENAME2_RESPONSE =
Rename2ResponseProto.newBuilder().build();
@Override
public Rename2ResponseProto rename2(RpcController controller,
Rename2RequestProto req) throws ServiceException {
@ -419,8 +467,6 @@ public MkdirsResponseProto mkdirs(RpcController controller,
}
}
static final GetListingResponseProto NULL_GETLISTING_RESPONSE =
GetListingResponseProto.newBuilder().build();
@Override
public GetListingResponseProto getListing(RpcController controller,
GetListingRequestProto req) throws ServiceException {
@ -432,16 +478,13 @@ public GetListingResponseProto getListing(RpcController controller,
return GetListingResponseProto.newBuilder().setDirList(
PBHelper.convert(result)).build();
} else {
return NULL_GETLISTING_RESPONSE;
return VOID_GETLISTING_RESPONSE;
}
} catch (IOException e) {
throw new ServiceException(e);
}
}
static final RenewLeaseResponseProto VOID_RENEWLEASE_RESPONSE =
RenewLeaseResponseProto.newBuilder().build();
@Override
public RenewLeaseResponseProto renewLease(RpcController controller,
RenewLeaseRequestProto req) throws ServiceException {
@ -526,9 +569,6 @@ public SetSafeModeResponseProto setSafeMode(RpcController controller,
}
}
static final SaveNamespaceResponseProto VOID_SAVENAMESPACE_RESPONSE =
SaveNamespaceResponseProto.newBuilder().build();
@Override
public SaveNamespaceResponseProto saveNamespace(RpcController controller,
SaveNamespaceRequestProto req) throws ServiceException {
@ -555,9 +595,6 @@ public RollEditsResponseProto rollEdits(RpcController controller,
}
static final RefreshNodesResponseProto VOID_REFRESHNODES_RESPONSE =
RefreshNodesResponseProto.newBuilder().build();
@Override
public RefreshNodesResponseProto refreshNodes(RpcController controller,
RefreshNodesRequestProto req) throws ServiceException {
@ -570,9 +607,6 @@ public RefreshNodesResponseProto refreshNodes(RpcController controller,
}
static final FinalizeUpgradeResponseProto VOID_FINALIZEUPGRADE_RESPONSE =
FinalizeUpgradeResponseProto.newBuilder().build();
@Override
public FinalizeUpgradeResponseProto finalizeUpgrade(RpcController controller,
FinalizeUpgradeRequestProto req) throws ServiceException {
@ -599,9 +633,6 @@ public ListCorruptFileBlocksResponseProto listCorruptFileBlocks(
}
}
static final MetaSaveResponseProto VOID_METASAVE_RESPONSE =
MetaSaveResponseProto.newBuilder().build();
@Override
public MetaSaveResponseProto metaSave(RpcController controller,
MetaSaveRequestProto req) throws ServiceException {
@ -614,8 +645,6 @@ public MetaSaveResponseProto metaSave(RpcController controller,
}
static final GetFileInfoResponseProto NULL_GETFILEINFO_RESPONSE =
GetFileInfoResponseProto.newBuilder().build();
@Override
public GetFileInfoResponseProto getFileInfo(RpcController controller,
GetFileInfoRequestProto req) throws ServiceException {
@ -626,14 +655,12 @@ public GetFileInfoResponseProto getFileInfo(RpcController controller,
return GetFileInfoResponseProto.newBuilder().setFs(
PBHelper.convert(result)).build();
}
return NULL_GETFILEINFO_RESPONSE;
return VOID_GETFILEINFO_RESPONSE;
} catch (IOException e) {
throw new ServiceException(e);
}
}
static final GetFileLinkInfoResponseProto NULL_GETFILELINKINFO_RESPONSE =
GetFileLinkInfoResponseProto.newBuilder().build();
@Override
public GetFileLinkInfoResponseProto getFileLinkInfo(RpcController controller,
GetFileLinkInfoRequestProto req) throws ServiceException {
@ -645,7 +672,7 @@ public GetFileLinkInfoResponseProto getFileLinkInfo(RpcController controller,
PBHelper.convert(result)).build();
} else {
System.out.println("got null result for getFileLinkInfo for " + req.getSrc());
return NULL_GETFILELINKINFO_RESPONSE;
return VOID_GETFILELINKINFO_RESPONSE;
}
} catch (IOException e) {
@ -666,9 +693,6 @@ public GetContentSummaryResponseProto getContentSummary(
}
}
static final SetQuotaResponseProto VOID_SETQUOTA_RESPONSE =
SetQuotaResponseProto.newBuilder().build();
@Override
public SetQuotaResponseProto setQuota(RpcController controller,
SetQuotaRequestProto req) throws ServiceException {
@ -681,9 +705,6 @@ public SetQuotaResponseProto setQuota(RpcController controller,
}
}
static final FsyncResponseProto VOID_FSYNC_RESPONSE =
FsyncResponseProto.newBuilder().build();
@Override
public FsyncResponseProto fsync(RpcController controller,
FsyncRequestProto req) throws ServiceException {
@ -695,9 +716,6 @@ public FsyncResponseProto fsync(RpcController controller,
}
}
static final SetTimesResponseProto VOID_SETTIMES_RESPONSE =
SetTimesResponseProto.newBuilder().build();
@Override
public SetTimesResponseProto setTimes(RpcController controller,
SetTimesRequestProto req) throws ServiceException {
@ -709,9 +727,6 @@ public SetTimesResponseProto setTimes(RpcController controller,
}
}
static final CreateSymlinkResponseProto VOID_CREATESYMLINK_RESPONSE =
CreateSymlinkResponseProto.newBuilder().build();
@Override
public CreateSymlinkResponseProto createSymlink(RpcController controller,
CreateSymlinkRequestProto req) throws ServiceException {
@ -755,9 +770,6 @@ public UpdateBlockForPipelineResponseProto updateBlockForPipeline(
}
}
static final UpdatePipelineResponseProto VOID_UPDATEPIPELINE_RESPONSE =
UpdatePipelineResponseProto.newBuilder().build();
@Override
public UpdatePipelineResponseProto updatePipeline(RpcController controller,
UpdatePipelineRequestProto req) throws ServiceException {
@ -805,10 +817,6 @@ public RenewDelegationTokenResponseProto renewDelegationToken(
}
}
static final CancelDelegationTokenResponseProto
VOID_CANCELDELEGATIONTOKEN_RESPONSE =
CancelDelegationTokenResponseProto.newBuilder().build();
@Override
public CancelDelegationTokenResponseProto cancelDelegationToken(
RpcController controller, CancelDelegationTokenRequestProto req)
@ -822,10 +830,6 @@ public CancelDelegationTokenResponseProto cancelDelegationToken(
}
}
static final SetBalancerBandwidthResponseProto
VOID_SETBALANCERBANDWIDTH_RESPONSE =
SetBalancerBandwidthResponseProto.newBuilder().build();
@Override
public SetBalancerBandwidthResponseProto setBalancerBandwidth(
RpcController controller, SetBalancerBandwidthRequestProto req)

View File

@ -129,6 +129,29 @@ public class ClientNamenodeProtocolTranslatorPB implements
ProtocolMetaInterface, ClientProtocol, Closeable, ProtocolTranslator {
final private ClientNamenodeProtocolPB rpcProxy;
static final GetServerDefaultsRequestProto VOID_GET_SERVER_DEFAULT_REQUEST =
GetServerDefaultsRequestProto.newBuilder().build();
private final static GetFsStatusRequestProto VOID_GET_FSSTATUS_REQUEST =
GetFsStatusRequestProto.newBuilder().build();
private final static SaveNamespaceRequestProto VOID_SAVE_NAMESPACE_REQUEST =
SaveNamespaceRequestProto.newBuilder().build();
private final static RollEditsRequestProto VOID_ROLLEDITS_REQUEST =
RollEditsRequestProto.getDefaultInstance();
private final static RefreshNodesRequestProto VOID_REFRESH_NODES_REQUEST =
RefreshNodesRequestProto.newBuilder().build();
private final static FinalizeUpgradeRequestProto
VOID_FINALIZE_UPGRADE_REQUEST =
FinalizeUpgradeRequestProto.newBuilder().build();
private final static GetDataEncryptionKeyRequestProto
VOID_GET_DATA_ENCRYPTIONKEY_REQUEST =
GetDataEncryptionKeyRequestProto.newBuilder().build();
public ClientNamenodeProtocolTranslatorPB(ClientNamenodeProtocolPB proxy) {
rpcProxy = proxy;
}
@ -160,7 +183,7 @@ public LocatedBlocks getBlockLocations(String src, long offset, long length)
@Override
public FsServerDefaults getServerDefaults() throws IOException {
GetServerDefaultsRequestProto req = GetServerDefaultsRequestProto.newBuilder().build();
GetServerDefaultsRequestProto req = VOID_GET_SERVER_DEFAULT_REQUEST;
try {
return PBHelper
.convert(rpcProxy.getServerDefaults(null, req).getServerDefaults());
@ -473,9 +496,9 @@ public boolean recoverLease(String src, String clientName)
@Override
public long[] getStats() throws IOException {
GetFsStatusRequestProto req = GetFsStatusRequestProto.newBuilder().build();
try {
return PBHelper.convert(rpcProxy.getFsStats(null, req));
return PBHelper.convert(rpcProxy.getFsStats(null,
VOID_GET_FSSTATUS_REQUEST));
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}
@ -522,10 +545,8 @@ public boolean setSafeMode(SafeModeAction action, boolean isChecked) throws IOEx
@Override
public void saveNamespace() throws AccessControlException, IOException {
SaveNamespaceRequestProto req = SaveNamespaceRequestProto.newBuilder()
.build();
try {
rpcProxy.saveNamespace(null, req);
rpcProxy.saveNamespace(null, VOID_SAVE_NAMESPACE_REQUEST);
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}
@ -533,9 +554,9 @@ public void saveNamespace() throws AccessControlException, IOException {
@Override
public long rollEdits() throws AccessControlException, IOException {
RollEditsRequestProto req = RollEditsRequestProto.getDefaultInstance();
try {
RollEditsResponseProto resp = rpcProxy.rollEdits(null, req);
RollEditsResponseProto resp = rpcProxy.rollEdits(null,
VOID_ROLLEDITS_REQUEST);
return resp.getNewSegmentTxId();
} catch (ServiceException se) {
throw ProtobufHelper.getRemoteException(se);
@ -557,9 +578,8 @@ public boolean restoreFailedStorage(String arg)
@Override
public void refreshNodes() throws IOException {
RefreshNodesRequestProto req = RefreshNodesRequestProto.newBuilder().build();
try {
rpcProxy.refreshNodes(null, req);
rpcProxy.refreshNodes(null, VOID_REFRESH_NODES_REQUEST);
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}
@ -567,9 +587,8 @@ public void refreshNodes() throws IOException {
@Override
public void finalizeUpgrade() throws IOException {
FinalizeUpgradeRequestProto req = FinalizeUpgradeRequestProto.newBuilder().build();
try {
rpcProxy.finalizeUpgrade(null, req);
rpcProxy.finalizeUpgrade(null, VOID_FINALIZE_UPGRADE_REQUEST);
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}
@ -818,12 +837,10 @@ public boolean isMethodSupported(String methodName) throws IOException {
@Override
public DataEncryptionKey getDataEncryptionKey() throws IOException {
GetDataEncryptionKeyRequestProto req = GetDataEncryptionKeyRequestProto
.newBuilder().build();
try {
GetDataEncryptionKeyResponseProto rsp =
rpcProxy.getDataEncryptionKey(null, req);
return rsp.hasDataEncryptionKey() ?
GetDataEncryptionKeyResponseProto rsp = rpcProxy.getDataEncryptionKey(
null, VOID_GET_DATA_ENCRYPTIONKEY_REQUEST);
return rsp.hasDataEncryptionKey() ?
PBHelper.convert(rsp.getDataEncryptionKey()) : null;
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);

View File

@ -84,7 +84,7 @@ public class DatanodeProtocolClientSideTranslatorPB implements
/** RpcController is not used and hence is set to null */
private final DatanodeProtocolPB rpcProxy;
private static final VersionRequestProto VERSION_REQUEST =
private static final VersionRequestProto VOID_VERSION_REQUEST =
VersionRequestProto.newBuilder().build();
private final static RpcController NULL_CONTROLLER = null;
@ -243,7 +243,7 @@ public void errorReport(DatanodeRegistration registration, int errorCode,
public NamespaceInfo versionRequest() throws IOException {
try {
return PBHelper.convert(rpcProxy.versionRequest(NULL_CONTROLLER,
VERSION_REQUEST).getInfo());
VOID_VERSION_REQUEST).getInfo());
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}

View File

@ -62,15 +62,17 @@ public class DatanodeProtocolServerSideTranslatorPB implements
DatanodeProtocolPB {
private final DatanodeProtocol impl;
private static final ErrorReportResponseProto ERROR_REPORT_RESPONSE_PROTO =
ErrorReportResponseProto.newBuilder().build();
private static final ErrorReportResponseProto
VOID_ERROR_REPORT_RESPONSE_PROTO =
ErrorReportResponseProto.newBuilder().build();
private static final BlockReceivedAndDeletedResponseProto
BLOCK_RECEIVED_AND_DELETE_RESPONSE =
VOID_BLOCK_RECEIVED_AND_DELETE_RESPONSE =
BlockReceivedAndDeletedResponseProto.newBuilder().build();
private static final ReportBadBlocksResponseProto REPORT_BAD_BLOCK_RESPONSE =
ReportBadBlocksResponseProto.newBuilder().build();
private static final ReportBadBlocksResponseProto
VOID_REPORT_BAD_BLOCK_RESPONSE =
ReportBadBlocksResponseProto.newBuilder().build();
private static final CommitBlockSynchronizationResponseProto
COMMIT_BLOCK_SYNCHRONIZATION_RESPONSE_PROTO =
VOID_COMMIT_BLOCK_SYNCHRONIZATION_RESPONSE_PROTO =
CommitBlockSynchronizationResponseProto.newBuilder().build();
public DatanodeProtocolServerSideTranslatorPB(DatanodeProtocol impl) {
@ -180,7 +182,7 @@ public BlockReceivedAndDeletedResponseProto blockReceivedAndDeleted(
} catch (IOException e) {
throw new ServiceException(e);
}
return BLOCK_RECEIVED_AND_DELETE_RESPONSE;
return VOID_BLOCK_RECEIVED_AND_DELETE_RESPONSE;
}
@Override
@ -192,7 +194,7 @@ public ErrorReportResponseProto errorReport(RpcController controller,
} catch (IOException e) {
throw new ServiceException(e);
}
return ERROR_REPORT_RESPONSE_PROTO;
return VOID_ERROR_REPORT_RESPONSE_PROTO;
}
@Override
@ -221,7 +223,7 @@ public ReportBadBlocksResponseProto reportBadBlocks(RpcController controller,
} catch (IOException e) {
throw new ServiceException(e);
}
return REPORT_BAD_BLOCK_RESPONSE;
return VOID_REPORT_BAD_BLOCK_RESPONSE;
}
@Override
@ -242,6 +244,6 @@ public CommitBlockSynchronizationResponseProto commitBlockSynchronization(
} catch (IOException e) {
throw new ServiceException(e);
}
return COMMIT_BLOCK_SYNCHRONIZATION_RESPONSE_PROTO;
return VOID_COMMIT_BLOCK_SYNCHRONIZATION_RESPONSE_PROTO;
}
}

View File

@ -42,6 +42,13 @@ public class JournalProtocolServerSideTranslatorPB implements JournalProtocolPB
/** Server side implementation to delegate the requests to */
private final JournalProtocol impl;
private final static JournalResponseProto VOID_JOURNAL_RESPONSE =
JournalResponseProto.newBuilder().build();
private final static StartLogSegmentResponseProto
VOID_START_LOG_SEGMENT_RESPONSE =
StartLogSegmentResponseProto.newBuilder().build();
public JournalProtocolServerSideTranslatorPB(JournalProtocol impl) {
this.impl = impl;
}
@ -56,7 +63,7 @@ public JournalResponseProto journal(RpcController unused,
} catch (IOException e) {
throw new ServiceException(e);
}
return JournalResponseProto.newBuilder().build();
return VOID_JOURNAL_RESPONSE;
}
/** @see JournalProtocol#startLogSegment */
@ -69,7 +76,7 @@ public StartLogSegmentResponseProto startLogSegment(RpcController controller,
} catch (IOException e) {
throw new ServiceException(e);
}
return StartLogSegmentResponseProto.newBuilder().build();
return VOID_START_LOG_SEGMENT_RESPONSE;
}
@Override

View File

@ -63,6 +63,12 @@ public class NamenodeProtocolServerSideTranslatorPB implements
NamenodeProtocolPB {
private final NamenodeProtocol impl;
private final static ErrorReportResponseProto VOID_ERROR_REPORT_RESPONSE =
ErrorReportResponseProto.newBuilder().build();
private final static EndCheckpointResponseProto VOID_END_CHECKPOINT_RESPONSE =
EndCheckpointResponseProto.newBuilder().build();
public NamenodeProtocolServerSideTranslatorPB(NamenodeProtocol impl) {
this.impl = impl;
}
@ -147,7 +153,7 @@ public ErrorReportResponseProto errorReport(RpcController unused,
} catch (IOException e) {
throw new ServiceException(e);
}
return ErrorReportResponseProto.newBuilder().build();
return VOID_ERROR_REPORT_RESPONSE;
}
@Override
@ -185,7 +191,7 @@ public EndCheckpointResponseProto endCheckpoint(RpcController unused,
} catch (IOException e) {
throw new ServiceException(e);
}
return EndCheckpointResponseProto.newBuilder().build();
return VOID_END_CHECKPOINT_RESPONSE;
}
@Override

View File

@ -68,13 +68,13 @@ public class NamenodeProtocolTranslatorPB implements NamenodeProtocol,
/*
* Protobuf requests with no parameters instantiated only once
*/
private static final GetBlockKeysRequestProto GET_BLOCKKEYS =
private static final GetBlockKeysRequestProto VOID_GET_BLOCKKEYS_REQUEST =
GetBlockKeysRequestProto.newBuilder().build();
private static final GetTransactionIdRequestProto GET_TRANSACTIONID =
private static final GetTransactionIdRequestProto VOID_GET_TRANSACTIONID_REQUEST =
GetTransactionIdRequestProto.newBuilder().build();
private static final RollEditLogRequestProto ROLL_EDITLOG =
private static final RollEditLogRequestProto VOID_ROLL_EDITLOG_REQUEST =
RollEditLogRequestProto.newBuilder().build();
private static final VersionRequestProto VERSION_REQUEST =
private static final VersionRequestProto VOID_VERSION_REQUEST =
VersionRequestProto.newBuilder().build();
final private NamenodeProtocolPB rpcProxy;
@ -106,7 +106,7 @@ public BlocksWithLocations getBlocks(DatanodeInfo datanode, long size)
public ExportedBlockKeys getBlockKeys() throws IOException {
try {
GetBlockKeysResponseProto rsp = rpcProxy.getBlockKeys(NULL_CONTROLLER,
GET_BLOCKKEYS);
VOID_GET_BLOCKKEYS_REQUEST);
return rsp.hasKeys() ? PBHelper.convert(rsp.getKeys()) : null;
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
@ -116,8 +116,8 @@ public ExportedBlockKeys getBlockKeys() throws IOException {
@Override
public long getTransactionID() throws IOException {
try {
return rpcProxy.getTransactionId(NULL_CONTROLLER, GET_TRANSACTIONID)
.getTxId();
return rpcProxy.getTransactionId(NULL_CONTROLLER,
VOID_GET_TRANSACTIONID_REQUEST).getTxId();
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}
@ -137,7 +137,7 @@ public long getMostRecentCheckpointTxId() throws IOException {
public CheckpointSignature rollEditLog() throws IOException {
try {
return PBHelper.convert(rpcProxy.rollEditLog(NULL_CONTROLLER,
ROLL_EDITLOG).getSignature());
VOID_ROLL_EDITLOG_REQUEST).getSignature());
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}
@ -147,7 +147,7 @@ public CheckpointSignature rollEditLog() throws IOException {
public NamespaceInfo versionRequest() throws IOException {
try {
return PBHelper.convert(rpcProxy.versionRequest(NULL_CONTROLLER,
VERSION_REQUEST).getInfo());
VOID_VERSION_REQUEST).getInfo());
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}

View File

@ -38,6 +38,10 @@ public class RefreshAuthorizationPolicyProtocolClientSideTranslatorPB implements
private final static RpcController NULL_CONTROLLER = null;
private final RefreshAuthorizationPolicyProtocolPB rpcProxy;
private final static RefreshServiceAclRequestProto
VOID_REFRESH_SERVICE_ACL_REQUEST =
RefreshServiceAclRequestProto.newBuilder().build();
public RefreshAuthorizationPolicyProtocolClientSideTranslatorPB(
RefreshAuthorizationPolicyProtocolPB rpcProxy) {
this.rpcProxy = rpcProxy;
@ -50,10 +54,9 @@ public void close() throws IOException {
@Override
public void refreshServiceAcl() throws IOException {
RefreshServiceAclRequestProto request = RefreshServiceAclRequestProto
.newBuilder().build();
try {
rpcProxy.refreshServiceAcl(NULL_CONTROLLER, request);
rpcProxy.refreshServiceAcl(NULL_CONTROLLER,
VOID_REFRESH_SERVICE_ACL_REQUEST);
} catch (ServiceException se) {
throw ProtobufHelper.getRemoteException(se);
}

View File

@ -32,6 +32,10 @@ public class RefreshAuthorizationPolicyProtocolServerSideTranslatorPB implements
private final RefreshAuthorizationPolicyProtocol impl;
private final static RefreshServiceAclResponseProto
VOID_REFRESH_SERVICE_ACL_RESPONSE = RefreshServiceAclResponseProto
.newBuilder().build();
public RefreshAuthorizationPolicyProtocolServerSideTranslatorPB(
RefreshAuthorizationPolicyProtocol impl) {
this.impl = impl;
@ -46,6 +50,6 @@ public RefreshServiceAclResponseProto refreshServiceAcl(
} catch (IOException e) {
throw new ServiceException(e);
}
return RefreshServiceAclResponseProto.newBuilder().build();
return VOID_REFRESH_SERVICE_ACL_RESPONSE;
}
}

View File

@ -39,6 +39,14 @@ public class RefreshUserMappingsProtocolClientSideTranslatorPB implements
private final static RpcController NULL_CONTROLLER = null;
private final RefreshUserMappingsProtocolPB rpcProxy;
private final static RefreshUserToGroupsMappingsRequestProto
VOID_REFRESH_USER_TO_GROUPS_MAPPING_REQUEST =
RefreshUserToGroupsMappingsRequestProto.newBuilder().build();
private final static RefreshSuperUserGroupsConfigurationRequestProto
VOID_REFRESH_SUPERUSER_GROUPS_CONFIGURATION_REQUEST =
RefreshSuperUserGroupsConfigurationRequestProto.newBuilder().build();
public RefreshUserMappingsProtocolClientSideTranslatorPB(
RefreshUserMappingsProtocolPB rpcProxy) {
this.rpcProxy = rpcProxy;
@ -51,10 +59,9 @@ public void close() throws IOException {
@Override
public void refreshUserToGroupsMappings() throws IOException {
RefreshUserToGroupsMappingsRequestProto request =
RefreshUserToGroupsMappingsRequestProto.newBuilder().build();
try {
rpcProxy.refreshUserToGroupsMappings(NULL_CONTROLLER, request);
rpcProxy.refreshUserToGroupsMappings(NULL_CONTROLLER,
VOID_REFRESH_USER_TO_GROUPS_MAPPING_REQUEST);
} catch (ServiceException se) {
throw ProtobufHelper.getRemoteException(se);
}
@ -62,10 +69,9 @@ public void refreshUserToGroupsMappings() throws IOException {
@Override
public void refreshSuperUserGroupsConfiguration() throws IOException {
RefreshSuperUserGroupsConfigurationRequestProto request =
RefreshSuperUserGroupsConfigurationRequestProto.newBuilder().build();
try {
rpcProxy.refreshSuperUserGroupsConfiguration(NULL_CONTROLLER, request);
rpcProxy.refreshSuperUserGroupsConfiguration(NULL_CONTROLLER,
VOID_REFRESH_SUPERUSER_GROUPS_CONFIGURATION_REQUEST);
} catch (ServiceException se) {
throw ProtobufHelper.getRemoteException(se);
}

View File

@ -33,6 +33,15 @@ public class RefreshUserMappingsProtocolServerSideTranslatorPB implements Refres
private final RefreshUserMappingsProtocol impl;
private final static RefreshUserToGroupsMappingsResponseProto
VOID_REFRESH_USER_GROUPS_MAPPING_RESPONSE =
RefreshUserToGroupsMappingsResponseProto.newBuilder().build();
private final static RefreshSuperUserGroupsConfigurationResponseProto
VOID_REFRESH_SUPERUSER_GROUPS_CONFIGURATION_RESPONSE =
RefreshSuperUserGroupsConfigurationResponseProto.newBuilder()
.build();
public RefreshUserMappingsProtocolServerSideTranslatorPB(RefreshUserMappingsProtocol impl) {
this.impl = impl;
}
@ -47,7 +56,7 @@ public RefreshUserMappingsProtocolServerSideTranslatorPB(RefreshUserMappingsProt
} catch (IOException e) {
throw new ServiceException(e);
}
return RefreshUserToGroupsMappingsResponseProto.newBuilder().build();
return VOID_REFRESH_USER_GROUPS_MAPPING_RESPONSE;
}
@Override
@ -60,7 +69,6 @@ public RefreshUserMappingsProtocolServerSideTranslatorPB(RefreshUserMappingsProt
} catch (IOException e) {
throw new ServiceException(e);
}
return RefreshSuperUserGroupsConfigurationResponseProto.newBuilder()
.build();
return VOID_REFRESH_SUPERUSER_GROUPS_CONFIGURATION_RESPONSE;
}
}

View File

@ -65,6 +65,13 @@ public class QJournalProtocolServerSideTranslatorPB implements QJournalProtocolP
/** Server side implementation to delegate the requests to */
private final QJournalProtocol impl;
private final static JournalResponseProto VOID_JOURNAL_RESPONSE =
JournalResponseProto.newBuilder().build();
private final static StartLogSegmentResponseProto
VOID_START_LOG_SEGMENT_RESPONSE =
StartLogSegmentResponseProto.newBuilder().build();
public QJournalProtocolServerSideTranslatorPB(QJournalProtocol impl) {
this.impl = impl;
}
@ -135,7 +142,7 @@ public JournalResponseProto journal(RpcController unused,
} catch (IOException e) {
throw new ServiceException(e);
}
return JournalResponseProto.newBuilder().build();
return VOID_JOURNAL_RESPONSE;
}
/** @see JournalProtocol#heartbeat */
@ -160,7 +167,7 @@ public StartLogSegmentResponseProto startLogSegment(RpcController controller,
} catch (IOException e) {
throw new ServiceException(e);
}
return StartLogSegmentResponseProto.newBuilder().build();
return VOID_START_LOG_SEGMENT_RESPONSE;
}
@Override

View File

@ -168,7 +168,7 @@ message RenameRequestProto {
required string dst = 2;
}
message RenameResponseProto { // void response
message RenameResponseProto {
required bool result = 1;
}