Ce contenu n'est pas disponible dans la langue sélectionnée.
8.5.2. Example Gear Placement Algorithms
Prerequisites:
Gem_Location/lib/openshift/
directory, with any related example initializers and configuration files located in the Gem_Location/config/initializers/
and /etc/openshift/plugins.d/
directories, respectively. See Section 8.5.1, “Developing and Implementing a Custom Gear Placement Algorithm” for information on implementing custom algorithms in your environment.
The following are administrator constraint example algorithms for the gear placement plug-in.
Example 8.8. Return the First Node in the List
def self.select_best_fit_node_impl(server_infos, app_props, current_gears, comp_list, user_props, request_time) return server_infos.first end
def self.select_best_fit_node_impl(server_infos, app_props, current_gears, comp_list, user_props, request_time)
return server_infos.first
end
Example 8.9. Place PHP Applications on Specific Nodes
Gem_Location/lib/openshift/gear_placement_plugin.rb.pin-php-to-host-example
file. However, to prevent scalable or highly-available applications from behaving unpredictably as a result of the server_infos
filters mentioned in Section 8.5.1, “Developing and Implementing a Custom Gear Placement Algorithm”, use the VALID_GEAR_SIZES_FOR_CARTRIDGE
parameter in the /etc/openshift/broker.conf
file in conjunction with profiles.
Example 8.10. Restrict a User's Applications to Slow Hosts
Gem_Location/lib/openshift/gear_placement_plugin.rb.pin-user-to-host-example
file. However, this could prevent the user from scaling applications in some situations as a result of the server_infos
filters mentioned in Section 8.5.1, “Developing and Implementing a Custom Gear Placement Algorithm”.
Example 8.11. Ban a Specific Vendor's Cartridges
Gem_Location/lib/openshift/gear_placement_plugin.rb.blacklisted-vendor-example
file.
The following are resource usage example algorithms for the gear placement plug-in.
Example 8.12. Place a Gear on the Node with the Most Free Memory
Gem_Location/lib/openshift/gear_placement_plugin.rb.free-memory-example
file.
Example 8.13. Sort Nodes by Gear Usage (Round Robin)
def self.select_best_fit_node_impl(server_infos, app_props, current_gears, comp_list, user_props, request_time) return server_infos.sort_by {|x| x.node_consumed_capacity.to_f}.first end
def self.select_best_fit_node_impl(server_infos, app_props, current_gears, comp_list, user_props, request_time)
return server_infos.sort_by {|x| x.node_consumed_capacity.to_f}.first
end
Gem_Location/lib/openshift/gear_placement_plugin.rb.round-robin-example
file. The nodes in each profile fill evenly, unless complications arise, for example due to scaled applications, gears being deleted unevenly, or MCollective fact updates trailing behind. Implementing true round robin requires writing out a state file owned by this algorithm and using that for scheduling the placement rotation.