Skip to content

Commit f8fc1b8

Browse files
committed
HADOOP-16621. [pb-upgrade] Remove Protobuf classes from signatures of Public APIs. Fixed Review comments
1 parent e5db427 commit f8fc1b8

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufHelper.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import org.apache.hadoop.classification.InterfaceAudience;
2424
import org.apache.hadoop.io.Text;
25-
import org.apache.hadoop.security.proto.SecurityProtos;
25+
import org.apache.hadoop.security.proto.SecurityProtos.TokenProto;
2626
import org.apache.hadoop.security.token.Token;
2727
import org.apache.hadoop.security.token.TokenIdentifier;
2828

@@ -62,8 +62,8 @@ public static IOException getRemoteException(ServiceException se) {
6262
* This map should not be accessed directly. Used the getFixedByteString
6363
* methods instead.
6464
*/
65-
private static ConcurrentHashMap<Object, ByteString> fixedByteStringCache =
66-
new ConcurrentHashMap<>();
65+
private final static ConcurrentHashMap<Object, ByteString>
66+
fixedByteStringCache = new ConcurrentHashMap<>();
6767

6868
/**
6969
* Get the ByteString for frequently used fixed and small set strings.
@@ -98,17 +98,17 @@ public static ByteString getByteString(byte[] bytes) {
9898
return (bytes.length == 0) ? ByteString.EMPTY : ByteString.copyFrom(bytes);
9999
}
100100

101-
public static Token<? extends TokenIdentifier> convert(
102-
SecurityProtos.TokenProto tokenProto) {
101+
public static Token<? extends TokenIdentifier> tokenFromProto(
102+
TokenProto tokenProto) {
103103
Token<? extends TokenIdentifier> token = new Token<>(
104104
tokenProto.getIdentifier().toByteArray(),
105105
tokenProto.getPassword().toByteArray(), new Text(tokenProto.getKind()),
106106
new Text(tokenProto.getService()));
107107
return token;
108108
}
109109

110-
public static SecurityProtos.TokenProto convert(Token<?> tok) {
111-
SecurityProtos.TokenProto.Builder builder = SecurityProtos.TokenProto.newBuilder().
110+
public static TokenProto protoFromToken(Token<?> tok) {
111+
TokenProto.Builder builder = TokenProto.newBuilder().
112112
setIdentifier(getByteString(tok.getIdentifier())).
113113
setPassword(getByteString(tok.getPassword())).
114114
setKindBytes(getFixedByteString(tok.getKind())).

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/Credentials.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ void writeProto(DataOutput out) throws IOException {
369369
CredentialsKVProto.Builder kv = CredentialsKVProto.newBuilder().
370370
setAliasBytes(ByteString.copyFrom(
371371
e.getKey().getBytes(), 0, e.getKey().getLength())).
372-
setToken(ProtobufHelper.convert(e.getValue()));
372+
setToken(ProtobufHelper.protoFromToken(e.getValue()));
373373
storage.addTokens(kv.build());
374374
}
375375

@@ -391,7 +391,7 @@ void readProto(DataInput in) throws IOException {
391391
CredentialsProto storage = CredentialsProto.parseDelimitedFrom((DataInputStream)in);
392392
for (CredentialsKVProto kv : storage.getTokensList()) {
393393
addToken(new Text(kv.getAliasBytes().toByteArray()),
394-
ProtobufHelper.convert(kv.getToken()));
394+
ProtobufHelper.tokenFromProto(kv.getToken()));
395395
}
396396
for (CredentialsKVProto kv : storage.getSecretsList()) {
397397
addSecretKey(new Text(kv.getAliasBytes().toByteArray()),

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public static ExtendedBlockProto convert(final ExtendedBlock b) {
324324
}
325325

326326
public static TokenProto convert(Token<?> tok) {
327-
return ProtobufHelper.convert(tok);
327+
return ProtobufHelper.protoFromToken(tok);
328328
}
329329

330330
public static ShortCircuitShmIdProto convert(ShmId shmId) {
@@ -802,7 +802,8 @@ public static StorageType[] convertStorageTypes(
802802

803803
public static Token<BlockTokenIdentifier> convert(
804804
TokenProto blockToken) {
805-
return (Token<BlockTokenIdentifier>) ProtobufHelper.convert(blockToken);
805+
return (Token<BlockTokenIdentifier>) ProtobufHelper
806+
.tokenFromProto(blockToken);
806807
}
807808

808809
// DatanodeId

0 commit comments

Comments
 (0)