cpee 2.1.140 → 2.1.141

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.
@@ -140,7 +140,9 @@ module CPEE
140
140
  doc.find('/p:properties/p:transformation/p:dataelements/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dataelements/@type')
141
141
  doc.find('/p:properties/p:transformation/p:endpoints/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/endpoints/@type')
142
142
  doc.find('/p:properties/p:transformation/p:dslx').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dslx') || ''
143
- doc.find('/p:properties/p:transformation/p:dslx/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dslx/@type') || 'copy' # instances from before dslx backtransformation
143
+ ttype, text = PutTransformation::stored_dslx(id,opts)
144
+ doc.find('/p:properties/p:transformation/p:dslx/@type').first.text = ttype
145
+ doc.find('/p:properties/p:transformation/p:dslx').first.attributes['extension'] = text
144
146
  Riddl::Parameter::Complex.new('properties','application/xml',doc.to_s)
145
147
  end
146
148
  end #}}}
@@ -159,7 +161,7 @@ module CPEE
159
161
  CPEE::Properties::PutStatus::set id, opts, node.first.dump
160
162
  end
161
163
  if (node = doc.find('/p:properties/p:executionhandler')).any?
162
- if doc.find('/p:properties/p:description/*').any?
164
+ if doc.find('/p:properties/p:description/* | /p:properties/p:dslx/*').any?
163
165
  CPEE::Properties::PutExecutionHandler::set id, opts, node.first.text, false
164
166
  else
165
167
  CPEE::Properties::PutExecutionHandler::set id, opts, node.first.text
@@ -173,9 +175,12 @@ module CPEE
173
175
  end
174
176
 
175
177
  if (node = doc.find('/p:properties/p:transformation')).any?
176
- CPEE::Properties::PutTransformation::set id, opts, node.first.dump, doc.find('/p:properties/p:description/*').empty?
178
+ CPEE::Properties::PutTransformation::set id, opts, node.first.dump, doc.find('/p:properties/p:description/* | /p:properties/p:dslx/*').empty?
179
+ CPEE::Persistence::wait(opts)
177
180
  end
178
- if (node = doc.find('/p:properties/p:description/*')).any?
181
+ if (node = doc.find('/p:properties/p:dslx/*')).any?
182
+ CPEE::Properties::PutDescription::set id, opts, node.first.dump, true
183
+ elsif (node = doc.find('/p:properties/p:description/*')).any?
179
184
  CPEE::Properties::PutDescription::set id, opts, node.first.dump
180
185
  end
181
186
 
@@ -208,9 +213,12 @@ module CPEE
208
213
  end
209
214
 
210
215
  if (node = doc.find('/*/p:transformation')).any?
211
- CPEE::Properties::PutTransformation::set id, opts, node.first.dump, doc.find('/*/p:description/*').empty?
216
+ CPEE::Properties::PutTransformation::set id, opts, node.first.dump, doc.find('/*/p:description/* | /*/p:dslx/*').empty?
217
+ CPEE::Persistence::wait(opts)
212
218
  end
213
- if (node = doc.find('/*/p:description/*')).any?
219
+ if (node = doc.find('/*/p:dslx/*')).any?
220
+ CPEE::Properties::PutDescription::set id, opts, node.first.dump, true
221
+ elsif (node = doc.find('/*/p:description/*')).any?
214
222
  CPEE::Properties::PutDescription::set id, opts, node.first.dump
215
223
  end
216
224
 
@@ -310,7 +318,7 @@ module CPEE
310
318
  end
311
319
  end #}}}
312
320
  class PutStatus < Riddl::Implementation #{{{
313
- EXPOSITION_ONLY = 18510501 # status id that only carries expositions, the status stays as it is
321
+ EXPOSITION_ONLY = 18510501
314
322
 
315
323
  def self::set(id,opts,xml)
316
324
  doc = XML::Smart::string(xml)
@@ -320,18 +328,16 @@ module CPEE
320
328
  CPEE::Persistence::set_item(id,opts,'status',:id => sid, :message => doc.find('string(/p:status/p:message)'))
321
329
  end
322
330
 
323
- def self::expositions(id,opts,expositions) # [[info,body],...]
331
+ def self::expositions(id,opts,expositions)
324
332
  return if expositions.empty?
325
333
  attrs = CPEE::Persistence::extract_list(id,opts,'attributes').to_h
326
- change_uuid = CPEE::Persistence::extract_item(id,opts,'dslx/@change_uuid')
327
334
  expositions.each do |info,body|
328
335
  content = {
329
- :change_uuid => change_uuid,
330
336
  :exposition => body,
331
337
  :info => info,
332
338
  :attributes => attrs
333
339
  }
334
- CPEE::Message::send(:event,'description/exposition',File.join(opts[:url],'/'),id,attrs['uuid'],attrs['info'],content,opts[:redis])
340
+ CPEE::Message::send(:event,'status/exposition',File.join(opts[:url],'/'),id,attrs['uuid'],attrs['info'],content,opts[:redis])
335
341
  end
336
342
  end
337
343
 
@@ -901,7 +907,7 @@ module CPEE
901
907
  )
902
908
  end
903
909
  tdslx = CPEE::Persistence::extract_item(id,opts,'transformation/dslx')
904
- tdslxtype = CPEE::Persistence::extract_item(id,opts,'transformation/dslx/@type')
910
+ tdslxtype = PutTransformation::stored_dslx(id,opts)[0]
905
911
  description = if copy && tdslxtype == 'rest'
906
912
  nil # slow (e.g. bpmn layout), done after storing, see backtransform_async
907
913
  elsif copy
@@ -989,29 +995,41 @@ module CPEE
989
995
  des.find('p:dataelements/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dataelements/@type')
990
996
  des.find('p:endpoints/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/endpoints/@type')
991
997
  des.find('p:dslx').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dslx') || ''
992
- des.find('p:dslx/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dslx/@type') || 'copy' # instances from before dslx backtransformation
998
+ ttype, text = PutTransformation::stored_dslx(id,opts)
999
+ des.find('p:dslx/@type').first.text = ttype
1000
+ des.find('p:dslx').first.attributes['extension'] = text
993
1001
  Riddl::Parameter::Complex.new('status','text/xml',des.to_doc.to_s)
994
1002
  end
995
1003
  end #}}}
996
1004
  class PutTransformation < Riddl::Implementation #{{{
1005
+ def self::stored_dslx(id,opts)
1006
+ ttype = CPEE::Persistence::extract_item(id,opts,'transformation/dslx/@type')
1007
+ text = CPEE::Persistence::extract_item(id,opts,'transformation/dslx/@extension')
1008
+ fallback = ttype.nil? && CPEE::Persistence::extract_item(id,opts,'transformation/description/@type') == 'copy'
1009
+ [ttype || (fallback ? 'copy' : 'none'), text || (fallback ? 'xml' : 'txt')]
1010
+ end
997
1011
  def self::set(id,opts,xml,backtrans=true)
998
1012
  doc = XML::Smart::string(xml)
999
1013
  doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
1000
1014
  tdslx = doc.find('string(/p:transformation/p:dslx)')
1001
- tdslxtype = (t = doc.find('string(/p:transformation/p:dslx/@type)')).empty? ? 'copy' : t # optional, missing means copy
1015
+ type = Proc.new { |item| (t = doc.find("string(/p:transformation/p:#{item}/@type)")).empty? ? 'none' : t }
1016
+ fallback = doc.find('string(/p:transformation/p:dslx/@type)').empty? && type.call('description') == 'copy'
1017
+ tdslxtype = fallback ? 'copy' : type.call('dslx')
1018
+ tdslxext = (t = doc.find('string(/p:transformation/p:dslx/@extension)')).empty? ? (fallback ? 'xml' : 'txt') : t
1002
1019
  changed = tdslx != (CPEE::Persistence::extract_item(id,opts,'transformation/dslx') || '') ||
1003
- tdslxtype != (CPEE::Persistence::extract_item(id,opts,'transformation/dslx/@type') || 'copy')
1020
+ tdslxtype != PutTransformation::stored_dslx(id,opts)[0]
1004
1021
  dslx = CPEE::Persistence::extract_item(id,opts,'dslx')
1005
1022
  dslx = nil if dslx&.empty?
1006
1023
  CPEE::Persistence::set_item(id,opts,'transformation',
1007
1024
  :description => doc.find('string(/p:transformation/p:description)'),
1008
- :description_type => doc.find('string(/p:transformation/p:description/@type)'),
1025
+ :description_type => type.call('description'),
1009
1026
  :dataelements =>doc.find('string(/p:transformation/p:dataelements)'),
1010
- :dataelements_type => doc.find('string(/p:transformation/p:dataelements/@type)'),
1027
+ :dataelements_type => type.call('dataelements'),
1011
1028
  :endpoints =>doc.find('string(/p:transformation/p:endpoints)'),
1012
- :endpoints_type => doc.find('string(/p:transformation/p:endpoints/@type)'),
1029
+ :endpoints_type => type.call('endpoints'),
1013
1030
  :dslx => tdslx,
1014
1031
  :dslx_type => tdslxtype,
1032
+ :dslx_extension => tdslxext,
1015
1033
  :change_uuid => dslx ? Digest::SHA1.hexdigest(dslx) : nil,
1016
1034
  :change_pending => backtrans && changed && tdslxtype == 'rest' && !dslx.nil? # description follows with description/sync
1017
1035
  )
data/lib/cpee/message.rb CHANGED
@@ -66,11 +66,13 @@ module CPEE
66
66
  wid = SecureRandom.hex(16)
67
67
  begin
68
68
  sub.subscribe_with_timeout(2,"event:#{target}:transaction/finished") do |on|
69
+ on.subscribe do
70
+ backend.publish("event:#{target}:transaction/start","#{wid} {}")
71
+ end
69
72
  on.message do |what,message|
70
73
  mess = message[0...message.index(' ')]
71
74
  sub.unsubscribe("event:#{target}:transaction/finished") if mess == wid
72
75
  end
73
- backend.publish("event:#{target}:transaction/start","#{wid} {}")
74
76
  end
75
77
  rescue => e
76
78
  puts "timeout error"
@@ -8,6 +8,7 @@
8
8
  <include href="endpoints.rng"/>
9
9
  <include href="attributes.rng"/>
10
10
  <include href="description.rng"/>
11
+ <include href="dslx.rng"/>
11
12
  <include href="transformation.rng"/>
12
13
 
13
14
  <start>
@@ -21,6 +22,9 @@
21
22
  <ref name="endpoints"/>
22
23
  <ref name="attributes"/>
23
24
  <ref name="description"/>
25
+ <optional>
26
+ <ref name="dslx"/>
27
+ </optional>
24
28
  <ref name="transformation"/>
25
29
  </element>
26
30
  </start>
@@ -8,6 +8,7 @@
8
8
  <include href="endpoints.rng"/>
9
9
  <include href="attributes.rng"/>
10
10
  <include href="description.rng"/>
11
+ <include href="dslx.rng"/>
11
12
  <include href="transformation.rng"/>
12
13
 
13
14
  <start>
@@ -40,6 +41,9 @@
40
41
  <optional>
41
42
  <ref name="description"/>
42
43
  </optional>
44
+ <optional>
45
+ <ref name="dslx"/>
46
+ </optional>
43
47
  <optional>
44
48
  <ref name="transformation"/>
45
49
  </optional>
@@ -8,6 +8,7 @@
8
8
  <include href="endpoints.rng"/>
9
9
  <include href="attributes.rng"/>
10
10
  <include href="description.rng"/>
11
+ <include href="dslx.rng"/>
11
12
  <include href="transformation.rng"/>
12
13
  <include href="subscriptions.rng"/>
13
14
 
@@ -44,6 +45,9 @@
44
45
  <optional>
45
46
  <ref name="description"/>
46
47
  </optional>
48
+ <optional>
49
+ <ref name="dslx"/>
50
+ </optional>
47
51
  <optional>
48
52
  <ref name="transformation"/>
49
53
  </optional>
@@ -1,40 +1,46 @@
1
1
  <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
2
2
  <define name="transformation">
3
3
  <element name="transformation" ns="http://cpee.org/ns/properties/2.0">
4
- <element name="description">
5
- <attribute name="type">
6
- <choice>
7
- <value>copy</value>
8
- <value>rest</value>
9
- <value>xslt</value>
10
- <value>clean</value>
11
- <value>none</value>
12
- </choice>
13
- </attribute>
14
- <data type="anyURI"/>
15
- </element>
16
- <element name="dataelements">
17
- <attribute name="type">
18
- <choice>
19
- <value>rest</value>
20
- <value>xslt</value>
21
- <value>clean</value>
22
- <value>none</value>
23
- </choice>
24
- </attribute>
25
- <data type="anyURI"/>
26
- </element>
27
- <element name="endpoints">
28
- <attribute name="type">
29
- <choice>
30
- <value>rest</value>
31
- <value>xslt</value>
32
- <value>clean</value>
33
- <value>none</value>
34
- </choice>
35
- </attribute>
36
- <data type="anyURI"/>
37
- </element>
4
+ <optional>
5
+ <element name="description">
6
+ <attribute name="type">
7
+ <choice>
8
+ <value>copy</value>
9
+ <value>rest</value>
10
+ <value>xslt</value>
11
+ <value>clean</value>
12
+ <value>none</value>
13
+ </choice>
14
+ </attribute>
15
+ <data type="anyURI"/>
16
+ </element>
17
+ </optional>
18
+ <optional>
19
+ <element name="dataelements">
20
+ <attribute name="type">
21
+ <choice>
22
+ <value>rest</value>
23
+ <value>xslt</value>
24
+ <value>clean</value>
25
+ <value>none</value>
26
+ </choice>
27
+ </attribute>
28
+ <data type="anyURI"/>
29
+ </element>
30
+ </optional>
31
+ <optional>
32
+ <element name="endpoints">
33
+ <attribute name="type">
34
+ <choice>
35
+ <value>rest</value>
36
+ <value>xslt</value>
37
+ <value>clean</value>
38
+ <value>none</value>
39
+ </choice>
40
+ </attribute>
41
+ <data type="anyURI"/>
42
+ </element>
43
+ </optional>
38
44
  <optional>
39
45
  <!-- backtransformation: description from a directly set dslx. missing means copy -->
40
46
  <element name="dslx">
@@ -46,6 +52,9 @@
46
52
  <value>none</value>
47
53
  </choice>
48
54
  </attribute>
55
+ <optional>
56
+ <attribute name="extension"/>
57
+ </optional>
49
58
  <data type="anyURI"/>
50
59
  </element>
51
60
  </optional>
@@ -50,9 +50,13 @@ class Controller
50
50
 
51
51
  @callback_keys = {}
52
52
 
53
+ subscribed = WEEL::Continue.new
53
54
  @subs = Thread.new do
54
55
  @psredis = @opts[:redis_dyn].call "Instance #{@id} Callback Response"
55
56
  @psredis.psubscribe('callback-response:*','callback-end:*') do |on|
57
+ on.psubscribe do |pattern, count|
58
+ subscribed.continue if count == 2
59
+ end
56
60
  on.pmessage do |pat, what, message|
57
61
  if pat == 'callback-response:*'
58
62
  _, worker, identifier = what.split(':')
@@ -83,6 +87,7 @@ class Controller
83
87
  sleep 1
84
88
  retry
85
89
  end
90
+ subscribed.wait
86
91
  Thread.new do
87
92
  while true
88
93
  notify("status/resource_utilization", :mib => GetProcessMem.new.mb, **Process.times.to_h)
@@ -173,23 +178,22 @@ class Controller
173
178
  def vote(what,content={})
174
179
  topic, name = what.split('/')
175
180
  handler = File.join(topic,'vote',name)
176
- votes = []
181
+ pending = []
177
182
 
178
183
  @opts[:votes][handler]&.each do |client|
179
- voteid = SecureRandom.hex(16)
180
- content[:key] = voteid
181
- content[:attributes] = attributes
182
- content[:subscription] = client
183
- votes << voteid
184
- CPEE::Message::send(:vote,what,base,@id,uuid,info,content,@redis)
184
+ pending << content.merge(:key => SecureRandom.hex(16), :attributes => attributes, :subscription => client)
185
185
  end
186
+ votes = pending.map { |c| c[:key] }
186
187
 
187
188
  if votes.length > 0
188
189
  @votes += votes
189
190
  psredis = @opts[:redis_dyn].call "Instance #{@id} Vote"
190
191
  collect = []
191
192
  changes = []
192
- psredis.subscribe(votes.map{|e| ['vote-response:00:' + e.to_s] }.flatten) do |on|
193
+ psredis.subscribe(votes.map{|e| 'vote-response:00:' + e }) do |on|
194
+ on.subscribe do |channel, count|
195
+ pending.each { |c| CPEE::Message::send(:vote,what,base,@id,uuid,info,c,@redis) } if count == votes.length
196
+ end
193
197
  on.message do |what, message|
194
198
  index = message.index(' ')
195
199
  mess = message[index+1..-1]
@@ -17,6 +17,7 @@
17
17
  <event>instantiation</event>
18
18
  <event>take</event>
19
19
  <event>giveback</event>
20
+ <event>probe</event>
20
21
  </topic>
21
22
  <topic id="state">
22
23
  <event>change</event>
@@ -24,7 +25,11 @@
24
25
  <topic id="description">
25
26
  <event>change</event>
26
27
  </topic>
28
+ <topic id="status">
29
+ <event>exposition</event>
30
+ </topic>
27
31
  <topic id="gateway">
32
+ <event>split</event>
28
33
  <event>decide</event>
29
34
  <event>join</event>
30
35
  </topic>
@@ -1 +1 @@
1
- 3635871
1
+ 2228432
@@ -1 +1 @@
1
- 3635891
1
+ 2228450
@@ -1 +1 @@
1
- 3635884
1
+ 2228444
@@ -1 +1 @@
1
- 3635877
1
+ 2228438
@@ -140,6 +140,7 @@ Daemonite.new do |opts|
140
140
  multi.set("instance:#{instance}/transformation/endpoints/@type",mess.dig('content','endpoints_type'),keepttl: true)
141
141
  multi.set("instance:#{instance}/transformation/dslx",mess.dig('content','dslx'),keepttl: true)
142
142
  multi.set("instance:#{instance}/transformation/dslx/@type",mess.dig('content','dslx_type'),keepttl: true)
143
+ multi.set("instance:#{instance}/transformation/dslx/@extension",mess.dig('content','dslx_extension'),keepttl: true)
143
144
  if mess.dig('content','change_pending') # same dslx, but the description is no longer the one for it
144
145
  multi.del("instance:#{instance}/description/@change_uuid")
145
146
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.140
4
+ version: 2.1.141
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler