Class: DartMasterQuery
- Includes:
- DartCommon
- Defined in:
- lib/cosmos/dart/lib/dart_master_query.rb
Overview
JsonDRb server which responds to queries for decommutated and reduced data from the database.
Constant Summary
Constants included from DartCommon
DartCommon::INITIALIZING, DartCommon::MAX_COLUMNS_PER_TABLE, DartCommon::MAX_STRING_BIT_SIZE, DartCommon::MAX_STRING_BYTE_SIZE, DartCommon::PARSING_REGEX, DartCommon::READY_TO_REDUCE, DartCommon::REDUCED, DartCommon::REDUCED_TYPES
Constants included from DartConstants
DartConstants::MAX_DECOM_RESULTS
Instance Method Summary collapse
-
#get_decom_ple_ids ⇒ Object
Returns the id of a ple that needs to be decommed next.
-
#initialize(ples_per_request = 5) ⇒ DartMasterQuery
constructor
A new instance of DartMasterQuery.
Methods included from DartCommon
#comparison_cast, #decommutate_item?, #each_decom_and_reduced_table, #find_packet_log_entry, #get_decom_table_model, #get_table_model, handle_argv, #lookup_target_and_packet_id, #process_meta_filters, #query_decom_reduced, #read_packet_from_ple, #separate_raw_con?, #setup_packet_config, #switch_and_get_system_config, #sync_targets_and_packets
Constructor Details
#initialize(ples_per_request = 5) ⇒ DartMasterQuery
Returns a new instance of DartMasterQuery.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cosmos/dart/lib/dart_master_query.rb', line 30 def initialize(ples_per_request = 5) # Keep a thread to make sure we have the current list of items to decom @ples_per_request = ples_per_request @mutex = Mutex.new @decom_list = [] @thread = Thread.new do loop do # Get all entries that are ready and decommutation hasn't started if @decom_list.length <= 0 @mutex.synchronize do begin @decom_list.replace(PacketLogEntry.where("decom_state = #{PacketLogEntry::NOT_STARTED} and ready = true").order("id ASC").limit(1000).pluck(:id)) rescue Exception => error Cosmos::Logger.error("Error getting packets to decom\n#{error.formatted}") end end else sleep(1) end end end end |
Instance Method Details
#get_decom_ple_ids ⇒ Object
Returns the id of a ple that needs to be decommed next
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cosmos/dart/lib/dart_master_query.rb', line 55 def get_decom_ple_ids() begin @mutex.synchronize do result = [] @ples_per_request.times do ple_id = @decom_list.shift result << ple_id if ple_id end return result end rescue Exception => error msg = "Master Error: #{error.message}" raise $!, msg, $!.backtrace end end |