use of io.nuls.db.entity.NodePo in project nuls by nuls-io.
the class NodeDiscoverHandler method getLocalNodes.
// get nodes from local database
public List<Node> getLocalNodes(int size) {
Set<String> keys = nodesManager.getNodes().keySet();
List<NodePo> nodePos = getNodeDao().getNodePoList(size, keys);
List<Node> nodes = new ArrayList<>();
if (nodePos == null || nodePos.isEmpty()) {
return nodes;
}
for (NodePo po : nodePos) {
Node node = new Node(network);
NodeTransferTool.toNode(node, po);
nodes.add(node);
}
return nodes;
}
use of io.nuls.db.entity.NodePo in project nuls by nuls-io.
the class NodeTransferTool method toPojo.
public static NodePo toPojo(Node node) {
NodePo po = new NodePo();
po.setId(node.getId());
po.setFailCount(node.getFailCount());
po.setIp(node.getIp());
po.setPort(node.getPort());
po.setLastTime(node.getLastTime());
po.setMagicNum(node.getMagicNumber());
po.setStatus(0);
po.setLastFailTime(node.getLastFailTime());
if (po.getLastTime() == null) {
po.setLastTime(TimeService.currentTimeMillis());
}
if (po.getFailCount() == null) {
po.setFailCount(0);
}
return po;
}
use of io.nuls.db.entity.NodePo in project nuls by nuls-io.
the class NodeDaoImpl method getNodePoList.
@Override
public List<NodePo> getNodePoList(int size, Set<String> keys) {
Searchable searchable = new Searchable();
PageHelper.startPage(1, size);
PageHelper.orderBy("last_fail_time asc");
if (!keys.isEmpty()) {
List<String> keyList = new ArrayList<>(keys);
searchable.addCondition("id", SearchOperator.notIn, keyList);
}
searchable.addCondition("status", SearchOperator.eq, 0);
List<NodePo> list = getMapper().selectList(searchable);
return list;
}
Aggregations