Class: OsCtl::Lib::Zfs::ZpoolTransactionGroups::TransactionGroupList

Inherits:
Object
  • Object
show all
Defined in:
lib/libosctl/zfs/zpool_transaction_groups.rb

Instance Method Summary collapse

Constructor Details

#initializeTransactionGroupList

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

Parameters:



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

Yield Parameters:



83
84
85
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 83

def each(&)
  @list.each(&)
end

#lastTransactionGroup?

Returns:



88
89
90
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 88

def last
  @list.last
end

#last_committedTransactionGroup?

Returns:



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

#lengthInteger

Returns:

  • (Integer)


110
111
112
# File 'lib/libosctl/zfs/zpool_transaction_groups.rb', line 110

def length
  @list.length
end

#openedTransactionGroup

Returns:



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

Parameters:

  • other (TransactionGroupList)
  • changed (Boolean) (defaults to: false)

    include the last txg if its state has changed

Returns:



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