tyrantmanager 1.1.0 → 1.2.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.
data/HISTORY.rdoc CHANGED
@@ -1,4 +1,10 @@
1
1
  = Changelog
2
+ == Version 1.2.0 2009-09-13
3
+
4
+ * have TyrantInstance use TyrantTable or Tyrant as appropriate for the connection
5
+ * WARN if the configured lua extension file is missing
6
+ * add in configuration of indexes for Table databases
7
+
2
8
  == Version 1.1.0 2009-08-10
3
9
 
4
10
  * change 'status' command to 'process-status'
@@ -158,6 +158,27 @@ Loquacious::Configuration.for( "<%= instance_name %>" ) do
158
158
 
159
159
  }
160
160
 
161
+ desc <<-txt
162
+ Column index configuration. This is in the format of 'column_name' 'index type'
163
+ Tuning parameters. Each of these alters a tuning parameter on the database.
164
+
165
+ Indexes only apply to databases of type 'table'. A column may have only one
166
+ index.
167
+
168
+ The available index types are:
169
+ | lexical - lexical string
170
+ | decimal - decimal string
171
+ | token - token inverted index
172
+ | qgram - q-gram inverted index
173
+ | optimize - the index is optimize
174
+ | void - the index is removed
175
+ txt
176
+
177
+ indexes {
178
+ # my_col [ "lexical" | "decimal" | "token" | "qgram" | "optimize" | "void" ]
179
+ }
180
+
181
+
161
182
  desc <<-txt
162
183
  The directory holding the database file. By default this is relative
163
184
  to the instance directory. If you want to put it somewhere else, then
@@ -219,6 +240,9 @@ Loquacious::Configuration.for( "<%= instance_name %>" ) do
219
240
  The name of a file to load as a lua extension. By default this
220
241
  is relative to the root of the instance directory. This file will
221
242
  only be loaded if it exists.
243
+
244
+ If this is set to a value and the file does not exist, a WARN message
245
+ is printed to the log.
222
246
  txt
223
247
  lua_extension_file "lua/<%= instance_name %>.lua"
224
248
 
@@ -166,6 +166,17 @@ class TyrantManager
166
166
  @replication_timestamp_file ||= append_to_home_if_not_absolute( configuration.replication_timestamp_file )
167
167
  end
168
168
 
169
+ #
170
+ # Valid index styles as defined by Tokyo Cabinet
171
+ #
172
+ # See Tokyo Cabinet source code, tctdbstrtoindex() in
173
+ # tctdb.c
174
+ #
175
+ def index_types
176
+ %w[ lex lexical str dec decimal num tok token qgr qgram fts void optimize ]
177
+ end
178
+
179
+
169
180
 
170
181
  #
171
182
  # Start command.
@@ -174,90 +185,103 @@ class TyrantManager
174
185
  # into one big commandline item.
175
186
  #
176
187
  def start_command
188
+ unless @start_command then
189
+ ##-- ttserver executable
190
+ parts = [ manager.configuration.ttserver ]
177
191
 
178
- ##-- ttserver executable
179
- parts = [ manager.configuration.ttserver ]
192
+ ##-- host and port
193
+ parts << "-host #{configuration.host}" if configuration.host
194
+ parts << "-port #{configuration.port}" if configuration.port
180
195
 
181
- ##-- host and port
182
- parts << "-host #{configuration.host}" if configuration.host
183
- parts << "-port #{configuration.port}" if configuration.port
196
+ ##-- thread options
197
+ if thnum = cascading_config( 'thread_count' ) then
198
+ parts << "-thnum #{thnum}"
199
+ end
200
+ if tout = cascading_config( 'session_timeout' ) then
201
+ parts << "-tout #{tout}"
202
+ end
184
203
 
185
- ##-- thread options
186
- if thnum = cascading_config( 'thread_count' ) then
187
- parts << "-thnum #{thnum}"
188
- end
189
- if tout = cascading_config( 'session_timeout' ) then
190
- parts << "-tout #{tout}"
191
- end
204
+ ##-- daemoization and pid
205
+ parts << "-dmn" if cascading_config( 'daemonize' )
206
+ parts << "-pid #{pid_file}"
207
+
208
+
209
+ ##-- logging
210
+ parts << "-log #{log_file}"
211
+ if log_level = cascading_config( 'log_level' ) then
212
+ if log_level == "error" then
213
+ parts << "-le"
214
+ elsif log_level == "debug" then
215
+ parts << "-ld"
216
+ elsif log_level == "info" then
217
+ # leave it at info
218
+ else
219
+ raise Error, "Invalid log level setting [#{log_level}]"
220
+ end
221
+ end
222
+
223
+ ##-- update logs
224
+ parts << "-ulog #{ulog_dir}"
225
+ if ulim = cascading_config( 'update_log_size' )then
226
+ parts << "-ulim #{ulim}"
227
+ end
228
+ parts << "-uas" if cascading_config( 'update_log_async' )
229
+
230
+ ##-- replication items, server id, master, replication timestamp file
231
+ parts << "-sid #{configuration.server_id}" if configuration.server_id
232
+ parts << "-mhost #{configuration.master_server}" if configuration.master_server
233
+ parts << "-mport #{configuration.master_port}" if configuration.master_port
234
+ parts << "-rts #{replication_timestamp_file}" if configuration.replication_timestamp_file
235
+
236
+ ##-- lua extension
237
+ if configuration.lua_extension_file then
238
+ if File.exist?( lua_extension_file ) then
239
+ parts << "-ext #{lua_extension_file}"
240
+ if pc = configuration.periodic_command then
241
+ if pc.name and pc.period then
242
+ parts << "-extpc #{pc.name} #{pc.period}"
243
+ end
244
+ end
245
+ else
246
+ logger.warn "lua extension file #{lua_extension_file} does not exist"
247
+ end
248
+ end
192
249
 
193
- ##-- daemoization and pid
194
- parts << "-dmn" if cascading_config( 'daemonize' )
195
- parts << "-pid #{pid_file}"
250
+ ##-- command permissiosn
251
+ if deny = cascading_config( "deny_commands" ) then
252
+ parts << "-mask #{deny.join(",")}"
253
+ end
196
254
 
255
+ if allow = cascading_config( "allow_commands" ) then
256
+ parts << "-unmask #{allow.join(",")}"
257
+ end
197
258
 
198
- ##-- logging
199
- parts << "-log #{log_file}"
200
- if log_level = cascading_config( 'log_level' ) then
201
- if log_level == "error" then
202
- parts << "-le"
203
- elsif log_level == "debug" then
204
- parts << "-ld"
205
- elsif log_level == "info" then
206
- # leave it at info
207
- else
208
- raise Error, "Invalid log level setting [#{log_level}]"
259
+ ##-- now for the filename. The format is
260
+ # filename.ext#opts=ld#mode=wc#tuning_param=value#tuning_param=value#idx=field:dec...
261
+ #
262
+ file_pairs = []
263
+ file_pairs << "opts=#{configuration.opts}"
264
+ file_pairs << "mode=#{configuration.mode}"
265
+ Loquacious::Configuration::Iterator.new( configuration.tuning_params ).each do |node|
266
+ file_pairs << "#{node.name}=#{node.obj}" if node.obj
209
267
  end
210
- end
211
268
 
212
- ##-- update logs
213
- parts << "-ulog #{ulog_dir}"
214
- if ulim = cascading_config( 'update_log_size' )then
215
- parts << "-ulim #{ulim}"
216
- end
217
- parts << "-uas" if cascading_config( 'update_log_async' )
218
-
219
- ##-- replication items, server id, master, replication timestamp file
220
- parts << "-sid #{configuration.server_id}" if configuration.server_id
221
- parts << "-mhost #{configuration.master_server}" if configuration.master_server
222
- parts << "-mport #{configuration.master_port}" if configuration.master_port
223
- parts << "-rts #{replication_timestamp_file}" if configuration.replication_timestamp_file
224
-
225
- ##-- lua extension
226
- if configuration.lua_extension_file then
227
- if File.exist?( lua_extension_file ) then
228
- parts << "-ext #{lua_extension_file}"
229
- if pc = configuration.periodic_command then
230
- if pc.name and pc.period then
231
- parts << "-extpc #{pc.name} #{pc.period}"
269
+ if configuration.type == "table" then
270
+ Loquacious::Configuration::Iterator.new( configuration.indexes ).each do |index_node|
271
+ if index_node.obj and index_types.include?( index_node.obj.downcase ) then
272
+ file_pairs << "idx=#{index_node.name}:#{index_node.obj}"
232
273
  end
233
274
  end
234
275
  end
235
- end
236
276
 
237
- ##-- command permissiosn
238
- if deny = cascading_config( "deny_commands" ) then
239
- parts << "-mask #{deny.join(",")}"
240
- end
277
+ file_name_and_params = "#{db_file}##{file_pairs.join("#")}"
241
278
 
242
- if allow = cascading_config( "allow_commands" ) then
243
- parts << "-unmask #{allow.join(",")}"
244
- end
279
+ parts << file_name_and_params
245
280
 
246
- ##-- now for the filename. The format is
247
- # filename.ext#opts=ld#mode=wc#tuning_param=value#tuning_param=value...
248
- #
249
- file_pairs = []
250
- file_pairs << "opts=#{configuration.opts}"
251
- file_pairs << "mode=#{configuration.mode}"
252
- Loquacious::Configuration::Iterator.new( configuration.tuning_params ).each do |node|
253
- file_pairs << "#{node.name}=#{node.obj}" if node.obj
281
+ @start_command = parts.join( " " )
254
282
  end
255
283
 
256
- file_name_and_params = "#{db_file}##{file_pairs.join("#")}"
257
-
258
- parts << file_name_and_params
259
-
260
- return parts.join( " " )
284
+ return @start_command
261
285
  end
262
286
 
263
287
  #
@@ -325,7 +349,12 @@ class TyrantManager
325
349
  if host == "0.0.0.0" then
326
350
  host = "localhost"
327
351
  end
328
- Rufus::Tokyo::Tyrant.new( configuration.host, configuration.port.to_i )
352
+ tclass = Rufus::Tokyo::Tyrant
353
+
354
+ if configuration.type == "table" then
355
+ tclass = Rufus::Tokyo::TyrantTable
356
+ end
357
+ tclass.new( configuration.host, configuration.port.to_i )
329
358
  end
330
359
 
331
360
  #
@@ -6,7 +6,7 @@
6
6
  class TyrantManager
7
7
  module Version
8
8
  MAJOR = 1
9
- MINOR = 1
9
+ MINOR = 2
10
10
  BUILD = 0
11
11
 
12
12
  def to_a
@@ -18,7 +18,7 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
18
18
 
19
19
  desc "Install as a gem"
20
20
  task :install => [:clobber, :package] do
21
- sh "sudo gem install pkg/#{TyrantManager::GEM_SPEC.full_name}.gem"
21
+ sh "sudo gem install pkg/#{TyrantManager::GEM_SPEC.full_name}.gem --no-rdoc --no-ri --local"
22
22
  end
23
23
 
24
24
  desc "Uninstall gem"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tyrantmanager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Hinegardner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-10 00:00:00 -06:00
12
+ date: 2009-09-13 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency