HDDS-1201. Reporting Corruptions in Containers to SCM (#912)
This commit is contained in:
parent
944adc61b1
commit
c8276f3e76
@ -302,7 +302,7 @@ private ContainerCommandResponseProto dispatchRequest(
|
||||
containerState == State.OPEN || containerState == State.CLOSING);
|
||||
// mark and persist the container state to be unhealthy
|
||||
try {
|
||||
handler.markContainerUhealthy(container);
|
||||
handler.markContainerUnhealthy(container);
|
||||
} catch (IOException ioe) {
|
||||
// just log the error here in case marking the container fails,
|
||||
// Return the actual failure response to the client
|
||||
|
@ -135,7 +135,7 @@ public abstract void markContainerForClose(Container container)
|
||||
* @param container container to update
|
||||
* @throws IOException in case of exception
|
||||
*/
|
||||
public abstract void markContainerUhealthy(Container container)
|
||||
public abstract void markContainerUnhealthy(Container container)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
|
@ -884,20 +884,20 @@ public Container importContainer(long containerID, long maxSize,
|
||||
@Override
|
||||
public void markContainerForClose(Container container)
|
||||
throws IOException {
|
||||
State currentState = container.getContainerState();
|
||||
// Move the container to CLOSING state only if it's OPEN
|
||||
if (currentState == State.OPEN) {
|
||||
if (container.getContainerState() == State.OPEN) {
|
||||
container.markContainerForClose();
|
||||
sendICR(container);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markContainerUhealthy(Container container)
|
||||
public void markContainerUnhealthy(Container container)
|
||||
throws IOException {
|
||||
// this will mark the container unhealthy and a close container action will
|
||||
// be sent from the dispatcher ton SCM to close down this container.
|
||||
if (container.getContainerState() != State.UNHEALTHY) {
|
||||
container.markContainerUnhealthy();
|
||||
sendICR(container);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,11 +133,11 @@ public void deleteContainer(final long containerId, boolean force)
|
||||
* @param container Container
|
||||
* @return handler of the container
|
||||
*/
|
||||
Handler getHandler(final Container container) {
|
||||
private Handler getHandler(final Container container) {
|
||||
return handlers.get(container.getContainerType());
|
||||
}
|
||||
|
||||
Iterator<Container> getContainerSetIterator() {
|
||||
public Iterator<Container> getContainers() {
|
||||
return containerSet.getContainerIterator();
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
|
||||
import org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException;
|
||||
import org.apache.hadoop.ozone.container.common.interfaces.Container;
|
||||
import org.apache.hadoop.ozone.container.common.interfaces.Handler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -57,7 +56,11 @@ public ContainerScrubber(OzoneConfiguration conf,
|
||||
LOG.info("Background ContainerScrubber starting up");
|
||||
while (true) {
|
||||
|
||||
try {
|
||||
scrub();
|
||||
} catch (StorageContainerException e) {
|
||||
LOG.error("Scrubber encountered StorageContainerException.");
|
||||
}
|
||||
|
||||
if (this.halt) {
|
||||
break; // stop and exit if requested
|
||||
@ -126,25 +129,20 @@ private void throttleScrubber(TimeStamp startTime) {
|
||||
}
|
||||
}
|
||||
|
||||
private void scrub() {
|
||||
|
||||
Iterator<Container> containerIt = controller.getContainerSetIterator();
|
||||
private void scrub() throws StorageContainerException {
|
||||
Iterator<Container> containerIt = controller.getContainers();
|
||||
long count = 0;
|
||||
|
||||
while (containerIt.hasNext()) {
|
||||
while (containerIt.hasNext() && !halt) {
|
||||
TimeStamp startTime = new TimeStamp(System.currentTimeMillis());
|
||||
Container container = containerIt.next();
|
||||
Handler containerHandler = controller.getHandler(container);
|
||||
|
||||
if (this.halt) {
|
||||
break; // stop if requested
|
||||
}
|
||||
|
||||
try {
|
||||
container.check();
|
||||
} catch (StorageContainerException e) {
|
||||
LOG.error("Error unexpected exception {} for Container {}", e,
|
||||
container.getContainerData().getContainerID());
|
||||
container.markContainerUnhealthy();
|
||||
// XXX Action required here
|
||||
}
|
||||
count++;
|
||||
|
Loading…
Reference in New Issue
Block a user