16 #ifndef IMPALA_RUNTIME_COORDINATOR_H
17 #define IMPALA_RUNTIME_COORDINATOR_H
21 #include <boost/scoped_ptr.hpp>
22 #include <boost/accumulators/accumulators.hpp>
23 #include <boost/accumulators/statistics/stats.hpp>
24 #include <boost/accumulators/statistics/min.hpp>
25 #include <boost/accumulators/statistics/mean.hpp>
26 #include <boost/accumulators/statistics/median.hpp>
27 #include <boost/accumulators/statistics/max.hpp>
28 #include <boost/accumulators/statistics/variance.hpp>
29 #include <boost/unordered_map.hpp>
30 #include <boost/unordered_set.hpp>
31 #include <boost/thread/thread.hpp>
32 #include <boost/thread/mutex.hpp>
33 #include <boost/thread/condition_variable.hpp>
41 #include "gen-cpp/Types_types.h"
42 #include "gen-cpp/Frontend_types.h"
50 class PlanFragmentExecutor;
53 class ImpalaInternalServiceClient;
57 class TUpdateCatalogRequest;
58 class TQueryExecRequest;
59 class TReportExecStatusParams;
61 class TPlanExecRequest;
62 class TRuntimeProfileTree;
181 class BackendExecState;
185 typedef boost::accumulators::accumulator_set<int64_t,
186 boost::accumulators::features<
187 boost::accumulators::tag::min,
188 boost::accumulators::tag::max,
189 boost::accumulators::tag::mean,
190 boost::accumulators::tag::variance>
204 typedef std::map<PlanNodeId, RuntimeProfile::Counter*>
CounterMap;
246 boost::scoped_ptr<PlanFragmentExecutor>
executor_;
352 int backend_num,
const TPlanFragment& fragment,
354 const TNetworkAddress& coord, TExecPlanFragmentParams* rpc_params);
Status UpdateFragmentExecStatus(const TReportExecStatusParams ¶ms)
RuntimeState * runtime_state()
only valid after calling Exec(), and may return NULL if there is no executor
Status ExecRemoteFragment(void *exec_state)
client RuntimeProfile::EventSequence * events
Status GetNext(RowBatch **batch, RuntimeState *state)
SummaryStats completion_times
Completion times for instances of this fragment.
TFinalizeParams finalize_params_
Only valid if needs_finalization is true.
Struct for per fragment instance counters that will be aggregated by the coordinator.
ProgressUpdater progress_
Keeps track of number of completed ranges and total scan ranges.
boost::scoped_ptr< ObjectPool > obj_pool_
Object pool owned by the coordinator. Any executor will have its own pool.
const TUniqueId & query_id() const
TExecSummary exec_summary_
void CreateAggregateCounters(const std::vector< TPlanFragment > &fragments)
Create aggregate counters for all scan nodes in any of the fragments.
void PopulatePathPermissionCache(hdfsFS fs, const std::string &path_str, PermissionCache *permissions_cache)
void SetExecPlanFragmentParams(QuerySchedule &schedule, int backend_num, const TPlanFragment &fragment, int fragment_idx, const FragmentExecParams ¶ms, int instance_idx, const TNetworkAddress &coord, TExecPlanFragmentParams *rpc_params)
Fill in rpc_params based on parameters.
boost::mutex lock_
protects all fields below
CounterMap throughput_counters
Throughput counters per node.
TDescriptorTable desc_tbl_
copied from TQueryExecRequest; constant across all fragments
FileMoveMap files_to_move_
boost::unordered_map< TUniqueId, BackendExecState * > BackendExecStateMap
void UpdateExecSummary(int fragment_idx, int instance_idx, RuntimeProfile *profile)
RuntimeProfile * query_profile() const
void Cancel(const Status *cause=NULL)
std::vector< BackendExecState * > backend_exec_states_
BackendExecStates owned by obj_pool()
int64_t ComputeTotalScanRangesComplete(int node_id)
Status Exec(QuerySchedule &schedule, std::vector< ExprContext * > *output_expr_ctxs)
Per fragment profile information.
void CancelRemoteFragments()
bool PrepareCatalogUpdate(TUpdateCatalogRequest *catalog_update)
ObjectPool * obj_pool()
Returns a local object pool.
SpinLock exec_summary_lock_
Execution summary for this query.
bool returned_all_results_
boost::accumulators::accumulator_set< int64_t, boost::accumulators::features< boost::accumulators::tag::min, boost::accumulators::tag::max, boost::accumulators::tag::mean, boost::accumulators::tag::variance > > SummaryStats
std::map< PlanNodeId, RuntimeProfile::Counter * > CounterMap
map from id of a scan node to a specific counter in the node's profile
Status GetStatus()
Returns query_status_.
std::map< std::string, std::string > FileMoveMap
bool execution_completed_
True if execution has completed, false otherwise.
int64_t ComputeTotalThroughput(int node_id)
std::map< std::string, TInsertPartitionStatus > PartitionStatusMap
int num_remaining_backends_
bool needs_finalization_
True if the query needs a post-execution step to tidy up.
boost::unordered_map< TPlanNodeId, int > plan_node_id_to_summary_map_
A mapping of plan node ids to index into exec_summary_.nodes.
FragmentInstanceCounters coordinator_counters_
Throughput counters for the coordinator fragment.
This class is thread-safe.
RuntimeProfile::Counter * finalization_timer_
Total time spent in finalization (typically 0 except for INSERT into hdfs tables) ...
boost::mutex wait_lock_
ensures single-threaded execution of Wait(); must not hold lock_ when acquiring this ...
const RowDescriptor & row_desc() const
CounterMap scan_ranges_complete_counters
Total finished scan ranges per node.
boost::unordered_map< std::string, std::pair< bool, short > > PermissionCache
PartitionStatusMap per_partition_status_
void InitExecProfile(const TQueryExecRequest &request)
int num_instances
Number of instances running this fragment.
RuntimeProfile * root_profile
Root profile for all fragment instances for this fragment.
boost::shared_ptr< MemTracker > query_mem_tracker_
Status WaitForAllBackends()
boost::condition_variable backend_completion_cv_
std::vector< PerFragmentProfileData > fragment_profiles_
const ProgressUpdater & progress()
void UpdateAverageProfile(BackendExecState *backend_exec_state)
const TExecSummary & exec_summary() const
const RowDescriptor * row_desc_
owned by plan root, which resides in runtime_state_'s pool
BackendExecStateMap backend_exec_state_map_
void ComputeFragmentSummaryStats(BackendExecState *backend_exec_state)
RuntimeProfile * averaged_profile
int GetFragmentNum(const TUniqueId &fragment_id)
Determine fragment number, given fragment id.
SummaryStats bytes_assigned
Bytes assigned for instances of this fragment.
RuntimeProfile::EventSequence * query_events_
Event timeline for this query. Unowned.
std::string GetErrorLog()
Status UpdateStatus(const Status &status, const TUniqueId *failed_fragment)
SummaryStats rates
Execution rates for instances of this fragment.
ImpaladQueryExecutor * executor_
execution state of coordinator fragment
SpinLock & GetExecSummaryLock() const
const PartitionStatusMap & per_partition_status()
This is safe to call only after Wait()
void CancelInternal()
Runs cancel logic. Assumes that lock_ is held.
void ReportQuerySummary()
MemTracker * query_mem_tracker()
Status FinalizeSuccessfulInsert()
Moves all temporary staging files to their final destinations.
void CollectScanNodeCounters(RuntimeProfile *, FragmentInstanceCounters *result)
boost::scoped_ptr< RuntimeProfile > query_profile_
Aggregate counters for the entire query.
TStmtType::type stmt_type_
copied from TQueryExecRequest, governs when to call ReportQuerySummary
boost::unordered_set< TNetworkAddress > unique_hosts_
The set of hosts that the query will run on. Populated in Exec.
int num_remote_fragements_complete_
Number of remote fragments that have completed.