Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala-internal-service.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_IMPALA_INTERNAL_SERVICE_H
16 #define IMPALA_SERVICE_IMPALA_INTERNAL_SERVICE_H
17 
18 #include <boost/shared_ptr.hpp>
19 
20 #include "gen-cpp/ImpalaInternalService.h"
21 #include "gen-cpp/ImpalaInternalService_types.h"
22 #include "service/impala-server.h"
23 #include "service/fragment-mgr.h"
24 
25 namespace impala {
26 
29 class ImpalaInternalService : public ImpalaInternalServiceIf {
30  public:
31  ImpalaInternalService(const boost::shared_ptr<ImpalaServer>& impala_server,
32  const boost::shared_ptr<FragmentMgr>& fragment_mgr)
33  : impala_server_(impala_server), fragment_mgr_(fragment_mgr) { }
34 
35  virtual void ExecPlanFragment(TExecPlanFragmentResult& return_val,
36  const TExecPlanFragmentParams& params) {
37  fragment_mgr_->ExecPlanFragment(params).SetTStatus(&return_val);
38  }
39 
40  virtual void CancelPlanFragment(TCancelPlanFragmentResult& return_val,
41  const TCancelPlanFragmentParams& params) {
42  fragment_mgr_->CancelPlanFragment(return_val, params);
43  }
44 
45  virtual void ReportExecStatus(TReportExecStatusResult& return_val,
46  const TReportExecStatusParams& params) {
47  impala_server_->ReportExecStatus(return_val, params);
48  }
49 
50  virtual void TransmitData(TTransmitDataResult& return_val,
51  const TTransmitDataParams& params) {
52  // Prevent the fragment (which has the receiver for transmit data) from being
53  // destroyed unti TransmitData() completes. Otherwise if query cancellation happens
54  // while TransmitData() is running, TransmitData() could end up with the last
55  // shared_ptr to a DataStreamRecvr. When the DataStreamRecvr is destroyed it expects
56  // the fragment which owns it to still be around. Even if no fragment is found call
57  // TransmitData() to set the return_val.
58  boost::shared_ptr<FragmentMgr::FragmentExecState> fragment_exec_state
59  = fragment_mgr_->GetFragmentExecState(params.dest_fragment_instance_id);
60  impala_server_->TransmitData(return_val, params);
61  }
62 
63  private:
65  boost::shared_ptr<ImpalaServer> impala_server_;
66 
68  boost::shared_ptr<FragmentMgr> fragment_mgr_;
69 };
70 
71 }
72 
73 #endif
virtual void ReportExecStatus(TReportExecStatusResult &return_val, const TReportExecStatusParams &params)
boost::shared_ptr< FragmentMgr > fragment_mgr_
Manages fragment execution.
virtual void CancelPlanFragment(TCancelPlanFragmentResult &return_val, const TCancelPlanFragmentParams &params)
ImpalaInternalService(const boost::shared_ptr< ImpalaServer > &impala_server, const boost::shared_ptr< FragmentMgr > &fragment_mgr)
virtual void ExecPlanFragment(TExecPlanFragmentResult &return_val, const TExecPlanFragmentParams &params)
virtual void TransmitData(TTransmitDataResult &return_val, const TTransmitDataParams &params)
boost::shared_ptr< ImpalaServer > impala_server_
Manages fragment reporting and data transmission.