Class: OsCtld::SendReceive::Log
- Inherits:
-
Object
- Object
- OsCtld::SendReceive::Log
- Defined in:
- lib/osctld/send_receive/log.rb
Overview
This class serves as a scratchpad for container send/receive
Both the source and the destination nodes have an instance of this class per container. This class determines whether the next step of the send can proceed, stores names of snapshots created during the send and other settings.
Defined Under Namespace
Classes: Options
Constant Summary collapse
- STATES =
%i[stage base incremental transfer cleanup].freeze
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#snapshots ⇒ Object
readonly
Returns the value of attribute snapshots.
-
#state ⇒ Object
Returns the value of attribute state.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
- #can_receive_cancel? ⇒ Boolean
- #can_receive_continue?(next_state) ⇒ Boolean
- #can_send_cancel?(force) ⇒ Boolean
- #can_send_continue?(next_state) ⇒ Boolean
- #close ⇒ Object
- #dump ⇒ Object
-
#initialize(opts) ⇒ Log
constructor
A new instance of Log.
Constructor Details
#initialize(opts) ⇒ Log
Returns a new instance of Log.
101 102 103 104 105 106 107 |
# File 'lib/osctld/send_receive/log.rb', line 101 def initialize(opts) @role = opts[:role] @token = opts[:token] @state = opts[:state] || :stage @snapshots = opts[:snapshots] || [] @opts = opts[:opts].is_a?(Options) ? opts[:opts] : Options.new(opts[:opts] || {}) end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
83 84 85 |
# File 'lib/osctld/send_receive/log.rb', line 83 def opts @opts end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
83 84 85 |
# File 'lib/osctld/send_receive/log.rb', line 83 def role @role end |
#snapshots ⇒ Object (readonly)
Returns the value of attribute snapshots.
83 84 85 |
# File 'lib/osctld/send_receive/log.rb', line 83 def snapshots @snapshots end |
#state ⇒ Object
Returns the value of attribute state.
83 84 85 |
# File 'lib/osctld/send_receive/log.rb', line 83 def state @state end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
83 84 85 |
# File 'lib/osctld/send_receive/log.rb', line 83 def token @token end |
Class Method Details
Instance Method Details
#can_receive_cancel? ⇒ Boolean
152 153 154 |
# File 'lib/osctld/send_receive/log.rb', line 152 def can_receive_cancel? %i[stage base incremental].include?(state) end |
#can_receive_continue?(next_state) ⇒ Boolean
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/osctld/send_receive/log.rb', line 138 def can_receive_continue?(next_state) syncs = %i[base incremental] cur_i = STATES.index(state) next_i = STATES.index(next_state) if !next_i false elsif syncs.include?(state) && syncs.include?(next_state) true else next_i > cur_i end end |
#can_send_cancel?(force) ⇒ Boolean
132 133 134 135 136 |
# File 'lib/osctld/send_receive/log.rb', line 132 def can_send_cancel?(force) cancellable = %i[stage base incremental] cancellable << :transfer if force cancellable.include?(state) end |
#can_send_continue?(next_state) ⇒ Boolean
119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/osctld/send_receive/log.rb', line 119 def can_send_continue?(next_state) cur_i = STATES.index(state) next_i = STATES.index(next_state) if !next_i false elsif state == :incremental && next_state == :incremental true else next_i > cur_i end end |
#close ⇒ Object
162 163 164 |
# File 'lib/osctld/send_receive/log.rb', line 162 def close SendReceive::Tokens.free(token) end |
#dump ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/osctld/send_receive/log.rb', line 109 def dump { 'role' => role.to_s, 'token' => token, 'state' => state.to_s, 'snapshots' => snapshots, 'opts' => opts.dump } end |