mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 11:52:08 +08:00
Broker增加服务是否存活接口
This commit is contained in:
@@ -67,4 +67,8 @@ public interface BrokerService {
|
|||||||
* 获取总的Broker数
|
* 获取总的Broker数
|
||||||
*/
|
*/
|
||||||
Integer countAllBrokers();
|
Integer countAllBrokers();
|
||||||
|
|
||||||
|
boolean allServerDown(Long clusterPhyId);
|
||||||
|
|
||||||
|
boolean existServerDown(Long clusterPhyId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,14 +262,32 @@ public class BrokerServiceImpl extends BaseVersionControlService implements Brok
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer countAllBrokers() {
|
public Integer countAllBrokers() {
|
||||||
LambdaQueryWrapper<BrokerPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BrokerPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
return brokerDAO.selectCount(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 method ****************************************************/
|
||||||
|
|
||||||
private List<Broker> listAllBrokersAndUpdateCache(Long clusterPhyId) {
|
private List<Broker> listAllBrokersAndUpdateCache(Long clusterPhyId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user