-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] support configServer V2 (#1592)
* modify pb * fix * rm mAttributes * rm FetchConfig * rm SendHeartBeat * add ProcessSourceDir * support CommonConfigProvider * add FetchProcessConfigFromServer and FetchPipelineConfigFromServer * fix test * add config feedbacker * fix loadconfigfile * heartbeat * rm once from cpp * add mProcessFileInfoMap * add CommandSource * modify ConfigWatcher * modify mRegion * modify operator= * modify * format * modify * fix Update * add test * add RegisterCallback * fix * format * add test * fix test * add FeedbackProcessConfigStatus * rm callbacks * fix test * add ConfigFeedbackableUnittest * fix * add GenerateCommandFeedBackKey * LCOV_EXCL_STOP * fix * rm provider --------- Co-authored-by: Tom Yu <[email protected]>
- Loading branch information
1 parent
0a477c0
commit c3252b1
Showing
62 changed files
with
10,630 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2023 iLogtail Authors | ||
// | ||
// 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/ProcessConfig.h" | ||
|
||
#include <string> | ||
|
||
#include "app_config/AppConfig.h" | ||
#include "common/FileSystemUtil.h" | ||
#include "common/Flags.h" | ||
#include "common/JsonUtil.h" | ||
#include "common/ParamExtractor.h" | ||
#include "common/YamlUtil.h" | ||
#include "plugin/PluginRegistry.h" | ||
|
||
|
||
using namespace std; | ||
|
||
namespace logtail {} // namespace logtail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright 2023 iLogtail Authors | ||
* | ||
* 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 <json/json.h> | ||
#include <re2/re2.h> | ||
|
||
#include <cstdint> | ||
#include <filesystem> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace logtail { | ||
|
||
struct ProcessConfig { | ||
std::string mName; | ||
std::unique_ptr<Json::Value> mDetail; | ||
|
||
// for alarm only | ||
std::string mProject; | ||
std::string mLogstore; | ||
std::string mRegion; | ||
|
||
ProcessConfig(const std::string& name, std::unique_ptr<Json::Value>&& detail) | ||
: mName(name), mDetail(std::move(detail)) { | ||
mProject = ""; | ||
mLogstore = ""; | ||
mRegion = ""; | ||
} | ||
ProcessConfig(const logtail::ProcessConfig& config) { | ||
mName = config.mName; | ||
mDetail = std::make_unique<Json::Value>(*config.mDetail); | ||
mProject = ""; | ||
mLogstore = ""; | ||
mRegion = ""; | ||
} | ||
|
||
ProcessConfig& operator=(ProcessConfig&& other) { | ||
if (this != &other) { | ||
mName = std::move(other.mName); | ||
mDetail = std::move(other.mDetail); | ||
mProject = ""; | ||
mLogstore = ""; | ||
mRegion = ""; | ||
} | ||
return *this; | ||
} | ||
|
||
ProcessConfig& operator=(const ProcessConfig& other) { | ||
if (this != &other) { | ||
mName = other.mName; | ||
mDetail = std::make_unique<Json::Value>(*other.mDetail); | ||
mProject = ""; | ||
mLogstore = ""; | ||
mRegion = ""; | ||
} | ||
return *this; | ||
} | ||
|
||
bool Parse() { return true; } | ||
|
||
const Json::Value& GetConfig() const { return *mDetail; } | ||
}; | ||
|
||
inline bool operator==(const ProcessConfig& lhs, const ProcessConfig& rhs) { | ||
return (lhs.mName == rhs.mName) && (*lhs.mDetail == *rhs.mDetail); | ||
} | ||
|
||
inline bool operator!=(const ProcessConfig& lhs, const ProcessConfig& rhs) { | ||
return !(lhs == rhs); | ||
} | ||
|
||
} // namespace logtail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright 2024 iLogtail Authors | ||
* | ||
* 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/feedbacker/ConfigFeedbackReceiver.h" | ||
|
||
#include <unordered_map> | ||
|
||
namespace logtail { | ||
|
||
ConfigFeedbackReceiver& ConfigFeedbackReceiver::GetInstance() { | ||
static ConfigFeedbackReceiver instance; | ||
return instance; | ||
} | ||
|
||
void ConfigFeedbackReceiver::RegisterPipelineConfig(const std::string& name, ConfigFeedbackable* feedbackable) { | ||
std::lock_guard<std::mutex> lock(mMutex); | ||
mPipelineConfigFeedbackableMap[name] = feedbackable; | ||
} | ||
|
||
void ConfigFeedbackReceiver::RegisterProcessConfig(const std::string& name, ConfigFeedbackable* feedbackable) { | ||
std::lock_guard<std::mutex> lock(mMutex); | ||
mProcessConfigFeedbackableMap[name] = feedbackable; | ||
} | ||
|
||
void ConfigFeedbackReceiver::RegisterCommand(const std::string& type, | ||
const std::string& name, | ||
ConfigFeedbackable* feedbackable) { | ||
std::lock_guard<std::mutex> lock(mMutex); | ||
mCommandFeedbackableMap[GenerateCommandFeedBackKey(type, name)] = feedbackable; | ||
} | ||
|
||
void ConfigFeedbackReceiver::UnregisterPipelineConfig(const std::string& name) { | ||
std::lock_guard<std::mutex> lock(mMutex); | ||
mPipelineConfigFeedbackableMap.erase(name); | ||
} | ||
|
||
void ConfigFeedbackReceiver::UnregisterProcessConfig(const std::string& name) { | ||
std::lock_guard<std::mutex> lock(mMutex); | ||
mProcessConfigFeedbackableMap.erase(name); | ||
} | ||
|
||
void ConfigFeedbackReceiver::UnregisterCommand(const std::string& type, const std::string& name) { | ||
std::lock_guard<std::mutex> lock(mMutex); | ||
mCommandFeedbackableMap.erase(GenerateCommandFeedBackKey(type, name)); | ||
} | ||
|
||
void ConfigFeedbackReceiver::FeedbackPipelineConfigStatus(const std::string& name, ConfigFeedbackStatus status) { | ||
std::lock_guard<std::mutex> lock(mMutex); | ||
auto iter = mPipelineConfigFeedbackableMap.find(name); | ||
if (iter != mPipelineConfigFeedbackableMap.end()) { | ||
iter->second->FeedbackPipelineConfigStatus(name, status); | ||
} | ||
} | ||
|
||
void ConfigFeedbackReceiver::FeedbackProcessConfigStatus(const std::string& name, ConfigFeedbackStatus status) { | ||
std::lock_guard<std::mutex> lock(mMutex); | ||
auto iter = mProcessConfigFeedbackableMap.find(name); | ||
if (iter != mProcessConfigFeedbackableMap.end()) { | ||
iter->second->FeedbackProcessConfigStatus(name, status); | ||
} | ||
} | ||
|
||
void ConfigFeedbackReceiver::FeedbackCommandConfigStatus(const std::string& type, | ||
const std::string& name, | ||
ConfigFeedbackStatus status) { | ||
std::lock_guard<std::mutex> lock(mMutex); | ||
auto iter = mCommandFeedbackableMap.find(GenerateCommandFeedBackKey(type, name)); | ||
if (iter != mCommandFeedbackableMap.end()) { | ||
iter->second->FeedbackCommandConfigStatus(type, name, status); | ||
} | ||
} | ||
|
||
std::string GenerateCommandFeedBackKey(const std::string& type, const std::string& name) { | ||
return type + '\1' + name; | ||
} | ||
|
||
} // namespace logtail |
Oops, something went wrong.