hdfs多副本删除策略

本文介绍了HDFS中删除多余副本的策略,包括优先移除节点上副本超过一个的文件,其次选择心跳时间最久的副本,最后是删除磁盘空间最小的节点上的副本。

代码:

chooseExcessReplicates

// split nodes into two sets
// moreThanOne contains nodes on rack with more than one replica
// exactlyOne contains the remaining nodes
splitNodesWithRack(candidates, rackMap, moreThanOne, exactlyOne);

// pick one node to delete that favors the delete hint
// otherwise pick one with least space from priSet if it is not empty
// otherwise one node with least space from remains
  • 1.删除节点副本多余一个的
  • 2.删除心跳最久的
  • 3.删除空间最小的
//oldestHeartbeat
if(lastHeartbeat < oldestHeartbeat) {
  oldestHeartbeat = lastHeartbeat;
  oldestHeartbeatStorage = storage;
}
//HDFS可用空间
if (minSpace > free) {
  minSpace = free;
  minSpaceStorage = storage;
}

oldestHeartbeat

long oldestHeartbeat =
  now() - heartbeatInterval * tolerateHeartbeatMultiplier;
  
this.tolerateHeartbeatMultiplier = conf.getInt(
DFSConfigKeys.DFS_NAMENODE_TOLERATE_HEARTBEAT_MULTIPLIER_KEY,4);
this.heartbeatInterval = conf.getLong(
    DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY,3) * 1000;
public static long now() {
  return System.currentTimeMillis();
}
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奈文摩尔ST

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值