-
Notifications
You must be signed in to change notification settings - Fork 595
HDDS-8848. Clean up datanode memory in case of an ozone stream write error #4891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HDDS-8848. Clean up datanode memory in case of an ozone stream write error #4891
Conversation
|
hi, @szetszwo . |
|
cc @ChenSammi |
szetszwo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guohao-rosicky , thanks a lot for working on this! Please see the comments inlined.
| } | ||
|
|
||
| final ContainerCommandRequestProto request; | ||
| if (dataChannel instanceof KeyValueStreamDataChannel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change it to
if (!(dataChannel instanceof KeyValueStreamDataChannel)) {
return JavaUtils.completeExceptionally(new IllegalStateException(
"Unexpected DataChannel " + dataChannel.getClass()));
}Then, the code don't need to have so many indentation levels.
|
|
||
| class LocalStream implements StateMachine.DataStream { | ||
| private final StateMachine.DataChannel dataChannel; | ||
| private final StreamDataChannelBase dataChannel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use KeyValueStreamDataChannel instead. Then, we can keep StreamDataChannelBase package private.
| void cleanUpAll() { | ||
| final int size = deque.size(); | ||
| for (int i = 0; i < size; i++) { | ||
| Optional.ofNullable(poll()).ifPresent(ReferenceCountedObject::release); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call it releaseAll() and check isEmpty(). Also, poll() won't return null.
void releaseAll() {
while (!deque.isEmpty()) {
poll().release();
}
}| @Override | ||
| protected void cleanupInternal() throws IOException { | ||
| buffers.cleanUpAll(); | ||
| if (!closed.get()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use if (closed.compareAndSet(false, true)) {
| * For write state machine data. | ||
| */ | ||
| abstract class StreamDataChannelBase implements StateMachine.DataChannel { | ||
| public abstract class StreamDataChannelBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't add public.
szetszwo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 the change looks good.
What changes were proposed in this pull request?
Clean up datanode memory in case of an ozone stream write error
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-8848
How was this patch tested?