-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-13045. Implement Immediate Triggering of Heartbeat when Volume Full #8590
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
Changes from 2 commits
e7eb172
be17bc8
928471d
e130f27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| import java.util.Set; | ||
| import java.util.TreeMap; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
| import org.apache.hadoop.hdds.HddsConfigKeys; | ||
| import org.apache.hadoop.hdds.HddsUtils; | ||
| import org.apache.hadoop.hdds.client.BlockID; | ||
|
|
@@ -580,7 +581,9 @@ public void validateContainerCommand( | |
| */ | ||
| private void sendCloseContainerActionIfNeeded(Container container) { | ||
| // We have to find a more efficient way to close a container. | ||
| boolean isSpaceFull = isContainerFull(container) || isVolumeFull(container); | ||
| boolean isOpen = container != null && container.getContainerState() == State.OPEN; | ||
| boolean isVolumeFull = isOpen && isVolumeFullExcludingCommittedSpace(container); | ||
| boolean isSpaceFull = isContainerFull(container) || isVolumeFull; | ||
| boolean shouldClose = isSpaceFull || isContainerUnhealthy(container); | ||
| if (shouldClose) { | ||
| ContainerData containerData = container.getContainerData(); | ||
|
|
@@ -591,6 +594,21 @@ private void sendCloseContainerActionIfNeeded(Container container) { | |
| .setContainerID(containerData.getContainerID()) | ||
| .setAction(ContainerAction.Action.CLOSE).setReason(reason).build(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are closing the container because of full volume, we can set the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nandakumar131 Thanks for the review! Since
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we can do that as a followup. |
||
| context.addContainerActionIfAbsent(action); | ||
| if (isVolumeFull) { | ||
| HddsVolume volume = containerData.getVolume(); | ||
| LOG.warn("Volume [{}] is full. containerID: {}. Volume usage: [{}].", volume, containerData.getContainerID(), | ||
| volume.getCurrentUsage()); | ||
| } | ||
| AtomicBoolean immediateCloseActionSent = containerData.getImmediateCloseActionSent(); | ||
| // if an immediate heartbeat has not been triggered already, trigger it now | ||
| if (immediateCloseActionSent.compareAndSet(false, true)) { | ||
| context.getParent().triggerHeartbeat(); | ||
| if (isVolumeFull) { | ||
| // log only if volume is full | ||
| // don't want to log if only container is full because that is expected to happen frequently | ||
| LOG.warn("Triggered immediate heartbeat because of full volume."); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -608,20 +626,8 @@ private boolean isContainerFull(Container container) { | |
| } | ||
| } | ||
|
|
||
| private boolean isVolumeFull(Container container) { | ||
| boolean isOpen = Optional.ofNullable(container) | ||
| .map(cont -> cont.getContainerState() == ContainerDataProto.State.OPEN) | ||
| .orElse(Boolean.FALSE); | ||
| if (isOpen) { | ||
| HddsVolume volume = container.getContainerData().getVolume(); | ||
| StorageLocationReport volumeReport = volume.getReport(); | ||
| boolean full = volumeReport.getUsableSpace() <= 0; | ||
| if (full) { | ||
| LOG.info("Container {} volume is full: {}", container.getContainerData().getContainerID(), volumeReport); | ||
| } | ||
| return full; | ||
| } | ||
| return false; | ||
| private boolean isVolumeFullExcludingCommittedSpace(Container container) { | ||
| return container.getContainerData().getVolume().isVolumeFull(); | ||
| } | ||
|
|
||
| private boolean isContainerUnhealthy(Container container) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.