Skip to content

Commit c0fa3ca

Browse files
committed
cleanup & correct logging
Signed-off-by: Atanas Atanasov <[email protected]>
1 parent 8648b95 commit c0fa3ca

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

server/src/main/java/com/hedera/block/server/ack/AckHandlerImpl.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-License-Identifier: Apache-2.0
22
package com.hedera.block.server.ack;
33

4+
import static java.lang.System.Logger.Level.ERROR;
5+
46
import com.hedera.block.server.block.BlockInfo;
57
import com.hedera.block.server.metrics.BlockNodeMetricTypes;
68
import com.hedera.block.server.metrics.MetricsService;
@@ -110,8 +112,9 @@ public void blockVerificationFailed(long blockNumber) {
110112
notifier.sendEndOfStream(lastAcknowledgedBlockNumber, PublishStreamResponseCode.STREAM_ITEMS_BAD_STATE_PROOF);
111113
try {
112114
blockRemover.removeUnverified(blockNumber);
113-
} catch (IOException e) {
114-
LOGGER.log(System.Logger.Level.ERROR, "Failed to remove block " + blockNumber, e);
115+
} catch (final IOException e) {
116+
final String message = "Failed to remove Block with number [%d]".formatted(blockNumber);
117+
LOGGER.log(ERROR, message, e);
115118
throw new RuntimeException(e);
116119
}
117120
blockInfo.remove(blockNumber);
@@ -161,6 +164,11 @@ private void attemptAcks() {
161164
// again. What would be the best way to hande inability to move the block with
162165
// the limitations we current have?
163166
// @todo(774) we should use a response code for failed persistence here
167+
LOGGER.log(
168+
ERROR,
169+
"Failed to move Block with number [%d] from unverified to live storage"
170+
.formatted(nextBlock),
171+
e);
164172
blockVerificationFailed(nextBlock);
165173
return;
166174
}

server/src/main/java/com/hedera/block/server/persistence/StreamPersistenceHandlerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public void moveVerified(final long blockNumber) throws IOException {
146146
rawPathToLive, unverifiedBlockPath.compressionType().getFileExtension());
147147
Files.createDirectories(target.getParent());
148148
Files.move(source, target);
149+
archiver.notifyBlockPersisted(blockNumber);
149150
} else {
150151
throw new FileNotFoundException(
151152
"File for Block [%s] not found under unverified root".formatted(blockNumber));
@@ -209,7 +210,6 @@ private void handleBlockItems(final List<BlockItemUnparsed> blockItems)
209210
final AsyncBlockWriter writer = asyncBlockWriterFactory.create(blockNumber);
210211
currentWriterQueue = writer.getQueue();
211212
completionService.submit(writer);
212-
archiver.notifyBlockPersisted(blockNumber);
213213
} else {
214214
// we need to notify the ackHandler that the block number is invalid
215215
// IMPORTANT: the currentWriterQueue MUST be null after we have

server/src/main/java/com/hedera/block/server/persistence/storage/archive/LocalGroupZipArchiveTask.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ public final class LocalGroupZipArchiveTask implements Callable<Long> {
4444
private static final String ADD_ENTRY_MESSAGE = "Adding Zip Entry [{0}] to zip file [{1}]";
4545
private static final String ADD_SUCCESS_MESSAGE = "Zip Entry [{0}] successfully added to zip file [{1}]";
4646
private static final String ZIP_FILE_SUCCESSFULLY_CREATED_MESSAGE = "Zip File [{0}] successfully created";
47-
private static final String MUST_CREATE_SYMLINK_MESSAGE =
48-
"Unable to create hard link [{0} <-> {1}], attempting to create a symbolic link instead";
4947
private static final String LINK_CREATED_MESSAGE = "Link [{0} <-> {1}] created";
5048
private static final int BUFFER_SIZE = 32768; // 32K should exactly contain one or two disk blocks in most cases.
5149
private final BlockPathResolver pathResolver;
@@ -259,7 +257,10 @@ private void createLink(final Path rootToArchive, final Path zipFilePath) throws
259257
try {
260258
Files.createLink(livelink, zipFilePath);
261259
} catch (final IOException e) {
262-
LOGGER.log(Level.DEBUG, MUST_CREATE_SYMLINK_MESSAGE, livelink, zipFilePath, e);
260+
final String message =
261+
"Unable to create hard link [%s <-> %s], attempting to create a symbolic link instead"
262+
.formatted(livelink, zipFilePath);
263+
LOGGER.log(Level.DEBUG, message, e);
263264
// If we are unable to create a link, we need to attempt to create a symbolic link.
264265
Files.createSymbolicLink(livelink, zipFilePath);
265266
}

0 commit comments

Comments
 (0)