未验证 提交 b3e8856a 编写于 作者: C Cai Yudong 提交者: GitHub

move all APIs in utils into namespace milvus (#2614)

* move APIs in util into namespace milvus
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* fix clang-format
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* update changelog
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* combine BlockingQueue.h and src/utils/BlockingQueue.inl
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* retry ci
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>
上级 43672ea8
...@@ -20,6 +20,7 @@ Please mark all changes in change log and use the issue from GitHub ...@@ -20,6 +20,7 @@ Please mark all changes in change log and use the issue from GitHub
- \#2543 Remove secondary_path related code - \#2543 Remove secondary_path related code
- \#2544 Optimize unittest build - \#2544 Optimize unittest build
- \#2561 Clean util dependencies with other modules - \#2561 Clean util dependencies with other modules
- \#2612 Move all APIs in utils into namespace milvus
## Task ## Task
......
...@@ -648,7 +648,7 @@ Status ...@@ -648,7 +648,7 @@ Status
Config::ProcessConfigCli(std::string& result, const std::string& cmd) { Config::ProcessConfigCli(std::string& result, const std::string& cmd) {
std::vector<std::string> tokens; std::vector<std::string> tokens;
std::vector<std::string> nodes; std::vector<std::string> nodes;
server::StringHelpFunctions::SplitStringByDelimeter(cmd, " ", tokens); StringHelpFunctions::SplitStringByDelimeter(cmd, " ", tokens);
if (tokens[0] == "get_config") { if (tokens[0] == "get_config") {
if (tokens.size() != 2) { if (tokens.size() != 2) {
return Status(SERVER_UNEXPECTED_ERROR, "Invalid command: " + cmd); return Status(SERVER_UNEXPECTED_ERROR, "Invalid command: " + cmd);
...@@ -657,7 +657,7 @@ Config::ProcessConfigCli(std::string& result, const std::string& cmd) { ...@@ -657,7 +657,7 @@ Config::ProcessConfigCli(std::string& result, const std::string& cmd) {
GetConfigJsonStr(result); GetConfigJsonStr(result);
return Status::OK(); return Status::OK();
} else { } else {
server::StringHelpFunctions::SplitStringByDelimeter(tokens[1], CONFIG_NODE_DELIMITER, nodes); StringHelpFunctions::SplitStringByDelimeter(tokens[1], CONFIG_NODE_DELIMITER, nodes);
if (nodes.size() < 2) { if (nodes.size() < 2) {
return Status(SERVER_UNEXPECTED_ERROR, "Invalid command: " + cmd); return Status(SERVER_UNEXPECTED_ERROR, "Invalid command: " + cmd);
} else if (nodes.size() > 2) { } else if (nodes.size() > 2) {
...@@ -676,7 +676,7 @@ Config::ProcessConfigCli(std::string& result, const std::string& cmd) { ...@@ -676,7 +676,7 @@ Config::ProcessConfigCli(std::string& result, const std::string& cmd) {
if (tokens.size() != 3) { if (tokens.size() != 3) {
return Status(SERVER_UNEXPECTED_ERROR, "Invalid command: " + cmd); return Status(SERVER_UNEXPECTED_ERROR, "Invalid command: " + cmd);
} }
server::StringHelpFunctions::SplitStringByDelimeter(tokens[1], CONFIG_NODE_DELIMITER, nodes); StringHelpFunctions::SplitStringByDelimeter(tokens[1], CONFIG_NODE_DELIMITER, nodes);
if (nodes.size() < 2) { if (nodes.size() < 2) {
return Status(SERVER_UNEXPECTED_ERROR, "Invalid command: " + cmd); return Status(SERVER_UNEXPECTED_ERROR, "Invalid command: " + cmd);
} else if (nodes.size() > 2) { } else if (nodes.size() > 2) {
...@@ -1694,7 +1694,7 @@ Config::GetConfigSequenceStr(const std::string& parent_key, const std::string& c ...@@ -1694,7 +1694,7 @@ Config::GetConfigSequenceStr(const std::string& parent_key, const std::string& c
if (sequence.empty()) { if (sequence.empty()) {
value = default_value; value = default_value;
} else { } else {
server::StringHelpFunctions::MergeStringWithDelimeter(sequence, delim, value); StringHelpFunctions::MergeStringWithDelimeter(sequence, delim, value);
} }
SetConfigValueInMem(parent_key, child_key, value); SetConfigValueInMem(parent_key, child_key, value);
} }
...@@ -2026,7 +2026,7 @@ Config::GetGpuResourceConfigSearchResources(std::vector<int64_t>& value) { ...@@ -2026,7 +2026,7 @@ Config::GetGpuResourceConfigSearchResources(std::vector<int64_t>& value) {
std::string str = GetConfigSequenceStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES, std::string str = GetConfigSequenceStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES,
CONFIG_GPU_RESOURCE_DELIMITER, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES_DEFAULT); CONFIG_GPU_RESOURCE_DELIMITER, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES_DEFAULT);
std::vector<std::string> res_vec; std::vector<std::string> res_vec;
server::StringHelpFunctions::SplitStringByDelimeter(str, CONFIG_GPU_RESOURCE_DELIMITER, res_vec); StringHelpFunctions::SplitStringByDelimeter(str, CONFIG_GPU_RESOURCE_DELIMITER, res_vec);
STATUS_CHECK(CheckGpuResourceConfigSearchResources(res_vec)); STATUS_CHECK(CheckGpuResourceConfigSearchResources(res_vec));
value.clear(); value.clear();
for (std::string& res : res_vec) { for (std::string& res : res_vec) {
...@@ -2048,7 +2048,7 @@ Config::GetGpuResourceConfigBuildIndexResources(std::vector<int64_t>& value) { ...@@ -2048,7 +2048,7 @@ Config::GetGpuResourceConfigBuildIndexResources(std::vector<int64_t>& value) {
GetConfigSequenceStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, GetConfigSequenceStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES,
CONFIG_GPU_RESOURCE_DELIMITER, CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES_DEFAULT); CONFIG_GPU_RESOURCE_DELIMITER, CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES_DEFAULT);
std::vector<std::string> res_vec; std::vector<std::string> res_vec;
server::StringHelpFunctions::SplitStringByDelimeter(str, CONFIG_GPU_RESOURCE_DELIMITER, res_vec); StringHelpFunctions::SplitStringByDelimeter(str, CONFIG_GPU_RESOURCE_DELIMITER, res_vec);
STATUS_CHECK(CheckGpuResourceConfigBuildIndexResources(res_vec)); STATUS_CHECK(CheckGpuResourceConfigBuildIndexResources(res_vec));
value.clear(); value.clear();
for (std::string& res : res_vec) { for (std::string& res : res_vec) {
...@@ -2387,7 +2387,7 @@ Config::SetGpuResourceConfigGpuSearchThreshold(const std::string& value) { ...@@ -2387,7 +2387,7 @@ Config::SetGpuResourceConfigGpuSearchThreshold(const std::string& value) {
Status Status
Config::SetGpuResourceConfigSearchResources(const std::string& value) { Config::SetGpuResourceConfigSearchResources(const std::string& value) {
std::vector<std::string> res_vec; std::vector<std::string> res_vec;
server::StringHelpFunctions::SplitStringByDelimeter(value, CONFIG_GPU_RESOURCE_DELIMITER, res_vec); StringHelpFunctions::SplitStringByDelimeter(value, CONFIG_GPU_RESOURCE_DELIMITER, res_vec);
STATUS_CHECK(CheckGpuResourceConfigSearchResources(res_vec)); STATUS_CHECK(CheckGpuResourceConfigSearchResources(res_vec));
STATUS_CHECK(SetConfigValueInMem(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES, value)); STATUS_CHECK(SetConfigValueInMem(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES, value));
return ExecCallBacks(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES, value); return ExecCallBacks(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES, value);
...@@ -2396,7 +2396,7 @@ Config::SetGpuResourceConfigSearchResources(const std::string& value) { ...@@ -2396,7 +2396,7 @@ Config::SetGpuResourceConfigSearchResources(const std::string& value) {
Status Status
Config::SetGpuResourceConfigBuildIndexResources(const std::string& value) { Config::SetGpuResourceConfigBuildIndexResources(const std::string& value) {
std::vector<std::string> res_vec; std::vector<std::string> res_vec;
server::StringHelpFunctions::SplitStringByDelimeter(value, CONFIG_GPU_RESOURCE_DELIMITER, res_vec); StringHelpFunctions::SplitStringByDelimeter(value, CONFIG_GPU_RESOURCE_DELIMITER, res_vec);
STATUS_CHECK(CheckGpuResourceConfigBuildIndexResources(res_vec)); STATUS_CHECK(CheckGpuResourceConfigBuildIndexResources(res_vec));
STATUS_CHECK(SetConfigValueInMem(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, value)); STATUS_CHECK(SetConfigValueInMem(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, value));
return ExecCallBacks(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, value); return ExecCallBacks(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES, value);
......
...@@ -630,7 +630,7 @@ DBImpl::HasPartition(const std::string& collection_id, const std::string& tag, b ...@@ -630,7 +630,7 @@ DBImpl::HasPartition(const std::string& collection_id, const std::string& tag, b
// trim side-blank of tag, only compare valid characters // trim side-blank of tag, only compare valid characters
// for example: " ab cd " is treated as "ab cd" // for example: " ab cd " is treated as "ab cd"
std::string valid_tag = tag; std::string valid_tag = tag;
server::StringHelpFunctions::TrimStringBlank(valid_tag); StringHelpFunctions::TrimStringBlank(valid_tag);
if (valid_tag == milvus::engine::DEFAULT_PARTITON_TAG) { if (valid_tag == milvus::engine::DEFAULT_PARTITON_TAG) {
has_or_not = true; has_or_not = true;
...@@ -2808,7 +2808,7 @@ DBImpl::GetPartitionByTag(const std::string& collection_id, const std::string& p ...@@ -2808,7 +2808,7 @@ DBImpl::GetPartitionByTag(const std::string& collection_id, const std::string& p
// trim side-blank of tag, only compare valid characters // trim side-blank of tag, only compare valid characters
// for example: " ab cd " is treated as "ab cd" // for example: " ab cd " is treated as "ab cd"
std::string valid_tag = partition_tag; std::string valid_tag = partition_tag;
server::StringHelpFunctions::TrimStringBlank(valid_tag); StringHelpFunctions::TrimStringBlank(valid_tag);
if (valid_tag == milvus::engine::DEFAULT_PARTITON_TAG) { if (valid_tag == milvus::engine::DEFAULT_PARTITON_TAG) {
partition_name = collection_id; partition_name = collection_id;
...@@ -2834,7 +2834,7 @@ DBImpl::GetPartitionsByTags(const std::string& collection_id, const std::vector< ...@@ -2834,7 +2834,7 @@ DBImpl::GetPartitionsByTags(const std::string& collection_id, const std::vector<
// trim side-blank of tag, only compare valid characters // trim side-blank of tag, only compare valid characters
// for example: " ab cd " is treated as "ab cd" // for example: " ab cd " is treated as "ab cd"
std::string valid_tag = tag; std::string valid_tag = tag;
server::StringHelpFunctions::TrimStringBlank(valid_tag); StringHelpFunctions::TrimStringBlank(valid_tag);
if (valid_tag == milvus::engine::DEFAULT_PARTITON_TAG) { if (valid_tag == milvus::engine::DEFAULT_PARTITON_TAG) {
partition_name_array.insert(collection_id); partition_name_array.insert(collection_id);
...@@ -2842,7 +2842,7 @@ DBImpl::GetPartitionsByTags(const std::string& collection_id, const std::vector< ...@@ -2842,7 +2842,7 @@ DBImpl::GetPartitionsByTags(const std::string& collection_id, const std::vector<
} }
for (auto& schema : partition_array) { for (auto& schema : partition_array) {
if (server::StringHelpFunctions::IsRegexMatch(schema.partition_tag_, valid_tag)) { if (StringHelpFunctions::IsRegexMatch(schema.partition_tag_, valid_tag)) {
partition_name_array.insert(schema.collection_id_); partition_name_array.insert(schema.collection_id_);
} }
} }
......
...@@ -60,7 +60,7 @@ Status ...@@ -60,7 +60,7 @@ Status
CreateCollectionPath(const DBMetaOptions& options, const std::string& collection_id) { CreateCollectionPath(const DBMetaOptions& options, const std::string& collection_id) {
std::string db_path = options.path_; std::string db_path = options.path_;
std::string table_path = db_path + TABLES_FOLDER + collection_id; std::string table_path = db_path + TABLES_FOLDER + collection_id;
auto status = server::CommonUtil::CreateDirectory(table_path); auto status = CommonUtil::CreateDirectory(table_path);
if (!status.ok()) { if (!status.ok()) {
LOG_ENGINE_ERROR_ << status.message(); LOG_ENGINE_ERROR_ << status.message();
return status; return status;
...@@ -100,7 +100,7 @@ Status ...@@ -100,7 +100,7 @@ Status
CreateCollectionFilePath(const DBMetaOptions& options, meta::SegmentSchema& table_file) { CreateCollectionFilePath(const DBMetaOptions& options, meta::SegmentSchema& table_file) {
std::string parent_path = ConstructParentFolder(options.path_, table_file); std::string parent_path = ConstructParentFolder(options.path_, table_file);
auto status = server::CommonUtil::CreateDirectory(parent_path); auto status = CommonUtil::CreateDirectory(parent_path);
fiu_do_on("CreateCollectionFilePath.fail_create", status = Status(DB_INVALID_PATH, "")); fiu_do_on("CreateCollectionFilePath.fail_create", status = Status(DB_INVALID_PATH, ""));
if (!status.ok()) { if (!status.ok()) {
LOG_ENGINE_ERROR_ << status.message(); LOG_ENGINE_ERROR_ << status.message();
......
...@@ -371,7 +371,7 @@ ExecutionEngineImpl::Serialize() { ...@@ -371,7 +371,7 @@ ExecutionEngineImpl::Serialize() {
// here we reset index size by file size, // here we reset index size by file size,
// since some index type(such as SQ8) data size become smaller after serialized // since some index type(such as SQ8) data size become smaller after serialized
index_->SetIndexSize(server::CommonUtil::GetFileSize(location_)); index_->SetIndexSize(CommonUtil::GetFileSize(location_));
LOG_ENGINE_DEBUG_ << "Finish serialize index file: " << location_ << " size: " << index_->Size(); LOG_ENGINE_DEBUG_ << "Finish serialize index file: " << location_ << " size: " << index_->Size();
if (index_->Size() == 0) { if (index_->Size() == 0) {
......
...@@ -101,7 +101,7 @@ class MetaField { ...@@ -101,7 +101,7 @@ class MetaField {
// only check field type, don't check field width, for example: VARCHAR(255) and VARCHAR(100) is equal // only check field type, don't check field width, for example: VARCHAR(255) and VARCHAR(100) is equal
std::vector<std::string> type_split; std::vector<std::string> type_split;
milvus::server::StringHelpFunctions::SplitStringByDelimeter(type_, "(", type_split); milvus::StringHelpFunctions::SplitStringByDelimeter(type_, "(", type_split);
if (!type_split.empty()) { if (!type_split.empty()) {
type_len_min = type_split[0].length() > type_len_min ? type_len_min : type_split[0].length(); type_len_min = type_split[0].length() > type_len_min ? type_len_min : type_split[0].length();
} }
...@@ -1484,7 +1484,7 @@ MySQLMetaImpl::CreatePartition(const std::string& collection_id, const std::stri ...@@ -1484,7 +1484,7 @@ MySQLMetaImpl::CreatePartition(const std::string& collection_id, const std::stri
// trim side-blank of tag, only compare valid characters // trim side-blank of tag, only compare valid characters
// for example: " ab cd " is treated as "ab cd" // for example: " ab cd " is treated as "ab cd"
std::string valid_tag = tag; std::string valid_tag = tag;
server::StringHelpFunctions::TrimStringBlank(valid_tag); StringHelpFunctions::TrimStringBlank(valid_tag);
// not allow duplicated partition // not allow duplicated partition
std::string exist_partition; std::string exist_partition;
...@@ -1525,7 +1525,7 @@ MySQLMetaImpl::HasPartition(const std::string& collection_id, const std::string& ...@@ -1525,7 +1525,7 @@ MySQLMetaImpl::HasPartition(const std::string& collection_id, const std::string&
// trim side-blank of tag, only compare valid characters // trim side-blank of tag, only compare valid characters
// for example: " ab cd " is treated as "ab cd" // for example: " ab cd " is treated as "ab cd"
std::string valid_tag = tag; std::string valid_tag = tag;
server::StringHelpFunctions::TrimStringBlank(valid_tag); StringHelpFunctions::TrimStringBlank(valid_tag);
{ {
mysqlpp::ScopedConnection connectionPtr(*mysql_connection_pool_, safe_grab_); mysqlpp::ScopedConnection connectionPtr(*mysql_connection_pool_, safe_grab_);
...@@ -1624,7 +1624,7 @@ MySQLMetaImpl::GetPartitionName(const std::string& collection_id, const std::str ...@@ -1624,7 +1624,7 @@ MySQLMetaImpl::GetPartitionName(const std::string& collection_id, const std::str
// trim side-blank of tag, only compare valid characters // trim side-blank of tag, only compare valid characters
// for example: " ab cd " is treated as "ab cd" // for example: " ab cd " is treated as "ab cd"
std::string valid_tag = tag; std::string valid_tag = tag;
server::StringHelpFunctions::TrimStringBlank(valid_tag); StringHelpFunctions::TrimStringBlank(valid_tag);
{ {
mysqlpp::ScopedConnection connectionPtr(*mysql_connection_pool_, safe_grab_); mysqlpp::ScopedConnection connectionPtr(*mysql_connection_pool_, safe_grab_);
......
...@@ -918,7 +918,7 @@ SqliteMetaImpl::CreatePartition(const std::string& collection_id, const std::str ...@@ -918,7 +918,7 @@ SqliteMetaImpl::CreatePartition(const std::string& collection_id, const std::str
// trim side-blank of tag, only compare valid characters // trim side-blank of tag, only compare valid characters
// for example: " ab cd " is treated as "ab cd" // for example: " ab cd " is treated as "ab cd"
std::string valid_tag = tag; std::string valid_tag = tag;
server::StringHelpFunctions::TrimStringBlank(valid_tag); StringHelpFunctions::TrimStringBlank(valid_tag);
// not allow duplicated partition // not allow duplicated partition
std::string exist_partition; std::string exist_partition;
...@@ -957,7 +957,7 @@ SqliteMetaImpl::HasPartition(const std::string& collection_id, const std::string ...@@ -957,7 +957,7 @@ SqliteMetaImpl::HasPartition(const std::string& collection_id, const std::string
// trim side-blank of tag, only compare valid characters // trim side-blank of tag, only compare valid characters
// for example: " ab cd " is treated as "ab cd" // for example: " ab cd " is treated as "ab cd"
std::string valid_tag = tag; std::string valid_tag = tag;
server::StringHelpFunctions::TrimStringBlank(valid_tag); StringHelpFunctions::TrimStringBlank(valid_tag);
auto name = ConnectorPtr->select(columns(&CollectionSchema::collection_id_), auto name = ConnectorPtr->select(columns(&CollectionSchema::collection_id_),
where(c(&CollectionSchema::owner_collection_) == collection_id and where(c(&CollectionSchema::owner_collection_) == collection_id and
...@@ -1031,7 +1031,7 @@ SqliteMetaImpl::GetPartitionName(const std::string& collection_id, const std::st ...@@ -1031,7 +1031,7 @@ SqliteMetaImpl::GetPartitionName(const std::string& collection_id, const std::st
// trim side-blank of tag, only compare valid characters // trim side-blank of tag, only compare valid characters
// for example: " ab cd " is treated as "ab cd" // for example: " ab cd " is treated as "ab cd"
std::string valid_tag = tag; std::string valid_tag = tag;
server::StringHelpFunctions::TrimStringBlank(valid_tag); StringHelpFunctions::TrimStringBlank(valid_tag);
auto name = ConnectorPtr->select(columns(&CollectionSchema::collection_id_), auto name = ConnectorPtr->select(columns(&CollectionSchema::collection_id_),
where(c(&CollectionSchema::owner_collection_) == collection_id and where(c(&CollectionSchema::owner_collection_) == collection_id and
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
// or implied. See the License for the specific language governing permissions and limitations under the License. // or implied. See the License for the specific language governing permissions and limitations under the License.
#pragma once #pragma once
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include <thread> #include <thread>
...@@ -22,7 +23,7 @@ namespace engine { ...@@ -22,7 +23,7 @@ namespace engine {
namespace snapshot { namespace snapshot {
using ThreadPtr = std::shared_ptr<std::thread>; using ThreadPtr = std::shared_ptr<std::thread>;
using OperationQueue = server::BlockingQueue<OperationsPtr>; using OperationQueue = BlockingQueue<OperationsPtr>;
using OperationQueuePtr = std::shared_ptr<OperationQueue>; using OperationQueuePtr = std::shared_ptr<OperationQueue>;
class OperationExecutor { class OperationExecutor {
......
...@@ -39,7 +39,7 @@ WalManager::WalManager(const MXLogConfiguration& config) { ...@@ -39,7 +39,7 @@ WalManager::WalManager(const MXLogConfiguration& config) {
mxlog_config_.mxlog_path += '/'; mxlog_config_.mxlog_path += '/';
} }
// check path exist // check path exist
auto status = server::CommonUtil::CreateDirectory(mxlog_config_.mxlog_path); auto status = CommonUtil::CreateDirectory(mxlog_config_.mxlog_path);
if (!status.ok()) { if (!status.ok()) {
std::string msg = "failed to create wal directory " + mxlog_config_.mxlog_path; std::string msg = "failed to create wal directory " + mxlog_config_.mxlog_path;
LOG_ENGINE_ERROR_ << msg; LOG_ENGINE_ERROR_ << msg;
......
...@@ -39,7 +39,7 @@ using ResWPtr = std::weak_ptr<Resource>; ...@@ -39,7 +39,7 @@ using ResWPtr = std::weak_ptr<Resource>;
class FaissGpuResourceMgr { class FaissGpuResourceMgr {
public: public:
friend class ResScope; friend class ResScope;
using ResBQ = milvus::server::BlockingQueue<ResPtr>; using ResBQ = BlockingQueue<ResPtr>;
public: public:
struct DeviceParams { struct DeviceParams {
......
...@@ -117,16 +117,16 @@ main(int argc, char* argv[]) { ...@@ -117,16 +117,16 @@ main(int argc, char* argv[]) {
} }
/* Handle Signal */ /* Handle Signal */
milvus::server::signal_routine_func = [](int32_t exit_code) { milvus::signal_routine_func = [](int32_t exit_code) {
milvus::server::Server::GetInstance().Stop(); milvus::server::Server::GetInstance().Stop();
exit(exit_code); exit(exit_code);
}; };
signal(SIGHUP, milvus::server::HandleSignal); signal(SIGHUP, milvus::HandleSignal);
signal(SIGINT, milvus::server::HandleSignal); signal(SIGINT, milvus::HandleSignal);
signal(SIGUSR1, milvus::server::HandleSignal); signal(SIGUSR1, milvus::HandleSignal);
signal(SIGSEGV, milvus::server::HandleSignal); signal(SIGSEGV, milvus::HandleSignal);
signal(SIGUSR2, milvus::server::HandleSignal); signal(SIGUSR2, milvus::HandleSignal);
signal(SIGTERM, milvus::server::HandleSignal); signal(SIGTERM, milvus::HandleSignal);
server.Init(start_daemonized, pid_filename, config_filename); server.Init(start_daemonized, pid_filename, config_filename);
......
...@@ -203,7 +203,7 @@ XBuildIndexTask::Execute() { ...@@ -203,7 +203,7 @@ XBuildIndexTask::Execute() {
// step 5: update meta // step 5: update meta
table_file.file_type_ = engine::meta::SegmentSchema::INDEX; table_file.file_type_ = engine::meta::SegmentSchema::INDEX;
table_file.file_size_ = server::CommonUtil::GetFileSize(table_file.location_); table_file.file_size_ = CommonUtil::GetFileSize(table_file.location_);
table_file.row_count_ = file_->row_count_; // index->Count(); table_file.row_count_ = file_->row_count_; // index->Count();
auto origin_file = *file_; auto origin_file = *file_;
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <vector> #include <vector>
namespace milvus { namespace milvus {
namespace server {
template <typename T> template <typename T>
class BlockingQueue { class BlockingQueue {
...@@ -35,25 +34,55 @@ class BlockingQueue { ...@@ -35,25 +34,55 @@ class BlockingQueue {
operator=(const BlockingQueue& rhs) = delete; operator=(const BlockingQueue& rhs) = delete;
void void
Put(const T& task); Put(const T& task) {
std::unique_lock<std::mutex> lock(mtx);
full_.wait(lock, [this] { return (queue_.size() < capacity_); });
queue_.push(task);
empty_.notify_all();
}
T T
Take(); Take() {
std::unique_lock<std::mutex> lock(mtx);
empty_.wait(lock, [this] { return !queue_.empty(); });
T front(queue_.front());
queue_.pop();
full_.notify_all();
return front;
}
T T
Front(); Front() {
std::unique_lock<std::mutex> lock(mtx);
empty_.wait(lock, [this] { return !queue_.empty(); });
T front(queue_.front());
return front;
}
T T
Back(); Back() {
std::unique_lock<std::mutex> lock(mtx);
empty_.wait(lock, [this] { return !queue_.empty(); });
T back(queue_.back());
return back;
}
size_t size_t
Size(); Size() {
std::lock_guard<std::mutex> lock(mtx);
return queue_.size();
}
bool bool
Empty(); Empty() {
std::unique_lock<std::mutex> lock(mtx);
return queue_.empty();
}
void void
SetCapacity(const size_t capacity); SetCapacity(const size_t capacity) {
capacity_ = (capacity > 0 ? capacity : capacity_);
}
protected: protected:
mutable std::mutex mtx; mutable std::mutex mtx;
...@@ -63,7 +92,4 @@ class BlockingQueue { ...@@ -63,7 +92,4 @@ class BlockingQueue {
size_t capacity_ = 32; size_t capacity_ = 32;
}; };
} // namespace server
} // namespace milvus } // namespace milvus
#include "./BlockingQueue.inl"
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed 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
namespace milvus {
namespace server {
template <typename T>
void
BlockingQueue<T>::Put(const T& task) {
std::unique_lock<std::mutex> lock(mtx);
full_.wait(lock, [this] { return (queue_.size() < capacity_); });
queue_.push(task);
empty_.notify_all();
}
template <typename T>
T
BlockingQueue<T>::Take() {
std::unique_lock<std::mutex> lock(mtx);
empty_.wait(lock, [this] { return !queue_.empty(); });
T front(queue_.front());
queue_.pop();
full_.notify_all();
return front;
}
template <typename T>
size_t
BlockingQueue<T>::Size() {
std::lock_guard<std::mutex> lock(mtx);
return queue_.size();
}
template <typename T>
T
BlockingQueue<T>::Front() {
std::unique_lock<std::mutex> lock(mtx);
empty_.wait(lock, [this] { return !queue_.empty(); });
T front(queue_.front());
return front;
}
template <typename T>
T
BlockingQueue<T>::Back() {
std::unique_lock<std::mutex> lock(mtx);
empty_.wait(lock, [this] { return !queue_.empty(); });
T back(queue_.back());
return back;
}
template <typename T>
bool
BlockingQueue<T>::Empty() {
std::unique_lock<std::mutex> lock(mtx);
return queue_.empty();
}
template <typename T>
void
BlockingQueue<T>::SetCapacity(const size_t capacity) {
capacity_ = (capacity > 0 ? capacity : capacity_);
}
} // namespace server
} // namespace milvus
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <vector> #include <vector>
namespace milvus { namespace milvus {
namespace server {
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
...@@ -204,5 +203,4 @@ CommonUtil::GetCurrentTimeStr() { ...@@ -204,5 +203,4 @@ CommonUtil::GetCurrentTimeStr() {
} }
#endif #endif
} // namespace server
} // namespace milvus } // namespace milvus
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <string> #include <string>
namespace milvus { namespace milvus {
namespace server {
class CommonUtil { class CommonUtil {
public: public:
...@@ -52,5 +51,4 @@ class CommonUtil { ...@@ -52,5 +51,4 @@ class CommonUtil {
#endif #endif
}; };
} // namespace server
} // namespace milvus } // namespace milvus
...@@ -130,28 +130,4 @@ constexpr ErrorCode SS_CONSTRAINT_CHECK_ERROR = ToSSErrorCode(7); ...@@ -130,28 +130,4 @@ constexpr ErrorCode SS_CONSTRAINT_CHECK_ERROR = ToSSErrorCode(7);
constexpr ErrorCode SS_INVALID_ARGUMENT_ERROR = ToSSErrorCode(8); constexpr ErrorCode SS_INVALID_ARGUMENT_ERROR = ToSSErrorCode(8);
constexpr ErrorCode SS_OPERATION_PENDING = ToSSErrorCode(9); constexpr ErrorCode SS_OPERATION_PENDING = ToSSErrorCode(9);
namespace server {
class ServerException : public std::exception {
public:
explicit ServerException(ErrorCode error_code, const std::string& message = std::string())
: error_code_(error_code), message_(message) {
}
public:
ErrorCode
error_code() const {
return error_code_;
}
virtual const char*
what() const noexcept {
return message_.c_str();
}
private:
ErrorCode error_code_;
std::string message_;
};
} // namespace server
} // namespace milvus } // namespace milvus
...@@ -8,10 +8,13 @@ ...@@ -8,10 +8,13 @@
// Unless required by applicable law or agreed to in writing, software distributed under the License // 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 // 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. // or implied. See the License for the specific language governing permissions and limitations under the License.
#pragma once #pragma once
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
namespace milvus { namespace milvus {
using json = nlohmann::json; using json = nlohmann::json;
}
} // namespace milvus
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
// Unless required by applicable law or agreed to in writing, software distributed under the License // 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 // 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. // or implied. See the License for the specific language governing permissions and limitations under the License.
#include "utils/Log.h" #include "utils/Log.h"
#include <cstdarg> #include <cstdarg>
......
...@@ -122,59 +122,6 @@ namespace milvus { ...@@ -122,59 +122,6 @@ namespace milvus {
#define LOG_WAL_ERROR_ LOG(ERROR) << WAL_MODULE_FUNCTION #define LOG_WAL_ERROR_ LOG(ERROR) << WAL_MODULE_FUNCTION
#define LOG_WAL_FATAL_ LOG(FATAL) << WAL_MODULE_FUNCTION #define LOG_WAL_FATAL_ LOG(FATAL) << WAL_MODULE_FUNCTION
/*
* Deprecated
*/
/////////////////////////////////////////////////////////////////////////////////////////////////
// #define SERVER_DOMAIN_NAME "[SERVER]"
// #define LOG_SERVER_TRACE_ LOG(TRACE) << SERVER_DOMAIN_NAME
// #define LOG_SERVER_DEBUG_ LOG(DEBUG) << SERVER_DOMAIN_NAME
// #define LOG_SERVER_INFO_ LOG(INFO) << SERVER_DOMAIN_NAME
// #define LOG_SERVER_WARNING_ LOG(WARNING) << SERVER_DOMAIN_NAME
// #define LOG_SERVER_ERROR_ LOG(ERROR) << SERVER_DOMAIN_NAME
// #define LOG_SERVER_FATAL_ LOG(FATAL) << SERVER_DOMAIN_NAME
/////////////////////////////////////////////////////////////////////////////////////////////////
// #define ENGINE_DOMAIN_NAME "[ENGINE]"
// #define LOG_ENGINE_TRACE_ LOG(TRACE) << ENGINE_DOMAIN_NAME
// #define LOG_ENGINE_DEBUG_ LOG(DEBUG) << ENGINE_DOMAIN_NAME
// #define LOG_ENGINE_INFO_ LOG(INFO) << ENGINE_DOMAIN_NAME
// #define LOG_ENGINE_WARNING_ LOG(WARNING) << ENGINE_DOMAIN_NAME
// #define LOG_ENGINE_ERROR_ LOG(ERROR) << ENGINE_DOMAIN_NAME
// #define LOG_ENGINE_FATAL_ LOG(FATAL) << ENGINE_DOMAIN_NAME
/////////////////////////////////////////////////////////////////////////////////////////////////
// #define WRAPPER_DOMAIN_NAME "[WRAPPER]"
// #define WRAPPER_LOG_TRACE LOG(TRACE) << WRAPPER_DOMAIN_NAME
// #define WRAPPER_LOG_DEBUG LOG(DEBUG) << WRAPPER_DOMAIN_NAME
// #define WRAPPER_LOG_INFO LOG(INFO) << WRAPPER_DOMAIN_NAME
// #define WRAPPER_LOG_WARNING LOG(WARNING) << WRAPPER_DOMAIN_NAME
// #define WRAPPER_LOG_ERROR LOG(ERROR) << WRAPPER_DOMAIN_NAME
// #define WRAPPER_LOG_FATAL LOG(FATAL) << WRAPPER_DOMAIN_NAME
/////////////////////////////////////////////////////////////////////////////////////////////////
// #define STORAGE_DOMAIN_NAME "[STORAGE]"
// #define LOG_STORAGE_TRACE_ LOG(TRACE) << STORAGE_DOMAIN_NAME
// #define LOG_STORAGE_DEBUG_ LOG(DEBUG) << STORAGE_DOMAIN_NAME
// #define LOG_STORAGE_INFO_ LOG(INFO) << STORAGE_DOMAIN_NAME
// #define LOG_STORAGE_WARNING_ LOG(WARNING) << STORAGE_DOMAIN_NAME
// #define LOG_STORAGE_ERROR_ LOG(ERROR) << STORAGE_DOMAIN_NAME
// #define LOG_STORAGE_FATAL_ LOG(FATAL) << STORAGE_DOMAIN_NAME
// #define WAL_DOMAIN_NAME "[WAL]"
// #define LOG_WAL_TRACE_ LOG(TRACE) << WAL_DOMAIN_NAME
// #define LOG_WAL_DEBUG_ LOG(DEBUG) << WAL_DOMAIN_NAME
// #define LOG_WAL_INFO_ LOG(INFO) << WAL_DOMAIN_NAME
// #define LOG_WAL_WARNING_ LOG(WARNING) << WAL_DOMAIN_NAME
// #define LOG_WAL_ERROR_ LOG(ERROR) << WAL_DOMAIN_NAME
// #define LOG_WAL_FATAL_ LOG(FATAL) << WAL_DOMAIN_NAME
///////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////
std::string std::string
LogOut(const char* pattern, ...); LogOut(const char* pattern, ...);
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "utils/Log.h" #include "utils/Log.h"
namespace milvus { namespace milvus {
namespace server {
namespace { namespace {
static int global_idx = 0; static int global_idx = 0;
...@@ -191,13 +190,13 @@ InitLog(bool trace_enable, bool debug_enable, bool info_enable, bool warning_ena ...@@ -191,13 +190,13 @@ InitLog(bool trace_enable, bool debug_enable, bool info_enable, bool warning_ena
} }
fiu_do_on("LogUtil.InitLog.set_max_log_size_small_than_min", fiu_do_on("LogUtil.InitLog.set_max_log_size_small_than_min",
max_log_file_size = CONFIG_LOGS_MAX_LOG_FILE_SIZE_MIN - 1); max_log_file_size = server::CONFIG_LOGS_MAX_LOG_FILE_SIZE_MIN - 1);
if (max_log_file_size < CONFIG_LOGS_MAX_LOG_FILE_SIZE_MIN || if (max_log_file_size < server::CONFIG_LOGS_MAX_LOG_FILE_SIZE_MIN ||
max_log_file_size > CONFIG_LOGS_MAX_LOG_FILE_SIZE_MAX) { max_log_file_size > server::CONFIG_LOGS_MAX_LOG_FILE_SIZE_MAX) {
return Status(SERVER_UNEXPECTED_ERROR, "max_log_file_size must in range[" + return Status(SERVER_UNEXPECTED_ERROR, "max_log_file_size must in range[" +
std::to_string(CONFIG_LOGS_MAX_LOG_FILE_SIZE_MIN) + ", " + std::to_string(server::CONFIG_LOGS_MAX_LOG_FILE_SIZE_MIN) + ", " +
std::to_string(CONFIG_LOGS_MAX_LOG_FILE_SIZE_MAX) + "], now is " + std::to_string(server::CONFIG_LOGS_MAX_LOG_FILE_SIZE_MAX) +
std::to_string(max_log_file_size)); "], now is " + std::to_string(max_log_file_size));
} }
defaultConf.setGlobally(el::ConfigurationType::MaxLogFileSize, std::to_string(max_log_file_size)); defaultConf.setGlobally(el::ConfigurationType::MaxLogFileSize, std::to_string(max_log_file_size));
el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck); el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);
...@@ -206,12 +205,14 @@ InitLog(bool trace_enable, bool debug_enable, bool info_enable, bool warning_ena ...@@ -206,12 +205,14 @@ InitLog(bool trace_enable, bool debug_enable, bool info_enable, bool warning_ena
// set delete_exceeds = 0 means disable throw away log file even they reach certain limit. // set delete_exceeds = 0 means disable throw away log file even they reach certain limit.
if (delete_exceeds != 0) { if (delete_exceeds != 0) {
fiu_do_on("LogUtil.InitLog.delete_exceeds_small_than_min", delete_exceeds = CONFIG_LOGS_LOG_ROTATE_NUM_MIN - 1); fiu_do_on("LogUtil.InitLog.delete_exceeds_small_than_min",
if (delete_exceeds < CONFIG_LOGS_LOG_ROTATE_NUM_MIN || delete_exceeds > CONFIG_LOGS_LOG_ROTATE_NUM_MAX) { delete_exceeds = server::CONFIG_LOGS_LOG_ROTATE_NUM_MIN - 1);
if (delete_exceeds < server::CONFIG_LOGS_LOG_ROTATE_NUM_MIN ||
delete_exceeds > server::CONFIG_LOGS_LOG_ROTATE_NUM_MAX) {
return Status(SERVER_UNEXPECTED_ERROR, "delete_exceeds must in range[" + return Status(SERVER_UNEXPECTED_ERROR, "delete_exceeds must in range[" +
std::to_string(CONFIG_LOGS_LOG_ROTATE_NUM_MIN) + ", " + std::to_string(server::CONFIG_LOGS_LOG_ROTATE_NUM_MIN) + ", " +
std::to_string(CONFIG_LOGS_LOG_ROTATE_NUM_MAX) + "], now is " + std::to_string(server::CONFIG_LOGS_LOG_ROTATE_NUM_MAX) +
std::to_string(delete_exceeds)); "], now is " + std::to_string(delete_exceeds));
} }
enable_log_delete = true; enable_log_delete = true;
logs_delete_exceeds = delete_exceeds; logs_delete_exceeds = delete_exceeds;
...@@ -235,7 +236,7 @@ LogConfigInFile(const std::string& path) { ...@@ -235,7 +236,7 @@ LogConfigInFile(const std::string& path) {
void void
LogConfigInMem() { LogConfigInMem() {
auto& config = Config::GetInstance(); auto& config = server::Config::GetInstance();
std::string config_str; std::string config_str;
config.GetConfigJsonStr(config_str, 3); config.GetConfigJsonStr(config_str, 3);
LOG_SERVER_INFO_ << "\n\n" LOG_SERVER_INFO_ << "\n\n"
...@@ -267,5 +268,4 @@ LogCpuInfo() { ...@@ -267,5 +268,4 @@ LogCpuInfo() {
LOG_SERVER_INFO_ << "\n\n" << std::string(15, '*') << "CPU" << std::string(15, '*') << "\n\n" << sub_str; LOG_SERVER_INFO_ << "\n\n" << std::string(15, '*') << "CPU" << std::string(15, '*') << "\n\n" << sub_str;
} }
} // namespace server
} // namespace milvus } // namespace milvus
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <string> #include <string>
namespace milvus { namespace milvus {
namespace server {
Status Status
InitLog(bool trace_enable, bool debug_enable, bool info_enable, bool warning_enable, bool error_enable, InitLog(bool trace_enable, bool debug_enable, bool info_enable, bool warning_enable, bool error_enable,
...@@ -43,5 +42,4 @@ LogConfigInMem(); ...@@ -43,5 +42,4 @@ LogConfigInMem();
void void
LogCpuInfo(); LogCpuInfo();
} // namespace server
} // namespace milvus } // namespace milvus
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <string> #include <string>
namespace milvus { namespace milvus {
namespace server {
signal_func_ptr signal_routine_func = nullptr; signal_func_ptr signal_routine_func = nullptr;
...@@ -59,5 +58,4 @@ PrintStacktrace() { ...@@ -59,5 +58,4 @@ PrintStacktrace() {
free(stacktrace); free(stacktrace);
} }
} // namespace server
} // namespace milvus } // namespace milvus
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <cstdint> #include <cstdint>
namespace milvus { namespace milvus {
namespace server {
typedef void (*signal_func_ptr)(int32_t); typedef void (*signal_func_ptr)(int32_t);
...@@ -26,5 +25,4 @@ HandleSignal(int signum); ...@@ -26,5 +25,4 @@ HandleSignal(int signum);
extern void extern void
PrintStacktrace(); PrintStacktrace();
} // namespace server
} // namespace milvus } // namespace milvus
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <string> #include <string>
namespace milvus { namespace milvus {
namespace server {
void void
StringHelpFunctions::TrimStringBlank(std::string& string) { StringHelpFunctions::TrimStringBlank(std::string& string) {
...@@ -161,5 +160,4 @@ StringHelpFunctions::ConvertToBoolean(const std::string& str, bool& value) { ...@@ -161,5 +160,4 @@ StringHelpFunctions::ConvertToBoolean(const std::string& str, bool& value) {
return Status::OK(); return Status::OK();
} }
} // namespace server
} // namespace milvus } // namespace milvus
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <vector> #include <vector>
namespace milvus { namespace milvus {
namespace server {
class StringHelpFunctions { class StringHelpFunctions {
private: private:
...@@ -72,5 +71,4 @@ class StringHelpFunctions { ...@@ -72,5 +71,4 @@ class StringHelpFunctions {
ConvertToBoolean(const std::string& str, bool& value); ConvertToBoolean(const std::string& str, bool& value);
}; };
} // namespace server
} // namespace milvus } // namespace milvus
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "utils/Log.h" #include "utils/Log.h"
namespace milvus { namespace milvus {
inline void inline void
print_timestamp(const std::string& message) { print_timestamp(const std::string& message) {
std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now(); std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now();
......
...@@ -81,11 +81,11 @@ ConvertTimeRangeToDBDates(const std::string& start_value, const std::string& end ...@@ -81,11 +81,11 @@ ConvertTimeRangeToDBDates(const std::string& start_value, const std::string& end
time_t tt_start, tt_end; time_t tt_start, tt_end;
tm tm_start, tm_end; tm tm_start, tm_end;
if (!milvus::server::CommonUtil::TimeStrToTime(start_value, tt_start, tm_start)) { if (!milvus::CommonUtil::TimeStrToTime(start_value, tt_start, tm_start)) {
return; return;
} }
if (!milvus::server::CommonUtil::TimeStrToTime(end_value, tt_end, tm_end)) { if (!milvus::CommonUtil::TimeStrToTime(end_value, tt_end, tm_end)) {
return; return;
} }
...@@ -97,7 +97,7 @@ ConvertTimeRangeToDBDates(const std::string& start_value, const std::string& end ...@@ -97,7 +97,7 @@ ConvertTimeRangeToDBDates(const std::string& start_value, const std::string& end
for (int64_t i = 0; i < days; i++) { for (int64_t i = 0; i < days; i++) {
time_t tt_day = tt_start + DAY_SECONDS * i; time_t tt_day = tt_start + DAY_SECONDS * i;
tm tm_day; tm tm_day;
milvus::server::CommonUtil::ConvertTime(tt_day, tm_day); milvus::CommonUtil::ConvertTime(tt_day, tm_day);
int64_t date = tm_day.tm_year * 10000 + tm_day.tm_mon * 100 + tm_day.tm_mday; // according to db logic int64_t date = tm_day.tm_year * 10000 + tm_day.tm_mon * 100 + tm_day.tm_mday; // according to db logic
dates.push_back(date); dates.push_back(date);
......
...@@ -60,8 +60,8 @@ using FieldElement = milvus::engine::snapshot::FieldElement; ...@@ -60,8 +60,8 @@ using FieldElement = milvus::engine::snapshot::FieldElement;
using Snapshots = milvus::engine::snapshot::Snapshots; using Snapshots = milvus::engine::snapshot::Snapshots;
using ScopedSnapshotT = milvus::engine::snapshot::ScopedSnapshotT; using ScopedSnapshotT = milvus::engine::snapshot::ScopedSnapshotT;
using ReferenceProxy = milvus::engine::snapshot::ReferenceProxy; using ReferenceProxy = milvus::engine::snapshot::ReferenceProxy;
using Queue = milvus::server::BlockingQueue<ID_TYPE>; using Queue = milvus::BlockingQueue<ID_TYPE>;
using TQueue = milvus::server::BlockingQueue<std::tuple<ID_TYPE, ID_TYPE>>; using TQueue = milvus::BlockingQueue<std::tuple<ID_TYPE, ID_TYPE>>;
int RandomInt(int start, int end) { int RandomInt(int start, int end) {
std::random_device dev; std::random_device dev;
......
...@@ -1268,7 +1268,7 @@ TEST_F(WebControllerTest, GET_VECTORS_BY_IDS) { ...@@ -1268,7 +1268,7 @@ TEST_F(WebControllerTest, GET_VECTORS_BY_IDS) {
} }
std::string query_ids; std::string query_ids;
milvus::server::StringHelpFunctions::MergeStringWithDelimeter(vector_ids, ",", query_ids); milvus::StringHelpFunctions::MergeStringWithDelimeter(vector_ids, ",", query_ids);
auto response = client_ptr->getVectors(collection_name, query_ids.c_str(), conncetion_ptr); auto response = client_ptr->getVectors(collection_name, query_ids.c_str(), conncetion_ptr);
ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str();
......
...@@ -323,7 +323,7 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) { ...@@ -323,7 +323,7 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) {
std::vector<std::string> search_resources = {"gpu0"}; std::vector<std::string> search_resources = {"gpu0"};
std::vector<int64_t> search_res_vec; std::vector<int64_t> search_res_vec;
std::string search_res_str; std::string search_res_str;
milvus::server::StringHelpFunctions::MergeStringWithDelimeter( milvus::StringHelpFunctions::MergeStringWithDelimeter(
search_resources, milvus::server::CONFIG_GPU_RESOURCE_DELIMITER, search_res_str); search_resources, milvus::server::CONFIG_GPU_RESOURCE_DELIMITER, search_res_str);
ASSERT_TRUE(config.SetGpuResourceConfigSearchResources(search_res_str).ok()); ASSERT_TRUE(config.SetGpuResourceConfigSearchResources(search_res_str).ok());
ASSERT_TRUE(config.GetGpuResourceConfigSearchResources(search_res_vec).ok()); ASSERT_TRUE(config.GetGpuResourceConfigSearchResources(search_res_vec).ok());
...@@ -334,7 +334,7 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) { ...@@ -334,7 +334,7 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) {
std::vector<std::string> build_index_resources = {"gpu0"}; std::vector<std::string> build_index_resources = {"gpu0"};
std::vector<int64_t> build_index_res_vec; std::vector<int64_t> build_index_res_vec;
std::string build_index_res_str; std::string build_index_res_str;
milvus::server::StringHelpFunctions::MergeStringWithDelimeter( milvus::StringHelpFunctions::MergeStringWithDelimeter(
build_index_resources, milvus::server::CONFIG_GPU_RESOURCE_DELIMITER, build_index_res_str); build_index_resources, milvus::server::CONFIG_GPU_RESOURCE_DELIMITER, build_index_res_str);
ASSERT_TRUE(config.SetGpuResourceConfigBuildIndexResources(build_index_res_str).ok()); ASSERT_TRUE(config.SetGpuResourceConfigBuildIndexResources(build_index_res_str).ok());
ASSERT_TRUE(config.GetGpuResourceConfigBuildIndexResources(build_index_res_vec).ok()); ASSERT_TRUE(config.GetGpuResourceConfigBuildIndexResources(build_index_res_vec).ok());
......
...@@ -44,16 +44,11 @@ CopyStatus(milvus::Status& st1, milvus::Status& st2) { ...@@ -44,16 +44,11 @@ CopyStatus(milvus::Status& st1, milvus::Status& st2) {
TEST(UtilTest, EXCEPTION_TEST) { TEST(UtilTest, EXCEPTION_TEST) {
std::string err_msg = "failed"; std::string err_msg = "failed";
milvus::server::ServerException ex(milvus::SERVER_UNEXPECTED_ERROR, err_msg); milvus::Exception ex(milvus::SERVER_UNEXPECTED_ERROR, err_msg);
ASSERT_EQ(ex.error_code(), milvus::SERVER_UNEXPECTED_ERROR); ASSERT_EQ(ex.code(), milvus::SERVER_UNEXPECTED_ERROR);
std::string msg = ex.what(); std::string msg = ex.what();
ASSERT_EQ(msg, err_msg); ASSERT_EQ(msg, err_msg);
milvus::Exception ex1(milvus::SERVER_UNEXPECTED_ERROR, err_msg);
ASSERT_EQ(ex1.code(), milvus::SERVER_UNEXPECTED_ERROR);
msg = ex1.what();
ASSERT_EQ(msg, err_msg);
std::string empty_err_msg; std::string empty_err_msg;
milvus::Exception empty_ex(milvus::SERVER_UNEXPECTED_ERROR, empty_err_msg); milvus::Exception empty_ex(milvus::SERVER_UNEXPECTED_ERROR, empty_err_msg);
ASSERT_EQ(empty_ex.code(), milvus::SERVER_UNEXPECTED_ERROR); ASSERT_EQ(empty_ex.code(), milvus::SERVER_UNEXPECTED_ERROR);
...@@ -62,8 +57,8 @@ TEST(UtilTest, EXCEPTION_TEST) { ...@@ -62,8 +57,8 @@ TEST(UtilTest, EXCEPTION_TEST) {
} }
TEST(UtilTest, SIGNAL_TEST) { TEST(UtilTest, SIGNAL_TEST) {
milvus::server::HandleSignal(SIGINT); milvus::HandleSignal(SIGINT);
milvus::server::HandleSignal(SIGABRT); milvus::HandleSignal(SIGABRT);
} }
TEST(UtilTest, COMMON_TEST) { TEST(UtilTest, COMMON_TEST) {
...@@ -86,50 +81,50 @@ TEST(UtilTest, COMMON_TEST) { ...@@ -86,50 +81,50 @@ TEST(UtilTest, COMMON_TEST) {
std::string path1 = "/tmp/milvus_test/"; std::string path1 = "/tmp/milvus_test/";
std::string path2 = path1 + "common_test_12345/"; std::string path2 = path1 + "common_test_12345/";
std::string path3 = path2 + "abcdef"; std::string path3 = path2 + "abcdef";
milvus::Status status = milvus::server::CommonUtil::CreateDirectory(path3); milvus::Status status = milvus::CommonUtil::CreateDirectory(path3);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
status = milvus::server::CommonUtil::CreateDirectory(empty_path); status = milvus::CommonUtil::CreateDirectory(empty_path);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
// test again // test again
status = milvus::server::CommonUtil::CreateDirectory(path3); status = milvus::CommonUtil::CreateDirectory(path3);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
ASSERT_TRUE(milvus::server::CommonUtil::IsDirectoryExist(path3)); ASSERT_TRUE(milvus::CommonUtil::IsDirectoryExist(path3));
status = milvus::server::CommonUtil::DeleteDirectory(empty_path); status = milvus::CommonUtil::DeleteDirectory(empty_path);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
status = milvus::server::CommonUtil::DeleteDirectory(path1); status = milvus::CommonUtil::DeleteDirectory(path1);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
// test again // test again
status = milvus::server::CommonUtil::DeleteDirectory(path1); status = milvus::CommonUtil::DeleteDirectory(path1);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
ASSERT_FALSE(milvus::server::CommonUtil::IsDirectoryExist(path1)); ASSERT_FALSE(milvus::CommonUtil::IsDirectoryExist(path1));
ASSERT_FALSE(milvus::server::CommonUtil::IsFileExist(path1)); ASSERT_FALSE(milvus::CommonUtil::IsFileExist(path1));
std::string exe_path = milvus::server::CommonUtil::GetExePath(); std::string exe_path = milvus::CommonUtil::GetExePath();
ASSERT_FALSE(exe_path.empty()); ASSERT_FALSE(exe_path.empty());
fiu_enable("CommonUtil.GetExePath.readlink_fail", 1, NULL, 0); fiu_enable("CommonUtil.GetExePath.readlink_fail", 1, NULL, 0);
exe_path = milvus::server::CommonUtil::GetExePath(); exe_path = milvus::CommonUtil::GetExePath();
ASSERT_FALSE(!exe_path.empty()); ASSERT_FALSE(!exe_path.empty());
fiu_disable("CommonUtil.GetExePath.readlink_fail"); fiu_disable("CommonUtil.GetExePath.readlink_fail");
fiu_enable("CommonUtil.GetExePath.exe_path_error", 1, NULL, 0); fiu_enable("CommonUtil.GetExePath.exe_path_error", 1, NULL, 0);
exe_path = milvus::server::CommonUtil::GetExePath(); exe_path = milvus::CommonUtil::GetExePath();
ASSERT_FALSE(exe_path.empty()); ASSERT_FALSE(exe_path.empty());
fiu_disable("CommonUtil.GetExePath.exe_path_error"); fiu_disable("CommonUtil.GetExePath.exe_path_error");
fiu_enable("CommonUtil.CreateDirectory.create_parent_fail", 1, NULL, 0); fiu_enable("CommonUtil.CreateDirectory.create_parent_fail", 1, NULL, 0);
status = milvus::server::CommonUtil::CreateDirectory(path3); status = milvus::CommonUtil::CreateDirectory(path3);
ASSERT_FALSE(status.ok()); ASSERT_FALSE(status.ok());
fiu_disable("CommonUtil.CreateDirectory.create_parent_fail"); fiu_disable("CommonUtil.CreateDirectory.create_parent_fail");
fiu_enable("CommonUtil.CreateDirectory.create_dir_fail", 1, NULL, 0); fiu_enable("CommonUtil.CreateDirectory.create_dir_fail", 1, NULL, 0);
status = milvus::server::CommonUtil::CreateDirectory(path3); status = milvus::CommonUtil::CreateDirectory(path3);
ASSERT_FALSE(status.ok()); ASSERT_FALSE(status.ok());
fiu_disable("CommonUtil.CreateDirectory.create_dir_fail"); fiu_disable("CommonUtil.CreateDirectory.create_dir_fail");
...@@ -137,14 +132,14 @@ TEST(UtilTest, COMMON_TEST) { ...@@ -137,14 +132,14 @@ TEST(UtilTest, COMMON_TEST) {
time(&tt); time(&tt);
tm time_struct; tm time_struct;
memset(&time_struct, 0, sizeof(tm)); memset(&time_struct, 0, sizeof(tm));
milvus::server::CommonUtil::ConvertTime(tt, time_struct); milvus::CommonUtil::ConvertTime(tt, time_struct);
ASSERT_GE(time_struct.tm_year, 0); ASSERT_GE(time_struct.tm_year, 0);
ASSERT_GE(time_struct.tm_mon, 0); ASSERT_GE(time_struct.tm_mon, 0);
ASSERT_GE(time_struct.tm_mday, 0); ASSERT_GE(time_struct.tm_mday, 0);
milvus::server::CommonUtil::ConvertTime(time_struct, tt); milvus::CommonUtil::ConvertTime(time_struct, tt);
ASSERT_GT(tt, 0); ASSERT_GT(tt, 0);
bool res = milvus::server::CommonUtil::TimeStrToTime("2019-03-23", tt, time_struct); bool res = milvus::CommonUtil::TimeStrToTime("2019-03-23", tt, time_struct);
ASSERT_EQ(time_struct.tm_year, 119); ASSERT_EQ(time_struct.tm_year, 119);
ASSERT_EQ(time_struct.tm_mon, 2); ASSERT_EQ(time_struct.tm_mon, 2);
ASSERT_EQ(time_struct.tm_mday, 23); ASSERT_EQ(time_struct.tm_mday, 23);
...@@ -154,72 +149,72 @@ TEST(UtilTest, COMMON_TEST) { ...@@ -154,72 +149,72 @@ TEST(UtilTest, COMMON_TEST) {
TEST(UtilTest, STRINGFUNCTIONS_TEST) { TEST(UtilTest, STRINGFUNCTIONS_TEST) {
std::string str = " test str"; std::string str = " test str";
milvus::server::StringHelpFunctions::TrimStringBlank(str); milvus::StringHelpFunctions::TrimStringBlank(str);
ASSERT_EQ(str, "test str"); ASSERT_EQ(str, "test str");
str = "\"test str\""; str = "\"test str\"";
milvus::server::StringHelpFunctions::TrimStringQuote(str, "\""); milvus::StringHelpFunctions::TrimStringQuote(str, "\"");
ASSERT_EQ(str, "test str"); ASSERT_EQ(str, "test str");
str = "a,b,c"; str = "a,b,c";
std::vector<std::string> result; std::vector<std::string> result;
milvus::server::StringHelpFunctions::SplitStringByDelimeter(str, ",", result); milvus::StringHelpFunctions::SplitStringByDelimeter(str, ",", result);
ASSERT_EQ(result.size(), 3UL); ASSERT_EQ(result.size(), 3UL);
std::string merge_str; std::string merge_str;
milvus::server::StringHelpFunctions::MergeStringWithDelimeter(result, ",", merge_str); milvus::StringHelpFunctions::MergeStringWithDelimeter(result, ",", merge_str);
ASSERT_EQ(merge_str, "a,b,c"); ASSERT_EQ(merge_str, "a,b,c");
result.clear(); result.clear();
milvus::server::StringHelpFunctions::MergeStringWithDelimeter(result, ",", merge_str); milvus::StringHelpFunctions::MergeStringWithDelimeter(result, ",", merge_str);
ASSERT_TRUE(merge_str.empty()); ASSERT_TRUE(merge_str.empty());
auto status = milvus::server::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result); auto status = milvus::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
ASSERT_EQ(result.size(), 3UL); ASSERT_EQ(result.size(), 3UL);
result.clear(); result.clear();
status = milvus::server::StringHelpFunctions::SplitStringByQuote(str, ",", "", result); status = milvus::StringHelpFunctions::SplitStringByQuote(str, ",", "", result);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
ASSERT_EQ(result.size(), 3UL); ASSERT_EQ(result.size(), 3UL);
str = "55,\"aa,gg,yy\",b"; str = "55,\"aa,gg,yy\",b";
result.clear(); result.clear();
status = milvus::server::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result); status = milvus::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
ASSERT_EQ(result.size(), 3UL); ASSERT_EQ(result.size(), 3UL);
fiu_init(0); fiu_init(0);
fiu_enable("StringHelpFunctions.SplitStringByQuote.invalid_index", 1, NULL, 0); fiu_enable("StringHelpFunctions.SplitStringByQuote.invalid_index", 1, NULL, 0);
result.clear(); result.clear();
status = milvus::server::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result); status = milvus::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result);
ASSERT_FALSE(status.ok()); ASSERT_FALSE(status.ok());
fiu_disable("StringHelpFunctions.SplitStringByQuote.invalid_index"); fiu_disable("StringHelpFunctions.SplitStringByQuote.invalid_index");
fiu_enable("StringHelpFunctions.SplitStringByQuote.index_gt_last", 1, NULL, 0); fiu_enable("StringHelpFunctions.SplitStringByQuote.index_gt_last", 1, NULL, 0);
result.clear(); result.clear();
status = milvus::server::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result); status = milvus::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
fiu_disable("StringHelpFunctions.SplitStringByQuote.index_gt_last"); fiu_disable("StringHelpFunctions.SplitStringByQuote.index_gt_last");
fiu_enable("StringHelpFunctions.SplitStringByQuote.invalid_index2", 1, NULL, 0); fiu_enable("StringHelpFunctions.SplitStringByQuote.invalid_index2", 1, NULL, 0);
result.clear(); result.clear();
status = milvus::server::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result); status = milvus::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result);
ASSERT_FALSE(status.ok()); ASSERT_FALSE(status.ok());
fiu_disable("StringHelpFunctions.SplitStringByQuote.invalid_index2"); fiu_disable("StringHelpFunctions.SplitStringByQuote.invalid_index2");
fiu_enable("StringHelpFunctions.SplitStringByQuote.last_is_end", 1, NULL, 0); fiu_enable("StringHelpFunctions.SplitStringByQuote.last_is_end", 1, NULL, 0);
result.clear(); result.clear();
status = milvus::server::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result); status = milvus::StringHelpFunctions::SplitStringByQuote(str, ",", "\"", result);
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok());
fiu_disable("StringHelpFunctions.SplitStringByQuote.last_is_end2"); fiu_disable("StringHelpFunctions.SplitStringByQuote.last_is_end2");
ASSERT_TRUE(milvus::server::StringHelpFunctions::IsRegexMatch("abc", "abc")); ASSERT_TRUE(milvus::StringHelpFunctions::IsRegexMatch("abc", "abc"));
ASSERT_TRUE(milvus::server::StringHelpFunctions::IsRegexMatch("a8c", "a\\d.")); ASSERT_TRUE(milvus::StringHelpFunctions::IsRegexMatch("a8c", "a\\d."));
ASSERT_FALSE(milvus::server::StringHelpFunctions::IsRegexMatch("abc", "a\\dc")); ASSERT_FALSE(milvus::StringHelpFunctions::IsRegexMatch("abc", "a\\dc"));
} }
TEST(UtilTest, BLOCKINGQUEUE_TEST) { TEST(UtilTest, BLOCKINGQUEUE_TEST) {
milvus::server::BlockingQueue<std::string> bq; milvus::BlockingQueue<std::string> bq;
static const size_t count = 10; static const size_t count = 10;
bq.SetCapacity(count); bq.SetCapacity(count);
...@@ -251,13 +246,13 @@ TEST(UtilTest, LOG_TEST) { ...@@ -251,13 +246,13 @@ TEST(UtilTest, LOG_TEST) {
fiu_init(0); fiu_init(0);
fiu_enable("LogUtil.InitLog.set_max_log_size_small_than_min", 1, NULL, 0); fiu_enable("LogUtil.InitLog.set_max_log_size_small_than_min", 1, NULL, 0);
auto status = milvus::server::InitLog(true, true, true, true, true, true, auto status = milvus::InitLog(true, true, true, true, true, true,
"/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB "/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB
ASSERT_FALSE(status.ok()); ASSERT_FALSE(status.ok());
fiu_disable("LogUtil.InitLog.set_max_log_size_small_than_min"); fiu_disable("LogUtil.InitLog.set_max_log_size_small_than_min");
fiu_enable("LogUtil.InitLog.delete_exceeds_small_than_min", 1, NULL, 0); fiu_enable("LogUtil.InitLog.delete_exceeds_small_than_min", 1, NULL, 0);
status = milvus::server::InitLog(true, true, true, true, true, true, status = milvus::InitLog(true, true, true, true, true, true,
"/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB "/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB
ASSERT_FALSE(status.ok()); ASSERT_FALSE(status.ok());
fiu_disable("LogUtil.InitLog.delete_exceeds_small_than_min"); fiu_disable("LogUtil.InitLog.delete_exceeds_small_than_min");
...@@ -268,7 +263,7 @@ TEST(UtilTest, LOG_TEST) { ...@@ -268,7 +263,7 @@ TEST(UtilTest, LOG_TEST) {
fiu_enable("LogUtil.InitLog.trace_enable_to_false", 1, NULL, 0); fiu_enable("LogUtil.InitLog.trace_enable_to_false", 1, NULL, 0);
fiu_enable("LogUtil.InitLog.error_enable_to_false", 1, NULL, 0); fiu_enable("LogUtil.InitLog.error_enable_to_false", 1, NULL, 0);
fiu_enable("LogUtil.InitLog.fatal_enable_to_false", 1, NULL, 0); fiu_enable("LogUtil.InitLog.fatal_enable_to_false", 1, NULL, 0);
status = milvus::server::InitLog(true, true, true, true, true, true, status = milvus::InitLog(true, true, true, true, true, true,
"/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB "/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB
ASSERT_TRUE(status.ok()) << status.message(); ASSERT_TRUE(status.ok()) << status.message();
fiu_disable("LogUtil.InitLog.fatal_enable_to_false"); fiu_disable("LogUtil.InitLog.fatal_enable_to_false");
...@@ -278,26 +273,26 @@ TEST(UtilTest, LOG_TEST) { ...@@ -278,26 +273,26 @@ TEST(UtilTest, LOG_TEST) {
fiu_disable("LogUtil.InitLog.debug_enable_to_false"); fiu_disable("LogUtil.InitLog.debug_enable_to_false");
fiu_disable("LogUtil.InitLog.info_enable_to_false"); fiu_disable("LogUtil.InitLog.info_enable_to_false");
status = milvus::server::InitLog(true, true, true, true, true, true, status = milvus::InitLog(true, true, true, true, true, true,
"/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB "/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB
ASSERT_TRUE(status.ok()) << status.message(); ASSERT_TRUE(status.ok()) << status.message();
EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::NewLineForContainer)); EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::NewLineForContainer));
EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::LogDetailedCrashReason)); EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::LogDetailedCrashReason));
std::string fname = milvus::server::CommonUtil::GetFileName(LOG_FILE_PATH); std::string fname = milvus::CommonUtil::GetFileName(LOG_FILE_PATH);
ASSERT_EQ(fname, "log_config.conf"); ASSERT_EQ(fname, "log_config.conf");
ASSERT_NO_THROW(milvus::server::LogConfigInMem()); ASSERT_NO_THROW(milvus::LogConfigInMem());
ASSERT_NO_THROW(milvus::server::LogCpuInfo()); ASSERT_NO_THROW(milvus::LogCpuInfo());
// test log config file // test log config file
ASSERT_ANY_THROW(milvus::server::LogConfigInFile("log_config.conf")); ASSERT_ANY_THROW(milvus::LogConfigInFile("log_config.conf"));
const char * config_str = "server_config:\n address: 0.0.0.0\n port: 19530"; const char * config_str = "server_config:\n address: 0.0.0.0\n port: 19530";
std::fstream fs("/tmp/config.yaml", std::ios_base::out); std::fstream fs("/tmp/config.yaml", std::ios_base::out);
fs << config_str; fs << config_str;
fs.close(); fs.close();
ASSERT_NO_THROW(milvus::server::LogConfigInFile("/tmp/config.yaml")); ASSERT_NO_THROW(milvus::LogConfigInFile("/tmp/config.yaml"));
boost::filesystem::remove("/tmp/config.yaml"); boost::filesystem::remove("/tmp/config.yaml");
} }
...@@ -826,7 +821,7 @@ TEST(UtilTest, ROLLOUTHANDLER_TEST) { ...@@ -826,7 +821,7 @@ TEST(UtilTest, ROLLOUTHANDLER_TEST) {
file.open(tmp.c_str()); file.open(tmp.c_str());
file << "test" << std::endl; file << "test" << std::endl;
milvus::server::RolloutHandler(tmp.c_str(), 0, list[i]); milvus::RolloutHandler(tmp.c_str(), 0, list[i]);
tmp.append(".1"); tmp.append(".1");
std::ifstream file2; std::ifstream file2;
...@@ -842,7 +837,7 @@ TEST(UtilTest, ROLLOUTHANDLER_TEST) { ...@@ -842,7 +837,7 @@ TEST(UtilTest, ROLLOUTHANDLER_TEST) {
std::ofstream file; std::ofstream file;
file.open(tmp.c_str()); file.open(tmp.c_str());
file << "test" << std::endl; file << "test" << std::endl;
milvus::server::RolloutHandler(tmp.c_str(), 0, el::Level::Unknown); milvus::RolloutHandler(tmp.c_str(), 0, el::Level::Unknown);
tmp.append(".1"); tmp.append(".1");
std::ifstream file2; std::ifstream file2;
file2.open(tmp); file2.open(tmp);
......
...@@ -92,7 +92,7 @@ WriteToFile(const std::string& file_path, const char* content) { ...@@ -92,7 +92,7 @@ WriteToFile(const std::string& file_path, const char* content) {
void void
ConfigTest::SetUp() { ConfigTest::SetUp() {
std::string config_path(CONFIG_PATH); std::string config_path(CONFIG_PATH);
milvus::server::CommonUtil::CreateDirectory(config_path); milvus::CommonUtil::CreateDirectory(config_path);
WriteToFile(config_path + VALID_CONFIG_FILE, VALID_CONFIG_STR); WriteToFile(config_path + VALID_CONFIG_FILE, VALID_CONFIG_STR);
WriteToFile(config_path + INVALID_CONFIG_FILE, INVALID_CONFIG_STR); WriteToFile(config_path + INVALID_CONFIG_FILE, INVALID_CONFIG_STR);
} }
...@@ -100,5 +100,5 @@ ConfigTest::SetUp() { ...@@ -100,5 +100,5 @@ ConfigTest::SetUp() {
void void
ConfigTest::TearDown() { ConfigTest::TearDown() {
std::string config_path(CONFIG_PATH); std::string config_path(CONFIG_PATH);
milvus::server::CommonUtil::DeleteDirectory(config_path); milvus::CommonUtil::DeleteDirectory(config_path);
} }
...@@ -44,7 +44,7 @@ WriteToFile(const std::string& file_path, const char* content) { ...@@ -44,7 +44,7 @@ WriteToFile(const std::string& file_path, const char* content) {
void void
StorageTest::SetUp() { StorageTest::SetUp() {
std::string config_path(CONFIG_PATH); std::string config_path(CONFIG_PATH);
milvus::server::CommonUtil::CreateDirectory(config_path); milvus::CommonUtil::CreateDirectory(config_path);
config_path += CONFIG_FILE; config_path += CONFIG_FILE;
WriteToFile(config_path, CONFIG_STR); WriteToFile(config_path, CONFIG_STR);
...@@ -55,5 +55,5 @@ StorageTest::SetUp() { ...@@ -55,5 +55,5 @@ StorageTest::SetUp() {
void void
StorageTest::TearDown() { StorageTest::TearDown() {
std::string config_path(CONFIG_PATH); std::string config_path(CONFIG_PATH);
milvus::server::CommonUtil::DeleteDirectory(config_path); milvus::CommonUtil::DeleteDirectory(config_path);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册