droonga-engine 1.0.6 → 1.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e2a22b317f8d67460835b19b148b87065317f62
4
- data.tar.gz: 2dd51cbb6b2ed3f667474d45f0735f5626a989e7
3
+ metadata.gz: c9d356f5ce7ea305000e8d982a0bacd9c02c1db4
4
+ data.tar.gz: 700367d322a8b3df05ed73a6b57782d30568bf8f
5
5
  SHA512:
6
- metadata.gz: 64d02366c1dc7945091afeec62787ea1082091edb08e34f844d32cbc39ebed5839ff36cf840c4dbd7c89dff92d95e5037fbdfeadaee58af129c1aeaea8316a5c
7
- data.tar.gz: b7c88b9cab4a8f5b438d789cb78cee50080efb4d78b826829b1057a3412d7b930fe99ab52ee2e2d899e98ca3725c4df244461671598e51adf455dafb99d55ce7
6
+ metadata.gz: b99cb2c1e4fa3df7d96700499277e37c6c7c37ba3eabeba5eb0721232712911d1cb691fc10f3159196b5633224d96f47fc66f4e279479643042282d2b3bc0654
7
+ data.tar.gz: 766e53f931fa1ea0c5ca58614bdaa9627cd382b84be60673cdcd35a9842739d097d9b3b9f9105eb6b675fec6cdbe480994b7ededd7802d287d512cc6234096b5
@@ -23,6 +23,7 @@ require "droonga/path"
23
23
  require "droonga/command/droonga_engine"
24
24
  require "droonga/safe_file_writer"
25
25
  require "droonga/service_installation"
26
+ require "droonga/logger"
26
27
 
27
28
  options = {
28
29
  :quiet => nil,
@@ -178,7 +179,9 @@ if options[:reset_config]
178
179
  if configuration.have_given_log_level? or options[:quiet]
179
180
  log_level = configuration.log_level
180
181
  else
181
- log_level = input("log level", configuration.log_level)
182
+ levels = Droonga::Logger::Level::LABELS
183
+ levels_label = levels.join(",")
184
+ log_level = input("log level (#{levels_label})", configuration.log_level)
182
185
  end
183
186
 
184
187
  new_configuration = {
data/install.sh CHANGED
@@ -43,6 +43,7 @@ TEMPDIR=/tmp/install-$NAME
43
43
 
44
44
  : ${VERSION:=release}
45
45
  : ${HOST:=Auto Detect}
46
+ : ${PORT:=10031}
46
47
 
47
48
  case $(uname) in
48
49
  Darwin|*BSD|CYGWIN*) sed="sed -E" ;;
@@ -133,7 +134,7 @@ setup_configuration_directory() {
133
134
  fi
134
135
 
135
136
  droonga-engine-configure --quiet \
136
- --host=$HOST
137
+ --host=$HOST --port=$PORT
137
138
  if [ $? -ne 0 ]; then
138
139
  echo "ERROR: Failed to configure $NAME!"
139
140
  exit 1
@@ -20,6 +20,11 @@ cd $DROONGA_BASE_DIR
20
20
  PIDFILE=/run/$NAME/$NAME.pid
21
21
  DAEMON_ARGS="--daemon --pid-file=$PIDFILE"
22
22
 
23
+ # This directory is required to write PID file by non-root user.
24
+ pid_dir=/run/$NAME
25
+ mkdir -p $pid_dir
26
+ chown -R $USER:$GROUP $pid_dir
27
+
23
28
  [ -x $DAEMON ] || exit 0
24
29
 
25
30
  start() {
@@ -20,10 +20,6 @@ register_service() {
20
20
 
21
21
  #TODO: we should migrate to systemd in near future...
22
22
 
23
- local pid_dir=/run/$NAME
24
- mkdir -p $pid_dir
25
- chown -R $USER:$GROUP $pid_dir
26
-
27
23
  curl -o /etc/rc.d/init.d/$NAME $(download_url "install/centos/$NAME")
28
24
  if [ $? -ne 0 ]; then
29
25
  echo "ERROR: Failed to download service script!"
@@ -22,6 +22,11 @@ PIDFILE=/var/run/$NAME/$NAME.pid
22
22
  DAEMON_ARGS="--daemon --pid-file=$PIDFILE"
23
23
  SCRIPTNAME=/etc/init.d/$NAME
24
24
 
25
+ # This directory is required to write PID file by non-root user.
26
+ pid_dir=/var/run/$NAME
27
+ mkdir -p $pid_dir
28
+ chown -R $USER:$GROUP $pid_dir
29
+
25
30
  # Exit if the package is not installed
26
31
  [ -x "$DAEMON" ] || exit 0
27
32
 
@@ -18,10 +18,6 @@ register_service() {
18
18
  local USER=$2
19
19
  local GROUP=$3
20
20
 
21
- local pid_dir=/var/run/$NAME
22
- mkdir -p $pid_dir
23
- chown -R $USER:$GROUP $pid_dir
24
-
25
21
  curl -o /etc/init.d/$NAME $(download_url "install/debian/$NAME")
26
22
  if [ $? -ne 0 ]; then
27
23
  echo "ERROR: Failed to download service script!"
@@ -36,6 +36,7 @@ module Droonga
36
36
  end
37
37
 
38
38
  DEFAULT_HOST = Socket.gethostname
39
+ DEFAULT_HOST.force_encoding("US-ASCII") if DEFAULT_HOST.ascii_only?
39
40
  DEFAULT_PORT = 10031
40
41
  DEFAULT_TAG = "droonga"
41
42
 
@@ -114,7 +114,7 @@ module Droonga
114
114
 
115
115
  class Configuration
116
116
  attr_reader :host, :port, :tag, :log_file, :pid_file_path
117
- attr_reader :ready_notify_fd
117
+ attr_reader :ready_notify_fd, :orchestrated
118
118
  def initialize
119
119
  config = load_config
120
120
 
@@ -128,6 +128,7 @@ module Droonga
128
128
  @daemon = false
129
129
  @pid_file_path = nil
130
130
  @ready_notify_fd = nil
131
+ @orchestrated = true
131
132
 
132
133
  if have_config_file?
133
134
  if config.include?("daemon")
@@ -224,6 +225,7 @@ module Droonga
224
225
  add_log_options(parser)
225
226
  add_process_options(parser)
226
227
  add_path_options(parser)
228
+ add_orchestration_options(parser)
227
229
  add_notification_options(parser)
228
230
  end
229
231
 
@@ -308,6 +310,13 @@ module Droonga
308
310
  end
309
311
  end
310
312
 
313
+ def add_orchestration_options(parser)
314
+ parser.on("--no-orchestration",
315
+ "Disable orchestration with other nodes") do
316
+ @orchestrated = false
317
+ end
318
+ end
319
+
311
320
  def add_notification_options(parser)
312
321
  parser.separator("")
313
322
  parser.separator("Notification:")
@@ -339,7 +348,7 @@ module Droonga
339
348
 
340
349
  trap_signals
341
350
  @loop.run
342
- @serf.stop if @serf.running?
351
+ @serf.stop if @serf and @serf.running?
343
352
 
344
353
  @service_runner.success?
345
354
  end
@@ -380,14 +389,14 @@ module Droonga
380
389
 
381
390
  def stop_gracefully
382
391
  @command_runner.stop
383
- @serf.stop
392
+ @serf.stop if @serf
384
393
  @catalog_observer.stop
385
394
  @service_runner.stop_gracefully
386
395
  end
387
396
 
388
397
  def stop_immediately
389
398
  @command_runner.stop
390
- @serf.stop
399
+ @serf.stop if @serf
391
400
  @catalog_observer.stop
392
401
  @service_runner.stop_immediately
393
402
  end
@@ -418,6 +427,7 @@ module Droonga
418
427
  end
419
428
 
420
429
  def run_serf
430
+ return nil unless @configuration.orchestrated
421
431
  serf = Serf.new(@loop, @configuration.engine_name)
422
432
  serf.start
423
433
  serf
@@ -15,6 +15,6 @@
15
15
 
16
16
  module Droonga
17
17
  class Engine
18
- VERSION = "1.0.6"
18
+ VERSION = "1.0.7"
19
19
  end
20
20
  end
@@ -19,6 +19,7 @@ module Droonga
19
19
  module Plugins
20
20
  module Groonga
21
21
  module Select
22
+ DEFAULT_QUERY_FLAGS = "ALLOW_PRAGMA|ALLOW_COLUMN"
22
23
  DRILLDOWN_RESULT_PREFIX = "drilldown_result_"
23
24
 
24
25
  class RequestConverter
@@ -89,13 +90,13 @@ module Droonga
89
90
 
90
91
  conditions = []
91
92
  if query
92
- conditions << {
93
+ condition = {
93
94
  "query" => query,
94
95
  "matchTo"=> match_to,
95
96
  "defaultOperator"=> "&&",
96
- "allowPragma"=> false,
97
- "allowColumn"=> true,
98
97
  }
98
+ apply_query_flags(condition, select_request["query_flags"])
99
+ conditions << condition
99
100
  end
100
101
 
101
102
  if filter
@@ -114,6 +115,15 @@ module Droonga
114
115
  condition
115
116
  end
116
117
 
118
+ def apply_query_flags(condition, flags)
119
+ flags ||= DEFAULT_QUERY_FLAGS
120
+ flags = flags.split("|")
121
+ condition["allowPragma"] = flags.include?("ALLOW_PRAGMA")
122
+ condition["allowColumn"] = flags.include?("ALLOW_COLUMN")
123
+ condition["allowUpdate"] = flags.include?("ALLOW_UPDATE")
124
+ condition["allowLeadingNot"] = flags.include?("ALLOW_LEADING_NOT")
125
+ end
126
+
117
127
  def convert_drilldown(select_request)
118
128
  drilldown_keys = select_request["drilldown"]
119
129
  return nil if drilldown_keys.nil? or drilldown_keys.empty?
@@ -265,6 +265,10 @@ module Droonga
265
265
  query = condition["query"]
266
266
  if query
267
267
  options[:syntax] = :query
268
+ options[:allow_pragma] = true
269
+ options[:allow_column] = true
270
+ options[:allow_update] = false
271
+ options[:allow_leading_not] = false
268
272
  if condition["defaultOperator"]
269
273
  default_operator_string = condition["defaultOperator"]
270
274
  default_operator = OPERATOR_CONVERSION_TABLE[default_operator_string]
@@ -273,11 +277,21 @@ module Droonga
273
277
  end
274
278
  options[:default_operator] = default_operator
275
279
  end
276
- if condition["allowPragma"]
277
- options[:allow_pragma] = true
280
+ unless condition["allowPragma"].nil?
281
+ options[:allow_pragma] = condition["allowPragma"] ? true : false
278
282
  end
279
- if condition["allowColumn"]
280
- options[:allow_column] = true
283
+ unless condition["allowColumn"].nil?
284
+ options[:allow_column] = condition["allowColumn"] ? true : false
285
+ end
286
+ #XXX Currently we disallow to set this option to true, because
287
+ # a `search` command is handled only on one replica and ignored by other replicas.
288
+ # If we simply allow allowUpdate=true, replicas can be un-synchronized.
289
+ # We have to do something about this problem.
290
+ # unless condition["allowUpdate"].nil?
291
+ # options[:allow_update] = condition["allowUpdate"] ? true : false
292
+ # end
293
+ unless condition["allowLeadingNot"].nil?
294
+ options[:allow_leading_not] = condition["allowLeadingNot"] ? true : false
281
295
  end
282
296
  syntax_errors = [
283
297
  Groonga::SyntaxError,
@@ -29,6 +29,7 @@ lib_dir = File.expand_path(File.join(base_dir, "..", "..", "lib"))
29
29
 
30
30
  drntest_options = []
31
31
  drntest_options.concat(["--base-path", base_dir])
32
+ drntest_options.concat(["--droonga-engine-options", "--no-orchestration"])
32
33
  drntest_options.concat(ARGV)
33
34
 
34
35
  run("bundle", "exec", "drntest", *drntest_options)
@@ -83,8 +83,10 @@ class GroongaSelectAdapterInputTest < Test::Unit::TestCase
83
83
  "query" => "QueryTest",
84
84
  "matchTo"=> expected_matchTo,
85
85
  "defaultOperator"=> "&&",
86
- "allowPragma"=> false,
86
+ "allowPragma"=> true,
87
87
  "allowColumn"=> true,
88
+ "allowUpdate"=> false,
89
+ "allowLeadingNot" => false,
88
90
  },
89
91
  "output" => {
90
92
  "elements" => [
@@ -165,8 +167,10 @@ class GroongaSelectAdapterInputTest < Test::Unit::TestCase
165
167
  "query" => "QueryTest",
166
168
  "matchTo"=> ["_key"],
167
169
  "defaultOperator"=> "&&",
168
- "allowPragma"=> false,
170
+ "allowPragma"=> true,
169
171
  "allowColumn"=> true,
172
+ "allowUpdate"=> false,
173
+ "allowLeadingNot" => false,
170
174
  },
171
175
  "title@'FilterTest'",
172
176
  ],
@@ -189,6 +193,88 @@ class GroongaSelectAdapterInputTest < Test::Unit::TestCase
189
193
  end
190
194
  end
191
195
 
196
+ class QueryFlagsTest < self
197
+ def test_none
198
+ select_request = {
199
+ "table" => "EmptyTable",
200
+ "match_columns" => "_key",
201
+ "query" => "QueryTest",
202
+ "query_flags" => "NONE",
203
+ }
204
+ expected_search_condition = {
205
+ "query" => "QueryTest",
206
+ "matchTo"=> ["_key"],
207
+ "defaultOperator"=> "&&",
208
+ "allowPragma" => false,
209
+ "allowColumn" => false,
210
+ "allowUpdate"=> false,
211
+ "allowLeadingNot" => false,
212
+ }
213
+ assert_equal(expected_search_condition,
214
+ convert(select_request)["queries"]["EmptyTable_result"]["condition"])
215
+ end
216
+
217
+ def test_allow_pragma_only
218
+ select_request = {
219
+ "table" => "EmptyTable",
220
+ "match_columns" => "_key",
221
+ "query" => "QueryTest",
222
+ "query_flags" => "ALLOW_PRAGMA",
223
+ }
224
+ expected_search_condition = {
225
+ "query" => "QueryTest",
226
+ "matchTo"=> ["_key"],
227
+ "defaultOperator"=> "&&",
228
+ "allowPragma" => true,
229
+ "allowColumn" => false,
230
+ "allowUpdate"=> false,
231
+ "allowLeadingNot" => false,
232
+ }
233
+ assert_equal(expected_search_condition,
234
+ convert(select_request)["queries"]["EmptyTable_result"]["condition"])
235
+ end
236
+
237
+ def test_allow_column_only
238
+ select_request = {
239
+ "table" => "EmptyTable",
240
+ "match_columns" => "_key",
241
+ "query" => "QueryTest",
242
+ "query_flags" => "ALLOW_COLUMN",
243
+ }
244
+ expected_search_condition = {
245
+ "query" => "QueryTest",
246
+ "matchTo"=> ["_key"],
247
+ "defaultOperator"=> "&&",
248
+ "allowPragma" => false,
249
+ "allowColumn" => true,
250
+ "allowUpdate"=> false,
251
+ "allowLeadingNot" => false,
252
+ }
253
+ assert_equal(expected_search_condition,
254
+ convert(select_request)["queries"]["EmptyTable_result"]["condition"])
255
+ end
256
+
257
+ def test_allow_leading_not_only
258
+ select_request = {
259
+ "table" => "EmptyTable",
260
+ "match_columns" => "_key",
261
+ "query" => "QueryTest",
262
+ "query_flags" => "ALLOW_LEADING_NOT",
263
+ }
264
+ expected_search_condition = {
265
+ "query" => "QueryTest",
266
+ "matchTo"=> ["_key"],
267
+ "defaultOperator"=> "&&",
268
+ "allowPragma" => false,
269
+ "allowColumn" => false,
270
+ "allowUpdate"=> false,
271
+ "allowLeadingNot" => true,
272
+ }
273
+ assert_equal(expected_search_condition,
274
+ convert(select_request)["queries"]["EmptyTable_result"]["condition"])
275
+ end
276
+ end
277
+
192
278
  class OffsetTest < self
193
279
  def assert_offset(expected_offset, offset)
194
280
  select_request = {
@@ -44,6 +44,10 @@ class TableListTest < GroongaHandlerTest
44
44
  end
45
45
 
46
46
  class ListTest < self
47
+ def table_path
48
+ @database_path.to_s + ".0000100"
49
+ end
50
+
47
51
  def test_hash_table
48
52
  Groonga::Schema.define do |schema|
49
53
  schema.create_table("Books", :type => :hash)
@@ -53,7 +57,7 @@ class TableListTest < GroongaHandlerTest
53
57
  TABLES_HEADER,
54
58
  [256,
55
59
  "Books",
56
- @database_path.to_s + ".0000100",
60
+ table_path,
57
61
  "TABLE_HASH_KEY|PERSISTENT",
58
62
  "ShortText",
59
63
  nil,
@@ -72,7 +76,7 @@ class TableListTest < GroongaHandlerTest
72
76
  TABLES_HEADER,
73
77
  [256,
74
78
  "HistoryEntries",
75
- @database_path.to_s + ".0000100",
79
+ table_path,
76
80
  "TABLE_NO_KEY|PERSISTENT",
77
81
  nil,
78
82
  nil,
@@ -91,7 +95,7 @@ class TableListTest < GroongaHandlerTest
91
95
  TABLES_HEADER,
92
96
  [256,
93
97
  "Books",
94
- @database_path.to_s + ".0000100",
98
+ table_path,
95
99
  "TABLE_PAT_KEY|PERSISTENT",
96
100
  "ShortText",
97
101
  nil,
@@ -110,7 +114,7 @@ class TableListTest < GroongaHandlerTest
110
114
  TABLES_HEADER,
111
115
  [256,
112
116
  "Books",
113
- @database_path.to_s + ".0000100",
117
+ table_path,
114
118
  "TABLE_DAT_KEY|PERSISTENT",
115
119
  "ShortText",
116
120
  nil,
@@ -131,7 +135,7 @@ class TableListTest < GroongaHandlerTest
131
135
  TABLES_HEADER,
132
136
  [256,
133
137
  "BookIds",
134
- @database_path.to_s + ".0000100",
138
+ table_path,
135
139
  "TABLE_HASH_KEY|PERSISTENT",
136
140
  "UInt32",
137
141
  "UInt32",
@@ -151,7 +155,7 @@ class TableListTest < GroongaHandlerTest
151
155
  TABLES_HEADER,
152
156
  [256,
153
157
  "Books",
154
- @database_path.to_s + ".0000100",
158
+ table_path,
155
159
  "TABLE_HASH_KEY|PERSISTENT",
156
160
  "ShortText",
157
161
  nil,
@@ -171,7 +175,7 @@ class TableListTest < GroongaHandlerTest
171
175
  TABLES_HEADER,
172
176
  [256,
173
177
  "Books",
174
- @database_path.to_s + ".0000100",
178
+ table_path,
175
179
  "TABLE_HASH_KEY|PERSISTENT",
176
180
  "ShortText",
177
181
  nil,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: droonga-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Droonga Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-29 00:00:00.000000000 Z
11
+ date: 2014-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: archive-zip