Class: WiseOMF::Client::ReservationManager
- Inherits:
-
Object
- Object
- WiseOMF::Client::ReservationManager
- Defined in:
- lib/wise_omf/client.rb
Overview
The reservation manager handles the creation and storage of node groups and stores all relevant information for the current experiment. The manager is designed as factory, so that it only exists once in the experiment. If you need to talk to a single node, call the ResverationManager.groupForNode(nodeUrn) method. If you want a custom subset of nodes, call the ReservationManager.groupForNodes(nodeUrnArray) method. For talking to all nodes, you can get the approprita group bei calling ReservationManager.allNodesGroup.
Class Method Summary collapse
-
.allNodesGroup ⇒ WiseOMF::Client::WiseGroup
Returns a group to work with when interacting with all nodes of the reservation.
-
.createGroupForNodes(nodeUrns, name = nil, &block) ⇒ Object
Method for creating a group for an arbitrary subset of nodes.
-
.done ⇒ Object
Finalizes all node groups and the reservation group.
-
.groupForNode(nodeUrn) ⇒ Object
Returns a WiseGroup to talk to.
-
.groupForNodes(nodeUrns) ⇒ WiseOMF::Client::WiseGroup
Returns a group to use when interacting with an arbitrary subset of the all nodes set.
-
.init(reservation, nodeUrns) ⇒ Object
Initializes the reservation manager class and creates the following WiseGroups: - The allNodesGroup (containing all nodes of this reservation) - One node group for each single node - One group for the reservation itself.
-
.reservationGroup ⇒ Object
Getter for the reservation group.
-
.reservationID ⇒ Object
Getter for the reservation id of the current reservation.
Class Method Details
.allNodesGroup ⇒ WiseOMF::Client::WiseGroup
Returns a group to work with when interacting with all nodes of the reservation
248 249 250 251 252 253 254 255 |
# File 'lib/wise_omf/client.rb', line 248 def self.allNodesGroup groupId = WiseOMFUtils::UIDHelper.node_group_uid(@@reservation, @@nodeUrns) if @@nodeGroups[groupId].nil? @@nodeGroups[groupId] = WiseOMF::Client::WiseGroup.new('AllNodes', groupId) @@nodeGroups[groupId].init_callback end @@nodeGroups[groupId] end |
.createGroupForNodes(nodeUrns, name = nil, &block) ⇒ Object
Method for creating a group for an arbitrary subset of nodes
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/wise_omf/client.rb', line 206 def self.createGroupForNodes(nodeUrns, name = nil, &block) groupId = WiseOMFUtils::UIDHelper.node_group_uid(@@reservation, nodeUrns) if @@nodeGroups[groupId].nil? if name.nil? group = WiseOMF::Client::WiseGroup.new(nodeUrns.to_s, groupId) else group = WiseOMF::Client::WiseGroup.new(name, groupId) end @@nodeGroups[groupId] = group info 'Creating new group' group.init_callback { info 'Topic initialized' group.group.topic.(:wait_for_membership) { |msg| info "Wait for Membership: #{msg.to_yaml}" if msg.properties.membership && msg.properties.membership.include?(group.group.address) info 'New group setup finished' group.group.topic.unsubscribe(:wait_for_membership) block.call(group) if block end } @@reservationGroup.group.topic.create(:wisebed_node, {uid: groupId, urns: nodeUrns, membership: group.group.address}) } else block.call(@@nodeGroups[groupId]) if block end end |
.done ⇒ Object
Finalizes all node groups and the reservation group. Call this method at the end of your experiment just before calling OmfEc::Experiment.done
280 281 282 283 284 |
# File 'lib/wise_omf/client.rb', line 280 def self.done info 'Cleaning Reservation Resources' @@nodeGroups.each_value { |group| group.done } @@reservationGroup.done end |
.groupForNode(nodeUrn) ⇒ Object
Returns a WiseGroup to talk to. This group should be used for interacting with single nodes.
@return the group for a single resource
262 263 264 265 266 267 268 269 |
# File 'lib/wise_omf/client.rb', line 262 def self.groupForNode(nodeUrn) groupId = WiseOMFUtils::UIDHelper.node_group_uid(@@reservation, [nodeUrn]) if @@nodeGroups[groupId].nil? @@nodeGroups[groupId] = WiseOMF::Client::WiseGroup.new(nodeUrn, groupId) @@nodeGroups[groupId].init_callback end @@nodeGroups[groupId] end |
.groupForNodes(nodeUrns) ⇒ WiseOMF::Client::WiseGroup
Returns a group to use when interacting with an arbitrary subset of the all nodes set
240 241 242 243 |
# File 'lib/wise_omf/client.rb', line 240 def self.groupForNodes(nodeUrns) groupId = WiseOMFUtils::UIDHelper.node_group_uid(@@reservation, nodeUrns) @@nodeGroups[groupId] end |
.init(reservation, nodeUrns) ⇒ Object
Initializes the reservation manager class and creates the following WiseGroups:
- The allNodesGroup (containing all nodes of this reservation)
- One node group for each single node
- One group for the reservation itself
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/wise_omf/client.rb', line 176 def self.init(reservation, nodeUrns) @@nodeGroups = {} @@reservation = reservation @@nodeUrns = nodeUrns @@reservationGroup = WiseOMF::Client::WiseGroup.new('ReservationGroup', self.reservationID) @@reservationGroup.init_callback # Creating the all nodes group: self.allNodesGroup # Creating the single node groups: @@nodeUrns.each { |node| self.groupForNode(node) } end |
.reservationGroup ⇒ Object
Getter for the reservation group
@return the group
195 196 197 |
# File 'lib/wise_omf/client.rb', line 195 def self.reservationGroup @@reservationGroup end |
.reservationID ⇒ Object
Getter for the reservation id of the current reservation
@return the reservation id for this reservation
274 275 276 |
# File 'lib/wise_omf/client.rb', line 274 def self.reservationID WiseOMFUtils::UIDHelper.reservation_uid(@@reservation) end |