|
4 | 4 | import java.util.HashMap; |
5 | 5 | import java.util.List; |
6 | 6 | import java.util.Map; |
| 7 | +import org.tron.common.entity.NodeInfo.MachineInfo.DeadLockThreadInfo; |
| 8 | +import org.tron.common.entity.NodeInfo.MachineInfo.MemoryDescInfo; |
| 9 | +import org.tron.protos.Protocol; |
7 | 10 |
|
8 | 11 | public class NodeInfo { |
9 | 12 |
|
@@ -311,6 +314,7 @@ public static class ConfigNodeInfo { |
311 | 314 | private double minTimeRatio; |
312 | 315 | private double maxTimeRatio; |
313 | 316 | private long allowCreationOfContracts; |
| 317 | + private long allowAdaptiveEnergy; |
314 | 318 |
|
315 | 319 | public String getCodeVersion() { |
316 | 320 | return codeVersion; |
@@ -473,6 +477,16 @@ public ConfigNodeInfo setAllowCreationOfContracts(long allowCreationOfContracts) |
473 | 477 | this.allowCreationOfContracts = allowCreationOfContracts; |
474 | 478 | return this; |
475 | 479 | } |
| 480 | + |
| 481 | + public long getAllowAdaptiveEnergy() { |
| 482 | + return allowAdaptiveEnergy; |
| 483 | + } |
| 484 | + |
| 485 | + public ConfigNodeInfo setAllowAdaptiveEnergy(long allowAdaptiveEnergy) { |
| 486 | + this.allowAdaptiveEnergy = allowAdaptiveEnergy; |
| 487 | + return this; |
| 488 | + } |
| 489 | + |
476 | 490 | } |
477 | 491 |
|
478 | 492 | public long getBeginSyncNum() { |
@@ -574,4 +588,111 @@ public NodeInfo setCheatWitnessInfoMap( |
574 | 588 | this.cheatWitnessInfoMap = cheatWitnessInfoMap; |
575 | 589 | return this; |
576 | 590 | } |
| 591 | + |
| 592 | + public Protocol.NodeInfo transferToProtoEntity() { |
| 593 | + Protocol.NodeInfo.Builder builder = Protocol.NodeInfo.newBuilder(); |
| 594 | + builder.setBeginSyncNum(getBeginSyncNum()); |
| 595 | + builder.setBlock(getBlock()); |
| 596 | + builder.setSolidityBlock(getSolidityBlock()); |
| 597 | + builder.setCurrentConnectCount(getCurrentConnectCount()); |
| 598 | + builder.setActiveConnectCount(getActiveConnectCount()); |
| 599 | + builder.setPassiveConnectCount(getPassiveConnectCount()); |
| 600 | + builder.setTotalFlow(getTotalFlow()); |
| 601 | + builder.putAllCheatWitnessInfoMap(getCheatWitnessInfoMap()); |
| 602 | + for (PeerInfo peerInfo : getPeerList()) { |
| 603 | + Protocol.NodeInfo.PeerInfo.Builder peerInfoBuilder = Protocol.NodeInfo.PeerInfo.newBuilder(); |
| 604 | + peerInfoBuilder.setLastSyncBlock(peerInfo.getLastSyncBlock()); |
| 605 | + peerInfoBuilder.setRemainNum(peerInfo.getRemainNum()); |
| 606 | + peerInfoBuilder.setLastBlockUpdateTime(peerInfo.getLastBlockUpdateTime()); |
| 607 | + peerInfoBuilder.setSyncFlag(peerInfo.isSyncFlag()); |
| 608 | + peerInfoBuilder.setHeadBlockTimeWeBothHave(peerInfo.getHeadBlockTimeWeBothHave()); |
| 609 | + peerInfoBuilder.setNeedSyncFromPeer(peerInfo.isSyncFlag()); |
| 610 | + peerInfoBuilder.setNeedSyncFromUs(peerInfo.isNeedSyncFromUs()); |
| 611 | + peerInfoBuilder.setHost(peerInfo.getHost()); |
| 612 | + peerInfoBuilder.setPort(peerInfo.getPort()); |
| 613 | + peerInfoBuilder.setNodeId(peerInfo.getNodeId()); |
| 614 | + peerInfoBuilder.setConnectTime(peerInfo.getConnectTime()); |
| 615 | + peerInfoBuilder.setAvgLatency(peerInfo.getAvgLatency()); |
| 616 | + peerInfoBuilder.setSyncToFetchSize(peerInfo.getSyncToFetchSize()); |
| 617 | + peerInfoBuilder.setSyncToFetchSizePeekNum(peerInfo.getSyncToFetchSizePeekNum()); |
| 618 | + peerInfoBuilder.setSyncBlockRequestedSize(peerInfo.getSyncBlockRequestedSize()); |
| 619 | + peerInfoBuilder.setUnFetchSynNum(peerInfo.getUnFetchSynNum()); |
| 620 | + peerInfoBuilder.setBlockInPorcSize(peerInfo.getBlockInPorcSize()); |
| 621 | + peerInfoBuilder.setHeadBlockWeBothHave(peerInfo.getHeadBlockWeBothHave()); |
| 622 | + peerInfoBuilder.setIsActive(peerInfo.isActive()); |
| 623 | + peerInfoBuilder.setScore(peerInfo.getScore()); |
| 624 | + peerInfoBuilder.setNodeCount(peerInfo.getNodeCount()); |
| 625 | + peerInfoBuilder.setInFlow(peerInfo.getInFlow()); |
| 626 | + peerInfoBuilder.setDisconnectTimes(peerInfo.getDisconnectTimes()); |
| 627 | + peerInfoBuilder.setLocalDisconnectReason(peerInfo.getLocalDisconnectReason()); |
| 628 | + peerInfoBuilder.setRemoteDisconnectReason(peerInfo.getRemoteDisconnectReason()); |
| 629 | + builder.addPeerInfoList(peerInfoBuilder.build()); |
| 630 | + } |
| 631 | + ConfigNodeInfo configNodeInfo = getConfigNodeInfo(); |
| 632 | + if (configNodeInfo != null) { |
| 633 | + Protocol.NodeInfo.ConfigNodeInfo.Builder configBuilder = Protocol.NodeInfo.ConfigNodeInfo |
| 634 | + .newBuilder(); |
| 635 | + configBuilder.setCodeVersion(configNodeInfo.getCodeVersion()); |
| 636 | + configBuilder.setP2PVersion(configNodeInfo.getP2pVersion()); |
| 637 | + configBuilder.setListenPort(configNodeInfo.getListenPort()); |
| 638 | + configBuilder.setDiscoverEnable(configNodeInfo.isDiscoverEnable()); |
| 639 | + configBuilder.setActiveNodeSize(configNodeInfo.getActiveNodeSize()); |
| 640 | + configBuilder.setPassiveNodeSize(configNodeInfo.getPassiveNodeSize()); |
| 641 | + configBuilder.setSendNodeSize(configNodeInfo.getSendNodeSize()); |
| 642 | + configBuilder.setMaxConnectCount(configNodeInfo.getMaxConnectCount()); |
| 643 | + configBuilder.setSameIpMaxConnectCount(configNodeInfo.getSameIpMaxConnectCount()); |
| 644 | + configBuilder.setBackupListenPort(configNodeInfo.getBackupListenPort()); |
| 645 | + configBuilder.setBackupMemberSize(configNodeInfo.getBackupMemberSize()); |
| 646 | + configBuilder.setBackupPriority(configNodeInfo.getBackupPriority()); |
| 647 | + configBuilder.setDbVersion(configNodeInfo.getDbVersion()); |
| 648 | + configBuilder.setMinParticipationRate(configNodeInfo.getMinParticipationRate()); |
| 649 | + configBuilder.setSupportConstant(configNodeInfo.isSupportConstant()); |
| 650 | + configBuilder.setMinTimeRatio(configNodeInfo.getMinTimeRatio()); |
| 651 | + configBuilder.setMaxTimeRatio(configNodeInfo.getMaxTimeRatio()); |
| 652 | + configBuilder.setAllowCreationOfContracts(configNodeInfo.getAllowCreationOfContracts()); |
| 653 | + configBuilder.setAllowAdaptiveEnergy(configNodeInfo.getAllowAdaptiveEnergy()); |
| 654 | + builder.setConfigNodeInfo(configBuilder.build()); |
| 655 | + } |
| 656 | + MachineInfo machineInfo = getMachineInfo(); |
| 657 | + if (machineInfo != null) { |
| 658 | + Protocol.NodeInfo.MachineInfo.Builder machineBuilder = Protocol.NodeInfo.MachineInfo |
| 659 | + .newBuilder(); |
| 660 | + machineBuilder.setThreadCount(machineInfo.getThreadCount()); |
| 661 | + machineBuilder.setDeadLockThreadCount(machineInfo.getDeadLockThreadCount()); |
| 662 | + machineBuilder.setCpuCount(machineInfo.getCpuCount()); |
| 663 | + machineBuilder.setTotalMemory(machineInfo.getTotalMemory()); |
| 664 | + machineBuilder.setFreeMemory(machineInfo.getFreeMemory()); |
| 665 | + machineBuilder.setCpuRate(machineInfo.getCpuRate()); |
| 666 | + machineBuilder.setJavaVersion(machineInfo.getJavaVersion()); |
| 667 | + machineBuilder.setOsName(machineInfo.getOsName()); |
| 668 | + machineBuilder.setJvmTotalMemoery(machineInfo.getJvmTotalMemoery()); |
| 669 | + machineBuilder.setJvmFreeMemory(machineInfo.getJvmFreeMemory()); |
| 670 | + machineBuilder.setProcessCpuRate(machineInfo.getProcessCpuRate()); |
| 671 | + for (MemoryDescInfo memoryDescInfo : machineInfo.getMemoryDescInfoList()) { |
| 672 | + Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder descBuilder = Protocol.NodeInfo.MachineInfo.MemoryDescInfo |
| 673 | + .newBuilder(); |
| 674 | + descBuilder.setName(memoryDescInfo.getName()); |
| 675 | + descBuilder.setInitSize(memoryDescInfo.getInitSize()); |
| 676 | + descBuilder.setUseSize(memoryDescInfo.getUseSize()); |
| 677 | + descBuilder.setMaxSize(memoryDescInfo.getMaxSize()); |
| 678 | + descBuilder.setUseRate(memoryDescInfo.getUseRate()); |
| 679 | + machineBuilder.addMemoryDescInfoList(descBuilder.build()); |
| 680 | + } |
| 681 | + for (DeadLockThreadInfo deadLockThreadInfo : machineInfo.getDeadLockThreadInfoList()) { |
| 682 | + Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder deadBuilder = Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo |
| 683 | + .newBuilder(); |
| 684 | + deadBuilder.setName(deadLockThreadInfo.getName()); |
| 685 | + deadBuilder.setLockName(deadLockThreadInfo.getLockName()); |
| 686 | + deadBuilder.setLockOwner(deadLockThreadInfo.getLockOwner()); |
| 687 | + deadBuilder.setState(deadLockThreadInfo.getState()); |
| 688 | + deadBuilder.setBlockTime(deadLockThreadInfo.getBlockTime()); |
| 689 | + deadBuilder.setWaitTime(deadLockThreadInfo.getWaitTime()); |
| 690 | + deadBuilder.setStackTrace(deadLockThreadInfo.getStackTrace()); |
| 691 | + machineBuilder.addDeadLockThreadInfoList(deadBuilder.build()); |
| 692 | + } |
| 693 | + builder.setMachineInfo(machineBuilder.build()); |
| 694 | + } |
| 695 | + |
| 696 | + return builder.build(); |
| 697 | + } |
577 | 698 | } |
0 commit comments