diff --git a/server/src/main/java/com/hedera/block/server/BlockStreamService.java b/server/src/main/java/com/hedera/block/server/BlockStreamService.java index f7ea6c77..7e508806 100644 --- a/server/src/main/java/com/hedera/block/server/BlockStreamService.java +++ b/server/src/main/java/com/hedera/block/server/BlockStreamService.java @@ -22,6 +22,8 @@ import static com.hedera.block.server.Constants.SINGLE_BLOCK_METHOD_NAME; import static com.hedera.block.server.Translator.toProtocSingleBlockResponse; import static com.hedera.block.server.Translator.toProtocSubscribeStreamResponse; +import static java.lang.System.Logger.Level.DEBUG; +import static java.lang.System.Logger.Level.ERROR; import com.google.protobuf.Descriptors; import com.google.protobuf.InvalidProtocolBufferException; @@ -130,7 +132,7 @@ StreamObserver protocPublishB final StreamObserver publishStreamResponseObserver) { LOGGER.log( - System.Logger.Level.DEBUG, + DEBUG, "Executing bidirectional publishBlockStream gRPC method"); return new ProducerBlockItemObserver( @@ -145,7 +147,7 @@ void protocSubscribeBlockStream( final StreamObserver subscribeStreamResponseObserver) { LOGGER.log( - System.Logger.Level.DEBUG, + DEBUG, "Executing Server Streaming subscribeBlockStream gRPC method"); // Return a custom StreamObserver to handle streaming blocks from the producer. @@ -160,7 +162,7 @@ void protocSubscribeBlockStream( streamMediator.subscribe(streamObserver); } else { LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Server Streaming subscribeBlockStream gRPC Service is not currently running"); subscribeStreamResponseObserver.onNext(buildSubscribeStreamNotAvailableResponse()); @@ -172,7 +174,7 @@ void protocSingleBlock( @NonNull final StreamObserver singleBlockResponseStreamObserver) { - LOGGER.log(System.Logger.Level.DEBUG, "Executing Unary singleBlock gRPC method"); + LOGGER.log(DEBUG, "Executing Unary singleBlock gRPC method"); try { final SingleBlockRequest pbjSingleBlockRequest = @@ -180,7 +182,7 @@ void protocSingleBlock( singleBlock(pbjSingleBlockRequest, singleBlockResponseStreamObserver); } catch (ParseException e) { LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Error parsing protoc SingleBlockRequest: {0}", singleBlockRequest); singleBlockResponseStreamObserver.onNext(buildSingleBlockNotAvailableResponse()); @@ -193,7 +195,7 @@ private void singleBlock( final StreamObserver singleBlockResponseStreamObserver) { - LOGGER.log(System.Logger.Level.DEBUG, "Executing Unary singleBlock gRPC method"); + LOGGER.log(DEBUG, "Executing Unary singleBlock gRPC method"); if (serviceStatus.isRunning()) { final long blockNumber = singleBlockRequest.blockNumber(); @@ -201,7 +203,7 @@ private void singleBlock( final Optional blockOpt = blockReader.read(blockNumber); if (blockOpt.isPresent()) { LOGGER.log( - System.Logger.Level.DEBUG, + DEBUG, "Successfully returning block number: {0}", blockNumber); singleBlockResponseStreamObserver.onNext( @@ -211,17 +213,17 @@ private void singleBlock( metricsService.singleBlocksRetrieved.increment(); } else { LOGGER.log( - System.Logger.Level.DEBUG, "Block number {0} not found", blockNumber); + DEBUG, "Block number {0} not found", blockNumber); singleBlockResponseStreamObserver.onNext(buildSingleBlockNotFoundResponse()); } } catch (IOException e) { LOGGER.log( - System.Logger.Level.ERROR, "Error reading block number: {0}", blockNumber); + ERROR, "Error reading block number: {0}", blockNumber); singleBlockResponseStreamObserver.onNext(buildSingleBlockNotAvailableResponse()); } } else { LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Unary singleBlock gRPC method is not currently running"); singleBlockResponseStreamObserver.onNext(buildSingleBlockNotAvailableResponse()); } diff --git a/server/src/main/java/com/hedera/block/server/Server.java b/server/src/main/java/com/hedera/block/server/Server.java index f3c4da6e..fddfbd64 100644 --- a/server/src/main/java/com/hedera/block/server/Server.java +++ b/server/src/main/java/com/hedera/block/server/Server.java @@ -37,6 +37,8 @@ import io.helidon.webserver.http.HttpRouting; import java.io.IOException; +import static java.lang.System.Logger.Level.INFO; + /** Main class for the block node server */ public class Server { @@ -51,7 +53,7 @@ private Server() {} */ public static void main(final String[] args) { - LOGGER.log(System.Logger.Level.INFO, "Starting BlockNode Server"); + LOGGER.log(INFO, "Starting BlockNode Server"); try { // init context, metrics, and configuration. @@ -103,7 +105,7 @@ public static void main(final String[] args) { // Log the server status LOGGER.log( - System.Logger.Level.INFO, + INFO, "Block Node Server started at port: " + webServer.port()); } catch (IOException e) { throw new RuntimeException(e); diff --git a/server/src/main/java/com/hedera/block/server/consumer/ConsumerStreamResponseObserver.java b/server/src/main/java/com/hedera/block/server/consumer/ConsumerStreamResponseObserver.java index 1ba84735..e4fd320c 100644 --- a/server/src/main/java/com/hedera/block/server/consumer/ConsumerStreamResponseObserver.java +++ b/server/src/main/java/com/hedera/block/server/consumer/ConsumerStreamResponseObserver.java @@ -17,6 +17,8 @@ package com.hedera.block.server.consumer; import static com.hedera.block.server.Translator.toProtocSubscribeStreamResponse; +import static java.lang.System.Logger.Level.DEBUG; +import static java.lang.System.Logger.Level.ERROR; import com.hedera.block.server.config.BlockNodeContext; import com.hedera.block.server.data.ObjectEvent; @@ -108,7 +110,7 @@ public ConsumerStreamResponseObserver( isResponsePermitted.set(false); subscriptionHandler.unsubscribe(this); LOGGER.log( - System.Logger.Level.DEBUG, + DEBUG, "Consumer cancelled stream. Observer unsubscribed."); }; serverCallStreamObserver.setOnCancelHandler(onCancel); @@ -120,7 +122,7 @@ public ConsumerStreamResponseObserver( isResponsePermitted.set(false); subscriptionHandler.unsubscribe(this); LOGGER.log( - System.Logger.Level.DEBUG, + DEBUG, "Consumer completed stream. Observer unsubscribed."); }; serverCallStreamObserver.setOnCloseHandler(onClose); @@ -155,7 +157,7 @@ public void onEvent( if (currentMillis - producerLivenessMillis > timeoutThresholdMillis) { subscriptionHandler.unsubscribe(this); LOGGER.log( - System.Logger.Level.DEBUG, + DEBUG, "Unsubscribed ConsumerBlockItemObserver due to producer timeout"); } else { // Refresh the producer liveness and pass the BlockItem to the downstream observer. @@ -196,7 +198,7 @@ public void send(@NonNull final SubscribeStreamResponse subscribeStreamResponse) final BlockItem blockItem = subscribeStreamResponse.blockItem(); if (blockItem == null) { LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "SubscribeStreamResponse was of type BLOCK_ITEM but block_item is null." + " This is a protocol violation: {0}", subscribeStreamResponse.toString()); @@ -209,7 +211,7 @@ public void send(@NonNull final SubscribeStreamResponse subscribeStreamResponse) if (streamStarted) { LOGGER.log( - System.Logger.Level.DEBUG, + DEBUG, "Send BlockItem downstream: {0} ", blockItem); subscribeStreamResponseObserver.onNext( @@ -222,7 +224,7 @@ public void send(@NonNull final SubscribeStreamResponse subscribeStreamResponse) private final class StatusResponseSender implements ResponseSender { public void send(@NonNull final SubscribeStreamResponse subscribeStreamResponse) { LOGGER.log( - System.Logger.Level.DEBUG, + DEBUG, "Send SubscribeStreamResponse downstream: {0} ", subscribeStreamResponse); subscribeStreamResponseObserver.onNext( diff --git a/server/src/main/java/com/hedera/block/server/mediator/LiveStreamMediatorImpl.java b/server/src/main/java/com/hedera/block/server/mediator/LiveStreamMediatorImpl.java index 2ad5e45f..9bb361e1 100644 --- a/server/src/main/java/com/hedera/block/server/mediator/LiveStreamMediatorImpl.java +++ b/server/src/main/java/com/hedera/block/server/mediator/LiveStreamMediatorImpl.java @@ -37,6 +37,9 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import static java.lang.System.Logger.Level.DEBUG; +import static java.lang.System.Logger.Level.ERROR; + /** * LiveStreamMediatorImpl is an implementation of the StreamMediator interface. It is responsible * for managing the subscribe and unsubscribe operations of downstream consumers. It also proxies @@ -111,7 +114,7 @@ public void publish(@NonNull final BlockItem blockItem) throws IOException { if (serviceStatus.isRunning()) { // Publish the block for all subscribers to receive - LOGGER.log(System.Logger.Level.DEBUG, "Publishing BlockItem: {0}", blockItem); + LOGGER.log(DEBUG, "Publishing BlockItem: {0}", blockItem); final var subscribeStreamResponse = SubscribeStreamResponse.newBuilder().blockItem(blockItem).build(); ringBuffer.publishEvent((event, sequence) -> event.set(subscribeStreamResponse)); @@ -126,12 +129,12 @@ public void publish(@NonNull final BlockItem blockItem) throws IOException { // Disable BlockItem publication for upstream producers serviceStatus.setRunning(false); LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "An exception occurred while attempting to persist the BlockItem: " + blockItem, e); - LOGGER.log(System.Logger.Level.DEBUG, "Send a response to end the stream"); + LOGGER.log(DEBUG, "Send a response to end the stream"); // Publish the block for all subscribers to receive final SubscribeStreamResponse endStreamResponse = buildEndStreamResponse(); @@ -139,14 +142,14 @@ public void publish(@NonNull final BlockItem blockItem) throws IOException { // Unsubscribe all downstream consumers for (final var subscriber : subscribers.keySet()) { - LOGGER.log(System.Logger.Level.DEBUG, "Unsubscribing: {0}", subscriber); + LOGGER.log(DEBUG, "Unsubscribing: {0}", subscriber); unsubscribe(subscriber); } throw e; } } else { - LOGGER.log(System.Logger.Level.ERROR, "StreamMediator is not accepting BlockItems"); + LOGGER.log(ERROR, "StreamMediator is not accepting BlockItems"); } } @@ -175,7 +178,7 @@ public void unsubscribe( // Remove the subscriber final var batchEventProcessor = subscribers.remove(handler); if (batchEventProcessor == null) { - LOGGER.log(System.Logger.Level.ERROR, "Subscriber not found: {0}", handler); + LOGGER.log(ERROR, "Subscriber not found: {0}", handler); } else { diff --git a/server/src/main/java/com/hedera/block/server/persistence/storage/PersistenceStorageConfig.java b/server/src/main/java/com/hedera/block/server/persistence/storage/PersistenceStorageConfig.java index eb91065f..dadc9e5c 100644 --- a/server/src/main/java/com/hedera/block/server/persistence/storage/PersistenceStorageConfig.java +++ b/server/src/main/java/com/hedera/block/server/persistence/storage/PersistenceStorageConfig.java @@ -23,6 +23,8 @@ import java.nio.file.Path; import java.nio.file.Paths; +import static java.lang.System.Logger.Level.ERROR; + /** * Use this configuration across the persistent storage package * @@ -50,7 +52,7 @@ public record PersistenceStorageConfig(@ConfigProperty(defaultValue = "") String if (Files.notExists(path)) { try { FileUtils.createPathIfNotExists( - path, System.Logger.Level.ERROR, FileUtils.defaultPerms); + path, ERROR, FileUtils.defaultPerms); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/server/src/main/java/com/hedera/block/server/persistence/storage/read/BlockAsDirReader.java b/server/src/main/java/com/hedera/block/server/persistence/storage/read/BlockAsDirReader.java index 9595754c..8166db8c 100644 --- a/server/src/main/java/com/hedera/block/server/persistence/storage/read/BlockAsDirReader.java +++ b/server/src/main/java/com/hedera/block/server/persistence/storage/read/BlockAsDirReader.java @@ -17,6 +17,9 @@ package com.hedera.block.server.persistence.storage.read; import static com.hedera.block.server.Constants.BLOCK_FILE_EXTENSION; +import static java.lang.System.Logger.Level.DEBUG; +import static java.lang.System.Logger.Level.ERROR; +import static java.lang.System.Logger.Level.INFO; import com.hedera.block.server.persistence.storage.PersistenceStorageConfig; import com.hedera.hapi.block.stream.Block; @@ -59,12 +62,12 @@ class BlockAsDirReader implements BlockReader { @NonNull final PersistenceStorageConfig config, @NonNull final FileAttribute> filePerms) { - LOGGER.log(System.Logger.Level.INFO, "Initializing FileSystemBlockReader"); + LOGGER.log(INFO, "Initializing FileSystemBlockReader"); final Path blockNodeRootPath = Path.of(config.rootPath()); - LOGGER.log(System.Logger.Level.INFO, config.toString()); - LOGGER.log(System.Logger.Level.INFO, "Block Node Root Path: " + blockNodeRootPath); + LOGGER.log(INFO, config.toString()); + LOGGER.log(INFO, "Block Node Root Path: " + blockNodeRootPath); this.blockNodeRootPath = blockNodeRootPath; this.filePerms = filePerms; @@ -123,7 +126,7 @@ public Optional read(final long blockNumber) throws IOException { // Return the Block return Optional.of(builder.build()); } catch (IOException io) { - LOGGER.log(System.Logger.Level.ERROR, "Error reading block: " + blockPath, io); + LOGGER.log(ERROR, "Error reading block: " + blockPath, io); throw io; } } @@ -151,7 +154,7 @@ private Optional readBlockItem(@NonNull final String blockItemPath) // So re-throw here to make a different decision upstream. throw io; } catch (ParseException e) { - LOGGER.log(System.Logger.Level.ERROR, "Error parsing block item: " + blockItemPath, e); + LOGGER.log(ERROR, "Error parsing block item: " + blockItemPath, e); throw new IOException(e); } } @@ -162,14 +165,14 @@ private boolean isPathDisqualified(@NonNull final Path path) { // This code path gets hit if a consumer // requests a block that does not exist. // Only log this as a debug message. - LOGGER.log(System.Logger.Level.DEBUG, "Path not found: {0}", path); + LOGGER.log(DEBUG, "Path not found: {0}", path); return true; } if (!path.toFile().canRead()) { - LOGGER.log(System.Logger.Level.ERROR, "Path not readable: {0}", path); + LOGGER.log(ERROR, "Path not readable: {0}", path); LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Attempting to repair the path permissions: {0}", path); @@ -182,13 +185,13 @@ private boolean isPathDisqualified(@NonNull final Path path) { } } catch (IOException e) { LOGGER.log( - System.Logger.Level.ERROR, "Error setting permissions on: {0}" + path, e); + ERROR, "Error setting permissions on: {0}" + path, e); return true; } } if (!path.toFile().isDirectory()) { - LOGGER.log(System.Logger.Level.ERROR, "Path is not a directory: {0}", path); + LOGGER.log(ERROR, "Path is not a directory: {0}", path); return true; } diff --git a/server/src/main/java/com/hedera/block/server/persistence/storage/remove/BlockAsDirRemover.java b/server/src/main/java/com/hedera/block/server/persistence/storage/remove/BlockAsDirRemover.java index a0fdf77a..3a3e922d 100644 --- a/server/src/main/java/com/hedera/block/server/persistence/storage/remove/BlockAsDirRemover.java +++ b/server/src/main/java/com/hedera/block/server/persistence/storage/remove/BlockAsDirRemover.java @@ -25,6 +25,8 @@ import java.nio.file.attribute.PosixFilePermission; import java.util.Set; +import static java.lang.System.Logger.Level.ERROR; + /** * The BlockAsDirRemover class removes a block from the file system. The block is stored as a * directory containing block items. The block items are stored as files within the block directory. @@ -62,7 +64,7 @@ public void remove(final long id) throws IOException { // for removal final Path blockPath = blockNodeRootPath.resolve(String.valueOf(id)); if (Files.notExists(blockPath)) { - LOGGER.log(System.Logger.Level.ERROR, "Block does not exist: {0}", id); + LOGGER.log(ERROR, "Block does not exist: {0}", id); return; } @@ -70,7 +72,7 @@ public void remove(final long id) throws IOException { // Best effort to delete the block if (!delete(blockPath.toFile())) { - LOGGER.log(System.Logger.Level.ERROR, "Failed to delete block: {0}", id); + LOGGER.log(ERROR, "Failed to delete block: {0}", id); } } diff --git a/server/src/main/java/com/hedera/block/server/persistence/storage/write/BlockAsDirWriter.java b/server/src/main/java/com/hedera/block/server/persistence/storage/write/BlockAsDirWriter.java index a17ef022..a5325ee7 100644 --- a/server/src/main/java/com/hedera/block/server/persistence/storage/write/BlockAsDirWriter.java +++ b/server/src/main/java/com/hedera/block/server/persistence/storage/write/BlockAsDirWriter.java @@ -17,6 +17,9 @@ package com.hedera.block.server.persistence.storage.write; import static com.hedera.block.server.Constants.BLOCK_FILE_EXTENSION; +import static java.lang.System.Logger.Level.DEBUG; +import static java.lang.System.Logger.Level.ERROR; +import static java.lang.System.Logger.Level.INFO; import com.hedera.block.server.config.BlockNodeContext; import com.hedera.block.server.metrics.MetricsService; @@ -67,20 +70,20 @@ class BlockAsDirWriter implements BlockWriter { @NonNull final BlockNodeContext blockNodeContext) throws IOException { - LOGGER.log(System.Logger.Level.INFO, "Initializing FileSystemBlockStorage"); + LOGGER.log(INFO, "Initializing FileSystemBlockStorage"); PersistenceStorageConfig config = blockNodeContext.configuration().getConfigData(PersistenceStorageConfig.class); final Path blockNodeRootPath = Path.of(config.rootPath()); - LOGGER.log(System.Logger.Level.INFO, "Block Node Root Path: " + blockNodeRootPath); + LOGGER.log(INFO, "Block Node Root Path: " + blockNodeRootPath); this.blockNodeRootPath = blockNodeRootPath; this.blockRemover = blockRemover; this.filePerms = filePerms; // Initialize the block node root directory if it does not exist - FileUtils.createPathIfNotExists(blockNodeRootPath, System.Logger.Level.INFO, filePerms); + FileUtils.createPathIfNotExists(blockNodeRootPath, INFO, filePerms); this.blockNodeContext = blockNodeContext; } @@ -106,7 +109,7 @@ public void write(@NonNull final BlockItem blockItem) throws IOException { } catch (IOException e) { LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Error writing the BlockItem protobuf to a file: ", e); @@ -121,7 +124,7 @@ public void write(@NonNull final BlockItem blockItem) throws IOException { repairPermissions(blockNodeRootPath); repairPermissions(calculateBlockPath()); LOGGER.log( - System.Logger.Level.INFO, + INFO, "Retrying to write the BlockItem protobuf to a file"); } } @@ -141,12 +144,12 @@ protected void write(@NonNull final Path blockItemFilePath, @NonNull final Block BlockItem.PROTOBUF.toBytes(blockItem).writeTo(fos); LOGGER.log( - System.Logger.Level.DEBUG, + DEBUG, "Successfully wrote the block item file: {0}", blockItemFilePath); } catch (IOException e) { LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Error writing the BlockItem protobuf to a file: ", e); throw e; @@ -163,7 +166,7 @@ private void resetState(@NonNull final BlockItem blockItem) throws IOException { repairPermissions(blockNodeRootPath); // Construct the path to the block directory - FileUtils.createPathIfNotExists(calculateBlockPath(), System.Logger.Level.DEBUG, filePerms); + FileUtils.createPathIfNotExists(calculateBlockPath(), DEBUG, filePerms); // Reset blockNodeFileNameIndex = 0; @@ -177,7 +180,7 @@ private void repairPermissions(@NonNull final Path path) throws IOException { final boolean isWritable = Files.isWritable(path); if (!isWritable) { LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Block node root directory is not writable. Attempting to change the" + " permissions."); @@ -186,7 +189,7 @@ private void repairPermissions(@NonNull final Path path) throws IOException { Files.setPosixFilePermissions(path, filePerms.value()); } catch (IOException e) { LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Error setting permissions on the path: " + path, e); throw e; diff --git a/server/src/main/java/com/hedera/block/server/producer/ProducerBlockItemObserver.java b/server/src/main/java/com/hedera/block/server/producer/ProducerBlockItemObserver.java index 5d70cddc..75717617 100644 --- a/server/src/main/java/com/hedera/block/server/producer/ProducerBlockItemObserver.java +++ b/server/src/main/java/com/hedera/block/server/producer/ProducerBlockItemObserver.java @@ -19,6 +19,8 @@ import static com.hedera.block.server.Translator.toPbjBlockItem; import static com.hedera.block.server.Translator.toProtocPublishStreamResponse; import static com.hedera.block.server.producer.Util.getFakeHash; +import static java.lang.System.Logger.Level.DEBUG; +import static java.lang.System.Logger.Level.ERROR; import com.hedera.block.server.ServiceStatus; import com.hedera.block.server.mediator.Publisher; @@ -105,26 +107,26 @@ public void onNext( } catch (IOException | NoSuchAlgorithmException e) { final var errorResponse = buildErrorStreamResponse(); publishStreamResponseObserver.onNext(errorResponse); - LOGGER.log(System.Logger.Level.ERROR, "Error calculating hash: ", e); + LOGGER.log(ERROR, "Error calculating hash: ", e); } } else { // Close the upstream connection to the producer(s) final var errorResponse = buildErrorStreamResponse(); publishStreamResponseObserver.onNext(errorResponse); - LOGGER.log(System.Logger.Level.DEBUG, "StreamMediator is not accepting BlockItems"); + LOGGER.log(DEBUG, "StreamMediator is not accepting BlockItems"); } } catch (IOException io) { final var errorResponse = buildErrorStreamResponse(); publishStreamResponseObserver.onNext(errorResponse); - LOGGER.log(System.Logger.Level.ERROR, "Exception thrown publishing BlockItem: ", io); - LOGGER.log(System.Logger.Level.ERROR, "Shutting down the web server"); + LOGGER.log(ERROR, "Exception thrown publishing BlockItem: ", io); + LOGGER.log(ERROR, "Shutting down the web server"); serviceStatus.stopWebServer(); } catch (ParseException e) { final var errorResponse = buildErrorStreamResponse(); publishStreamResponseObserver.onNext(errorResponse); LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Error parsing inbound block item from a producer: " + publishStreamRequest.getBlockItem(), e); @@ -178,7 +180,7 @@ protected Acknowledgement buildAck(@NonNull final BlockItem blockItem) */ @Override public void onError(@NonNull final Throwable t) { - LOGGER.log(System.Logger.Level.ERROR, "onError method invoked with an exception: ", t); + LOGGER.log(ERROR, "onError method invoked with an exception: ", t); publishStreamResponseObserver.onError(t); } @@ -188,7 +190,7 @@ public void onError(@NonNull final Throwable t) { */ @Override public void onCompleted() { - LOGGER.log(System.Logger.Level.DEBUG, "ProducerBlockStreamObserver completed"); + LOGGER.log(DEBUG, "ProducerBlockStreamObserver completed"); publishStreamResponseObserver.onCompleted(); } } diff --git a/server/src/test/java/com/hedera/block/server/BlockStreamServiceIntegrationTest.java b/server/src/test/java/com/hedera/block/server/BlockStreamServiceIntegrationTest.java index a8b32dcf..93e003c3 100644 --- a/server/src/test/java/com/hedera/block/server/BlockStreamServiceIntegrationTest.java +++ b/server/src/test/java/com/hedera/block/server/BlockStreamServiceIntegrationTest.java @@ -19,6 +19,7 @@ import static com.hedera.block.server.Translator.*; import static com.hedera.block.server.producer.Util.getFakeHash; import static com.hedera.block.server.util.PersistTestUtils.generateBlockItems; +import static java.lang.System.Logger.Level.INFO; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -118,7 +119,7 @@ public class BlockStreamServiceIntegrationTest { @BeforeEach public void setUp() throws IOException { testPath = Files.createTempDirectory(TEMP_DIR); - LOGGER.log(System.Logger.Level.INFO, "Created temp directory: " + testPath.toString()); + LOGGER.log(INFO, "Created temp directory: " + testPath.toString()); blockNodeContext = TestConfigUtil.getTestBlockNodeContext( diff --git a/server/src/test/java/com/hedera/block/server/BlockStreamServiceTest.java b/server/src/test/java/com/hedera/block/server/BlockStreamServiceTest.java index 12e666e7..fb45a4c1 100644 --- a/server/src/test/java/com/hedera/block/server/BlockStreamServiceTest.java +++ b/server/src/test/java/com/hedera/block/server/BlockStreamServiceTest.java @@ -22,6 +22,7 @@ import static com.hedera.block.server.Translator.toProtocSingleBlockResponse; import static com.hedera.block.server.util.PersistTestUtils.generateBlockItems; import static com.hedera.block.server.util.PersistTestUtils.reverseByteArray; +import static java.lang.System.Logger.Level.INFO; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; @@ -83,7 +84,7 @@ public class BlockStreamServiceTest { @BeforeEach public void setUp() throws IOException { testPath = Files.createTempDirectory(TEMP_DIR); - LOGGER.log(System.Logger.Level.INFO, "Created temp directory: " + testPath.toString()); + LOGGER.log(INFO, "Created temp directory: " + testPath.toString()); blockNodeContext = TestConfigUtil.getTestBlockNodeContext( diff --git a/server/src/test/java/com/hedera/block/server/persistence/storage/read/BlockAsDirReaderTest.java b/server/src/test/java/com/hedera/block/server/persistence/storage/read/BlockAsDirReaderTest.java index 81c698ec..ea593e10 100644 --- a/server/src/test/java/com/hedera/block/server/persistence/storage/read/BlockAsDirReaderTest.java +++ b/server/src/test/java/com/hedera/block/server/persistence/storage/read/BlockAsDirReaderTest.java @@ -19,6 +19,8 @@ import static com.hedera.block.server.Constants.BLOCK_FILE_EXTENSION; import static com.hedera.block.server.util.PersistTestUtils.generateBlockItems; import static com.hedera.block.server.util.PersistTestUtils.reverseByteArray; +import static java.lang.System.Logger.Level.ERROR; +import static java.lang.System.Logger.Level.INFO; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; @@ -63,7 +65,7 @@ public class BlockAsDirReaderTest { @BeforeEach public void setUp() throws IOException { testPath = Files.createTempDirectory(TEMP_DIR); - LOGGER.log(System.Logger.Level.INFO, "Created temp directory: " + testPath.toString()); + LOGGER.log(INFO, "Created temp directory: " + testPath.toString()); blockNodeContext = TestConfigUtil.getTestBlockNodeContext( @@ -75,7 +77,7 @@ public void setUp() throws IOException { public void tearDown() { if (!TestUtils.deleteDirectory(testPath.toFile())) { LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Failed to delete temp directory: " + testPath.toString()); } } diff --git a/server/src/test/java/com/hedera/block/server/persistence/storage/remove/BlockAsDirRemoverTest.java b/server/src/test/java/com/hedera/block/server/persistence/storage/remove/BlockAsDirRemoverTest.java index 87733fa2..e57d500c 100644 --- a/server/src/test/java/com/hedera/block/server/persistence/storage/remove/BlockAsDirRemoverTest.java +++ b/server/src/test/java/com/hedera/block/server/persistence/storage/remove/BlockAsDirRemoverTest.java @@ -16,6 +16,7 @@ package com.hedera.block.server.persistence.storage.remove; +import static java.lang.System.Logger.Level.INFO; import static org.junit.jupiter.api.Assertions.assertEquals; import com.hedera.block.server.config.BlockNodeContext; @@ -52,7 +53,7 @@ public class BlockAsDirRemoverTest { @BeforeEach public void setUp() throws IOException { testPath = Files.createTempDirectory(TEMP_DIR); - LOGGER.log(System.Logger.Level.INFO, "Created temp directory: " + testPath.toString()); + LOGGER.log(INFO, "Created temp directory: " + testPath.toString()); blockNodeContext = TestConfigUtil.getTestBlockNodeContext( diff --git a/server/src/test/java/com/hedera/block/server/persistence/storage/write/BlockAsDirWriterTest.java b/server/src/test/java/com/hedera/block/server/persistence/storage/write/BlockAsDirWriterTest.java index d7404195..3dccdd38 100644 --- a/server/src/test/java/com/hedera/block/server/persistence/storage/write/BlockAsDirWriterTest.java +++ b/server/src/test/java/com/hedera/block/server/persistence/storage/write/BlockAsDirWriterTest.java @@ -17,6 +17,8 @@ package com.hedera.block.server.persistence.storage.write; import static com.hedera.block.server.persistence.storage.read.BlockAsDirReaderTest.removeBlockReadPerms; +import static java.lang.System.Logger.Level.ERROR; +import static java.lang.System.Logger.Level.INFO; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -60,7 +62,7 @@ public class BlockAsDirWriterTest { @BeforeEach public void setUp() throws IOException { testPath = Files.createTempDirectory(TEMP_DIR); - LOGGER.log(System.Logger.Level.INFO, "Created temp directory: " + testPath.toString()); + LOGGER.log(INFO, "Created temp directory: " + testPath.toString()); blockNodeContext = TestConfigUtil.getTestBlockNodeContext( @@ -72,7 +74,7 @@ public void setUp() throws IOException { public void tearDown() { if (!TestUtils.deleteDirectory(testPath.toFile())) { LOGGER.log( - System.Logger.Level.ERROR, + ERROR, "Failed to delete temp directory: " + testPath.toString()); } } diff --git a/server/src/test/java/com/hedera/block/server/util/PersistTestUtils.java b/server/src/test/java/com/hedera/block/server/util/PersistTestUtils.java index d2030d59..380241d8 100644 --- a/server/src/test/java/com/hedera/block/server/util/PersistTestUtils.java +++ b/server/src/test/java/com/hedera/block/server/util/PersistTestUtils.java @@ -29,6 +29,8 @@ import java.util.ArrayList; import java.util.List; +import static java.lang.System.Logger.Level.INFO; + public final class PersistTestUtils { private static final System.Logger LOGGER = System.getLogger(PersistTestUtils.class.getName()); @@ -45,7 +47,7 @@ public static void writeBlockItemToPath(final Path path, final BlockItem blockIt public static void writeBytesToPath(final Path path, final byte[] bytes) throws IOException { try (FileOutputStream fos = new FileOutputStream(path.toString())) { fos.write(bytes); - LOGGER.log(System.Logger.Level.INFO, "Successfully wrote the bytes to file: {0}", path); + LOGGER.log(INFO, "Successfully wrote the bytes to file: {0}", path); } }