Skip to content

Commit

Permalink
list_batches
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed Oct 8, 2024
1 parent f359186 commit 80fbed2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/ruby/lib/merritt_zk_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,24 @@ def delete(zk)
# puts "DELETE #{path}"
zk.rm_rf(path)
end

def self.list_batches_as_json(zk)
batches = []
zk.children(DIR).sort.each do |cp|

begin
batch = Batch.new(cp)
batch.load(zk)
batchjson = batch.data
batchjson[:id] = batch.id
batchjson[:status] = batch.status_name
batches.append(batchjson)
rescue StandardError => e
puts "List Batch #{cp} exception: #{e}"
end
end
batches
end
end

end
4 changes: 4 additions & 0 deletions src/main/ruby/spec/zk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ def make_batch_json(s = 'bar', u = 'bid-uuid')
expect(arr.length).to eq(1)
expect(arr[0].id).to eq(@remap['jid1'])

# Only for Ruby interface
arr = MerrittZK::Batch.list_batches_as_json(@zk)
expect(arr.length).to eq(1)

jj.set_status(@zk, MerrittZK::JobState::Deleted)

bbbb.set_status(@zk, MerrittZK::BatchState::Deleted)
Expand Down

0 comments on commit 80fbed2

Please sign in to comment.