Skip to content

Commit 4261c85

Browse files
committed
add migration switch
1 parent 68febc9 commit 4261c85

File tree

2 files changed

+11
-58
lines changed

2 files changed

+11
-58
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.1.l'
15+
gem 'mrt-zk', git: 'https://github.com/CDLUC3/mrt-zk.git', tag: '1.0.2.a'
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/actions/zookeeper_action.rb

Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -31,55 +31,6 @@ def to_table
3131
end
3232
end
3333

34-
class QueueItemReader
35-
@@na = "NA"
36-
def initialize(zk_action, id, payload)
37-
@bytes = payload.nil? ? [] : payload.bytes
38-
@is_json = zk_action.is_json
39-
@status_vals = zk_action.status_vals
40-
@queue_node = zk_action.zk_path
41-
@id = id
42-
end
43-
44-
def status_byte
45-
@bytes.empty? ? 0 : @bytes[0]
46-
end
47-
48-
def status
49-
return @@na if status_byte > @status_vals.length
50-
@status_vals[status_byte]
51-
end
52-
53-
def time
54-
return nil if @bytes.length < 9
55-
# https://stackoverflow.com/a/68855488/3846548
56-
t = @bytes[1..8].inject(0) {|m, b| (m << 8) + b }
57-
Time.at(t/1000)
58-
end
59-
60-
def payload_text
61-
return "" if @bytes.length < 10
62-
@bytes[9..].pack('c*')
63-
end
64-
65-
def payload_object
66-
if @is_json
67-
json = JSON.parse(payload_text)
68-
else
69-
json = {
70-
payload: payload_text
71-
}
72-
end
73-
json['queueNode'] = @queue_node
74-
json['id'] = @id
75-
json['date'] = time
76-
json['status'] = status
77-
json
78-
end
79-
80-
end
81-
82-
8334
class ZookeeperAction < AdminAction
8435
def initialize(config, action, path, myparams, filters)
8536
super(config, action, path, myparams)
@@ -88,6 +39,15 @@ def initialize(config, action, path, myparams, filters)
8839
@items = ZkList.new
8940
end
9041

42+
def migration_level
43+
return :m1 if @zk.exists?("/migration/m1")
44+
:none
45+
end
46+
47+
def migration_m1?
48+
migration_level == :m1
49+
end
50+
9151
def zk_path
9252
'/tbd'
9353
end
@@ -109,17 +69,10 @@ def register_item(item)
10969
end
11070

11171
def perform_action
112-
jobs = MerrittZK::LegacyIngestJob.list_jobs(@zk)
72+
jobs = migration_m1? ? MerrittZK::Job.list_jobs(@zk) : MerrittZK::LegacyIngestJob.list_jobs(@zk)
11373
jobs.each do |po|
11474
register_item(QueueEntry.new(po))
11575
end
116-
if false
117-
@zk.children(zk_path).each do |cp|
118-
arr = @zk.get("#{zk_path}/#{cp}")
119-
po = QueueItemReader.new(self, cp, arr[0]).payload_object
120-
register_item(QueueEntry.new(po))
121-
end
122-
end
12376
convert_json_to_table('')
12477
end
12578

0 commit comments

Comments
 (0)