Class: OsCtl::Lib::Zfs::ZpoolTransactionGroups::TransactionGroupList
- Inherits:
-
Object
- Object
- OsCtl::Lib::Zfs::ZpoolTransactionGroups::TransactionGroupList
- Defined in:
- lib/libosctl/zfs/zpool_transaction_groups.rb
Instance Method Summary collapse
- #<<(txg) ⇒ Object
- #each {|| ... } ⇒ Object
-
#initialize ⇒ TransactionGroupList
constructor
A new instance of TransactionGroupList.
- #last ⇒ TransactionGroup?
- #last_committed ⇒ TransactionGroup?
- #length ⇒ Integer
- #opened ⇒ TransactionGroup
-
#since(other, changed: false) ⇒ TransactionGroupList
List transaction groups since older list.
Constructor Details
#initialize ⇒ TransactionGroupList
Returns a new instance of TransactionGroupList.
71 72 73 74 |
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 71 def initialize @list = [] @index = {} end |
Instance Method Details
#<<(txg) ⇒ Object
77 78 79 80 |
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 77 def <<(txg) @list << txg @index[txg.txg] = txg end |
#each {|| ... } ⇒ Object
83 84 85 |
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 83 def each(&) @list.each(&) end |
#last ⇒ TransactionGroup?
88 89 90 |
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 88 def last @list.last end |
#last_committed ⇒ TransactionGroup?
93 94 95 96 97 98 99 |
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 93 def last_committed @list.reverse_each do |txg| return txg if txg.committed? end nil end |
#length ⇒ Integer
110 111 112 |
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 110 def length @list.length end |
#opened ⇒ TransactionGroup
102 103 104 105 106 107 |
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 102 def opened txg = @list.last raise 'expected the last txg to be open' unless txg.open? txg end |
#since(other, changed: false) ⇒ TransactionGroupList
List transaction groups since older list
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 118 def since(other, changed: false) last_txg = other.last return self if last_txg.nil? || !@index.has_key?(last_txg.txg) ret = self.class.new add = false @list.each do |txg| if txg.txg == last_txg.txg add = true next if !changed || txg.state == last_txg.state end ret << txg if add end ret end |