Skip to content

Conversation

@robertroeser
Copy link
Member

@robertroeser robertroeser commented Feb 8, 2019

Originally RSocket didn't use ByteBuf, and the existing frame classes are a legacy of that. This change finishes the framing work @nebhale started, and turns all the Frames into flyweights. It removes the Frame class completely. The frames originally required offsets and this has been replaced using ByteBuf's reader and writer indexes.

Frame length is not long part of the header flyweight. It is a separate flyweight that can be used by transports that require a length. It only needs to be applied to in the duplex connection before sending the frame.

The Payload classes remained unchanged.

Only two things are now recycled - the Payloads, and ByteBufs.

There is an API change in the RSocketFactory. The default remains unchanged but instead of taking a function that turns a ByteBuf into a Payload it now takes a specific type called a PayloadDecoder. There are constants in the interface to a zero copy implementation and a default copying implementation. There is also a method added to let the call specify a ByteBufAllocator if they want to change from ByteBufAllocator.DEFAULT

These changes - aside from RSocketFactory - are transparent.

@robertroeser robertroeser requested review from mostroverkhov, nebhale and rdegnan and removed request for nebhale February 8, 2019 22:31
robertroeser and others added 8 commits February 8, 2019 14:41
* optimize request channel to let you peak at the first item in the requestChannel

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* updated javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* updates

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* call requestChannelWith 2 arguments

Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
… PayloadDecoder

Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
robertroeser and others added 8 commits February 8, 2019 14:43
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
… PayloadDecoder

Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
return new DefaultConnectionSetupPayload(setupFrame);
}

Copy link
Member

Choose a reason for hiding this comment

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

Are we having some format war? Every PR recently seems to reformat more lines than it changes...

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 didn't run a formatter on purpose I was going to wait till after this pull request and then make the formatter required for a build to pass.

* @throws NullPointerException if {@code byteBufAllocator} or {@code delegate} are {@code null}
* @throws IllegalArgumentException if {@code maxFragmentSize} is not {@code positive}
*/
*//*
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to check in this commented code?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah - should have added to my pull request that its not quite done yet, and there's a couple things left. I wanted people to start looking at it.

Copy link
Member

Choose a reason for hiding this comment

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

@yschimke just removed one commented block (not this one though), so those will be cleaned out also - one change at a time.


final class LocalTransportTest implements TransportTest {

final class LocalTransportTest {// implements TransportTest {
Copy link
Member

Choose a reason for hiding this comment

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

Is this WIP or you want to land, if the latter can you link to a github issue?

@yschimke
Copy link
Member

yschimke commented Feb 9, 2019

Overall the change looks sensible, but I'm probably not the best to give the final shipit.

Awkward with review with the large amount of reformatted and also large commented out blocks.

restore micrometer RSocket test

Signed-off-by: Maksym Ostroverkhov <m.ostroverkhov@gmail.com>
release ByteBufs in tests

Signed-off-by: Maksym Ostroverkhov <m.ostroverkhov@gmail.com>
Copy link
Member

@nebhale nebhale left a comment

Choose a reason for hiding this comment

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

Huge improvement in consistency and readability.

@robertroeser
Copy link
Member Author

@mostroverkhov - you good with the changes? Can I merge this?

@mostroverkhov
Copy link
Member

@robertroeser There is still missing support for fragmentation, but that can be done is follow-up PR

@robertroeser robertroeser merged commit e45f9d2 into develop Feb 12, 2019
@robertroeser robertroeser deleted the feature/framing branch February 12, 2019 08:31
mostroverkhov pushed a commit to mostroverkhov/rsocket-java that referenced this pull request Feb 27, 2019
* Adds specific requestChannel(Payload, Publisher<Payload>)  (rsocket#572)

* optimize request channel to let you peak at the first item in the requestChannel

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* updated javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* updates

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* call requestChannelWith 2 arguments

Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* first pass at refactoring to idomatic ByteBuf flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixing tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixed some more tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fix frame flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* testing

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* accept ByteBufAllocator in a constructors and renames FrameDecoder to PayloadDecoder

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* first pass at refactoring to idomatic ByteBuf flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixing tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixed some more tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* testing

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fix frame flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* accept ByteBufAllocator in a constructors and renames FrameDecoder to PayloadDecoder

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* setup frame flyweight: allow null metadata

restore micrometer RSocket test

Signed-off-by: Maksym Ostroverkhov <m.ostroverkhov@gmail.com>

* apply fixes from review

release ByteBufs in tests

Signed-off-by: Maksym Ostroverkhov <m.ostroverkhov@gmail.com>
Signed-off-by: Maksym Ostroverkhov <m.ostroverkhov@gmail.com>
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.

6 participants