Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
frontend.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_FRONTEND_H
16 #define IMPALA_SERVICE_FRONTEND_H
17 
18 #include <jni.h>
19 
20 #include "gen-cpp/ImpalaService.h"
21 #include "gen-cpp/ImpalaHiveServer2Service.h"
22 #include "gen-cpp/ImpalaInternalService.h"
23 #include "gen-cpp/Frontend_types.h"
24 #include "common/status.h"
25 
26 namespace impala {
27 
32 class Frontend {
33  public:
36  Frontend();
37 
41  Status UpdateCatalogCache(const TUpdateCatalogCacheRequest& req,
42  TUpdateCatalogCacheResponse *resp);
43 
45  Status GetExplainPlan(const TQueryCtx& query_ctx, std::string* explain_string);
46 
48  Status GetExecRequest(const TQueryCtx& query_ctx, TExecRequest* result);
49 
60  Status GetTableNames(const std::string& db, const std::string* pattern,
61  const TSessionState* session, TGetTablesResult* table_names);
62 
72  Status GetDbNames(const std::string* pattern, const TSessionState* session,
73  TGetDbsResult* table_names);
74 
79  Status GetDataSrcMetadata(const std::string* pattern, TGetDataSrcsResult* result);
80 
82  Status GetStats(const TShowStatsParams& params, TResultSet* result);
83 
85  Status GetRolePrivileges(const TShowGrantRoleParams& params, TResultSet* result);
86 
95  Status GetFunctions(TFunctionCategory::type fn_category, const std::string& db,
96  const std::string* pattern, const TSessionState* session,
97  TGetFunctionsResult* functions);
98 
103  Status GetCatalogObject(const TCatalogObject& request, TCatalogObject* response);
104 
106  Status ShowRoles(const TShowRolesParams& params, TShowRolesResult* result);
107 
115  Status DescribeTable(const TDescribeTableParams& params,
116  TDescribeTableResult* response);
117 
120  Status ShowCreateTable(const TTableName& table_name, std::string* response);
121 
124 
126  Status ExecHiveServer2MetadataOp(const TMetadataOpRequest& request,
127  TResultSet* result);
128 
130  Status GetAllHadoopConfigs(TGetAllHadoopConfigsResponse* result);
131 
135  Status GetHadoopConfig(const TGetHadoopConfigRequest& request,
136  TGetHadoopConfigResponse* response);
137 
141  Status LoadData(const TLoadDataReq& load_data_request, TLoadDataResp* response);
142 
144  static bool IsAuthorizationError(const Status& status);
145 
151 
153  Status GetTableFiles(const TShowFilesParams& params, TResultSet* result);
154 
155  private:
157  jclass fe_class_;
158 
159  jobject fe_; // instance of com.cloudera.impala.service.JniFrontend
160  jmethodID create_exec_request_id_; // JniFrontend.createExecRequest()
161  jmethodID get_explain_plan_id_; // JniFrontend.getExplainPlan()
162  jmethodID get_hadoop_config_id_; // JniFrontend.getHadoopConfig(byte[])
163  jmethodID get_hadoop_configs_id_; // JniFrontend.getAllHadoopConfigs()
164  jmethodID check_config_id_; // JniFrontend.checkConfiguration()
165  jmethodID update_catalog_cache_id_; // JniFrontend.updateCatalogCache()
166  jmethodID get_table_names_id_; // JniFrontend.getTableNames
167  jmethodID describe_table_id_; // JniFrontend.describeTable
168  jmethodID show_create_table_id_; // JniFrontend.showCreateTable
169  jmethodID get_db_names_id_; // JniFrontend.getDbNames
170  jmethodID get_data_src_metadata_id_; // JniFrontend.getDataSrcMetadata
171  jmethodID get_stats_id_; // JniFrontend.getTableStats
172  jmethodID get_functions_id_; // JniFrontend.getFunctions
173  jmethodID get_catalog_object_id_; // JniFrontend.getCatalogObject
174  jmethodID show_roles_id_; // JniFrontend.getRoles
175  jmethodID get_role_privileges_id_; // JniFrontend.getRolePrivileges
176  jmethodID exec_hs2_metadata_op_id_; // JniFrontend.execHiveServer2MetadataOp
177  jmethodID load_table_data_id_; // JniFrontend.loadTableData
178  jmethodID set_catalog_initialized_id_; // JniFrontend.setCatalogInitialized
179  jmethodID get_table_files_id_; // JniFrontend.getTableFiles
180  jmethodID fe_ctor_;
181 };
182 
183 }
184 
185 #endif
jmethodID get_catalog_object_id_
Definition: frontend.h:173
jmethodID fe_ctor_
Definition: frontend.h:180
Status ShowRoles(const TShowRolesParams &params, TShowRolesResult *result)
Call FE to get the roles.
Definition: frontend.cc:164
Status GetStats(const TShowStatsParams &params, TResultSet *result)
Call FE to get the table/column stats.
Definition: frontend.cc:143
jmethodID get_table_files_id_
Definition: frontend.h:179
jmethodID load_table_data_id_
Definition: frontend.h:177
jmethodID show_create_table_id_
Definition: frontend.h:168
jmethodID get_explain_plan_id_
Definition: frontend.h:161
Status GetFunctions(TFunctionCategory::type fn_category, const std::string &db, const std::string *pattern, const TSessionState *session, TGetFunctionsResult *functions)
Definition: frontend.cc:153
Status ShowCreateTable(const TTableName &table_name, std::string *response)
Definition: frontend.cc:115
Status GetDataSrcMetadata(const std::string *pattern, TGetDataSrcsResult *result)
Definition: frontend.cc:136
jmethodID get_role_privileges_id_
Definition: frontend.h:175
jmethodID update_catalog_cache_id_
Definition: frontend.h:165
jmethodID get_functions_id_
Definition: frontend.h:172
Status DescribeTable(const TDescribeTableParams &params, TDescribeTableResult *response)
Definition: frontend.cc:110
jmethodID exec_hs2_metadata_op_id_
Definition: frontend.h:176
Status GetCatalogObject(const TCatalogObject &request, TCatalogObject *response)
Definition: frontend.cc:168
Status GetExplainPlan(const TQueryCtx &query_ctx, std::string *explain_string)
Call FE to get explain plan.
Definition: frontend.cc:178
Status LoadData(const TLoadDataReq &load_data_request, TLoadDataResp *response)
Definition: frontend.cc:220
jmethodID get_table_names_id_
Definition: frontend.h:166
jmethodID check_config_id_
Definition: frontend.h:164
static bool IsAuthorizationError(const Status &status)
Returns true if the error returned by the FE was due to an AuthorizationException.
Definition: frontend.cc:224
jmethodID describe_table_id_
Definition: frontend.h:167
Status GetRolePrivileges(const TShowGrantRoleParams &params, TResultSet *result)
Call FE to get the privileges granted to a role.
Definition: frontend.cc:148
jmethodID create_exec_request_id_
Definition: frontend.h:160
jmethodID get_stats_id_
Definition: frontend.h:171
Status GetHadoopConfig(const TGetHadoopConfigRequest &request, TGetHadoopConfigResponse *response)
Definition: frontend.cc:215
jmethodID get_db_names_id_
Definition: frontend.h:169
jmethodID set_catalog_initialized_id_
Definition: frontend.h:178
Status GetTableFiles(const TShowFilesParams &params, TResultSet *result)
Call FE to get files info for a table or partition.
Definition: frontend.cc:237
Status GetDbNames(const std::string *pattern, const TSessionState *session, TGetDbsResult *table_names)
Definition: frontend.cc:128
jmethodID get_hadoop_configs_id_
Definition: frontend.h:163
Status SetCatalogInitialized()
Definition: frontend.cc:228
jmethodID get_hadoop_config_id_
Definition: frontend.h:162
Status ExecHiveServer2MetadataOp(const TMetadataOpRequest &request, TResultSet *result)
Calls FE to execute HiveServer2 metadata operation.
Definition: frontend.cc:206
Status GetTableNames(const std::string &db, const std::string *pattern, const TSessionState *session, TGetTablesResult *table_names)
Definition: frontend.cc:119
Status ValidateSettings()
Validate Hadoop config; requires FE.
Definition: frontend.cc:183
Status UpdateCatalogCache(const TUpdateCatalogCacheRequest &req, TUpdateCatalogCacheResponse *resp)
Definition: frontend.cc:105
jmethodID get_data_src_metadata_id_
Definition: frontend.h:170
Status GetExecRequest(const TQueryCtx &query_ctx, TExecRequest *result)
Call FE to get TExecRequest.
Definition: frontend.cc:173
Status GetAllHadoopConfigs(TGetAllHadoopConfigsResponse *result)
Returns all Hadoop configurations in key, value form in result.
Definition: frontend.cc:211
jclass fe_class_
Descriptor of Java Frontend class itself, used to create a new instance.
Definition: frontend.h:157
jmethodID show_roles_id_
Definition: frontend.h:174