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, logger: nil) ⇒ ControllerBasedBrokerSelector
constructor
A new instance of ControllerBasedBrokerSelector.
Methods inherited from TableAwareBrokerSelector
#select_broker, #update_broker_data
Constructor Details
#initialize(config, http_client = nil, logger: nil) ⇒ ControllerBasedBrokerSelector
Returns a new instance of ControllerBasedBrokerSelector.
10 11 12 13 14 15 |
# File 'lib/pinot/controller_based_broker_selector.rb', line 10 def initialize(config, http_client = nil, logger: nil) super() @config = config @internal_http = http_client || HttpClient.new @logger = logger end |
Instance Method Details
#build_controller_url(address) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pinot/controller_based_broker_selector.rb', line 26 def build_controller_url(address) addr = address.to_s if addr.include?("://") scheme = addr.split("://").first unless %w[http https].include?(scheme) raise ConfigurationError, "unsupported controller URL scheme: #{scheme}" end addr.chomp("/") + CONTROLLER_API_PATH else "http://#{addr.chomp("/")}#{CONTROLLER_API_PATH}" end end |
#init ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/pinot/controller_based_broker_selector.rb', line 17 def init @config.update_freq_ms ||= DEFAULT_UPDATE_FREQ_MS @controller_url = build_controller_url(@config.controller_address) fetch_and_update logger.info "ControllerBasedBrokerSelector initialized with #{@all_broker_list.size} brokers" start_background_refresh nil end |