Search in sources :

Example 1 with NodePo

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;
}
Also used : NodePo(io.nuls.db.entity.NodePo) Node(io.nuls.network.entity.Node)

Example 2 with NodePo

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;
}
Also used : NodePo(io.nuls.db.entity.NodePo)

Example 3 with NodePo

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;
}
Also used : NodePo(io.nuls.db.entity.NodePo) Searchable(io.nuls.db.dao.impl.mybatis.util.Searchable)

Aggregations

NodePo (io.nuls.db.entity.NodePo)3 Searchable (io.nuls.db.dao.impl.mybatis.util.Searchable)1 Node (io.nuls.network.entity.Node)1