use of io.nuls.network.storage.po.NodeContainerPo in project nuls by nuls-io.
the class NodeManager method loadDatas.
public void loadDatas() {
// 本地已经存储的节点信息
NodeContainerPo containerPo = getNetworkStorageService().loadNodeContainer();
if (containerPo != null) {
NodesContainer container = new NodesContainer(containerPo);
this.nodesContainer = container;
}
// 获取种子节点
List<Node> seedList = getSeedNodes();
for (Node node : seedList) {
node.setConnectStatus(NodeConnectStatusEnum.UNCONNECT);
nodesContainer.getCanConnectNodes().put(node.getId(), node);
nodesContainer.getUncheckNodes().remove(node.getId());
nodesContainer.getDisconnectNodes().remove(node.getId());
nodesContainer.getFailNodes().remove(node.getId());
}
}
use of io.nuls.network.storage.po.NodeContainerPo in project nuls by nuls-io.
the class NetworkStorageServiceImpl method saveNodes.
@Override
public void saveNodes(Map<String, Node> disConnectNodes, Map<String, Node> canConnectNodes, Map<String, Node> failNodes, Map<String, Node> uncheckNodes, Map<String, Node> connectedNodes) {
NodeContainerPo containerPo = createNodeContainerPo(disConnectNodes, canConnectNodes, failNodes, uncheckNodes, connectedNodes);
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(getStoreageFile());
oos = new ObjectOutputStream(fos);
oos.writeObject(containerPo);
} catch (FileNotFoundException e) {
Log.error(e);
} catch (IOException e) {
Log.error(e);
} finally {
if (oos != null) {
try {
oos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
use of io.nuls.network.storage.po.NodeContainerPo in project nuls by nuls-io.
the class NetworkStorageServiceImpl method loadNodeContainer.
@Override
public NodeContainerPo loadNodeContainer() {
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
fis = new FileInputStream(getStoreageFile());
ois = new ObjectInputStream(fis);
NodeContainerPo containerPo = (NodeContainerPo) ois.readObject();
return containerPo;
} catch (FileNotFoundException e) {
// Log.error(e);
} catch (IOException e) {
Log.error(e);
} catch (ClassNotFoundException e) {
Log.error(e);
} finally {
if (ois != null) {
try {
ois.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
Aggregations