Former-commit-id: 471118fe238938668b89db35a46db446a21758a3
This commit is contained in:
zhiru 2019-06-30 10:43:06 +08:00 committed by jinhai
parent bc8f7c8c5e
commit 394087fd34
7 changed files with 30 additions and 15 deletions

View File

@ -1,8 +1,8 @@
server_config:
address: 0.0.0.0
port: 19531 # the port milvus listen to, default: 19530, range: 1025 ~ 65534
port: 19530 # the port milvus listen to, default: 19530, range: 1025 ~ 65534
gpu_index: 0 # the gpu milvus use, default: 0, range: 0 ~ gpu number - 1
mode: cluster # milvus deployment type: single, cluster
mode: single # milvus deployment type: single, cluster, read_only
db_config:
db_path: /tmp/milvus

View File

@ -136,7 +136,7 @@ DBImpl::DBImpl(const Options& options)
shutting_down_(false),
compact_thread_pool_(1, 1),
index_thread_pool_(1, 1) {
meta_ptr_ = DBMetaImplFactory::Build(options.meta);
meta_ptr_ = DBMetaImplFactory::Build(options.meta, options.mode);
mem_mgr_ = std::make_shared<MemManager>(meta_ptr_, options_);
// mem_mgr_ = (MemManagerPtr)(new MemManager(meta_ptr_, options_));
if (options.mode != "read_only") {

View File

@ -53,7 +53,8 @@ std::shared_ptr<meta::DBMetaImpl> DBMetaImplFactory::Build() {
return std::shared_ptr<meta::DBMetaImpl>(new meta::DBMetaImpl(options));
}
std::shared_ptr<meta::Meta> DBMetaImplFactory::Build(const DBMetaOptions& metaOptions) {
std::shared_ptr<meta::Meta> DBMetaImplFactory::Build(const DBMetaOptions& metaOptions,
const std::string& mode) {
std::string uri = metaOptions.backend_uri;
// if (uri.empty()) {
@ -81,21 +82,21 @@ std::shared_ptr<meta::Meta> DBMetaImplFactory::Build(const DBMetaOptions& metaOp
std::string dialect = pieces_match[1].str();
std::transform(dialect.begin(), dialect.end(), dialect.begin(), ::tolower);
if (dialect.find("mysql") != std::string::npos) {
ENGINE_LOG_DEBUG << "Using MySQL";
return std::make_shared<meta::MySQLMetaImpl>(meta::MySQLMetaImpl(metaOptions));
ENGINE_LOG_INFO << "Using MySQL";
return std::make_shared<meta::MySQLMetaImpl>(meta::MySQLMetaImpl(metaOptions, mode));
}
else if (dialect.find("sqlite") != std::string::npos) {
ENGINE_LOG_DEBUG << "Using SQLite";
return std::make_shared<meta::DBMetaImpl>(meta::DBMetaImpl(metaOptions));
}
else {
LOG(ERROR) << "Invalid dialect in URI: dialect = " << dialect;
ENGINE_LOG_ERROR << "Invalid dialect in URI: dialect = " << dialect;
throw InvalidArgumentException("URI dialect is not mysql / sqlite");
}
}
else {
LOG(ERROR) << "Wrong URI format: URI = " << uri;
throw InvalidArgumentException("Wrong URI format");
ENGINE_LOG_ERROR << "Wrong URI format: URI = " << uri;
throw InvalidArgumentException("Wrong URI format ");
}
}

View File

@ -28,7 +28,7 @@ struct OptionsFactory {
struct DBMetaImplFactory {
static std::shared_ptr<meta::DBMetaImpl> Build();
static std::shared_ptr<meta::Meta> Build(const DBMetaOptions& metaOptions);
static std::shared_ptr<meta::Meta> Build(const DBMetaOptions& metaOptions, const std::string& mode);
};
struct DBFactory {

View File

@ -103,8 +103,9 @@ namespace meta {
return Status::OK();
}
MySQLMetaImpl::MySQLMetaImpl(const DBMetaOptions &options_)
: options_(options_) {
MySQLMetaImpl::MySQLMetaImpl(const DBMetaOptions &options_, const std::string& mode)
: options_(options_),
mode_(mode) {
Initialize();
}
@ -424,6 +425,14 @@ namespace meta {
}
} //Scoped Connection
// ConfigNode& serverConfig = ServerConfig::GetInstance().GetConfig(CONFIG_SERVER);
// opt.mode = serverConfig.GetValue(CONFIG_CLUSTER_MODE, "single");
if (mode_ != "single") {
DeleteTableFiles(table_id);
}
} catch (const BadQuery& er) {
// Handle any query errors
ENGINE_LOG_ERROR << "GENERAL ERROR WHEN DELETING TABLE" << ": " << er.what();
@ -448,10 +457,10 @@ namespace meta {
Query deleteTableFilesQuery = connectionPtr->query();
//
deleteTableFilesQuery << "UPDATE TableFiles " <<
"SET file_type = " << std::to_string(TableSchema::TO_DELETE) << ", " <<
"SET file_type = " << std::to_string(TableFileSchema::TO_DELETE) << ", " <<
"updated_time = " << std::to_string(utils::GetMicroSecTimeStamp()) << " " <<
"WHERE table_id = " << quote << table_id << " AND " <<
"file_type <> " << std::to_string(TableSchema::TO_DELETE) << ";";
"file_type <> " << std::to_string(TableFileSchema::TO_DELETE) << ";";
if (!deleteTableFilesQuery.exec()) {
ENGINE_LOG_ERROR << "QUERY ERROR WHEN DELETING TABLE FILES";

View File

@ -22,7 +22,7 @@ namespace meta {
class MySQLMetaImpl : public Meta {
public:
MySQLMetaImpl(const DBMetaOptions& options_);
MySQLMetaImpl(const DBMetaOptions& options_, const std::string& mode);
virtual Status CreateTable(TableSchema& table_schema) override;
virtual Status DescribeTable(TableSchema& group_info_) override;
@ -77,6 +77,7 @@ namespace meta {
Status Initialize();
const DBMetaOptions options_;
const std::string mode_;
std::shared_ptr<MySQLConnectionPool> mySQLConnectionPool_;
bool safe_grab = false;

View File

@ -25,6 +25,10 @@ DBWrapper::DBWrapper() {
}
ConfigNode& serverConfig = ServerConfig::GetInstance().GetConfig(CONFIG_SERVER);
opt.mode = serverConfig.GetValue(CONFIG_CLUSTER_MODE, "single");
if (opt.mode != "single" && opt.mode != "cluster" && opt.mode != "read_only") {
std::cout << "ERROR: mode specified in server_config is not one of ['single', 'cluster', 'read_only']" << std::endl;
kill(0, SIGUSR1);
}
//set archive config
engine::ArchiveConf::CriteriaT criterial;