-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-23833. The relocated hadoop-thirdparty protobuf breaks HBase asyncwal #1301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0)
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
saintstack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arcane but looks like it would work. Some comments in the below. Thanks @jojochuang
...src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputSaslHelper.java
Show resolved
Hide resolved
| // Was ByteStringer; fix w/o using ByteStringer. Its in hbase-protocol | ||
| // and we want to keep that out of hbase-server. | ||
| builder.setPayload(ByteString.copyFrom(payload)); | ||
| BuilderPayloadSetter.setter(builder, payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The builder is from HDFS. It is NOT a pb. It has pbs in it?
|
|
||
| static { | ||
| builderClass = DataTransferEncryptorMessageProto.Builder.class; | ||
| byteStringClass = com.google.protobuf.ByteString.class; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ok? This presumes what pb is on the CLASSPATH? pb2.5? Should it be the shaded hbase ByteString?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or this is just a default setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it should be hbase internal shaded ByteString, not this com.google one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. i get it. This is the HDFS ByteString. The one that will be on the CP for all versions before HDFS3.3. Ok.
...src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputSaslHelper.java
Outdated
Show resolved
Hide resolved
| static void setter(DataTransferEncryptorMessageProto.Builder builder, byte[] payload) { | ||
| Object byteStringObject = null; | ||
| try { | ||
| byteStringObject = copyFromMethod.invoke(null, payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a byte array copy? If we wanted to wrap w/o copy, could we do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think that's possible. In fact, that was the case prior to HBASE-17908. Here the code simply do what was there after HBASE-17908. I can certain try do the zero copy thing too.
...src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputSaslHelper.java
Outdated
Show resolved
Hide resolved
hbase-server/src/main/java/org/apache/hadoop/hbase/io/asyncfs/ProtobufDecoder.java
Show resolved
Hide resolved
hbase-server/src/main/java/org/apache/hadoop/hbase/io/asyncfs/ProtobufDecoder.java
Outdated
Show resolved
Hide resolved
1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time.
|
Thanks @saintstack. |
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
The spotbugs error is unrelated, existing bug. |
Apache9
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try it.
|
🎊 +1 overall
This message was automatically generated. |
saintstack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets try it (Sorry, forgot about it).
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
…yncwal (apache#1301) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]>
…yncwal (apache#1301) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]>
…yncwal (apache#1301) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]>
…yncwal (apache#1301) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]> (cherry picked from commit 72727ff)
…yncwal (apache#1301) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]> (cherry picked from commit 72727ff) (cherry picked from commit ae3de38)
…yncwal (#1301) (#1534) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]> (cherry picked from commit 72727ff)
…yncwal (#1301) (#1535) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]> (cherry picked from commit 72727ff) (cherry picked from commit ae3de38)
…yncwal (apache#1301) (apache#1535) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]> (cherry picked from commit 72727ff) (cherry picked from commit ae3de38)
…yncwal (apache#1301) (apache#1535) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]> (cherry picked from commit 72727ff) (cherry picked from commit ae3de38) (cherry picked from commit b8b8e0a)
…yncwal (#1301) (#1535) (#1567) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]> (cherry picked from commit 72727ff) (cherry picked from commit ae3de38) (cherry picked from commit b8b8e0a)
…yncwal (apache#1301) (apache#1535) (apache#1567) * Use Reflection to access shaded Hadoop protobuf classes. (cherry picked from commit a321e536989083ca3620bf2c53f12c07740bf5b0) * Update to improve the code: 1. Added license. 2. Added more comments. 3. Wrap byte array instead of copy to make a ByteString. 4. Moved all reflection instantiation to static class loading time. * Use LiteralByteString to wrap byte array instead of copying it. Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: stack <[email protected]> (cherry picked from commit 72727ff) (cherry picked from commit ae3de38) (cherry picked from commit b8b8e0a) (cherry picked from commit 6a2314d) Change-Id: Id87f30e022d36acbd629364e01e952954cce4460
I've tried a few approaches. It turns out the quickest solution to this is with Java Reflection.
(1) Create a ProtobufDecoder that is inspired by io.netty.handler.codec.protobuf.ProtobufDecoder. The original ProtobufDecoder has dependency on protobuf. Use reflection to access the shaded protobuf in HDFS when applicable.
(2) Similarly, create a private class BuilderPayloadSetter that does ByteString.copyFrom() + DataTransferEncryptorMessageProto.Builder.setPayload().
Manually tested with Hadoop 3.1.2 and 3.3.0-SNAPSHOT (on top of HBASE-22103 and HBASE-23998 and set jetty.version=9.4.20)
Please let me know if this is the acceptable approach.