-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add information_schema.backend_kerberos_ticket_cache
- Loading branch information
1 parent
fbecf5f
commit 678ba24
Showing
13 changed files
with
235 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,8 +53,13 @@ class KerberosConfig { | |
// Get the minimum time before refresh in seconds | ||
int32_t get_min_time_before_refresh_second() const { return _min_time_before_refresh_second; } | ||
|
||
std::string get_hash_code() const { return _get_hash_code(_principal, _keytab_path); } | ||
|
||
// Use principal and keytab to generate a hash code. | ||
std::string get_hash_code() const; | ||
static std::string get_hash_code(const std::string& principal, const std::string& keytab); | ||
|
||
private: | ||
static std::string _get_hash_code(const std::string& principal, const std::string& keytab); | ||
|
||
private: | ||
// Kerberos principal name (e.g., "[email protected]") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
be/src/exec/schema_scanner/schema_backend_kerberos_ticket_cache.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
#include "exec/schema_scanner/schema_backend_kerberos_ticket_cache.h" | ||
|
||
#include "common/kerberos/kerberos_ticket_mgr.h" | ||
#include "runtime/exec_env.h" | ||
#include "runtime/runtime_state.h" | ||
#include "vec/common/string_ref.h" | ||
#include "vec/core/block.h" | ||
#include "vec/data_types/data_type_factory.hpp" | ||
|
||
namespace doris { | ||
#include "common/compile_check_begin.h" | ||
|
||
std::vector<SchemaScanner::ColumnDesc> SchemaBackendKerberosTicketCacheScanner::_s_tbls_columns = { | ||
// name, type, size | ||
{"BE_ID", TYPE_BIGINT, sizeof(int64_t), true}, | ||
{"BE_IP", TYPE_STRING, sizeof(StringRef), true}, | ||
{"PRINCIPAL", TYPE_STRING, sizeof(StringRef), true}, | ||
{"KEYTAB", TYPE_STRING, sizeof(StringRef), true}, | ||
{"SERVICE_PRINCIPAL", TYPE_STRING, sizeof(StringRef), true}, | ||
{"TICKET_CACHE_PATH", TYPE_STRING, sizeof(StringRef), true}, | ||
{"HASH_CODE", TYPE_STRING, sizeof(StringRef), true}, | ||
{"START_TIME", TYPE_DATETIME, sizeof(int128_t), true}, | ||
{"EXPIRE_TIME", TYPE_DATETIME, sizeof(int128_t), true}, | ||
{"AUTH_TIME", TYPE_DATETIME, sizeof(int128_t), true}, | ||
{"REF_COUNT", TYPE_BIGINT, sizeof(int64_t), true}, | ||
{"REFRESH_INTERVAL_SECOND", TYPE_BIGINT, sizeof(int64_t), true}}; | ||
|
||
SchemaBackendKerberosTicketCacheScanner::SchemaBackendKerberosTicketCacheScanner() | ||
: SchemaScanner(_s_tbls_columns, TSchemaTableType::SCH_BACKEND_KERBEROS_TICKET_CACHE) {} | ||
|
||
SchemaBackendKerberosTicketCacheScanner::~SchemaBackendKerberosTicketCacheScanner() {} | ||
|
||
Status SchemaBackendKerberosTicketCacheScanner::start(RuntimeState* state) { | ||
_block_rows_limit = state->batch_size(); | ||
_timezone_obj = state->timezone_obj(); | ||
return Status::OK(); | ||
} | ||
|
||
Status SchemaBackendKerberosTicketCacheScanner::get_next_block_internal(vectorized::Block* block, | ||
bool* eos) { | ||
if (!_is_init) { | ||
return Status::InternalError("Used before initialized."); | ||
} | ||
|
||
if (nullptr == block || nullptr == eos) { | ||
return Status::InternalError("input pointer is nullptr."); | ||
} | ||
|
||
if (_info_block == nullptr) { | ||
_info_block = vectorized::Block::create_unique(); | ||
|
||
for (int i = 0; i < _s_tbls_columns.size(); ++i) { | ||
TypeDescriptor descriptor(_s_tbls_columns[i].type); | ||
auto data_type = | ||
vectorized::DataTypeFactory::instance().create_data_type(descriptor, true); | ||
_info_block->insert(vectorized::ColumnWithTypeAndName( | ||
data_type->create_column(), data_type, _s_tbls_columns[i].name)); | ||
} | ||
|
||
_info_block->reserve(_block_rows_limit); | ||
|
||
ExecEnv::GetInstance()->kerberos_ticket_mgr()->get_ticket_cache_info_block( | ||
_info_block.get(), _timezone_obj); | ||
_total_rows = (int)_info_block->rows(); | ||
} | ||
|
||
if (_row_idx == _total_rows) { | ||
*eos = true; | ||
return Status::OK(); | ||
} | ||
|
||
int current_batch_rows = std::min(_block_rows_limit, _total_rows - _row_idx); | ||
vectorized::MutableBlock mblock = vectorized::MutableBlock::build_mutable_block(block); | ||
RETURN_IF_ERROR(mblock.add_rows(_info_block.get(), _row_idx, current_batch_rows)); | ||
_row_idx += current_batch_rows; | ||
|
||
*eos = _row_idx == _total_rows; | ||
return Status::OK(); | ||
} | ||
|
||
} // namespace doris |
51 changes: 51 additions & 0 deletions
51
be/src/exec/schema_scanner/schema_backend_kerberos_ticket_cache.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
|
||
#include "cctz/time_zone.h" | ||
#include "common/status.h" | ||
#include "exec/schema_scanner.h" | ||
|
||
namespace doris { | ||
class RuntimeState; | ||
namespace vectorized { | ||
class Block; | ||
} // namespace vectorized | ||
|
||
class SchemaBackendKerberosTicketCacheScanner : public SchemaScanner { | ||
ENABLE_FACTORY_CREATOR(SchemaBackendKerberosTicketCacheScanner); | ||
|
||
public: | ||
SchemaBackendKerberosTicketCacheScanner(); | ||
~SchemaBackendKerberosTicketCacheScanner() override; | ||
|
||
Status start(RuntimeState* state) override; | ||
Status get_next_block_internal(vectorized::Block* block, bool* eos) override; | ||
|
||
static std::vector<SchemaScanner::ColumnDesc> _s_tbls_columns; | ||
|
||
private: | ||
int _block_rows_limit = 4096; | ||
int _row_idx = 0; | ||
int _total_rows = 0; | ||
std::unique_ptr<vectorized::Block> _info_block = nullptr; | ||
cctz::time_zone _timezone_obj; | ||
}; | ||
}; // namespace doris |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.