Class: Baykit::BayServer::Docker::BuiltIn::BuiltInHarborDocker

Inherits:
Baykit::BayServer::Docker::Base::DockerBase show all
Includes:
Baykit::BayServer, Bcf, Common, Constants, Harbor, Util
Defined in:
lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb

Constant Summary collapse

DEFAULT_MAX_SHIPS =
256
DEFAULT_SHIP_AGENTS =
0
DEFAULT_TRAIN_RUNNERS =
8
DEFAULT_TAXI_RUNNERS =
8
DEFAULT_WAIT_TIMEOUT_SEC =
120
DEFAULT_KEEP_TIMEOUT_SEC =
20
DEFAULT_TOUR_BUFFER_SIZE =

1M

1024 * 1024
DEFAULT_TRACE_HEADER =
false
DEFAULT_CHARSET =
"UTF-8"
DEFAULT_CONTROL_PORT =
-1
DEFAULT_MULTI_CORE =
true
DEFAULT_GZIP_COMP =
false
DEFAULT_NET_MULTIPLEXER =
MULTIPLEXER_TYPE_SPIDER
DEFAULT_FILE_MULTIPLEXER =
MULTIPLEXER_TYPE_SPIDER
DEFAULT_LOG_MULTIPLEXER =
MULTIPLEXER_TYPE_SPIDER
DEFAULT_CGI_MULTIPLEXER =
MULTIPLEXER_TYPE_SPIDER
DEFAULT_RECIPIENT =
RECIPIENT_TYPE_SPIDER
DEFAULT_PID_FILE =
"bayserver.pid"
DEFAULT_ENABLE_CACHE =
false
DEFAULT_CACHE_LIFESPAN_SEC =
60
DEFAULT_CACHE_SIZE_MB =
32

Constants included from Harbor

Harbor::MULTIPLEXER_TYPE_JOB, Harbor::MULTIPLEXER_TYPE_PIGEON, Harbor::MULTIPLEXER_TYPE_SPIDER, Harbor::MULTIPLEXER_TYPE_SPIN, Harbor::MULTIPLEXER_TYPE_TAXI, Harbor::MULTIPLEXER_TYPE_TRAIN, Harbor::RECIPIENT_TYPE_PIPE, Harbor::RECIPIENT_TYPE_SPIDER

Instance Attribute Summary collapse

Attributes inherited from Baykit::BayServer::Docker::Base::DockerBase

#type

Instance Method Summary collapse

Methods included from Harbor

get_multiplexer_type, get_multiplexer_type_name, get_recipient_type, get_recipient_type_name

Methods included from Docker

#type

Methods inherited from Baykit::BayServer::Docker::Base::DockerBase

#to_s

Constructor Details

#initializeBuiltInHarborDocker

Returns a new instance of BuiltInHarborDocker.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 122

def initialize
  @grand_agents = DEFAULT_SHIP_AGENTS
  @train_runners = DEFAULT_TRAIN_RUNNERS
  @taxi_runners = DEFAULT_TAXI_RUNNERS
  @max_ships = DEFAULT_MAX_SHIPS
  @groups = Groups.new
  @socket_timeout_sec = DEFAULT_WAIT_TIMEOUT_SEC
  @keep_timeout_sec = DEFAULT_KEEP_TIMEOUT_SEC
  @tour_buffer_size = DEFAULT_TOUR_BUFFER_SIZE
  @trace_header = DEFAULT_TRACE_HEADER
  @charset = DEFAULT_CHARSET
  @control_port = DEFAULT_CONTROL_PORT
  @multi_core = DEFAULT_MULTI_CORE
  @gzip_comp = DEFAULT_GZIP_COMP
  @net_multiplexer = DEFAULT_NET_MULTIPLEXER
  @file_multiplexer = DEFAULT_FILE_MULTIPLEXER
  @log_multiplexer = DEFAULT_LOG_MULTIPLEXER
  @cgi_multiplexer = DEFAULT_CGI_MULTIPLEXER
  @recipient = DEFAULT_RECIPIENT
  @pid_file = DEFAULT_PID_FILE
  @cache_lifespan_sec = DEFAULT_CACHE_LIFESPAN_SEC
  @cache_size_mb = DEFAULT_CACHE_SIZE_MB
end

Instance Attribute Details

#cache_lifespan_secObject (readonly)

Lifespan seconds of cache



117
118
119
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 117

def cache_lifespan_sec
  @cache_lifespan_sec
end

#cache_size_mbObject (readonly)

Cache size



120
121
122
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 120

def cache_size_mb
  @cache_size_mb
end

#cgi_multiplexerObject (readonly)

Multiplexer type of CGI input



105
106
107
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 105

def cgi_multiplexer
  @cgi_multiplexer
end

#charsetObject (readonly)

Default charset



48
49
50
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 48

def charset
  @charset
end

#control_portObject (readonly)

Port number of signal agent



90
91
92
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 90

def control_port
  @control_port
end

#enable_cacheObject (readonly)

True if cache is enabled



114
115
116
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 114

def enable_cache
  @enable_cache
end

#file_multiplexerObject (readonly)

Multiplexer type of file read



99
100
101
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 99

def file_multiplexer
  @file_multiplexer
end

#grand_agentsObject (readonly)

Number of grand agents



54
55
56
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 54

def grand_agents
  @grand_agents
end

#groupsObject (readonly)

Auth groups



81
82
83
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 81

def groups
  @groups
end

#gzip_compObject (readonly)

Gzip compression flag



87
88
89
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 87

def gzip_comp
  @gzip_comp
end

#keep_timeout_secObject (readonly)

Keep-Alive timeout in seconds



69
70
71
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 69

def keep_timeout_sec
  @keep_timeout_sec
end

#localeObject (readonly)

Default locale



51
52
53
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 51

def locale
  @locale
end

#log_multiplexerObject (readonly)

Multiplexer type of log output



102
103
104
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 102

def log_multiplexer
  @log_multiplexer
end

#max_shipsObject (readonly)

Max count of watercraft



63
64
65
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 63

def max_ships
  @max_ships
end

#multi_coreObject (readonly)

Multi core flag



93
94
95
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 93

def multi_core
  @multi_core
end

#net_multiplexerObject (readonly)

Multiplexer type of network I/O



96
97
98
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 96

def net_multiplexer
  @net_multiplexer
end

#pid_fileObject (readonly)

PID file name



111
112
113
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 111

def pid_file
  @pid_file
end

#recipientObject (readonly)

Recipient type



108
109
110
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 108

def recipient
  @recipient
end

#redirect_fileObject (readonly)

File name to redirect stdout/stderr



84
85
86
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 84

def redirect_file
  @redirect_file
end

#socket_timeout_secObject (readonly)

Socket timeout in seconds



66
67
68
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 66

def socket_timeout_sec
  @socket_timeout_sec
end

#taxi_runnersObject (readonly)

Number of taxi runners



60
61
62
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 60

def taxi_runners
  @taxi_runners
end

#tour_buffer_sizeObject (readonly)

Internal buffer size of Tour



72
73
74
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 72

def tour_buffer_size
  @tour_buffer_size
end

#trace_headerObject (readonly)

Trace req/res header flag



75
76
77
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 75

def trace_header
  @trace_header
end

#train_runnersObject (readonly)

Number of train runners



57
58
59
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 57

def train_runners
  @train_runners
end

#troubleObject (readonly)

Trouble docker



78
79
80
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 78

def trouble
  @trouble
end

Instance Method Details

#init(bcf, parent) ⇒ Object

Implements Docker



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 149

def init(bcf, parent)
  super

  if @grand_agents <= 0
    @grand_agents = SysUtil.processor_count()
  end

  if @train_runners <= 0
    @train_runners = 1
  end

  if @max_ships < DEFAULT_MAX_SHIPS
    @max_ships = DEFAULT_MAX_SHIPS
    BayLog.warn(BayMessage.get(:CFG_MAX_SHIPS_IS_TO_SMALL, @max_ships))
  end

  if @net_multiplexer == MULTIPLEXER_TYPE_TAXI ||
     @net_multiplexer == MULTIPLEXER_TYPE_TRAIN ||
     @net_multiplexer == MULTIPLEXER_TYPE_SPIN
    BayLog.warn(
      BayMessage.get(
        :CFG_NET_MULTIPLEXER_NOT_SUPPORTED,
        Harbor::get_multiplexer_type_name(@net_multiplexer),
        Harbor::get_multiplexer_type_name(DEFAULT_NET_MULTIPLEXER)))
    @net_multiplexer = DEFAULT_NET_MULTIPLEXER
  end

  if @file_multiplexer == MULTIPLEXER_TYPE_SPIDER and !SysUtil.support_select_file ||
     @file_multiplexer == MULTIPLEXER_TYPE_SPIN and !SysUtil.support_nonblock_file_read ||
     @file_multiplexer == MULTIPLEXER_TYPE_TRAIN
    BayLog.warn(
      BayMessage.get(
        :CFG_FILE_MULTIPLEXER_NOT_SUPPORTED,
        Harbor::get_multiplexer_type_name(@file_multiplexer),
        Harbor::get_multiplexer_type_name(DEFAULT_FILE_MULTIPLEXER)))
    @file_multiplexer = DEFAULT_FILE_MULTIPLEXER
  end

  if @log_multiplexer == MULTIPLEXER_TYPE_SPIDER and !SysUtil.support_select_file ||
     @log_multiplexer == MULTIPLEXER_TYPE_SPIN and !SysUtil.support_nonblock_file_write ||
     @log_multiplexer == MULTIPLEXER_TYPE_TRAIN
    BayLog.warn(
      BayMessage.get(
        :CFG_LOG_MULTIPLEXER_NOT_SUPPORTED,
        Harbor::get_multiplexer_type_name(@log_multiplexer),
        Harbor::get_multiplexer_type_name(DEFAULT_LOG_MULTIPLEXER)))
    @log_multiplexer = DEFAULT_LOG_MULTIPLEXER
  end

  if @cgi_multiplexer == MULTIPLEXER_TYPE_SPIN ||
     @cgi_multiplexer == MULTIPLEXER_TYPE_PIGEON
    BayLog.warn(
      BayMessage.get(
        :CFG_CGI_MULTIPLEXER_NOT_SUPPORTED,
        Harbor::get_multiplexer_type_name(@cgi_multiplexer),
        Harbor::get_multiplexer_type_name(DEFAULT_CGI_MULTIPLEXER)))
    @cgi_multiplexer = DEFAULT_CGI_MULTIPLEXER
  end

  if @net_multiplexer == MULTIPLEXER_TYPE_SPIDER &&
     @recipient != RECIPIENT_TYPE_SPIDER
    BayLog.warn(
      BayMessage.get(
        :CFG_NET_MULTIPLEXER_DOES_NOT_SUPPORT_THIS_RECIPIENT,
        Harbor::get_multiplexer_type_name(@net_multiplexer),
        Harbor::get_recipient_type_name(@recipient),
        Harbor::get_recipient_type_name(RECIPIENT_TYPE_SPIDER)))
    @recipient = RECIPIENT_TYPE_SPIDER
  end

end

#init_docker(dkr) ⇒ Object



221
222
223
224
225
226
227
228
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 221

def init_docker(dkr)
  if dkr.instance_of?(Trouble)
    @trouble = dkr
  else
    return super
  end
  return true
end

#init_key_val(kv) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb', line 230

def init_key_val(kv)
  case kv.key.downcase
  when "loglevel"
    BayLog.set_log_level(kv.value)
  when "charset"
    @charset = kv.value
  when "locale"
    @locale = kv.value
  when "groups"
    begin
      fname = BayServer.parse_path(kv.value)
      @groups.init(fname)
    rescue IOError => e
      raise ConfigException.new(kv.file_name, kv.line_no, BayMessage.get(:CFG_FILE_NOT_FOUND, kv.value));
    end
  when "trains"
    @train_runners = Integer(kv.value)
  when "taxis", "taxies"
    @taxi_runners = Integer(kv.value)
  when "grandagents"
    @grand_agents = Integer(kv.value)
  when "maxships"
    @max_ships = Integer(kv.value)
  when "timeout"
    @socket_timeout_sec = Integer(kv.value)
  when "keeptimeout"
    @keep_timeout_sec = Integer(kv.value)
  when "tourbuffersize"
    @tour_buffer_size = StringUtil.parse_size(kv.value)
  when "traceheader"
    @trace_header = StringUtil.parse_bool(kv.value)
  when "redirectfile"
    @redirect_file = kv.value
  when "controlport"
    @control_port = kv.value.to_i
  when "multicore"
    @multi_core = StringUtil.parse_bool(kv.value)
  when "gzipcomp"
    @gzip_comp = StringUtil.parse_bool(kv.value)

  when "netmultiplexer"
    begin
      @net_multiplexer = Harbor::get_multiplexer_type(kv.value.downcase)
    rescue => e
      BayLog.error_e(e)
      raise ConfigException.new(kv.file_name, kv.line_no, BayMessage::get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
    end

  when "filemultiplexer"
    begin
      @file_multiplexer = Harbor::get_multiplexer_type(kv.value.downcase)
    rescue => e
      BayLog.error_e(e)
      raise ConfigException.new(kv.file_name, kv.line_no, BayMessage::get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
    end

  when "logmultiplexer"
    begin
      @log_multiplexer = Harbor.get_multiplexer_type(kv.value.downcase)
    rescue => e
      BayLog.error_e(e)
      raise ConfigException.new(kv.file_name, kv.line_no, BayMessage::get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
    end

  when "cgimultiplexer"
    begin
      @cgi_multiplexer = Harbor.get_multiplexer_type(kv.value.downcase)
    rescue => e
      BayLog.error_e(e)
      raise ConfigException.new(kv.file_name, kv.line_no, BayMessage::get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
    end

  when "recipient"
    begin
      @recipient = Harbor.get_recipient_type(kv.value.downcase)
    rescue => e
      BayLog.error_e(e)
      raise ConfigException.new(kv.file_name, kv.line_no, BayMessage::get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
    end

  when "pidfile"
    @pid_file = kv.value

  when "enablecache"
    @enable_cache = StringUtil.parse_bool(kv.value)

  when "cachelifespan"
    @cache_lifespan_sec = kv.value.to_i

  when "cachesize"
    @cache_size_mb = kv.value.to_i

  else
    return false
  end
  true
end