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,38 @@
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 Step = require('./step'),
8
+ StepEnum = require('./stepenum'),
9
+ Long = require('long');
10
+
11
+ function ActiveStackStep(id) {
12
+ Step.call(this);
13
+
14
+ this.seq = Long.ZERO;
15
+ this.hasCallStack = false;
16
+ if(id instanceof Long) {
17
+ this.seq = id;
18
+ }
19
+ };
20
+
21
+ ActiveStackStep.prototype = new Step();
22
+ ActiveStackStep.prototype.constructor = ActiveStackStep;
23
+ ActiveStackStep.prototype.getStepType = function() {
24
+ return StepEnum.ACTIVE_STACK;
25
+ };
26
+ ActiveStackStep.prototype.write = function(dout) {
27
+ Step.prototype.write.call(this, dout);
28
+ dout.writeLong(this.seq);
29
+ dout.writeBoolean(this.hasCallStack);
30
+ };
31
+ ActiveStackStep.prototype.read = function(din) {
32
+ Step.prototype.read.call(this, din);
33
+ this.seq = din.readLong();
34
+ this.hasCallStack = din.readBoolean();
35
+ return this;
36
+ };
37
+
38
+ module.exports = ActiveStackStep;
@@ -0,0 +1,36 @@
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 Step = require('./step'),
8
+ StepEnum = require('./stepenum');
9
+
10
+ function DBCStep() {
11
+ Step.call(this);
12
+ this.hash = 0;
13
+ this.elapsed = 0;
14
+ this.error = 0;
15
+ }
16
+
17
+ DBCStep.prototype = new Step();
18
+ DBCStep.prototype.constructor = DBCStep;
19
+ DBCStep.prototype.getStepType = function() {
20
+ return StepEnum.DBC;
21
+ };
22
+ DBCStep.prototype.write = function(dout) {
23
+ Step.prototype.write.call(this, dout);
24
+ dout.writeDecimal(this.hash);
25
+ dout.writeDecimal(this.elapsed);
26
+ dout.writeDecimal(this.error);
27
+ };
28
+ DBCStep.prototype.read = function(din) {
29
+ Step.prototype.read.call(this, din);
30
+ this.hash = din.readDecNumber();
31
+ this.elapsed = din.readDecNumber();
32
+ this.error = din.readDecNumber();
33
+ return this;
34
+ };
35
+
36
+ module.exports = DBCStep;
@@ -0,0 +1,67 @@
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 Step = require('./step'),
8
+ StepEnum = require('./stepenum'),
9
+ Long = require('long');
10
+
11
+ function HttpStepX() {
12
+ Step.call(this);
13
+
14
+ this.url = 0;
15
+ this.elapsed = 0;
16
+ this.error = Long.ZERO;
17
+ this.host = 0;
18
+ this.port = 0;
19
+
20
+ this.status = 0;
21
+
22
+ this.start_cpu = 0;
23
+ this.start_mem = 0;
24
+
25
+ this.stack = [];
26
+ this.callee = null;
27
+ };
28
+
29
+ HttpStepX.prototype = new Step();
30
+ HttpStepX.prototype.constructor = HttpStepX;
31
+ HttpStepX.prototype.getStepType = function () {
32
+ return StepEnum.HTTPCALL_X;
33
+ };
34
+ HttpStepX.prototype.write = function(dout) {
35
+ Step.prototype.write.call(this, dout);
36
+ dout.writeByte(1);
37
+ dout.writeDecimal(this.url);
38
+ dout.writeDecimal(this.elapsed);
39
+ dout.writeDecimal(this.error);
40
+ dout.writeDecimal(this.host);
41
+ dout.writeDecimal(this.port);
42
+
43
+ dout.writeDecimal(this.status);
44
+ dout.writeDecimal(this.start_cpu);
45
+ dout.writeDecimal(this.start_mem);
46
+ dout.writeIntArray(this.stack);
47
+ dout.writeDecimal(this.callee);
48
+ };
49
+ HttpStepX.prototype.read = function(din) {
50
+ Step.prototype.read.call(this, din);
51
+ var ver=din.readByte();
52
+ this.url = din.readDecNumber();
53
+ this.elapsed = din.readDecNumber();
54
+ this.error = din.readDecNumber();
55
+ this.host = din.readDecNumber();
56
+ this.port = din.readDecNumber();
57
+
58
+ this.status = din.readDecNumber();
59
+ this.start_cpu = din.readDecNumber();
60
+ this.start_mem = din.readDecNumber();
61
+
62
+ this.stack = din.readIntArray();
63
+ this.callee = din.readDecLong();
64
+ return this;
65
+ };
66
+
67
+ module.exports = HttpStepX;
@@ -0,0 +1,40 @@
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 Step = require('./step'),
8
+ StepEnum = require('./stepenum');
9
+
10
+ function MessageStep(start_time) {
11
+ Step.call(this);
12
+ this.hash = 0;
13
+ this.time = 0;
14
+ this.value = 0;
15
+ this.desc = null;
16
+ this.start_time = start_time || 0;
17
+ }
18
+
19
+ MessageStep.prototype = new Step();
20
+ MessageStep.prototype.constructor = MessageStep;
21
+ MessageStep.prototype.getStepType = function () {
22
+ return StepEnum.MESSAGE;
23
+ };
24
+ MessageStep.prototype.write = function(dout) {
25
+ Step.prototype.write.call(this, dout);
26
+ dout.writeDecimal(this.hash);
27
+ dout.writeDecimal(this.time);
28
+ dout.writeDecimal(this.value);
29
+ dout.writeText(this.desc);
30
+ };
31
+ MessageStep.prototype.read = function(din) {
32
+ Step.prototype.read.call(this, din);
33
+ this.hash = din.readDecNumber();
34
+ this.time = din.readDecNumber();
35
+ this.value = din.readDecNumber();
36
+ this.desc = din.readText();
37
+ return this;
38
+ };
39
+
40
+ module.exports = MessageStep;
@@ -0,0 +1,45 @@
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
+ module.exports = MethodStepX;
8
+
9
+ var Step = require('./step'),
10
+ StepEnum = require('./stepenum');
11
+
12
+ function MethodStepX() {
13
+ Step.call(this);
14
+
15
+ this.hash = 0;
16
+ this.elapsed = 0;
17
+ this.start_cpu = 0;
18
+ this.start_mem = 0;
19
+ this.stack = [];
20
+
21
+ };
22
+ MethodStepX.prototype = new Step();
23
+ MethodStepX.prototype.constructor = MethodStepX;
24
+ MethodStepX.prototype.getStepType = function () {
25
+ return StepEnum.METHOD_X;
26
+ };
27
+ MethodStepX.prototype.write = function(dout) {
28
+ Step.prototype.write.call(this, dout);
29
+ dout.writeByte(0);
30
+ dout.writeDecimal(this.hash);
31
+ dout.writeDecimal(this.elapsed);
32
+ dout.writeDecimal(this.start_cpu);
33
+ dout.writeDecimal(this.start_mem);
34
+ dout.writeIntArray(this.stack);
35
+ };
36
+ MethodStepX.prototype.read = function(din) {
37
+ Step.prototype.read.call(this, din);
38
+ var ver = din.readByte();
39
+ this.hash = din.readDecNumber();
40
+ this.elapsed = din.readDecNumber();
41
+ this.start_cpu = din.readDecNumber();
42
+ this.start_mem = din.readDecNumber();
43
+ this.stack = din.readIntArray();
44
+ return this;
45
+ };
@@ -0,0 +1,40 @@
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 Step = require('./step'),
8
+ StepEnum = require('./stepenum');
9
+
10
+ function ResultSetStep() {
11
+ Step.call(this);
12
+
13
+ this.dbc = 0;
14
+ this.sqlhash = 0;
15
+ this.elapsed = 0;
16
+ this.fetch = 0;
17
+ };
18
+
19
+ ResultSetStep.prototype = new Step();
20
+ ResultSetStep.prototype.constructor = ResultSetStep;
21
+ ResultSetStep.prototype.getStepType = function () {
22
+ return StepEnum.RESULTSET;
23
+ };
24
+ ResultSetStep.prototype.write = function(dout) {
25
+ Step.prototype.write.call(this, dout);
26
+ dout.writeDecimal(this.elapsed);
27
+ dout.writeDecimal(this.fetch);
28
+ dout.writeDecimal(this.dbc);
29
+ dout.writeDecimal(this.sqlhash);
30
+ };
31
+ ResultSetStep.prototype.read = function(din) {
32
+ Step.prototype.read.call(this, din);
33
+ this.elapsed = din.readDecNumber();
34
+ this.fetch = din.readDecNumber();
35
+ this.dbc = din.readDecNumber();
36
+ this.sqlhash = din.readDecNumber();
37
+ return this;
38
+ };
39
+
40
+ module.exports = ResultSetStep;
@@ -0,0 +1,44 @@
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 Step = require('./step'),
8
+ StepEnum = require('./stepenum');
9
+
10
+ function SecureMsgStep(start_time) {
11
+ Step.call(this);
12
+
13
+ this.hash = 0;
14
+ this.opt = 0;
15
+ this.crc = 0;
16
+ this.value = null;
17
+
18
+ if(start_time != null) {
19
+ this.start_time = start_time;
20
+ }
21
+ };
22
+
23
+ SecureMsgStep.prototype = new Step();
24
+ SecureMsgStep.prototype.constructor = SecureMsgStep;
25
+ SecureMsgStep.prototype.getStepType = function () {
26
+ return StepEnum.SECURE_MESSAGE;
27
+ };
28
+ SecureMsgStep.prototype.write = function(dout) {
29
+ Step.prototype.write.call(this, dout);
30
+ dout.writeDecimal(this.hash);
31
+ dout.writeByte(this.opt);
32
+ dout.writeByte(this.crc);
33
+ dout.writeBlob(this.value);
34
+ };
35
+ SecureMsgStep.prototype.read = function(din) {
36
+ Step.prototype.read.call(this, din);
37
+ this.hash = din.readDecNumber();
38
+ this.opt = din.readByte();
39
+ this.crc = din.readByte();
40
+ this.value = din.readBlob();
41
+ return this;
42
+ };
43
+
44
+ module.exports = SecureMsgStep;
@@ -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 Step = require('./step'),
8
+ StepEnum = require('./stepenum'),
9
+ Long = require('long');
10
+
11
+ function SocketStep(ipaddr, port) {
12
+ Step.call(this);
13
+
14
+ this.ipaddr = null; /*Buffer*/
15
+ this.port = 0;
16
+ this.elapsed = 0;
17
+ this.error = Long.ZERO;
18
+
19
+ if(Array.isArray(ipaddr)) {
20
+ this.ipaddr = ipaddr;
21
+ this.port = port;
22
+ }
23
+ }
24
+
25
+ SocketStep.prototype = new Step();
26
+ SocketStep.prototype.constructor = SocketStep;
27
+ SocketStep.prototype.getStepType = function () {
28
+ return StepEnum.SOCKET;
29
+ };
30
+ SocketStep.prototype.write = function(dout) {
31
+ Step.prototype.write.call(this, dout);
32
+ dout.writeBlob(this.ipaddr);
33
+ dout.writeDecimal(this.port);
34
+ dout.writeDecimal(this.elapsed);
35
+ dout.writeDecimal(this.error);
36
+ };
37
+ SocketStep.prototype.read = function(din) {
38
+ Step.prototype.read.call(this, din);
39
+ this.ipaddr = din.readBlob();
40
+ this.port = din.readDecNumber();
41
+ this.elapsed = din.readDecNumber();
42
+ this.error = din.readDecLong();
43
+ return this;
44
+ };
45
+
46
+ module.exports = SocketStep;
@@ -0,0 +1,68 @@
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 Step = require('./step'),
8
+ StepEnum = require('./stepenum'),
9
+ Long = require('long');
10
+
11
+ function SqlStepX() {
12
+ Step.call(this);
13
+
14
+ this.xtype = 0;
15
+ this.hash = 0;
16
+ this.elapsed = 0;
17
+ this.error = Long.ZERO;
18
+ this.updated = 0;
19
+ this.dbc = 0;
20
+
21
+ this.p1 = null;
22
+ this.p2 = null;
23
+ this.pcrc = 0;
24
+
25
+ this.start_cpu = 0;
26
+ this.start_mem = 0;
27
+ this.stack = [];
28
+
29
+ };
30
+ SqlStepX.prototype = new Step();
31
+ SqlStepX.prototype.constructor = SqlStepX;
32
+ SqlStepX.prototype.getStepType = function () {
33
+ return StepEnum.SQL_X;
34
+ };
35
+ SqlStepX.prototype.write = function (dout) {
36
+ Step.prototype.write.call(this, dout);
37
+ dout.writeByte(0);
38
+ dout.writeDecimal(this.hash);
39
+ dout.writeDecimal(this.elapsed);
40
+ dout.writeDecimal(this.error);
41
+ dout.writeByte(this.xtype);
42
+ dout.writeDecimal(this.dbc);
43
+ dout.writeBlob(this.p1);
44
+ dout.writeBlob(this.p2);
45
+ dout.writeByte(this.pcrc);
46
+ dout.writeDecimal(this.start_cpu);
47
+ dout.writeDecimal(this.start_mem);
48
+ dout.writeIntArray(this.stack);
49
+ };
50
+ SqlStepX.prototype.read = function (din) {
51
+ Step.prototype.read.call(this, din);
52
+ var ver = din.readByte();
53
+ this.hash = din.readDecNumber();
54
+ this.elapsed = din.readDecNumber();
55
+ this.error = din.readDecNumber();
56
+ this.xtype = din.readByte();
57
+ this.dbc = din.readDecNumber();
58
+ this.p1 = din.readBlob();
59
+ this.p2 = din.readBlob();
60
+ this.pcrc = din.readByte();
61
+ this.start_cpu = din.readDecNumber();
62
+ this.start_mem = din.readDecNumber();
63
+ this.stack = din.readIntArray();
64
+
65
+ return this;
66
+ };
67
+
68
+ module.exports = SqlStepX;
@@ -0,0 +1,16 @@
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
+ exports.STMT = 0x0;
8
+ exports.PREPARED = 0x1;
9
+ exports.METHOD_KNOWN = 0x00;
10
+ exports.METHOD_EXECUTE = 0x10;
11
+ exports.METHOD_UPDATE = 0x20;
12
+ exports.METHOD_QUERY = 0x30;
13
+
14
+ exports.getClassType = function(xtype) {
15
+ return (xtype & 0x0f);
16
+ };
@@ -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 DataOutputX = require('../io/data-outputx'),
8
+ DataInputX = require('../io/data-inputx');
9
+
10
+ function Step() {
11
+ this.parent = 0;
12
+ this.index = 0;
13
+ this.start_time = 0;
14
+ this.opt = 0;
15
+ };
16
+
17
+ Step.prototype.getStepType = function() {};
18
+ Step.prototype.getOrder = function () {
19
+ return this.index;
20
+ };
21
+ Step.prototype.write = function(dout) {
22
+ dout.writeDecimal(this.parent);
23
+ dout.writeDecimal(this.index);
24
+ dout.writeDecimal(this.start_time);
25
+ };
26
+ Step.prototype.read = function(din) {
27
+ this.parent = din.readDecNumber();
28
+ this.index = din.readDecNumber();
29
+ this.start_time = din.readDecNumber();
30
+ return this;
31
+ };
32
+ Step.prototype.compareTo = function(step) {
33
+ return this.getOrder() - step.getOrder();
34
+ };
35
+ Step.prototype.isTrue = function(flag) {
36
+ return (this.opt & flag) != 0;
37
+ };
38
+ Step.prototype.setTrue = function(flag) {
39
+ this.opt |= flag;
40
+ };
41
+
42
+ Step.toBytes = function(p) {
43
+ if(p == null ) {
44
+ return null;
45
+ }
46
+ var dout = new DataOutputX(p.length * 30);
47
+
48
+ for(var i=0; i< p.length; i++) {
49
+ dout.writeStep(p[i]);
50
+ }
51
+
52
+ return dout.toByteArray();
53
+ };
54
+ Step.toObjects = function(buff) {
55
+ if(buff == null ) {
56
+ return null;
57
+ }
58
+ var arr = [],
59
+ din = new DataInputX(buff);
60
+ while(din.available() > 0) {
61
+ arr.push(din.readStep());
62
+ }
63
+ return arr;
64
+ };
65
+
66
+ module.exports = Step;
@@ -0,0 +1,54 @@
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 MethodStepX = require('./method-stepx'),
8
+ SqlStepX = require('./sql-stepx'),
9
+ ResultSetStep = require('./resultset-step'),
10
+ SocketStep = require('./socket-step'),
11
+ HTtpStepX = require('./http-stepx'),
12
+ ActiveStackStep = require('./activestack-step'),
13
+ MessageStep = require('./message-step'),
14
+ SecureMsgStep = require('./securemsg-step'),
15
+ DBCStep = require('./dbc-step');
16
+
17
+ exports.METHOD = 1;
18
+ exports.SQL = 2;
19
+ exports.RESULTSET = 3;
20
+ exports.HTTPCALL = 4;
21
+ exports.SOCKET = 5;
22
+ exports.ACTIVE_STACK = 6;
23
+ exports.MESSAGE = 7;
24
+ exports.DBC = 8;
25
+ exports.SQL_2 = 9;
26
+ exports.METHOD_2 = 11;
27
+ exports.SECURE_MESSAGE = 15;
28
+
29
+ exports.METHOD_X = 17;
30
+ exports.SQL_X = 18;
31
+ exports.HTTPCALL_X = 19;
32
+
33
+ exports.create = function(type) {
34
+ switch (type) {
35
+ case this.METHOD_X:
36
+ return new MethodStepX();
37
+ case this.SQL_X:
38
+ return new SqlStepX();
39
+ case this.RESULTSET:
40
+ return new ResultSetStep();
41
+ case this.SOCKET:
42
+ return new SocketStep();
43
+ case this.HTTPCALL_X:
44
+ return new HTtpStepX();
45
+ case this.ACTIVE_STACK:
46
+ return new ActiveStackStep();
47
+ case this.MESSAGE:
48
+ return new MessageStep();
49
+ case this.SECURE_MESSAGE:
50
+ return new SecureMsgStep();
51
+ case this.DBC:
52
+ return new DBCStep();
53
+ };
54
+ };
@@ -0,0 +1,63 @@
1
+ var { InetAddress } = require('net');
2
+ var CompareUtil = require('../util/compare-util');
3
+ var HashUtil = require('../util/hashutil');
4
+
5
+ function LINK() {
6
+ this.ip = null;
7
+ this.port = 0;
8
+
9
+ this.toString = function () {
10
+ if (this.ip === null) return `0.0.0.0:${this.port}`;
11
+ try {
12
+ return `${InetAddress.getByAddress(this.ip).getHostAddress()}:${this.port}`;
13
+ } catch (e) {
14
+ return `0.0.0.0:${this.port}`;
15
+ }
16
+ };
17
+
18
+ this.include = function (k) {
19
+ if (!CompareUtil.equals(this.ip, k.ip)) return false;
20
+ if (this.port === 0) return true;
21
+ return this.port === k.port;
22
+ };
23
+
24
+ this.equals = function (o) {
25
+ if (o.constructor !== this.constructor) return false;
26
+ var k = o;
27
+ if (!CompareUtil.equals(this.ip, k.ip)) return false;
28
+ return this.port === k.port;
29
+ };
30
+
31
+ this.hashCode = function () {
32
+ return HashUtil.hash(this.ip) | this.port;
33
+ };
34
+
35
+ this.toBytes = function (out) {
36
+ out.writeBlob(this.ip);
37
+ out.writeInt(this.port);
38
+ return this;
39
+ };
40
+
41
+ this.toObject = function (din) {
42
+ this.ip = din.readBlob();
43
+ this.port = din.readInt();
44
+ return this;
45
+ };
46
+ }
47
+
48
+ LINK.create = function (ipStr, port) {
49
+ var k = new LINK();
50
+ try {
51
+ k.ip = InetAddress.getByName(ipStr).getAddress();
52
+ } catch (e) {
53
+ k.ip = new Buffer(4);
54
+ }
55
+ k.port = port;
56
+ return k;
57
+ };
58
+
59
+ LINK.prototype = new LINK();
60
+ LINK.prototype.constructor = LINK;
61
+
62
+ module.exports = LINK;
63
+