Skip to content

Commit

Permalink
pr review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Aug 22, 2024
1 parent 5387c34 commit d17722b
Showing 1 changed file with 14 additions and 28 deletions.
42 changes: 14 additions & 28 deletions server/src/main/java/com/hedera/block/server/BlockNodeApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package com.hedera.block.server;

import com.hedera.block.protos.BlockStreamService.Block;
import com.hedera.block.protos.BlockStreamService.BlockItem;
import com.hedera.block.protos.BlockStreamService.SubscribeStreamResponse;
import com.hedera.block.server.config.BlockNodeContext;
import com.hedera.block.server.data.ObjectEvent;
import com.hedera.block.server.health.HealthService;
Expand All @@ -42,7 +45,7 @@
@Singleton
public class BlockNodeApp {

private static final System.Logger LOGGER = System.getLogger(Server.class.getName());
private static final System.Logger LOGGER = System.getLogger(BlockNodeApp.class.getName());

Check warning on line 48 in server/src/main/java/com/hedera/block/server/BlockNodeApp.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/hedera/block/server/BlockNodeApp.java#L48

Added line #L48 was not covered by tests
private final ServiceStatus serviceStatus;
private final HealthService healthService;
private final BlockNodeContext blockNodeContext;
Expand All @@ -69,43 +72,30 @@ public BlockNodeApp(
* @throws IOException if the server cannot be started
*/
public void startServer() throws IOException {

@NonNull
final BlockWriter<com.hedera.block.protos.BlockStreamService.BlockItem> blockWriter =
final BlockWriter<BlockItem> blockWriter =
BlockAsDirWriterBuilder.newBuilder(blockNodeContext).build();
@NonNull
final StreamMediator<
com.hedera.block.protos.BlockStreamService.BlockItem,
ObjectEvent<
com.hedera.block.protos.BlockStreamService.SubscribeStreamResponse>>
streamMediator =
LiveStreamMediatorBuilder.newBuilder(
blockWriter, blockNodeContext, serviceStatus)
.build();

@NonNull
final BlockReader<com.hedera.block.protos.BlockStreamService.Block> blockReader =
final StreamMediator<BlockItem, ObjectEvent<SubscribeStreamResponse>> streamMediator =
LiveStreamMediatorBuilder.newBuilder(blockWriter, blockNodeContext, serviceStatus)
.build();

Check warning on line 79 in server/src/main/java/com/hedera/block/server/BlockNodeApp.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/hedera/block/server/BlockNodeApp.java#L75-L79

Added lines #L75 - L79 were not covered by tests

final BlockReader<Block> blockReader =
BlockAsDirReaderBuilder.newBuilder(

Check warning on line 82 in server/src/main/java/com/hedera/block/server/BlockNodeApp.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/hedera/block/server/BlockNodeApp.java#L81-L82

Added lines #L81 - L82 were not covered by tests
blockNodeContext
.configuration()
.getConfigData(PersistenceStorageConfig.class))
.build();

Check warning on line 86 in server/src/main/java/com/hedera/block/server/BlockNodeApp.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/hedera/block/server/BlockNodeApp.java#L84-L86

Added lines #L84 - L86 were not covered by tests

@NonNull
final BlockStreamService blockStreamService =
buildBlockStreamService(

Check warning on line 89 in server/src/main/java/com/hedera/block/server/BlockNodeApp.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/hedera/block/server/BlockNodeApp.java#L88-L89

Added lines #L88 - L89 were not covered by tests
streamMediator, blockReader, serviceStatus, blockNodeContext);

@NonNull
final GrpcRouting.Builder grpcRouting = GrpcRouting.builder().service(blockStreamService);

Check warning on line 92 in server/src/main/java/com/hedera/block/server/BlockNodeApp.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/hedera/block/server/BlockNodeApp.java#L92

Added line #L92 was not covered by tests

@NonNull
final HttpRouting.Builder httpRouting =
HttpRouting.builder().register(healthService.getHealthRootPath(), healthService);

Check warning on line 95 in server/src/main/java/com/hedera/block/server/BlockNodeApp.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/hedera/block/server/BlockNodeApp.java#L95

Added line #L95 was not covered by tests

// Build the web server
// TODO: make port server a configurable value.
@NonNull
final WebServer webServer =
WebServer.builder()
.port(8080)
Expand All @@ -121,20 +111,16 @@ public void startServer() throws IOException {

// Log the server status
LOGGER.log(

Check warning on line 113 in server/src/main/java/com/hedera/block/server/BlockNodeApp.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/hedera/block/server/BlockNodeApp.java#L113

Added line #L113 was not covered by tests
System.Logger.Level.INFO, "Block Node Server started at port: " + webServer.port());
System.Logger.Level.INFO,
String.format("Block Node Server started at port: %d", webServer.port()));
}

Check warning on line 116 in server/src/main/java/com/hedera/block/server/BlockNodeApp.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/hedera/block/server/BlockNodeApp.java#L115-L116

Added lines #L115 - L116 were not covered by tests

@NonNull
private static BlockStreamService buildBlockStreamService(
@NonNull
final StreamMediator<
com.hedera.block.protos.BlockStreamService.BlockItem,
ObjectEvent<
com.hedera.block.protos.BlockStreamService
.SubscribeStreamResponse>>
final StreamMediator<BlockItem, ObjectEvent<SubscribeStreamResponse>>
streamMediator,
@NonNull
final BlockReader<com.hedera.block.protos.BlockStreamService.Block> blockReader,
@NonNull final BlockReader<Block> blockReader,
@NonNull final ServiceStatus serviceStatus,
@NonNull final BlockNodeContext blockNodeContext) {

Expand Down

0 comments on commit d17722b

Please sign in to comment.