Class: Pinot::TableAwareBrokerSelector
- Inherits:
-
Object
- Object
- Pinot::TableAwareBrokerSelector
show all
- Includes:
- BrokerSelector
- Defined in:
- lib/pinot/table_aware_broker_selector.rb
Constant Summary
collapse
- OFFLINE_SUFFIX =
"_OFFLINE"
- REALTIME_SUFFIX =
"_REALTIME"
Instance Method Summary
collapse
Constructor Details
Returns a new instance of TableAwareBrokerSelector.
8
9
10
11
12
|
# File 'lib/pinot/table_aware_broker_selector.rb', line 8
def initialize
@mutex = Mutex.new
@all_broker_list = []
@table_broker_map = {}
end
|
Instance Method Details
#init ⇒ Object
14
15
16
|
# File 'lib/pinot/table_aware_broker_selector.rb', line 14
def init
raise NotImplementedError, "subclasses must implement init"
end
|
#select_broker(table) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/pinot/table_aware_broker_selector.rb', line 18
def select_broker(table)
table_name = (table.to_s)
@mutex.synchronize do
if table_name.empty?
raise "no available broker" if @all_broker_list.empty?
return @all_broker_list.sample
end
brokers = @table_broker_map[table_name]
raise "unable to find table: #{table}" unless brokers
raise "no available broker for table: #{table}" if brokers.empty?
brokers.sample
end
end
|
#update_broker_data(all_brokers, table_map) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/pinot/table_aware_broker_selector.rb', line 32
def update_broker_data(all_brokers, table_map)
@mutex.synchronize do
@all_broker_list = all_brokers
@table_broker_map = table_map
end
end
|