Skip to content

Commit f6d7723

Browse files
committed
inv and acc queues
1 parent 239bc42 commit f6d7723

File tree

9 files changed

+65
-84
lines changed

9 files changed

+65
-84
lines changed

src-colladmin/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gem 'aws-sdk-lambda'
1212
gem 'aws-sdk-s3'
1313
gem 'aws-sdk-ssm'
1414
gem 'csv'
15-
gem 'mrt-zk', git: 'https://github.com/CDLUC3/mrt-zk.git', tag: '1.0.3.g'
15+
gem 'mrt-zk', git: 'https://github.com/CDLUC3/mrt-zk.git', tag: '1.0.3.k'
1616
gem 'rest-client'
1717
gem 'rubocop'
1818
gem 'uc3-ssm', '0.3.10', git: 'https://github.com/CDLUC3/uc3-ssm.git', branch: 'main'

src-colladmin/Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GIT
22
remote: https://github.com/CDLUC3/mrt-zk.git
3-
revision: 9dd3b3e45de97160d2c6331c4152a5e1ab03f83f
4-
tag: 1.0.3.g
3+
revision: 562b8017b32c10473d5dd3986eb4c2243bc064e4
4+
tag: 1.0.3.k
55
specs:
66
mrt-zk (1.0.1)
77
zk (~> 1.10.0)

src-colladmin/actions/access_queue_action.rb

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
# frozen_string_literal: true
22

3-
require_relative 'forward_to_ingest_action'
3+
require_relative 'zookeeper_action'
44
require_relative '../lib/acc_queue'
55

66
# Collection Admin Task class - see config/actions.yml for description
7-
class AccessQueueAction < ForwardToIngestAction
7+
class AccessQueueAction < ZookeeperListAction
88
def initialize(config, action, path, myparams)
99
super(config, action, path, myparams, 'admin/queues-acc')
1010
end
1111

12+
def perform_action
13+
jobs = []
14+
if ZookeeperListAction.migration_m3?
15+
jobs = MerrittZK::Access.list_jobs(@zk)
16+
else
17+
jobs = MerrittZK::LegacyAccessJob.list_jobs(@zk)
18+
end
19+
jobs.each do |po|
20+
register_item(AccQueueEntry.new(po))
21+
end
22+
convert_json_to_table('')
23+
end
24+
1225
def get_title
1326
'List Access Queues'
1427
end
@@ -21,11 +34,6 @@ def table_types
2134
AccQueueEntry.table_types
2235
end
2336

24-
def table_rows(body)
25-
queue_list = AccQueueList.new(get_ingest_server, body)
26-
queue_list.to_table
27-
end
28-
2937
def has_table
3038
true
3139
end

src-colladmin/actions/inventory_queue_action.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# frozen_string_literal: true
22

3-
require_relative 'forward_to_ingest_action'
3+
require_relative 'zookeeper_action'
44
require_relative '../lib/inv_queue'
55

66
# Collection Admin Task class - see config/actions.yml for description
7-
class InventoryQueueAction < InventoryQueueZookeeperAction
7+
class InventoryQueueAction < ZookeeperListAction
88
def initialize(config, action, path, myparams)
99
super(config, action, path, myparams, 'admin/queues-inv')
1010
end
1111

12+
def perform_action
13+
jobs = ZookeeperListAction.migration_m1? ? [] : MerrittZK::LegacyInventoryJob.list_jobs(@zk)
14+
jobs.each do |po|
15+
register_item(InvQueueEntry.new(po))
16+
end
17+
convert_json_to_table('')
18+
end
19+
1220
def get_title
1321
'List Inventory Queues'
1422
end

src-colladmin/actions/zookeeper_action.rb

Lines changed: 16 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,27 @@ def initialize(config, action, path, myparams, _filters)
3838
@filters = {}
3939
@zk = ZK.new(get_zookeeper_conn)
4040
@items = ZkList.new
41+
migration_level
4142
end
4243

4344
def migration_level
44-
return :m1 if @zk.exists?('/migration/m1')
45+
return unless $migration.nil?
4546

46-
:none
47+
$migration = []
48+
$migration << :m1 if @zk.exists?('/migration/m1')
49+
$migration << :m3 if @zk.exists?('/migration/m3')
4750
end
4851

49-
def migration_m1?
50-
migration_level == :m1
51-
end
52+
def self.migration_m1?
53+
return false if $migration.nil?
5254

53-
def zk_path
54-
'/tbd'
55+
$migration.include?(:m1)
5556
end
5657

57-
def status_vals
58-
[]
59-
end
58+
def self.migration_m3?
59+
return false if $migration.nil?
6060

61-
def is_json
62-
false
61+
$migration.include?(:m3)
6362
end
6463

6564
attr_reader :items
@@ -120,17 +119,15 @@ class ZkReleaseM1Action < ZookeeperAction
120119

121120
## Legacy Queue manipulation action using new mrt-zk
122121
class LegacyZkAction < ZookeeperAction
123-
def status_vals
122+
def legacy_status_vals
124123
MerrittZK::LegacyItem::STATUS_VALS
125124
end
126125

127126
def prefix
128127
'na'
129128
end
130129

131-
def qpath
132-
@qpath
133-
end
130+
attr_reader :qpath
134131

135132
def bytes
136133
data = @zk.get(qpath)
@@ -148,7 +145,7 @@ def orig_stat
148145
def orig_stat_name
149146
return if orig_stat.nil?
150147

151-
status_vals[orig_stat]
148+
legacy_status_vals[orig_stat]
152149
end
153150

154151
def write_status(status)
@@ -158,7 +155,7 @@ def write_status(status)
158155
end
159156

160157
def set_status(status)
161-
i = status_vals.find_index(status)
158+
i = legacy_status_vals.find_index(status)
162159
return if i.nil?
163160

164161
orig_name = orig_stat_name
@@ -223,48 +220,11 @@ def check_status(status)
223220

224221
## Class for reading the legacy Merritt Ingest Queue
225222
class IngestQueueZookeeperAction < ZookeeperListAction
226-
def zk_path
227-
'/ingest'
228-
end
229-
230-
def status_vals
231-
MerrittZK::LegacyItem::STATUS_VALS
232-
end
233-
234-
def is_json
235-
true
236-
end
237-
238223
def perform_action
239-
$migration = migration_level if migration_m1?
240-
jobs = migration_m1? ? MerrittZK::Job.list_jobs(@zk) : MerrittZK::LegacyIngestJob.list_jobs(@zk)
224+
jobs = ZookeeperListAction.migration_m1? ? MerrittZK::Job.list_jobs(@zk) : MerrittZK::LegacyIngestJob.list_jobs(@zk)
241225
jobs.each do |po|
242226
register_item(QueueEntry.new(po))
243227
end
244228
convert_json_to_table('')
245229
end
246230
end
247-
248-
## Class for reading the legacy Merritt Inventory Queue
249-
class InventoryQueueZookeeperAction < ZookeeperListAction
250-
def zk_path
251-
'/mrt.inventory.full'
252-
end
253-
254-
def status_vals
255-
MerrittZK::LegacyItem::STATUS_VALS
256-
end
257-
258-
def is_json
259-
true
260-
end
261-
262-
def perform_action
263-
$migration = migration_level if migration_m1?
264-
jobs = migration_m1? ? [] : MerrittZK::LegacyInventoryJob.list_jobs(@zk)
265-
jobs.each do |po|
266-
register_item(InvQueueEntry.new(po))
267-
end
268-
convert_json_to_table('')
269-
end
270-
end

src-colladmin/lib/acc_queue.rb

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,35 @@ def initialize(json)
1414
super()
1515
add_property(
1616
:queueNode,
17-
MerrittJsonProperty.new('Queue Node').lookup_value(json, 'que', 'queueNode')
17+
MerrittJsonProperty.new('Queue Node').lookup_value(json, '', :queueNode)
1818
)
1919
add_property(
2020
:token,
21-
MerrittJsonProperty.new('Token').lookup_value(json, 'que', 'token')
21+
MerrittJsonProperty.new('Token').lookup_value(json, '', :token)
2222
)
2323
add_property(
2424
:bytes,
25-
MerrittJsonProperty.new('Bytes').lookup_value(json, 'que', 'cloudContentByte')
25+
MerrittJsonProperty.new('Bytes').lookup_value(json, '', :'cloud-content-byte')
2626
)
2727
add_property(
2828
:node,
29-
MerrittJsonProperty.new('Node').lookup_value(json, 'que', 'deliveryNode')
29+
MerrittJsonProperty.new('Node').lookup_value(json, '', :'delivery-node')
3030
)
3131
add_property(
3232
:status_code,
33-
MerrittJsonProperty.new('Status Code').lookup_value(json, 'que', 'queueStatus')
33+
MerrittJsonProperty.new('Status Code').lookup_value(json, '', :queueStatus)
3434
)
3535
add_property(
3636
:date,
37-
MerrittJsonProperty.new('Date').lookup_time_value(json, 'que', 'date')
37+
MerrittJsonProperty.new('Date').lookup_time_value(json, '', :date)
3838
)
3939
add_property(
4040
:qstatus,
41-
MerrittJsonProperty.new('QStatus').lookup_value(json, 'que', 'status')
41+
MerrittJsonProperty.new('QStatus').lookup_value(json, '', :status)
4242
)
4343
add_property(
4444
:queueId,
45-
MerrittJsonProperty.new('Queue ID').lookup_value(json, 'que', 'iD')
45+
MerrittJsonProperty.new('Queue ID').lookup_value(json, '', :id)
4646
)
4747
qs = get_value(:qstatus, '')
4848
qt = get_value(:date, '')
@@ -71,11 +71,11 @@ def initialize(json)
7171
)
7272
add_property(
7373
:qdelete,
74-
MerrittJsonProperty.new('Queue Del', get_queue_path(requeue: false))
74+
MerrittJsonProperty.new('Queue Del', get_del_queue_path_m1)
7575
)
7676
add_property(
7777
:requeue,
78-
MerrittJsonProperty.new('Requeue', get_queue_path(requeue: true))
78+
MerrittJsonProperty.new('Requeue', get_requeue_path_m1)
7979
)
8080
end
8181

@@ -93,8 +93,13 @@ def self.table_types
9393
type = 'name' if sym == :token
9494
type = 'bytes' if sym == :bytes
9595
type = 'datetime' if sym == :date
96-
type = 'qdelete' if sym == :qdelete
97-
type = 'requeue' if sym == :requeue
96+
if ZookeeperListAction.migration_m3?
97+
type = 'qdelete-mrtzk' if sym == :qdelete
98+
type = 'requeue-mrtzk' if sym == :requeue
99+
else
100+
type = 'qdelete-legacy' if sym == :qdelete
101+
type = 'requeue-legacy' if sym == :requeue
102+
end
98103
arr.append(type)
99104
end
100105
arr

src-colladmin/lib/inv_queue.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def self.table_types
8080
type = ''
8181
type = 'status' if sym == :status
8282
type = 'datetime' if sym == :date
83-
if $migration == :m1
83+
if ZookeeperListAction.migration_m1?
8484
type = 'qdelete-mrtzk' if sym == :qdelete
8585
type = 'requeue-mrtzk' if sym == :requeue
8686
else

src-colladmin/lib/queue.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def self.table_types
128128
type = 'qjob' if sym == :job
129129
type = 'status' if sym == :status
130130
type = 'datetime' if sym == :date
131-
if $migration == :m1
131+
if ZookeeperListAction.migration_m1?
132132
type = 'qdelete-mrtzk' if sym == :qdelete
133133
type = 'requeue-mrtzk' if sym == :requeue
134134
type = 'hold-mrtzk' if sym == :hold
@@ -192,7 +192,7 @@ def date
192192
end
193193

194194
def get_queue_node
195-
$migration == :m1 ? '/jobs' : '/ingest'
195+
ZookeeperListAction.migration_m1? ? '/jobs' : '/ingest'
196196
end
197197
end
198198

src-testdriver/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ GEM
5656
rspec-expectations (3.13.0)
5757
diff-lcs (>= 1.2.0, < 2.0)
5858
rspec-support (~> 3.13.0)
59-
rspec-mocks (3.13.0)
59+
rspec-mocks (3.13.1)
6060
diff-lcs (>= 1.2.0, < 2.0)
6161
rspec-support (~> 3.13.0)
6262
rspec-support (3.13.1)

0 commit comments

Comments
 (0)