Skip to content
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

core,netty: split stream state on client-side; AbstractStream2 #2140

Merged
merged 1 commit into from
Oct 3, 2016

Conversation

ejona86
Copy link
Member

@ejona86 ejona86 commented Aug 8, 2016

OkHttp will need to be migrated in a future commit.

This is a continuation of what already was done for server-side (#1656). Although
AbstractClientStream2 looks like new code, it is a reorganization of existing code
(although heavily reworked).

* Requests up to the given number of messages from the call to be delivered. This should end up
* triggering {@link TransportState#requestMessagesFromDeframer(int)} on the transport thread.
*/
void request(int numMessages);
Copy link
Member

Choose a reason for hiding this comment

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

nit: seems a bit strange to call request on something called a Sink

Copy link
Member

Choose a reason for hiding this comment

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

The other class is called TransportState. Perhaps a better name for this interface would be ApplicationState?

Copy link
Member Author

Choose a reason for hiding this comment

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

Implementations of this interface don't generally hold interesting state. The application state is held by Abstract{Client,}Stream2.

The reason for this interface is to simplify the naming issues we were having and make it more obvious what calls what.

Copy link
Member

Choose a reason for hiding this comment

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

So then doesn't the same comment apply to TransportState? Perhaps both should be renamed to be more consistent?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really follow. Rename Abstract{Client,}Stream2 to ApplicationState? Rename TransportState to... ???Sink? Rename both? There's three classes/interfaces involved and I don't understand what pair would gain what advantage.

I don't see the lack of consistency here, because no class is a true inverse of another. I can agree that TransportState is a bit of a weak name, but it gets the point across pretty well and I'm not aware of a better name.

At some point we could introduce Sinks to TransportState. I didn't because it seemed to add complexity without actually simplifying anything, because the various methods are pretty intertwined (especially w.r.t. error handling, since the transport has to be notified).

Copy link
Member

Choose a reason for hiding this comment

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

No, I'm not suggesting that you rename the stream, itself. I'm suggesting that Sink/TransportState are two views of the stream, each performs ~half the work of the stream, and that they should have consistent names to make this more obvious. Names like ApplicationView and TransportView would make this clear in my mind.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm suggesting that Sink/TransportState are two views of the stream

But... it's not. Sink holds no state. Sink is only to make it obvious how the abstract class interacts with the subclass, and that those method have no need to interact with the rest of the stream state.

Names like ApplicationView and TransportView would make this clear in my mind.

I can't see any way I would use "View". View would seem to imply that the state is shared. That's exactly the opposite of what I want to portray.

If I called something ApplicationState it would be AbstractClientStream2. But that seems a much poorer name than its current name (even assuming that it was tweaked as necessary to ClientStreamApplicationState).

@buchgr
Copy link
Collaborator

buchgr commented Sep 9, 2016

LGTM. I like your tests :).

@ejona86
Copy link
Member Author

ejona86 commented Sep 9, 2016

Would anyone like more time to review?

I expect there is still the variable name discussion that Nathan brought up. Is there anything else outstanding?

I like your tests :).

... what about them?

@buchgr
Copy link
Collaborator

buchgr commented Sep 9, 2016

... what about them?

don't be scared :). I think there is an elegance to AbstractStream2Test.

@carl-mastrangelo
Copy link
Contributor

I will

@carl-mastrangelo
Copy link
Contributor

Derp, that button is too close.

super(maxMessageSize);
}

protected abstract void http2ProcessingFailed(Status status, Metadata trailers);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a javadoc to abstract methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@ejona86
Copy link
Member Author

ejona86 commented Sep 9, 2016

@carl-mastrangelo, okay, sounds good, at your leisure.

* @param frame the received data frame
* @param endOfStream {@code true} if there will be no more data received for this stream
*/
protected void transportDataReceived(ReadableBuffer frame, boolean endOfStream) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this too?

@buchgr
Copy link
Collaborator

buchgr commented Sep 23, 2016

Is this PR ready for merge (once rebased), or any discussion points outstanding?

@ejona86
Copy link
Member Author

ejona86 commented Sep 26, 2016

It's waiting for @carl-mastrangelo to finish review. The past couple weeks have been very busy for me, so I also haven't been pushing hard.

@carl-mastrangelo
Copy link
Contributor

I'll get to it by eod


@Override
public Integer parseAsciiString(String serialized) {
return Integer.parseInt(serialized.split(" ", 2)[0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

make sure this merges properly with upstream. I can't remember if I converted this to a trusted marshaller

@carl-mastrangelo
Copy link
Contributor

@ejona86 LGTM. Please take care that the rebase goes successfully, there are a number of places that are likely going to conflict.

@ejona86
Copy link
Member Author

ejona86 commented Oct 1, 2016

@carl-mastrangelo, PTAL. The merge conflicts you can't really tell, since they are all together with everything else. But they were more mundate like imports or changes that happened on adjacent lines. The changes you pointed out didn't conflict at all, since the similarity of the copied files isn't high enough for git to notice the copy. So I had to just re-apply them manually.

I would have squashed in the JavaDoc commit, but it appears I never pushed it out for others to see, so here it is now.

@carl-mastrangelo
Copy link
Contributor

@ejona86 Still LGTM

OkHttp will need to be migrated in a future commit.
@ejona86 ejona86 merged commit cad7124 into grpc:master Oct 3, 2016
@ejona86 ejona86 deleted the split-abstractclientstream branch October 3, 2016 18:30
@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants