Class: Pinot::ControllerBasedBrokerSelector
- Inherits:
-
TableAwareBrokerSelector
- Object
- TableAwareBrokerSelector
- Pinot::ControllerBasedBrokerSelector
- Defined in:
- lib/pinot/controller_based_broker_selector.rb
Constant Summary collapse
- CONTROLLER_API_PATH =
"/v2/brokers/tables?state=ONLINE"- DEFAULT_UPDATE_FREQ_MS =
1000
Constants inherited from TableAwareBrokerSelector
TableAwareBrokerSelector::OFFLINE_SUFFIX, TableAwareBrokerSelector::REALTIME_SUFFIX
Instance Method Summary collapse
- #build_controller_url(address) ⇒ Object
- #init ⇒ Object
-
#initialize(config, http_client = nil) ⇒ ControllerBasedBrokerSelector
constructor
A new instance of ControllerBasedBrokerSelector.
Methods inherited from TableAwareBrokerSelector
#select_broker, #update_broker_data
Constructor Details
#initialize(config, http_client = nil) ⇒ ControllerBasedBrokerSelector
Returns a new instance of ControllerBasedBrokerSelector.
10 11 12 13 14 |
# File 'lib/pinot/controller_based_broker_selector.rb', line 10 def initialize(config, http_client = nil) super() @config = config @internal_http = http_client || HttpClient.new end |
Instance Method Details
#build_controller_url(address) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pinot/controller_based_broker_selector.rb', line 24 def build_controller_url(address) addr = address.to_s if addr.include?("://") scheme = addr.split("://").first unless %w[http https].include?(scheme) raise "unsupported controller URL scheme: #{scheme}" end addr.chomp("/") + CONTROLLER_API_PATH else "http://#{addr.chomp("/")}#{CONTROLLER_API_PATH}" end end |
#init ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pinot/controller_based_broker_selector.rb', line 16 def init @config.update_freq_ms ||= DEFAULT_UPDATE_FREQ_MS @controller_url = build_controller_url(@config.controller_address) fetch_and_update start_background_refresh nil end |