Skip to content

Commit

Permalink
Conflict resolution after rebase
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Aug 23, 2024
1 parent ad160ec commit 08f8150
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ jvmDependencyConflicts.patch {
module("io.grpc:grpc-stub") { annotationLibraries.forEach { removeDependency(it) } }
module("io.grpc:grpc-testing") { annotationLibraries.forEach { removeDependency(it) } }
module("io.grpc:grpc-util") { annotationLibraries.forEach { removeDependency(it) } }
module("com.google.dagger:dagger-compiler") {
annotationLibraries.forEach { removeDependency(it) }
}
module("com.google.dagger:dagger-producers") {
annotationLibraries.forEach { removeDependency(it) }
}
module("com.google.dagger:dagger-spi") { annotationLibraries.forEach { removeDependency(it) } }
module("com.google.guava:guava") {
(annotationLibraries -
"com.google.code.findbugs:jsr305" -
Expand All @@ -63,6 +70,9 @@ jvmDependencyConflicts.patch {
removeDependency("io.prometheus:simpleclient_tracer_otel")
removeDependency("io.prometheus:simpleclient_tracer_otel_agent")
}
module("org.jetbrains.kotlin:kotlin-stdlib") {
removeDependency("org.jetbrains.kotlin:kotlin-stdlib-common")
}
module("junit:junit") { removeDependency("org.hamcrest:hamcrest-core") }
module("org.hyperledger.besu:secp256k1") { addApiDependency("net.java.dev.jna:jna") }
}
Expand Down Expand Up @@ -110,7 +120,7 @@ extraJavaModuleInfo {
}
module("com.google.guava:failureaccess", "com.google.common.util.concurrent.internal")
module("com.google.api.grpc:proto-google-common-protos", "com.google.api.grpc.common")

module("com.google.dagger:dagger", "dagger")
module("io.perfmark:perfmark-api", "io.perfmark")
module("javax.inject:javax.inject", "javax.inject")

Expand All @@ -121,6 +131,7 @@ extraJavaModuleInfo {

module("org.checkerframework:checker-qual", "org.checkerframework.checker.qual")
module("net.i2p.crypto:eddsa", "net.i2p.crypto.eddsa")
module("org.jetbrains:annotations", "org.jetbrains.annotations")
module("org.antlr:antlr4-runtime", "org.antlr.antlr4.runtime")

// needed for metrics and logging, but also several platform classes
Expand All @@ -143,9 +154,24 @@ extraJavaModuleInfo {
module("com.google.auto.service:auto-service-annotations", "com.google.auto.service")
module("com.google.auto.service:auto-service", "com.google.auto.service.processor")
module("com.google.auto:auto-common", "com.google.auto.common")
module("com.google.dagger:dagger-compiler", "dagger.compiler")
module("com.google.dagger:dagger-producers", "dagger.producers")
module("com.google.dagger:dagger-spi", "dagger.spi")
module(
"com.google.devtools.ksp:symbol-processing-api",
"com.google.devtools.ksp.symbolprocessingapi"
)
module("com.google.errorprone:javac-shaded", "com.google.errorprone.javac.shaded")
module("com.google.googlejavaformat:google-java-format", "com.google.googlejavaformat")
module("net.ltgt.gradle.incap:incap", "net.ltgt.gradle.incap")
module("org.jetbrains.kotlinx:kotlinx-metadata-jvm", "kotlinx.metadata.jvm")

// Test clients only
module("com.google.protobuf:protobuf-java-util", "com.google.protobuf.util")
module("com.squareup:javapoet", "com.squareup.javapoet") {
exportAllPackages()
requires("java.compiler")
}
module("junit:junit", "junit")
module("org.hamcrest:hamcrest", "org.hamcrest")
module("org.json:json", "org.json")
Expand Down
23 changes: 11 additions & 12 deletions server/src/main/java/com/hedera/block/server/BlockNodeApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +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 static java.lang.System.Logger;
import static java.lang.System.Logger.Level.INFO;

import com.hedera.block.server.config.BlockNodeContext;
import com.hedera.block.server.data.ObjectEvent;
import com.hedera.block.server.health.HealthService;
Expand All @@ -29,14 +29,14 @@
import com.hedera.block.server.persistence.storage.read.BlockReader;
import com.hedera.block.server.persistence.storage.write.BlockAsDirWriterBuilder;
import com.hedera.block.server.persistence.storage.write.BlockWriter;
import com.hedera.block.server.producer.ItemAckBuilder;
import com.hedera.hapi.block.SubscribeStreamResponse;
import com.hedera.hapi.block.stream.Block;
import com.hedera.hapi.block.stream.BlockItem;
import edu.umd.cs.findbugs.annotations.NonNull;
import io.helidon.webserver.WebServer;
import io.helidon.webserver.grpc.GrpcRouting;
import io.helidon.webserver.http.HttpRouting;
import java.io.IOException;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import javax.inject.Inject;
import javax.inject.Singleton;

Expand All @@ -48,6 +48,7 @@
public class BlockNodeApp {

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

Check warning on line 50 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#L50

Added line #L50 was not covered by tests

private final ServiceStatus serviceStatus;
private final HealthService healthService;
private final BlockNodeContext blockNodeContext;
Expand All @@ -74,7 +75,8 @@ public BlockNodeApp(
*
* @throws IOException if the server cannot be started
*/
public void startServer() throws IOException {
public void start() throws IOException {

final BlockWriter<BlockItem> blockWriter =
BlockAsDirWriterBuilder.newBuilder(blockNodeContext).build();
final StreamMediator<BlockItem, ObjectEvent<SubscribeStreamResponse>> streamMediator =
Expand Down Expand Up @@ -113,9 +115,7 @@ public void startServer() throws IOException {
webServer.start();

Check warning on line 115 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

Added line #L115 was not covered by tests

// Log the server status
LOGGER.log(
Level.INFO,
String.format("Block Node Server started at port: %d", webServer.port()));
LOGGER.log(INFO, String.format("Block Node Server started at port: %d", webServer.port()));
}

Check warning on line 119 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#L118-L119

Added lines #L118 - L119 were not covered by tests

@NonNull
Expand All @@ -127,7 +127,6 @@ private static BlockStreamService buildBlockStreamService(
@NonNull final ServiceStatus serviceStatus,
@NonNull final BlockNodeContext blockNodeContext) {

return new BlockStreamService(
new ItemAckBuilder(), streamMediator, blockReader, serviceStatus, blockNodeContext);
return new BlockStreamService(streamMediator, blockReader, serviceStatus, blockNodeContext);

Check warning on line 130 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#L130

Added line #L130 was not covered by tests
}
}
93 changes: 6 additions & 87 deletions server/src/main/java/com/hedera/block/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,6 @@
import static java.lang.System.Logger;
import static java.lang.System.Logger.Level.INFO;

import com.hedera.block.server.config.BlockNodeContext;
import com.hedera.block.server.config.BlockNodeContextFactory;
import com.hedera.block.server.data.ObjectEvent;
import com.hedera.block.server.health.HealthService;
import com.hedera.block.server.health.HealthServiceImpl;
import com.hedera.block.server.mediator.LiveStreamMediatorBuilder;
import com.hedera.block.server.mediator.StreamMediator;
import com.hedera.block.server.persistence.storage.PersistenceStorageConfig;
import com.hedera.block.server.persistence.storage.read.BlockAsDirReaderBuilder;
import com.hedera.block.server.persistence.storage.read.BlockReader;
import com.hedera.block.server.persistence.storage.write.BlockAsDirWriterBuilder;
import com.hedera.block.server.persistence.storage.write.BlockWriter;
import com.hedera.hapi.block.SubscribeStreamResponse;
import com.hedera.hapi.block.stream.Block;
import com.hedera.hapi.block.stream.BlockItem;
import edu.umd.cs.findbugs.annotations.NonNull;
import io.helidon.webserver.WebServer;
import io.helidon.webserver.grpc.GrpcRouting;
import io.helidon.webserver.http.HttpRouting;
import java.io.IOException;

/** Main class for the block node server */
Expand All @@ -51,75 +32,13 @@ private Server() {}
* Main entrypoint for the block node server
*
* @param args Command line arguments. Not used at present.
* @throws IOException if there is an error starting the server
*/
public static void main(final String[] args) {

public static void main(final String[] args) throws IOException {
LOGGER.log(INFO, "Starting BlockNode Server");

try {
// init context, metrics, and configuration.
final BlockNodeContext blockNodeContext = BlockNodeContextFactory.create();
final ServiceStatus serviceStatus = new ServiceStatusImpl();

final BlockWriter<BlockItem> blockWriter =
BlockAsDirWriterBuilder.newBuilder(blockNodeContext).build();

final StreamMediator<BlockItem, ObjectEvent<SubscribeStreamResponse>> streamMediator =
LiveStreamMediatorBuilder.newBuilder(
blockWriter, blockNodeContext, serviceStatus)
.build();

final BlockReader<Block> blockReader =
BlockAsDirReaderBuilder.newBuilder(
blockNodeContext
.configuration()
.getConfigData(PersistenceStorageConfig.class))
.build();

final BlockStreamService blockStreamService =
buildBlockStreamService(
streamMediator, blockReader, serviceStatus, blockNodeContext);

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

final HealthService healthService = new HealthServiceImpl(serviceStatus);

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

// Build the web server
// TODO: make port server a configurable value.
final WebServer webServer =
WebServer.builder()
.port(8080)
.addRouting(grpcRouting)
.addRouting(httpRouting)
.build();

// Update the serviceStatus with the web server
serviceStatus.setWebServer(webServer);

// Start the web server
webServer.start();

// Log the server status
LOGGER.log(INFO, "Block Node Server started at port: " + webServer.port());
} catch (IOException e) {
throw new RuntimeException(e);
}
}

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

return new BlockStreamService(streamMediator, blockReader, serviceStatus, blockNodeContext);
final BlockNodeAppInjectionComponent daggerComponent =
DaggerBlockNodeAppInjectionComponent.create();
final BlockNodeApp blockNodeApp = daggerComponent.getBlockNodeApp();
blockNodeApp.start();
}
}
1 change: 1 addition & 0 deletions server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
exports com.hedera.block.server.config;
exports com.hedera.block.server.mediator;
exports com.hedera.block.server.data;
exports com.hedera.block.server.health;

requires com.hedera.block.stream;
requires com.google.protobuf;
Expand Down

0 comments on commit 08f8150

Please sign in to comment.