whatap 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +32 -78
  2. package/lib/conf/conf-sys-mon.js +101 -0
  3. package/lib/conf/config-default.js +10 -3
  4. package/lib/conf/configure.js +369 -349
  5. package/lib/conf/license.js +1 -1
  6. package/lib/control/cmd-config.js +24 -0
  7. package/lib/control/control-handler.js +367 -0
  8. package/lib/control/packagectr-helper.js +34 -3
  9. package/lib/core/agent.js +176 -882
  10. package/lib/core/interceptor.js +6 -6
  11. package/lib/core/request-agent.js +27 -0
  12. package/lib/core/shimmer.js +82 -36
  13. package/lib/counter/counter-manager.js +79 -8
  14. package/lib/counter/meter/meter-activex.js +67 -0
  15. package/lib/counter/meter/meter-httpc.js +57 -0
  16. package/lib/counter/meter/meter-resource.js +9 -0
  17. package/lib/counter/meter/meter-service.js +168 -0
  18. package/lib/counter/meter/meter-socket.io.js +51 -0
  19. package/lib/counter/meter/meter-sql.js +71 -0
  20. package/lib/counter/meter/meter-users.js +58 -0
  21. package/lib/counter/meter.js +183 -0
  22. package/lib/counter/task/activetransaction.js +68 -17
  23. package/lib/counter/task/agentinfo.js +107 -0
  24. package/lib/{system → counter/task}/gc-action.js +27 -74
  25. package/lib/counter/task/gcstat.js +34 -0
  26. package/lib/counter/task/heapmem.js +25 -0
  27. package/lib/counter/task/httpc.js +76 -0
  28. package/lib/counter/task/metering-info.js +125 -0
  29. package/lib/counter/task/proc-cpu.js +29 -0
  30. package/lib/counter/task/realtimeuser.js +31 -0
  31. package/lib/counter/task/res/systemECSTask.js +39 -0
  32. package/lib/counter/task/res/systemKubeTask.js +53 -0
  33. package/lib/counter/task/res/util/awsEcsClientThread.js +218 -0
  34. package/lib/counter/task/res/util/linuxProcStatUtil.js +14 -0
  35. package/lib/counter/task/res-sys-cpu.js +62 -0
  36. package/lib/counter/task/service.js +202 -0
  37. package/lib/counter/task/socketio.js +30 -0
  38. package/lib/counter/task/sql.js +105 -0
  39. package/lib/counter/task/systemperf.js +43 -0
  40. package/lib/data/datapack-sender.js +289 -0
  41. package/lib/data/dataprofile-agent.js +162 -0
  42. package/lib/data/datatext-agent.js +135 -0
  43. package/lib/data/event-level.js +15 -0
  44. package/lib/data/test.js +49 -0
  45. package/lib/data/zipprofile.js +197 -0
  46. package/lib/env/constants.js +21 -0
  47. package/lib/error/error-handler.js +437 -0
  48. package/lib/io/data-inputx.js +13 -3
  49. package/lib/io/data-outputx.js +268 -206
  50. package/lib/kube/kube-client.js +144 -0
  51. package/lib/lang/text-types.js +58 -0
  52. package/lib/logger.js +6 -6
  53. package/lib/logsink/line-log-util.js +87 -0
  54. package/lib/logsink/line-log.js +12 -0
  55. package/lib/logsink/log-sender.js +78 -0
  56. package/lib/logsink/log-tracer.js +40 -0
  57. package/lib/logsink/sender-util.js +56 -0
  58. package/lib/logsink/zip/zip-send.js +177 -0
  59. package/lib/net/netflag.js +55 -0
  60. package/lib/net/receiver.js +66 -0
  61. package/lib/net/security-master.js +139 -20
  62. package/lib/net/sender.js +141 -0
  63. package/lib/net/tcp-return.js +18 -0
  64. package/lib/net/tcp-session.js +286 -0
  65. package/lib/net/tcpreq-client-proxy.js +70 -0
  66. package/lib/net/tcprequest-mgr.js +58 -0
  67. package/lib/observers/apollo-server-observer.js +33 -27
  68. package/lib/observers/cluster-observer.js +22 -0
  69. package/lib/observers/express-observer.js +215 -0
  70. package/lib/observers/file-observer.js +184 -0
  71. package/lib/observers/global-observer.js +155 -80
  72. package/lib/observers/grpc-observer.js +336 -0
  73. package/lib/observers/http-observer.js +666 -236
  74. package/lib/observers/maria-observer.js +204 -362
  75. package/lib/observers/memcached-observer.js +56 -0
  76. package/lib/observers/mongo-observer.js +317 -0
  77. package/lib/observers/mongodb-observer.js +169 -226
  78. package/lib/observers/mongoose-observer.js +518 -323
  79. package/lib/observers/mssql-observer.js +177 -418
  80. package/lib/observers/mysql-observer.js +342 -449
  81. package/lib/observers/mysql2-observer.js +396 -358
  82. package/lib/observers/net-observer.js +77 -0
  83. package/lib/observers/oracle-observer.js +559 -384
  84. package/lib/observers/pgsql-observer.js +231 -489
  85. package/lib/observers/prisma-observer.js +303 -92
  86. package/lib/observers/process-observer.js +79 -35
  87. package/lib/observers/promise-observer.js +31 -0
  88. package/lib/observers/redis-observer.js +166 -331
  89. package/lib/observers/schedule-observer.js +67 -0
  90. package/lib/observers/socket.io-observer.js +226 -187
  91. package/lib/observers/stream-observer.js +19 -0
  92. package/lib/observers/thrift-observer.js +197 -0
  93. package/lib/observers/websocket-observer.js +175 -301
  94. package/lib/pack/activestack-pack.js +55 -0
  95. package/lib/pack/apenum.js +8 -0
  96. package/lib/pack/counter-pack.js +3 -0
  97. package/lib/pack/errorsnap-pack.js +69 -0
  98. package/lib/pack/event-pack.js +54 -0
  99. package/lib/pack/hitmap-pack.js +63 -0
  100. package/lib/pack/hitmap-pack1.js +152 -0
  101. package/lib/pack/log-sink-pack.js +14 -52
  102. package/lib/pack/netstat.js +15 -0
  103. package/lib/pack/otype.js +7 -0
  104. package/lib/pack/profile-pack.js +49 -0
  105. package/lib/pack/realtimeuser-pack.js +41 -0
  106. package/lib/pack/stat-general-pack.js +96 -0
  107. package/lib/pack/staterror-pack.js +120 -0
  108. package/lib/pack/stathttpc-pack.js +66 -0
  109. package/lib/pack/stathttpc-rec.js +78 -0
  110. package/lib/pack/statremote-pack.js +46 -0
  111. package/lib/pack/statservice-pack.js +63 -0
  112. package/lib/pack/statservice-pack1.js +88 -0
  113. package/lib/pack/statservice-rec.js +292 -0
  114. package/lib/pack/statservice-rec_dep.js +151 -0
  115. package/lib/pack/statsql-pack.js +69 -0
  116. package/lib/pack/statsql-rec.js +100 -0
  117. package/lib/pack/statuseragent-pack.js +44 -0
  118. package/lib/pack/tagcount-pack.js +4 -4
  119. package/lib/pack/tagctr.js +15 -0
  120. package/lib/pack/text-pack.js +50 -0
  121. package/lib/pack/time-count.js +25 -0
  122. package/lib/pack/websocket.js +15 -0
  123. package/lib/pack/zip-pack.js +70 -0
  124. package/lib/pii/pii-item.js +31 -0
  125. package/lib/pii/pii-mask.js +174 -0
  126. package/lib/plugin/plugin-loadermanager.js +57 -0
  127. package/lib/plugin/plugin.js +75 -0
  128. package/lib/service/tx-record.js +332 -0
  129. package/lib/stat/stat-error.js +116 -0
  130. package/lib/stat/stat-httpc.js +98 -0
  131. package/lib/stat/stat-remote-ip.js +46 -0
  132. package/lib/stat/stat-remote-ipurl.js +88 -0
  133. package/lib/stat/stat-sql.js +113 -0
  134. package/lib/stat/stat-tranx.js +58 -0
  135. package/lib/stat/stat-tx-caller.js +160 -0
  136. package/lib/stat/stat-tx-domain.js +111 -0
  137. package/lib/stat/stat-tx-referer.js +112 -0
  138. package/lib/stat/stat-useragent.js +48 -0
  139. package/lib/stat/timingsender.js +76 -0
  140. package/lib/step/activestack-step.js +38 -0
  141. package/lib/step/dbc-step.js +36 -0
  142. package/lib/step/http-stepx.js +67 -0
  143. package/lib/step/message-step.js +40 -0
  144. package/lib/step/method-stepx.js +45 -0
  145. package/lib/step/resultset-step.js +40 -0
  146. package/lib/step/securemsg-step.js +44 -0
  147. package/lib/step/socket-step.js +46 -0
  148. package/lib/step/sql-stepx.js +68 -0
  149. package/lib/step/sqlxtype.js +16 -0
  150. package/lib/step/step.js +66 -0
  151. package/lib/step/stepenum.js +54 -0
  152. package/lib/topology/link.js +63 -0
  153. package/lib/topology/nodeinfo.js +123 -0
  154. package/lib/topology/status-detector.js +111 -0
  155. package/lib/trace/trace-context-manager.js +113 -25
  156. package/lib/trace/trace-context.js +21 -7
  157. package/lib/trace/trace-httpc.js +17 -11
  158. package/lib/trace/trace-sql.js +29 -21
  159. package/lib/util/anylist.js +103 -0
  160. package/lib/util/cardinality/hyperloglog.js +106 -0
  161. package/lib/util/cardinality/murmurhash.js +31 -0
  162. package/lib/util/cardinality/registerset.js +75 -0
  163. package/lib/util/errordata.js +21 -0
  164. package/lib/util/escape-literal-sql.js +5 -5
  165. package/lib/util/hashutil.js +18 -18
  166. package/lib/util/iputil_x.js +527 -0
  167. package/lib/util/keygen.js +0 -3
  168. package/lib/util/kube-util.js +73 -0
  169. package/lib/util/linkedset.js +1 -2
  170. package/lib/util/nodeutil.js +2 -1
  171. package/lib/util/paramsecurity.js +80 -0
  172. package/lib/util/pre-process.js +13 -0
  173. package/lib/util/process-seq.js +166 -0
  174. package/lib/util/property-util.js +36 -0
  175. package/lib/util/request-queue.js +70 -0
  176. package/lib/util/requestdouble-queue.js +72 -0
  177. package/lib/util/resourceprofile.js +157 -0
  178. package/lib/util/stop-watch.js +30 -0
  179. package/lib/util/system-util.js +10 -0
  180. package/lib/util/userid-util.js +57 -0
  181. package/lib/value/map-value.js +3 -2
  182. package/package.json +9 -4
  183. package/whatap.conf +1 -4
  184. package/agent/darwin/arm64/whatap_nodejs +0 -0
  185. package/agent/linux/amd64/whatap_nodejs +0 -0
  186. package/agent/linux/arm64/whatap_nodejs +0 -0
  187. package/build.txt +0 -4
  188. package/lib/observers/ioredis-observer.js +0 -294
  189. package/lib/udp/async_sender.js +0 -119
  190. package/lib/udp/index.js +0 -17
  191. package/lib/udp/packet_enum.js +0 -52
  192. package/lib/udp/packet_queue.js +0 -69
  193. package/lib/udp/packet_type_enum.js +0 -33
  194. package/lib/udp/param_def.js +0 -72
  195. package/lib/udp/udp_session.js +0 -336
  196. package/lib/util/sql-util.js +0 -178
  197. package/lib/util/trace-helper.js +0 -91
  198. package/lib/util/transfer.js +0 -58
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Copyright 2016 the WHATAP project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ var PackEnum = require('./packenum'),
8
+ Pack = require('./pack'),
9
+ BitUtil = require('../util/bitutil'),
10
+ DataOutputX = require('../io/data-outputx'),
11
+ DataInputX = require('../io/data-inputx'),
12
+ Long = require('long');
13
+
14
+ function ErrorRec() {
15
+ this.classHash = 0;
16
+ this.service = 0;
17
+ this.snapSeq = Long.ZERO;
18
+ this.msg = 0;
19
+ this.count = 0;
20
+
21
+ this.merge = function(rec) {
22
+ if(rec instanceof ErrorRec) {
23
+ this.count += rec.count;
24
+ }
25
+ };
26
+
27
+ this.getKey = function () {
28
+ return BitUtil.composite(this.classHash, this.service);
29
+ }
30
+ }
31
+
32
+ function StatErrorPack() {
33
+ Pack.call(this);
34
+ this.records = null;
35
+ this.record_count = 0;
36
+
37
+ this.setRecords = function(size /*int*/, items /*Enumeration<ErrorRec>*/) {
38
+ var dout = new DataOutputX();
39
+ dout.writeShort(size);
40
+
41
+ while(items.hasMoreElements()) {
42
+ StatErrorPack.writeRec(dout, items.nextElement());
43
+ }
44
+ /*
45
+ for (i = 0; i < size; i++) {
46
+ StatErrorPack.writeRec(dout, items.nextElement());
47
+ }
48
+ */
49
+ this.records = dout.toByteArray();
50
+ this.record_count = size;
51
+ return this;
52
+ };
53
+
54
+ this.getRecords = function() {
55
+ var items = [];
56
+ if (this.records == null ) {
57
+ return null;
58
+ }
59
+
60
+ var din = new DataInputX(this.records);
61
+ var i;
62
+ for (i = 0; i < din.readShort(); i++) {
63
+ items.push(StatErrorPack.readRec(din));
64
+ }
65
+ return items;
66
+ };
67
+ }
68
+
69
+
70
+ StatErrorPack.writeRec = function(dout, m){
71
+ if(m instanceof ErrorRec) {
72
+ dout.writeInt(m.classHash);
73
+ dout.writeInt(m.service);
74
+ dout.writeLong(m.snapSeq);
75
+ dout.writeDecimal(m.msg);
76
+ dout.writeDecimal(m.count);
77
+ }
78
+ };
79
+
80
+ StatErrorPack.readRec = function(din) {
81
+ var m = new ErrorRec();
82
+ m.classHash = din.readInt();
83
+ m.service = din.readInt();
84
+ m.snapSeq = din.readLong();
85
+ m.msg = din.readDecNumber();
86
+ m.count = din.readDecNumber();
87
+ return m;
88
+ };
89
+
90
+ StatErrorPack.prototype = new Pack();
91
+ StatErrorPack.prototype.constructor = StatErrorPack;
92
+
93
+ StatErrorPack.prototype.getPackType = function() {
94
+ return PackEnum.STAT_ERROR;
95
+ };
96
+
97
+ StatErrorPack.prototype.write = function(dout) {
98
+ Pack.prototype.write.call(this, dout);
99
+ dout.writeBlob(this.records);
100
+ dout.writeDecimal(this.record_count);
101
+ };
102
+
103
+ StatErrorPack.prototype.read = function(din) {
104
+ Pack.prototype.read.call(this, din);
105
+ this.records = din.readBlob();
106
+ this.record_count = din.readDecNumber();
107
+ return this;
108
+ };
109
+
110
+ StatErrorPack.prototype.toString = function() {
111
+ return 'StatError '
112
+ + Pack.prototype.toString.call(this)
113
+ + ', records='
114
+ + this.record_count
115
+ + ", bytes="
116
+ + (this.records != null ? this.records.length : 0);
117
+ };
118
+
119
+ exports.ErrorRec = ErrorRec;
120
+ exports.StatErrorPack = StatErrorPack;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Copyright 2016 the WHATAP project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ var Pack = require('./pack'),
8
+ PackEnum = require('./packenum'),
9
+ DataOutputX = require('../io/data-outputx'),
10
+ DataInputX = require('../io/data-inputx'),
11
+ HttpcRec = require('./stathttpc-rec');
12
+
13
+ function StatHttpcPack() {
14
+ Pack.call(this);
15
+
16
+ this.records = null; /*byte[]*/
17
+ this.record_count = 0; /*int*/
18
+ }
19
+
20
+ StatHttpcPack.prototype = new Pack();
21
+ StatHttpcPack.prototype.constructor = StatHttpcPack;
22
+ StatHttpcPack.prototype.getPackType = function(){
23
+ return PackEnum.STAT_HTTPC;
24
+ };
25
+ StatHttpcPack.prototype.setRecords = function(size /*int*/, items /*Enumeration<HttpcRec>*/) {
26
+ var dout = new DataOutputX();
27
+ dout.writeShort(size);
28
+ while(items.hasMoreElements()) {
29
+ HttpcRec.writeRec(dout, items.nextElement());
30
+ }
31
+ /*
32
+ for (var i = 0; i < size; i++) {
33
+ items.nextElement().write(dout);
34
+ }
35
+ */
36
+ this.records = dout.toByteArray();
37
+ this.record_count = size;
38
+ return this;
39
+ };
40
+
41
+ StatHttpcPack.prototype.getRecords = function() {
42
+ var items = [];
43
+ if (this.records == null ) {
44
+ return null;
45
+ }
46
+
47
+ var din = new DataInputX(this.records);
48
+ for (var i = 0; i < din.readShort(); i++) {
49
+ items.push(new HttpcRec().read(din));
50
+ }
51
+ return items;
52
+ };
53
+ StatHttpcPack.prototype.write = function(dout) {
54
+ Pack.prototype.write.call(this, dout);
55
+ dout.writeBlob(this.records);
56
+ dout.writeDecimal(this.record_count);
57
+ };
58
+
59
+ StatHttpcPack.prototype.read = function(din) {
60
+ Pack.prototype.read.call(this, din);
61
+ this.records = din.readBlob();
62
+ this.record_count = din.readDecNumber();
63
+ return this;
64
+ };
65
+
66
+ module.exports = StatHttpcPack;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Copyright 2016 the WHATAP project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ var BitUtil = require('../util/bitutil'),
8
+ DataOutputX = require('../io/data-outputx'),
9
+ DataInputX = require('../io/data-inputx');
10
+
11
+ function HttpcRec(){
12
+ this.url = 0;
13
+ this.host = 0;
14
+ this.port = 0;
15
+ this.count_total = 0;
16
+ this.count_error = 0;
17
+ this.time_sum = 0;
18
+ this.time_std = 0;
19
+ this.time_min = 0;
20
+ this.time_max = 0;
21
+ this.service = 0;
22
+ }
23
+ HttpcRec.prototype.merge = function (o) {
24
+ this.count_total += o.count_total;
25
+ this.count_error += o.count_error;
26
+ this.time_sum += o.time_sum;
27
+ this.time_std = o.time_std;
28
+ this.time_max = Math.max(this.time_max, o.time_max);
29
+ this.time_min = Math.min(this.time_min, o.time_min);
30
+ };
31
+
32
+ HttpcRec.prototype.write = function(dout){
33
+ dout.writeInt(this.url);
34
+ dout.writeInt(this.host);
35
+ dout.writeInt(this.port);
36
+ dout.writeDecimal(this.count_total);
37
+ dout.writeDecimal(this.count_error);
38
+ dout.writeDecimal(-1);
39
+ dout.writeDecimal(this.time_sum);
40
+ dout.writeDecimal(this.time_std);
41
+ dout.writeDecimal(this.time_min);
42
+ dout.writeDecimal(this.time_max);
43
+
44
+ dout.writeDecimal(this.service);
45
+ };
46
+ HttpcRec.prototype.read = function(din) {
47
+ this.url = din.readInt();
48
+ this.host = din.readInt();
49
+ this.port = din.readInt();
50
+ this.count_total = din.readDecNumber();
51
+ this.count_error = din.readDecNumber();
52
+ var ver = din.readDecNumber();
53
+ this.time_sum = din.readDecNumber();
54
+ this.time_std = din.readDecNumber();
55
+ this.time_min = din.readDecNumber();
56
+ this.time_max = din.readDecNumber();
57
+ if(ver>=0){
58
+ return this;
59
+ }
60
+ this.service = din.readDecNumber();
61
+ return this;
62
+ };
63
+ HttpcRec.writeRec = function(dout , m){
64
+ dout.writeInt(m.url);
65
+ dout.writeInt(m.host);
66
+ dout.writeInt(m.port);
67
+ dout.writeDecimal(m.count_total);
68
+ dout.writeDecimal(m.count_error);
69
+ dout.writeDecimal(-1);
70
+ dout.writeDecimal(m.time_sum);
71
+ dout.writeDecimal(m.time_std);
72
+ dout.writeDecimal(m.time_min);
73
+ dout.writeDecimal(m.time_max);
74
+
75
+ dout.writeDecimal(m.service);
76
+ };
77
+
78
+ module.exports = HttpcRec;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright 2016 the WHATAP project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ var Pack = require('./pack'),
8
+ PackEnum = require('./packenum'),
9
+ IntIntMap = require('../util/intint-map');
10
+
11
+ function StatRemoteIpPack(){
12
+ Pack.call(this);
13
+ this.iptable = new IntIntMap();
14
+ }
15
+
16
+ StatRemoteIpPack.prototype = new Pack();
17
+ StatRemoteIpPack.prototype.constructor = StatRemoteIpPack;
18
+ StatRemoteIpPack.prototype.getPackType = function () {
19
+ return PackEnum.STAT_REMOTE_IP;
20
+ };
21
+ StatRemoteIpPack.prototype.write = function(dout) {
22
+ Pack.prototype.write.call(this, dout);
23
+
24
+ dout.writeDecimal(this.iptable.size());
25
+ var en = this.iptable.entries();
26
+ while(en.hasMoreElements()) {
27
+ var e = en.nextElement();
28
+ dout.writeInt(e.getKey());
29
+ dout.writeInt(e.getValue());
30
+ }
31
+ };
32
+ StatRemoteIpPack.prototype.read = function(din) {
33
+ Pack.prototype.read.call(this, din);
34
+ var ip, count;
35
+ var cnt = din.readDecNumber();
36
+ this.iptable = new IntIntMap();
37
+
38
+ for(var i=0; i<cnt; i++) {
39
+ ip = din.readInt();
40
+ count = din.readInt();
41
+ this.iptable.put(ip, count);
42
+ }
43
+ return this;
44
+ };
45
+
46
+ module.exports = StatRemoteIpPack;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright 2016 the WHATAP project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ var Pack = require('./pack'),
8
+ PackEnum = require('./packenum'),
9
+ TransactionRec = require('./statservice-rec'),
10
+ DataOutputX = require('../io/data-outputx'),
11
+ DataInputX = require('../io/data-inputx');
12
+
13
+ function StatServicePack(){
14
+ Pack.call(this);
15
+
16
+ this.records = null; /*byte[]*/
17
+ this.record_count = 0; /*int*/
18
+
19
+ return this;
20
+ }
21
+
22
+ StatServicePack.prototype = new Pack();
23
+ StatServicePack.prototype.constructor = StatServicePack;
24
+ StatServicePack.prototype.getPackType = function(){
25
+ return PackEnum.STAT_SERVICE;
26
+ };
27
+ StatServicePack.prototype.write = function(dout){
28
+ Pack.prototype.write.call(this, dout);
29
+ dout.writeBlob(this.records);
30
+ dout.writeDecimal(this.record_count);
31
+ };
32
+ StatServicePack.prototype.read = function(din){
33
+ Pack.prototype.read.call(this, din);
34
+ this.records = din.readBlob();
35
+ this.record_count = din.readDecNumber();
36
+ return this;
37
+ };
38
+ StatServicePack.prototype.setRecords = function(size /*int*/, items /*Enumer<TransactionRec>*/) {
39
+ var dout = new DataOutputX();
40
+ dout.writeShort(size);
41
+ while(items.hasMoreElements()) {
42
+ TransactionRec.writeRec(dout, items.nextElement());
43
+ }
44
+ this.records = dout.toByteArray();
45
+ this.record_count = size;
46
+ return this;
47
+ };
48
+ StatServicePack.prototype.getRecords = function() {
49
+ var items = [];
50
+ if (this.records == null) {
51
+ return [];
52
+ }
53
+
54
+ var din = new DataInputX(this.records);
55
+ var cnt=din.readShort();
56
+ for (var i = 0; i < cnt; i++) {
57
+ // items.push(new TransactionRec().read(din));
58
+ items.push(TransactionRec.readRec(din));
59
+ }
60
+ return items;
61
+ };
62
+
63
+ module.exports = StatServicePack;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Copyright 2016 the WHATAP project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ var Pack = require('./pack'),
8
+ PackEnum = require('./packenum'),
9
+ TransactionRec = require('./statservice-rec'),
10
+ DataOutputX = require('../io/data-outputx'),
11
+ DataInputX = require('../io/data-inputx');
12
+
13
+ function StatServicePack1(){
14
+ Pack.call(this);
15
+
16
+ this.records = null; /*byte[]*/
17
+ this.record_count = 0; /*int*/
18
+
19
+ this.spec = 0;
20
+ return this;
21
+ }
22
+
23
+ StatServicePack1.prototype = new Pack();
24
+ StatServicePack1.prototype.constructor = StatServicePack1;
25
+
26
+ StatServicePack1.prototype.getPackType = function(){
27
+ return PackEnum.STAT_SERVICE_1;
28
+ };
29
+
30
+ StatServicePack1.prototype.write = function(dout){
31
+ Pack.prototype.write.call(this, dout);
32
+
33
+ dout.writeBlob(this.records);
34
+ dout.writeDecimal(this.record_count);
35
+
36
+ dout.writeByte(0);
37
+ dout.writeDecimal(this.spec);
38
+ };
39
+
40
+ StatServicePack1.prototype.read = function(din){
41
+ Pack.prototype.read.call(this, din);
42
+ this.records = din.readBlob();
43
+ this.record_count = din.readDecNumber();
44
+
45
+ var ver = din.readByte();
46
+ this.spec = din.readDecimal();
47
+
48
+ return this;
49
+ };
50
+
51
+ StatServicePack1.prototype.setRecords = function(size /*int*/, items /*Enumer<TransactionRec>*/) {
52
+ var dout = new DataOutputX();
53
+ dout.writeShort(size);
54
+
55
+ while(items.hasMoreElements()) {
56
+ let aa = items.nextElement();
57
+ TransactionRec.writeRec(dout, aa);
58
+ }
59
+
60
+ this.records = dout.toByteArray();
61
+ this.record_count = size;
62
+ return this;
63
+ };
64
+
65
+ StatServicePack1.prototype.getRecords = function() {
66
+ var items = [];
67
+ if (this.records == null) {
68
+ return [];
69
+ }
70
+
71
+ var din = new DataInputX(this.records);
72
+ var size = din.readShort();
73
+ for (var i = 0; i < size; i++) {
74
+ items.push(new TransactionRec().read(din));
75
+ }
76
+ return items;
77
+ };
78
+
79
+ StatServicePack1.prototype.toString = function() {
80
+ return 'StatServicePack1 '
81
+ + Pack.prototype.toString.call(this)
82
+ + ', records='
83
+ + this.record_count
84
+ + ", bytes="
85
+ + (this.records != null ? this.records.length : 0);
86
+ };
87
+
88
+ module.exports = StatServicePack1;