oml4r 2.9.5 → 2.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +8 -8
- data/lib/oml4r.rb +200 -71
- data/lib/oml4r/version.rb +1 -1
- metadata +27 -45
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d3d1eb545b9421f2879295e80e877f4f062c23d9
|
4
|
+
data.tar.gz: efdf663660b0bb02826371fe2a452b7a85575d99
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3df9d5505c1d71b4f0f789a1159dbe8b42a736a393edc13f2e7d94e69c382d8e5d365822f0c4ba8cb07164b6e6dbe36989ef132ea61b599621b5cfef1025aa32
|
7
|
+
data.tar.gz: 22de82d382d2fc8559629a8fd015bc65684d76ae1937f6937a092a2d0ff1b872df744594d00df124a156876648fad9d6674d243d63fef3a435591f640277cbd6
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
OML4R: Native OML Implementation in Ruby
|
1
|
+
OML4R: Native OML Implementation in Ruby
|
2
2
|
========================================
|
3
3
|
|
4
4
|
This is a simple client library for OML which does not use liboml2 and its
|
5
|
-
filters, but connects directly to the server using the text protocol [
|
5
|
+
filters, but connects directly to the server using the text protocol [omsp].
|
6
6
|
User can use this library to create ruby applications which can send
|
7
7
|
measurement to the OML collection server. A simple example on how to use
|
8
8
|
this library is attached at the end of this file. Another example can be
|
@@ -31,9 +31,9 @@ Usage
|
|
31
31
|
|
32
32
|
### Initialisation, Injection and Tear-down
|
33
33
|
|
34
|
-
OML4R::init(ARGV,
|
34
|
+
OML4R::init(ARGV,
|
35
35
|
:appName => 'oml4rSimpleExample',
|
36
|
-
:domain => 'foo',
|
36
|
+
:domain => 'foo',
|
37
37
|
:nodeID => 'n1',
|
38
38
|
)
|
39
39
|
MyMP.inject("hello", 13, 37.1)
|
@@ -59,11 +59,11 @@ this with the 'channel' abstraction.
|
|
59
59
|
param :b_val, :type => :int32
|
60
60
|
end
|
61
61
|
|
62
|
-
OML4R::init(ARGV,
|
62
|
+
OML4R::init(ARGV,
|
63
63
|
:appName => 'doubleAgent',
|
64
|
-
:domain => 'foo'
|
64
|
+
:domain => 'foo'
|
65
65
|
)
|
66
|
-
OML4R::create_channel(:archive, 'file:/tmp/archive.log')
|
66
|
+
OML4R::create_channel(:archive, 'file:/tmp/archive.log')
|
67
67
|
|
68
68
|
Setting the command line flag '--oml-collect' will define a ':default' channel. Any additional channels
|
69
69
|
need to be declared with 'OML4R::create_channel' which takes two arguments, the name of the channel
|
@@ -76,7 +76,7 @@ Please note that by declaring a specific channel, every MP needs at least one ch
|
|
76
76
|
|
77
77
|
See examples files oml4r-simple-example.rb and oml4r-wlanconfig.rb.
|
78
78
|
|
79
|
-
[
|
79
|
+
[omsp]: http://oml.mytestbed.net/projects/oml/wiki/OML_Measurement_Stream_Protocol_(OMSP)_Specification
|
80
80
|
[oml4r-rubygem]: https://rubygems.org/gems/oml4r/
|
81
81
|
|
82
82
|
License
|
data/lib/oml4r.rb
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
# User can use this library to create ruby applications which can send
|
14
14
|
# measurement to the OML collection server.
|
15
15
|
#
|
16
|
+
|
17
|
+
require 'set'
|
16
18
|
require 'socket'
|
17
19
|
require 'monitor'
|
18
20
|
require 'thread'
|
@@ -20,6 +22,7 @@ require 'optparse'
|
|
20
22
|
|
21
23
|
require 'oml4r/version'
|
22
24
|
|
25
|
+
|
23
26
|
#
|
24
27
|
# This is the OML4R module, which should be required by ruby applications
|
25
28
|
# that want to collect measurements via OML
|
@@ -27,7 +30,7 @@ require 'oml4r/version'
|
|
27
30
|
module OML4R
|
28
31
|
|
29
32
|
DEF_SERVER_PORT = 3003
|
30
|
-
DEF_PROTOCOL =
|
33
|
+
DEF_PROTOCOL = 4
|
31
34
|
|
32
35
|
# Overwrite the default logger
|
33
36
|
#
|
@@ -51,9 +54,11 @@ module OML4R
|
|
51
54
|
# Some Class variables
|
52
55
|
@@defs = {}
|
53
56
|
@@channels = {}
|
57
|
+
@@channelNames = {}
|
54
58
|
@@frozen = false
|
55
59
|
@@useOML = false
|
56
60
|
@@start_time = nil
|
61
|
+
@@newDefs = Set[]
|
57
62
|
|
58
63
|
# Execute a block for each defined MP
|
59
64
|
def self.each_mp(&block)
|
@@ -71,6 +76,7 @@ module OML4R
|
|
71
76
|
defs = @@defs[self] = {}
|
72
77
|
defs[:p_def] = []
|
73
78
|
defs[:seq_no] = 0
|
79
|
+
defs[:meta_no] = 0
|
74
80
|
end
|
75
81
|
defs
|
76
82
|
end
|
@@ -81,10 +87,18 @@ module OML4R
|
|
81
87
|
# opts add_prefix Add app name as prefix to table. Default: true
|
82
88
|
#
|
83
89
|
def self.name(name, opts = {})
|
90
|
+
|
91
|
+
# ok, lets add it then
|
84
92
|
if opts[:add_prefix].nil?
|
85
93
|
opts[:add_prefix] = true
|
86
94
|
end
|
87
95
|
__def__()[:name] = {:name => name, :opts => opts}
|
96
|
+
|
97
|
+
# if we're frozen remember to inject schema before measurements
|
98
|
+
if @@frozen
|
99
|
+
@@newDefs.add self
|
100
|
+
end
|
101
|
+
|
88
102
|
end
|
89
103
|
|
90
104
|
# Set the channel these measurements should be sent out on.
|
@@ -92,23 +106,20 @@ module OML4R
|
|
92
106
|
# the channel defined by the command line arguments or environment variables.
|
93
107
|
#
|
94
108
|
def self.channel(channel, domain = :default)
|
95
|
-
(@@
|
109
|
+
(@@channelNames[self] ||= []) << [channel, domain]
|
96
110
|
end
|
97
111
|
|
98
112
|
# Set a metric for this MP
|
99
113
|
# - name = name of the metric to set
|
100
114
|
# - opts = a Hash with the options for this metric
|
101
|
-
# Only supported option is :type = { :string | :int32 | :double }
|
115
|
+
# Only supported option is :type = { :string | :int32 | :double | :bool }
|
102
116
|
def self.param(name, opts = {})
|
103
117
|
o = opts.dup
|
104
118
|
o[:name] = name
|
105
119
|
o[:type] ||= :string
|
106
|
-
|
107
|
-
when :long
|
120
|
+
if :long == o[:type]
|
108
121
|
OML4R.logger.warn ":long is deprecated use, :int32 instead"
|
109
122
|
o[:type] = :int32
|
110
|
-
when :boolean
|
111
|
-
o[:type] = :int32 # TODO: Hopefully we can remove this soon
|
112
123
|
end
|
113
124
|
__def__()[:p_def] << o
|
114
125
|
nil
|
@@ -119,8 +130,41 @@ module OML4R
|
|
119
130
|
# - args = a list of arguments (comma separated) which correspond to the
|
120
131
|
# different values of the metrics for the measurement to inject
|
121
132
|
def self.inject(*args)
|
133
|
+
|
122
134
|
return unless @@useOML
|
123
135
|
|
136
|
+
# Do we need to send a schema update?
|
137
|
+
if @@newDefs.include? self
|
138
|
+
defs = @@defs[self]
|
139
|
+
mp_name_def = defs[:name]
|
140
|
+
mp_name = mp_name_def[:name]
|
141
|
+
pdefs = defs[:p_def]
|
142
|
+
defs[:types] = pdefs.map {|h| h[:type]}
|
143
|
+
# prepare the message header
|
144
|
+
a = []
|
145
|
+
a << Time.now - @@start_time
|
146
|
+
a << "0"
|
147
|
+
a << (defs[:meta_no] += 1)
|
148
|
+
a << "."
|
149
|
+
a << "schema"
|
150
|
+
msg = a.join("\t")
|
151
|
+
# Create the channels
|
152
|
+
names = @@channelNames[self] || []
|
153
|
+
chans = names.collect do |cname, domain|
|
154
|
+
[Channel[cname.to_sym, domain.to_sym]]
|
155
|
+
end
|
156
|
+
@@channels[self] = chans.empty? ? [[Channel[]]] : chans
|
157
|
+
# Now inject the schema
|
158
|
+
meta_ca = @@channels[OML4R::ExperimentMetadata][0]
|
159
|
+
channel = meta_ca[0]
|
160
|
+
schema_info = channel.build_schema(mp_name, mp_name_def[:opts][:add_prefix], pdefs)
|
161
|
+
channel.send_schema_update(msg + "\t" + schema_info[1])
|
162
|
+
@@channels[self].each do |ca|
|
163
|
+
ca << schema_info[0]
|
164
|
+
end
|
165
|
+
@@newDefs.delete self
|
166
|
+
end
|
167
|
+
|
124
168
|
# Check that the list of values passed as argument matches the
|
125
169
|
# definition of this Measurement Point
|
126
170
|
defs = __def__()
|
@@ -138,10 +182,10 @@ module OML4R
|
|
138
182
|
case types[i]
|
139
183
|
when :string
|
140
184
|
# Escape tabs and newlines
|
141
|
-
arg = arg.to_s.gsub("\n", "\\n").gsub("\t", "\\t")
|
142
|
-
when :
|
143
|
-
# boolean
|
144
|
-
arg = arg ?
|
185
|
+
arg = arg.to_s.gsub("\\", "\\\\").gsub("\r", "\\r").gsub("\n", "\\n").gsub("\t", "\\t")
|
186
|
+
when :bool
|
187
|
+
# Convert boolean value to appropriate literal
|
188
|
+
arg = arg ? "True" : "False"
|
145
189
|
when :blob
|
146
190
|
arg = [arg].pack("m")
|
147
191
|
end
|
@@ -157,6 +201,13 @@ module OML4R
|
|
157
201
|
args
|
158
202
|
end
|
159
203
|
|
204
|
+
# Inject measurement metadata from this Measurement Point to the
|
205
|
+
# OML Server.
|
206
|
+
#
|
207
|
+
# def self.inject_metadata(key, value, fname)
|
208
|
+
# MPBase::__inject_metadata__(@name, key, value, fname)
|
209
|
+
# end
|
210
|
+
|
160
211
|
def self.start_time()
|
161
212
|
@@start_time
|
162
213
|
end
|
@@ -173,14 +224,14 @@ module OML4R
|
|
173
224
|
|
174
225
|
# replace channel names with channel object
|
175
226
|
self.each_mp do |klass, defs|
|
176
|
-
|
177
|
-
OML4R.logger.debug "'#{
|
178
|
-
|
227
|
+
names = @@channelNames[klass] || []
|
228
|
+
OML4R.logger.debug "'#{names.inspect}', '#{klass}'"
|
229
|
+
chans = names.collect do |cname, domain|
|
179
230
|
# return it in an array as we need to add the channel specific index
|
180
231
|
[Channel[cname.to_sym, domain.to_sym]]
|
181
232
|
end
|
182
|
-
OML4R.logger.debug "Using channels '#{
|
183
|
-
@@channels[klass] =
|
233
|
+
OML4R.logger.debug "Using channels '#{chans.inspect}"
|
234
|
+
@@channels[klass] = chans.empty? ? [[Channel[]]] : chans
|
184
235
|
end
|
185
236
|
@@start_time = start_time
|
186
237
|
end
|
@@ -204,21 +255,17 @@ module OML4R
|
|
204
255
|
unless (mp_name_def = defs[:name])
|
205
256
|
raise MissingArgumentException.new "Missing 'name' declaration for '#{self}'"
|
206
257
|
end
|
207
|
-
mp_name = mp_name_def[:name]
|
208
|
-
if !name_prefix.nil? && mp_name_def[:opts][:add_prefix]
|
209
|
-
mp_name = "#{name_prefix}_#{mp_name}"
|
210
|
-
end
|
211
258
|
|
259
|
+
# Build the schema
|
260
|
+
mp_name = mp_name_def[:name]
|
212
261
|
@@channels[self].each do |ca|
|
213
262
|
OML4R.logger.debug "Setting up channel '#{ca.inspect}"
|
214
|
-
|
215
|
-
ca <<
|
263
|
+
schema_info = ca[0].build_schema(mp_name, mp_name_def[:opts][:add_prefix], defs[:p_def])
|
264
|
+
ca << schema_info[0]
|
216
265
|
end
|
217
266
|
end
|
218
267
|
end # class MPBase
|
219
268
|
|
220
|
-
|
221
|
-
|
222
269
|
#
|
223
270
|
# The Init method of OML4R
|
224
271
|
# Ruby applications should call this method to initialise the OML4R module
|
@@ -238,8 +285,7 @@ module OML4R
|
|
238
285
|
# param block = a block which defines the additional application-specific arguments
|
239
286
|
#
|
240
287
|
def self.init(argv, opts = {}, &block)
|
241
|
-
OML4R#{
|
242
|
-
|
288
|
+
OML4R.logger.info "V#{VERSION} #{COPYRIGHT}"
|
243
289
|
if d = (ENV['OML_EXP_ID'] || opts[:expID])
|
244
290
|
# NOTE: It is still too early to complain about that. We need to be sure
|
245
291
|
# of the nomenclature before making user-visible changes.
|
@@ -270,6 +316,7 @@ module OML4R
|
|
270
316
|
end
|
271
317
|
opts[:collect] = ENV['OML_COLLECT'] || ENV['OML_SERVER'] || opts[:collect] || opts[:omlServer]
|
272
318
|
noop = opts[:noop] || false
|
319
|
+
omlConfigFile = nil
|
273
320
|
|
274
321
|
if argv
|
275
322
|
# Create a new Parser for the command line
|
@@ -283,6 +330,7 @@ module OML4R
|
|
283
330
|
op.on("--oml-protocol p", "Protocol number [#{OML4R::DEF_PROTOCOL}]") { |l| opts[:protocol] = l.to_i }
|
284
331
|
op.on("--oml-log-level l", "Log level used (info: 1 .. debug: 0)") { |l| OML4R.logger.level = l.to_i }
|
285
332
|
op.on("--oml-noop", "Do not collect measurements") { noop = true }
|
333
|
+
op.on("--oml-config file", "File holding OML configuration parameters") { |f| omlConfigFile = f }
|
286
334
|
op.on("--oml-exp-id domain", "Obsolescent equivalent to --oml-domain domain") { |name|
|
287
335
|
domain = name
|
288
336
|
OML4R.logger.warn "Option --oml-exp-id is getting deprecated; please use '--oml-domain #{domain}' instead"
|
@@ -306,10 +354,25 @@ module OML4R
|
|
306
354
|
# give the app a chance to fix missing parameters
|
307
355
|
opts[:afterParse].call(opts)
|
308
356
|
end
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
357
|
+
return if noop
|
358
|
+
# Parameters in OML config file takes precedence
|
359
|
+
unless omlConfigFile.nil?
|
360
|
+
f = File.open(omlConfigFile, 'r')
|
361
|
+
f.each_line do |l|
|
362
|
+
d = l[/.*experiment=["']([^["']]*)/,1]
|
363
|
+
opts[:domain] = d if d
|
364
|
+
d = l[/.*domain=["']([^["']]*)/,1]
|
365
|
+
opts[:domain] = d if d
|
366
|
+
i = l[/.*id=["']([^["']]*)/,1]
|
367
|
+
opts[:nodeID] = i if i
|
368
|
+
u = l[/.*url=["']([^["']]*)/,1]
|
369
|
+
opts[:omlCollectUri] = u if u
|
370
|
+
end
|
371
|
+
f.close
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
unless opts[:nodeID]
|
313
376
|
begin
|
314
377
|
# Create a default nodeID by concatinating the local hostname with the process ID
|
315
378
|
hostname = nil
|
@@ -334,16 +397,12 @@ module OML4R
|
|
334
397
|
raise MissingArgumentException.new 'OML4R: Missing values for parameters :domain (--oml-domain), :nodeID (--oml-id), or :appName (in code)!'
|
335
398
|
end
|
336
399
|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
OML4R.logger.info "Collection URI is #{opts[:omlCollectUri]}"
|
344
|
-
end
|
345
|
-
create_channel(:default, opts[:omlCollectUri])
|
346
|
-
end
|
400
|
+
# Set a default collection URI if nothing has been specified
|
401
|
+
opts[:omlCollectUri] ||= "file:#{opts[:appName]}_#{opts[:nodeID]}_#{opts[:domain]}_#{Time.now.strftime("%Y-%m-%dt%H.%M.%S%z")}"
|
402
|
+
opts[:omlCollectUri] = qualify_uri(opts[:omlCollectUri])
|
403
|
+
OML4R.logger.info "Collection URI is #{opts[:omlCollectUri]}"
|
404
|
+
|
405
|
+
create_channel(:default, opts[:omlCollectUri]) if opts[:omlCollectUri]
|
347
406
|
|
348
407
|
# Handle the defined Measurement Points
|
349
408
|
startTime = Time.now
|
@@ -351,6 +410,54 @@ module OML4R
|
|
351
410
|
rest || []
|
352
411
|
end
|
353
412
|
|
413
|
+
# Parse an underspecified URI into a fully-qualified one
|
414
|
+
# URIs are resolved as follows; the default is [tcp:]host[:port].
|
415
|
+
# hostname -> tcp:hostname:3003
|
416
|
+
# hostname:3004 -> tcp:hostname:3004
|
417
|
+
# tcp:hostname -> tcp:hostname:3003
|
418
|
+
# tcp:hostname:3004 -> tcp:hostname:3004
|
419
|
+
# file:/P/A/T/H -> file:/P/A/T/H
|
420
|
+
#
|
421
|
+
# @param uri [String] a potentially under-qualified collection URI
|
422
|
+
#
|
423
|
+
# @return [String] afully-qualified collection URI equivalent to uri
|
424
|
+
#
|
425
|
+
# @raise [OML4RException] in case of a parsing error
|
426
|
+
#
|
427
|
+
def self.qualify_uri(uri)
|
428
|
+
curi = uri.split(':')
|
429
|
+
|
430
|
+
# Defaults
|
431
|
+
scheme = 'tcp'
|
432
|
+
port = DEF_SERVER_PORT
|
433
|
+
|
434
|
+
if curi.length == 1
|
435
|
+
host = curi[0]
|
436
|
+
|
437
|
+
elsif curi.length == 2
|
438
|
+
if curi[0] == 'tcp'
|
439
|
+
scheme, host = curi
|
440
|
+
|
441
|
+
elsif curi[0] == 'file'
|
442
|
+
scheme, host = curi
|
443
|
+
port = nil
|
444
|
+
|
445
|
+
else
|
446
|
+
host, port = curi
|
447
|
+
end
|
448
|
+
|
449
|
+
elsif curi.length >= 3
|
450
|
+
if curi.length > 3
|
451
|
+
OML4R.logger.warn "Parsing URI '#{uri}' as a triplet, ignoring later components"
|
452
|
+
end
|
453
|
+
scheme, host, port = curi
|
454
|
+
|
455
|
+
else
|
456
|
+
raise OML4RException.new "OML4R: Unable to parse URI '#{url}"
|
457
|
+
end
|
458
|
+
"#{scheme}:#{host}#{":#{port}" if port}"
|
459
|
+
end
|
460
|
+
|
354
461
|
def self.create_channel(name, url)
|
355
462
|
Channel.create(name, url)
|
356
463
|
end
|
@@ -363,19 +470,13 @@ module OML4R
|
|
363
470
|
end
|
364
471
|
|
365
472
|
|
366
|
-
|
367
473
|
#
|
368
|
-
# Measurement
|
369
|
-
# Ruby applications using this module should sub-class this MPBase class
|
370
|
-
# to define their own Measurement Point (see the example at the end of
|
371
|
-
# this file)
|
474
|
+
# Measurement Channel
|
372
475
|
#
|
373
476
|
class Channel
|
374
477
|
@@channels = {}
|
375
478
|
@@default_domain = nil
|
376
479
|
|
377
|
-
|
378
|
-
|
379
480
|
def self.create(name, url, domain = :default)
|
380
481
|
key = "#{name}:#{domain}"
|
381
482
|
if channel = @@channels[key]
|
@@ -384,8 +485,36 @@ module OML4R
|
|
384
485
|
end
|
385
486
|
return channel
|
386
487
|
end
|
387
|
-
|
388
|
-
|
488
|
+
return self._create(key, domain, url)
|
489
|
+
end
|
490
|
+
|
491
|
+
def self._create(key, domain, url)
|
492
|
+
@@channels[key] = self.new(url, domain)
|
493
|
+
end
|
494
|
+
|
495
|
+
# Parse the given fully-qualified collection URI, and return a suitably connected objet
|
496
|
+
#
|
497
|
+
# Supported URIs are
|
498
|
+
# tcp:host:port
|
499
|
+
# file:/P/A/T/H
|
500
|
+
#
|
501
|
+
# @param fquri [String] a fully qualified collection URI
|
502
|
+
# @return [IO] an object suitably connected to the required URL
|
503
|
+
#
|
504
|
+
# @raise [OML4RException] in case of an unknown scheme
|
505
|
+
#
|
506
|
+
def self._connect(fquri)
|
507
|
+
scheme, host, port = fquri.split(':')
|
508
|
+
out = case scheme
|
509
|
+
when 'tcp'
|
510
|
+
out = TCPSocket.new(host, port)
|
511
|
+
when 'file'
|
512
|
+
# host is really a filename here
|
513
|
+
out = (host == '-' ? $stdout : File.open(host, "w+"))
|
514
|
+
else
|
515
|
+
raise OML4RException.new "OML4R: Unknown scheme '#{scheme}"
|
516
|
+
end
|
517
|
+
out
|
389
518
|
end
|
390
519
|
|
391
520
|
def self.[](name = :default, domain = :default)
|
@@ -438,22 +567,25 @@ module OML4R
|
|
438
567
|
@url = url
|
439
568
|
end
|
440
569
|
|
441
|
-
def
|
442
|
-
# Build the schema and send it
|
570
|
+
def build_schema(mp_name, add_prefix, pdefs)
|
443
571
|
@index += 1
|
444
|
-
|
445
|
-
line = [@index, mp_name]
|
572
|
+
line = [@index, (!@@appName.nil? && add_prefix)? "#{@@appName}_#{mp_name}" : mp_name]
|
446
573
|
pdefs.each do |d|
|
447
574
|
line << "#{d[:name]}:#{d[:type]}"
|
448
575
|
end
|
449
576
|
msg = line.join(' ')
|
450
577
|
@schemas << msg
|
451
|
-
@index
|
578
|
+
[@index, msg]
|
452
579
|
end
|
453
580
|
|
454
581
|
def send(msg)
|
455
582
|
@queue.push msg
|
456
583
|
end
|
584
|
+
|
585
|
+
def send_schema_update(msg)
|
586
|
+
@header_sent = true
|
587
|
+
@queue.push msg
|
588
|
+
end
|
457
589
|
|
458
590
|
def init(nodeID, appName, startTime, protocol)
|
459
591
|
@nodeID, @appName, @startTime, @protocol = nodeID, appName, startTime, protocol
|
@@ -469,7 +601,7 @@ module OML4R
|
|
469
601
|
def initialize(url, domain)
|
470
602
|
@domain = domain
|
471
603
|
@url = url
|
472
|
-
@index =
|
604
|
+
@index = -1
|
473
605
|
@schemas = []
|
474
606
|
@header_sent = false
|
475
607
|
@queue = Queue.new
|
@@ -499,26 +631,15 @@ module OML4R
|
|
499
631
|
d = (@domain == :default) ? @@default_domain : @domain
|
500
632
|
raise MissingArgumentException.new "Missing domain name" unless d
|
501
633
|
case @protocol || OML4R::DEF_PROTOCOL
|
502
|
-
when
|
503
|
-
header << "
|
504
|
-
header << "
|
634
|
+
when 4
|
635
|
+
header << "domain: #{d}"
|
636
|
+
header << "start-time: #{@startTime.tv_sec}"
|
505
637
|
header << "sender-id: #{@nodeID}"
|
506
638
|
header << "app-name: #{@appName}"
|
507
639
|
@schemas.each do |s|
|
508
640
|
header << "schema: #{s}"
|
509
641
|
end
|
510
642
|
header << ""
|
511
|
-
when 4
|
512
|
-
i = 0
|
513
|
-
header << ""
|
514
|
-
header << "0\t0\t#{i += 1}\t.\texperiment-id\t#{d}"
|
515
|
-
header << "0\t0\t#{i += 1}\t.\tstart_time\t#{@startTime.tv_sec}"
|
516
|
-
header << "0\t0\t#{i += 1}\t.\tsender-id\t#{@nodeID}"
|
517
|
-
header << "0\t0\t#{i += 1}\t.\tapp-name\t#{@appName}"
|
518
|
-
@schemas.each do |s|
|
519
|
-
header << "0\t0\t#{i += 1}\t.\tschema\t#{s}"
|
520
|
-
end
|
521
|
-
|
522
643
|
else
|
523
644
|
raise OML4RException.new "Unsupported protocol #{@protocol}"
|
524
645
|
end
|
@@ -526,7 +647,6 @@ module OML4R
|
|
526
647
|
end
|
527
648
|
|
528
649
|
def start_runner
|
529
|
-
header_sent = false
|
530
650
|
@runner = Thread.new do
|
531
651
|
active = true
|
532
652
|
begin
|
@@ -586,6 +706,16 @@ module OML4R
|
|
586
706
|
|
587
707
|
end # Channel
|
588
708
|
|
709
|
+
|
710
|
+
# Hard-code "schema0" measurement point
|
711
|
+
class ExperimentMetadata < MPBase
|
712
|
+
name :_experiment_metadata, :add_prefix => false
|
713
|
+
param :subject, :type => :string
|
714
|
+
param :key, :type => :string
|
715
|
+
param :value, :type => :string
|
716
|
+
end
|
717
|
+
|
718
|
+
|
589
719
|
require 'logger'
|
590
720
|
|
591
721
|
class Logger < ::Logger
|
@@ -601,7 +731,6 @@ module OML4R
|
|
601
731
|
@@logger
|
602
732
|
end
|
603
733
|
|
604
|
-
|
605
734
|
end # module OML4R
|
606
735
|
|
607
736
|
# vim: sw=2
|
data/lib/oml4r/version.rb
CHANGED
metadata
CHANGED
@@ -1,33 +1,22 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: oml4r
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 9
|
9
|
-
- 5
|
10
|
-
version: 2.9.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.9.6
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- NICTA
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2013-09-02 00:00:00 Z
|
11
|
+
date: 2013-10-09 00:00:00.000000000 Z
|
19
12
|
dependencies: []
|
20
|
-
|
21
|
-
|
22
|
-
email:
|
13
|
+
description: '["Simple OML client library for Ruby"]'
|
14
|
+
email:
|
23
15
|
- oml-user@lists.nicta.com.au
|
24
16
|
executables: []
|
25
|
-
|
26
17
|
extensions: []
|
27
|
-
|
28
18
|
extra_rdoc_files: []
|
29
|
-
|
30
|
-
files:
|
19
|
+
files:
|
31
20
|
- .gitignore
|
32
21
|
- Gemfile
|
33
22
|
- LICENSE.txt
|
@@ -47,38 +36,31 @@ files:
|
|
47
36
|
- lib/oml4r/version.rb
|
48
37
|
- oml4r.gemspec
|
49
38
|
homepage: http://oml.mytestbed.net
|
50
|
-
licenses:
|
39
|
+
licenses:
|
51
40
|
- MIT
|
41
|
+
metadata: {}
|
52
42
|
post_install_message:
|
53
43
|
rdoc_options: []
|
54
|
-
|
55
|
-
require_paths:
|
44
|
+
require_paths:
|
56
45
|
- lib
|
57
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
none: false
|
68
|
-
requirements:
|
69
|
-
- - ">="
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
hash: 3
|
72
|
-
segments:
|
73
|
-
- 0
|
74
|
-
version: "0"
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
75
56
|
requirements: []
|
76
|
-
|
77
57
|
rubyforge_project:
|
78
|
-
rubygems_version:
|
58
|
+
rubygems_version: 2.0.3
|
79
59
|
signing_key:
|
80
|
-
specification_version:
|
81
|
-
summary: This is a simple client library for OML which does not use liboml2 and
|
60
|
+
specification_version: 4
|
61
|
+
summary: '["This is a simple client library for OML which does not use liboml2 and
|
62
|
+
its filters, but connects directly to the server using the +text+ protocol. User
|
63
|
+
can use this library to create ruby applications which can send measurement to the
|
64
|
+
OML collection server."]'
|
82
65
|
test_files: []
|
83
|
-
|
84
66
|
has_rdoc:
|