whatap 1.0.2 → 1.0.3-canary.0

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 +77 -33
  2. package/agent/darwin/arm64/whatap_nodejs +0 -0
  3. package/agent/linux/amd64/whatap_nodejs +0 -0
  4. package/agent/linux/arm64/whatap_nodejs +0 -0
  5. package/build.txt +4 -0
  6. package/lib/conf/config-default.js +3 -10
  7. package/lib/conf/configure.js +349 -369
  8. package/lib/conf/license.js +1 -1
  9. package/lib/control/packagectr-helper.js +3 -34
  10. package/lib/core/agent.js +888 -176
  11. package/lib/core/interceptor.js +6 -6
  12. package/lib/core/shimmer.js +36 -82
  13. package/lib/counter/counter-manager.js +8 -79
  14. package/lib/counter/task/activetransaction.js +17 -68
  15. package/lib/io/data-inputx.js +3 -13
  16. package/lib/io/data-outputx.js +206 -268
  17. package/lib/logger.js +6 -6
  18. package/lib/net/security-master.js +20 -139
  19. package/lib/observers/apollo-server-observer.js +27 -33
  20. package/lib/observers/global-observer.js +80 -155
  21. package/lib/observers/http-observer.js +236 -666
  22. package/lib/observers/ioredis-observer.js +294 -0
  23. package/lib/observers/maria-observer.js +362 -204
  24. package/lib/observers/mongodb-observer.js +226 -169
  25. package/lib/observers/mongoose-observer.js +323 -518
  26. package/lib/observers/mssql-observer.js +418 -177
  27. package/lib/observers/mysql-observer.js +449 -342
  28. package/lib/observers/mysql2-observer.js +358 -396
  29. package/lib/observers/oracle-observer.js +384 -559
  30. package/lib/observers/pgsql-observer.js +489 -231
  31. package/lib/observers/prisma-observer.js +92 -303
  32. package/lib/observers/process-observer.js +35 -79
  33. package/lib/observers/redis-observer.js +331 -166
  34. package/lib/observers/socket.io-observer.js +187 -226
  35. package/lib/observers/websocket-observer.js +301 -175
  36. package/lib/pack/counter-pack.js +0 -3
  37. package/lib/pack/log-sink-pack.js +52 -14
  38. package/lib/pack/tagcount-pack.js +4 -4
  39. package/lib/{counter/task → system}/gc-action.js +74 -27
  40. package/lib/trace/trace-context-manager.js +25 -113
  41. package/lib/trace/trace-context.js +7 -21
  42. package/lib/trace/trace-httpc.js +11 -17
  43. package/lib/trace/trace-sql.js +21 -29
  44. package/lib/udp/async_sender.js +119 -0
  45. package/lib/udp/index.js +17 -0
  46. package/lib/udp/packet_enum.js +52 -0
  47. package/lib/udp/packet_queue.js +69 -0
  48. package/lib/udp/packet_type_enum.js +33 -0
  49. package/lib/udp/param_def.js +72 -0
  50. package/lib/udp/udp_session.js +336 -0
  51. package/lib/util/escape-literal-sql.js +5 -5
  52. package/lib/util/hashutil.js +18 -18
  53. package/lib/util/keygen.js +3 -0
  54. package/lib/util/linkedset.js +2 -1
  55. package/lib/util/nodeutil.js +1 -2
  56. package/lib/util/sql-util.js +178 -0
  57. package/lib/util/trace-helper.js +91 -0
  58. package/lib/util/transfer.js +58 -0
  59. package/lib/value/map-value.js +2 -3
  60. package/package.json +5 -9
  61. package/whatap.conf +4 -1
  62. package/lib/conf/conf-sys-mon.js +0 -101
  63. package/lib/control/cmd-config.js +0 -24
  64. package/lib/control/control-handler.js +0 -367
  65. package/lib/core/request-agent.js +0 -27
  66. package/lib/counter/meter/meter-activex.js +0 -67
  67. package/lib/counter/meter/meter-httpc.js +0 -57
  68. package/lib/counter/meter/meter-resource.js +0 -9
  69. package/lib/counter/meter/meter-service.js +0 -168
  70. package/lib/counter/meter/meter-socket.io.js +0 -51
  71. package/lib/counter/meter/meter-sql.js +0 -71
  72. package/lib/counter/meter/meter-users.js +0 -58
  73. package/lib/counter/meter.js +0 -183
  74. package/lib/counter/task/agentinfo.js +0 -107
  75. package/lib/counter/task/gcstat.js +0 -34
  76. package/lib/counter/task/heapmem.js +0 -25
  77. package/lib/counter/task/httpc.js +0 -76
  78. package/lib/counter/task/metering-info.js +0 -125
  79. package/lib/counter/task/proc-cpu.js +0 -29
  80. package/lib/counter/task/realtimeuser.js +0 -31
  81. package/lib/counter/task/res/systemECSTask.js +0 -39
  82. package/lib/counter/task/res/systemKubeTask.js +0 -53
  83. package/lib/counter/task/res/util/awsEcsClientThread.js +0 -218
  84. package/lib/counter/task/res/util/linuxProcStatUtil.js +0 -14
  85. package/lib/counter/task/res-sys-cpu.js +0 -62
  86. package/lib/counter/task/service.js +0 -202
  87. package/lib/counter/task/socketio.js +0 -30
  88. package/lib/counter/task/sql.js +0 -105
  89. package/lib/counter/task/systemperf.js +0 -43
  90. package/lib/data/datapack-sender.js +0 -289
  91. package/lib/data/dataprofile-agent.js +0 -162
  92. package/lib/data/datatext-agent.js +0 -135
  93. package/lib/data/event-level.js +0 -15
  94. package/lib/data/test.js +0 -49
  95. package/lib/data/zipprofile.js +0 -197
  96. package/lib/env/constants.js +0 -21
  97. package/lib/error/error-handler.js +0 -437
  98. package/lib/kube/kube-client.js +0 -144
  99. package/lib/lang/text-types.js +0 -58
  100. package/lib/logsink/line-log-util.js +0 -87
  101. package/lib/logsink/line-log.js +0 -12
  102. package/lib/logsink/log-sender.js +0 -78
  103. package/lib/logsink/log-tracer.js +0 -40
  104. package/lib/logsink/sender-util.js +0 -56
  105. package/lib/logsink/zip/zip-send.js +0 -177
  106. package/lib/net/netflag.js +0 -55
  107. package/lib/net/receiver.js +0 -66
  108. package/lib/net/sender.js +0 -141
  109. package/lib/net/tcp-return.js +0 -18
  110. package/lib/net/tcp-session.js +0 -286
  111. package/lib/net/tcpreq-client-proxy.js +0 -70
  112. package/lib/net/tcprequest-mgr.js +0 -58
  113. package/lib/observers/cluster-observer.js +0 -22
  114. package/lib/observers/express-observer.js +0 -215
  115. package/lib/observers/file-observer.js +0 -184
  116. package/lib/observers/grpc-observer.js +0 -336
  117. package/lib/observers/memcached-observer.js +0 -56
  118. package/lib/observers/mongo-observer.js +0 -317
  119. package/lib/observers/net-observer.js +0 -77
  120. package/lib/observers/promise-observer.js +0 -31
  121. package/lib/observers/schedule-observer.js +0 -67
  122. package/lib/observers/stream-observer.js +0 -19
  123. package/lib/observers/thrift-observer.js +0 -197
  124. package/lib/pack/activestack-pack.js +0 -55
  125. package/lib/pack/apenum.js +0 -8
  126. package/lib/pack/errorsnap-pack.js +0 -69
  127. package/lib/pack/event-pack.js +0 -54
  128. package/lib/pack/hitmap-pack.js +0 -63
  129. package/lib/pack/hitmap-pack1.js +0 -152
  130. package/lib/pack/netstat.js +0 -15
  131. package/lib/pack/otype.js +0 -7
  132. package/lib/pack/profile-pack.js +0 -49
  133. package/lib/pack/realtimeuser-pack.js +0 -41
  134. package/lib/pack/stat-general-pack.js +0 -96
  135. package/lib/pack/staterror-pack.js +0 -120
  136. package/lib/pack/stathttpc-pack.js +0 -66
  137. package/lib/pack/stathttpc-rec.js +0 -78
  138. package/lib/pack/statremote-pack.js +0 -46
  139. package/lib/pack/statservice-pack.js +0 -63
  140. package/lib/pack/statservice-pack1.js +0 -88
  141. package/lib/pack/statservice-rec.js +0 -292
  142. package/lib/pack/statservice-rec_dep.js +0 -151
  143. package/lib/pack/statsql-pack.js +0 -69
  144. package/lib/pack/statsql-rec.js +0 -100
  145. package/lib/pack/statuseragent-pack.js +0 -44
  146. package/lib/pack/tagctr.js +0 -15
  147. package/lib/pack/text-pack.js +0 -50
  148. package/lib/pack/time-count.js +0 -25
  149. package/lib/pack/websocket.js +0 -15
  150. package/lib/pack/zip-pack.js +0 -70
  151. package/lib/pii/pii-item.js +0 -31
  152. package/lib/pii/pii-mask.js +0 -174
  153. package/lib/plugin/plugin-loadermanager.js +0 -57
  154. package/lib/plugin/plugin.js +0 -75
  155. package/lib/service/tx-record.js +0 -332
  156. package/lib/stat/stat-error.js +0 -116
  157. package/lib/stat/stat-httpc.js +0 -98
  158. package/lib/stat/stat-remote-ip.js +0 -46
  159. package/lib/stat/stat-remote-ipurl.js +0 -88
  160. package/lib/stat/stat-sql.js +0 -113
  161. package/lib/stat/stat-tranx.js +0 -58
  162. package/lib/stat/stat-tx-caller.js +0 -160
  163. package/lib/stat/stat-tx-domain.js +0 -111
  164. package/lib/stat/stat-tx-referer.js +0 -112
  165. package/lib/stat/stat-useragent.js +0 -48
  166. package/lib/stat/timingsender.js +0 -76
  167. package/lib/step/activestack-step.js +0 -38
  168. package/lib/step/dbc-step.js +0 -36
  169. package/lib/step/http-stepx.js +0 -67
  170. package/lib/step/message-step.js +0 -40
  171. package/lib/step/method-stepx.js +0 -45
  172. package/lib/step/resultset-step.js +0 -40
  173. package/lib/step/securemsg-step.js +0 -44
  174. package/lib/step/socket-step.js +0 -46
  175. package/lib/step/sql-stepx.js +0 -68
  176. package/lib/step/sqlxtype.js +0 -16
  177. package/lib/step/step.js +0 -66
  178. package/lib/step/stepenum.js +0 -54
  179. package/lib/topology/link.js +0 -63
  180. package/lib/topology/nodeinfo.js +0 -123
  181. package/lib/topology/status-detector.js +0 -111
  182. package/lib/util/anylist.js +0 -103
  183. package/lib/util/cardinality/hyperloglog.js +0 -106
  184. package/lib/util/cardinality/murmurhash.js +0 -31
  185. package/lib/util/cardinality/registerset.js +0 -75
  186. package/lib/util/errordata.js +0 -21
  187. package/lib/util/iputil_x.js +0 -527
  188. package/lib/util/kube-util.js +0 -73
  189. package/lib/util/paramsecurity.js +0 -80
  190. package/lib/util/pre-process.js +0 -13
  191. package/lib/util/process-seq.js +0 -166
  192. package/lib/util/property-util.js +0 -36
  193. package/lib/util/request-queue.js +0 -70
  194. package/lib/util/requestdouble-queue.js +0 -72
  195. package/lib/util/resourceprofile.js +0 -157
  196. package/lib/util/stop-watch.js +0 -30
  197. package/lib/util/system-util.js +0 -10
  198. package/lib/util/userid-util.js +0 -57
@@ -1,197 +0,0 @@
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 TraceContextManager = require('../trace/trace-context-manager'),
8
- MethodStepX = require('../step/method-stepx'),
9
- DBCStep = require('../step/dbc-step'),
10
- ResultSetStep = require('../step/resultset-step'),
11
- DataTextAgent = require('../data/datatext-agent'),
12
- StatSql = require('../stat/stat-sql'),
13
- MeterSql = require('../counter/meter/meter-sql'),
14
- conf = require('../conf/configure'),
15
- IntKeyMap = require('../util/intkey-map'),
16
- EscapeLiteralSQL = require('../util/escape-literal-sql'),
17
- HashUtil = require('../util/hashutil'),
18
- StatError = require('../stat/stat-error'),
19
- TextTypes = require('../lang/text-types'),
20
- ParamSecurity = require('../util/paramsecurity'),
21
- Logger = require('../logger'),
22
- Buffer = require('buffer').Buffer;
23
-
24
- var ThriftObserver = function (agent) {
25
- this.agent = agent;
26
- this.packages = ['thrift'];
27
- };
28
-
29
-
30
- ThriftObserver.prototype.inject = function (mod, moduleName) {
31
- if (mod.__whatap_observe__) {
32
- return;
33
- }
34
- mod.__whatap_observe__ = true;
35
- Logger.initPrint("ThriftObserver");
36
- var self = this;
37
- var aop = self.agent.aop;
38
-
39
- if (conf.trx_profile_thrift_enabled == false) {
40
- return;
41
- }
42
-
43
- aop.both(mod, 'createConnection',
44
- createConnectionBeforeHook,
45
- createConnectionAfterHook);
46
-
47
- aop.both(mod, 'createSSLConnection',
48
- createConnectionBeforeHook,
49
- createConnectionAfterHook);
50
-
51
-
52
- function createConnectionBeforeHook(obj, args, lctx) {
53
- var ctx = lctx.context;
54
- if(ctx == null || ctx.db_opening) { return; }
55
-
56
- ctx.thrift_opeing = true;
57
-
58
- var dbc_step = new DBCStep();
59
- dbc_step.start_time = ctx.getElapsedTime();
60
- lctx.step = dbc_step;
61
-
62
- }
63
-
64
-
65
- function createConnectionAfterHook(obj, args, ret, lctx){
66
-
67
- var dbc, dbc_hash;
68
- if(args.length > 1) {
69
- var host = args[0];
70
- var port = args[1];
71
- //Open [DatabaseName] connection 메세지 보여줄때 필요함.
72
- dbc = 'thrift://';
73
- dbc += host || '';
74
- dbc += ':';
75
- dbc += port || '';
76
- dbc_hash = HashUtil.hashFromString(dbc);
77
- DataTextAgent.DBC.add(dbc_hash, dbc);
78
- DataTextAgent.METHOD.add(dbc_hash, dbc);
79
- DataTextAgent.ERROR.add(dbc_hash, dbc);
80
-
81
- ret.dbc_hash = dbc_hash;
82
- ret.dbc_string = dbc;
83
- }
84
-
85
- var ctx = lctx.context,
86
- step = lctx.step;
87
-
88
- // secureConnect, connect, error, close, timeout
89
-
90
- if (ctx == null || step == null) { return; }
91
-
92
- TraceContextManager.resume(ctx);
93
- step.hash = dbc_hash;
94
-
95
- ret.on('connect', connectComplete);
96
- ret.on('secureConnect', connectComplete);
97
-
98
- function connectComplete(obj, args){
99
- // var ctx = TraceContextManager.getCurrentContext();
100
- // var step = ctx.step;
101
-
102
- if (ctx == null || step == null) { return; }
103
-
104
- ctx.profile.push(step);
105
- }
106
-
107
- aop.before(ret, 'error', function (obj, args) {
108
-
109
- });
110
- }
111
-
112
- aop.both(mod, 'createClient',
113
- function(obj, args, lctx) {
114
-
115
- },
116
- function(obj, args, ret, lctx){
117
-
118
- var proto = ret.__proto__;
119
-
120
- var funcKeys = Object.keys(proto).map(function(key){
121
- if(proto[key] && proto[key].constructor == Function) {
122
- return key;
123
- }
124
- }).filter(function(key){ return key !== undefined })
125
-
126
- var dbc_hash = undefined;
127
- var dbc_string = undefined;
128
- if(args.length > 1){
129
- var conn = args[1];
130
- if(conn.dbc_hash){
131
- dbc_hash = conn.dbc_hash;
132
- dbc_string = conn.dbc_string;
133
- }
134
- }
135
-
136
- if(proto.__whatap_hook__ == true) return;
137
-
138
- funcKeys.forEach(function(key){
139
- var method_string = dbc_string + '/' + key;
140
- var method_hash = HashUtil.hashFromString(method_string);
141
- // DataTextAgent.DBC.add(dbc_hash, dbc);
142
- DataTextAgent.METHOD.add(method_hash, method_string);
143
-
144
- proto.__whatap_hook__ = true;
145
- aop.both(proto, key , startThriftFunc(method_hash, self.agent) ,
146
- endThriftFunc
147
- )
148
- })
149
- });
150
-
151
- var startThriftFunc = function (method_hash, agent) {
152
-
153
- return function (obj, args) {
154
- var ctx = TraceContextManager.getCurrentContext();
155
-
156
- if (ctx == null || args[0] == null) { return; }
157
- // if(args[0].sql == null && typeof args[0] != 'string') { return; }
158
-
159
- var method_step = new MethodStepX();
160
- method_step.start_time = ctx.getElapsedTime();
161
- method_step.hash = method_hash;
162
-
163
- ctx.profile.push(method_step);
164
- // ctx.sql_count++;
165
- }
166
- }
167
-
168
- var endThriftFunc = function (obj, args, ret, lctx) {
169
-
170
- if(args != undefined && args.length > 0 && args[args.length-1] !== undefined && args[args.length-1].constructor === Function){
171
- agent.aop.functionHook(args, -1, endHook);
172
- }else{
173
- endHook();
174
- }
175
- }
176
-
177
- function endHook(obj, args){
178
- var ctx = TraceContextManager.getCurrentContext();
179
- if(ctx == null ) { return; }
180
-
181
- TraceContextManager.resume(ctx._id);
182
-
183
- var laststep = ctx.profile.getLastSteps(1);
184
- if(laststep == null || laststep.length == 0) { return; }
185
-
186
- var step = laststep[0];
187
- step.elapsed = ctx.getElapsedTime() - step.start_time;
188
- ctx.sql_time += sql_step.elapsed;
189
- }
190
-
191
- aop.after(mod, ['createPool', 'createPoolCluster'], function (obj, args, ret) {
192
-
193
- });
194
-
195
- }
196
-
197
- exports.ThriftObserver = ThriftObserver;
@@ -1,55 +0,0 @@
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
- Long = require('long');
10
-
11
- function ActiveStackPack() {
12
- Pack.call(this);
13
-
14
- this.seq = Long.ZERO;
15
- this.txid = Long.ZERO;
16
- this.service = 0;
17
- this.elapsed = 0;
18
-
19
- this.callstack = [];
20
- this.callstack_hash = 0;
21
- }
22
-
23
- ActiveStackPack.prototype = new Pack();
24
- ActiveStackPack.prototype.constructor = ActiveStackPack;
25
- ActiveStackPack.prototype.getPackType = function () {
26
- return PackEnum.ACTIVESTACK_1;
27
- };
28
- ActiveStackPack.prototype.write = function(dout) {
29
- Pack.prototype.write.call(this, dout);
30
- dout.writeByte(1);
31
- dout.writeLong(this.seq);
32
- dout.writeLong(this.txid);
33
- dout.writeDecimal(this.service);
34
- dout.writeDecimal(this.callstack_hash);
35
- dout.writeIntArray(this.callstack);
36
- dout.writeDecimal(this.elapsed);
37
- };
38
- ActiveStackPack.prototype.read = function(din) {
39
-
40
- Pack.prototype.read.call(this, din);
41
- var ver= din.readByte();
42
- this.seq = din.readLong();
43
- this.txid = din.readLong();
44
- this.service = din.readDecNumber();
45
-
46
- this.callstack_hash = din.readDecNumber();
47
- this.callstack = din.readIntArray();
48
- if(ver>0){
49
- this.elapsed = din.readDecNumber();
50
- }
51
- return this;
52
- };
53
-
54
-
55
- module.exports = ActiveStackPack;
@@ -1,8 +0,0 @@
1
- exports.AP_JAVA = 1;
2
- exports.AP_NODE = 2;
3
- exports.AP_PYTHON = 3;
4
- exports.AP_PHP = 4;
5
- exports.AP_URL_ADM = 5;
6
- exports.BSM = 6;
7
- exports.WEB_CHECK = 9;
8
- exports.OTEL = 10;
@@ -1,69 +0,0 @@
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
- Step = require('../step/step'),
10
- DataOutputX = require('../io/data-outputx'),
11
- Long = require('long');
12
-
13
- function ErrorSnapPack1() {
14
- Pack.call(this);
15
- this.seq = Long.ZERO;
16
- this.profile = null;
17
- this.stack = null;
18
- this.append_type = 0;
19
- this.append_hash = 0;
20
- this.setProfile = function(steps){
21
- this.profile = Step.toBytes(steps);
22
- return this;
23
- };
24
- this.setStack = function(callstacks) {
25
- this.stack = new DataOutputX().writeIntArray(callstacks).toByteArray();
26
- return this;
27
- };
28
- this.getProfile = function() {
29
- return Step.toObjects(this.stack);
30
- };
31
- this.getStack = function() {
32
- if( this.stack == null || this.stack.length === 0 ) {
33
- return null;
34
- }
35
- return this.stack;
36
- }
37
- }
38
-
39
- ErrorSnapPack1.prototype = new Pack();
40
- ErrorSnapPack1.prototype.constructor = ErrorSnapPack1;
41
- ErrorSnapPack1.prototype.toString = function() {
42
- return "ErrorSnap " + Pack.prototype.toString.call(this)
43
- + ", profile_bytes="
44
- + ((this.profile != null) ? this.profile.length : 0)
45
- + " stack_bytes="
46
- + ((this.stack != null) ? this.stack.length : 0);
47
- };
48
- ErrorSnapPack1.prototype.getPackType = function () {
49
- return PackEnum.ERROR_SNAP_1;
50
- };
51
- ErrorSnapPack1.prototype.write = function(dout) {
52
- Pack.prototype.write.call(this, dout);
53
- dout.writeLong(this.seq);
54
- dout.writeBlob(this.profile);
55
- dout.writeBlob(this.stack);
56
- dout.writeByte(this.append_type);
57
- dout.writeDecimal(this.append_hash);
58
- };
59
- ErrorSnapPack1.prototype.read = function(din) {
60
- Pack.prototype.read.call(this, din);
61
- this.seq = din.readLong();
62
- this.profile = din.readBlob();
63
- this.stack = din.readBlob();
64
- this.append_type = din.readByte();
65
- this.append_hash = din.readDecNumber();
66
- return this;
67
- };
68
-
69
- module.exports = ErrorSnapPack1;
@@ -1,54 +0,0 @@
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
-
10
- function EventPack() {
11
- Pack.call(this);
12
- this.level = 0;
13
- this.title = '';
14
- this.message = '';
15
- this.attr = {};
16
- }
17
- EventPack.prototype = new Pack();
18
- EventPack.prototype.constructor = EventPack;
19
- EventPack.prototype.getPackType = function() {
20
- return PackEnum.EVENT;
21
- };
22
- EventPack.prototype.write = function(dout) {
23
- Pack.prototype.write.call(this, dout);
24
-
25
- dout.writeByte(this.level);
26
- dout.writeText(this.title);
27
- dout.writeText(this.message);
28
- dout.writeByte(Object.keys(this.attr).length);
29
-
30
- for(var key in this.attr) {
31
- dout.writeText(key);
32
- dout.writeText(this.attr[key]);
33
- }
34
- };
35
- EventPack.prototype.read = function(din) {
36
- Pack.prototype.read.call(this, din);
37
-
38
- this.level = din.readByte();
39
- this.title = din.readText();
40
- this.message = din.readText();
41
-
42
- var keySize = din.readByte(),
43
- key, value;
44
-
45
- for(var i=0; i<keySize; i++) {
46
- key = din.readText();
47
- value = din.readText();
48
- this.attr[key] = value;
49
- }
50
-
51
- return this;
52
- };
53
-
54
- module.exports = EventPack;
@@ -1,63 +0,0 @@
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
-
10
- function HitMapPack() {
11
- this.hitCount = 0;
12
- this.errorCount = 0;
13
- this.hit = [];
14
- this.error = [];
15
- this.time90pct = 0;
16
- };
17
-
18
- HitMapPack.prototype.getPackType = function() {
19
- return PackEnum.HITMAP;
20
- };
21
- HitMapPack.prototype.write = function(dout) {
22
-
23
- Pack.prototype.write.call(this, dout);
24
- dout.writeDecimal(this.hitCount);
25
- dout.writeDecimal(this.errorCount);
26
- dout.writeDecimal(this.time90pct);
27
- this.writeIntArray(dout, this.hit);
28
- this.writeIntArray(dout, this.error);
29
- };
30
- HitMapPack.prototype.read = function(din) {
31
-
32
- Pack.prototype.read.call(this, din);
33
- this.hitCount = din.readDecLong();
34
- this.errorCount = din.readDecLong();
35
- this.time90pct = din.readDecNumber();
36
- this.readIntArray(din, this.hit);
37
- this.readIntArray(din, this.error);
38
-
39
- return this;
40
- };
41
- HitMapPack.prototype.writeIntArray = function(dout, v){
42
-
43
- if(v == null) {
44
- dout.writeByte(0);
45
- } else {
46
- dout.writeByte(v.length);
47
- for(var val in v) {
48
- dout.writeDecimal(val);
49
- }
50
- }
51
- };
52
- HitMapPack.prototype.readIntArray = function(din, map) {
53
- var len = din.readByte();
54
- for(var i=0; i<len; i++) {
55
- if(i < map.length) {
56
- map[i] = din.readDecNumber();
57
- }
58
- }
59
- };
60
-
61
- exports.Instance = HitMapPack;
62
- exports.PCT_BOX = 50;
63
- exports.HIT_MAP = 51;
@@ -1,152 +0,0 @@
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
- Logger = require('../logger');
10
-
11
- function HitMapPack1() {
12
- Pack.call(this);
13
- this.hit = new Array(HitMapPack1.LENGTH);
14
- this.error = new Array(HitMapPack1.LENGTH);
15
-
16
- this.hit.fill(0);
17
- this.error.fill(0);
18
- }
19
-
20
- HitMapPack1.LENGTH = 120;
21
- HitMapPack1.prototype = new Pack();
22
- HitMapPack1.prototype.constructor = HitMapPack1;
23
- HitMapPack1.prototype.getPackType = function () {
24
- return PackEnum.HITMAP_1;
25
- };
26
- HitMapPack1.prototype.write = function (dout) {
27
- Pack.prototype.write.call(this, dout);
28
- // dout.writeByte(1);
29
- // for(var i=0; i<HitMapPack1.LENGTH; i++) {
30
- // dout.writeShort(this.hit[i]);
31
- // dout.writeShort(this.error[i]);
32
- // }
33
- dout.writeByte(3);// version
34
- writeArr(dout, this.hit);
35
- writeArr(dout, this.error);
36
- };
37
- HitMapPack1.prototype.read = function (din) {
38
- Pack.prototype.read.call(this, din);
39
- var ver = din.readByte();
40
-
41
- if(ver === 1) {
42
- for(var i=0; i<HitMapPack1.LENGTH; i++) {
43
- this.hit[i] = din.readShort() & 0xffff;
44
- this.error[i] = din.readShort() & 0xffff;
45
- }
46
- }
47
- if(ver === 3){
48
- readArr(din, this.hit);
49
- readArr(din, this.error);
50
- }
51
- return this;
52
- };
53
-
54
- function writeArr( dout, arr) {
55
- try{
56
- if (arr == null) {
57
- dout.writeByte(0);
58
- } else {
59
- var len = HitMapPack1.LENGTH - 1;
60
- for (; len >= 0; len--) {
61
- if (arr[len] != 0)
62
- break;
63
- }
64
- len = len + 1;
65
- dout.writeByte(len);
66
- for (var i = 0; i < len; i++) {
67
- dout.writeUInt16BE(arr[i]);
68
- }
69
- }
70
- }catch (e) {
71
- Logger.printError('WHATAP-088', 'Hit-map pack - write error', e, false);
72
- }
73
- }
74
-
75
- function readArr( din, arr) {
76
- var len = din.readByte() & 0xff;
77
- for (var i = 0; i < len; i++) {
78
- arr[i] = din.readShort() & 0xffff;
79
- }
80
- }
81
- HitMapPack1.prototype.copy = function () {
82
- var newOne = new HitMapPack1();
83
- newOne.pcode = this.pcode;
84
- newOne.oid = this.oid;
85
- newOne.time = this.time;
86
-
87
- newOne.hit = this.hit.slice();
88
- newOne.error = this.error.slice();
89
- return newOne;
90
- };
91
- HitMapPack1.prototype.merge = function (p) {
92
- for(var i=0; i<this.LENGTH; i++) {
93
- this.hit[i] += p.hit[i];
94
- this.error[i] += p.error[i];
95
- }
96
- };
97
- HitMapPack1.prototype.add = function (time, isError) {
98
- var idx = HitMapPack1.index(time);
99
- this.hit[idx]++;
100
- if(isError) {
101
- this.error[idx]++;
102
- }
103
- };
104
- HitMapPack1.prototype.toString = function() {
105
- return 'HitMap1 ' + Pack.prototype.toString.call(this) + ', hit=' + this.hit.length + ", error=" + this.error.length;
106
- };
107
-
108
- HitMapPack1.index = function (time) {
109
- var x = parseInt(time / 10000);
110
- switch (x) {
111
- case 0:
112
- if (time < 5000)
113
- return parseInt(time / 125);
114
- else
115
- return 40 + parseInt((time - 5000) / 250);
116
- case 1:
117
- return 60 + parseInt((time - 10000) / 500);
118
- case 2:
119
- case 3:
120
- return 80 + parseInt((time - 20000) / 1000);
121
- case 4:
122
- case 5:
123
- case 6:
124
- case 7:
125
- return 100 + parseInt((time - 40000) / 2000);
126
- default:
127
- return 119;
128
- }
129
- };
130
- HitMapPack1.time = function(index) {
131
- var _time = 0;
132
- if (index < 40)
133
- return index * 125;
134
- _time = 5000;
135
- if (index < 60)
136
- return _time + (index - 40) * 250;
137
- _time = 10000;
138
- if (index < 80)
139
- return _time + (index - 60) * 500;
140
-
141
- _time = 20000;
142
- if (index < 100)
143
- return _time + (index - 80) * 1000;
144
-
145
- _time = 40000;
146
- if (index < 120)
147
- return _time + (index - 100) * 2000;
148
- return 80000;
149
- };
150
-
151
-
152
- module.exports = HitMapPack1;
@@ -1,15 +0,0 @@
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
- function NETSTAT(){
8
- this.est = 0;
9
- this.fin_w = 0;
10
- this.tim_w = 0;
11
- this.clo_w = 0;
12
- }
13
-
14
-
15
- module.exports = NETSTAT;
package/lib/pack/otype.js DELETED
@@ -1,7 +0,0 @@
1
- exports.AP = 0x0001;
2
- exports.SM = 0x0002;
3
- exports.DB = 0x0004;
4
- exports.VR = 0x0008;
5
- exports.CL = 0x0010;
6
- exports.BSM = 0x0011;
7
- exports.WC = 0x0012;
@@ -1,49 +0,0 @@
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
- TxRecord = require('../service/tx-record'),
10
- Step = require('../step/step');
11
-
12
- function ProfilePack() {
13
- Pack.call(this);
14
- this.service = null;
15
- this.steps = null;
16
- }
17
-
18
- ProfilePack.prototype = new Pack();
19
- ProfilePack.prototype.constructor = ProfilePack;
20
- ProfilePack.prototype.toString = function() {
21
- var text = 'Profile '
22
- + Pack.prototype.toString.call(this)
23
- + ', step_bytes='
24
- + ((this.steps != null) ? this.steps.length : 0);
25
- if (this.service != null) {
26
- text += " time=" + this.service.endTime + ", active=" + this.service.active;
27
- }
28
- return text;
29
- };
30
- ProfilePack.prototype.getPackType = function() {
31
- return PackEnum.PROFILE;
32
- };
33
- ProfilePack.prototype.write = function(dout) {
34
- Pack.prototype.write.call(this, dout);
35
- this.service.write(dout);
36
- dout.writeBlob(this.steps);
37
- };
38
- ProfilePack.prototype.read = function(din) {
39
- Pack.prototype.read.call(this, din);
40
- this.service = new TxRecord().read(din);
41
- this.steps = din.readBlob();
42
- return this;
43
- };
44
- ProfilePack.prototype.setProfile = function(steps) {
45
- this.steps = Step.toBytes(steps);
46
- return this;
47
- };
48
-
49
- module.exports = ProfilePack;