cpee 2.1.29 → 2.1.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/cockpit/templates/Frames.xml +297 -0
  3. data/cockpit/templates/Worklist.xml +58 -26
  4. data/cockpit/themes/compact/theme.js +1 -1
  5. data/cockpit/themes/control/theme.js +1 -1
  6. data/cockpit/themes/default/theme.js +1 -1
  7. data/cockpit/themes/extended/theme.js +1 -1
  8. data/cockpit/themes/model/theme.js +1 -1
  9. data/cockpit/themes/packed/theme.js +1 -1
  10. data/cockpit/themes/preset/theme.js +1 -1
  11. data/cpee.gemspec +2 -2
  12. data/lib/cpee/fail.rb +23 -0
  13. data/lib/cpee/implementation.rb +84 -23
  14. data/lib/cpee/implementation_callbacks.rb +11 -10
  15. data/lib/cpee/implementation_notifications.rb +4 -3
  16. data/lib/cpee/implementation_properties.rb +2 -1
  17. data/lib/cpee/message.rb +35 -13
  18. data/lib/cpee/persistence.rb +30 -11
  19. data/server/executionhandlers/ruby/connection.rb +18 -2
  20. data/server/executionhandlers/ruby/controller.rb +11 -6
  21. data/server/executionhandlers/ruby/dsl_to_dslx.xsl +5 -5
  22. data/server/resources/topics.xml +1 -0
  23. data/server/routing/forward-events.rb +6 -0
  24. data/server/routing/persist.rb +4 -2
  25. data/server/server.conf +1 -1
  26. metadata +17 -25
  27. data/cockpit/templates/Coopis 2010.xml.active +0 -1
  28. data/cockpit/templates/Coopis 2010.xml.active-uuid +0 -1
  29. data/cockpit/templates/Subprocess.xml.active +0 -1
  30. data/cockpit/templates/Subprocess.xml.active-uuid +0 -1
  31. data/cockpit/templates/Track Test.xml.active +0 -1
  32. data/cockpit/templates/Track Test.xml.active-uuid +0 -1
  33. data/cockpit/templates/UR-VUE 2020 Solution Baseline.xml.active +0 -1
  34. data/cockpit/templates/UR-VUE 2020 Solution Baseline.xml.active-uuid +0 -1
  35. data/cockpit/templates/Wait.xml.active +0 -1
  36. data/cockpit/templates/Wait.xml.active-uuid +0 -1
@@ -16,6 +16,7 @@ require 'fileutils'
16
16
  require 'redis'
17
17
  require 'riddl/server'
18
18
  require 'riddl/client'
19
+ require_relative 'fail'
19
20
  require_relative 'redis'
20
21
  require_relative 'message'
21
22
  require_relative 'persistence'
@@ -67,6 +68,9 @@ module CPEE
67
68
  opts[:watchdog_start_off] ||= false
68
69
  opts[:infinite_loop_stop] ||= 10000
69
70
 
71
+ opts[:dashing_frequency] ||= 3
72
+ opts[:dashing_target] ||= nil
73
+
70
74
  ### set redis_cmd to nil if you want to do global
71
75
  ### at least redis_path or redis_url and redis_db have to be set if you do global
72
76
  opts[:redis_path] ||= 'redis.sock' # use e.g. /tmp/redis.sock for global stuff. Look it up in your redis config
@@ -83,7 +87,7 @@ module CPEE
83
87
  opts[:sse_connections] = {}
84
88
 
85
89
  opts[:statemachine] = CPEE::StateMachine.new opts[:states], %w{running simulating replaying finishing stopping abandoned finished} do |id|
86
- opts[:redis].get("instance:#{id}/state")
90
+ CPEE::Persistence::extract_item(id,opts,"state")
87
91
  end
88
92
 
89
93
  opts[:runtime_cmds] << [
@@ -113,6 +117,55 @@ module CPEE
113
117
  EM.add_periodic_timer(opts[:sse_keepalive_frequency]) do
114
118
  CPEE::Notifications::sse_heartbeat(opts)
115
119
  end
120
+
121
+ if opts[:dashing_target]
122
+ cpu_last = 0
123
+ idl_last = 0
124
+ EM.add_periodic_timer(opts[:dashing_frequency]) do
125
+ src = `cat /proc/stat | head -n 1`.split("\n")
126
+ srm = `cat /proc/meminfo`.split("\n")
127
+ sc = {}
128
+ sm = {}
129
+ src.each do |e|
130
+ x = e.split(' ')
131
+ sc[x[0]] = x[1..-1].map{|r| r.to_i}
132
+ end
133
+ srm.each do |e|
134
+ x = e.split(/\s+/)
135
+ sm[x[0].chop] = x[1].to_i
136
+ end
137
+ scc = 0
138
+ sci = 0
139
+ sc.each do |_,e|
140
+ scc = e[0..4].sum
141
+ sci = e[3]
142
+ end
143
+ cpu_delta = scc - cpu_last
144
+ cpu_idle = sci - idl_last
145
+ cpu_used = cpu_delta - cpu_idle
146
+ cpu_usage = '%.2f' % (100 * cpu_used / cpu_delta.to_f)
147
+ mem_tot = '%.1f' % (sm['MemTotal']/1024.0)
148
+ mem_fre = '%.1f' % (sm['MemFree']/1024.0)
149
+ mem_ava = '%.1f' % (sm['MemAvailable']/1024.0)
150
+ mem_buc = '%.1f' % ((sm['Buffers'] + sm['Cached'] + sm['SReclaimable'])/1024.0)
151
+ mem_usd = '%.1f' % ((sm['MemTotal'] - sm['MemFree'] - sm['Buffers'] - sm['Cached'] - sm['SReclaimable'])/1024.0)
152
+
153
+ # puts "CPU usage at #{cpu_usage}%"
154
+ # puts "Mem usage at #{mem_tot}/#{mem_fre}/#{mem_usd}/#{mem_buc}/#{mem_ava}"
155
+ content = {}
156
+ content['cpu_usage'] = cpu_usage
157
+ content['mem_total'] = mem_tot
158
+ content['mem_free'] = mem_fre
159
+ content['mem_available'] = mem_ava
160
+ content['mem_bufferedandcached'] = mem_buc
161
+ content['mem_used'] = mem_usd
162
+ CPEE::Message::send_url(:event,'node/resource_utilization',File.join(opts[:url],'/'),content,File.join(opts[:dashing_target],'/dash/events'))
163
+
164
+ # Keep this as last for our next read
165
+ idl_last = sci
166
+ cpu_last = scc
167
+ end
168
+ end
116
169
  end
117
170
 
118
171
  cleanup do
@@ -176,16 +229,14 @@ module CPEE
176
229
 
177
230
  class Instances < Riddl::Implementation #{{{
178
231
  def response
179
- redis = @a[0][:redis]
232
+ opts = @a[0]
180
233
  Riddl::Parameter::Complex.new("wis","text/xml") do
181
234
  ins = XML::Smart::string('<instances/>')
182
- redis.zrevrange('instances',0,-1).each do |instance|
183
- statekey = "instance:#{instance}/state"
184
- attributes = "instance:#{instance}/attributes/"
185
- info = redis.get(attributes + 'info')
186
- uuid = redis.get(attributes + 'uuid')
187
- state = redis.get(statekey)
188
- state_changed = redis.get(File.join(statekey,'@changed'))
235
+ CPEE::Persistence::each_object(opts) do |instance|
236
+ info = CPEE::Persistence::extract_item(instance,opts,'attributes/info')
237
+ uuid = CPEE::Persistence::extract_item(instance,opts,'attributes/uuid')
238
+ state = CPEE::Persistence::extract_item(instance,opts,'state')
239
+ state_changed = CPEE::Persistence::extract_item(instance,opts,'state/@changed')
189
240
  ins.root.add('instance', info, 'uuid' => uuid, 'id' => instance, 'state' => state, 'state_changed' => state_changed )
190
241
  end
191
242
  ins.to_s
@@ -209,9 +260,9 @@ module CPEE
209
260
  doc = XML::Smart::open_unprotected(opts[:properties_init])
210
261
  doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
211
262
  name = @p[0].value
212
- id = redis.zrevrange('instances', 0, 0).first.to_i + 1
263
+ id = CPEE::Persistence::new_object(opts)
213
264
  uuid = SecureRandom.uuid
214
- instance = 'instance:' + id.to_s
265
+ instance = CPEE::Persistence::OBJ + ':' + id.to_s
215
266
  redis.multi do |multi|
216
267
  multi.zadd('instances',id,id)
217
268
  doc.root.find(PROPERTIES_PATHS_FULL.join(' | ')).each do |e|
@@ -235,12 +286,12 @@ module CPEE
235
286
  doc.register_namespace 'np', 'http://riddl.org/ns/common-patterns/notifications-producer/2.0'
236
287
  key = File.basename(File.dirname(f))
237
288
  url = doc.find('string(/np:subscription/@url)')
238
- multi.sadd("instance:#{id}/handlers",key)
239
- multi.set("instance:#{id}/handlers/#{key}/url",url)
289
+ multi.sadd(CPEE::Persistence::OBJ + ":#{id}/handlers",key)
290
+ multi.set(CPEE::Persistence::OBJ + ":#{id}/handlers/#{key}/url",url)
240
291
  doc.find('/np:subscription/np:topic/*').each do |e|
241
292
  c = File.join(e.parent.attributes['id'],e.qname.name,e.text)
242
- multi.sadd("instance:#{id}/handlers/#{key}",c)
243
- multi.sadd("instance:#{id}/handlers/#{c}",key)
293
+ multi.sadd(CPEE::Persistence::OBJ + ":#{id}/handlers/#{key}",c)
294
+ multi.sadd(CPEE::Persistence::OBJ + ":#{id}/handlers/#{c}",key)
244
295
  end
245
296
  end rescue nil # all the ones that are not ok, are ignored
246
297
  end
@@ -251,6 +302,12 @@ module CPEE
251
302
  multi.set(File.join(instance, 'state', '@changed'), Time.now.xmlschema(3))
252
303
  end
253
304
 
305
+ content = {
306
+ :state => 'ready',
307
+ :attributes => CPEE::Persistence::extract_list(id,opts,'attributes').to_h
308
+ }
309
+ CPEE::Message::send(:event,'state/change',File.join(opts[:url],'/'),id,uuid,name,content,redis)
310
+
254
311
  @headers << Riddl::Header.new("CPEE-INSTANCE", id.to_s)
255
312
  @headers << Riddl::Header.new("CPEE-INSTANCE-URL", File.join(opts[:url].to_s,id.to_s,'/'))
256
313
  @headers << Riddl::Header.new("CPEE-INSTANCE-UUID", uuid)
@@ -289,7 +346,18 @@ module CPEE
289
346
  @status = 404
290
347
  return
291
348
  end
292
- empt = redis.keys("instance:#{id}/*").to_a
349
+
350
+ content = {
351
+ :state => 'purged',
352
+ :attributes => CPEE::Persistence::extract_list(id,opts,'attributes').to_h
353
+ }
354
+ state = CPEE::Persistence::extract_item(id,opts,'state')
355
+ if state == 'stopped' || state == 'ready'
356
+ CPEE::Message::send(:event,'state/change',File.join(opts[:url],'/'),id,content[:attributes]['uuid'],content[:attributes]['info'],content,redis)
357
+ end
358
+
359
+ empt = CPEE::Persistence::keys(id,opts).to_a
360
+ empt.delete_if{|e| e =~ /\/handlers/ }
293
361
  redis.multi do |multi|
294
362
  multi.del empt
295
363
  multi.zrem 'instances', id
@@ -297,11 +365,4 @@ module CPEE
297
365
  end
298
366
  end #}}}
299
367
 
300
- class FAIL < Riddl::Implementation #{{{
301
- def response
302
- @status = 404
303
- nil
304
- end
305
- end #}}}
306
-
307
368
  end
@@ -13,6 +13,7 @@
13
13
  # <http://www.gnu.org/licenses/>.
14
14
 
15
15
  require 'json'
16
+ require_relative 'fail'
16
17
 
17
18
  module CPEE
18
19
  module Callbacks
@@ -54,13 +55,13 @@ module CPEE
54
55
  opts = @a[1]
55
56
  callback = @r[-1]
56
57
 
57
- if opts[:redis].sismember("instance:#{id}/callbacks",callback)
58
+ if CPEE::Persistence::is_member?(id,opts,'callbacks',callback)
58
59
  res = {}
59
- res[:uuid] = opts[:redis].get("instance:#{id}/callback/#{callback}/uuid")
60
- res[:type] = opts[:redis].get("instance:#{id}/callback/#{callback}/type")
61
- res[:position] = opts[:redis].get("instance:#{id}/callback/#{callback}/position")
62
- res[:label] = opts[:redis].get("instance:#{id}/callback/#{callback}/label")
63
- if sub = opts[:redis].get("instance:#{id}/callback/#{callback}/subscription")
60
+ res[:uuid] = CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/uuid")
61
+ res[:type] = CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type")
62
+ res[:position] = CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/position")
63
+ res[:label] = CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/label")
64
+ if sub = CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/subscription")
64
65
  res[:subscription] = sub
65
66
  end
66
67
 
@@ -77,7 +78,7 @@ module CPEE
77
78
  opts = @a[1]
78
79
  callback = @r[-1]
79
80
 
80
- if opts[:redis].get("instance:#{id}/callback/#{callback}/type") == 'callback'
81
+ if CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'callback'
81
82
  CPEE::Message::send(
82
83
  :'callback-end',
83
84
  callback,
@@ -88,7 +89,7 @@ module CPEE
88
89
  {},
89
90
  opts[:redis]
90
91
  )
91
- elsif opts[:redis].get("instance:#{id}/callback/#{callback}/type") == 'vote'
92
+ elsif CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'vote'
92
93
  CPEE::Message::send(
93
94
  :'vote-response',
94
95
  callback,
@@ -112,7 +113,7 @@ module CPEE
112
113
  opts = @a[1]
113
114
  callback = @r[-1]
114
115
 
115
- if opts[:redis].get("instance:#{id}/callback/#{callback}/type") == 'callback'
116
+ if CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'callback'
116
117
  ret = {}
117
118
  ret['values'] = @p.map{ |e|
118
119
  [e.name, e.class == Riddl::Parameter::Simple ? [:simple,e.value] : [:complex,e.mimetype,e.value.path] ]
@@ -129,7 +130,7 @@ module CPEE
129
130
  ret,
130
131
  opts[:redis]
131
132
  )
132
- elsif opts[:redis].get("instance:#{id}/callback/#{callback}/type") == 'vote'
133
+ elsif CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'vote'
133
134
  if @p.length == 1 && @p[0].name == 'continue' && @p[0].class == Riddl::Parameter::Simple
134
135
  CPEE::Message::send(
135
136
  :'vote-response',
@@ -13,6 +13,7 @@
13
13
  # <http://www.gnu.org/licenses/>.
14
14
 
15
15
  require 'json'
16
+ require_relative 'fail'
16
17
 
17
18
  module CPEE
18
19
  module Notifications
@@ -188,7 +189,7 @@ module CPEE
188
189
  on.pmessage do |pat, what, message|
189
190
  if pat == 'forward:*'
190
191
  id, key = what.match(/forward:([^\/]+)\/(.+)/).captures
191
- if sse = opts.dig(:sse_connections,id.to_i,key)
192
+ if sse = opts.dig(:sse_connections,id,key)
192
193
  sse.send message
193
194
  else
194
195
  DeleteSubscription::set(id,opts,key)
@@ -197,7 +198,7 @@ module CPEE
197
198
  mess = JSON.parse(message[message.index(' ')+1..-1])
198
199
  state = mess.dig('content','state')
199
200
  if state == 'finished' || state == 'abandoned'
200
- opts.dig(:sse_connections,mess.dig('instance').to_i)&.each do |key,sse|
201
+ opts.dig(:sse_connections,mess.dig('instance').to_s)&.each do |key,sse|
201
202
  EM.add_timer(10) do # just to be sure that all messages arrived. 10 seconds should be enough ... we think ... therefore we are (not sure)
202
203
  sse.close
203
204
  end
@@ -218,7 +219,7 @@ module CPEE
218
219
  class SSE < Riddl::SSEImplementation #{{{
219
220
  def onopen
220
221
  @opts = @a[1]
221
- @id = @a[0]
222
+ @id = @a[0].to_s
222
223
  @key = @r[-2]
223
224
  if CPEE::Persistence::exists_handler?(@id,@opts,@key)
224
225
  @opts[:sse_connections][@id] ||= {}
@@ -13,6 +13,7 @@
13
13
  # <http://www.gnu.org/licenses/>.
14
14
 
15
15
  require_relative 'attributes_helper'
16
+ require_relative 'fail'
16
17
  require_relative 'value_helper'
17
18
  require 'json'
18
19
  require 'erb'
@@ -226,7 +227,7 @@ module CPEE
226
227
  end #}}}
227
228
  class PutState < Riddl::Implementation #{{{
228
229
  def self::set(id,opts,state)
229
- CPEE::Persistence::set_item(id,opts,'state',:state => state, :timestamp => Time.now.xmlschema(3))
230
+ CPEE::Persistence::set_item(id,opts,'state',:state => state, :attributes => CPEE::Persistence::extract_list(id,opts,'attributes').to_h)
230
231
  end
231
232
 
232
233
  def self::run(id,opts,state)
data/lib/cpee/message.rb CHANGED
@@ -15,28 +15,50 @@
15
15
  module CPEE
16
16
 
17
17
  module Message
18
+ WHO = 'cpee'
19
+ TYPE = 'instance'
18
20
 
19
21
  def self::send(type, event, cpee, instance, instance_uuid, instance_name, content={}, backend)
20
22
  topic = ::File::dirname(event)
21
23
  name = ::File::basename(event)
24
+ payload = {
25
+ WHO => cpee,
26
+ TYPE + '-url' => File.join(cpee,instance.to_s),
27
+ TYPE => instance,
28
+ 'topic' => topic,
29
+ 'type' => type,
30
+ 'name' => name,
31
+ 'timestamp' => Time.now.xmlschema(3),
32
+ 'content' => content
33
+ }
34
+ payload[TYPE + '-uuid'] = instance_uuid if instance_uuid
35
+ payload[TYPE + '-name'] = instance_name if instance_name
22
36
  backend.publish(type.to_s + ':' + event,
23
37
  instance.to_s + ' ' +
24
- JSON::generate(
25
- { 'cpee' => cpee,
26
- 'instance-url' => File.join(cpee,instance.to_s),
27
- 'instance-uuid' => instance_uuid,
28
- 'instance-name' => instance_name,
29
- 'instance' => instance,
30
- 'topic' => topic,
31
- 'type' => type,
32
- 'name' => name,
33
- 'timestamp' => Time.now.xmlschema(3),
34
- 'content' => content
35
- }
36
- )
38
+ JSON::generate(payload)
37
39
  )
38
40
  end
39
41
 
42
+ def self::send_url(type, event, cpee, content={}, backend)
43
+ topic = ::File::dirname(event)
44
+ name = ::File::basename(event)
45
+ client = Riddl::Client.new(backend)
46
+ payload = {
47
+ WHO => cpee,
48
+ 'topic' => topic,
49
+ 'type' => type,
50
+ 'name' => name,
51
+ 'timestamp' => Time.now.xmlschema(3),
52
+ 'content' => content
53
+ }
54
+ client = Riddl::Client.new(backend)
55
+ client.post [
56
+ Riddl::Parameter::Simple::new('type',type),
57
+ Riddl::Parameter::Simple::new('topic',topic),
58
+ Riddl::Parameter::Simple::new('event',name),
59
+ Riddl::Parameter::Complex::new('notification','application/json',JSON::generate(payload))
60
+ ]
61
+ end
40
62
  end
41
63
 
42
64
  end
@@ -15,6 +15,8 @@
15
15
  module CPEE
16
16
 
17
17
  module Persistence
18
+ OBJ = 'instance'
19
+
18
20
  def self::set_list(id,opts,item,values,deleted=[]) #{{{
19
21
  ah = AttributesHelper.new
20
22
  attributes = Persistence::extract_list(id,opts,'attributes').to_h
@@ -37,13 +39,13 @@ module CPEE
37
39
  )
38
40
  end #}}}
39
41
  def self::extract_set(id,opts,item) #{{{
40
- opts[:redis].smembers("instance:#{id}/#{item}").map do |e|
41
- [e,opts[:redis].get("instance:#{id}/#{item}/#{e}")]
42
+ opts[:redis].smembers(OBJ + ":#{id}/#{item}").map do |e|
43
+ [e,opts[:redis].get(OBJ + ":#{id}/#{item}/#{e}")]
42
44
  end
43
45
  end #}}}
44
46
  def self::extract_list(id,opts,item) #{{{
45
- opts[:redis].zrange("instance:#{id}/#{item}",0,-1).map do |e|
46
- [e,opts[:redis].get("instance:#{id}/#{item}/#{e}")]
47
+ opts[:redis].zrange(OBJ + ":#{id}/#{item}",0,-1).map do |e|
48
+ [e,opts[:redis].get(OBJ + ":#{id}/#{item}/#{e}")]
47
49
  end
48
50
  end #}}}
49
51
 
@@ -60,15 +62,32 @@ module CPEE
60
62
  )
61
63
  end #}}}
62
64
  def self::extract_item(id,opts,item) #{{{
63
- opts[:redis].get("instance:#{id}/#{item}")
65
+ opts[:redis].get(OBJ + ":#{id}/#{item}")
64
66
  end #}}}
65
67
 
66
68
  def self::exists?(id,opts) #{{{
67
- opts[:redis].exists?("instance:#{id}/state")
69
+ opts[:redis].exists?(OBJ + ":#{id}/state")
68
70
  end #}}}
71
+ def self::is_member?(id,opts,item,value) #{{{
72
+ opts[:redis].sismember(OBJ + ":#{id}/#{item}",value)
73
+ end #}}}
74
+
75
+ def self::each_object(opts)
76
+ opts[:redis].zrevrange(OBJ + 's',0,-1).each do |instance|
77
+ yield instance
78
+ end
79
+ end
80
+
81
+ def self::new_object(opts)
82
+ opts[:redis].zrevrange(OBJ + 's', 0, 0).first.to_i + 1
83
+ end
84
+
85
+ def self::keys(id,opts,item=nil)
86
+ opts[:redis].keys(File.join(OBJ + ":#{id}",item.to_s,'*'))
87
+ end
69
88
 
70
89
  def self::set_handler(id,opts,key,url,values,update=false) #{{{
71
- exis = opts[:redis].smembers("instance:#{id}/handlers/#{key}")
90
+ exis = opts[:redis].smembers(OBJ + ":#{id}/handlers/#{key}")
72
91
 
73
92
  if update == false && exis.length > 0
74
93
  return 405
@@ -101,14 +120,14 @@ module CPEE
101
120
  200
102
121
  end #}}}
103
122
  def self::extract_handler(id,opts,key) #{{{
104
- opts[:redis].smembers("instance:#{id}/handlers/#{key}")
123
+ opts[:redis].smembers(OBJ + ":#{id}/handlers/#{key}")
105
124
  end #}}}
106
125
  def self::exists_handler?(id,opts,key) #{{{
107
- opts[:redis].exists?("instance:#{id}/handlers/#{key}")
126
+ opts[:redis].exists?(OBJ + ":#{id}/handlers/#{key}")
108
127
  end #}}}
109
128
  def self::extract_handlers(id,opts) #{{{
110
- opts[:redis].smembers("instance:#{id}/handlers").map do |e|
111
- [e, opts[:redis].get("instance:#{id}/handlers/#{e}/url")]
129
+ opts[:redis].smembers(OBJ + ":#{id}/handlers").map do |e|
130
+ [e, opts[:redis].get(OBJ + ":#{id}/handlers/#{e}/url")]
112
131
  end
113
132
  end #}}}
114
133
  end
@@ -15,6 +15,7 @@
15
15
  require 'charlock_holmes'
16
16
  require 'mimemagic'
17
17
  require 'base64'
18
+ require 'get_process_mem'
18
19
 
19
20
  class ConnectionWrapper < WEEL::ConnectionWrapperBase
20
21
  def self::loop_guard(arguments,id,count) # {{{
@@ -77,7 +78,15 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
77
78
  end #}}}
78
79
 
79
80
  def additional #{{{
80
- { :attributes => @controller.attributes }
81
+ {
82
+ :attributes => @controller.attributes,
83
+ :cpee => {
84
+ 'base' => @controller.base_url,
85
+ 'instance' => @controller.instance_id,
86
+ 'instance_url' => @controller.instance_url,
87
+ 'instance_uuid' => @controller.uuid
88
+ }
89
+ }
81
90
  end #}}}
82
91
 
83
92
  def proto_curl(parameters) #{{{
@@ -184,6 +193,7 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
184
193
 
185
194
  def inform_activity_done # {{{
186
195
  @controller.notify("activity/done", :'activity-uuid' => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :activity => @handler_position)
196
+ @controller.notify("status/resource_utilization", :mib => GetProcessMem.new.mb, **Process.times.to_h)
187
197
  end # }}}
188
198
  def inform_activity_manipulate # {{{
189
199
  @controller.notify("activity/manipulating", :'activity-uuid' => @handler_activity_uuid, :endpoint => @handler_endpoint, :label => @label, :activity => @handler_position)
@@ -220,6 +230,8 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
220
230
  elsif result[0].is_a? Riddl::Parameter::Complex
221
231
  if result[0].mimetype == 'application/json'
222
232
  result = JSON::parse(result[0].value.read) rescue nil
233
+ elsif result[0].mimetype == 'text/yaml'
234
+ result = YAML::load(result[0].value.read) rescue nil
223
235
  elsif result[0].mimetype == 'application/xml' || result[0].mimetype == 'text/xml'
224
236
  result = XML::Smart::string(result[0].value.read) rescue nil
225
237
  elsif result[0].mimetype == 'text/plain'
@@ -301,10 +313,14 @@ class ConnectionWrapper < WEEL::ConnectionWrapperBase
301
313
  end
302
314
 
303
315
  def callback(result=nil,options={})
304
- @controller.notify("activity/receiving", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => structurize_result(result), :annotations => @anno)
316
+ recv = structurize_result(result)
317
+ @controller.notify("activity/receiving", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => recv, :annotations => @anno)
305
318
  @guard_files += result
306
319
  @handler_returnValue = simplify_result(result)
307
320
  @handler_returnOptions = options
321
+ if options['CPEE_EVENT']
322
+ @controller.notify("task/#{headers['CPEE_EVENT'].gsub(/[^\w_-]/,'')}", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => recv)
323
+ end
308
324
  if options['CPEE_UPDATE']
309
325
  if options['CPEE_UPDATE_STATUS']
310
326
  @controller.notify("activity/status", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :status => options['CPEE_UPDATE_STATUS'])
@@ -21,6 +21,7 @@ require 'cpee/value_helper'
21
21
  require 'cpee/attributes_helper'
22
22
  require 'cpee/message'
23
23
  require 'cpee/redis'
24
+ require 'cpee/persistence'
24
25
 
25
26
  require 'ostruct'
26
27
  class ParaStruct < OpenStruct
@@ -41,8 +42,8 @@ class Controller
41
42
  @id = id
42
43
 
43
44
  @attributes = {}
44
- @redis.keys("instance:#{id}/attributes/*").each do |key|
45
- @attributes[File.basename(key)] = @redis.get(key)
45
+ CPEE::Persistence::extract_list(id,opts,'attributes').each do |de|
46
+ @attributes[de[0]] = de[1]
46
47
  end
47
48
 
48
49
  @attributes_helper = AttributesHelper.new
@@ -52,9 +53,9 @@ class Controller
52
53
  @loop_guard = {}
53
54
 
54
55
  @callback_keys = {}
55
- @psredis = @opts[:redis_dyn].call "Instance #{@id} Callback Response"
56
56
 
57
- Thread.new do
57
+ @subs = Thread.new do
58
+ @psredis = @opts[:redis_dyn].call "Instance #{@id} Callback Response"
58
59
  @psredis.psubscribe('callback-response:*','callback-end:*') do |on|
59
60
  on.pmessage do |pat, what, message|
60
61
  if pat == 'callback-response:*' && @callback_keys.has_key?(what[18..-1])
@@ -77,6 +78,10 @@ class Controller
77
78
  end
78
79
  end
79
80
  end
81
+ @psredis.close
82
+ rescue => e
83
+ sleep 1
84
+ retry
80
85
  end
81
86
  end
82
87
 
@@ -136,7 +141,6 @@ class Controller
136
141
  CPEE::Message::send(:'vote-response',key,base,@id,uuid,info,true,@redis)
137
142
  end
138
143
  end
139
- @thread.join if !@thread.nil? && @thread.alive?
140
144
  end
141
145
 
142
146
  def info
@@ -152,7 +156,8 @@ class Controller
152
156
  topic, name = what.split('/')
153
157
  handler = File.join(topic,'vote',name)
154
158
  votes = []
155
- @redis.smembers("instance:#{id}/handlers/#{handler}").each do |client|
159
+
160
+ CPEE::Persistence::extract_handler(id,@opts,handler).each do |client|
156
161
  voteid = Digest::MD5.hexdigest(Kernel::rand().to_s)
157
162
  content[:key] = voteid
158
163
  content[:attributes] = attributes_translated
@@ -6,10 +6,10 @@
6
6
  <xsl:template match="/">
7
7
  <xsl:text>control flow do</xsl:text>
8
8
  <xsl:call-template name="print-newline"/>
9
- <xsl:apply-templates select="//d:description"/>
9
+ <xsl:apply-templates select="/d:description"/>
10
10
  <xsl:text>end</xsl:text>
11
11
  </xsl:template>
12
- <xsl:template match="//d:description">
12
+ <xsl:template match="/d:description">
13
13
  <xsl:apply-templates>
14
14
  <xsl:with-param name="myspace">
15
15
  <xsl:value-of select="0*$myspacemultiplier"/>
@@ -749,9 +749,9 @@
749
749
  <xsl:otherwise>
750
750
  <xsl:choose>
751
751
  <xsl:when test="substring(.,1,1) = '!'">
752
- <xsl:text>#{</xsl:text>
753
- <xsl:value-of select="str:replace(str:replace(substring(.,2),'\','\\'),'&quot;','\\\&quot;')"/>
754
- <xsl:text>.to_json}</xsl:text>
752
+ <xsl:text>#{(</xsl:text>
753
+ <xsl:value-of select="substring(.,2)"/>
754
+ <xsl:text>).to_json}</xsl:text>
755
755
  </xsl:when>
756
756
  <xsl:otherwise>
757
757
  <xsl:text>\"</xsl:text>
@@ -41,6 +41,7 @@
41
41
  <vote>change</vote>
42
42
  </topic>
43
43
  <topic id='status'>
44
+ <event>resource_utilization</event>
44
45
  <event>change</event>
45
46
  </topic>
46
47
  <topic id='dataelements'>
@@ -62,6 +62,12 @@ Daemonite.new do |opts|
62
62
  end
63
63
  end
64
64
  end
65
+ unless opts[:redis].exists?("instance:#{instance}/state")
66
+ empt = opts[:redis].keys("instance:#{instance}/*").to_a
67
+ opts[:redis].multi do |multi|
68
+ multi.del empt
69
+ end
70
+ end
65
71
  rescue => e
66
72
  puts e.message
67
73
  puts e.backtrace
@@ -66,8 +66,10 @@ Daemonite.new do |opts|
66
66
  end
67
67
  when 'event:state/change'
68
68
  opts[:redis].multi do |multi|
69
- multi.set("instance:#{instance}/state",mess.dig('content','state'))
70
- multi.set("instance:#{instance}/state/@changed",mess.dig('timestamp'))
69
+ unless mess.dig('content','state') == 'purged'
70
+ multi.set("instance:#{instance}/state",mess.dig('content','state'))
71
+ multi.set("instance:#{instance}/state/@changed",mess.dig('timestamp'))
72
+ end
71
73
  end
72
74
  when 'event:executionhandler/change'
73
75
  opts[:redis].set("instance:#{instance}/executionhandler",mess.dig('content','executionhandler'))
data/server/server.conf CHANGED
@@ -1,4 +1,4 @@
1
1
  :host: tango.wst.univie.ac.at
2
2
  :port: 8298
3
- :url: http://tango.wst.univie.ac.at:8298
3
+ :url: http://tango.wst.univie.ac.at/flow/engine/
4
4
  :secure: false