Skip to content

Conversation

@bf8086
Copy link
Contributor

@bf8086 bf8086 commented Feb 6, 2019

Added APIs for intercepting gRPC client and server with custom data serialization/deserialization.

Also made the worker send read response asynchronously to improve throughput for single read request.

@bf8086
Copy link
Contributor Author

bf8086 commented Feb 6, 2019

@calvinjia @gpang PTAL.

@AmplabJenkins
Copy link

Merged build finished. Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Alluxio-Pull-Request-Builder/1913/
Test FAILed.

@AmplabJenkins
Copy link

Merged build finished. Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Alluxio-Pull-Request-Builder/1916/
Test PASSed.

@Override
public void beforeStart(ClientCallStreamObserver<ReqT> requestStream) {
if (mObserver instanceof ClientResponseObserver) {
((ClientResponseObserver<ReqT, RespT>) mObserver).beforeStart(requestStream);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is beforeStart called selectively?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to make sure the observer provided actually implemented the interface for beforeStart(). I can put a warning message if it is not implemented.

return mStreamingAsyncStub.readBlock(responseObserver);
public StreamObserver<ReadRequest> readBlock(
StreamObserver<ReadResponse> responseObserver) {
if (responseObserver instanceof DataMessageClientResponseObserver) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have a new interface with just getMarshaller, and just check/cast to that interface when getting the marshaller?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

private final WorkerNetAddress mAddress;

private final GrpcBlockingStream<ReadRequest, ReadResponse> mStream;
private final ReadResponseMarshaller mMarhshaller;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

public static final PropertyKey WORKER_NETWORK_ZEROCOPY_ENABLED =
new Builder(Name.WORKER_NETWORK_ZEROCOPY_ENABLED)
.setDefaultValue(true)
.setDescription("Whether zero copy is enabled on worker when processing data streams.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this for reading data from streams or writing data to streams?

Copy link
Contributor Author

@bf8086 bf8086 Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a general switch for all worker side zero-copy code path. For now only read path is implemented.

public static final PropertyKey USER_NETWORK_ZEROCOPY_ENABLED =
new Builder(Name.USER_NETWORK_ZEROCOPY_ENABLED)
.setDefaultValue(true)
.setDescription("Whether zero copy is enabled on client when processing data streams.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this for reading data from streams or writing data to streams?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a general switch for all client side zero-copy code path. For now only read path is implemented.


try {
sNettyWritableBufferConstruct = getPrivateConstructor(
"io.grpc.netty.NettyWritableBuffer", ByteBuf.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these strings be constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@AmplabJenkins
Copy link

Merged build finished. Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Alluxio-Pull-Request-Builder/1926/
Test PASSed.

@AmplabJenkins
Copy link

Merged build finished. Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Alluxio-Pull-Request-Builder/1927/
Test PASSed.

if (mObserver instanceof ClientResponseObserver) {
((ClientResponseObserver<ReqT, RespT>) mObserver).beforeStart(requestStream);
} else {
LOG.warn("observer does not implement ClientResponseObserver:beforeStart");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to print out the class for the mObserver?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 comments.

  • will this be spammy?
  • add the mObserver to the log message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not be spammy unless someone pass in the wrong observer. In most use cases the DataMessageClientResponseObserver is a wrapper of the original stream observer user implements, so user should only call method on the wrapper that the original observer actually implements.

public StreamObserver<ReadRequest> readBlock(StreamObserver<ReadResponse> responseObserver) {
return mStreamingAsyncStub.readBlock(responseObserver);
public StreamObserver<ReadRequest> readBlock(
StreamObserver<ReadResponse> responseObserver) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be on one line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformatted.

if (mObserver instanceof ClientResponseObserver) {
((ClientResponseObserver<ReqT, RespT>) mObserver).beforeStart(requestStream);
} else {
LOG.warn("observer does not implement ClientResponseObserver:beforeStart");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 comments.

  • will this be spammy?
  • add the mObserver to the log message.

*/
public abstract T combineData(DataMessage<T, DataBuffer> message);

protected abstract ByteBuf[] extractMessageBuffer(T message) throws IOException;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you javadoc these methods? I'm not sure what they are supposed to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the methods and added some java docs. Hopefully now they are easier to understand.

@AmplabJenkins
Copy link

Merged build finished. Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Alluxio-Pull-Request-Builder/1942/
Test PASSed.

@bf8086
Copy link
Contributor Author

bf8086 commented Feb 7, 2019

@calvinjia @gpang Thanks for the feedback. I updated the PR to address your comments. PTAL.

Copy link
Contributor

@gpang gpang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants