提交 9d9a453a 编写于 作者: W Wang XiangYu 提交者: JinHai-CN

Upgrade config (#2511)

* enable cron test on 0.10.0
Signed-off-by: Nzw <zw@milvus.io>

* fix merge result
Signed-off-by: Nshengjun.li <shengjun.li@zilliz.com>

* import test_during_creating_index_restart
Signed-off-by: Nzw <zw@milvus.io>

* config cluster
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* config general
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* config network
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* config storage
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* config wal
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* config cache
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* config gpu and metrics
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* config logs
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* update server_config.template
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* update changelog
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* config with unit
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* fix clang-format
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* update unittests
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* disable restart case
Signed-off-by: Nzw <zw@milvus.io>

* fix gpu compile failed
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* Fix lint and comments
Signed-off-by: NJinHai-CN <hai.jin@zilliz.com>

* fix wal unittest failed
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* fix some unittests
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* update config test cases
Signed-off-by: Nzw <zw@milvus.io>

* Fix config error
Signed-off-by: Nyhz <413554850@qq.com>

* remove unused code
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* Update CHANGELOG
Signed-off-by: NJinHai-CN <hai.jin@zilliz.com>

* [skip-ci] fix test cases
Signed-off-by: Nzw <zw@milvus.io>

* fix config storage
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* make -j3 on ci
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* update python test
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* remove unused code
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* fix ut
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* fix ut
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* update status message
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* update
Signed-off-by: Nwxyu <xy.wang@zilliz.com>

* fix set config bug
Signed-off-by: Nwxyu <xy.wang@zilliz.com>
Co-authored-by: Nzw <zw@milvus.io>
Co-authored-by: Nshengjun.li <shengjun.li@zilliz.com>
Co-authored-by: NJinHai-CN <hai.jin@zilliz.com>
Co-authored-by: Nyhz <413554850@qq.com>
上级 2ee3b60e
......@@ -24,12 +24,13 @@ Please mark all change in change log and use the issue from GitHub
## Feature
- \#2363 Update branch version
- \#2510 Upgrade Milvus config
## Improvement
- \#2381 Upgrade FAISS to 1.6.3
- \#2429 Fix Milvus 0.9.1 performance degrade issue
- \#2441 Improve Knowhere code coverage
- \#2466 optimize k-selection implemention of faiss gpu version
- \#2466 Optimize k-selection implemention of faiss gpu version
- \#2489 Add exception throw on mysql meta error
- \#2495 Add creating lock file failure reason.
- \#2516 Improve unit test coverage
......
......@@ -30,7 +30,7 @@ pipeline {
LOWER_BUILD_TYPE = params.BUILD_TYPE.toLowerCase()
SEMVER = "${BRANCH_NAME.contains('/') ? BRANCH_NAME.substring(BRANCH_NAME.lastIndexOf('/') + 1) : BRANCH_NAME}"
PIPELINE_NAME = "milvus-ci"
HELM_BRANCH = "master"
HELM_BRANCH = "0.10.0"
}
stages {
......
此差异已折叠。
此差异已折叠。
......@@ -22,8 +22,9 @@ namespace milvus {
namespace cache {
namespace {
constexpr int64_t unit = 1024 * 1024 * 1024;
}
// constexpr int64_t unit = 1024 * 1024 * 1024;
constexpr int64_t unit = 1;
} // namespace
CpuCacheMgr::CpuCacheMgr() {
// All config values have been checked in Config::ValidateConfig()
......@@ -32,6 +33,8 @@ CpuCacheMgr::CpuCacheMgr() {
int64_t cpu_cache_cap;
config.GetCacheConfigCpuCacheCapacity(cpu_cache_cap);
int64_t cap = cpu_cache_cap * unit;
LOG_SERVER_DEBUG_ << "cpu cache.size: " << cap;
LOG_SERVER_INFO_ << "cpu cache.size: " << cap;
cache_ = std::make_shared<Cache<DataObjPtr>>(cap, 1UL << 32, "[CACHE CPU]");
float cpu_cache_threshold;
......
此差异已折叠。
......@@ -28,55 +28,49 @@ using ConfigCallBackF = std::function<Status(const std::string&)>;
extern const char* CONFIG_NODE_DELIMITER;
extern const char* CONFIG_VERSION;
/* server config */
extern const char* CONFIG_SERVER;
extern const char* CONFIG_SERVER_ADDRESS;
extern const char* CONFIG_SERVER_ADDRESS_DEFAULT;
extern const char* CONFIG_SERVER_PORT;
extern const char* CONFIG_SERVER_PORT_DEFAULT;
extern const char* CONFIG_SERVER_DEPLOY_MODE;
extern const char* CONFIG_SERVER_DEPLOY_MODE_DEFAULT;
extern const char* CONFIG_SERVER_TIME_ZONE;
extern const char* CONFIG_SERVER_TIME_ZONE_DEFAULT;
extern const char* CONFIG_SERVER_WEB_ENABLE;
extern const char* CONFIG_SERVER_WEB_ENABLE_DEFAULT;
extern const char* CONFIG_SERVER_WEB_PORT;
extern const char* CONFIG_SERVER_WEB_PORT_DEFAULT;
/* cluster config */
extern const char* CONFIG_CLUSTER;
extern const char* CONFIG_CLUSTER_ENABLE;
extern const char* CONFIG_CLUSTER_ENABLE_DEFAULT;
extern const char* CONFIG_CLUSTER_ROLE;
extern const char* CONFIG_CLUSTER_ROLE_DEFAULT;
/* general config */
extern const char* CONFIG_GENERAL;
extern const char* CONFIG_GENERAL_TIMEZONE;
extern const char* CONFIG_GENERAL_TIMEZONE_DEFAULT;
extern const char* CONFIG_GENERAL_METAURI;
extern const char* CONFIG_GENERAL_METAURI_DEFAULT;
/* network config */
extern const char* CONFIG_NETWORK;
extern const char* CONFIG_NETWORK_BIND_ADDRESS;
extern const char* CONFIG_NETWORK_BIND_ADDRESS_DEFAULT;
extern const char* CONFIG_NETWORK_BIND_PORT;
extern const char* CONFIG_NETWORK_BIND_PORT_DEFAULT;
extern const char* CONFIG_NETWORK_HTTP_ENABLE;
extern const char* CONFIG_NETWORK_HTTP_ENABLE_DEFAULT;
extern const char* CONFIG_NETWORK_HTTP_PORT;
extern const char* CONFIG_NETWORK_HTTP_PORT_DEFAULT;
/* db config */
extern const char* CONFIG_DB;
extern const char* CONFIG_DB_BACKEND_URL;
extern const char* CONFIG_DB_BACKEND_URL_DEFAULT;
// extern const char* CONFIG_DB_BACKEND_URL;
// extern const char* CONFIG_DB_BACKEND_URL_DEFAULT;
extern const char* CONFIG_DB_ARCHIVE_DISK_THRESHOLD;
extern const char* CONFIG_DB_ARCHIVE_DISK_THRESHOLD_DEFAULT;
extern const char* CONFIG_DB_ARCHIVE_DAYS_THRESHOLD;
extern const char* CONFIG_DB_ARCHIVE_DAYS_THRESHOLD_DEFAULT;
extern const char* CONFIG_DB_PRELOAD_COLLECTION;
extern const char* CONFIG_DB_PRELOAD_COLLECTION_DEFAULT;
extern const char* CONFIG_DB_AUTO_FLUSH_INTERVAL;
extern const char* CONFIG_DB_AUTO_FLUSH_INTERVAL_DEFAULT;
/* storage config */
extern const char* CONFIG_STORAGE;
extern const char* CONFIG_STORAGE_PRIMARY_PATH;
extern const char* CONFIG_STORAGE_PRIMARY_PATH_DEFAULT;
extern const char* CONFIG_STORAGE_SECONDARY_PATH;
extern const char* CONFIG_STORAGE_SECONDARY_PATH_DEFAULT;
extern const char* CONFIG_STORAGE_PATH;
extern const char* CONFIG_STORAGE_PATH_DEFAULT;
extern const char* CONFIG_STORAGE_AUTO_FLUSH_INTERVAL;
extern const char* CONFIG_STORAGE_AUTO_FLUSH_INTERVAL_DEFAULT;
extern const char* CONFIG_STORAGE_FILE_CLEANUP_TIMEOUT;
extern const int64_t CONFIG_STORAGE_FILE_CLEANUP_TIMEOUT_MIN;
extern const int64_t CONFIG_STORAGE_FILE_CLEANUP_TIMEOUT_MAX;
// extern const char* CONFIG_STORAGE_S3_ENABLE;
// extern const char* CONFIG_STORAGE_S3_ENABLE_DEFAULT;
// extern const char* CONFIG_STORAGE_S3_ADDRESS;
// extern const char* CONFIG_STORAGE_S3_ADDRESS_DEFAULT;
// extern const char* CONFIG_STORAGE_S3_PORT;
// extern const char* CONFIG_STORAGE_S3_PORT_DEFAULT;
// extern const char* CONFIG_STORAGE_S3_ACCESS_KEY;
// extern const char* CONFIG_STORAGE_S3_ACCESS_KEY_DEFAULT;
// extern const char* CONFIG_STORAGE_S3_SECRET_KEY;
// extern const char* CONFIG_STORAGE_S3_SECRET_KEY_DEFAULT;
// extern const char* CONFIG_STORAGE_S3_BUCKET;
// extern const char* CONFIG_STORAGE_S3_BUCKET_DEFAULT;
/* cache config */
extern const char* CONFIG_CACHE;
......@@ -88,6 +82,8 @@ extern const char* CONFIG_CACHE_INSERT_BUFFER_SIZE;
extern const char* CONFIG_CACHE_INSERT_BUFFER_SIZE_DEFAULT;
extern const char* CONFIG_CACHE_CACHE_INSERT_DATA;
extern const char* CONFIG_CACHE_CACHE_INSERT_DATA_DEFAULT;
extern const char* CONFIG_CACHE_PRELOAD_COLLECTION;
extern const char* CONFIG_CACHE_PRELOAD_COLLECTION_DEFAULT;
/* metric config */
extern const char* CONFIG_METRIC;
......@@ -106,8 +102,6 @@ extern const char* CONFIG_ENGINE_OMP_THREAD_NUM;
extern const char* CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT;
extern const char* CONFIG_ENGINE_SIMD_TYPE;
extern const char* CONFIG_ENGINE_SIMD_TYPE_DEFAULT;
extern const char* CONFIG_ENGINE_GPU_SEARCH_THRESHOLD;
extern const char* CONFIG_ENGINE_GPU_SEARCH_THRESHOLD_DEFAULT;
/* gpu resource config */
extern const char* CONFIG_GPU_RESOURCE;
......@@ -117,6 +111,8 @@ extern const char* CONFIG_GPU_RESOURCE_CACHE_CAPACITY;
extern const char* CONFIG_GPU_RESOURCE_CACHE_CAPACITY_DEFAULT;
extern const char* CONFIG_GPU_RESOURCE_CACHE_THRESHOLD;
extern const char* CONFIG_GPU_RESOURCE_CACHE_THRESHOLD_DEFAULT;
extern const char* CONFIG_GPU_RESOURCE_GPU_SEARCH_THRESHOLD;
extern const char* CONFIG_GPU_RESOURCE_GPU_SEARCH_THRESHOLD_DEFAULT;
extern const char* CONFIG_GPU_RESOURCE_DELIMITER;
extern const char* CONFIG_GPU_RESOURCE_SEARCH_RESOURCES;
extern const char* CONFIG_GPU_RESOURCE_SEARCH_RESOURCES_DEFAULT;
......@@ -142,18 +138,10 @@ extern const char* CONFIG_WAL_WAL_PATH_DEFAULT;
/* logs config */
extern const char* CONFIG_LOGS;
extern const char* CONFIG_LOGS_LEVEL;
extern const char* CONFIG_LOGS_LEVEL_DEFAULT;
extern const char* CONFIG_LOGS_TRACE_ENABLE;
extern const char* CONFIG_LOGS_TRACE_ENABLE_DEFAULT;
extern const char* CONFIG_LOGS_DEBUG_ENABLE;
extern const char* CONFIG_LOGS_DEBUG_ENABLE_DEFAULT;
extern const char* CONFIG_LOGS_INFO_ENABLE;
extern const char* CONFIG_LOGS_INFO_ENABLE_DEFAULT;
extern const char* CONFIG_LOGS_WARNING_ENABLE;
extern const char* CONFIG_LOGS_WARNING_ENABLE_DEFAULT;
extern const char* CONFIG_LOGS_ERROR_ENABLE;
extern const char* CONFIG_LOGS_ERROR_ENABLE_DEFAULT;
extern const char* CONFIG_LOGS_FATAL_ENABLE;
extern const char* CONFIG_LOGS_FATAL_ENABLE_DEFAULT;
extern const char* CONFIG_LOGS_PATH;
extern const char* CONFIG_LOGS_MAX_LOG_FILE_SIZE;
extern const char* CONFIG_LOGS_MAX_LOG_FILE_SIZE_DEFAULT;
......@@ -215,51 +203,43 @@ class Config {
Status
CheckConfigVersion(const std::string& value);
/* server config */
/* cluster config */
Status
CheckServerConfigAddress(const std::string& value);
CheckClusterConfigEnable(const std::string& value);
Status
CheckServerConfigPort(const std::string& value);
CheckClusterConfigRole(const std::string& value);
/* general config */
Status
CheckServerConfigDeployMode(const std::string& value);
CheckGeneralConfigTimezone(const std::string& value);
Status
CheckServerConfigTimeZone(const std::string& value);
CheckGeneralConfigMetaURI(const std::string& value);
/* network config */
Status
CheckServerConfigWebEnable(const std::string& value);
CheckNetworkConfigBindAddress(const std::string& value);
Status
CheckServerConfigWebPort(const std::string& value);
/* db config */
CheckNetworkConfigBindPort(const std::string& value);
Status
CheckDBConfigBackendUrl(const std::string& value);
CheckNetworkConfigHTTPEnable(const std::string& value);
Status
CheckDBConfigPreloadCollection(const std::string& value);
CheckNetworkConfigHTTPPort(const std::string& value);
/* db config */
// Status
// CheckDBConfigBackendUrl(const std::string& value);
Status
CheckDBConfigArchiveDiskThreshold(const std::string& value);
Status
CheckDBConfigArchiveDaysThreshold(const std::string& value);
Status
CheckDBConfigAutoFlushInterval(const std::string& value);
/* storage config */
Status
CheckStorageConfigPrimaryPath(const std::string& value);
CheckStorageConfigPath(const std::string& value);
Status
CheckStorageConfigSecondaryPath(const std::string& value);
CheckStorageConfigAutoFlushInterval(const std::string& value);
Status
CheckStorageConfigFileCleanupTimeout(const std::string& value);
// Status
// CheckStorageConfigS3Enable(const std::string& value);
// Status
// CheckStorageConfigS3Address(const std::string& value);
// Status
// CheckStorageConfigS3Port(const std::string& value);
// Status
// CheckStorageConfigS3AccessKey(const std::string& value);
// Status
// CheckStorageConfigS3SecretKey(const std::string& value);
// Status
// CheckStorageConfigS3Bucket(const std::string& value);
/* metric config */
Status
......@@ -278,6 +258,8 @@ class Config {
CheckCacheConfigInsertBufferSize(const std::string& value);
Status
CheckCacheConfigCacheInsertData(const std::string& value);
Status
CheckCacheConfigPreloadCollection(const std::string& value);
/* engine config */
Status
......@@ -288,9 +270,6 @@ class Config {
CheckEngineConfigSimdType(const std::string& value);
#ifdef MILVUS_GPU_VERSION
Status
CheckEngineConfigGpuSearchThreshold(const std::string& value);
/* gpu resource config */
Status
CheckGpuResourceConfigEnable(const std::string& value);
......@@ -299,6 +278,8 @@ class Config {
Status
CheckGpuResourceConfigCacheThreshold(const std::string& value);
Status
CheckGpuResourceConfigGpuSearchThreshold(const std::string& value);
Status
CheckGpuResourceConfigSearchResources(const std::vector<std::string>& value);
Status
CheckGpuResourceConfigBuildIndexResources(const std::vector<std::string>& value);
......@@ -320,17 +301,9 @@ class Config {
/* logs config */
Status
CheckLogsTraceEnable(const std::string& value);
Status
CheckLogsDebugEnable(const std::string& value);
Status
CheckLogsInfoEnable(const std::string& value);
Status
CheckLogsWarningEnable(const std::string& value);
Status
CheckLogsErrorEnable(const std::string& value);
CheckLogsLevel(const std::string& level);
Status
CheckLogsFatalEnable(const std::string& value);
CheckLogsTraceEnable(const std::string& value);
Status
CheckLogsPath(const std::string& value);
Status
......@@ -350,51 +323,43 @@ class Config {
ExecCallBacks(const std::string& node, const std::string& sub_node, const std::string& value);
public:
/* server config */
/* cluster config */
Status
GetClusterConfigEnable(bool& value);
Status
GetClusterConfigRole(std::string& value);
/* general config */
Status
GetServerConfigAddress(std::string& value);
GetGeneralConfigTimezone(std::string& value);
Status
GetServerConfigPort(std::string& value);
GetGeneralConfigMetaURI(std::string& value);
/* network config */
Status
GetServerConfigDeployMode(std::string& value);
GetNetworkConfigBindAddress(std::string& value);
Status
GetServerConfigTimeZone(std::string& value);
GetNetworkConfigBindPort(std::string& value);
Status
GetServerConfigWebEnable(bool& value);
GetNetworkConfigHTTPEnable(bool& value);
Status
GetServerConfigWebPort(std::string& value);
GetNetworkConfigHTTPPort(std::string& value);
/* db config */
Status
GetDBConfigBackendUrl(std::string& value);
// Status
// GetDBConfigBackendUrl(std::string& value);
Status
GetDBConfigArchiveDiskThreshold(int64_t& value);
Status
GetDBConfigArchiveDaysThreshold(int64_t& value);
Status
GetDBConfigPreloadCollection(std::string& value);
Status
GetDBConfigAutoFlushInterval(int64_t& value);
/* storage config */
Status
GetStorageConfigPrimaryPath(std::string& value);
GetStorageConfigPath(std::string& value);
Status
GetStorageConfigSecondaryPath(std::string& value);
GetStorageConfigAutoFlushInterval(int64_t& value);
Status
GetStorageConfigFileCleanupTimeup(int64_t& value);
// Status
// GetStorageConfigS3Enable(bool& value);
// Status
// GetStorageConfigS3Address(std::string& value);
// Status
// GetStorageConfigS3Port(std::string& value);
// Status
// GetStorageConfigS3AccessKey(std::string& value);
// Status
// GetStorageConfigS3SecretKey(std::string& value);
// Status
// GetStorageConfigS3Bucket(std::string& value);
/* metric config */
Status
......@@ -413,6 +378,8 @@ class Config {
GetCacheConfigInsertBufferSize(int64_t& value);
Status
GetCacheConfigCacheInsertData(bool& value);
Status
GetCacheConfigPreloadCollection(std::string& value);
/* engine config */
Status
......@@ -423,9 +390,6 @@ class Config {
GetEngineConfigSimdType(std::string& value);
#ifdef MILVUS_GPU_VERSION
Status
GetEngineConfigGpuSearchThreshold(int64_t& value);
/* gpu resource config */
Status
GetGpuResourceConfigEnable(bool& value);
......@@ -434,6 +398,8 @@ class Config {
Status
GetGpuResourceConfigCacheThreshold(float& value);
Status
GetGpuResourceConfigGpuSearchThreshold(int64_t& value);
Status
GetGpuResourceConfigSearchResources(std::vector<int64_t>& value);
Status
GetGpuResourceConfigBuildIndexResources(std::vector<int64_t>& value);
......@@ -455,17 +421,9 @@ class Config {
/* logs config */
Status
GetLogsTraceEnable(bool& value);
Status
GetLogsDebugEnable(bool& value);
Status
GetLogsInfoEnable(bool& value);
GetLogsLevel(std::string& value);
Status
GetLogsWarningEnable(bool& value);
Status
GetLogsErrorEnable(bool& value);
Status
GetLogsFatalEnable(bool& value);
GetLogsTraceEnable(bool& value);
Status
GetLogsPath(std::string& value);
Status
......@@ -477,51 +435,43 @@ class Config {
GetServerRestartRequired(bool& required);
public:
/* server config */
/* cluster config */
Status
SetServerConfigAddress(const std::string& value);
SetClusterConfigEnable(const std::string& value);
Status
SetServerConfigPort(const std::string& value);
SetClusterConfigRole(const std::string& value);
/* general config */
Status
SetServerConfigDeployMode(const std::string& value);
SetGeneralConfigTimezone(const std::string& value);
Status
SetServerConfigTimeZone(const std::string& value);
SetGeneralConfigMetaURI(const std::string& value);
/* network config */
Status
SetServerConfigWebEnable(const std::string& value);
SetNetworkConfigBindAddress(const std::string& value);
Status
SetServerConfigWebPort(const std::string& value);
/* db config */
SetNetworkConfigBindPort(const std::string& value);
Status
SetDBConfigBackendUrl(const std::string& value);
SetNetworkConfigHTTPEnable(const std::string& value);
Status
SetDBConfigPreloadCollection(const std::string& value);
SetNetworkConfigHTTPPort(const std::string& value);
/* db config */
// Status
// SetDBConfigBackendUrl(const std::string& value);
Status
SetDBConfigArchiveDiskThreshold(const std::string& value);
Status
SetDBConfigArchiveDaysThreshold(const std::string& value);
Status
SetDBConfigAutoFlushInterval(const std::string& value);
/* storage config */
Status
SetStorageConfigPrimaryPath(const std::string& value);
SetStorageConfigPath(const std::string& value);
Status
SetStorageConfigSecondaryPath(const std::string& value);
SetStorageConfigAutoFlushInterval(const std::string& value);
Status
SetStorageConfigFileCleanupTimeout(const std::string& value);
// Status
// SetStorageConfigS3Enable(const std::string& value);
// Status
// SetStorageConfigS3Address(const std::string& value);
// Status
// SetStorageConfigS3Port(const std::string& value);
// Status
// SetStorageConfigS3AccessKey(const std::string& value);
// Status
// SetStorageConfigS3SecretKey(const std::string& value);
// Status
// SetStorageConfigS3Bucket(const std::string& value);
/* metric config */
Status
......@@ -540,6 +490,8 @@ class Config {
SetCacheConfigInsertBufferSize(const std::string& value);
Status
SetCacheConfigCacheInsertData(const std::string& value);
Status
SetCacheConfigPreloadCollection(const std::string& value);
/* engine config */
Status
......@@ -549,8 +501,6 @@ class Config {
Status
SetEngineConfigSimdType(const std::string& value);
#ifdef MILVUS_GPU_VERSION
Status
SetEngineConfigGpuSearchThreshold(const std::string& value);
/* gpu resource config */
Status
......@@ -560,6 +510,8 @@ class Config {
Status
SetGpuResourceConfigCacheThreshold(const std::string& value);
Status
SetGpuResourceConfigGpuSearchThreshold(const std::string& value);
Status
SetGpuResourceConfigSearchResources(const std::string& value);
Status
SetGpuResourceConfigBuildIndexResources(const std::string& value);
......@@ -581,17 +533,9 @@ class Config {
/* logs config */
Status
SetLogsTraceEnable(const std::string& value);
Status
SetLogsDebugEnable(const std::string& value);
SetLogsLevel(const std::string& value);
Status
SetLogsInfoEnable(const std::string& value);
Status
SetLogsWarningEnable(const std::string& value);
Status
SetLogsErrorEnable(const std::string& value);
Status
SetLogsFatalEnable(const std::string& value);
SetLogsTraceEnable(const std::string& value);
Status
SetLogsPath(const std::string& value);
Status
......
// 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.
#include "config/Utils.h"
#include <algorithm>
#include <sstream>
#include <unordered_map>
namespace milvus {
namespace server {
std::unordered_map<std::string, int64_t> BYTE_UNITS = {
{"b", 1},
{"k", 1024},
{"m", 1024 * 1024},
{"g", 1024 * 1024 * 1024},
};
bool
is_number(const std::string& s) {
return !s.empty() && std::find_if(s.begin(), s.end(), [](unsigned char c) { return !std::isdigit(c); }) == s.end();
}
bool
is_alpha(const std::string& s) {
return !s.empty() && std::find_if(s.begin(), s.end(), [](unsigned char c) { return !std::isalpha(c); }) == s.end();
}
std::string
str_tolower(std::string s) {
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::tolower(c); });
return s;
}
int64_t
parse_bytes(const std::string& str, std::string& err) {
try {
std::string s = str;
if (is_number(s))
return std::stoll(s);
if (s.length() == 0)
return 0;
auto last_two = s.substr(s.length() - 2, 2);
auto last_one = s.substr(s.length() - 1);
if (is_alpha(last_two) && is_alpha(last_one))
if (last_one == "b" or last_one == "B")
s = s.substr(0, s.length() - 1);
auto& units = BYTE_UNITS;
auto suffix = str_tolower(s.substr(s.length() - 1));
std::string digits_part;
if (is_number(suffix)) {
digits_part = s;
suffix = 'b';
} else {
digits_part = s.substr(0, s.length() - 1);
}
if (units.find(suffix) != units.end() or is_number(suffix)) {
auto digits = std::stoll(digits_part);
return digits * units[suffix];
} else {
std::stringstream ss;
ss << "The specified value for memory (" << str << ") should specify the units."
<< "The postfix should be one of the `b` `k` `m` `g` characters";
err = ss.str();
}
} catch (...) {
err = "Unknown error happened on parse bytes.";
}
return 0;
}
} // namespace server
} // namespace milvus
// 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
#include <string>
namespace milvus {
namespace server {
int64_t
parse_bytes(const std::string& str, std::string& err);
} // namespace server
} // namespace milvus
......@@ -94,19 +94,20 @@ GpuResourceConfigHandler::AddGpuSearchThresholdListener() {
ConfigCallBackF lambda_gpu_threshold = [this](const std::string& value) -> Status {
if (!gpu_enable_) {
std::string msg =
std::string("GPU resources is disable. Cannot set config ") + CONFIG_ENGINE_GPU_SEARCH_THRESHOLD;
std::string("GPU resources is disabled. Cannot set config ") + CONFIG_GPU_RESOURCE_GPU_SEARCH_THRESHOLD;
return Status(SERVER_UNEXPECTED_ERROR, msg);
}
auto& config = Config::GetInstance();
auto status = config.GetEngineConfigGpuSearchThreshold(threshold_);
auto status = config.GetGpuResourceConfigGpuSearchThreshold(threshold_);
if (status.ok()) {
OnGpuSearchThresholdChanged(threshold_);
}
return status;
};
config.RegisterCallBack(CONFIG_ENGINE, CONFIG_ENGINE_GPU_SEARCH_THRESHOLD, identity_, lambda_gpu_threshold);
config.RegisterCallBack(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_GPU_SEARCH_THRESHOLD, identity_,
lambda_gpu_threshold);
}
void
......@@ -152,7 +153,7 @@ GpuResourceConfigHandler::RemoveGpuBuildResourcesListener() {
void
GpuResourceConfigHandler::RemoveGpuSearchThresholdListener() {
auto& config = Config::GetInstance();
config.CancelCallBack(CONFIG_ENGINE, CONFIG_ENGINE_GPU_SEARCH_THRESHOLD, identity_);
config.CancelCallBack(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_GPU_SEARCH_THRESHOLD, identity_);
}
void
......
......@@ -48,6 +48,7 @@ MetaFactory::Build(const DBMetaOptions& meta_options, const int& mode) {
std::string uri = meta_options.backend_uri_;
utils::MetaUriInfo uri_info;
LOG_ENGINE_DEBUG_ << "MetaUri: " << uri << std::endl;
auto status = utils::ParseMetaUri(uri, uri_info);
if (!status.ok()) {
LOG_ENGINE_ERROR_ << "Wrong URI format: URI = " << uri;
......
......@@ -27,6 +27,7 @@ using TableSchemaPtr = std::shared_ptr<milvus::engine::meta::CollectionSchema>;
using TableMetaPtr = std::shared_ptr<std::unordered_map<std::string, TableSchemaPtr>>;
#define UNIT_MB (1024 * 1024)
#define UNIT_B 1
#define LSN_OFFSET_MASK 0x00000000ffffffff
enum class MXLogType { None, InsertBinary, InsertVector, Delete, Update, Flush, Entity };
......
......@@ -33,7 +33,7 @@ PrometheusMetrics::Init() {
// Following should be read from config file.
std::string server_port, push_port, push_address;
STATUS_CHECK(config.GetServerConfigPort(server_port));
STATUS_CHECK(config.GetNetworkConfigBindPort(server_port));
STATUS_CHECK(config.GetMetricConfigPort(push_port));
STATUS_CHECK(config.GetMetricConfigAddress(push_address));
......
......@@ -106,7 +106,7 @@ class OptimizerInst {
int64_t gpu_search_threshold;
config.GetGpuResourceConfigBuildIndexResources(build_gpus);
config.GetGpuResourceConfigSearchResources(search_gpus);
config.GetEngineConfigGpuSearchThreshold(gpu_search_threshold);
config.GetGpuResourceConfigGpuSearchThreshold(gpu_search_threshold);
std::string build_msg = "Build index gpu:";
for (auto build_id : build_gpus) {
build_msg.append(" gpu" + std::to_string(build_id));
......
......@@ -25,7 +25,7 @@ namespace scheduler {
void
FaissFlatPass::Init() {
server::Config& config = server::Config::GetInstance();
Status s = config.GetEngineConfigGpuSearchThreshold(threshold_);
Status s = config.GetGpuResourceConfigGpuSearchThreshold(threshold_);
if (!s.ok()) {
threshold_ = std::numeric_limits<int32_t>::max();
}
......
......@@ -25,7 +25,7 @@ void
FaissIVFFlatPass::Init() {
#ifdef MILVUS_GPU_VERSION
server::Config& config = server::Config::GetInstance();
Status s = config.GetEngineConfigGpuSearchThreshold(threshold_);
Status s = config.GetGpuResourceConfigGpuSearchThreshold(threshold_);
if (!s.ok()) {
threshold_ = std::numeric_limits<int32_t>::max();
}
......
......@@ -27,7 +27,7 @@ void
FaissIVFPQPass::Init() {
#ifdef MILVUS_GPU_VERSION
server::Config& config = server::Config::GetInstance();
Status s = config.GetEngineConfigGpuSearchThreshold(threshold_);
Status s = config.GetGpuResourceConfigGpuSearchThreshold(threshold_);
if (!s.ok()) {
threshold_ = std::numeric_limits<int32_t>::max();
}
......
......@@ -25,7 +25,7 @@ namespace scheduler {
void
FaissIVFSQ8HPass::Init() {
server::Config& config = server::Config::GetInstance();
Status s = config.GetEngineConfigGpuSearchThreshold(threshold_);
Status s = config.GetGpuResourceConfigGpuSearchThreshold(threshold_);
if (!s.ok()) {
threshold_ = std::numeric_limits<int64_t>::max();
}
......
......@@ -25,7 +25,7 @@ void
FaissIVFSQ8Pass::Init() {
#ifdef MILVUS_GPU_VERSION
server::Config& config = server::Config::GetInstance();
Status s = config.GetEngineConfigGpuSearchThreshold(threshold_);
Status s = config.GetGpuResourceConfigGpuSearchThreshold(threshold_);
if (!s.ok()) {
threshold_ = std::numeric_limits<int32_t>::max();
}
......
......@@ -34,36 +34,26 @@ DBWrapper::StartService() {
// db config
engine::DBOptions opt;
s = config.GetDBConfigBackendUrl(opt.meta_.backend_uri_);
if (!s.ok()) {
std::cerr << s.ToString() << std::endl;
return s;
}
s = config.GetDBConfigAutoFlushInterval(opt.auto_flush_interval_);
s = config.GetGeneralConfigMetaURI(opt.meta_.backend_uri_);
if (!s.ok()) {
std::cerr << s.ToString() << std::endl;
return s;
}
std::string path;
s = config.GetStorageConfigPrimaryPath(path);
s = config.GetStorageConfigPath(path);
if (!s.ok()) {
std::cerr << s.ToString() << std::endl;
return s;
}
opt.meta_.path_ = path + "/db";
std::string db_slave_path;
s = config.GetStorageConfigSecondaryPath(db_slave_path);
s = config.GetStorageConfigAutoFlushInterval(opt.auto_flush_interval_);
if (!s.ok()) {
std::cerr << s.ToString() << std::endl;
return s;
}
StringHelpFunctions::SplitStringByDelimeter(db_slave_path, ";", opt.meta_.slave_paths_);
s = config.GetStorageConfigFileCleanupTimeup(opt.file_cleanup_timeout_);
if (!s.ok()) {
std::cerr << s.ToString() << std::endl;
......@@ -90,8 +80,25 @@ DBWrapper::StartService() {
std::cerr << s.ToString() << std::endl;
return s;
}
opt.insert_buffer_size_ = insert_buffer_size * engine::GB;
opt.insert_buffer_size_ = insert_buffer_size;
#if 1
bool cluster_enable = false;
std::string cluster_role;
STATUS_CHECK(config.GetClusterConfigEnable(cluster_enable));
STATUS_CHECK(config.GetClusterConfigRole(cluster_role));
if (not cluster_enable) {
opt.mode_ = engine::DBOptions::MODE::SINGLE;
} else if (cluster_role == "ro") {
opt.mode_ = engine::DBOptions::MODE::CLUSTER_READONLY;
} else if (cluster_role == "rw") {
opt.mode_ = engine::DBOptions::MODE::CLUSTER_WRITABLE;
} else {
std::cerr << "Error: cluster.role is not one of rw and ro." << std::endl;
kill(0, SIGUSR1);
}
#else
std::string mode;
s = config.GetServerConfigDeployMode(mode);
if (!s.ok()) {
......@@ -110,6 +117,7 @@ DBWrapper::StartService() {
<< "single, cluster_readonly, and cluster_writable." << std::endl;
kill(0, SIGUSR1);
}
#endif
// get wal configurations
s = config.GetWalConfigEnable(opt.wal_enable_);
......@@ -127,12 +135,15 @@ DBWrapper::StartService() {
kill(0, SIGUSR1);
}
s = config.GetWalConfigBufferSize(opt.buffer_size_);
int64_t wal_buffer_size = 0;
s = config.GetWalConfigBufferSize(wal_buffer_size);
if (!s.ok()) {
std::cerr << "ERROR! Failed to get buffer_size configuration." << std::endl;
std::cerr << s.ToString() << std::endl;
kill(0, SIGUSR1);
}
wal_buffer_size /= (1024 * 1024);
opt.buffer_size_ = wal_buffer_size;
s = config.GetWalConfigWalPath(opt.mxlog_path_);
if (!s.ok()) {
......@@ -227,7 +238,7 @@ DBWrapper::StartService() {
// preload collection
std::string preload_collections;
s = config.GetDBConfigPreloadCollection(preload_collections);
s = config.GetCacheConfigPreloadCollection(preload_collections);
if (!s.ok()) {
std::cerr << s.ToString() << std::endl;
return s;
......
......@@ -16,6 +16,7 @@
#include <unistd.h>
#include <boost/filesystem.hpp>
#include <cstring>
#include <unordered_map>
#include "config/Config.h"
#include "index/archive/KnowhereResource.h"
......@@ -154,7 +155,7 @@ Server::Start() {
Config& config = Config::GetInstance();
std::string meta_uri;
STATUS_CHECK(config.GetDBConfigBackendUrl(meta_uri));
STATUS_CHECK(config.GetGeneralConfigMetaURI(meta_uri));
if (meta_uri.length() > 6 && strcasecmp("sqlite", meta_uri.substr(0, 6).c_str()) == 0) {
std::cout << "WARNNING: You are using SQLite as the meta data management, "
"which can't be used in production. Please change it to MySQL!"
......@@ -169,7 +170,7 @@ Server::Start() {
/* log path is defined in Config file, so InitLog must be called after LoadConfig */
std::string time_zone;
s = config.GetServerConfigTimeZone(time_zone);
s = config.GetGeneralConfigTimezone(time_zone);
if (!s.ok()) {
std::cerr << "Fail to get server config timezone" << std::endl;
return s;
......@@ -194,6 +195,11 @@ Server::Start() {
tzset();
{
std::unordered_map<std::string, int64_t> level_to_int{
{"debug", 5}, {"info", 4}, {"warning", 3}, {"error", 2}, {"fatal", 1},
};
std::string level;
bool trace_enable = false;
bool debug_enable = false;
bool info_enable = false;
......@@ -203,12 +209,25 @@ Server::Start() {
std::string logs_path;
int64_t max_log_file_size = 0;
int64_t delete_exceeds = 0;
STATUS_CHECK(config.GetLogsLevel(level));
switch (level_to_int[level]) {
case 5:
debug_enable = true;
case 4:
info_enable = true;
case 3:
warning_enable = true;
case 2:
error_enable = true;
case 1:
fatal_enable = true;
break;
default:
return Status(SERVER_UNEXPECTED_ERROR, "invalid log level");
}
STATUS_CHECK(config.GetLogsTraceEnable(trace_enable));
STATUS_CHECK(config.GetLogsDebugEnable(debug_enable));
STATUS_CHECK(config.GetLogsInfoEnable(info_enable));
STATUS_CHECK(config.GetLogsWarningEnable(warning_enable));
STATUS_CHECK(config.GetLogsErrorEnable(error_enable));
STATUS_CHECK(config.GetLogsFatalEnable(fatal_enable));
STATUS_CHECK(config.GetLogsPath(logs_path));
STATUS_CHECK(config.GetLogsMaxLogFileSize(max_log_file_size));
STATUS_CHECK(config.GetLogsLogRotateNum(delete_exceeds));
......@@ -216,12 +235,18 @@ Server::Start() {
max_log_file_size, delete_exceeds);
}
std::string deploy_mode;
STATUS_CHECK(config.GetServerConfigDeployMode(deploy_mode));
bool cluster_enable = false;
std::string cluster_role;
STATUS_CHECK(config.GetClusterConfigEnable(cluster_enable));
STATUS_CHECK(config.GetClusterConfigRole(cluster_role));
// std::string deploy_mode;
// STATUS_CHECK(config.GetServerConfigDeployMode(deploy_mode));
if (deploy_mode == "single" || deploy_mode == "cluster_writable") {
// if (deploy_mode == "single" || deploy_mode == "cluster_writable") {
if ((not cluster_enable) || cluster_role == "rw") {
std::string db_path;
STATUS_CHECK(config.GetStorageConfigPrimaryPath(db_path));
STATUS_CHECK(config.GetStorageConfigPath(db_path));
try {
// True if a new directory was created, otherwise false.
......@@ -232,7 +257,11 @@ Server::Start() {
s = InstanceLockCheck::Check(db_path);
if (!s.ok()) {
std::cerr << "deploy_mode: " << deploy_mode << " instance lock db path failed." << std::endl;
if (not cluster_enable) {
std::cerr << "single instance lock db path failed." << s.message() << std::endl;
} else {
std::cerr << cluster_role << " instance lock db path failed." << s.message() << std::endl;
}
return s;
}
......@@ -251,7 +280,11 @@ Server::Start() {
}
s = InstanceLockCheck::Check(wal_path);
if (!s.ok()) {
std::cerr << "deploy_mode: " << deploy_mode << " instance lock wal path failed." << std::endl;
if (not cluster_enable) {
std::cerr << "single instance lock wal path failed." << s.message() << std::endl;
} else {
std::cerr << cluster_role << " instance lock wal path failed." << s.message() << std::endl;
}
return s;
}
}
......
......@@ -37,6 +37,17 @@ Status
ReLoadSegmentsRequest::OnExecute() {
auto& config = Config::GetInstance();
#if 1
bool cluster_enable = false;
std::string cluster_role;
STATUS_CHECK(config.GetClusterConfigEnable(cluster_enable));
STATUS_CHECK(config.GetClusterConfigRole(cluster_role));
if ((not cluster_enable) || cluster_role == "rw") {
// TODO: No need to reload segment files
return Status(SERVER_SUCCESS, "");
}
#else
std::string deploy_mode;
auto status = config.GetServerConfigDeployMode(deploy_mode);
if (!status.ok()) {
......@@ -48,6 +59,7 @@ ReLoadSegmentsRequest::OnExecute() {
// TODO: No need to reload segment files
return Status(SERVER_SUCCESS, "");
}
#endif
try {
std::string hdr = "ReloadSegmentsRequest(collection=" + collection_name_ + ")";
......
......@@ -77,8 +77,8 @@ GrpcServer::StartService() {
Config& config = Config::GetInstance();
std::string address, port;
STATUS_CHECK(config.GetServerConfigAddress(address));
STATUS_CHECK(config.GetServerConfigPort(port));
STATUS_CHECK(config.GetNetworkConfigBindAddress(address));
STATUS_CHECK(config.GetNetworkConfigBindPort(port));
std::string server_address(address + ":" + port);
......
......@@ -44,6 +44,16 @@ StorageChecker::CheckStoragePermission() {
return Status(SERVER_UNEXPECTED_ERROR, err_msg);
}
#if 1
bool cluster_enable = false;
std::string cluster_role;
STATUS_CHECK(config.GetClusterConfigEnable(cluster_enable));
STATUS_CHECK(config.GetClusterConfigRole(cluster_role));
if (cluster_enable && cluster_role == "ro") {
return Status::OK();
}
#else
std::string deploy_mode;
status = config.GetServerConfigDeployMode(deploy_mode);
if (!status.ok()) {
......@@ -53,10 +63,11 @@ StorageChecker::CheckStoragePermission() {
if (deploy_mode == "cluster_readonly") {
return Status::OK();
}
#endif
/* Check db directory write permission */
std::string primary_path;
status = config.GetStorageConfigPrimaryPath(primary_path);
status = config.GetStorageConfigPath(primary_path);
if (!status.ok()) {
return status;
}
......@@ -64,35 +75,13 @@ StorageChecker::CheckStoragePermission() {
ret = access(primary_path.c_str(), F_OK | R_OK | W_OK);
fiu_do_on("StorageChecker.CheckStoragePermission.db_primary_path_access_fail", ret = -1);
if (0 != ret) {
std::string err_msg = " Access DB storage primary path " + primary_path + " fail. " + strerror(errno) +
std::string err_msg = " Access DB storage path " + primary_path + " fail. " + strerror(errno) +
"(code: " + std::to_string(errno) + ")";
LOG_SERVER_FATAL_ << err_msg;
std::cerr << err_msg << std::endl;
return Status(SERVER_UNEXPECTED_ERROR, err_msg);
}
std::string secondary_paths;
status = config.GetStorageConfigSecondaryPath(secondary_paths);
if (!status.ok()) {
return status;
}
if (!secondary_paths.empty()) {
std::vector<std::string> secondary_path_vector;
StringHelpFunctions::SplitStringByDelimeter(secondary_paths, ",", secondary_path_vector);
for (auto& path : secondary_path_vector) {
ret = access(path.c_str(), F_OK | R_OK | W_OK);
fiu_do_on("StorageChecker.CheckStoragePermission.db_secondary_path_access_fail", ret = -1);
if (0 != ret) {
std::string err_msg = " Access DB storage secondary path " + path + " fail. " + strerror(errno) +
"(code: " + std::to_string(errno) + ")";
LOG_SERVER_FATAL_ << err_msg;
std::cerr << err_msg << std::endl;
return Status(SERVER_UNEXPECTED_ERROR, err_msg);
}
}
}
/* Check wal directory write permission */
bool wal_enable = false;
status = config.GetWalConfigEnable(wal_enable);
......
......@@ -24,7 +24,7 @@ void
WebServer::Start() {
auto& config = Config::GetInstance();
bool enable = true;
config.GetServerConfigWebEnable(enable);
config.GetNetworkConfigHTTPEnable(enable);
if (enable && nullptr == thread_ptr_) {
thread_ptr_ = std::make_shared<std::thread>(&WebServer::StartService, this);
}
......@@ -47,7 +47,7 @@ WebServer::StartService() {
Config& config = Config::GetInstance();
std::string port;
STATUS_CHECK(config.GetServerConfigWebPort(port));
STATUS_CHECK(config.GetNetworkConfigHTTPPort(port));
{
AppComponent components = AppComponent(std::stoi(port));
......
......@@ -1019,7 +1019,7 @@ WebRequestHandler::GetAdvancedConfig(AdvancedConfigDto::ObjectWrapper& advanced_
advanced_config->use_blas_threshold = std::stol(reply);
#ifdef MILVUS_GPU_VERSION
engine_cmd_string = engine_cmd_prefix + std::string(CONFIG_ENGINE_GPU_SEARCH_THRESHOLD);
engine_cmd_string = engine_cmd_prefix + std::string(CONFIG_GPU_RESOURCE_GPU_SEARCH_THRESHOLD);
CommandLine(engine_cmd_string, reply);
if (!status.ok()) {
ASSIGN_RETURN_STATUS_DTO(status)
......@@ -1077,9 +1077,10 @@ WebRequestHandler::SetAdvancedConfig(const AdvancedConfigDto::ObjectWrapper& adv
}
#ifdef MILVUS_GPU_VERSION
engine_cmd_string = engine_cmd_prefix + std::string(CONFIG_ENGINE_GPU_SEARCH_THRESHOLD) + " " +
std::to_string(advanced_config->gpu_search_threshold->getValue());
status = CommandLine(engine_cmd_string, reply);
auto gpu_cmd_prefix = "set_config " + std::string(CONFIG_GPU_RESOURCE) + ".";
auto gpu_cmd_string = gpu_cmd_prefix + std::string(CONFIG_GPU_RESOURCE_GPU_SEARCH_THRESHOLD) + " " +
std::to_string(advanced_config->gpu_search_threshold->getValue());
status = CommandLine(gpu_cmd_string, reply);
if (!status.ok()) {
ASSIGN_RETURN_STATUS_DTO(status)
}
......
......@@ -199,7 +199,6 @@ InitLog(bool trace_enable, bool debug_enable, bool info_enable, bool warning_ena
std::to_string(CONFIG_LOGS_MAX_LOG_FILE_SIZE_MAX) + "], now is " +
std::to_string(max_log_file_size));
}
max_log_file_size *= 1024 * 1024;
defaultConf.setGlobally(el::ConfigurationType::MaxLogFileSize, std::to_string(max_log_file_size));
el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);
el::Helpers::installPreRollOutCallback(RolloutHandler);
......
......@@ -31,6 +31,7 @@
#include <cmath>
#include <limits>
#include <regex>
#include <set>
#include <string>
namespace milvus {
......@@ -651,6 +652,15 @@ ValidationUtil::ValidateStoragePath(const std::string& path) {
return std::regex_match(path, regex) ? Status::OK() : Status(SERVER_INVALID_ARGUMENT, "Invalid file path");
}
Status
ValidationUtil::ValidateLogLevel(const std::string& level) {
std::set<std::string> supported_level{"debug", "info", "warning", "error", "fatal"};
return supported_level.find(level) != supported_level.end()
? Status::OK()
: Status(SERVER_INVALID_ARGUMENT, "Log level must be one of debug, info, warning, error and fatal.");
}
bool
ValidationUtil::IsNumber(const std::string& s) {
return !s.empty() && std::all_of(s.begin(), s.end(), ::isdigit);
......
......@@ -93,6 +93,9 @@ class ValidationUtil {
static Status
ValidateStoragePath(const std::string& path);
static Status
ValidateLogLevel(const std::string& level);
static bool
IsNumber(const std::string& s);
};
......
......@@ -42,6 +42,60 @@ INITIALIZE_EASYLOGGINGPP
namespace {
static const char* CONFIG_STR =
"version: 0.5\n"
"\n"
"cluster:\n"
" enable: false\n"
" role: rw\n"
"\n"
"general:\n"
" timezone: UTC+8\n"
" meta_uri: sqlite://:@:/\n"
"\n"
"network:\n"
" bind.address: 0.0.0.0\n"
" bind.port: 19530\n"
" http.enable: true\n"
" http.port: 19121\n"
"\n"
"storage:\n"
" path: /tmp/milvus\n"
" auto_flush_interval: 1\n"
"\n"
"wal:\n"
" enable: true\n"
" recovery_error_ignore: false\n"
" buffer_size: 256MB\n"
" path: /tmp/milvus/wal\n"
"\n"
"cache:\n"
" cache_size: 4GB\n"
" insert_buffer_size: 1GB\n"
" preload_collection:\n"
"\n"
"gpu:\n"
" enable: true\n"
" cache_size: 1GB\n"
" gpu_search_threshold: 1000\n"
" search_devices:\n"
" - gpu0\n"
" build_index_devices:\n"
" - gpu0\n"
"\n"
"logs:\n"
" level: debug\n"
" trace.enable: true\n"
" path: /tmp/milvus/logs\n"
" max_log_file_size: 1024MB\n"
" log_rotate_num: 0\n"
"\n"
"metric:\n"
" enable: false\n"
" address: 127.0.0.1\n"
" port: 9091\n"
"\n";
/*static const char* CONFIG_STR =
"version: 0.4\n"
"server_config:\n"
" address: 0.0.0.0\n"
......@@ -103,6 +157,7 @@ static const char* CONFIG_STR =
" max_log_file_size: 256\n"
" delete_exceeds: 10\n"
"";
*/
void
WriteToFile(const std::string &file_path, const char *content) {
......
......@@ -37,11 +37,7 @@ class ServerCheckerTest : public testing::Test {
db_primary_path = "/tmp/milvus-test/db";
boost::filesystem::create_directories(db_primary_path);
config.SetStorageConfigPrimaryPath(db_primary_path);
db_secondary_path = "/tmp/milvus-test/db-secondary";
boost::filesystem::create_directories(db_secondary_path);
config.SetStorageConfigSecondaryPath(db_secondary_path);
config.SetStorageConfigPath(db_primary_path);
wal_path = "/tmp/milvus-test/wal";
boost::filesystem::create_directories(wal_path);
......@@ -77,15 +73,6 @@ TEST_F(ServerCheckerTest, STORAGE_FAIL_TEST) {
ASSERT_FALSE(ms::StorageChecker::CheckStoragePermission().ok());
fiu_disable("StorageChecker.CheckStoragePermission.db_primary_path_access_fail");
auto& config = ms::Config::GetInstance();
std::string storage_secondary_path;
ASSERT_TRUE(config.GetStorageConfigSecondaryPath(storage_secondary_path).ok());
ASSERT_TRUE(config.SetStorageConfigSecondaryPath("/tmp/milvus-test01,/tmp/milvus-test02").ok());
fiu_enable("StorageChecker.CheckStoragePermission.db_secondary_path_access_fail", 1, NULL, 0);
ASSERT_FALSE(ms::StorageChecker::CheckStoragePermission().ok());
fiu_disable("StorageChecker.CheckStoragePermission.db_secondary_path_access_fail");
ASSERT_TRUE(config.SetStorageConfigSecondaryPath(storage_secondary_path).ok());
fiu_enable("StorageChecker.CheckStoragePermission.wal_path_access_fail", 1, NULL, 0);
ASSERT_FALSE(ms::StorageChecker::CheckStoragePermission().ok());
fiu_disable("StorageChecker.CheckStoragePermission.wal_path_access_fail");
......
......@@ -84,14 +84,13 @@ class RpcHandlerTest : public testing::Test {
milvus::engine::DBOptions opt;
milvus::server::Config::GetInstance().SetDBConfigBackendUrl("sqlite://:@:/");
milvus::server::Config::GetInstance().SetGeneralConfigMetaURI("sqlite://:@:/");
milvus::server::Config::GetInstance().SetDBConfigArchiveDiskThreshold("");
milvus::server::Config::GetInstance().SetDBConfigArchiveDaysThreshold("");
milvus::server::Config::GetInstance().SetStorageConfigPrimaryPath("/tmp/milvus_test");
milvus::server::Config::GetInstance().SetStorageConfigSecondaryPath("");
milvus::server::Config::GetInstance().SetStorageConfigPath("/tmp/milvus_test");
milvus::server::Config::GetInstance().SetCacheConfigCacheInsertData("");
milvus::server::Config::GetInstance().SetEngineConfigOmpThreadNum("");
milvus::server::Config::GetInstance().SetServerConfigPort("19531");
milvus::server::Config::GetInstance().SetNetworkConfigBindPort("19531");
// serverConfig.SetValue(server::CONFIG_CLUSTER_MODE, "cluster");
// DBWrapper::GetInstance().GetInstance().StartService();
......
......@@ -249,12 +249,14 @@ TEST(UtilTest, LOG_TEST) {
fiu_init(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, "/tmp/test_util", 1024, 10);
auto status = milvus::server::InitLog(true, true, true, true, true, true,
"/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB
ASSERT_FALSE(status.ok());
fiu_disable("LogUtil.InitLog.set_max_log_size_small_than_min");
fiu_enable("LogUtil.InitLog.delete_exceeds_small_than_min", 1, NULL, 0);
status = milvus::server::InitLog(true, true, true, true, true, true, "/tmp/test_util", 1024, 10);
status = milvus::server::InitLog(true, true, true, true, true, true,
"/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB
ASSERT_FALSE(status.ok());
fiu_disable("LogUtil.InitLog.delete_exceeds_small_than_min");
......@@ -264,7 +266,8 @@ TEST(UtilTest, LOG_TEST) {
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.fatal_enable_to_false", 1, NULL, 0);
status = milvus::server::InitLog(true, true, true, true, true, true, "/tmp/test_util", 1024, 10);
status = milvus::server::InitLog(true, true, true, true, true, true,
"/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB
ASSERT_TRUE(status.ok()) << status.message();
fiu_disable("LogUtil.InitLog.fatal_enable_to_false");
fiu_disable("LogUtil.InitLog.error_enable_to_false");
......@@ -273,7 +276,8 @@ TEST(UtilTest, LOG_TEST) {
fiu_disable("LogUtil.InitLog.debug_enable_to_false");
fiu_disable("LogUtil.InitLog.info_enable_to_false");
status = milvus::server::InitLog(true, true, true, true, true, true, "/tmp/test_util", 1024, 10);
status = milvus::server::InitLog(true, true, true, true, true, true,
"/tmp/test_util", 1024 * 1024 * 1024, 10); // 1024 MB
ASSERT_TRUE(status.ok()) << status.message();
EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::NewLineForContainer));
......
......@@ -142,109 +142,64 @@ namespace {
static const char* CONTROLLER_TEST_VALID_CONFIG_STR =
"# Default values are used when you make no changes to the following parameters.\n"
"\n"
"version: 0.4\n"
"version: 0.5\n"
"\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"# Server Config | Description | Type | Default "
" |\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"server_config:\n"
" address: 0.0.0.0\n"
" port: 19530\n"
" deploy_mode: single\n"
" time_zone: UTC+8\n"
" web_enable: true\n"
" web_port: 19121\n"
"cluster:\n"
" enable: false\n"
" role: rw\n"
"\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"# DataBase Config | Description | Type | Default "
" |\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"db_config:\n"
" backend_url: sqlite://:@:/\n"
" preload_collection:\n"
"general:\n"
" timezone: UTC+8\n"
" meta_uri: sqlite://:@:/\n"
"\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"# Storage Config | Description | Type | Default "
" |\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"storage_config:\n"
" primary_path: /tmp/milvus\n"
" secondary_path:\n"
" s3_enable: false\n"
" s3_address: 127.0.0.1\n"
" s3_port: 9000\n"
" s3_access_key: minioadmin\n"
" s3_secret_key: minioadmin\n"
" s3_bucket: milvus-bucket\n"
"network:\n"
" bind.address: 0.0.0.0\n"
" bind.port: 19530\n"
" http.enable: true\n"
" http.port: 19121\n"
"\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"# Metric Config | Description | Type | Default "
" |\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"metric_config:\n"
" enable_monitor: false\n"
" address: 127.0.0.1\n"
" port: 9091\n"
"storage:\n"
" path: /tmp/milvus\n"
" auto_flush_interval: 1\n"
"\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"# Cache Config | Description | Type | Default "
" |\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"cache_config:\n"
" cpu_cache_capacity: 4\n"
" insert_buffer_size: 1\n"
" cache_insert_data: false\n"
"wal:\n"
" enable: true\n"
" recovery_error_ignore: false\n"
" buffer_size: 256MB\n"
" path: /tmp/milvus/wal\n"
"\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"# Engine Config | Description | Type | Default "
" |\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"engine_config:\n"
" use_blas_threshold: 1100\n"
#ifdef MILVUS_GPU_VERSION
" gpu_search_threshold: 1000\n"
"cache:\n"
" cache_size: 4GB\n"
" insert_buffer_size: 1GB\n"
" preload_collection:\n"
"\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"# GPU Resource Config | Description | Type | Default "
" |\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"gpu_resource_config:\n"
"gpu:\n"
" enable: true\n"
" cache_capacity: 1\n"
" search_resources:\n"
" cache_size: 1GB\n"
" gpu_search_threshold: 1000\n"
" search_devices:\n"
" - gpu0\n"
" build_index_resources:\n"
" build_index_devices:\n"
" - gpu0\n"
#endif
"\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"# Tracing Config | Description | Type | Default "
" |\n"
"#----------------------+------------------------------------------------------------+------------+----------------"
"-+\n"
"tracing_config:\n"
" json_config_path:\n"
"";
"logs:\n"
" level: debug\n"
" trace.enable: true\n"
" path: /tmp/milvus/logs\n"
" max_log_file_size: 1024MB\n"
" log_rotate_num: 0\n"
"\n"
"metric:\n"
" enable: false\n"
" address: 127.0.0.1\n"
" port: 9091\n"
"\n";
} // namespace
static const char* CONTROLLER_TEST_COLLECTION_NAME = "controller_unit_test";
static const char* CONTROLLER_TEST_CONFIG_DIR = "/tmp/milvus_web_controller_test/";
static const char* CONTROLLER_TEST_CONFIG_WAL_DIR = "/tmp/milvus_web_controller_test/wal";
static const char* CONTROLLER_TEST_CONFIG_FILE = "config.yaml";
class TestClient : public oatpp::web::client::ApiClient {
......@@ -382,13 +337,14 @@ class WebControllerTest : public ::testing::Test {
milvus::engine::DBOptions opt;
milvus::server::Config::GetInstance().SetDBConfigBackendUrl("sqlite://:@:/");
milvus::server::Config::GetInstance().SetGeneralConfigMetaURI("sqlite://:@:/");
boost::filesystem::remove_all(CONTROLLER_TEST_CONFIG_DIR);
milvus::server::Config::GetInstance().SetStorageConfigPrimaryPath(CONTROLLER_TEST_CONFIG_DIR);
milvus::server::Config::GetInstance().SetStorageConfigPath(CONTROLLER_TEST_CONFIG_DIR);
milvus::server::Config::GetInstance().SetWalConfigWalPath(CONTROLLER_TEST_CONFIG_WAL_DIR);
milvus::server::DBWrapper::GetInstance().StartService();
milvus::server::Config::GetInstance().SetServerConfigWebPort("29999");
milvus::server::Config::GetInstance().SetNetworkConfigHTTPPort("29999");
milvus::server::web::WebServer::GetInstance().Start();
......@@ -1421,11 +1377,11 @@ TEST_F(WebControllerTest, CONFIG) {
OString collection_name_s = "milvus_test_webcontroller_test_preload_collection_s";
GenCollection(client_ptr, conncetion_ptr, collection_name_s, 16, 10, "L2");
OString body_str = "{\"db_config\": {\"preload_collection\": \"" + collection_name + "\"}}";
OString body_str = "{\"cache\": {\"preload_collection\": \"" + collection_name + "\"}}";
response = client_ptr->op("config", body_str, conncetion_ptr);
ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str();
body_str = "{\"db_config\": {\"preload_collection\": \"" + collection_name + "," + collection_name_s + "\"}}";
body_str = "{\"cache\": {\"preload_collection\": \"" + collection_name + "," + collection_name_s + "\"}}";
response = client_ptr->op("config", body_str, conncetion_ptr);
ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str();
auto set_result_json = nlohmann::json::parse(response->readBodyToString()->c_str());
......@@ -1467,7 +1423,7 @@ TEST_F(WebControllerTest, ADVANCED_CONFIG) {
auto config_dto = milvus::server::web::AdvancedConfigDto::createShared();
response = client_ptr->setAdvanced(config_dto, conncetion_ptr);
ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode());
ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str();
config_dto->cpu_cache_capacity = 3;
response = client_ptr->setAdvanced(config_dto, conncetion_ptr);
......@@ -1489,7 +1445,7 @@ TEST_F(WebControllerTest, ADVANCED_CONFIG) {
// test fault
// cpu cache capacity exceed total memory
config_dto->cpu_cache_capacity = 10000000;
config_dto->cpu_cache_capacity = 10000L * (1024L * 1024 * 1024); // 10000 GB
response = client_ptr->setAdvanced(config_dto, conncetion_ptr);
ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode());
}
......@@ -1543,10 +1499,10 @@ TEST_F(WebControllerTest, GPU_CONFIG) {
ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode());
//// test fault config
// cache capacity exceed GPU mem size
gpu_config_dto->cache_capacity = 100000;
// cache capacity exceed GPU mem size (GiB)
gpu_config_dto->cache_capacity = 100000L * 1024 * 1024 * 1024; // 100000 GiB
response = client_ptr->setGPUConfig(gpu_config_dto, conncetion_ptr);
ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode());
ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()) << response->readBodyToString()->c_str();
gpu_config_dto->cache_capacity = 1;
// duplicate resources
......
......@@ -19,6 +19,64 @@
namespace {
static const char* VALID_CONFIG_STR =
"# Default values are used when you make no changes to the following parameters.\n"
"\n"
"version: 0.5\n"
"\n"
"cluster:\n"
" enable: false\n"
" role: rw\n"
"\n"
"general:\n"
" timezone: UTC+8\n"
" meta_uri: sqlite://:@:/\n"
"\n"
"network:\n"
" bind.address: 0.0.0.0\n"
" bind.port: 19530\n"
" http.enable: true\n"
" http.port: 19121\n"
"\n"
"storage:\n"
" path: /tmp/milvus\n"
" auto_flush_interval: 1\n"
"\n"
"wal:\n"
" enable: true\n"
" recovery_error_ignore: false\n"
" buffer_size: 256MB\n"
" path: /tmp/milvus/wal\n"
"\n"
"cache:\n"
" cache_size: 4GB\n"
" insert_buffer_size: 1GB\n"
" preload_collection:\n"
"\n"
"gpu:\n"
" enable: true\n"
" cache_size: 1GB\n"
" gpu_search_threshold: 1000\n"
" search_devices:\n"
" - gpu0\n"
" build_index_devices:\n"
" - gpu0\n"
"\n"
"logs:\n"
" level: debug\n"
" trace.enable: true\n"
" path: /tmp/milvus/logs\n"
" max_log_file_size: 1024MB\n"
" log_rotate_num: 0\n"
"\n"
"metric:\n"
" enable: false\n"
" address: 127.0.0.1\n"
" port: 9091\n"
"\n";
/*
static const char* VALID_CONFIG_STR =
"# Default values are used when you make no changes to the following parameters.\n"
"\n"
......@@ -84,6 +142,7 @@ static const char* VALID_CONFIG_STR =
" max_log_file_size: 256\n"
" delete_exceeds: 10\n"
"";
*/
static const char* INVALID_CONFIG_STR = "*INVALID*";
......
......@@ -378,6 +378,7 @@ class TestCompactBase:
assert status.OK()
@pytest.mark.timeout(COMPACT_TIMEOUT)
@pytest.mark.repeat(10)
def test_index_creation_after_compact(self, connect, collection, get_simple_index):
'''
target: test index creation after compact
......
......@@ -38,15 +38,15 @@ def get_milvus(host, port, uri=None, handler=None, **kwargs):
def disable_flush(connect):
status, reply = connect.set_config("db_config", "auto_flush_interval", big_flush_interval)
status, reply = connect.set_config("storage", "auto_flush_interval", big_flush_interval)
assert status.OK()
def enable_flush(connect):
# reset auto_flush_interval=1
status, reply = connect.set_config("db_config", "auto_flush_interval", default_flush_interval)
status, reply = connect.set_config("storage", "auto_flush_interval", default_flush_interval)
assert status.OK()
status, config_value = connect.get_config("db_config", "auto_flush_interval")
status, config_value = connect.get_config("storage", "auto_flush_interval")
assert status.OK()
assert config_value == str(default_flush_interval)
......@@ -470,7 +470,7 @@ def gen_invalid_cache_config():
return invalid_configs
def gen_invalid_engine_config():
def gen_invalid_gpu_config():
invalid_configs = [
-1,
[1,2,3],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册