Skip to content

Commit

Permalink
Set Discovery client name as a combination of module name and instanc…
Browse files Browse the repository at this point in the history
…e Id

This is required to handle the case of multiple tor-agents running from same node.

Change-Id: Idfeaa55824ff1b1b147b44c7d1f8ed3b8119384a
Closes-Bug: #1455618
  • Loading branch information
ashoksr committed May 22, 2015
1 parent e8d240d commit a15257d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/vnsw/agent/cfg/discovery_agent.cc
Expand Up @@ -139,8 +139,6 @@ void DiscoveryAgentClient::DiscoverServices() {
(agent->module_type());
NodeType::type node_type =
g_vns_constants.Module2NodeType.find(module)->second;
std::string subscriber_name =
agent->discovery_client_name();
std::string node_type_name =
g_vns_constants.NodeTypeNames.find(node_type)->second;

Expand All @@ -149,7 +147,7 @@ void DiscoveryAgentClient::DiscoverServices() {
ds_client, _1, _2, _3);
std::vector<std::string> list;
list.clear();
Sandesh::InitGenerator(subscriber_name,
Sandesh::InitGenerator(agent->module_name(),
agent->host_name(),
node_type_name,
agent->instance_id(),
Expand Down
12 changes: 9 additions & 3 deletions src/vnsw/agent/cmn/agent.cc
Expand Up @@ -300,7 +300,7 @@ void Agent::InitCollector() {
NodeType::type node_type =
g_vns_constants.Module2NodeType.find(module)->second;
if (params_->collector_server_list().size() != 0) {
Sandesh::InitGenerator(discovery_client_name_,
Sandesh::InitGenerator(module_name(),
host_name(),
g_vns_constants.NodeTypeNames.find(node_type)->second,
instance_id_,
Expand All @@ -309,7 +309,7 @@ void Agent::InitCollector() {
params_->collector_server_list(),
NULL);
} else {
Sandesh::InitGenerator(discovery_client_name_,
Sandesh::InitGenerator(module_name(),
host_name(),
g_vns_constants.NodeTypeNames.find(node_type)->second,
instance_id_,
Expand Down Expand Up @@ -433,7 +433,9 @@ Agent::Agent() :
CreateLifetimeManager();

Module::type module = static_cast<Module::type>(module_type_);
discovery_client_name_ = g_vns_constants.ModuleNames.find(module)->second;
module_name_ = g_vns_constants.ModuleNames.find(module)->second;
discovery_client_name_ = BuildDiscoveryClientName(module_name_,
instance_id_);

agent_signal_.reset(
AgentObjectFactory::Create<AgentSignal>(event_mgr_));
Expand Down Expand Up @@ -597,3 +599,7 @@ bool Agent::vrouter_on_host_dpdk() const {
bool Agent::vrouter_on_host() const {
return params_->vrouter_on_host();
}

const string Agent::BuildDiscoveryClientName(string mod_name, string id) {
return (mod_name + ":" + id);
}
6 changes: 6 additions & 0 deletions src/vnsw/agent/cmn/agent.h
Expand Up @@ -557,6 +557,9 @@ class Agent {
const int &module_type() const { return module_type_; }
void set_module_type(int id) { module_type_ = id; }

const std::string &module_name() const { return module_name_; }
void set_module_name(const std::string &name) { module_name_ = name; }

// Multicast related
const std::string &multicast_label_range(uint8_t idx) {
return label_range_[idx];
Expand Down Expand Up @@ -805,6 +808,8 @@ class Agent {
bool vrouter_on_host() const;
void SetAgentTaskPolicy();
void CopyConfig(AgentParam *params);
const std::string BuildDiscoveryClientName(std::string mod_name,
std::string id);

void Init(AgentParam *param);
void InitPeers();
Expand Down Expand Up @@ -856,6 +861,7 @@ class Agent {
int introspect_port_;
std::string instance_id_;
int module_type_;
std::string module_name_;

// DB handles
DB *db_;
Expand Down
8 changes: 7 additions & 1 deletion src/vnsw/agent/init/agent_init.cc
Expand Up @@ -78,10 +78,16 @@ int AgentInit::Start() {
agent_->CopyConfig(agent_param_);

string module_name = ModuleName();
agent_->set_discovery_client_name(module_name);
/* Discovery client name should have InstanceId as well because multiple
* instances of tor-agent can run on a single node.
*/
string ds_client_name =
agent_->BuildDiscoveryClientName(module_name, InstanceId());
agent_->set_discovery_client_name(ds_client_name);
agent_->set_agent_name(AgentName());
agent_->set_instance_id(InstanceId());
agent_->set_module_type(ModuleType());
agent_->set_module_name(module_name);

LoggingInit(agent_param_->log_file(), agent_param_->log_file_size(),
agent_param_->log_files_count(), agent_param_->use_syslog(),
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/uve/agent_uve_base.cc
Expand Up @@ -56,7 +56,7 @@ void AgentUveBase::Shutdown() {
}

void AgentUveBase::Init() {
std::string module_id(agent_->discovery_client_name());
std::string module_id(agent_->module_name());
std::string instance_id(agent_->instance_id());
EventManager *evm = agent_->event_manager();
boost::asio::io_service &io = *evm->io_service();
Expand Down

0 comments on commit a15257d

Please sign in to comment.