提交 87cd058f 编写于 作者: Z zengqiao

Broker增加服务是否存活接口

上级 66dd82f4
......@@ -67,4 +67,8 @@ public interface BrokerService {
* 获取总的Broker数
*/
Integer countAllBrokers();
boolean allServerDown(Long clusterPhyId);
boolean existServerDown(Long clusterPhyId);
}
......@@ -262,14 +262,32 @@ public class BrokerServiceImpl extends BaseVersionControlService implements Brok
return version;
}
@Override
public Integer countAllBrokers() {
LambdaQueryWrapper<BrokerPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
return brokerDAO.selectCount(lambdaQueryWrapper);
}
@Override
public boolean allServerDown(Long clusterPhyId) {
List<BrokerPO> poList = this.getAllBrokerPOsFromDB(clusterPhyId);
if (ValidateUtils.isEmptyList(poList)) {
return false;
}
return poList.stream().filter(elem -> elem.getStatus().equals(Constant.DOWN)).count() == poList.size();
}
@Override
public boolean existServerDown(Long clusterPhyId) {
List<BrokerPO> poList = this.getAllBrokerPOsFromDB(clusterPhyId);
if (ValidateUtils.isEmptyList(poList)) {
return false;
}
return poList.stream().filter(elem -> elem.getStatus().equals(Constant.DOWN)).count() > 0;
}
/**************************************************** private method ****************************************************/
private List<Broker> listAllBrokersAndUpdateCache(Long clusterPhyId) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册