HDFS-9111. Move hdfs-client protobuf convert methods from PBHelper to PBHelperClient. Contributed by Mingliang Liu.

This commit is contained in:
Haohui Mai 2015-09-21 18:53:13 -07:00
parent b39b61e356
commit 4e752a37e7
23 changed files with 2220 additions and 2232 deletions

View File

@ -590,6 +590,9 @@ Release 2.8.0 - UNRELEASED
HDFS-9101. Remove deprecated NameNode.getUri() static helper method. HDFS-9101. Remove deprecated NameNode.getUri() static helper method.
(Mingliang Liu via wheat9) (Mingliang Liu via wheat9)
HDFS-9111. Move hdfs-client protobuf convert methods from PBHelper to
PBHelperClient. (Mingliang Liu via wheat9)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than

View File

@ -37,7 +37,6 @@ import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.OpTransferBlockP
import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.OpWriteBlockProto; import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.OpWriteBlockProto;
import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.ReleaseShortCircuitAccessRequestProto; import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.ReleaseShortCircuitAccessRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.ShortCircuitShmRequestProto; import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.ShortCircuitShmRequestProto;
import org.apache.hadoop.hdfs.protocolPB.PBHelper;
import org.apache.hadoop.hdfs.protocolPB.PBHelperClient; import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
import org.apache.hadoop.hdfs.server.datanode.CachingStrategy; import org.apache.hadoop.hdfs.server.datanode.CachingStrategy;
import org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.SlotId; import org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.SlotId;
@ -115,7 +114,7 @@ public abstract class Receiver implements DataTransferProtocol {
proto.getClass().getSimpleName()); proto.getClass().getSimpleName());
try { try {
readBlock(PBHelperClient.convert(proto.getHeader().getBaseHeader().getBlock()), readBlock(PBHelperClient.convert(proto.getHeader().getBaseHeader().getBlock()),
PBHelper.convert(proto.getHeader().getBaseHeader().getToken()), PBHelperClient.convert(proto.getHeader().getBaseHeader().getToken()),
proto.getHeader().getClientName(), proto.getHeader().getClientName(),
proto.getOffset(), proto.getOffset(),
proto.getLen(), proto.getLen(),
@ -131,17 +130,17 @@ public abstract class Receiver implements DataTransferProtocol {
/** Receive OP_WRITE_BLOCK */ /** Receive OP_WRITE_BLOCK */
private void opWriteBlock(DataInputStream in) throws IOException { private void opWriteBlock(DataInputStream in) throws IOException {
final OpWriteBlockProto proto = OpWriteBlockProto.parseFrom(vintPrefixed(in)); final OpWriteBlockProto proto = OpWriteBlockProto.parseFrom(vintPrefixed(in));
final DatanodeInfo[] targets = PBHelper.convert(proto.getTargetsList()); final DatanodeInfo[] targets = PBHelperClient.convert(proto.getTargetsList());
TraceScope traceScope = continueTraceSpan(proto.getHeader(), TraceScope traceScope = continueTraceSpan(proto.getHeader(),
proto.getClass().getSimpleName()); proto.getClass().getSimpleName());
try { try {
writeBlock(PBHelperClient.convert(proto.getHeader().getBaseHeader().getBlock()), writeBlock(PBHelperClient.convert(proto.getHeader().getBaseHeader().getBlock()),
PBHelperClient.convertStorageType(proto.getStorageType()), PBHelperClient.convertStorageType(proto.getStorageType()),
PBHelper.convert(proto.getHeader().getBaseHeader().getToken()), PBHelperClient.convert(proto.getHeader().getBaseHeader().getToken()),
proto.getHeader().getClientName(), proto.getHeader().getClientName(),
targets, targets,
PBHelper.convertStorageTypes(proto.getTargetStorageTypesList(), targets.length), PBHelperClient.convertStorageTypes(proto.getTargetStorageTypesList(), targets.length),
PBHelper.convert(proto.getSource()), PBHelperClient.convert(proto.getSource()),
fromProto(proto.getStage()), fromProto(proto.getStage()),
proto.getPipelineSize(), proto.getPipelineSize(),
proto.getMinBytesRcvd(), proto.getMaxBytesRcvd(), proto.getMinBytesRcvd(), proto.getMaxBytesRcvd(),
@ -152,7 +151,7 @@ public abstract class Receiver implements DataTransferProtocol {
CachingStrategy.newDefaultStrategy()), CachingStrategy.newDefaultStrategy()),
(proto.hasAllowLazyPersist() ? proto.getAllowLazyPersist() : false), (proto.hasAllowLazyPersist() ? proto.getAllowLazyPersist() : false),
(proto.hasPinning() ? proto.getPinning(): false), (proto.hasPinning() ? proto.getPinning(): false),
(PBHelper.convertBooleanList(proto.getTargetPinningsList()))); (PBHelperClient.convertBooleanList(proto.getTargetPinningsList())));
} finally { } finally {
if (traceScope != null) traceScope.close(); if (traceScope != null) traceScope.close();
} }
@ -162,15 +161,15 @@ public abstract class Receiver implements DataTransferProtocol {
private void opTransferBlock(DataInputStream in) throws IOException { private void opTransferBlock(DataInputStream in) throws IOException {
final OpTransferBlockProto proto = final OpTransferBlockProto proto =
OpTransferBlockProto.parseFrom(vintPrefixed(in)); OpTransferBlockProto.parseFrom(vintPrefixed(in));
final DatanodeInfo[] targets = PBHelper.convert(proto.getTargetsList()); final DatanodeInfo[] targets = PBHelperClient.convert(proto.getTargetsList());
TraceScope traceScope = continueTraceSpan(proto.getHeader(), TraceScope traceScope = continueTraceSpan(proto.getHeader(),
proto.getClass().getSimpleName()); proto.getClass().getSimpleName());
try { try {
transferBlock(PBHelperClient.convert(proto.getHeader().getBaseHeader().getBlock()), transferBlock(PBHelperClient.convert(proto.getHeader().getBaseHeader().getBlock()),
PBHelper.convert(proto.getHeader().getBaseHeader().getToken()), PBHelperClient.convert(proto.getHeader().getBaseHeader().getToken()),
proto.getHeader().getClientName(), proto.getHeader().getClientName(),
targets, targets,
PBHelper.convertStorageTypes(proto.getTargetStorageTypesList(), targets.length)); PBHelperClient.convertStorageTypes(proto.getTargetStorageTypesList(), targets.length));
} finally { } finally {
if (traceScope != null) traceScope.close(); if (traceScope != null) traceScope.close();
} }
@ -181,12 +180,12 @@ public abstract class Receiver implements DataTransferProtocol {
final OpRequestShortCircuitAccessProto proto = final OpRequestShortCircuitAccessProto proto =
OpRequestShortCircuitAccessProto.parseFrom(vintPrefixed(in)); OpRequestShortCircuitAccessProto.parseFrom(vintPrefixed(in));
SlotId slotId = (proto.hasSlotId()) ? SlotId slotId = (proto.hasSlotId()) ?
PBHelper.convert(proto.getSlotId()) : null; PBHelperClient.convert(proto.getSlotId()) : null;
TraceScope traceScope = continueTraceSpan(proto.getHeader(), TraceScope traceScope = continueTraceSpan(proto.getHeader(),
proto.getClass().getSimpleName()); proto.getClass().getSimpleName());
try { try {
requestShortCircuitFds(PBHelperClient.convert(proto.getHeader().getBlock()), requestShortCircuitFds(PBHelperClient.convert(proto.getHeader().getBlock()),
PBHelper.convert(proto.getHeader().getToken()), PBHelperClient.convert(proto.getHeader().getToken()),
slotId, proto.getMaxVersion(), slotId, proto.getMaxVersion(),
proto.getSupportsReceiptVerification()); proto.getSupportsReceiptVerification());
} finally { } finally {
@ -202,7 +201,7 @@ public abstract class Receiver implements DataTransferProtocol {
TraceScope traceScope = continueTraceSpan(proto.getTraceInfo(), TraceScope traceScope = continueTraceSpan(proto.getTraceInfo(),
proto.getClass().getSimpleName()); proto.getClass().getSimpleName());
try { try {
releaseShortCircuitFds(PBHelper.convert(proto.getSlotId())); releaseShortCircuitFds(PBHelperClient.convert(proto.getSlotId()));
} finally { } finally {
if (traceScope != null) traceScope.close(); if (traceScope != null) traceScope.close();
} }
@ -229,9 +228,9 @@ public abstract class Receiver implements DataTransferProtocol {
try { try {
replaceBlock(PBHelperClient.convert(proto.getHeader().getBlock()), replaceBlock(PBHelperClient.convert(proto.getHeader().getBlock()),
PBHelperClient.convertStorageType(proto.getStorageType()), PBHelperClient.convertStorageType(proto.getStorageType()),
PBHelper.convert(proto.getHeader().getToken()), PBHelperClient.convert(proto.getHeader().getToken()),
proto.getDelHint(), proto.getDelHint(),
PBHelper.convert(proto.getSource())); PBHelperClient.convert(proto.getSource()));
} finally { } finally {
if (traceScope != null) traceScope.close(); if (traceScope != null) traceScope.close();
} }
@ -244,7 +243,7 @@ public abstract class Receiver implements DataTransferProtocol {
proto.getClass().getSimpleName()); proto.getClass().getSimpleName());
try { try {
copyBlock(PBHelperClient.convert(proto.getHeader().getBlock()), copyBlock(PBHelperClient.convert(proto.getHeader().getBlock()),
PBHelper.convert(proto.getHeader().getToken())); PBHelperClient.convert(proto.getHeader().getToken()));
} finally { } finally {
if (traceScope != null) traceScope.close(); if (traceScope != null) traceScope.close();
} }
@ -257,7 +256,7 @@ public abstract class Receiver implements DataTransferProtocol {
proto.getClass().getSimpleName()); proto.getClass().getSimpleName());
try { try {
blockChecksum(PBHelperClient.convert(proto.getHeader().getBlock()), blockChecksum(PBHelperClient.convert(proto.getHeader().getBlock()),
PBHelper.convert(proto.getHeader().getToken())); PBHelperClient.convert(proto.getHeader().getToken()));
} finally { } finally {
if (traceScope != null) traceScope.close(); if (traceScope != null) traceScope.close();
} }

View File

@ -134,7 +134,9 @@ public class ClientDatanodeProtocolServerSideTranslatorPB implements
throws ServiceException { throws ServiceException {
BlockLocalPathInfo resp; BlockLocalPathInfo resp;
try { try {
resp = impl.getBlockLocalPathInfo(PBHelperClient.convert(request.getBlock()), PBHelper.convert(request.getToken())); resp = impl.getBlockLocalPathInfo(
PBHelperClient.convert(request.getBlock()),
PBHelperClient.convert(request.getToken()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -155,7 +157,7 @@ public class ClientDatanodeProtocolServerSideTranslatorPB implements
List<Token<BlockTokenIdentifier>> tokens = List<Token<BlockTokenIdentifier>> tokens =
new ArrayList<Token<BlockTokenIdentifier>>(request.getTokensCount()); new ArrayList<Token<BlockTokenIdentifier>>(request.getTokensCount());
for (TokenProto b : request.getTokensList()) { for (TokenProto b : request.getTokensList()) {
tokens.add(PBHelper.convert(b)); tokens.add(PBHelperClient.convert(b));
} }
long[] blockIds = Longs.toArray(request.getBlockIdsList()); long[] blockIds = Longs.toArray(request.getBlockIdsList());
@ -193,7 +195,7 @@ public class ClientDatanodeProtocolServerSideTranslatorPB implements
GetDatanodeInfoResponseProto res; GetDatanodeInfoResponseProto res;
try { try {
res = GetDatanodeInfoResponseProto.newBuilder() res = GetDatanodeInfoResponseProto.newBuilder()
.setLocalInfo(PBHelper.convert(impl.getDatanodeInfo())).build(); .setLocalInfo(PBHelperClient.convert(impl.getDatanodeInfo())).build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }

View File

@ -19,7 +19,7 @@ package org.apache.hadoop.hdfs.protocolPB;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.HdfsConstants;
import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.ClientNamenodeProtocol; import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.ClientNamenodeProtocol;
import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSelector; import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSelector;
@ -31,7 +31,7 @@ import org.apache.hadoop.security.token.TokenInfo;
@InterfaceAudience.Private @InterfaceAudience.Private
@InterfaceStability.Stable @InterfaceStability.Stable
@KerberosInfo( @KerberosInfo(
serverPrincipal = DFSConfigKeys.DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY) serverPrincipal = HdfsClientConfigKeys.DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY)
@TokenInfo(DelegationTokenSelector.class) @TokenInfo(DelegationTokenSelector.class)
@ProtocolInfo(protocolName = HdfsConstants.CLIENT_NAMENODE_PROTOCOL_NAME, @ProtocolInfo(protocolName = HdfsConstants.CLIENT_NAMENODE_PROTOCOL_NAME,
protocolVersion = 1) protocolVersion = 1)

View File

@ -370,7 +370,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
Builder builder = GetBlockLocationsResponseProto Builder builder = GetBlockLocationsResponseProto
.newBuilder(); .newBuilder();
if (b != null) { if (b != null) {
builder.setLocations(PBHelper.convert(b)).build(); builder.setLocations(PBHelperClient.convert(b)).build();
} }
return builder.build(); return builder.build();
} catch (IOException e) { } catch (IOException e) {
@ -385,7 +385,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
try { try {
FsServerDefaults result = server.getServerDefaults(); FsServerDefaults result = server.getServerDefaults();
return GetServerDefaultsResponseProto.newBuilder() return GetServerDefaultsResponseProto.newBuilder()
.setServerDefaults(PBHelper.convert(result)) .setServerDefaults(PBHelperClient.convert(result))
.build(); .build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
@ -398,14 +398,14 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
CreateRequestProto req) throws ServiceException { CreateRequestProto req) throws ServiceException {
try { try {
HdfsFileStatus result = server.create(req.getSrc(), HdfsFileStatus result = server.create(req.getSrc(),
PBHelper.convert(req.getMasked()), req.getClientName(), PBHelperClient.convert(req.getMasked()), req.getClientName(),
PBHelper.convertCreateFlag(req.getCreateFlag()), req.getCreateParent(), PBHelperClient.convertCreateFlag(req.getCreateFlag()), req.getCreateParent(),
(short) req.getReplication(), req.getBlockSize(), (short) req.getReplication(), req.getBlockSize(),
PBHelper.convertCryptoProtocolVersions( PBHelperClient.convertCryptoProtocolVersions(
req.getCryptoProtocolVersionList())); req.getCryptoProtocolVersionList()));
if (result != null) { if (result != null) {
return CreateResponseProto.newBuilder().setFs(PBHelper.convert(result)) return CreateResponseProto.newBuilder().setFs(PBHelperClient.convert(result))
.build(); .build();
} }
return VOID_CREATE_RESPONSE; return VOID_CREATE_RESPONSE;
@ -419,16 +419,16 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
AppendRequestProto req) throws ServiceException { AppendRequestProto req) throws ServiceException {
try { try {
EnumSetWritable<CreateFlag> flags = req.hasFlag() ? EnumSetWritable<CreateFlag> flags = req.hasFlag() ?
PBHelper.convertCreateFlag(req.getFlag()) : PBHelperClient.convertCreateFlag(req.getFlag()) :
new EnumSetWritable<>(EnumSet.of(CreateFlag.APPEND)); new EnumSetWritable<>(EnumSet.of(CreateFlag.APPEND));
LastBlockWithStatus result = server.append(req.getSrc(), LastBlockWithStatus result = server.append(req.getSrc(),
req.getClientName(), flags); req.getClientName(), flags);
AppendResponseProto.Builder builder = AppendResponseProto.newBuilder(); AppendResponseProto.Builder builder = AppendResponseProto.newBuilder();
if (result.getLastBlock() != null) { if (result.getLastBlock() != null) {
builder.setBlock(PBHelper.convert(result.getLastBlock())); builder.setBlock(PBHelperClient.convert(result.getLastBlock()));
} }
if (result.getFileStatus() != null) { if (result.getFileStatus() != null) {
builder.setStat(PBHelper.convert(result.getFileStatus())); builder.setStat(PBHelperClient.convert(result.getFileStatus()));
} }
return builder.build(); return builder.build();
} catch (IOException e) { } catch (IOException e) {
@ -453,7 +453,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public SetPermissionResponseProto setPermission(RpcController controller, public SetPermissionResponseProto setPermission(RpcController controller,
SetPermissionRequestProto req) throws ServiceException { SetPermissionRequestProto req) throws ServiceException {
try { try {
server.setPermission(req.getSrc(), PBHelper.convert(req.getPermission())); server.setPermission(req.getSrc(), PBHelperClient.convert(req.getPermission()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -496,12 +496,12 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
req.getSrc(), req.getSrc(),
req.getClientName(), req.getClientName(),
req.hasPrevious() ? PBHelperClient.convert(req.getPrevious()) : null, req.hasPrevious() ? PBHelperClient.convert(req.getPrevious()) : null,
(excl == null || excl.size() == 0) ? null : PBHelper.convert(excl (excl == null || excl.size() == 0) ? null : PBHelperClient.convert(excl
.toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(), .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(),
(favor == null || favor.size() == 0) ? null : favor (favor == null || favor.size() == 0) ? null : favor
.toArray(new String[favor.size()])); .toArray(new String[favor.size()]));
return AddBlockResponseProto.newBuilder() return AddBlockResponseProto.newBuilder()
.setBlock(PBHelper.convert(result)).build(); .setBlock(PBHelperClient.convert(result)).build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -517,15 +517,15 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
List<DatanodeInfoProto> excludesList = req.getExcludesList(); List<DatanodeInfoProto> excludesList = req.getExcludesList();
LocatedBlock result = server.getAdditionalDatanode(req.getSrc(), LocatedBlock result = server.getAdditionalDatanode(req.getSrc(),
req.getFileId(), PBHelperClient.convert(req.getBlk()), req.getFileId(), PBHelperClient.convert(req.getBlk()),
PBHelper.convert(existingList.toArray( PBHelperClient.convert(existingList.toArray(
new DatanodeInfoProto[existingList.size()])), new DatanodeInfoProto[existingList.size()])),
existingStorageIDsList.toArray( existingStorageIDsList.toArray(
new String[existingStorageIDsList.size()]), new String[existingStorageIDsList.size()]),
PBHelper.convert(excludesList.toArray( PBHelperClient.convert(excludesList.toArray(
new DatanodeInfoProto[excludesList.size()])), new DatanodeInfoProto[excludesList.size()])),
req.getNumAdditionalNodes(), req.getClientName()); req.getNumAdditionalNodes(), req.getClientName());
return GetAdditionalDatanodeResponseProto.newBuilder().setBlock( return GetAdditionalDatanodeResponseProto.newBuilder().setBlock(
PBHelper.convert(result)) PBHelperClient.convert(result))
.build(); .build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
@ -551,8 +551,8 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
ReportBadBlocksRequestProto req) throws ServiceException { ReportBadBlocksRequestProto req) throws ServiceException {
try { try {
List<LocatedBlockProto> bl = req.getBlocksList(); List<LocatedBlockProto> bl = req.getBlocksList();
server.reportBadBlocks(PBHelper.convertLocatedBlock( server.reportBadBlocks(PBHelperClient.convertLocatedBlock(
bl.toArray(new LocatedBlockProto[bl.size()]))); bl.toArray(new LocatedBlockProto[bl.size()])));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -623,7 +623,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
MkdirsRequestProto req) throws ServiceException { MkdirsRequestProto req) throws ServiceException {
try { try {
boolean result = server.mkdirs(req.getSrc(), boolean result = server.mkdirs(req.getSrc(),
PBHelper.convert(req.getMasked()), req.getCreateParent()); PBHelperClient.convert(req.getMasked()), req.getCreateParent());
return MkdirsResponseProto.newBuilder().setResult(result).build(); return MkdirsResponseProto.newBuilder().setResult(result).build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
@ -639,7 +639,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
req.getNeedLocation()); req.getNeedLocation());
if (result !=null) { if (result !=null) {
return GetListingResponseProto.newBuilder().setDirList( return GetListingResponseProto.newBuilder().setDirList(
PBHelper.convert(result)).build(); PBHelperClient.convert(result)).build();
} else { } else {
return VOID_GETLISTING_RESPONSE; return VOID_GETLISTING_RESPONSE;
} }
@ -687,7 +687,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public GetFsStatsResponseProto getFsStats(RpcController controller, public GetFsStatsResponseProto getFsStats(RpcController controller,
GetFsStatusRequestProto req) throws ServiceException { GetFsStatusRequestProto req) throws ServiceException {
try { try {
return PBHelper.convert(server.getStats()); return PBHelperClient.convert(server.getStats());
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -699,7 +699,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
throws ServiceException { throws ServiceException {
try { try {
List<? extends DatanodeInfoProto> result = PBHelperClient.convert(server List<? extends DatanodeInfoProto> result = PBHelperClient.convert(server
.getDatanodeReport(PBHelper.convert(req.getType()))); .getDatanodeReport(PBHelperClient.convert(req.getType())));
return GetDatanodeReportResponseProto.newBuilder() return GetDatanodeReportResponseProto.newBuilder()
.addAllDi(result).build(); .addAllDi(result).build();
} catch (IOException e) { } catch (IOException e) {
@ -712,8 +712,8 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
RpcController controller, GetDatanodeStorageReportRequestProto req) RpcController controller, GetDatanodeStorageReportRequestProto req)
throws ServiceException { throws ServiceException {
try { try {
List<DatanodeStorageReportProto> reports = PBHelper.convertDatanodeStorageReports( List<DatanodeStorageReportProto> reports = PBHelperClient.convertDatanodeStorageReports(
server.getDatanodeStorageReport(PBHelper.convert(req.getType()))); server.getDatanodeStorageReport(PBHelperClient.convert(req.getType())));
return GetDatanodeStorageReportResponseProto.newBuilder() return GetDatanodeStorageReportResponseProto.newBuilder()
.addAllDatanodeStorageReports(reports) .addAllDatanodeStorageReports(reports)
.build(); .build();
@ -739,7 +739,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public SetSafeModeResponseProto setSafeMode(RpcController controller, public SetSafeModeResponseProto setSafeMode(RpcController controller,
SetSafeModeRequestProto req) throws ServiceException { SetSafeModeRequestProto req) throws ServiceException {
try { try {
boolean result = server.setSafeMode(PBHelper.convert(req.getAction()), boolean result = server.setSafeMode(PBHelperClient.convert(req.getAction()),
req.getChecked()); req.getChecked());
return SetSafeModeResponseProto.newBuilder().setResult(result).build(); return SetSafeModeResponseProto.newBuilder().setResult(result).build();
} catch (IOException e) { } catch (IOException e) {
@ -801,10 +801,10 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
RollingUpgradeRequestProto req) throws ServiceException { RollingUpgradeRequestProto req) throws ServiceException {
try { try {
final RollingUpgradeInfo info = server.rollingUpgrade( final RollingUpgradeInfo info = server.rollingUpgrade(
PBHelper.convert(req.getAction())); PBHelperClient.convert(req.getAction()));
final RollingUpgradeResponseProto.Builder b = RollingUpgradeResponseProto.newBuilder(); final RollingUpgradeResponseProto.Builder b = RollingUpgradeResponseProto.newBuilder();
if (info != null) { if (info != null) {
b.setRollingUpgradeInfo(PBHelper.convert(info)); b.setRollingUpgradeInfo(PBHelperClient.convert(info));
} }
return b.build(); return b.build();
} catch (IOException e) { } catch (IOException e) {
@ -820,7 +820,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
CorruptFileBlocks result = server.listCorruptFileBlocks( CorruptFileBlocks result = server.listCorruptFileBlocks(
req.getPath(), req.hasCookie() ? req.getCookie(): null); req.getPath(), req.hasCookie() ? req.getCookie(): null);
return ListCorruptFileBlocksResponseProto.newBuilder() return ListCorruptFileBlocksResponseProto.newBuilder()
.setCorrupt(PBHelper.convert(result)) .setCorrupt(PBHelperClient.convert(result))
.build(); .build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
@ -847,7 +847,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
if (result != null) { if (result != null) {
return GetFileInfoResponseProto.newBuilder().setFs( return GetFileInfoResponseProto.newBuilder().setFs(
PBHelper.convert(result)).build(); PBHelperClient.convert(result)).build();
} }
return VOID_GETFILEINFO_RESPONSE; return VOID_GETFILEINFO_RESPONSE;
} catch (IOException e) { } catch (IOException e) {
@ -862,7 +862,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
HdfsFileStatus result = server.getFileLinkInfo(req.getSrc()); HdfsFileStatus result = server.getFileLinkInfo(req.getSrc());
if (result != null) { if (result != null) {
return GetFileLinkInfoResponseProto.newBuilder().setFs( return GetFileLinkInfoResponseProto.newBuilder().setFs(
PBHelper.convert(result)).build(); PBHelperClient.convert(result)).build();
} else { } else {
return VOID_GETFILELINKINFO_RESPONSE; return VOID_GETFILELINKINFO_RESPONSE;
} }
@ -879,7 +879,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
try { try {
ContentSummary result = server.getContentSummary(req.getPath()); ContentSummary result = server.getContentSummary(req.getPath());
return GetContentSummaryResponseProto.newBuilder() return GetContentSummaryResponseProto.newBuilder()
.setSummary(PBHelper.convert(result)).build(); .setSummary(PBHelperClient.convert(result)).build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -927,7 +927,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
CreateSymlinkRequestProto req) throws ServiceException { CreateSymlinkRequestProto req) throws ServiceException {
try { try {
server.createSymlink(req.getTarget(), req.getLink(), server.createSymlink(req.getTarget(), req.getLink(),
PBHelper.convert(req.getDirPerm()), req.getCreateParent()); PBHelperClient.convert(req.getDirPerm()), req.getCreateParent());
return VOID_CREATESYMLINK_RESPONSE; return VOID_CREATESYMLINK_RESPONSE;
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
@ -955,7 +955,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
RpcController controller, UpdateBlockForPipelineRequestProto req) RpcController controller, UpdateBlockForPipelineRequestProto req)
throws ServiceException { throws ServiceException {
try { try {
LocatedBlockProto result = PBHelper.convert(server LocatedBlockProto result = PBHelperClient.convert(server
.updateBlockForPipeline(PBHelperClient.convert(req.getBlock()), .updateBlockForPipeline(PBHelperClient.convert(req.getBlock()),
req.getClientName())); req.getClientName()));
return UpdateBlockForPipelineResponseProto.newBuilder().setBlock(result) return UpdateBlockForPipelineResponseProto.newBuilder().setBlock(result)
@ -974,7 +974,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
server.updatePipeline(req.getClientName(), server.updatePipeline(req.getClientName(),
PBHelperClient.convert(req.getOldBlock()), PBHelperClient.convert(req.getOldBlock()),
PBHelperClient.convert(req.getNewBlock()), PBHelperClient.convert(req.getNewBlock()),
PBHelper.convert(newNodes.toArray(new DatanodeIDProto[newNodes.size()])), PBHelperClient.convert(newNodes.toArray(new DatanodeIDProto[newNodes.size()])),
newStorageIDs.toArray(new String[newStorageIDs.size()])); newStorageIDs.toArray(new String[newStorageIDs.size()]));
return VOID_UPDATEPIPELINE_RESPONSE; return VOID_UPDATEPIPELINE_RESPONSE;
} catch (IOException e) { } catch (IOException e) {
@ -1005,7 +1005,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
RpcController controller, RenewDelegationTokenRequestProto req) RpcController controller, RenewDelegationTokenRequestProto req)
throws ServiceException { throws ServiceException {
try { try {
long result = server.renewDelegationToken(PBHelper long result = server.renewDelegationToken(PBHelperClient
.convertDelegationToken(req.getToken())); .convertDelegationToken(req.getToken()));
return RenewDelegationTokenResponseProto.newBuilder() return RenewDelegationTokenResponseProto.newBuilder()
.setNewExpiryTime(result).build(); .setNewExpiryTime(result).build();
@ -1019,7 +1019,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
RpcController controller, CancelDelegationTokenRequestProto req) RpcController controller, CancelDelegationTokenRequestProto req)
throws ServiceException { throws ServiceException {
try { try {
server.cancelDelegationToken(PBHelper.convertDelegationToken(req server.cancelDelegationToken(PBHelperClient.convertDelegationToken(req
.getToken())); .getToken()));
return VOID_CANCELDELEGATIONTOKEN_RESPONSE; return VOID_CANCELDELEGATIONTOKEN_RESPONSE;
} catch (IOException e) { } catch (IOException e) {
@ -1048,7 +1048,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
GetDataEncryptionKeyResponseProto.newBuilder(); GetDataEncryptionKeyResponseProto.newBuilder();
DataEncryptionKey encryptionKey = server.getDataEncryptionKey(); DataEncryptionKey encryptionKey = server.getDataEncryptionKey();
if (encryptionKey != null) { if (encryptionKey != null) {
builder.setDataEncryptionKey(PBHelper.convert(encryptionKey)); builder.setDataEncryptionKey(PBHelperClient.convert(encryptionKey));
} }
return builder.build(); return builder.build();
} catch (IOException e) { } catch (IOException e) {
@ -1127,7 +1127,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
.getSnapshottableDirListing(); .getSnapshottableDirListing();
if (result != null) { if (result != null) {
return GetSnapshottableDirListingResponseProto.newBuilder(). return GetSnapshottableDirListingResponseProto.newBuilder().
setSnapshottableDirList(PBHelper.convert(result)).build(); setSnapshottableDirList(PBHelperClient.convert(result)).build();
} else { } else {
return NULL_GET_SNAPSHOTTABLE_DIR_LISTING_RESPONSE; return NULL_GET_SNAPSHOTTABLE_DIR_LISTING_RESPONSE;
} }
@ -1145,7 +1145,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
request.getSnapshotRoot(), request.getFromSnapshot(), request.getSnapshotRoot(), request.getFromSnapshot(),
request.getToSnapshot()); request.getToSnapshot());
return GetSnapshotDiffReportResponseProto.newBuilder() return GetSnapshotDiffReportResponseProto.newBuilder()
.setDiffReport(PBHelper.convert(report)).build(); .setDiffReport(PBHelperClient.convert(report)).build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -1169,8 +1169,8 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
throws ServiceException { throws ServiceException {
try { try {
long id = server.addCacheDirective( long id = server.addCacheDirective(
PBHelper.convert(request.getInfo()), PBHelperClient.convert(request.getInfo()),
PBHelper.convertCacheFlags(request.getCacheFlags())); PBHelperClient.convertCacheFlags(request.getCacheFlags()));
return AddCacheDirectiveResponseProto.newBuilder(). return AddCacheDirectiveResponseProto.newBuilder().
setId(id).build(); setId(id).build();
} catch (IOException e) { } catch (IOException e) {
@ -1184,8 +1184,8 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
throws ServiceException { throws ServiceException {
try { try {
server.modifyCacheDirective( server.modifyCacheDirective(
PBHelper.convert(request.getInfo()), PBHelperClient.convert(request.getInfo()),
PBHelper.convertCacheFlags(request.getCacheFlags())); PBHelperClient.convertCacheFlags(request.getCacheFlags()));
return ModifyCacheDirectiveResponseProto.newBuilder().build(); return ModifyCacheDirectiveResponseProto.newBuilder().build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
@ -1212,14 +1212,14 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
throws ServiceException { throws ServiceException {
try { try {
CacheDirectiveInfo filter = CacheDirectiveInfo filter =
PBHelper.convert(request.getFilter()); PBHelperClient.convert(request.getFilter());
BatchedEntries<CacheDirectiveEntry> entries = BatchedEntries<CacheDirectiveEntry> entries =
server.listCacheDirectives(request.getPrevId(), filter); server.listCacheDirectives(request.getPrevId(), filter);
ListCacheDirectivesResponseProto.Builder builder = ListCacheDirectivesResponseProto.Builder builder =
ListCacheDirectivesResponseProto.newBuilder(); ListCacheDirectivesResponseProto.newBuilder();
builder.setHasMore(entries.hasMore()); builder.setHasMore(entries.hasMore());
for (int i=0, n=entries.size(); i<n; i++) { for (int i=0, n=entries.size(); i<n; i++) {
builder.addElements(PBHelper.convert(entries.get(i))); builder.addElements(PBHelperClient.convert(entries.get(i)));
} }
return builder.build(); return builder.build();
} catch (IOException e) { } catch (IOException e) {
@ -1231,7 +1231,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public AddCachePoolResponseProto addCachePool(RpcController controller, public AddCachePoolResponseProto addCachePool(RpcController controller,
AddCachePoolRequestProto request) throws ServiceException { AddCachePoolRequestProto request) throws ServiceException {
try { try {
server.addCachePool(PBHelper.convert(request.getInfo())); server.addCachePool(PBHelperClient.convert(request.getInfo()));
return AddCachePoolResponseProto.newBuilder().build(); return AddCachePoolResponseProto.newBuilder().build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
@ -1242,7 +1242,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public ModifyCachePoolResponseProto modifyCachePool(RpcController controller, public ModifyCachePoolResponseProto modifyCachePool(RpcController controller,
ModifyCachePoolRequestProto request) throws ServiceException { ModifyCachePoolRequestProto request) throws ServiceException {
try { try {
server.modifyCachePool(PBHelper.convert(request.getInfo())); server.modifyCachePool(PBHelperClient.convert(request.getInfo()));
return ModifyCachePoolResponseProto.newBuilder().build(); return ModifyCachePoolResponseProto.newBuilder().build();
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
@ -1270,7 +1270,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
ListCachePoolsResponseProto.newBuilder(); ListCachePoolsResponseProto.newBuilder();
responseBuilder.setHasMore(entries.hasMore()); responseBuilder.setHasMore(entries.hasMore());
for (int i=0, n=entries.size(); i<n; i++) { for (int i=0, n=entries.size(); i<n; i++) {
responseBuilder.addEntries(PBHelper.convert(entries.get(i))); responseBuilder.addEntries(PBHelperClient.convert(entries.get(i)));
} }
return responseBuilder.build(); return responseBuilder.build();
} catch (IOException e) { } catch (IOException e) {
@ -1283,7 +1283,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
RpcController controller, ModifyAclEntriesRequestProto req) RpcController controller, ModifyAclEntriesRequestProto req)
throws ServiceException { throws ServiceException {
try { try {
server.modifyAclEntries(req.getSrc(), PBHelper.convertAclEntry(req.getAclSpecList())); server.modifyAclEntries(req.getSrc(), PBHelperClient.convertAclEntry(req.getAclSpecList()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -1296,7 +1296,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
throws ServiceException { throws ServiceException {
try { try {
server.removeAclEntries(req.getSrc(), server.removeAclEntries(req.getSrc(),
PBHelper.convertAclEntry(req.getAclSpecList())); PBHelperClient.convertAclEntry(req.getAclSpecList()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -1330,7 +1330,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public SetAclResponseProto setAcl(RpcController controller, public SetAclResponseProto setAcl(RpcController controller,
SetAclRequestProto req) throws ServiceException { SetAclRequestProto req) throws ServiceException {
try { try {
server.setAcl(req.getSrc(), PBHelper.convertAclEntry(req.getAclSpecList())); server.setAcl(req.getSrc(), PBHelperClient.convertAclEntry(req.getAclSpecList()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -1341,7 +1341,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public GetAclStatusResponseProto getAclStatus(RpcController controller, public GetAclStatusResponseProto getAclStatus(RpcController controller,
GetAclStatusRequestProto req) throws ServiceException { GetAclStatusRequestProto req) throws ServiceException {
try { try {
return PBHelper.convert(server.getAclStatus(req.getSrc())); return PBHelperClient.convert(server.getAclStatus(req.getSrc()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -1368,7 +1368,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
GetEZForPathResponseProto.newBuilder(); GetEZForPathResponseProto.newBuilder();
final EncryptionZone ret = server.getEZForPath(req.getSrc()); final EncryptionZone ret = server.getEZForPath(req.getSrc());
if (ret != null) { if (ret != null) {
builder.setZone(PBHelper.convert(ret)); builder.setZone(PBHelperClient.convert(ret));
} }
return builder.build(); return builder.build();
} catch (IOException e) { } catch (IOException e) {
@ -1387,7 +1387,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
ListEncryptionZonesResponseProto.newBuilder(); ListEncryptionZonesResponseProto.newBuilder();
builder.setHasMore(entries.hasMore()); builder.setHasMore(entries.hasMore());
for (int i=0; i<entries.size(); i++) { for (int i=0; i<entries.size(); i++) {
builder.addZones(PBHelper.convert(entries.get(i))); builder.addZones(PBHelperClient.convert(entries.get(i)));
} }
return builder.build(); return builder.build();
} catch (IOException e) { } catch (IOException e) {
@ -1399,8 +1399,8 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public SetXAttrResponseProto setXAttr(RpcController controller, public SetXAttrResponseProto setXAttr(RpcController controller,
SetXAttrRequestProto req) throws ServiceException { SetXAttrRequestProto req) throws ServiceException {
try { try {
server.setXAttr(req.getSrc(), PBHelper.convertXAttr(req.getXAttr()), server.setXAttr(req.getSrc(), PBHelperClient.convertXAttr(req.getXAttr()),
PBHelper.convert(req.getFlag())); PBHelperClient.convert(req.getFlag()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -1411,8 +1411,8 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public GetXAttrsResponseProto getXAttrs(RpcController controller, public GetXAttrsResponseProto getXAttrs(RpcController controller,
GetXAttrsRequestProto req) throws ServiceException { GetXAttrsRequestProto req) throws ServiceException {
try { try {
return PBHelper.convertXAttrsResponse(server.getXAttrs(req.getSrc(), return PBHelperClient.convertXAttrsResponse(server.getXAttrs(req.getSrc(),
PBHelper.convertXAttrs(req.getXAttrsList()))); PBHelperClient.convertXAttrs(req.getXAttrsList())));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -1422,7 +1422,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public ListXAttrsResponseProto listXAttrs(RpcController controller, public ListXAttrsResponseProto listXAttrs(RpcController controller,
ListXAttrsRequestProto req) throws ServiceException { ListXAttrsRequestProto req) throws ServiceException {
try { try {
return PBHelper.convertListXAttrsResponse(server.listXAttrs(req.getSrc())); return PBHelperClient.convertListXAttrsResponse(server.listXAttrs(req.getSrc()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -1432,7 +1432,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public RemoveXAttrResponseProto removeXAttr(RpcController controller, public RemoveXAttrResponseProto removeXAttr(RpcController controller,
RemoveXAttrRequestProto req) throws ServiceException { RemoveXAttrRequestProto req) throws ServiceException {
try { try {
server.removeXAttr(req.getSrc(), PBHelper.convertXAttr(req.getXAttr())); server.removeXAttr(req.getSrc(), PBHelperClient.convertXAttr(req.getXAttr()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -1443,7 +1443,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public CheckAccessResponseProto checkAccess(RpcController controller, public CheckAccessResponseProto checkAccess(RpcController controller,
CheckAccessRequestProto req) throws ServiceException { CheckAccessRequestProto req) throws ServiceException {
try { try {
server.checkAccess(req.getPath(), PBHelper.convert(req.getMode())); server.checkAccess(req.getPath(), PBHelperClient.convert(req.getMode()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
@ -1467,7 +1467,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
RpcController controller, GetStoragePolicyRequestProto request) RpcController controller, GetStoragePolicyRequestProto request)
throws ServiceException { throws ServiceException {
try { try {
BlockStoragePolicyProto policy = PBHelper.convert(server BlockStoragePolicyProto policy = PBHelperClient.convert(server
.getStoragePolicy(request.getPath())); .getStoragePolicy(request.getPath()));
return GetStoragePolicyResponseProto.newBuilder() return GetStoragePolicyResponseProto.newBuilder()
.setStoragePolicy(policy).build(); .setStoragePolicy(policy).build();
@ -1488,7 +1488,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
return builder.build(); return builder.build();
} }
for (BlockStoragePolicy policy : policies) { for (BlockStoragePolicy policy : policies) {
builder.addPolicies(PBHelper.convert(policy)); builder.addPolicies(PBHelperClient.convert(policy));
} }
return builder.build(); return builder.build();
} catch (IOException e) { } catch (IOException e) {
@ -1510,7 +1510,7 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
public GetEditsFromTxidResponseProto getEditsFromTxid(RpcController controller, public GetEditsFromTxidResponseProto getEditsFromTxid(RpcController controller,
GetEditsFromTxidRequestProto req) throws ServiceException { GetEditsFromTxidRequestProto req) throws ServiceException {
try { try {
return PBHelper.convertEditsResponse(server.getEditsFromTxid( return PBHelperClient.convertEditsResponse(server.getEditsFromTxid(
req.getTxid())); req.getTxid()));
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);

View File

@ -255,8 +255,8 @@ public class ClientNamenodeProtocolTranslatorPB implements
try { try {
GetBlockLocationsResponseProto resp = rpcProxy.getBlockLocations(null, GetBlockLocationsResponseProto resp = rpcProxy.getBlockLocations(null,
req); req);
return resp.hasLocations() ? return resp.hasLocations() ?
PBHelper.convert(resp.getLocations()) : null; PBHelperClient.convert(resp.getLocations()) : null;
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -266,7 +266,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
public FsServerDefaults getServerDefaults() throws IOException { public FsServerDefaults getServerDefaults() throws IOException {
GetServerDefaultsRequestProto req = VOID_GET_SERVER_DEFAULT_REQUEST; GetServerDefaultsRequestProto req = VOID_GET_SERVER_DEFAULT_REQUEST;
try { try {
return PBHelper return PBHelperClient
.convert(rpcProxy.getServerDefaults(null, req).getServerDefaults()); .convert(rpcProxy.getServerDefaults(null, req).getServerDefaults());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -285,17 +285,17 @@ public class ClientNamenodeProtocolTranslatorPB implements
IOException { IOException {
CreateRequestProto.Builder builder = CreateRequestProto.newBuilder() CreateRequestProto.Builder builder = CreateRequestProto.newBuilder()
.setSrc(src) .setSrc(src)
.setMasked(PBHelper.convert(masked)) .setMasked(PBHelperClient.convert(masked))
.setClientName(clientName) .setClientName(clientName)
.setCreateFlag(PBHelper.convertCreateFlag(flag)) .setCreateFlag(PBHelperClient.convertCreateFlag(flag))
.setCreateParent(createParent) .setCreateParent(createParent)
.setReplication(replication) .setReplication(replication)
.setBlockSize(blockSize); .setBlockSize(blockSize);
builder.addAllCryptoProtocolVersion(PBHelper.convert(supportedVersions)); builder.addAllCryptoProtocolVersion(PBHelperClient.convert(supportedVersions));
CreateRequestProto req = builder.build(); CreateRequestProto req = builder.build();
try { try {
CreateResponseProto res = rpcProxy.create(null, req); CreateResponseProto res = rpcProxy.create(null, req);
return res.hasFs() ? PBHelper.convert(res.getFs()) : null; return res.hasFs() ? PBHelperClient.convert(res.getFs()) : null;
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -323,13 +323,13 @@ public class ClientNamenodeProtocolTranslatorPB implements
DSQuotaExceededException, FileNotFoundException, SafeModeException, DSQuotaExceededException, FileNotFoundException, SafeModeException,
UnresolvedLinkException, IOException { UnresolvedLinkException, IOException {
AppendRequestProto req = AppendRequestProto.newBuilder().setSrc(src) AppendRequestProto req = AppendRequestProto.newBuilder().setSrc(src)
.setClientName(clientName).setFlag(PBHelper.convertCreateFlag(flag)) .setClientName(clientName).setFlag(PBHelperClient.convertCreateFlag(flag))
.build(); .build();
try { try {
AppendResponseProto res = rpcProxy.append(null, req); AppendResponseProto res = rpcProxy.append(null, req);
LocatedBlock lastBlock = res.hasBlock() ? PBHelper LocatedBlock lastBlock = res.hasBlock() ? PBHelperClient
.convert(res.getBlock()) : null; .convert(res.getBlock()) : null;
HdfsFileStatus stat = (res.hasStat()) ? PBHelper.convert(res.getStat()) HdfsFileStatus stat = (res.hasStat()) ? PBHelperClient.convert(res.getStat())
: null; : null;
return new LastBlockWithStatus(lastBlock, stat); return new LastBlockWithStatus(lastBlock, stat);
} catch (ServiceException e) { } catch (ServiceException e) {
@ -359,7 +359,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
UnresolvedLinkException, IOException { UnresolvedLinkException, IOException {
SetPermissionRequestProto req = SetPermissionRequestProto.newBuilder() SetPermissionRequestProto req = SetPermissionRequestProto.newBuilder()
.setSrc(src) .setSrc(src)
.setPermission(PBHelper.convert(permission)) .setPermission(PBHelperClient.convert(permission))
.build(); .build();
try { try {
rpcProxy.setPermission(null, req); rpcProxy.setPermission(null, req);
@ -416,7 +416,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
req.addAllFavoredNodes(Arrays.asList(favoredNodes)); req.addAllFavoredNodes(Arrays.asList(favoredNodes));
} }
try { try {
return PBHelper.convert(rpcProxy.addBlock(null, req.build()).getBlock()); return PBHelperClient.convert(rpcProxy.addBlock(null, req.build()).getBlock());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -441,7 +441,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
.setClientName(clientName) .setClientName(clientName)
.build(); .build();
try { try {
return PBHelper.convert(rpcProxy.getAdditionalDatanode(null, req) return PBHelperClient.convert(rpcProxy.getAdditionalDatanode(null, req)
.getBlock()); .getBlock());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -469,7 +469,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
@Override @Override
public void reportBadBlocks(LocatedBlock[] blocks) throws IOException { public void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
ReportBadBlocksRequestProto req = ReportBadBlocksRequestProto.newBuilder() ReportBadBlocksRequestProto req = ReportBadBlocksRequestProto.newBuilder()
.addAllBlocks(Arrays.asList(PBHelper.convertLocatedBlock(blocks))) .addAllBlocks(Arrays.asList(PBHelperClient.convertLocatedBlock(blocks)))
.build(); .build();
try { try {
rpcProxy.reportBadBlocks(null, req); rpcProxy.reportBadBlocks(null, req);
@ -552,7 +552,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
IOException { IOException {
MkdirsRequestProto req = MkdirsRequestProto.newBuilder() MkdirsRequestProto req = MkdirsRequestProto.newBuilder()
.setSrc(src) .setSrc(src)
.setMasked(PBHelper.convert(masked)) .setMasked(PBHelperClient.convert(masked))
.setCreateParent(createParent).build(); .setCreateParent(createParent).build();
try { try {
@ -574,7 +574,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
GetListingResponseProto result = rpcProxy.getListing(null, req); GetListingResponseProto result = rpcProxy.getListing(null, req);
if (result.hasDirList()) { if (result.hasDirList()) {
return PBHelper.convert(result.getDirList()); return PBHelperClient.convert(result.getDirList());
} }
return null; return null;
} catch (ServiceException e) { } catch (ServiceException e) {
@ -610,7 +610,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
@Override @Override
public long[] getStats() throws IOException { public long[] getStats() throws IOException {
try { try {
return PBHelper.convert(rpcProxy.getFsStats(null, return PBHelperClient.convert(rpcProxy.getFsStats(null,
VOID_GET_FSSTATUS_REQUEST)); VOID_GET_FSSTATUS_REQUEST));
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -622,9 +622,9 @@ public class ClientNamenodeProtocolTranslatorPB implements
throws IOException { throws IOException {
GetDatanodeReportRequestProto req = GetDatanodeReportRequestProto GetDatanodeReportRequestProto req = GetDatanodeReportRequestProto
.newBuilder() .newBuilder()
.setType(PBHelper.convert(type)).build(); .setType(PBHelperClient.convert(type)).build();
try { try {
return PBHelper.convert( return PBHelperClient.convert(
rpcProxy.getDatanodeReport(null, req).getDiList()); rpcProxy.getDatanodeReport(null, req).getDiList());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -636,9 +636,9 @@ public class ClientNamenodeProtocolTranslatorPB implements
throws IOException { throws IOException {
final GetDatanodeStorageReportRequestProto req final GetDatanodeStorageReportRequestProto req
= GetDatanodeStorageReportRequestProto.newBuilder() = GetDatanodeStorageReportRequestProto.newBuilder()
.setType(PBHelper.convert(type)).build(); .setType(PBHelperClient.convert(type)).build();
try { try {
return PBHelper.convertDatanodeStorageReports( return PBHelperClient.convertDatanodeStorageReports(
rpcProxy.getDatanodeStorageReport(null, req).getDatanodeStorageReportsList()); rpcProxy.getDatanodeStorageReport(null, req).getDatanodeStorageReportsList());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -662,7 +662,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
@Override @Override
public boolean setSafeMode(SafeModeAction action, boolean isChecked) throws IOException { public boolean setSafeMode(SafeModeAction action, boolean isChecked) throws IOException {
SetSafeModeRequestProto req = SetSafeModeRequestProto.newBuilder() SetSafeModeRequestProto req = SetSafeModeRequestProto.newBuilder()
.setAction(PBHelper.convert(action)).setChecked(isChecked).build(); .setAction(PBHelperClient.convert(action)).setChecked(isChecked).build();
try { try {
return rpcProxy.setSafeMode(null, req).getResult(); return rpcProxy.setSafeMode(null, req).getResult();
} catch (ServiceException e) { } catch (ServiceException e) {
@ -724,11 +724,11 @@ public class ClientNamenodeProtocolTranslatorPB implements
@Override @Override
public RollingUpgradeInfo rollingUpgrade(RollingUpgradeAction action) throws IOException { public RollingUpgradeInfo rollingUpgrade(RollingUpgradeAction action) throws IOException {
final RollingUpgradeRequestProto r = RollingUpgradeRequestProto.newBuilder() final RollingUpgradeRequestProto r = RollingUpgradeRequestProto.newBuilder()
.setAction(PBHelper.convert(action)).build(); .setAction(PBHelperClient.convert(action)).build();
try { try {
final RollingUpgradeResponseProto proto = rpcProxy.rollingUpgrade(null, r); final RollingUpgradeResponseProto proto = rpcProxy.rollingUpgrade(null, r);
if (proto.hasRollingUpgradeInfo()) { if (proto.hasRollingUpgradeInfo()) {
return PBHelper.convert(proto.getRollingUpgradeInfo()); return PBHelperClient.convert(proto.getRollingUpgradeInfo());
} }
return null; return null;
} catch (ServiceException e) { } catch (ServiceException e) {
@ -744,7 +744,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
if (cookie != null) if (cookie != null)
req.setCookie(cookie); req.setCookie(cookie);
try { try {
return PBHelper.convert( return PBHelperClient.convert(
rpcProxy.listCorruptFileBlocks(null, req.build()).getCorrupt()); rpcProxy.listCorruptFileBlocks(null, req.build()).getCorrupt());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -770,7 +770,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
.setSrc(src).build(); .setSrc(src).build();
try { try {
GetFileInfoResponseProto res = rpcProxy.getFileInfo(null, req); GetFileInfoResponseProto res = rpcProxy.getFileInfo(null, req);
return res.hasFs() ? PBHelper.convert(res.getFs()) : null; return res.hasFs() ? PBHelperClient.convert(res.getFs()) : null;
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -784,7 +784,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
try { try {
GetFileLinkInfoResponseProto result = rpcProxy.getFileLinkInfo(null, req); GetFileLinkInfoResponseProto result = rpcProxy.getFileLinkInfo(null, req);
return result.hasFs() ? return result.hasFs() ?
PBHelper.convert(rpcProxy.getFileLinkInfo(null, req).getFs()) : null; PBHelperClient.convert(rpcProxy.getFileLinkInfo(null, req).getFs()) : null;
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -799,7 +799,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
.setPath(path) .setPath(path)
.build(); .build();
try { try {
return PBHelper.convert(rpcProxy.getContentSummary(null, req) return PBHelperClient.convert(rpcProxy.getContentSummary(null, req)
.getSummary()); .getSummary());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -867,7 +867,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
CreateSymlinkRequestProto req = CreateSymlinkRequestProto.newBuilder() CreateSymlinkRequestProto req = CreateSymlinkRequestProto.newBuilder()
.setTarget(target) .setTarget(target)
.setLink(link) .setLink(link)
.setDirPerm(PBHelper.convert(dirPerm)) .setDirPerm(PBHelperClient.convert(dirPerm))
.setCreateParent(createParent) .setCreateParent(createParent)
.build(); .build();
try { try {
@ -899,7 +899,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
.setClientName(clientName) .setClientName(clientName)
.build(); .build();
try { try {
return PBHelper.convert( return PBHelperClient.convert(
rpcProxy.updateBlockForPipeline(null, req).getBlock()); rpcProxy.updateBlockForPipeline(null, req).getBlock());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -913,7 +913,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
.setClientName(clientName) .setClientName(clientName)
.setOldBlock(PBHelperClient.convert(oldBlock)) .setOldBlock(PBHelperClient.convert(oldBlock))
.setNewBlock(PBHelperClient.convert(newBlock)) .setNewBlock(PBHelperClient.convert(newBlock))
.addAllNewNodes(Arrays.asList(PBHelper.convert(newNodes))) .addAllNewNodes(Arrays.asList(PBHelperClient.convert(newNodes)))
.addAllStorageIDs(storageIDs == null ? null : Arrays.asList(storageIDs)) .addAllStorageIDs(storageIDs == null ? null : Arrays.asList(storageIDs))
.build(); .build();
try { try {
@ -932,7 +932,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
.build(); .build();
try { try {
GetDelegationTokenResponseProto resp = rpcProxy.getDelegationToken(null, req); GetDelegationTokenResponseProto resp = rpcProxy.getDelegationToken(null, req);
return resp.hasToken() ? PBHelper.convertDelegationToken(resp.getToken()) return resp.hasToken() ? PBHelperClient.convertDelegationToken(resp.getToken())
: null; : null;
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -991,7 +991,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
GetDataEncryptionKeyResponseProto rsp = rpcProxy.getDataEncryptionKey( GetDataEncryptionKeyResponseProto rsp = rpcProxy.getDataEncryptionKey(
null, VOID_GET_DATA_ENCRYPTIONKEY_REQUEST); null, VOID_GET_DATA_ENCRYPTIONKEY_REQUEST);
return rsp.hasDataEncryptionKey() ? return rsp.hasDataEncryptionKey() ?
PBHelper.convert(rsp.getDataEncryptionKey()) : null; PBHelperClient.convert(rsp.getDataEncryptionKey()) : null;
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -1088,7 +1088,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
.getSnapshottableDirListing(null, req); .getSnapshottableDirListing(null, req);
if (result.hasSnapshottableDirList()) { if (result.hasSnapshottableDirList()) {
return PBHelper.convert(result.getSnapshottableDirList()); return PBHelperClient.convert(result.getSnapshottableDirList());
} }
return null; return null;
} catch (ServiceException e) { } catch (ServiceException e) {
@ -1106,7 +1106,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
GetSnapshotDiffReportResponseProto result = GetSnapshotDiffReportResponseProto result =
rpcProxy.getSnapshotDiffReport(null, req); rpcProxy.getSnapshotDiffReport(null, req);
return PBHelper.convert(result.getDiffReport()); return PBHelperClient.convert(result.getDiffReport());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -1118,9 +1118,9 @@ public class ClientNamenodeProtocolTranslatorPB implements
try { try {
AddCacheDirectiveRequestProto.Builder builder = AddCacheDirectiveRequestProto.Builder builder =
AddCacheDirectiveRequestProto.newBuilder(). AddCacheDirectiveRequestProto.newBuilder().
setInfo(PBHelper.convert(directive)); setInfo(PBHelperClient.convert(directive));
if (!flags.isEmpty()) { if (!flags.isEmpty()) {
builder.setCacheFlags(PBHelper.convertCacheFlags(flags)); builder.setCacheFlags(PBHelperClient.convertCacheFlags(flags));
} }
return rpcProxy.addCacheDirective(null, builder.build()).getId(); return rpcProxy.addCacheDirective(null, builder.build()).getId();
} catch (ServiceException e) { } catch (ServiceException e) {
@ -1134,9 +1134,9 @@ public class ClientNamenodeProtocolTranslatorPB implements
try { try {
ModifyCacheDirectiveRequestProto.Builder builder = ModifyCacheDirectiveRequestProto.Builder builder =
ModifyCacheDirectiveRequestProto.newBuilder(). ModifyCacheDirectiveRequestProto.newBuilder().
setInfo(PBHelper.convert(directive)); setInfo(PBHelperClient.convert(directive));
if (!flags.isEmpty()) { if (!flags.isEmpty()) {
builder.setCacheFlags(PBHelper.convertCacheFlags(flags)); builder.setCacheFlags(PBHelperClient.convertCacheFlags(flags));
} }
rpcProxy.modifyCacheDirective(null, builder.build()); rpcProxy.modifyCacheDirective(null, builder.build());
} catch (ServiceException e) { } catch (ServiceException e) {
@ -1167,7 +1167,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
@Override @Override
public CacheDirectiveEntry get(int i) { public CacheDirectiveEntry get(int i) {
return PBHelper.convert(response.getElements(i)); return PBHelperClient.convert(response.getElements(i));
} }
@Override @Override
@ -1193,7 +1193,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
rpcProxy.listCacheDirectives(null, rpcProxy.listCacheDirectives(null,
ListCacheDirectivesRequestProto.newBuilder(). ListCacheDirectivesRequestProto.newBuilder().
setPrevId(prevId). setPrevId(prevId).
setFilter(PBHelper.convert(filter)). setFilter(PBHelperClient.convert(filter)).
build())); build()));
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -1204,7 +1204,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
public void addCachePool(CachePoolInfo info) throws IOException { public void addCachePool(CachePoolInfo info) throws IOException {
AddCachePoolRequestProto.Builder builder = AddCachePoolRequestProto.Builder builder =
AddCachePoolRequestProto.newBuilder(); AddCachePoolRequestProto.newBuilder();
builder.setInfo(PBHelper.convert(info)); builder.setInfo(PBHelperClient.convert(info));
try { try {
rpcProxy.addCachePool(null, builder.build()); rpcProxy.addCachePool(null, builder.build());
} catch (ServiceException e) { } catch (ServiceException e) {
@ -1216,7 +1216,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
public void modifyCachePool(CachePoolInfo req) throws IOException { public void modifyCachePool(CachePoolInfo req) throws IOException {
ModifyCachePoolRequestProto.Builder builder = ModifyCachePoolRequestProto.Builder builder =
ModifyCachePoolRequestProto.newBuilder(); ModifyCachePoolRequestProto.newBuilder();
builder.setInfo(PBHelper.convert(req)); builder.setInfo(PBHelperClient.convert(req));
try { try {
rpcProxy.modifyCachePool(null, builder.build()); rpcProxy.modifyCachePool(null, builder.build());
} catch (ServiceException e) { } catch (ServiceException e) {
@ -1246,7 +1246,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
@Override @Override
public CachePoolEntry get(int i) { public CachePoolEntry get(int i) {
CachePoolEntryProto elem = proto.getEntries(i); CachePoolEntryProto elem = proto.getEntries(i);
return PBHelper.convert(elem); return PBHelperClient.convert(elem);
} }
@Override @Override
@ -1278,7 +1278,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
throws IOException { throws IOException {
ModifyAclEntriesRequestProto req = ModifyAclEntriesRequestProto ModifyAclEntriesRequestProto req = ModifyAclEntriesRequestProto
.newBuilder().setSrc(src) .newBuilder().setSrc(src)
.addAllAclSpec(PBHelper.convertAclEntryProto(aclSpec)).build(); .addAllAclSpec(PBHelperClient.convertAclEntryProto(aclSpec)).build();
try { try {
rpcProxy.modifyAclEntries(null, req); rpcProxy.modifyAclEntries(null, req);
} catch (ServiceException e) { } catch (ServiceException e) {
@ -1291,7 +1291,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
throws IOException { throws IOException {
RemoveAclEntriesRequestProto req = RemoveAclEntriesRequestProto RemoveAclEntriesRequestProto req = RemoveAclEntriesRequestProto
.newBuilder().setSrc(src) .newBuilder().setSrc(src)
.addAllAclSpec(PBHelper.convertAclEntryProto(aclSpec)).build(); .addAllAclSpec(PBHelperClient.convertAclEntryProto(aclSpec)).build();
try { try {
rpcProxy.removeAclEntries(null, req); rpcProxy.removeAclEntries(null, req);
} catch (ServiceException e) { } catch (ServiceException e) {
@ -1325,7 +1325,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
public void setAcl(String src, List<AclEntry> aclSpec) throws IOException { public void setAcl(String src, List<AclEntry> aclSpec) throws IOException {
SetAclRequestProto req = SetAclRequestProto.newBuilder() SetAclRequestProto req = SetAclRequestProto.newBuilder()
.setSrc(src) .setSrc(src)
.addAllAclSpec(PBHelper.convertAclEntryProto(aclSpec)) .addAllAclSpec(PBHelperClient.convertAclEntryProto(aclSpec))
.build(); .build();
try { try {
rpcProxy.setAcl(null, req); rpcProxy.setAcl(null, req);
@ -1339,7 +1339,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
GetAclStatusRequestProto req = GetAclStatusRequestProto.newBuilder() GetAclStatusRequestProto req = GetAclStatusRequestProto.newBuilder()
.setSrc(src).build(); .setSrc(src).build();
try { try {
return PBHelper.convert(rpcProxy.getAclStatus(null, req)); return PBHelperClient.convert(rpcProxy.getAclStatus(null, req));
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -1373,7 +1373,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
final EncryptionZonesProtos.GetEZForPathResponseProto response = final EncryptionZonesProtos.GetEZForPathResponseProto response =
rpcProxy.getEZForPath(null, req); rpcProxy.getEZForPath(null, req);
if (response.hasZone()) { if (response.hasZone()) {
return PBHelper.convert(response.getZone()); return PBHelperClient.convert(response.getZone());
} else { } else {
return null; return null;
} }
@ -1395,7 +1395,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
List<EncryptionZone> elements = List<EncryptionZone> elements =
Lists.newArrayListWithCapacity(response.getZonesCount()); Lists.newArrayListWithCapacity(response.getZonesCount());
for (EncryptionZoneProto p : response.getZonesList()) { for (EncryptionZoneProto p : response.getZonesList()) {
elements.add(PBHelper.convert(p)); elements.add(PBHelperClient.convert(p));
} }
return new BatchedListEntries<EncryptionZone>(elements, return new BatchedListEntries<EncryptionZone>(elements,
response.getHasMore()); response.getHasMore());
@ -1409,8 +1409,8 @@ public class ClientNamenodeProtocolTranslatorPB implements
throws IOException { throws IOException {
SetXAttrRequestProto req = SetXAttrRequestProto.newBuilder() SetXAttrRequestProto req = SetXAttrRequestProto.newBuilder()
.setSrc(src) .setSrc(src)
.setXAttr(PBHelper.convertXAttrProto(xAttr)) .setXAttr(PBHelperClient.convertXAttrProto(xAttr))
.setFlag(PBHelper.convert(flag)) .setFlag(PBHelperClient.convert(flag))
.build(); .build();
try { try {
rpcProxy.setXAttr(null, req); rpcProxy.setXAttr(null, req);
@ -1420,16 +1420,16 @@ public class ClientNamenodeProtocolTranslatorPB implements
} }
@Override @Override
public List<XAttr> getXAttrs(String src, List<XAttr> xAttrs) public List<XAttr> getXAttrs(String src, List<XAttr> xAttrs)
throws IOException { throws IOException {
GetXAttrsRequestProto.Builder builder = GetXAttrsRequestProto.newBuilder(); GetXAttrsRequestProto.Builder builder = GetXAttrsRequestProto.newBuilder();
builder.setSrc(src); builder.setSrc(src);
if (xAttrs != null) { if (xAttrs != null) {
builder.addAllXAttrs(PBHelper.convertXAttrProto(xAttrs)); builder.addAllXAttrs(PBHelperClient.convertXAttrProto(xAttrs));
} }
GetXAttrsRequestProto req = builder.build(); GetXAttrsRequestProto req = builder.build();
try { try {
return PBHelper.convert(rpcProxy.getXAttrs(null, req)); return PBHelperClient.convert(rpcProxy.getXAttrs(null, req));
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -1442,7 +1442,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
builder.setSrc(src); builder.setSrc(src);
ListXAttrsRequestProto req = builder.build(); ListXAttrsRequestProto req = builder.build();
try { try {
return PBHelper.convert(rpcProxy.listXAttrs(null, req)); return PBHelperClient.convert(rpcProxy.listXAttrs(null, req));
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -1452,7 +1452,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
public void removeXAttr(String src, XAttr xAttr) throws IOException { public void removeXAttr(String src, XAttr xAttr) throws IOException {
RemoveXAttrRequestProto req = RemoveXAttrRequestProto RemoveXAttrRequestProto req = RemoveXAttrRequestProto
.newBuilder().setSrc(src) .newBuilder().setSrc(src)
.setXAttr(PBHelper.convertXAttrProto(xAttr)).build(); .setXAttr(PBHelperClient.convertXAttrProto(xAttr)).build();
try { try {
rpcProxy.removeXAttr(null, req); rpcProxy.removeXAttr(null, req);
} catch (ServiceException e) { } catch (ServiceException e) {
@ -1463,7 +1463,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
@Override @Override
public void checkAccess(String path, FsAction mode) throws IOException { public void checkAccess(String path, FsAction mode) throws IOException {
CheckAccessRequestProto req = CheckAccessRequestProto.newBuilder() CheckAccessRequestProto req = CheckAccessRequestProto.newBuilder()
.setPath(path).setMode(PBHelper.convert(mode)).build(); .setPath(path).setMode(PBHelperClient.convert(mode)).build();
try { try {
rpcProxy.checkAccess(null, req); rpcProxy.checkAccess(null, req);
} catch (ServiceException e) { } catch (ServiceException e) {
@ -1488,7 +1488,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
GetStoragePolicyRequestProto request = GetStoragePolicyRequestProto GetStoragePolicyRequestProto request = GetStoragePolicyRequestProto
.newBuilder().setPath(path).build(); .newBuilder().setPath(path).build();
try { try {
return PBHelper.convert(rpcProxy.getStoragePolicy(null, request) return PBHelperClient.convert(rpcProxy.getStoragePolicy(null, request)
.getStoragePolicy()); .getStoragePolicy());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
@ -1500,7 +1500,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
try { try {
GetStoragePoliciesResponseProto response = rpcProxy GetStoragePoliciesResponseProto response = rpcProxy
.getStoragePolicies(null, VOID_GET_STORAGE_POLICIES_REQUEST); .getStoragePolicies(null, VOID_GET_STORAGE_POLICIES_REQUEST);
return PBHelper.convertStoragePolicies(response.getPoliciesList()); return PBHelperClient.convertStoragePolicies(response.getPoliciesList());
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }
@ -1521,7 +1521,7 @@ public class ClientNamenodeProtocolTranslatorPB implements
GetEditsFromTxidRequestProto req = GetEditsFromTxidRequestProto.newBuilder() GetEditsFromTxidRequestProto req = GetEditsFromTxidRequestProto.newBuilder()
.setTxid(txid).build(); .setTxid(txid).build();
try { try {
return PBHelper.convert(rpcProxy.getEditsFromTxid(null, req)); return PBHelperClient.convert(rpcProxy.getEditsFromTxid(null, req));
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }

View File

@ -139,7 +139,7 @@ public class DatanodeProtocolClientSideTranslatorPB implements
.setXmitsInProgress(xmitsInProgress).setXceiverCount(xceiverCount) .setXmitsInProgress(xmitsInProgress).setXceiverCount(xceiverCount)
.setFailedVolumes(failedVolumes) .setFailedVolumes(failedVolumes)
.setRequestFullBlockReportLease(requestFullBlockReportLease); .setRequestFullBlockReportLease(requestFullBlockReportLease);
builder.addAllReports(PBHelper.convertStorageReports(reports)); builder.addAllReports(PBHelperClient.convertStorageReports(reports));
if (cacheCapacity != 0) { if (cacheCapacity != 0) {
builder.setCacheCapacity(cacheCapacity); builder.setCacheCapacity(cacheCapacity);
} }
@ -164,7 +164,7 @@ public class DatanodeProtocolClientSideTranslatorPB implements
} }
RollingUpgradeStatus rollingUpdateStatus = null; RollingUpgradeStatus rollingUpdateStatus = null;
if (resp.hasRollingUpgradeStatus()) { if (resp.hasRollingUpgradeStatus()) {
rollingUpdateStatus = PBHelper.convert(resp.getRollingUpgradeStatus()); rollingUpdateStatus = PBHelperClient.convert(resp.getRollingUpgradeStatus());
} }
return new HeartbeatResponse(cmds, PBHelper.convert(resp.getHaStatus()), return new HeartbeatResponse(cmds, PBHelper.convert(resp.getHaStatus()),
rollingUpdateStatus, resp.getFullBlockReportLeaseId()); rollingUpdateStatus, resp.getFullBlockReportLeaseId());
@ -183,7 +183,7 @@ public class DatanodeProtocolClientSideTranslatorPB implements
for (StorageBlockReport r : reports) { for (StorageBlockReport r : reports) {
StorageBlockReportProto.Builder reportBuilder = StorageBlockReportProto StorageBlockReportProto.Builder reportBuilder = StorageBlockReportProto
.newBuilder().setStorage(PBHelper.convert(r.getStorage())); .newBuilder().setStorage(PBHelperClient.convert(r.getStorage()));
BlockListAsLongs blocks = r.getBlocks(); BlockListAsLongs blocks = r.getBlocks();
if (useBlocksBuffer) { if (useBlocksBuffer) {
reportBuilder.setNumberOfBlocks(blocks.getNumberOfBlocks()); reportBuilder.setNumberOfBlocks(blocks.getNumberOfBlocks());
@ -240,7 +240,7 @@ public class DatanodeProtocolClientSideTranslatorPB implements
StorageReceivedDeletedBlocksProto.Builder repBuilder = StorageReceivedDeletedBlocksProto.Builder repBuilder =
StorageReceivedDeletedBlocksProto.newBuilder(); StorageReceivedDeletedBlocksProto.newBuilder();
repBuilder.setStorageUuid(storageBlock.getStorage().getStorageID()); // Set for wire compatibility. repBuilder.setStorageUuid(storageBlock.getStorage().getStorageID()); // Set for wire compatibility.
repBuilder.setStorage(PBHelper.convert(storageBlock.getStorage())); repBuilder.setStorage(PBHelperClient.convert(storageBlock.getStorage()));
for (ReceivedDeletedBlockInfo rdBlock : storageBlock.getBlocks()) { for (ReceivedDeletedBlockInfo rdBlock : storageBlock.getBlocks()) {
repBuilder.addBlocks(PBHelper.convert(rdBlock)); repBuilder.addBlocks(PBHelper.convert(rdBlock));
} }
@ -281,7 +281,7 @@ public class DatanodeProtocolClientSideTranslatorPB implements
ReportBadBlocksRequestProto.Builder builder = ReportBadBlocksRequestProto ReportBadBlocksRequestProto.Builder builder = ReportBadBlocksRequestProto
.newBuilder(); .newBuilder();
for (int i = 0; i < blocks.length; i++) { for (int i = 0; i < blocks.length; i++) {
builder.addBlocks(i, PBHelper.convert(blocks[i])); builder.addBlocks(i, PBHelperClient.convert(blocks[i]));
} }
ReportBadBlocksRequestProto req = builder.build(); ReportBadBlocksRequestProto req = builder.build();
try { try {

View File

@ -105,7 +105,7 @@ public class DatanodeProtocolServerSideTranslatorPB implements
HeartbeatRequestProto request) throws ServiceException { HeartbeatRequestProto request) throws ServiceException {
HeartbeatResponse response; HeartbeatResponse response;
try { try {
final StorageReport[] report = PBHelper.convertStorageReports( final StorageReport[] report = PBHelperClient.convertStorageReports(
request.getReportsList()); request.getReportsList());
VolumeFailureSummary volumeFailureSummary = VolumeFailureSummary volumeFailureSummary =
request.hasVolumeFailureSummary() ? PBHelper.convertVolumeFailureSummary( request.hasVolumeFailureSummary() ? PBHelper.convertVolumeFailureSummary(
@ -132,7 +132,7 @@ public class DatanodeProtocolServerSideTranslatorPB implements
RollingUpgradeStatus rollingUpdateStatus = response RollingUpgradeStatus rollingUpdateStatus = response
.getRollingUpdateStatus(); .getRollingUpdateStatus();
if (rollingUpdateStatus != null) { if (rollingUpdateStatus != null) {
builder.setRollingUpgradeStatus(PBHelper builder.setRollingUpgradeStatus(PBHelperClient
.convertRollingUpgradeStatus(rollingUpdateStatus)); .convertRollingUpgradeStatus(rollingUpdateStatus));
} }
builder.setFullBlockReportLeaseId(response.getFullBlockReportLeaseId()); builder.setFullBlockReportLeaseId(response.getFullBlockReportLeaseId());
@ -157,7 +157,7 @@ public class DatanodeProtocolServerSideTranslatorPB implements
} else { } else {
blocks = BlockListAsLongs.decodeLongs(s.getBlocksList()); blocks = BlockListAsLongs.decodeLongs(s.getBlocksList());
} }
report[index++] = new StorageBlockReport(PBHelper.convert(s.getStorage()), report[index++] = new StorageBlockReport(PBHelperClient.convert(s.getStorage()),
blocks); blocks);
} }
try { try {
@ -214,7 +214,7 @@ public class DatanodeProtocolServerSideTranslatorPB implements
} }
if (sBlock.hasStorage()) { if (sBlock.hasStorage()) {
info[i] = new StorageReceivedDeletedBlocks( info[i] = new StorageReceivedDeletedBlocks(
PBHelper.convert(sBlock.getStorage()), rdBlocks); PBHelperClient.convert(sBlock.getStorage()), rdBlocks);
} else { } else {
info[i] = new StorageReceivedDeletedBlocks(sBlock.getStorageUuid(), rdBlocks); info[i] = new StorageReceivedDeletedBlocks(sBlock.getStorageUuid(), rdBlocks);
} }
@ -259,7 +259,7 @@ public class DatanodeProtocolServerSideTranslatorPB implements
List<LocatedBlockProto> lbps = request.getBlocksList(); List<LocatedBlockProto> lbps = request.getBlocksList();
LocatedBlock [] blocks = new LocatedBlock [lbps.size()]; LocatedBlock [] blocks = new LocatedBlock [lbps.size()];
for(int i=0; i<lbps.size(); i++) { for(int i=0; i<lbps.size(); i++) {
blocks[i] = PBHelper.convert(lbps.get(i)); blocks[i] = PBHelperClient.convert(lbps.get(i));
} }
try { try {
impl.reportBadBlocks(blocks); impl.reportBadBlocks(blocks);
@ -276,7 +276,7 @@ public class DatanodeProtocolServerSideTranslatorPB implements
List<DatanodeIDProto> dnprotos = request.getNewTaragetsList(); List<DatanodeIDProto> dnprotos = request.getNewTaragetsList();
DatanodeID[] dns = new DatanodeID[dnprotos.size()]; DatanodeID[] dns = new DatanodeID[dnprotos.size()];
for (int i = 0; i < dnprotos.size(); i++) { for (int i = 0; i < dnprotos.size(); i++) {
dns[i] = PBHelper.convert(dnprotos.get(i)); dns[i] = PBHelperClient.convert(dnprotos.get(i));
} }
final List<String> sidprotos = request.getNewTargetStoragesList(); final List<String> sidprotos = request.getNewTargetStoragesList();
final String[] storageIDs = sidprotos.toArray(new String[sidprotos.size()]); final String[] storageIDs = sidprotos.toArray(new String[sidprotos.size()]);

View File

@ -64,7 +64,7 @@ public class InterDatanodeProtocolServerSideTranslatorPB implements
} else { } else {
return InitReplicaRecoveryResponseProto.newBuilder() return InitReplicaRecoveryResponseProto.newBuilder()
.setReplicaFound(true) .setReplicaFound(true)
.setBlock(PBHelper.convert(r)) .setBlock(PBHelperClient.convert(r))
.setState(PBHelper.convert(r.getOriginalReplicaState())).build(); .setState(PBHelper.convert(r.getOriginalReplicaState())).build();
} }
} }

View File

@ -67,7 +67,7 @@ public class JournalProtocolTranslatorPB implements ProtocolMetaInterface,
.setEpoch(epoch) .setEpoch(epoch)
.setFirstTxnId(firstTxnId) .setFirstTxnId(firstTxnId)
.setNumTxns(numTxns) .setNumTxns(numTxns)
.setRecords(PBHelper.getByteString(records)) .setRecords(PBHelperClient.getByteString(records))
.build(); .build();
try { try {
rpcProxy.journal(NULL_CONTROLLER, req); rpcProxy.journal(NULL_CONTROLLER, req);

View File

@ -22,7 +22,6 @@ import java.io.IOException;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo; import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.VersionRequestProto; import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.VersionRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.VersionResponseProto; import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.VersionResponseProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.EndCheckpointRequestProto; import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.EndCheckpointRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.EndCheckpointResponseProto; import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.EndCheckpointResponseProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.ErrorReportRequestProto; import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.ErrorReportRequestProto;
@ -79,7 +78,7 @@ public class NamenodeProtocolServerSideTranslatorPB implements
@Override @Override
public GetBlocksResponseProto getBlocks(RpcController unused, public GetBlocksResponseProto getBlocks(RpcController unused,
GetBlocksRequestProto request) throws ServiceException { GetBlocksRequestProto request) throws ServiceException {
DatanodeInfo dnInfo = new DatanodeInfo(PBHelper.convert(request DatanodeInfo dnInfo = new DatanodeInfo(PBHelperClient.convert(request
.getDatanode())); .getDatanode()));
BlocksWithLocations blocks; BlocksWithLocations blocks;
try { try {

View File

@ -25,6 +25,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hdfs.protocolPB.JournalProtocolPB; import org.apache.hadoop.hdfs.protocolPB.JournalProtocolPB;
import org.apache.hadoop.hdfs.protocolPB.PBHelper; import org.apache.hadoop.hdfs.protocolPB.PBHelper;
import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
import org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocol; import org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocol;
import org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos; import org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos;
import org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.AcceptRecoveryRequestProto; import org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.AcceptRecoveryRequestProto;
@ -161,7 +162,7 @@ public class QJournalProtocolTranslatorPB implements ProtocolMetaInterface,
.setSegmentTxnId(segmentTxId) .setSegmentTxnId(segmentTxId)
.setFirstTxnId(firstTxnId) .setFirstTxnId(firstTxnId)
.setNumTxns(numTxns) .setNumTxns(numTxns)
.setRecords(PBHelper.getByteString(records)) .setRecords(PBHelperClient.getByteString(records))
.build(); .build();
try { try {
rpcProxy.journal(NULL_CONTROLLER, req); rpcProxy.journal(NULL_CONTROLLER, req);

View File

@ -65,7 +65,7 @@ import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
import org.apache.hadoop.hdfs.protocol.LocatedBlock; import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.CacheDirectiveInfoProto; import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.CacheDirectiveInfoProto;
import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.CachePoolInfoProto; import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.CachePoolInfoProto;
import org.apache.hadoop.hdfs.protocolPB.PBHelper; import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager; import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
import org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor; import org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor;
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor; import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
@ -1048,7 +1048,7 @@ public final class CacheManager {
Expiration expiry = info.getExpiration(); Expiration expiry = info.getExpiration();
if (expiry != null) { if (expiry != null) {
assert (!expiry.isRelative()); assert (!expiry.isRelative());
b.setExpiration(PBHelper.convert(expiry)); b.setExpiration(PBHelperClient.convert(expiry));
} }
directives.add(b.build()); directives.add(b.build());

View File

@ -36,7 +36,7 @@ import org.apache.hadoop.hdfs.XAttrHelper;
import org.apache.hadoop.hdfs.protocol.EncryptionZone; import org.apache.hadoop.hdfs.protocol.EncryptionZone;
import org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException; import org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException;
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos; import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos;
import org.apache.hadoop.hdfs.protocolPB.PBHelper; import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -305,7 +305,7 @@ public class EncryptionZoneManager {
} }
final HdfsProtos.ZoneEncryptionInfoProto proto = final HdfsProtos.ZoneEncryptionInfoProto proto =
PBHelper.convert(suite, version, keyName); PBHelperClient.convert(suite, version, keyName);
final XAttr ezXAttr = XAttrHelper final XAttr ezXAttr = XAttrHelper
.buildXAttr(CRYPTO_XATTR_ENCRYPTION_ZONE, proto.toByteArray()); .buildXAttr(CRYPTO_XATTR_ENCRYPTION_ZONE, proto.toByteArray());

View File

@ -29,7 +29,6 @@ import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.XAttrHelper; import org.apache.hadoop.hdfs.XAttrHelper;
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos; import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos;
import org.apache.hadoop.hdfs.protocolPB.PBHelper;
import org.apache.hadoop.hdfs.protocolPB.PBHelperClient; import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
import org.apache.hadoop.security.AccessControlException; import org.apache.hadoop.security.AccessControlException;
@ -284,7 +283,7 @@ class FSDirXAttrOp {
HdfsProtos.ZoneEncryptionInfoProto.parseFrom(xattr.getValue()); HdfsProtos.ZoneEncryptionInfoProto.parseFrom(xattr.getValue());
fsd.ezManager.addEncryptionZone(inode.getId(), fsd.ezManager.addEncryptionZone(inode.getId(),
PBHelperClient.convert(ezProto.getSuite()), PBHelperClient.convert(ezProto.getSuite()),
PBHelper.convert(ezProto.getCryptoProtocolVersion()), PBHelperClient.convert(ezProto.getCryptoProtocolVersion()),
ezProto.getKeyName()); ezProto.getKeyName());
} }

View File

@ -48,7 +48,6 @@ import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
import org.apache.hadoop.hdfs.protocol.QuotaExceededException; import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
import org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException; import org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException;
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos; import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos;
import org.apache.hadoop.hdfs.protocolPB.PBHelper;
import org.apache.hadoop.hdfs.protocolPB.PBHelperClient; import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager; import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
@ -1134,7 +1133,7 @@ public class FSDirectory implements Closeable {
xattr.getValue()); xattr.getValue());
ezManager.unprotectedAddEncryptionZone(inode.getId(), ezManager.unprotectedAddEncryptionZone(inode.getId(),
PBHelperClient.convert(ezProto.getSuite()), PBHelperClient.convert(ezProto.getSuite()),
PBHelper.convert(ezProto.getCryptoProtocolVersion()), PBHelperClient.convert(ezProto.getCryptoProtocolVersion()),
ezProto.getKeyName()); ezProto.getKeyName());
} catch (InvalidProtocolBufferException e) { } catch (InvalidProtocolBufferException e) {
NameNode.LOG.warn("Error parsing protocol buffer of " + NameNode.LOG.warn("Error parsing protocol buffer of " +
@ -1261,7 +1260,7 @@ public class FSDirectory implements Closeable {
throws IOException { throws IOException {
// Make the PB for the xattr // Make the PB for the xattr
final HdfsProtos.PerFileEncryptionInfoProto proto = final HdfsProtos.PerFileEncryptionInfoProto proto =
PBHelper.convertPerFileEncInfo(info); PBHelperClient.convertPerFileEncInfo(info);
final byte[] protoBytes = proto.toByteArray(); final byte[] protoBytes = proto.toByteArray();
final XAttr fileEncryptionAttr = final XAttr fileEncryptionAttr =
XAttrHelper.buildXAttr(CRYPTO_XATTR_FILE_ENCRYPTION_INFO, protoBytes); XAttrHelper.buildXAttr(CRYPTO_XATTR_FILE_ENCRYPTION_INFO, protoBytes);
@ -1327,7 +1326,7 @@ public class FSDirectory implements Closeable {
HdfsProtos.PerFileEncryptionInfoProto fileProto = HdfsProtos.PerFileEncryptionInfoProto fileProto =
HdfsProtos.PerFileEncryptionInfoProto.parseFrom( HdfsProtos.PerFileEncryptionInfoProto.parseFrom(
fileXAttr.getValue()); fileXAttr.getValue());
return PBHelper.convert(fileProto, suite, version, keyName); return PBHelperClient.convert(fileProto, suite, version, keyName);
} catch (InvalidProtocolBufferException e) { } catch (InvalidProtocolBufferException e) {
throw new IOException("Could not parse file encryption info for " + throw new IOException("Could not parse file encryption info for " +
"inode " + inode, e); "inode " + inode, e);

View File

@ -105,7 +105,7 @@ import org.apache.hadoop.hdfs.protocol.LayoutVersion;
import org.apache.hadoop.hdfs.protocol.LayoutVersion.Feature; import org.apache.hadoop.hdfs.protocol.LayoutVersion.Feature;
import org.apache.hadoop.hdfs.protocol.proto.EditLogProtos.AclEditLogProto; import org.apache.hadoop.hdfs.protocol.proto.EditLogProtos.AclEditLogProto;
import org.apache.hadoop.hdfs.protocol.proto.EditLogProtos.XAttrEditLogProto; import org.apache.hadoop.hdfs.protocol.proto.EditLogProtos.XAttrEditLogProto;
import org.apache.hadoop.hdfs.protocolPB.PBHelper; import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier; import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants; import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
import org.apache.hadoop.hdfs.util.XMLUtils; import org.apache.hadoop.hdfs.util.XMLUtils;
@ -412,7 +412,7 @@ public abstract class FSEditLogOp {
return null; return null;
} }
XAttrEditLogProto proto = XAttrEditLogProto.parseDelimitedFrom(in); XAttrEditLogProto proto = XAttrEditLogProto.parseDelimitedFrom(in);
return PBHelper.convertXAttrs(proto.getXAttrsList()); return PBHelperClient.convertXAttrs(proto.getXAttrsList());
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -556,7 +556,7 @@ public abstract class FSEditLogOp {
if (this.opCode == OP_ADD) { if (this.opCode == OP_ADD) {
AclEditLogUtil.write(aclEntries, out); AclEditLogUtil.write(aclEntries, out);
XAttrEditLogProto.Builder b = XAttrEditLogProto.newBuilder(); XAttrEditLogProto.Builder b = XAttrEditLogProto.newBuilder();
b.addAllXAttrs(PBHelper.convertXAttrProto(xAttrs)); b.addAllXAttrs(PBHelperClient.convertXAttrProto(xAttrs));
b.build().writeDelimitedTo(out); b.build().writeDelimitedTo(out);
FSImageSerialization.writeString(clientName,out); FSImageSerialization.writeString(clientName,out);
FSImageSerialization.writeString(clientMachine,out); FSImageSerialization.writeString(clientMachine,out);
@ -1633,7 +1633,7 @@ public abstract class FSEditLogOp {
permissions.write(out); permissions.write(out);
AclEditLogUtil.write(aclEntries, out); AclEditLogUtil.write(aclEntries, out);
XAttrEditLogProto.Builder b = XAttrEditLogProto.newBuilder(); XAttrEditLogProto.Builder b = XAttrEditLogProto.newBuilder();
b.addAllXAttrs(PBHelper.convertXAttrProto(xAttrs)); b.addAllXAttrs(PBHelperClient.convertXAttrProto(xAttrs));
b.build().writeDelimitedTo(out); b.build().writeDelimitedTo(out);
} }
@ -4160,7 +4160,7 @@ public abstract class FSEditLogOp {
void readFields(DataInputStream in, int logVersion) throws IOException { void readFields(DataInputStream in, int logVersion) throws IOException {
XAttrEditLogProto p = XAttrEditLogProto.parseDelimitedFrom(in); XAttrEditLogProto p = XAttrEditLogProto.parseDelimitedFrom(in);
src = p.getSrc(); src = p.getSrc();
xAttrs = PBHelper.convertXAttrs(p.getXAttrsList()); xAttrs = PBHelperClient.convertXAttrs(p.getXAttrsList());
readRpcIds(in, logVersion); readRpcIds(in, logVersion);
} }
@ -4170,7 +4170,7 @@ public abstract class FSEditLogOp {
if (src != null) { if (src != null) {
b.setSrc(src); b.setSrc(src);
} }
b.addAllXAttrs(PBHelper.convertXAttrProto(xAttrs)); b.addAllXAttrs(PBHelperClient.convertXAttrProto(xAttrs));
b.build().writeDelimitedTo(out); b.build().writeDelimitedTo(out);
// clientId and callId // clientId and callId
writeRpcIds(rpcClientId, rpcCallId, out); writeRpcIds(rpcClientId, rpcCallId, out);
@ -4213,7 +4213,7 @@ public abstract class FSEditLogOp {
void readFields(DataInputStream in, int logVersion) throws IOException { void readFields(DataInputStream in, int logVersion) throws IOException {
XAttrEditLogProto p = XAttrEditLogProto.parseDelimitedFrom(in); XAttrEditLogProto p = XAttrEditLogProto.parseDelimitedFrom(in);
src = p.getSrc(); src = p.getSrc();
xAttrs = PBHelper.convertXAttrs(p.getXAttrsList()); xAttrs = PBHelperClient.convertXAttrs(p.getXAttrsList());
readRpcIds(in, logVersion); readRpcIds(in, logVersion);
} }
@ -4223,7 +4223,7 @@ public abstract class FSEditLogOp {
if (src != null) { if (src != null) {
b.setSrc(src); b.setSrc(src);
} }
b.addAllXAttrs(PBHelper.convertXAttrProto(xAttrs)); b.addAllXAttrs(PBHelperClient.convertXAttrProto(xAttrs));
b.build().writeDelimitedTo(out); b.build().writeDelimitedTo(out);
// clientId and callId // clientId and callId
writeRpcIds(rpcClientId, rpcCallId, out); writeRpcIds(rpcClientId, rpcCallId, out);
@ -4269,7 +4269,7 @@ public abstract class FSEditLogOp {
throw new IOException("Failed to read fields from SetAclOp"); throw new IOException("Failed to read fields from SetAclOp");
} }
src = p.getSrc(); src = p.getSrc();
aclEntries = PBHelper.convertAclEntry(p.getEntriesList()); aclEntries = PBHelperClient.convertAclEntry(p.getEntriesList());
} }
@Override @Override
@ -4277,7 +4277,7 @@ public abstract class FSEditLogOp {
AclEditLogProto.Builder b = AclEditLogProto.newBuilder(); AclEditLogProto.Builder b = AclEditLogProto.newBuilder();
if (src != null) if (src != null)
b.setSrc(src); b.setSrc(src);
b.addAllEntries(PBHelper.convertAclEntryProto(aclEntries)); b.addAllEntries(PBHelperClient.convertAclEntryProto(aclEntries));
b.build().writeDelimitedTo(out); b.build().writeDelimitedTo(out);
} }

View File

@ -41,7 +41,6 @@ import org.apache.hadoop.fs.XAttr;
import org.apache.hadoop.hdfs.protocol.Block; import org.apache.hadoop.hdfs.protocol.Block;
import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.HdfsConstants;
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockProto; import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockProto;
import org.apache.hadoop.hdfs.protocolPB.PBHelper;
import org.apache.hadoop.hdfs.protocolPB.PBHelperClient; import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
@ -336,7 +335,7 @@ public final class FSImageFormatPBINode {
BlockInfo[] blocks = new BlockInfo[bp.size()]; BlockInfo[] blocks = new BlockInfo[bp.size()];
for (int i = 0, e = bp.size(); i < e; ++i) { for (int i = 0, e = bp.size(); i < e; ++i) {
blocks[i] = blocks[i] =
new BlockInfoContiguous(PBHelper.convert(bp.get(i)), replication); new BlockInfoContiguous(PBHelperClient.convert(bp.get(i)), replication);
} }
final PermissionStatus permissions = loadPermission(f.getPermission(), final PermissionStatus permissions = loadPermission(f.getPermission(),
parent.getLoaderContext().getStringTable()); parent.getLoaderContext().getStringTable());
@ -444,7 +443,7 @@ public final class FSImageFormatPBINode {
XATTR_NAMESPACE_EXT_OFFSET); XATTR_NAMESPACE_EXT_OFFSET);
xAttrCompactBuilder.setName(v); xAttrCompactBuilder.setName(v);
if (a.getValue() != null) { if (a.getValue() != null) {
xAttrCompactBuilder.setValue(PBHelper.getByteString(a.getValue())); xAttrCompactBuilder.setValue(PBHelperClient.getByteString(a.getValue()));
} }
b.addXAttrs(xAttrCompactBuilder.build()); b.addXAttrs(xAttrCompactBuilder.build());
} }
@ -633,7 +632,7 @@ public final class FSImageFormatPBINode {
if (n.getBlocks() != null) { if (n.getBlocks() != null) {
for (Block block : n.getBlocks()) { for (Block block : n.getBlocks()) {
b.addBlocks(PBHelper.convert(block)); b.addBlocks(PBHelperClient.convert(block));
} }
} }

View File

@ -41,7 +41,7 @@ import org.apache.hadoop.fs.StorageType;
import org.apache.hadoop.hdfs.protocol.Block; import org.apache.hadoop.hdfs.protocol.Block;
import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.HdfsConstants;
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockProto; import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockProto;
import org.apache.hadoop.hdfs.protocolPB.PBHelper; import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager; import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
@ -245,7 +245,7 @@ public class FSImageFormatPBSnapshot {
List<BlockProto> bpl = pbf.getBlocksList(); List<BlockProto> bpl = pbf.getBlocksList();
BlockInfo[] blocks = new BlockInfo[bpl.size()]; BlockInfo[] blocks = new BlockInfo[bpl.size()];
for(int j = 0, e = bpl.size(); j < e; ++j) { for(int j = 0, e = bpl.size(); j < e; ++j) {
Block blk = PBHelper.convert(bpl.get(j)); Block blk = PBHelperClient.convert(bpl.get(j));
BlockInfo storedBlock = bm.getStoredBlock(blk); BlockInfo storedBlock = bm.getStoredBlock(blk);
if(storedBlock == null) { if(storedBlock == null) {
storedBlock = bm.addBlockCollection( storedBlock = bm.addBlockCollection(
@ -525,7 +525,7 @@ public class FSImageFormatPBSnapshot {
.setFileSize(diff.getFileSize()); .setFileSize(diff.getFileSize());
if(diff.getBlocks() != null) { if(diff.getBlocks() != null) {
for(Block block : diff.getBlocks()) { for(Block block : diff.getBlocks()) {
fb.addBlocks(PBHelper.convert(block)); fb.addBlocks(PBHelperClient.convert(block));
} }
} }
INodeFileAttributes copy = diff.snapshotINode; INodeFileAttributes copy = diff.snapshotINode;

View File

@ -154,7 +154,7 @@ public class TestPBHelper {
public void testConvertDatanodeID() { public void testConvertDatanodeID() {
DatanodeID dn = DFSTestUtil.getLocalDatanodeID(); DatanodeID dn = DFSTestUtil.getLocalDatanodeID();
DatanodeIDProto dnProto = PBHelperClient.convert(dn); DatanodeIDProto dnProto = PBHelperClient.convert(dn);
DatanodeID dn2 = PBHelper.convert(dnProto); DatanodeID dn2 = PBHelperClient.convert(dnProto);
compare(dn, dn2); compare(dn, dn2);
} }
@ -176,8 +176,8 @@ public class TestPBHelper {
@Test @Test
public void testConvertBlock() { public void testConvertBlock() {
Block b = new Block(1, 100, 3); Block b = new Block(1, 100, 3);
BlockProto bProto = PBHelper.convert(b); BlockProto bProto = PBHelperClient.convert(b);
Block b2 = PBHelper.convert(bProto); Block b2 = PBHelperClient.convert(bProto);
assertEquals(b, b2); assertEquals(b, b2);
} }
@ -399,7 +399,7 @@ public class TestPBHelper {
"identifier".getBytes(), "password".getBytes(), new Text("kind"), "identifier".getBytes(), "password".getBytes(), new Text("kind"),
new Text("service")); new Text("service"));
TokenProto tokenProto = PBHelperClient.convert(token); TokenProto tokenProto = PBHelperClient.convert(token);
Token<BlockTokenIdentifier> token2 = PBHelper.convert(tokenProto); Token<BlockTokenIdentifier> token2 = PBHelperClient.convert(tokenProto);
compare(token, token2); compare(token, token2);
} }
@ -489,16 +489,16 @@ public class TestPBHelper {
@Test @Test
public void testConvertLocatedBlock() { public void testConvertLocatedBlock() {
LocatedBlock lb = createLocatedBlock(); LocatedBlock lb = createLocatedBlock();
LocatedBlockProto lbProto = PBHelper.convert(lb); LocatedBlockProto lbProto = PBHelperClient.convert(lb);
LocatedBlock lb2 = PBHelper.convert(lbProto); LocatedBlock lb2 = PBHelperClient.convert(lbProto);
compare(lb,lb2); compare(lb,lb2);
} }
@Test @Test
public void testConvertLocatedBlockNoStorageMedia() { public void testConvertLocatedBlockNoStorageMedia() {
LocatedBlock lb = createLocatedBlockNoStorageMedia(); LocatedBlock lb = createLocatedBlockNoStorageMedia();
LocatedBlockProto lbProto = PBHelper.convert(lb); LocatedBlockProto lbProto = PBHelperClient.convert(lb);
LocatedBlock lb2 = PBHelper.convert(lbProto); LocatedBlock lb2 = PBHelperClient.convert(lbProto);
compare(lb,lb2); compare(lb,lb2);
} }
@ -508,8 +508,8 @@ public class TestPBHelper {
for (int i=0;i<3;i++) { for (int i=0;i<3;i++) {
lbl.add(createLocatedBlock()); lbl.add(createLocatedBlock());
} }
List<LocatedBlockProto> lbpl = PBHelper.convertLocatedBlock2(lbl); List<LocatedBlockProto> lbpl = PBHelperClient.convertLocatedBlock2(lbl);
List<LocatedBlock> lbl2 = PBHelper.convertLocatedBlock(lbpl); List<LocatedBlock> lbl2 = PBHelperClient.convertLocatedBlock(lbpl);
assertEquals(lbl.size(), lbl2.size()); assertEquals(lbl.size(), lbl2.size());
for (int i=0;i<lbl.size();i++) { for (int i=0;i<lbl.size();i++) {
compare(lbl.get(i), lbl2.get(2)); compare(lbl.get(i), lbl2.get(2));
@ -522,8 +522,8 @@ public class TestPBHelper {
for (int i=0;i<3;i++) { for (int i=0;i<3;i++) {
lbl[i] = createLocatedBlock(); lbl[i] = createLocatedBlock();
} }
LocatedBlockProto [] lbpl = PBHelper.convertLocatedBlock(lbl); LocatedBlockProto [] lbpl = PBHelperClient.convertLocatedBlock(lbl);
LocatedBlock [] lbl2 = PBHelper.convertLocatedBlock(lbpl); LocatedBlock [] lbl2 = PBHelperClient.convertLocatedBlock(lbpl);
assertEquals(lbl.length, lbl2.length); assertEquals(lbl.length, lbl2.length);
for (int i=0;i<lbl.length;i++) { for (int i=0;i<lbl.length;i++) {
compare(lbl[i], lbl2[i]); compare(lbl[i], lbl2[i]);
@ -551,8 +551,8 @@ public class TestPBHelper {
DatanodeStorage dns1 = new DatanodeStorage( DatanodeStorage dns1 = new DatanodeStorage(
"id1", DatanodeStorage.State.NORMAL, StorageType.SSD); "id1", DatanodeStorage.State.NORMAL, StorageType.SSD);
DatanodeStorageProto proto = PBHelper.convert(dns1); DatanodeStorageProto proto = PBHelperClient.convert(dns1);
DatanodeStorage dns2 = PBHelper.convert(proto); DatanodeStorage dns2 = PBHelperClient.convert(proto);
compare(dns1, dns2); compare(dns1, dns2);
} }
@ -625,7 +625,7 @@ public class TestPBHelper {
.setPermission(FsAction.NONE) .setPermission(FsAction.NONE)
.build() }; .build() };
AclEntry[] actual = Lists.newArrayList( AclEntry[] actual = Lists.newArrayList(
PBHelper.convertAclEntry(PBHelper.convertAclEntryProto(Lists PBHelperClient.convertAclEntry(PBHelperClient.convertAclEntryProto(Lists
.newArrayList(e1, e2, e3)))).toArray(new AclEntry[0]); .newArrayList(e1, e2, e3)))).toArray(new AclEntry[0]);
Assert.assertArrayEquals(expected, actual); Assert.assertArrayEquals(expected, actual);
} }
@ -637,6 +637,6 @@ public class TestPBHelper {
.setType(AclEntryType.OTHER).build(); .setType(AclEntryType.OTHER).build();
AclStatus s = new AclStatus.Builder().owner("foo").group("bar").addEntry(e) AclStatus s = new AclStatus.Builder().owner("foo").group("bar").addEntry(e)
.build(); .build();
Assert.assertEquals(s, PBHelper.convert(PBHelper.convert(s))); Assert.assertEquals(s, PBHelperClient.convert(PBHelperClient.convert(s)));
} }
} }