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

Live Stream processing support #23

Merged
merged 34 commits into from
Jun 28, 2024

Conversation

mattp-swirldslabs
Copy link
Contributor

@mattp-swirldslabs mattp-swirldslabs commented Jun 14, 2024

Description:

Fixes #16
Fixes #17
Fixes #18
Fixes #21

First draft of #27

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@mattp-swirldslabs mattp-swirldslabs self-assigned this Jun 14, 2024
@mattp-swirldslabs mattp-swirldslabs force-pushed the peterson-initial-stream-support branch 2 times, most recently from 1f19410 to 1e9dbfb Compare June 20, 2024 21:43
- added license headers to java files
- added bidirectional gRPC live streaming blocks implementation
  with 1 producer and N consumers

Signed-off-by: Matt Peterson <[email protected]>
@mattp-swirldslabs mattp-swirldslabs force-pushed the peterson-initial-stream-support branch from 1e9dbfb to 0608e65 Compare June 25, 2024 16:18
@mattp-swirldslabs mattp-swirldslabs marked this pull request as ready for review June 25, 2024 16:25
@mattp-swirldslabs mattp-swirldslabs requested review from a team as code owners June 25, 2024 16:25
@mattp-swirldslabs mattp-swirldslabs changed the title Stream processing support Live Stream processing support Jun 25, 2024
Copy link
Member

@rbair23 rbair23 left a comment

Choose a reason for hiding this comment

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

Great start, happy to see the PR! Another thing I'm missing is some kind of design documentation to give some orientation around what the different components are.

.gitignore Outdated Show resolved Hide resolved
gradle/modules.properties Outdated Show resolved Hide resolved
protos/src/main/protobuf/blockstream.proto Outdated Show resolved Hide resolved
server/src/main/java/com/hedera/block/server/Server.java Outdated Show resolved Hide resolved
server/src/main/resources/application.yaml Outdated Show resolved Hide resolved
@rbair23
Copy link
Member

rbair23 commented Jun 25, 2024

block-node-architecture

Is this the basis for the design in this PR?

Copy link
Member

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

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

A few suggestions and a question or two.

…re line to prevent that from being added

Signed-off-by: Matt Peterson <[email protected]>
Signed-off-by: Matt Peterson <[email protected]>
Signed-off-by: Matt Peterson <[email protected]>
@mattp-swirldslabs
Copy link
Contributor Author

mattp-swirldslabs commented Jun 27, 2024

Great start, happy to see the PR! Another thing I'm missing is some kind of design documentation to give some orientation around what the different components are.

Hey @rbair23, given the expected refactoring of this approach, do you mind if I submit the design doc with the PR for that effort?

rbair23
rbair23 previously approved these changes Jun 28, 2024
Signed-off-by: Matt Peterson <[email protected]>
AlfredoG87
AlfredoG87 previously approved these changes Jun 28, 2024
Copy link
Contributor

@AlfredoG87 AlfredoG87 left a comment

Choose a reason for hiding this comment

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

LGTM, only a few nits...

server/build.gradle.kts Outdated Show resolved Hide resolved
Signed-off-by: Matt Peterson <[email protected]>
Copy link
Contributor

@AlfredoG87 AlfredoG87 left a comment

Choose a reason for hiding this comment

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

LGTM

@mattp-swirldslabs mattp-swirldslabs merged commit 8e98b5b into main Jun 28, 2024
2 checks passed
@mattp-swirldslabs mattp-swirldslabs deleted the peterson-initial-stream-support branch June 28, 2024 21:58
Copy link
Contributor

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

Nice work.
Some considerations for future PRs and backlog tickets


static void grpcEcho(EchoServiceGrpcProto.EchoRequest request, StreamObserver<EchoServiceGrpcProto.EchoResponse> responseObserver) {}
// TODO: Make timeoutThresholdMillis configurable
Copy link
Contributor

Choose a reason for hiding this comment

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

Please turn this into a ticket on the backlog. Thanks

/**
* Constants used in the BlockNode service.
*/
public final class Constants {
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: Would ServiceContracts be more appropriate.
I feel like this is one of those files that will get overloaded with many values over time


static void grpcEcho(EchoServiceGrpcProto.EchoRequest request, StreamObserver<EchoServiceGrpcProto.EchoResponse> responseObserver) {}
// TODO: Make timeoutThresholdMillis configurable
final BlockStreamService blockStreamService = new BlockStreamService(1500,
Copy link
Contributor

Choose a reason for hiding this comment

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

1500 should be a configureable value


// Start the web server
WebServer.builder()
.port(8080)
Copy link
Contributor

Choose a reason for hiding this comment

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

Expose as a configureable value

this.mediator = mediator;
this.responseStreamObserver = responseStreamObserver;

this.producerLivenessMillis = producerLivenessClock.millis();
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: This is the part you noted helidon doesn't handle itself huh so we need to implement our own custom solution to determine timeouts. Sigh.

We should open an issue on helidon for this.
if we're luck it might get resolved and we can remove this logic in the future

*/
@Override
public void unsubscribe(final LiveStreamObserver<BlockStreamServiceGrpcProto.Block, BlockStreamServiceGrpcProto.BlockResponse> liveStreamObserver) {
if (subscribers.remove(liveStreamObserver)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the removal fails is there some backup step we should take?
Does this hold up a slot that is unclaimable?
Should we at least warn or something?

}

// Persist the block
blockPersistenceHandler.persist(block);
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: Should we consider splitting out persistence into it's own StreamMediator or something appropriate?
I don't like the idea that the block doesn't get persisted if there are any issues streaming to subscribers.
Even if we don't pull it out we should persist first.

private String resolvePath(final Long id) {

String fileName = id + BLOCK_FILE_EXTENSION;
Path fullPath = blockNodeRootPath.resolve(fileName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Later item, we'll wanna explore a directory structure to avoid having one flat dir with all files.
Maybe some multiple to help map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants