Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ private ContainerUtils() {
public static ContainerCommandResponseProto logAndReturnError(
Logger log, StorageContainerException ex,
ContainerCommandRequestProto request) {
String logInfo = "Operation: {} , Trace ID: {} , Message: {} , " +
"Result: {} , StorageContainerException Occurred.";
String logInfo = "Operation: {} , Trace ID: {} , Block ID: {} , " +
"Message: {} , Result: {} , StorageContainerException Occurred.";
if (ex.getResult() == CLOSED_CONTAINER_IO ||
ex.getResult() == CONTAINER_NOT_OPEN) {
if (log.isDebugEnabled()) {
log.debug(logInfo, request.getCmdType(), request.getTraceID(),
request.getGetBlock().getBlockID(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be still logged at DEBUG level if it is under the isDebugEnabled() condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for your comment
I commit new version that if it is under the condition still logged at DEBUG level.
if it's not under the condition logged at Warn level.

ex.getMessage(), ex.getResult().getValueDescriptor().getName(), ex);
}
} else {
log.info(logInfo, request.getCmdType(), request.getTraceID(),
log.warn(logInfo, request.getCmdType(), request.getTraceID(),
request.getGetBlock().getBlockID(),
Copy link
Contributor

@adoroszlai adoroszlai Mar 6, 2023

Choose a reason for hiding this comment

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

request.getGetBlock() is only applicable to GetBlock requests. Also, not all commands are related to blocks anyway.

Looking at HDDS-8010, I think the goal is to change the message in:

private BlockData getBlockByID(DBHandle db, BlockID blockID,
KeyValueContainerData containerData) throws IOException {
String blockKey = containerData.getBlockKey(blockID.getLocalID());
BlockData blockData = db.getStore().getBlockDataTable().get(blockKey);
if (blockData == null) {
throw new StorageContainerException(NO_SUCH_BLOCK_ERR_MSG,
NO_SUCH_BLOCK);
}
return blockData;
}

Copy link
Contributor Author

@GAOJHIHCYUAN GAOJHIHCYUAN Mar 9, 2023

Choose a reason for hiding this comment

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

request.getGetBlock() is only applicable to GetBlock requests. Also, not all commands are related to blocks anyway.

Looking at HDDS-8010, I think the goal is to change the message in:

private BlockData getBlockByID(DBHandle db, BlockID blockID,
KeyValueContainerData containerData) throws IOException {
String blockKey = containerData.getBlockKey(blockID.getLocalID());
BlockData blockData = db.getStore().getBlockDataTable().get(blockKey);
if (blockData == null) {
throw new StorageContainerException(NO_SUCH_BLOCK_ERR_MSG,
NO_SUCH_BLOCK);
}
return blockData;
}

public class StorageContainerException extends IOException {
  private final ContainerProtos.Result result;

  private final BlockID blockID = getLocalID();

  public BlockID getLocalID() {return blockID;}
if (log.isDebugEnabled()) {
        log.debug(logInfo, request.getCmdType(), request.getTraceID(),
            ex.getLocalID(),
            ex.getMessage(), ex.getResult().getValueDescriptor().getName(), ex);
      }
    } else {
      log.warn(logInfo, request.getCmdType(), request.getTraceID(),
          ex.getLocalID(),
          ex.getMessage(), ex.getResult().getValueDescriptor().getName(), ex);
    }

because the log was logged when StorageContainerException occurred
my opinion was adding the getLocalID() in StorageContainerException.java
and then we can call function in getBlockByID() getting the block ID.
Idk is it a good soultion.
thanks you so much

@GAOJHIHCYUAN have you observed the updated message in the log?

No,I haven't
I will try how could I observe the updated message.
sorry,i was a newbie. I'm still learning.
thanks you so much.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can update message in getBlockByID while throwing StorageContainerException to print the blockID. Can you update the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can update message in getBlockByID while throwing StorageContainerException to print the blockID. Can you update the PR?

okay,I will update the PR.
appreciate

ex.getMessage(), ex.getResult().getValueDescriptor().getName(), ex);
}
return getContainerCommandResponse(request, ex.getResult(), ex.getMessage())
Expand Down