soar_sr 1.1.8 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/soar_sr/associations.rb +48 -1
- data/lib/soar_sr/services.rb +1 -22
- data/lib/soar_sr/threaded_handler.rb +28 -0
- data/lib/soar_sr/version.rb +1 -1
- data/lib/soar_sr.rb +7 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74ef5cd38ea67592ac85026463f7162449e11c06
|
4
|
+
data.tar.gz: a366c7a73d6e93fc659b61bd392e395d607e1138
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7055ac00e8c02ea0cce619655f2b30b93a0a2cec87d9ae338892ff661b741977474fa827c43a109447f52abb0755e11623da823fb04fdd5e7c7c3e4bd61b541d
|
7
|
+
data.tar.gz: 4e37f159c663a79f511cbdc6e9c12cb0bfdbfebd34eb9da4be49b34bbb78fbf100237bea0dff38c969d35674fa8cfe452d303930bb3d16d8b3a647a90e273024
|
data/lib/soar_sr/associations.rb
CHANGED
@@ -3,7 +3,7 @@ require 'soap4juddi'
|
|
3
3
|
require 'byebug'
|
4
4
|
|
5
5
|
module SoarSr
|
6
|
-
class Associations < SoarSr::
|
6
|
+
class Associations < SoarSr::ThreadedHandler
|
7
7
|
include Jsender
|
8
8
|
|
9
9
|
def service_component_has_domain_perspective_associations?(service_component)_{
|
@@ -44,6 +44,28 @@ module SoarSr
|
|
44
44
|
(associations['service_components'].size > 0) or (associations['services'].size > 0)
|
45
45
|
end
|
46
46
|
|
47
|
+
def service_associations(service)
|
48
|
+
service = standardize(service)
|
49
|
+
provided?(service, 'service') and registered?(service, 'services')
|
50
|
+
result = @registry.services.service_uris(service)
|
51
|
+
service = {'id' => compile_domain_id('services', service), 'uris' => result['data']['bindings'], 'associations' => { 'domain_perspectives' => []}}
|
52
|
+
domain_perspectives = @registry.domain_perspectives.list_domain_perspectives['data']['domain_perspectives']
|
53
|
+
|
54
|
+
threads = []
|
55
|
+
services = []
|
56
|
+
domain_perspectives.each do |name, details|
|
57
|
+
threads, services = domain_perspective_associations_threaded(threads, name, service, services)
|
58
|
+
end
|
59
|
+
join_threads(threads)
|
60
|
+
services.each do |sv|
|
61
|
+
service['associations']['domain_perspectives'] =
|
62
|
+
Hash::deep_merge(service['associations']['domain_perspectives'],
|
63
|
+
sv['associations']['domain_perspectives'])
|
64
|
+
service['associations']['domain_perspectives'] = service['associations']['domain_perspectives'].uniq
|
65
|
+
end
|
66
|
+
service
|
67
|
+
end
|
68
|
+
|
47
69
|
def associate_service_component_with_domain_perspective(service_component, domain_perspective)_{
|
48
70
|
service_component = standardize(service_component)
|
49
71
|
domain_perspective = standardize(domain_perspective)
|
@@ -154,6 +176,31 @@ module SoarSr
|
|
154
176
|
|
155
177
|
private
|
156
178
|
|
179
|
+
def domain_perspective_associations_threaded(threads, domain_perspective, service, services)
|
180
|
+
thread = nil
|
181
|
+
threads = join_on_max_threads(threads)
|
182
|
+
threads << Thread.new do
|
183
|
+
result = map_domain_perspective_associations(domain_perspective, service)
|
184
|
+
@@mutex.synchronize do
|
185
|
+
services << result
|
186
|
+
end
|
187
|
+
end
|
188
|
+
return threads, services
|
189
|
+
end
|
190
|
+
|
191
|
+
def map_domain_perspective_associations(domain_perspective, service)
|
192
|
+
result = domain_perspective_associations(domain_perspective)
|
193
|
+
result['data']['associations']['services'].each do |id, associated|
|
194
|
+
`echo "#{id} -> #{associated} with #{service[id]} and #{id} and #{associated}}" >> /Users/ernstv/scratch/log` if (domain_perspective == 'testing')
|
195
|
+
if ((service['id'] == id) and (associated == true))
|
196
|
+
service['associations'] ||= {}
|
197
|
+
service['associations']['domain_perspectives'] ||= []
|
198
|
+
service['associations']['domain_perspectives'] << domain_perspective
|
199
|
+
end
|
200
|
+
end
|
201
|
+
service
|
202
|
+
end
|
203
|
+
|
157
204
|
def no_meta?(meta)
|
158
205
|
(meta['associations']['service_components'] == {}) and (meta['associations']['services'] == {})
|
159
206
|
end
|
data/lib/soar_sr/services.rb
CHANGED
@@ -4,16 +4,9 @@ require 'json'
|
|
4
4
|
require 'byebug'
|
5
5
|
|
6
6
|
module SoarSr
|
7
|
-
class Services < SoarSr::
|
7
|
+
class Services < SoarSr::ThreadedHandler
|
8
8
|
include Jsender
|
9
9
|
ALL_SERVICES = nil unless defined? ALL_SERVICES; ALL_SERVICES.freeze
|
10
|
-
attr_accessor :max_threads
|
11
|
-
|
12
|
-
def initialize(urns, uddi, credentials, registry, max_threads = 15)
|
13
|
-
super(urns, uddi, credentials, registry)
|
14
|
-
@@mutex = Mutex.new
|
15
|
-
@max_threads = max_threads
|
16
|
-
end
|
17
10
|
|
18
11
|
def register_service(service, description = nil)_{
|
19
12
|
service = standardize(service)
|
@@ -177,20 +170,6 @@ module SoarSr
|
|
177
170
|
services
|
178
171
|
end
|
179
172
|
|
180
|
-
def join_threads(threads)
|
181
|
-
threads.each do |t|
|
182
|
-
t.join
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
def join_on_max_threads(threads)
|
187
|
-
if threads.count == @max_threads
|
188
|
-
join_threads(threads)
|
189
|
-
threads = []
|
190
|
-
end
|
191
|
-
threads
|
192
|
-
end
|
193
|
-
|
194
173
|
def map_service_uri_threaded(threads, service)
|
195
174
|
thread = nil
|
196
175
|
threads = join_on_max_threads(threads)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module SoarSr
|
2
|
+
class ThreadedHandler < Handler
|
3
|
+
include Jsender
|
4
|
+
attr_accessor :max_threads
|
5
|
+
|
6
|
+
def initialize(urns, uddi, credentials, registry, max_threads = 15)
|
7
|
+
super(urns, uddi, credentials, registry)
|
8
|
+
@@mutex = Mutex.new
|
9
|
+
@max_threads = max_threads
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def join_threads(threads)
|
15
|
+
threads.each do |t|
|
16
|
+
t.join
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def join_on_max_threads(threads)
|
21
|
+
if threads.count == @max_threads
|
22
|
+
join_threads(threads)
|
23
|
+
threads = []
|
24
|
+
end
|
25
|
+
threads
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/soar_sr/version.rb
CHANGED
data/lib/soar_sr.rb
CHANGED
@@ -2,6 +2,7 @@ require "soar_sr/version"
|
|
2
2
|
require "soar_sr/validation_error"
|
3
3
|
require "soar_sr/validator"
|
4
4
|
require "soar_sr/handler"
|
5
|
+
require "soar_sr/threaded_handler"
|
5
6
|
require "soar_sr/services"
|
6
7
|
require "soar_sr/service_components"
|
7
8
|
require "soar_sr/service_definitions"
|
@@ -20,7 +21,12 @@ end
|
|
20
21
|
|
21
22
|
class ::Hash
|
22
23
|
def self.deep_merge(first, second)
|
23
|
-
result = first
|
24
|
+
result = first
|
25
|
+
if first.is_a?(Hash) and (second.is_a?(Hash))
|
26
|
+
result = first.merge(second)
|
27
|
+
else
|
28
|
+
return first + second
|
29
|
+
end
|
24
30
|
first.each do |first_key, first_value|
|
25
31
|
second.each do |second_key, second_value|
|
26
32
|
if (first_key == second_key)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soar_sr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernst van Graan
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/soar_sr/service_registry.rb
|
140
140
|
- lib/soar_sr/services.rb
|
141
141
|
- lib/soar_sr/teams.rb
|
142
|
+
- lib/soar_sr/threaded_handler.rb
|
142
143
|
- lib/soar_sr/validation_error.rb
|
143
144
|
- lib/soar_sr/validator.rb
|
144
145
|
- lib/soar_sr/version.rb
|