omf_common 6.0.4.pre.1 → 6.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTRlZWFhMDI4MWE0NDQ2ZDIxM2U3ZWVlZWM0NmIzN2QzMTNjZGUwNA==
4
+ MGMxMmVlYjViNTBmOGM2ZmVmZWY5OTNmMDVmNTcyYzJkNjc5OTU5Ng==
5
5
  data.tar.gz: !binary |-
6
- OTBhNDQ5NWZiOGRmNWRhZWYwOTJjMGQwYWNmNDBlZjJjMjhkZTRlYg==
6
+ OGIwZTAwNmI4ZmI3MDE1MzU0ZDQ5ZDM5YmNmOWQ0ZWFhOWQ1YThlOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDk2NDE0N2JjMmE0YzMwYTk3NzFiNTJiM2I2MWVhNjNlZTEwYmY2MjUwOGI4
10
- ZDQ5NmFiZTU3NmE2NzNjZThiNDIyYTVmOWYxYjJiM2I2NzFjMTEzOGQzM2Mz
11
- ZDg2YWM0Y2YyY2MxZDM1ZDUyYjU5YTZlMDk4NjE3NjExZWE0MjU=
9
+ Yzk3YWE4NzllMmQxYTMxZWUxNzZkMzc1YTQ4MzY5ZGY3NWMzOTAzOTlhMDZk
10
+ M2FjMTkyOGI0YWYyMjk0NWQyOWQ1ODFmZDhlZWNmNWVjNDA0YWUzYmQ0NWFh
11
+ OTcwMDBjNjM3ZWUyNDU5NzI3ZDk3MDQ1MDM0ZjRlNDJlYjc4OTM=
12
12
  data.tar.gz: !binary |-
13
- NTkwNWZiZmZlZWI2N2NjMWYzODhhMzE5YzBiYzdkZjk5ZDM2ZmNmZDM2NmUy
14
- ZDQ0M2MzNDczYmZjZjM4NGQ1ZGNlNDY1M2U5NDkzN2Q2MWRhMWRmNjRiNGE2
15
- ZmIzZGQyMTdiZWY2MTVkNjlmNTM3NGQyYjkwOGU1M2IxMTNhYWQ=
13
+ ZTc1NmQ4ZDA0ZjU4ZmFkMzFkY2QzMTk5OWQ1MWE3ZmJjZDc0YmMxNmUzYjg1
14
+ MjFkMGZlMWJlNjgwMDJmNWI3OGZjMjNmNDAzYTcxNWM0ZGJlYjAyZTBlYTBl
15
+ YzIzZGVjMTBiMzUyN2FhMDMxOWJmZDliZDhjNDM0Y2U3NzYxODc=
@@ -12,6 +12,12 @@ that there will be a delay until the new monitors are in place which
12
12
  can result in missed messages.
13
13
  }
14
14
 
15
+ # The following is to work around a bug in activesupport triggered by
16
+ # the JWT library which is used only in the AMQP transport, os it
17
+ # fails quietly if that library is not installed in XMPP deployments
18
+ begin; require 'json/jwt'; rescue Exception; end
19
+
20
+
15
21
  require 'optparse'
16
22
  require 'omf_common'
17
23
 
@@ -10,6 +10,11 @@ Any additional command line arguments are interpreted as property:value and are
10
10
  sent with the create message.
11
11
  }
12
12
 
13
+ # The following is to work around a bug in activesupport triggered by
14
+ # the JWT library which is used only in the AMQP transport, os it
15
+ # fails quietly if that library is not installed in XMPP deployments
16
+ begin; require 'json/jwt'; rescue Exception; end
17
+
13
18
  require 'omf_common'
14
19
 
15
20
  OP_MODE = :development
data/bin/omf_send_create CHANGED
@@ -10,6 +10,11 @@ Any additional command line arguments are interpreted as property:value and are
10
10
  sent with the create message.
11
11
  }
12
12
 
13
+ # The following is to work around a bug in activesupport triggered by
14
+ # the JWT library which is used only in the AMQP transport, os it
15
+ # fails quietly if that library is not installed in XMPP deployments
16
+ begin; require 'json/jwt'; rescue Exception; end
17
+
13
18
  require 'omf_common'
14
19
 
15
20
  OP_MODE = :development
data/bin/omf_send_request CHANGED
@@ -10,6 +10,12 @@ Any additional command line arguments are interpreted as limiting the request
10
10
  to those, otherwise all properties are requested.
11
11
  }
12
12
 
13
+ # The following is to work around a bug in activesupport triggered by
14
+ # the JWT library which is used only in the AMQP transport, os it
15
+ # fails quietly if that library is not installed in XMPP deployments
16
+ begin; require 'json/jwt'; rescue Exception; end
17
+
18
+
13
19
  require 'omf_common'
14
20
 
15
21
  OP_MODE = :development
@@ -34,7 +34,6 @@ module OmfCommon
34
34
  end
35
35
  @address_prefix = @url + '/'
36
36
  _connect()
37
- #AMQP::Session#on_skipped_heartbeats callback that can be used to handle skipped heartbeats
38
37
  super
39
38
  end
40
39
 
@@ -119,60 +118,78 @@ module OmfCommon
119
118
  end
120
119
 
121
120
  def _connect()
122
- last_reported_timestamp = nil
123
- @session = ::AMQP.connect(@url, @opts) do |connection|
124
- connection.on_tcp_connection_loss do |conn, settings|
125
- now = Time.now
126
- if last_reported_timestamp == nil || (now - last_reported_timestamp) > 60
127
- warn "Lost connectivity. Trying to reconnect..."
128
- last_reported_timestamp = now
121
+ begin
122
+ last_reported_timestamp = nil
123
+ @session = ::AMQP.connect(@url, @opts) do |connection|
124
+ connection.on_tcp_connection_loss do |conn, settings|
125
+ now = Time.now
126
+ if last_reported_timestamp == nil || (now - last_reported_timestamp) > 60
127
+ warn "Lost connectivity. Trying to reconnect..."
128
+ last_reported_timestamp = now
129
+ end
130
+ _reconnect(conn)
129
131
  end
130
- conn.reconnect(false, 2)
131
- end
132
- @channel = ::AMQP::Channel.new(connection)
133
- @channel.auto_recovery = true
132
+ @channel = ::AMQP::Channel.new(connection)
133
+ @channel.auto_recovery = true
134
134
 
135
+ @on_connected_procs.each do |proc|
136
+ proc.arity == 1 ? proc.call(self) : proc.call
137
+ end
135
138
 
136
- @on_connected_procs.each do |proc|
137
- proc.arity == 1 ? proc.call(self) : proc.call
139
+ OmfCommon.eventloop.on_stop do
140
+ connection.close
141
+ end
138
142
  end
139
143
 
140
- OmfCommon.eventloop.on_stop do
141
- connection.close
144
+ rec_delay = @opts[:reconnect_delay]
145
+ @session.on_tcp_connection_failure do
146
+ warn "Cannot connect to AMQP server '#{@url}'. Attempt to retry in #{rec_delay} sec"
147
+ @session = nil
148
+ OmfCommon.eventloop.after(rec_delay) do
149
+ info 'Retrying'
150
+ _connect
151
+ end
142
152
  end
143
- end
144
-
145
- rec_delay = @opts[:reconnect_delay]
146
- @session.on_tcp_connection_failure do
147
- warn "Cannot connect to AMQP server '#{@url}'. Attempt to retry in #{rec_delay} sec"
148
- @session = nil
149
- OmfCommon.eventloop.after(rec_delay) do
150
- info 'Retrying'
151
- _connect
153
+ # @session.on_tcp_connection_loss do
154
+ # _reconnect "Appear to have lost tcp connection. Attempt to reconnect in #{rec_delay} sec"
155
+ # end
156
+ @session.on_skipped_heartbeats do
157
+ info '... on_skipped_heartbeats!'
158
+ #_reconnect "Appear to have lost heartbeat. Attempt to reconnect in #{rec_delay} sec"
152
159
  end
160
+ @session.on_recovery do
161
+ info 'Recovered!'
162
+ last_reported_timestamp = nil
163
+ @on_reconnect.values.each do |block|
164
+ block.call()
165
+ end
166
+ end
167
+ true
168
+ rescue Exception => ex
169
+ delay = @opts[:reconnect_delay]
170
+ warn "Connecting AMQP failed, will retry in #{delay} (#{ex})"
171
+ OmfCommon.eventloop.after(delay) do
172
+ if _connect
173
+ info 'Reconnection suceeded'
174
+ end
175
+ end
176
+ false
153
177
  end
154
- # @session.on_tcp_connection_loss do
155
- # _reconnect "Appear to have lost tcp connection. Attempt to reconnect in #{rec_delay} sec"
156
- # end
157
- # @session.on_skipped_heartbeats do
158
- # _reconnect "Appear to have lost heartbeat. Attempt to reconnect in #{rec_delay} sec"
159
- # end
160
- @session.on_recovery do
161
- info 'Recovered!'
162
- last_reported_timestamp = nil
163
- @on_reconnect.values.each do |block|
164
- block.call()
178
+ end
179
+
180
+ def _reconnect(conn)
181
+ begin
182
+ conn.reconnect(false, 2)
183
+ rescue Exception => ex
184
+ delay = @opts[:reconnect_delay]
185
+ warn "Reconnect AMQP failed, will retry in #{delay} (#{ex})"
186
+ OmfCommon.eventloop.after(delay) do
187
+ info 'Reconnecting'
188
+ _reconnect(conn)
165
189
  end
166
190
  end
167
191
  end
168
192
 
169
- # def _reconnect(warn_message = nil)
170
- # warn(warn_message) if warn_message
171
- # OmfCommon.eventloop.after(@opts[:reconnect_delay]) do
172
- # info 'Reconnecting'
173
- # @session.reconnect
174
- # end
175
- # end
176
193
  end
177
194
  end
178
195
  end
@@ -37,7 +37,7 @@ require 'fcntl'
37
37
  # Borrows from Open3
38
38
  #
39
39
  class ExecApp
40
-
40
+
41
41
  # Holds the pids for all active apps
42
42
  @@all_apps = Hash.new
43
43
 
@@ -55,7 +55,7 @@ class ExecApp
55
55
  end
56
56
 
57
57
  attr_reader :pid, :clean_exit
58
-
58
+
59
59
  # True if this active app is being killed by a proper
60
60
  # call to ExecApp.signal_all() or signal()
61
61
  # (i.e. when the caller of ExecApp decided to stop the application,
@@ -70,11 +70,11 @@ class ExecApp
70
70
  end
71
71
 
72
72
  def signal(signal = 'KILL')
73
+ logger.debug "Sending signal '#{signal}' to app '#{@id}' with pid #{@pid}"
73
74
  @clean_exit = true
74
75
  Process.kill(signal, -1 * @pid) # we are sending to the entire process group
75
76
  end
76
77
 
77
-
78
78
  #
79
79
  # Run an application 'cmd' in a separate thread and monitor
80
80
  # its stdout. Also send status reports to the 'observer' by
@@ -115,9 +115,9 @@ class ExecApp
115
115
  pe[1].close
116
116
 
117
117
  begin
118
- pgid = Process.setsid # Create a new process group
118
+ pgid = Process.setsid # Create a new process group
119
119
  # which includes all potential child processes
120
- STDOUT.puts "INTERNAL WARNING: Assuming process_group_id == pid" unless pgid == $$
120
+ STDOUT.puts "INTERNAL WARNING: Assuming process_group_id == pid" unless pgid == $$
121
121
  Dir.chdir working_directory if working_directory
122
122
  exec(cmd)
123
123
  rescue => ex
@@ -135,9 +135,10 @@ class ExecApp
135
135
  monitor_pipe(map_std_err_to_out ? :stdout : :stderr, pe[0])
136
136
  # Create thread which waits for application to exit
137
137
  @threads << Thread.new(id, @pid) do |id, pid|
138
- ret = Process.waitpid(pid)
139
- @exit_status = $?.exitstatus
140
- if @exit_status > 127
138
+ Process.waitpid(pid)
139
+ # Exit status is sometimes nil (OSX 10.8, ping)
140
+ @exit_status = $?.exitstatus || 0
141
+ if @exit_status > 127
141
142
  @exit_status = 128 - @exit_status
142
143
  end
143
144
  @@all_apps.delete(@id)
@@ -149,7 +150,7 @@ class ExecApp
149
150
  end
150
151
  end
151
152
  @stdin = pw[1]
152
-
153
+
153
154
  # wait for done in yet another thread
154
155
  Thread.new do
155
156
  @threads.each {|t| t.join }
@@ -157,7 +158,7 @@ class ExecApp
157
158
  end
158
159
  logger.debug "Application is running with PID #{@pid}"
159
160
  end
160
-
161
+
161
162
  private
162
163
 
163
164
  #
@@ -184,7 +185,7 @@ class ExecApp
184
185
  end
185
186
  end
186
187
  end
187
-
188
+
188
189
  def call_observer(event_type, msg)
189
190
  return unless @observer
190
191
  begin
@@ -4,6 +4,6 @@
4
4
  # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
5
 
6
6
  module OmfCommon
7
- VERSION = "6.0.4.pre.1"
7
+ VERSION = "6.0.4"
8
8
  PROTOCOL_VERSION = "6.0"
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_common
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.4.pre.1
4
+ version: 6.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - NICTA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-29 00:00:00.000000000 Z
11
+ date: 2013-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -263,9 +263,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
263
263
  version: 1.9.3
264
264
  required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  requirements:
266
- - - ! '>'
266
+ - - ! '>='
267
267
  - !ruby/object:Gem::Version
268
- version: 1.3.1
268
+ version: '0'
269
269
  requirements: []
270
270
  rubyforge_project: omf_common
271
271
  rubygems_version: 2.0.7