Skip to content

Commit

Permalink
HDFS-16186 Datanode kicks out hard disk logic optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyb16 committed Sep 7, 2021
1 parent 852af87 commit 1e1dc86
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,43 @@
package org.apache.hadoop.hdfs.server.datanode;

/**
* Record volume's IOException total counts and update timestamp
* Record volume's IOException total counts and update timestamp.
*/
public class VolumeExCountPair {

private long prevTs;
private long IoExceptionCnt;
private long prevTs;
private long ioExceptionCnt;

public VolumeExCountPair() {
}
public VolumeExCountPair() {
}

public VolumeExCountPair(long prevTimeStamp, long IoExceptionCnt) {
this.prevTs = prevTimeStamp;
this.IoExceptionCnt = IoExceptionCnt;
}
public VolumeExCountPair(long prevTimeStamp, long ioExceptionCnt) {
this.prevTs = prevTimeStamp;
this.ioExceptionCnt = ioExceptionCnt;
}

public void setNewPair(long now, long curExCnt) {
setPrevTs(now);
setIoExceptionCnt(curExCnt);
}
public void setNewPair(long now, long curExCnt) {
setPrevTs(now);
setIoExceptionCnt(curExCnt);
}

public VolumeExCountPair getPair() {
return new VolumeExCountPair(prevTs, IoExceptionCnt);
}
public VolumeExCountPair getPair() {
return new VolumeExCountPair(prevTs, ioExceptionCnt);
}

public void setPrevTs(long prevTs) {
this.prevTs = prevTs;
}
public void setPrevTs(long prevTs) {
this.prevTs = prevTs;
}

public void setIoExceptionCnt(long ioExceptionCnt) {
IoExceptionCnt = ioExceptionCnt;
}
public void setIoExceptionCnt(long ioExceptionCnt) {
this.ioExceptionCnt = ioExceptionCnt;
}

public long getPrevTs() {
return prevTs;
}
public long getPrevTs() {
return prevTs;
}

public long getIoExceptionCnt() {
return IoExceptionCnt;
}
public long getIoExceptionCnt() {
return ioExceptionCnt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.util.DiskChecker.DiskErrorException;
import org.apache.hadoop.util.Sets;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.util.Timer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -400,11 +401,12 @@ private void markHealthy() {
LOG.warn("Volume {} Exception Count is {}", reference.getVolume().toString(),
reference.getVolume().getExCountPair().getIoExceptionCnt());
if (volumeExCountPair.getIoExceptionCnt() == 0) {
volumeExCountPair.setNewPair(System.currentTimeMillis(), totalFileIoErrors);
volumeExCountPair.setNewPair(Time.monotonicNow(), totalFileIoErrors);
}else{
if((System.currentTimeMillis() - reference.getVolume().getExCountPair().getPrevTs())/1000/60/60 > 2){
long lastTime = reference.getVolume().getExCountPair().getPrevTs();
if((Time.monotonicNow() - lastTime)/1000/60/60 > 2){
long cnt = reference.getVolume().getExCountPair().getPair().getIoExceptionCnt();
if(cnt > 100){
if(cnt > 30){
failedVolumes.add(reference.getVolume());
return;
}
Expand Down

0 comments on commit 1e1dc86

Please sign in to comment.