groonga-query-log 1.2.8 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/groonga-query-log-analyze +3 -4
- data/bin/groonga-query-log-analyze-load +22 -0
- data/bin/groonga-query-log-check-command-version-compatibility +2 -2
- data/bin/groonga-query-log-check-crash +22 -0
- data/bin/groonga-query-log-detect-memory-leak +2 -2
- data/bin/groonga-query-log-extract +2 -2
- data/bin/groonga-query-log-format-regression-test-logs +2 -2
- data/bin/groonga-query-log-replay +3 -5
- data/bin/groonga-query-log-run-regression-test +2 -2
- data/bin/groonga-query-log-show-running-queries +2 -2
- data/bin/groonga-query-log-verify-server +2 -2
- data/doc/text/news.md +31 -0
- data/groonga-query-log.gemspec +5 -4
- data/lib/groonga-query-log.rb +42 -0
- data/lib/{groonga/query-log/command-line-utils.rb → groonga-query-log/command-line.rb} +25 -13
- data/lib/{groonga/query-log → groonga-query-log}/command-version-compatibility-checker.rb +3 -5
- data/lib/groonga-query-log/command/analyze-load.rb +188 -0
- data/lib/{groonga/query-log → groonga-query-log/command}/analyzer.rb +60 -44
- data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/reporter.rb +15 -20
- data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/reporter/console.rb +19 -18
- data/lib/groonga-query-log/command/analyzer/reporter/csv.rb +77 -0
- data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/reporter/html.rb +32 -16
- data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/reporter/json-stream.rb +4 -6
- data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/reporter/json.rb +7 -7
- data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/sized-grouped-operations.rb +3 -5
- data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/sized-statistics.rb +4 -6
- data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/streamer.rb +4 -6
- data/lib/groonga-query-log/command/check-command-version-compatibility.rb +69 -0
- data/lib/groonga-query-log/command/check-crash.rb +169 -0
- data/lib/groonga-query-log/command/detect-memory-leak.rb +89 -0
- data/lib/groonga-query-log/command/extract.rb +171 -0
- data/lib/groonga-query-log/command/format-regression-test-logs.rb +143 -0
- data/lib/groonga-query-log/command/replay.rb +117 -0
- data/lib/groonga-query-log/command/run-regression-test.rb +432 -0
- data/lib/groonga-query-log/command/show-running-queries.rb +78 -0
- data/lib/{groonga/query-log/command/replay.rb → groonga-query-log/command/verify-server.rb} +68 -37
- data/lib/{groonga/query-log → groonga-query-log}/incompatibility-detector.rb +3 -5
- data/lib/{groonga/query-log → groonga-query-log}/memory-leak-detector.rb +3 -7
- data/lib/groonga-query-log/parser.rb +173 -0
- data/lib/{groonga/query-log → groonga-query-log}/replayer.rb +7 -8
- data/lib/{groonga/query-log → groonga-query-log}/response-comparer.rb +3 -5
- data/lib/{groonga/query-log → groonga-query-log}/server-verifier.rb +3 -5
- data/lib/groonga-query-log/statistic.rb +192 -0
- data/lib/{groonga/query-log → groonga-query-log}/version.rb +2 -4
- data/lib/groonga/query-log.rb +21 -9
- data/lib/groonga/query-log/command/analyzer.rb +18 -0
- data/lib/groonga/query-log/command/check-command-version-compatibility.rb +2 -55
- data/lib/groonga/query-log/command/detect-memory-leak.rb +3 -78
- data/lib/groonga/query-log/command/extract.rb +5 -179
- data/lib/groonga/query-log/command/format-regression-test-logs.rb +3 -130
- data/lib/groonga/query-log/command/reply.rb +18 -0
- data/lib/groonga/query-log/command/run-regression-test.rb +2 -418
- data/lib/groonga/query-log/command/show-running-queries.rb +3 -65
- data/lib/groonga/query-log/command/verify-server.rb +2 -137
- data/test/{test-analyzer.rb → command/test-analyzer.rb} +17 -11
- data/test/command/test-extract.rb +9 -18
- data/test/command/test-format-regression-test-logs.rb +3 -3
- data/test/fixtures/reporter/html.expected +55 -20
- data/test/helper.rb +22 -7
- data/test/test-incompatibility-detector.rb +3 -3
- data/test/test-parser.rb +19 -4
- data/test/test-replayer.rb +4 -4
- data/test/test-response-comparer.rb +2 -2
- metadata +86 -97
- data/lib/groonga/query-log/analyzer/statistic.rb +0 -194
- data/lib/groonga/query-log/parser.rb +0 -125
- data/test/fixtures/run-regression-test/db.new/db +0 -0
- data/test/fixtures/run-regression-test/db.new/db.0000000 +0 -0
- data/test/fixtures/run-regression-test/db.new/db.0000100 +0 -0
- data/test/fixtures/run-regression-test/db.new/db.0000101 +0 -0
- data/test/fixtures/run-regression-test/db.new/db.0000102 +0 -0
- data/test/fixtures/run-regression-test/db.new/db.0000103 +0 -0
- data/test/fixtures/run-regression-test/db.new/db.0000103.c +0 -0
- data/test/fixtures/run-regression-test/db.new/db.001 +0 -0
- data/test/fixtures/run-regression-test/db.new/db.conf +0 -0
- data/test/fixtures/run-regression-test/db.new/groonga.log +0 -165
- data/test/fixtures/run-regression-test/db.old/db +0 -0
- data/test/fixtures/run-regression-test/db.old/db.0000000 +0 -0
- data/test/fixtures/run-regression-test/db.old/db.0000100 +0 -0
- data/test/fixtures/run-regression-test/db.old/db.0000101 +0 -0
- data/test/fixtures/run-regression-test/db.old/db.0000102 +0 -0
- data/test/fixtures/run-regression-test/db.old/db.0000103 +0 -0
- data/test/fixtures/run-regression-test/db.old/db.0000103.c +0 -0
- data/test/fixtures/run-regression-test/db.old/db.001 +0 -0
- data/test/fixtures/run-regression-test/db.old/db.conf +0 -0
- data/test/fixtures/run-regression-test/db.old/groonga.log +0 -79
- data/test/fixtures/run-regression-test/results/query.log +0 -0
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2013-2017 Kouhei Sutou <kou@clear-code.com>
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -21,10 +19,9 @@ require "thread"
|
|
21
19
|
|
22
20
|
require "groonga/client"
|
23
21
|
|
24
|
-
require "groonga
|
22
|
+
require "groonga-query-log/parser"
|
25
23
|
|
26
|
-
module
|
27
|
-
module QueryLog
|
24
|
+
module GroongaQueryLog
|
28
25
|
class Replayer
|
29
26
|
def initialize(options)
|
30
27
|
@options = options
|
@@ -147,11 +144,14 @@ module Groonga
|
|
147
144
|
attr_accessor :protocol
|
148
145
|
attr_accessor :n_clients
|
149
146
|
attr_writer :request_queue_size
|
147
|
+
attr_writer :disable_cache
|
150
148
|
attr_accessor :target_command_names
|
149
|
+
attr_accessor :requests_path
|
150
|
+
attr_accessor :responses_path
|
151
151
|
def initialize
|
152
152
|
@host = "127.0.0.1"
|
153
153
|
@port = 10041
|
154
|
-
@protocol = :
|
154
|
+
@protocol = :http
|
155
155
|
@n_clients = 8
|
156
156
|
@request_queue_size = nil
|
157
157
|
@disable_cache = false
|
@@ -201,5 +201,4 @@ module Groonga
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
204
|
-
end
|
205
204
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2017 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -14,8 +14,7 @@
|
|
14
14
|
# License along with this library; if not, write to the Free Software
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
|
-
module
|
18
|
-
module QueryLog
|
17
|
+
module GroongaQueryLog
|
19
18
|
class ResponseComparer
|
20
19
|
def initialize(command, response1, response2, options={})
|
21
20
|
@command = command
|
@@ -46,7 +45,7 @@ module Groonga
|
|
46
45
|
|
47
46
|
private
|
48
47
|
def error_response?(response)
|
49
|
-
response.is_a?(Client::Response::Error)
|
48
|
+
response.is_a?(Groonga::Client::Response::Error)
|
50
49
|
end
|
51
50
|
|
52
51
|
def same_error_response?
|
@@ -211,5 +210,4 @@ module Groonga
|
|
211
210
|
map
|
212
211
|
end
|
213
212
|
end
|
214
|
-
end
|
215
213
|
end
|
@@ -19,11 +19,10 @@ require "thread"
|
|
19
19
|
|
20
20
|
require "groonga/client"
|
21
21
|
|
22
|
-
require "groonga
|
23
|
-
require "groonga
|
22
|
+
require "groonga-query-log/parser"
|
23
|
+
require "groonga-query-log/response-comparer"
|
24
24
|
|
25
|
-
module
|
26
|
-
module QueryLog
|
25
|
+
module GroongaQueryLog
|
27
26
|
class ServerVerifier
|
28
27
|
def initialize(options)
|
29
28
|
@options = options
|
@@ -246,5 +245,4 @@ module Groonga
|
|
246
245
|
end
|
247
246
|
end
|
248
247
|
end
|
249
|
-
end
|
250
248
|
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
# Copyright (C) 2011-2017 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "groonga/command/parser"
|
18
|
+
|
19
|
+
module GroongaQueryLog
|
20
|
+
class Statistic
|
21
|
+
DEFAULT_SLOW_OPERATION_THRESHOLD = 0.1
|
22
|
+
DEFAULT_SLOW_RESPONSE_THRESHOLD = 0.2
|
23
|
+
|
24
|
+
attr_reader :context_id, :start_time, :raw_command
|
25
|
+
attr_reader :elapsed, :return_code
|
26
|
+
attr_accessor :slow_operation_threshold, :slow_response_threshold
|
27
|
+
def initialize(context_id)
|
28
|
+
@context_id = context_id
|
29
|
+
@start_time = nil
|
30
|
+
@command = nil
|
31
|
+
@select_command = nil
|
32
|
+
@raw_command = nil
|
33
|
+
@operations = []
|
34
|
+
@elapsed = nil
|
35
|
+
@return_code = 0
|
36
|
+
@slow_operation_threshold = DEFAULT_SLOW_OPERATION_THRESHOLD
|
37
|
+
@slow_response_threshold = DEFAULT_SLOW_RESPONSE_THRESHOLD
|
38
|
+
end
|
39
|
+
|
40
|
+
def start(start_time, command)
|
41
|
+
@start_time = start_time
|
42
|
+
@raw_command = command
|
43
|
+
end
|
44
|
+
|
45
|
+
def finish(elapsed, return_code)
|
46
|
+
@elapsed = elapsed
|
47
|
+
@return_code = return_code
|
48
|
+
end
|
49
|
+
|
50
|
+
def command
|
51
|
+
Groonga::Command::Parser.parse(@raw_command) do |status, command|
|
52
|
+
case status
|
53
|
+
when :on_load_start
|
54
|
+
@loading = false
|
55
|
+
@command ||= command
|
56
|
+
when :on_command
|
57
|
+
@command ||= command
|
58
|
+
end
|
59
|
+
end
|
60
|
+
@command
|
61
|
+
end
|
62
|
+
|
63
|
+
def elapsed_in_seconds
|
64
|
+
nano_seconds_to_seconds(@elapsed)
|
65
|
+
end
|
66
|
+
|
67
|
+
def last_time
|
68
|
+
@start_time + elapsed_in_seconds
|
69
|
+
end
|
70
|
+
|
71
|
+
def slow?
|
72
|
+
elapsed_in_seconds >= @slow_response_threshold
|
73
|
+
end
|
74
|
+
|
75
|
+
def each_operation
|
76
|
+
return to_enum(__method__) unless block_given?
|
77
|
+
|
78
|
+
previous_elapsed = 0
|
79
|
+
ensure_parse_command
|
80
|
+
operation_context_context = {
|
81
|
+
:filter_index => 0,
|
82
|
+
:drilldown_index => 0,
|
83
|
+
}
|
84
|
+
@operations.each_with_index do |operation, i|
|
85
|
+
relative_elapsed = operation[:elapsed] - previous_elapsed
|
86
|
+
relative_elapsed_in_seconds = nano_seconds_to_seconds(relative_elapsed)
|
87
|
+
previous_elapsed = operation[:elapsed]
|
88
|
+
parsed_operation = {
|
89
|
+
:i => i,
|
90
|
+
:elapsed => operation[:elapsed],
|
91
|
+
:elapsed_in_seconds => nano_seconds_to_seconds(operation[:elapsed]),
|
92
|
+
:relative_elapsed => relative_elapsed,
|
93
|
+
:relative_elapsed_in_seconds => relative_elapsed_in_seconds,
|
94
|
+
:name => operation[:name],
|
95
|
+
:context => operation_context(operation[:name],
|
96
|
+
operation_context_context),
|
97
|
+
:n_records => operation[:n_records],
|
98
|
+
:extra => operation[:extra],
|
99
|
+
:slow? => slow_operation?(relative_elapsed_in_seconds),
|
100
|
+
}
|
101
|
+
yield parsed_operation
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def add_operation(operation)
|
106
|
+
@operations << operation
|
107
|
+
end
|
108
|
+
|
109
|
+
def operations
|
110
|
+
_operations = []
|
111
|
+
each_operation do |operation|
|
112
|
+
_operations << operation
|
113
|
+
end
|
114
|
+
_operations
|
115
|
+
end
|
116
|
+
|
117
|
+
def select_command?
|
118
|
+
command.name == "select"
|
119
|
+
end
|
120
|
+
|
121
|
+
def to_hash
|
122
|
+
data = {
|
123
|
+
"start_time" => start_time.to_f,
|
124
|
+
"last_time" => last_time.to_f,
|
125
|
+
"elapsed" => elapsed_in_seconds,
|
126
|
+
"return_code" => return_code,
|
127
|
+
"slow" => slow?,
|
128
|
+
}
|
129
|
+
arguments = command.arguments.collect do |key, value|
|
130
|
+
{"key" => key, "value" => value}
|
131
|
+
end
|
132
|
+
data["command"] = {
|
133
|
+
"raw" => raw_command,
|
134
|
+
"name" => command.name,
|
135
|
+
"parameters" => arguments,
|
136
|
+
}
|
137
|
+
operations = []
|
138
|
+
each_operation do |operation|
|
139
|
+
operation_data = {}
|
140
|
+
operation_data["name"] = operation[:name]
|
141
|
+
operation_data["relative_elapsed"] = operation[:relative_elapsed_in_seconds]
|
142
|
+
operation_data["context"] = operation[:context]
|
143
|
+
operation_data["slow"] = operation[:slow?]
|
144
|
+
operations << operation_data
|
145
|
+
end
|
146
|
+
data["operations"] = operations
|
147
|
+
data
|
148
|
+
end
|
149
|
+
|
150
|
+
private
|
151
|
+
def nano_seconds_to_seconds(nano_seconds)
|
152
|
+
nano_seconds / 1000.0 / 1000.0 / 1000.0
|
153
|
+
end
|
154
|
+
|
155
|
+
def operation_context(label, context)
|
156
|
+
return nil if @select_command.nil?
|
157
|
+
|
158
|
+
case label
|
159
|
+
when "filter"
|
160
|
+
if @select_command.query and context[:query_used].nil?
|
161
|
+
context[:query_used] = true
|
162
|
+
"query: #{@select_command.query}"
|
163
|
+
else
|
164
|
+
index = context[:filter_index]
|
165
|
+
context[:filter_index] += 1
|
166
|
+
@select_command.conditions[index]
|
167
|
+
end
|
168
|
+
when "sort"
|
169
|
+
@select_command.sortby
|
170
|
+
when "score"
|
171
|
+
@select_command.scorer
|
172
|
+
when "output"
|
173
|
+
@select_command.output_columns
|
174
|
+
when "drilldown"
|
175
|
+
index = context[:drilldown_index]
|
176
|
+
context[:drilldown_index] += 1
|
177
|
+
@select_command.drilldowns[index]
|
178
|
+
else
|
179
|
+
nil
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def ensure_parse_command
|
184
|
+
return unless select_command?
|
185
|
+
@select_command = Groonga::Command::Parser.parse(@raw_command)
|
186
|
+
end
|
187
|
+
|
188
|
+
def slow_operation?(elapsed)
|
189
|
+
elapsed >= @slow_operation_threshold
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -14,8 +14,6 @@
|
|
14
14
|
# License along with this library; if not, write to the Free Software
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
|
-
module
|
18
|
-
|
19
|
-
VERSION = "1.2.8"
|
20
|
-
end
|
17
|
+
module GroongaQueryLog
|
18
|
+
VERSION = "1.2.9"
|
21
19
|
end
|
data/lib/groonga/query-log.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2017 Kouhei Sutou <kou@clear-code.com>
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -16,9 +14,23 @@
|
|
16
14
|
# License along with this library; if not, write to the Free Software
|
17
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
16
|
|
19
|
-
require "groonga
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
require "groonga-query-log"
|
18
|
+
|
19
|
+
module GroongaQueryLog
|
20
|
+
module NamespaceBackwardCompatibility
|
21
|
+
def const_missing(name)
|
22
|
+
case name
|
23
|
+
when :QueryLog
|
24
|
+
warn("Groonga::QueryLog is deprecated. Use GroongaQueryLog instead:\n" +
|
25
|
+
caller.join("\n"))
|
26
|
+
const_set(name, GroongaQueryLog)
|
27
|
+
else
|
28
|
+
super
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Groonga
|
35
|
+
extend GroongaQueryLog::NamespaceBackwardCompatibility
|
36
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (C) 2017 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "groonga/query-log"
|
18
|
+
require "groonga-query-log/command/analyzer"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C)
|
1
|
+
# Copyright (C) 2017 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -14,58 +14,5 @@
|
|
14
14
|
# License along with this library; if not, write to the Free Software
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
|
-
require "optparse"
|
18
|
-
|
19
17
|
require "groonga/query-log"
|
20
|
-
|
21
|
-
module Groonga
|
22
|
-
module QueryLog
|
23
|
-
module Command
|
24
|
-
class CheckCommandVersionCompatibility
|
25
|
-
def initialize
|
26
|
-
@options = CommandVersionCompatibilityChecker::Options.new
|
27
|
-
end
|
28
|
-
|
29
|
-
def run(command_line)
|
30
|
-
input_paths = create_parser.parse(command_line)
|
31
|
-
checker = CommandVersionCompatibilityChecker.new(@options)
|
32
|
-
checker.start do
|
33
|
-
compatible = true
|
34
|
-
if input_paths.empty?
|
35
|
-
compatible = false unless checker.check($stdin)
|
36
|
-
else
|
37
|
-
input_paths.each do |input_path|
|
38
|
-
File.open(input_path) do |input|
|
39
|
-
compatible = false unless checker.check(input)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
compatible
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
def create_parser
|
49
|
-
parser = OptionParser.new
|
50
|
-
parser.version = VERSION
|
51
|
-
parser.banner += " QUERY_LOG1 QUERY_LOG2 ..."
|
52
|
-
|
53
|
-
parser.separator("")
|
54
|
-
parser.separator("Options:")
|
55
|
-
|
56
|
-
parser.on("--target-version=VERSION", Integer,
|
57
|
-
"Check incompatibility against command version VERSION",
|
58
|
-
"[#{@options.target_version}]") do |version|
|
59
|
-
@options.target_version = version
|
60
|
-
end
|
61
|
-
|
62
|
-
parser.on("--output=PATH",
|
63
|
-
"Output results to PATH",
|
64
|
-
"[stdout]") do |path|
|
65
|
-
@options.output_path = path
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
18
|
+
require "groonga-query-log/command/check-command-version-compatibility"
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2013-2014 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2017 Kouhei Sutou <kou@clear-code.com>
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -16,78 +14,5 @@
|
|
16
14
|
# License along with this library; if not, write to the Free Software
|
17
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
16
|
|
19
|
-
require "
|
20
|
-
|
21
|
-
require "groonga/query-log/version"
|
22
|
-
require "groonga/query-log/memory-leak-detector"
|
23
|
-
|
24
|
-
module Groonga
|
25
|
-
module QueryLog
|
26
|
-
module Command
|
27
|
-
class DetectMemoryLeak
|
28
|
-
def initialize
|
29
|
-
@options = MemoryLeakDetector::Options.new
|
30
|
-
end
|
31
|
-
|
32
|
-
def run(command_line)
|
33
|
-
input_paths = create_parser.parse(command_line)
|
34
|
-
detector = MemoryLeakDetector.new(@options)
|
35
|
-
input_paths.each do |input_path|
|
36
|
-
File.open(input_path) do |input|
|
37
|
-
detector.detect(input)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
true
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
def create_parser
|
45
|
-
parser = OptionParser.new
|
46
|
-
parser.version = VERSION
|
47
|
-
parser.banner += " QUERY_LOG"
|
48
|
-
|
49
|
-
parser.separator("")
|
50
|
-
parser.separator("Options:")
|
51
|
-
|
52
|
-
parser.on("--host=HOST",
|
53
|
-
"Host name or IP address of groonga server",
|
54
|
-
"[#{@options.host}]") do |host|
|
55
|
-
@options.host = host
|
56
|
-
end
|
57
|
-
|
58
|
-
parser.on("--port=PORT", Integer,
|
59
|
-
"Port number of groonga server",
|
60
|
-
"[#{@options.port}]") do |port|
|
61
|
-
@options.port = port
|
62
|
-
end
|
63
|
-
|
64
|
-
available_protocols = [:gqtp, :http]
|
65
|
-
available_protocols_label = "[#{available_protocols.join(', ')}]"
|
66
|
-
parser.on("--protocol=PROTOCOL", available_protocols,
|
67
|
-
"Protocol of groonga server",
|
68
|
-
available_protocols_label) do |protocol|
|
69
|
-
@options.protocol = protocol
|
70
|
-
end
|
71
|
-
|
72
|
-
parser.on("--pid=PID",
|
73
|
-
"The PID of groonga server",
|
74
|
-
"[#{@options.pid}]") do |pid|
|
75
|
-
@options.pid = pid
|
76
|
-
end
|
77
|
-
|
78
|
-
parser.on("--n-tries=N", Integer,
|
79
|
-
"The number of the same request tries",
|
80
|
-
"[#{@options.n_tries}]") do |n|
|
81
|
-
@options.n_tries = n
|
82
|
-
end
|
83
|
-
|
84
|
-
parser.on("--[no-]force-disable-cache",
|
85
|
-
"Force disable cache of select command by cache=no parameter",
|
86
|
-
"[#{@options.force_disable_cache?}]") do |boolean|
|
87
|
-
@options.force_disable_cache = boolean
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
17
|
+
require "groonga/query-log"
|
18
|
+
require "groonga-query-log/command/detect-memory-leak"
|