Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fragment-exec-state.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef IMPALA_SERVICE_FRAGMENT_EXEC_STATE_H
16 #define IMPALA_SERVICE_FRAGMENT_EXEC_STATE_H
17 
18 #include <boost/bind.hpp>
19 #include <boost/thread/mutex.hpp>
20 
21 #include "common/status.h"
22 #include "runtime/client-cache.h"
24 #include "service/fragment-mgr.h"
25 
26 namespace impala {
27 
30  public:
31  FragmentExecState(const TPlanFragmentInstanceCtx& fragment_instance_ctx,
32  ExecEnv* exec_env)
33  : fragment_instance_ctx_(fragment_instance_ctx),
34  executor_(exec_env, boost::bind<void>(
36  this, _1, _2, _3)),
37  client_cache_(exec_env->impalad_client_cache()) {
38  }
39 
43 
46  Status Cancel();
47 
49  Status Prepare(const TExecPlanFragmentParams& exec_params);
50 
52  void Exec();
53 
54  const TUniqueId& query_id() const {
55  return fragment_instance_ctx_.query_ctx.query_id;
56  }
57 
58  const TUniqueId& fragment_instance_id() const {
59  return fragment_instance_ctx_.fragment_instance_id;
60  }
61 
62  const TNetworkAddress& coord_address() const {
63  return fragment_instance_ctx_.query_ctx.coord_address;
64  }
65 
67  void set_exec_thread(Thread* exec_thread) { exec_thread_.reset(exec_thread); }
68 
69  private:
70  TPlanFragmentInstanceCtx fragment_instance_ctx_;
73  TExecPlanFragmentParams exec_params_;
74 
76  boost::scoped_ptr<Thread> exec_thread_;
77 
79  boost::mutex status_lock_;
80 
84 
87  void ReportStatusCb(const Status& status, RuntimeProfile* profile, bool done);
88 
91  Status UpdateStatus(const Status& status);
92 };
93 
94 }
95 
96 #endif
const TUniqueId & fragment_instance_id() const
TODO: Consider allowing fragment IDs as category parameters.
Definition: thread.h:45
boost::scoped_ptr< Thread > exec_thread_
the thread executing this plan fragment
void Exec()
Main loop of plan fragment execution. Blocks until execution finishes.
Status Prepare(const TExecPlanFragmentParams &exec_params)
Call Prepare() and create and initialize data sink.
FragmentExecState(const TPlanFragmentInstanceCtx &fragment_instance_ctx, ExecEnv *exec_env)
Status UpdateStatus(const Status &status)
void set_exec_thread(Thread *exec_thread)
Set the execution thread, taking ownership of the object.
boost::mutex status_lock_
protects exec_status_
ImpalaInternalServiceClientCache * client_cache_
const TNetworkAddress & coord_address() const
TPlanFragmentInstanceCtx fragment_instance_ctx_
Execution state of a single plan fragment.
void ReportStatusCb(const Status &status, RuntimeProfile *profile, bool done)