iudex-worker 1.3.0-java → 1.3.1-java

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.3.1 (2012-10-25)
2
+ * Improve shutdown reliability by adding Agent.run_safe with ensure'd
3
+ close calls.
4
+
1
5
  === 1.3.0 (2012-10-4)
2
6
  * Expand to iudex-core, -da, -rome, -html, -simhash [1.2.1,1.4)
3
7
 
data/init/iudex-worker CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  require 'rubygems'
26
26
 
27
- gem( "iudex-worker", "= 1.3.0" )
27
+ gem( "iudex-worker", "= 1.3.1" )
28
28
 
29
29
  module IudexInitScript
30
30
 
@@ -86,45 +86,48 @@ module Iudex
86
86
 
87
87
  def run
88
88
  Hooker.with( :iudex ) do
89
- dsf = PoolDataSourceFactory.new
90
- data_source = dsf.create
89
+ run_safe
90
+ end
91
+ end
91
92
 
92
- wpoller = work_poller( data_source )
93
- vexec = visit_manager( wpoller )
94
- vexec.start_executor
93
+ def run_safe
94
+ dsf = PoolDataSourceFactory.new
95
+ data_source = dsf.create
95
96
 
96
- hclient = http_client( vexec.executor )
97
+ wpoller = work_poller( data_source )
98
+ vexec = visit_manager( wpoller )
99
+ vexec.start_executor
97
100
 
98
- fcf = filter_chain_factory
99
- fcf.http_client = hclient
100
- fcf.data_source = data_source
101
- fcf.visit_counter = vexec
101
+ hclient = http_client( vexec.executor )
102
102
 
103
- # FilterChain's executor is the same executor, unless using
104
- # HTTPClient3, where executor is best not used
105
- fcf.executor = vexec.executor unless @http_manager
103
+ fcf = filter_chain_factory
104
+ fcf.http_client = hclient
105
+ fcf.data_source = data_source
106
+ fcf.visit_counter = vexec
106
107
 
107
- Hooker.apply( :filter_factory, fcf )
108
+ # FilterChain's executor is the same executor, unless using
109
+ # HTTPClient3, where executor is best not used
110
+ fcf.executor = vexec.executor unless @http_manager
108
111
 
109
- fcf.filter do |chain|
110
- vexec.filter_chain = chain
112
+ Hooker.apply( [ :iudex, :filter_factory ], fcf )
111
113
 
112
- Hooker.log_not_applied # All hooks should be used by now
114
+ fcf.filter do |chain|
115
+ vexec.filter_chain = chain
113
116
 
114
- vexec.start
115
- vexec.join #Run until interrupted
116
- end # fcf closes
117
+ Hooker.log_not_applied # All hooks should be used by now
117
118
 
118
- hclient.close if hclient.respond_to?( :close )
119
- @http_manager.shutdown if @http_manager
119
+ vexec.start
120
+ vexec.join # Run until interrupted
121
+ end # fcf closes
120
122
 
121
- dsf.close
122
- end
123
123
  rescue => e
124
124
  @log.error( "On run: ", e )
125
+ ensure
126
+ hclient.close if hclient && hclient.respond_to?( :close )
127
+ @http_manager.shutdown if @http_manager
128
+ dsf.close if dsf
125
129
  end
126
130
 
127
131
  end
128
-
129
132
  end
130
133
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Iudex
18
18
  module Worker
19
- VERSION = '1.3.0'
19
+ VERSION = '1.3.1'
20
20
  end
21
21
  end
data/test/test_agent.rb CHANGED
@@ -69,6 +69,19 @@ class TestAgent < MiniTest::Unit::TestCase
69
69
  Iudex.send( :remove_const, :AsyncHTTPClient )
70
70
  end
71
71
 
72
+ def test_agent_graceful_shutdown_on_fcf_error
73
+ Hooker.add( [ :iudex, :filter_factory ] ) do |fcf|
74
+ def fcf.filters
75
+ super
76
+ raise "Test Badness in FCF"
77
+ end
78
+ end
79
+
80
+ agent = Agent.new
81
+ agent.run
82
+ pass # returns
83
+ end
84
+
72
85
  def assert_agent
73
86
 
74
87
  # Stub VisitManager.start to allow agent.run to return early.
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: iudex-worker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.3.0
5
+ version: 1.3.1
6
6
  platform: java
7
7
  authors:
8
8
  - David Kellum
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-04 00:00:00.000000000 Z
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: iudex-core