Repository navigation
Expand file tree
/
Copy pathNodeInfo.java
More file actions
716 lines (585 loc) · 20.4 KB
/
Copy pathNodeInfo.java
File metadata and controls
716 lines (585 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
package org.tron.common.entity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.tron.common.entity.NodeInfo.MachineInfo.DeadLockThreadInfo;
import org.tron.common.entity.NodeInfo.MachineInfo.MemoryDescInfo;
import org.tron.protos.Protocol;
public class NodeInfo {
/*block information*/
private long beginSyncNum;
private String block;
private String solidityBlock;
/*connect information*/
private int currentConnectCount;
private int activeConnectCount;
private int passiveConnectCount;
private long totalFlow;
private List<PeerInfo> peerList = new ArrayList<>();
/*node config information*/
private ConfigNodeInfo configNodeInfo;
/*machine information*/
private MachineInfo machineInfo;
private Map<String, String> cheatWitnessInfoMap = new HashMap<>();
public static class MachineInfo {
/*machine information*/
private int threadCount;
private int deadLockThreadCount;
private int cpuCount;
private long totalMemory;
private long freeMemory;
private double cpuRate;
private String javaVersion;
private String osName;
private long jvmTotalMemoery;
private long jvmFreeMemory;
private double processCpuRate;
private List<MemoryDescInfo> memoryDescInfoList = new ArrayList<>();
private List<DeadLockThreadInfo> deadLockThreadInfoList = new ArrayList<>();
public static class MemoryDescInfo {
private String name;
private long initSize;
private long useSize;
private long maxSize;
private double useRate;
public String getName() {
return name;
}
public MemoryDescInfo setName(String name) {
this.name = name;
return this;
}
public long getInitSize() {
return initSize;
}
public MemoryDescInfo setInitSize(long initSize) {
this.initSize = initSize;
return this;
}
public long getUseSize() {
return useSize;
}
public MemoryDescInfo setUseSize(long useSize) {
this.useSize = useSize;
return this;
}
public long getMaxSize() {
return maxSize;
}
public MemoryDescInfo setMaxSize(long maxSize) {
this.maxSize = maxSize;
return this;
}
public double getUseRate() {
return useRate;
}
public MemoryDescInfo setUseRate(double useRate) {
this.useRate = useRate;
return this;
}
}
public static class DeadLockThreadInfo {
private String name;
private String lockName;
private String lockOwner;
private String state;
private long blockTime;
private long waitTime;
private String stackTrace;
public String getName() {
return name;
}
public DeadLockThreadInfo setName(String name) {
this.name = name;
return this;
}
public String getLockName() {
return lockName;
}
public DeadLockThreadInfo setLockName(String lockName) {
this.lockName = lockName;
return this;
}
public String getLockOwner() {
return lockOwner;
}
public DeadLockThreadInfo setLockOwner(String lockOwner) {
this.lockOwner = lockOwner;
return this;
}
public String getState() {
return state;
}
public DeadLockThreadInfo setState(String state) {
this.state = state;
return this;
}
public long getBlockTime() {
return blockTime;
}
public DeadLockThreadInfo setBlockTime(long blockTime) {
this.blockTime = blockTime;
return this;
}
public long getWaitTime() {
return waitTime;
}
public DeadLockThreadInfo setWaitTime(long waitTime) {
this.waitTime = waitTime;
return this;
}
public String getStackTrace() {
return stackTrace;
}
public DeadLockThreadInfo setStackTrace(String stackTrace) {
this.stackTrace = stackTrace;
return this;
}
}
public int getThreadCount() {
return threadCount;
}
public MachineInfo setThreadCount(int threadCount) {
this.threadCount = threadCount;
return this;
}
public int getCpuCount() {
return cpuCount;
}
public MachineInfo setCpuCount(int cpuCount) {
this.cpuCount = cpuCount;
return this;
}
public long getTotalMemory() {
return totalMemory;
}
public MachineInfo setTotalMemory(long totalMemory) {
this.totalMemory = totalMemory;
return this;
}
public long getFreeMemory() {
return freeMemory;
}
public MachineInfo setFreeMemory(long freeMemory) {
this.freeMemory = freeMemory;
return this;
}
public double getCpuRate() {
return cpuRate;
}
public MachineInfo setCpuRate(double cpuRate) {
this.cpuRate = cpuRate;
return this;
}
public String getJavaVersion() {
return javaVersion;
}
public MachineInfo setJavaVersion(String javaVersion) {
this.javaVersion = javaVersion;
return this;
}
public String getOsName() {
return osName;
}
public MachineInfo setOsName(String osName) {
this.osName = osName;
return this;
}
public long getJvmTotalMemoery() {
return jvmTotalMemoery;
}
public MachineInfo setJvmTotalMemoery(long jvmTotalMemoery) {
this.jvmTotalMemoery = jvmTotalMemoery;
return this;
}
public long getJvmFreeMemory() {
return jvmFreeMemory;
}
public MachineInfo setJvmFreeMemory(long jvmFreeMemory) {
this.jvmFreeMemory = jvmFreeMemory;
return this;
}
public double getProcessCpuRate() {
return processCpuRate;
}
public MachineInfo setProcessCpuRate(double processCpuRate) {
this.processCpuRate = processCpuRate;
return this;
}
public List<MemoryDescInfo> getMemoryDescInfoList() {
return new ArrayList<>(memoryDescInfoList);
}
public MachineInfo setMemoryDescInfoList(
List<MemoryDescInfo> memoryDescInfoList) {
this.memoryDescInfoList = new ArrayList<>(memoryDescInfoList);
return this;
}
public int getDeadLockThreadCount() {
return deadLockThreadCount;
}
public MachineInfo setDeadLockThreadCount(int deadLockThreadCount) {
this.deadLockThreadCount = deadLockThreadCount;
return this;
}
public List<DeadLockThreadInfo> getDeadLockThreadInfoList() {
return new ArrayList<>(deadLockThreadInfoList);
}
public MachineInfo setDeadLockThreadInfoList(List<DeadLockThreadInfo> deadLockThreadInfoList) {
this.deadLockThreadInfoList = new ArrayList<>(deadLockThreadInfoList);
return this;
}
}
public static class ConfigNodeInfo {
/*node information*/
private String codeVersion;
private String versionName;
private String versionNum;
private String p2pVersion;
private int listenPort;
private boolean discoverEnable;
private int activeNodeSize;
private int passiveNodeSize;
private int sendNodeSize;
private int maxConnectCount;
private int sameIpMaxConnectCount;
private int backupListenPort;
private int backupMemberSize;
private int backupPriority;
private int dbVersion;
private int minParticipationRate;
private boolean supportConstant;
private double minTimeRatio;
private double maxTimeRatio;
private long allowCreationOfContracts;
private long allowAdaptiveEnergy;
public String getCodeVersion() {
return codeVersion;
}
public ConfigNodeInfo setCodeVersion(String codeVersion) {
this.codeVersion = codeVersion;
return this;
}
public String getVersionName() {
return versionName;
}
public void setVersionName(String versionName) {
this.versionName = versionName;
}
public String getVersionNum() {
return versionNum;
}
public void setVersionNum(String versionNum) {
this.versionNum = versionNum;
}
public String getP2pVersion() {
return p2pVersion;
}
public ConfigNodeInfo setP2pVersion(String p2pVersion) {
this.p2pVersion = p2pVersion;
return this;
}
public int getListenPort() {
return listenPort;
}
public ConfigNodeInfo setListenPort(int listenPort) {
this.listenPort = listenPort;
return this;
}
public boolean isDiscoverEnable() {
return discoverEnable;
}
public ConfigNodeInfo setDiscoverEnable(boolean discoverEnable) {
this.discoverEnable = discoverEnable;
return this;
}
public int getActiveNodeSize() {
return activeNodeSize;
}
public ConfigNodeInfo setActiveNodeSize(int activeNodeSize) {
this.activeNodeSize = activeNodeSize;
return this;
}
public int getPassiveNodeSize() {
return passiveNodeSize;
}
public ConfigNodeInfo setPassiveNodeSize(int passiveNodeSize) {
this.passiveNodeSize = passiveNodeSize;
return this;
}
public int getSendNodeSize() {
return sendNodeSize;
}
public ConfigNodeInfo setSendNodeSize(int sendNodeSize) {
this.sendNodeSize = sendNodeSize;
return this;
}
public int getMaxConnectCount() {
return maxConnectCount;
}
public ConfigNodeInfo setMaxConnectCount(int maxConnectCount) {
this.maxConnectCount = maxConnectCount;
return this;
}
public int getSameIpMaxConnectCount() {
return sameIpMaxConnectCount;
}
public ConfigNodeInfo setSameIpMaxConnectCount(int sameIpMaxConnectCount) {
this.sameIpMaxConnectCount = sameIpMaxConnectCount;
return this;
}
public int getBackupListenPort() {
return backupListenPort;
}
public ConfigNodeInfo setBackupListenPort(int backupListenPort) {
this.backupListenPort = backupListenPort;
return this;
}
public int getBackupMemberSize() {
return backupMemberSize;
}
public ConfigNodeInfo setBackupMemberSize(int backupMemberSize) {
this.backupMemberSize = backupMemberSize;
return this;
}
public int getBackupPriority() {
return backupPriority;
}
public ConfigNodeInfo setBackupPriority(int backupPriority) {
this.backupPriority = backupPriority;
return this;
}
public int getDbVersion() {
return dbVersion;
}
public ConfigNodeInfo setDbVersion(int dbVersion) {
this.dbVersion = dbVersion;
return this;
}
public int getMinParticipationRate() {
return minParticipationRate;
}
public ConfigNodeInfo setMinParticipationRate(int minParticipationRate) {
this.minParticipationRate = minParticipationRate;
return this;
}
public boolean isSupportConstant() {
return supportConstant;
}
public ConfigNodeInfo setSupportConstant(boolean supportConstant) {
this.supportConstant = supportConstant;
return this;
}
public double getMinTimeRatio() {
return minTimeRatio;
}
public ConfigNodeInfo setMinTimeRatio(double minTimeRatio) {
this.minTimeRatio = minTimeRatio;
return this;
}
public double getMaxTimeRatio() {
return maxTimeRatio;
}
public ConfigNodeInfo setMaxTimeRatio(double maxTimeRatio) {
this.maxTimeRatio = maxTimeRatio;
return this;
}
public long getAllowCreationOfContracts() {
return allowCreationOfContracts;
}
public ConfigNodeInfo setAllowCreationOfContracts(long allowCreationOfContracts) {
this.allowCreationOfContracts = allowCreationOfContracts;
return this;
}
public long getAllowAdaptiveEnergy() {
return allowAdaptiveEnergy;
}
public ConfigNodeInfo setAllowAdaptiveEnergy(long allowAdaptiveEnergy) {
this.allowAdaptiveEnergy = allowAdaptiveEnergy;
return this;
}
}
public long getBeginSyncNum() {
return beginSyncNum;
}
public NodeInfo setBeginSyncNum(long beginSyncNum) {
this.beginSyncNum = beginSyncNum;
return this;
}
public String getBlock() {
return block;
}
public NodeInfo setBlock(String block) {
this.block = block;
return this;
}
public String getSolidityBlock() {
return solidityBlock;
}
public NodeInfo setSolidityBlock(String solidityBlock) {
this.solidityBlock = solidityBlock;
return this;
}
public int getCurrentConnectCount() {
return currentConnectCount;
}
public NodeInfo setCurrentConnectCount(int currentConnectCount) {
this.currentConnectCount = currentConnectCount;
return this;
}
public int getActiveConnectCount() {
return activeConnectCount;
}
public NodeInfo setActiveConnectCount(int activeConnectCount) {
this.activeConnectCount = activeConnectCount;
return this;
}
public int getPassiveConnectCount() {
return passiveConnectCount;
}
public NodeInfo setPassiveConnectCount(int passiveConnectCount) {
this.passiveConnectCount = passiveConnectCount;
return this;
}
public long getTotalFlow() {
return totalFlow;
}
public NodeInfo setTotalFlow(long totalFlow) {
this.totalFlow = totalFlow;
return this;
}
public List<PeerInfo> getPeerList() {
return new ArrayList<>(peerList);
}
public NodeInfo setPeerList(List<PeerInfo> peerList) {
this.peerList = new ArrayList<>(peerList);
return this;
}
public ConfigNodeInfo getConfigNodeInfo() {
return configNodeInfo;
}
public NodeInfo setConfigNodeInfo(ConfigNodeInfo configNodeInfo) {
this.configNodeInfo = configNodeInfo;
return this;
}
public MachineInfo getMachineInfo() {
return machineInfo;
}
public NodeInfo setMachineInfo(MachineInfo machineInfo) {
this.machineInfo = machineInfo;
return this;
}
public Map<String, String> getCheatWitnessInfoMap() {
return cheatWitnessInfoMap;
}
public NodeInfo setCheatWitnessInfoMap(
Map<String, String> cheatWitnessInfoMap) {
this.cheatWitnessInfoMap = cheatWitnessInfoMap;
return this;
}
public Protocol.NodeInfo transferToProtoEntity() {
Protocol.NodeInfo.Builder builder = Protocol.NodeInfo.newBuilder();
builder.setBeginSyncNum(getBeginSyncNum());
builder.setBlock(getBlock());
builder.setSolidityBlock(getSolidityBlock());
builder.setCurrentConnectCount(getCurrentConnectCount());
builder.setActiveConnectCount(getActiveConnectCount());
builder.setPassiveConnectCount(getPassiveConnectCount());
builder.setTotalFlow(getTotalFlow());
builder.putAllCheatWitnessInfoMap(getCheatWitnessInfoMap());
for (PeerInfo peerInfo : getPeerList()) {
Protocol.NodeInfo.PeerInfo.Builder peerInfoBuilder = Protocol.NodeInfo.PeerInfo.newBuilder();
peerInfoBuilder.setLastSyncBlock(peerInfo.getLastSyncBlock());
peerInfoBuilder.setRemainNum(peerInfo.getRemainNum());
peerInfoBuilder.setLastBlockUpdateTime(peerInfo.getLastBlockUpdateTime());
peerInfoBuilder.setSyncFlag(peerInfo.isSyncFlag());
peerInfoBuilder.setHeadBlockTimeWeBothHave(peerInfo.getHeadBlockTimeWeBothHave());
peerInfoBuilder.setNeedSyncFromPeer(peerInfo.isSyncFlag());
peerInfoBuilder.setNeedSyncFromUs(peerInfo.isNeedSyncFromUs());
peerInfoBuilder.setHost(peerInfo.getHost());
peerInfoBuilder.setPort(peerInfo.getPort());
peerInfoBuilder.setNodeId(peerInfo.getNodeId());
peerInfoBuilder.setConnectTime(peerInfo.getConnectTime());
peerInfoBuilder.setAvgLatency(peerInfo.getAvgLatency());
peerInfoBuilder.setSyncToFetchSize(peerInfo.getSyncToFetchSize());
peerInfoBuilder.setSyncToFetchSizePeekNum(peerInfo.getSyncToFetchSizePeekNum());
peerInfoBuilder.setSyncBlockRequestedSize(peerInfo.getSyncBlockRequestedSize());
peerInfoBuilder.setUnFetchSynNum(peerInfo.getUnFetchSynNum());
peerInfoBuilder.setBlockInPorcSize(peerInfo.getBlockInPorcSize());
peerInfoBuilder.setHeadBlockWeBothHave(peerInfo.getHeadBlockWeBothHave());
peerInfoBuilder.setIsActive(peerInfo.isActive());
peerInfoBuilder.setScore(peerInfo.getScore());
peerInfoBuilder.setNodeCount(peerInfo.getNodeCount());
peerInfoBuilder.setInFlow(peerInfo.getInFlow());
peerInfoBuilder.setDisconnectTimes(peerInfo.getDisconnectTimes());
peerInfoBuilder.setLocalDisconnectReason(peerInfo.getLocalDisconnectReason());
peerInfoBuilder.setRemoteDisconnectReason(peerInfo.getRemoteDisconnectReason());
builder.addPeerInfoList(peerInfoBuilder.build());
}
ConfigNodeInfo configNodeInfo = getConfigNodeInfo();
if (configNodeInfo != null) {
Protocol.NodeInfo.ConfigNodeInfo.Builder configBuilder = Protocol.NodeInfo.ConfigNodeInfo
.newBuilder();
configBuilder.setCodeVersion(configNodeInfo.getCodeVersion());
configBuilder.setP2PVersion(configNodeInfo.getP2pVersion());
configBuilder.setListenPort(configNodeInfo.getListenPort());
configBuilder.setDiscoverEnable(configNodeInfo.isDiscoverEnable());
configBuilder.setActiveNodeSize(configNodeInfo.getActiveNodeSize());
configBuilder.setPassiveNodeSize(configNodeInfo.getPassiveNodeSize());
configBuilder.setSendNodeSize(configNodeInfo.getSendNodeSize());
configBuilder.setMaxConnectCount(configNodeInfo.getMaxConnectCount());
configBuilder.setSameIpMaxConnectCount(configNodeInfo.getSameIpMaxConnectCount());
configBuilder.setBackupListenPort(configNodeInfo.getBackupListenPort());
configBuilder.setBackupMemberSize(configNodeInfo.getBackupMemberSize());
configBuilder.setBackupPriority(configNodeInfo.getBackupPriority());
configBuilder.setDbVersion(configNodeInfo.getDbVersion());
configBuilder.setMinParticipationRate(configNodeInfo.getMinParticipationRate());
configBuilder.setSupportConstant(configNodeInfo.isSupportConstant());
configBuilder.setMinTimeRatio(configNodeInfo.getMinTimeRatio());
configBuilder.setMaxTimeRatio(configNodeInfo.getMaxTimeRatio());
configBuilder.setAllowCreationOfContracts(configNodeInfo.getAllowCreationOfContracts());
configBuilder.setAllowAdaptiveEnergy(configNodeInfo.getAllowAdaptiveEnergy());
builder.setConfigNodeInfo(configBuilder.build());
}
MachineInfo machineInfo = getMachineInfo();
if (machineInfo != null) {
Protocol.NodeInfo.MachineInfo.Builder machineBuilder = Protocol.NodeInfo.MachineInfo
.newBuilder();
machineBuilder.setThreadCount(machineInfo.getThreadCount());
machineBuilder.setDeadLockThreadCount(machineInfo.getDeadLockThreadCount());
machineBuilder.setCpuCount(machineInfo.getCpuCount());
machineBuilder.setTotalMemory(machineInfo.getTotalMemory());
machineBuilder.setFreeMemory(machineInfo.getFreeMemory());
machineBuilder.setCpuRate(machineInfo.getCpuRate());
machineBuilder.setJavaVersion(machineInfo.getJavaVersion());
machineBuilder.setOsName(machineInfo.getOsName());
machineBuilder.setJvmTotalMemoery(machineInfo.getJvmTotalMemoery());
machineBuilder.setJvmFreeMemory(machineInfo.getJvmFreeMemory());
machineBuilder.setProcessCpuRate(machineInfo.getProcessCpuRate());
for (MemoryDescInfo memoryDescInfo : machineInfo.getMemoryDescInfoList()) {
Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder descBuilder = Protocol.NodeInfo.MachineInfo.MemoryDescInfo
.newBuilder();
descBuilder.setName(memoryDescInfo.getName());
descBuilder.setInitSize(memoryDescInfo.getInitSize());
descBuilder.setUseSize(memoryDescInfo.getUseSize());
descBuilder.setMaxSize(memoryDescInfo.getMaxSize());
descBuilder.setUseRate(memoryDescInfo.getUseRate());
machineBuilder.addMemoryDescInfoList(descBuilder.build());
}
for (DeadLockThreadInfo deadLockThreadInfo : machineInfo.getDeadLockThreadInfoList()) {
Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder deadBuilder = Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo
.newBuilder();
deadBuilder.setName(deadLockThreadInfo.getName());
deadBuilder.setLockName(deadLockThreadInfo.getLockName());
deadBuilder.setLockOwner(deadLockThreadInfo.getLockOwner());
deadBuilder.setState(deadLockThreadInfo.getState());
deadBuilder.setBlockTime(deadLockThreadInfo.getBlockTime());
deadBuilder.setWaitTime(deadLockThreadInfo.getWaitTime());
deadBuilder.setStackTrace(deadLockThreadInfo.getStackTrace());
machineBuilder.addDeadLockThreadInfoList(deadBuilder.build());
}
builder.setMachineInfo(machineBuilder.build());
}
return builder.build();
}
}