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)
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.
87 88 89 90 91 92 93 |
# File 'lib/osctld/send_receive/log.rb', line 87 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.
69 70 71 |
# File 'lib/osctld/send_receive/log.rb', line 69 def opts @opts end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
69 70 71 |
# File 'lib/osctld/send_receive/log.rb', line 69 def role @role end |
#snapshots ⇒ Object (readonly)
Returns the value of attribute snapshots.
69 70 71 |
# File 'lib/osctld/send_receive/log.rb', line 69 def snapshots @snapshots end |
#state ⇒ Object
Returns the value of attribute state.
69 70 71 |
# File 'lib/osctld/send_receive/log.rb', line 69 def state @state end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
69 70 71 |
# File 'lib/osctld/send_receive/log.rb', line 69 def token @token end |
Class Method Details
Instance Method Details
#can_receive_cancel? ⇒ Boolean
138 139 140 |
# File 'lib/osctld/send_receive/log.rb', line 138 def can_receive_cancel? %i(stage base incremental).include?(state) end |
#can_receive_continue?(next_state) ⇒ Boolean
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/osctld/send_receive/log.rb', line 124 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
118 119 120 121 122 |
# File 'lib/osctld/send_receive/log.rb', line 118 def can_send_cancel?(force) cancellable = %i(stage base incremental) cancellable << :transfer if force cancellable.include?(state) end |
#can_send_continue?(next_state) ⇒ Boolean
105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/osctld/send_receive/log.rb', line 105 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
147 148 149 |
# File 'lib/osctld/send_receive/log.rb', line 147 def close SendReceive::Tokens.free(token) end |
#dump ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/osctld/send_receive/log.rb', line 95 def dump { 'role' => role.to_s, 'token' => token, 'state' => state.to_s, 'snapshots' => snapshots, 'opts' => opts.dump, } end |