Skip to content

Commit

Permalink
1) Remove stale Xmpp Servers i.e the ones different from the list ret…
Browse files Browse the repository at this point in the history
…urned

   from Discovery Servers only if DOWN.
   (Note: Responses from discovery server are not applied if the
    current XMPP connection is UP)
2) Remove checkum code in discovery client library so all
   responses from Discovery Server are delivered to the end client.
3) Add introspect to show the responses from Discovery Server and
   currently connected Xmpp servers for both control-node and dns.

Change-Id: I80c9a8446ef94db73db36144109e80b2432a07fd
Closes-Bug:1471002
Closes-Bug:1396807
  • Loading branch information
nipak committed Jul 9, 2015
1 parent 8a7a373 commit 0cba3c1
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 42 deletions.
8 changes: 5 additions & 3 deletions src/discovery/client/discovery_client.cc
Expand Up @@ -612,7 +612,7 @@ void DiscoveryServiceClient::SubscribeResponseHandler(std::string &xmls,

hdr->sub_rcvd_++;
hdr->attempts_ = 0;
if ((hdr->chksum_ == gen_chksum) || (ds_response.size() == 0)) {
if (ds_response.size() == 0) {
//Restart Subscribe Timer
hdr->StartSubscribeTimer(ttl);
DISCOVERY_CLIENT_TRACE(DiscoveryClientMsg, "SubscribeResponseHandler",
Expand All @@ -624,8 +624,10 @@ void DiscoveryServiceClient::SubscribeResponseHandler(std::string &xmls,
return; //No change in message, ignore
}

DISCOVERY_CLIENT_TRACE(DiscoveryClientMsg, "SubscribeResponseHandler",
serviceName, xmls);
if (hdr->chksum_ != gen_chksum) {
DISCOVERY_CLIENT_TRACE(DiscoveryClientMsg, "SubscribeResponseHandler",
serviceName, xmls);
}
// Update connection info
ConnectionState::GetInstance()->Update(ConnectionType::DISCOVERY,
serviceName, ConnectionStatus::UP, ds_endpoint_,
Expand Down
50 changes: 50 additions & 0 deletions src/vnsw/agent/cmn/agent.h
Expand Up @@ -337,6 +337,50 @@ class Agent {

// TODO: Should they be moved under controller/dns/cfg?

// Discovery Control-Node Server Response
const std::string &controller_ifmap_discovery_xmpp_server(uint8_t idx) const {
return xs_disc_addr_[idx];
}
void set_controller_ifmap_discovery_xmpp_server(const std::string &addr, uint8_t idx) {
xs_disc_addr_[idx] = addr;
}
const uint32_t controller_ifmap_discovery_xmpp_port(uint8_t idx) const {
return xs_disc_port_[idx];
}
void set_controller_ifmap_discovery_xmpp_port(uint32_t port, uint8_t idx) {
xs_disc_port_[idx] = port;
}
void reset_controller_ifmap_discovery_xmpp_servers() {
uint8_t count = 0;
while (count < MAX_XMPP_SERVERS) {
xs_disc_addr_[count].clear();
xs_disc_port_[count] = 0;
count++;
}
}

// Discovery Dns Server Response
const std::string &dns_discovery_server(uint8_t idx) const {
return dns_disc_addr_[idx];
}
void set_dns_discovery_server(const std::string &addr, uint8_t idx) {
dns_disc_addr_[idx] = addr;
}
const uint32_t dns_discovery_port(uint8_t idx) const {
return dns_disc_port_[idx];
}
void set_dns_discovery_port(uint32_t port, uint8_t idx) {
dns_disc_port_[idx] = port;
}
void reset_dns_discovery_servers() {
uint8_t count = 0;
while (count < MAX_XMPP_SERVERS) {
dns_disc_addr_[count].clear();
dns_disc_port_[count] = 0;
count++;
}
}

// Common XMPP Client for control-node and config clients
const std::string &controller_ifmap_xmpp_server(uint8_t idx) const {
return xs_addr_[idx];
Expand Down Expand Up @@ -783,6 +827,12 @@ class Agent {
int8_t xs_dns_idx_;
std::string dns_addr_[MAX_XMPP_SERVERS];
uint32_t dns_port_[MAX_XMPP_SERVERS];
// Discovery Responses
std::string xs_disc_addr_[MAX_XMPP_SERVERS];
uint32_t xs_disc_port_[MAX_XMPP_SERVERS];
std::string dns_disc_addr_[MAX_XMPP_SERVERS];
uint32_t dns_disc_port_[MAX_XMPP_SERVERS];
// Discovery
std::string dss_addr_;
uint32_t dss_port_;
int dss_xs_instances_;
Expand Down
40 changes: 40 additions & 0 deletions src/vnsw/agent/controller/controller.sandesh
Expand Up @@ -23,6 +23,25 @@ struct AgentXmppData {
11: ControllerProtoStats tx_proto_stats;
}

struct AgentXmppDnsData {
1: string dns_controller_ip;
2: string state;
3: string last_state;
4: string last_event;
5: string last_state_at;
6: u32 flap_count;
7: string flap_time;
8: ControllerProtoStats rx_proto_stats;
9: ControllerProtoStats tx_proto_stats;
}

struct AgentDiscoveryXmppConnections {
1: string agent_controller_ip;
2: u32 agent_controller_port;
3: string discovery_controller_ip;
4: u32 discovery_controller_port;
}

traceobject sandesh AgentXmppTrace {
1: string peer;
2: string vrf;
Expand Down Expand Up @@ -100,3 +119,24 @@ request sandesh AgentXmppConnectionStatusReq {
response sandesh AgentXmppConnectionStatus {
1: list<AgentXmppData>peer;
}

request sandesh AgentDnsXmppConnectionStatusReq {
}

response sandesh AgentDnsXmppConnectionStatus {
1: list<AgentXmppDnsData>peer;
}

request sandesh AgentDiscoveryXmppConnectionsRequest {
}

response sandesh AgentDiscoveryXmppConnectionsResponse {
1: list<AgentDiscoveryXmppConnections>xmppc;
}

request sandesh AgentDiscoveryDnsXmppConnectionsRequest {
}

response sandesh AgentDiscoveryDnsXmppConnectionsResponse {
1: list<AgentDiscoveryXmppConnections>xmppc;
}
91 changes: 53 additions & 38 deletions src/vnsw/agent/controller/controller_init.cc
Expand Up @@ -274,31 +274,30 @@ void VNController::DeleteConnectionInfo(const std::string &addr, bool is_dns)

void VNController::DisConnectControllerIfmapServer(uint8_t idx) {

DeleteConnectionInfo(agent_->controller_ifmap_xmpp_server(idx),
false);

// Managed Delete of XmppClient object, which deletes the
// dependent XmppClientConnection object and
// scoped XmppChannel object
XmppClient *xc = agent_->controller_ifmap_xmpp_client(idx);
xc->UnRegisterConnectionEvent(xmps::BGP);
xc->Shutdown(); // ManagedDelete
agent_->set_controller_ifmap_xmpp_client(NULL, idx);

//cleanup AgentXmppChannel
agent_->ResetAgentMcastLabelRange(idx);
delete agent_->controller_xmpp_channel(idx);
agent_->set_controller_xmpp_channel(NULL, idx);

//cleanup AgentIfmapXmppChannel
delete agent_->ifmap_xmpp_channel(idx);
agent_->set_ifmap_xmpp_channel(NULL, idx);

agent_->controller_ifmap_xmpp_init(idx)->Reset();
delete agent_->controller_ifmap_xmpp_init(idx);
agent_->set_controller_ifmap_xmpp_init(NULL, idx);

agent_->reset_controller_ifmap_xmpp_server(idx);
DeleteConnectionInfo(agent_->controller_ifmap_xmpp_server(idx), false);

// Managed Delete of XmppClient object, which deletes the
// dependent XmppClientConnection object and
// scoped XmppChannel object
XmppClient *xc = agent_->controller_ifmap_xmpp_client(idx);
xc->UnRegisterConnectionEvent(xmps::BGP);
xc->Shutdown(); // ManagedDelete
agent_->set_controller_ifmap_xmpp_client(NULL, idx);

//cleanup AgentXmppChannel
agent_->ResetAgentMcastLabelRange(idx);
delete agent_->controller_xmpp_channel(idx);
agent_->set_controller_xmpp_channel(NULL, idx);

//cleanup AgentIfmapXmppChannel
delete agent_->ifmap_xmpp_channel(idx);
agent_->set_ifmap_xmpp_channel(NULL, idx);

agent_->controller_ifmap_xmpp_init(idx)->Reset();
delete agent_->controller_ifmap_xmpp_init(idx);
agent_->set_controller_ifmap_xmpp_init(NULL, idx);

agent_->reset_controller_ifmap_xmpp_server(idx);
}

bool VNController::AgentXmppServerExists(const std::string &server_ip,
Expand All @@ -318,12 +317,17 @@ void VNController::ApplyDiscoveryXmppServices(std::vector<DSResponse> resp) {

std::vector<DSResponse>::iterator iter;
int8_t count = -1;
agent_->reset_controller_ifmap_discovery_xmpp_servers();
for (iter = resp.begin(); iter != resp.end(); iter++) {
DSResponse dr = *iter;
count ++;

CONTROLLER_TRACE(DiscoveryConnection, "XMPP Discovery Server Response",
count, dr.ep.address().to_string(), integerToString(dr.ep.port()));
agent_->set_controller_ifmap_discovery_xmpp_server(
dr.ep.address().to_string(), count);
agent_->set_controller_ifmap_discovery_xmpp_port(
dr.ep.port(), count);

AgentXmppChannel *chnl = FindAgentXmppChannel(dr.ep.address().to_string());
if (chnl) {
Expand Down Expand Up @@ -383,17 +387,21 @@ void VNController::ApplyDiscoveryXmppServices(std::vector<DSResponse> resp) {
}
}

/* Remove stale Servers */
/* Remove stale Servers if DOWN */
for (uint8_t idx = 0; idx < MAX_XMPP_SERVERS; idx++) {
if (agent_->controller_xmpp_channel(idx) != NULL) {

if (!AgentXmppServerExists(
agent_->controller_ifmap_xmpp_server(idx), resp)) {
agent_->controller_ifmap_xmpp_server(idx), resp)) {

CONTROLLER_TRACE(DiscoveryConnection, "Cleanup Older Xmpp ",
idx, agent_->controller_ifmap_xmpp_server(idx), "");
DisConnectControllerIfmapServer(idx);
agent_->reset_controller_ifmap_xmpp_server(idx);
if (agent_->controller_xmpp_channel(idx)->GetXmppChannel()->
GetPeerState() == xmps::NOT_READY) {

CONTROLLER_TRACE(DiscoveryConnection, "Cleanup Older Xmpp ",
idx, agent_->controller_ifmap_xmpp_server(idx), "");
DisConnectControllerIfmapServer(idx);
agent_->reset_controller_ifmap_xmpp_server(idx);
}
}
}
}
Expand Down Expand Up @@ -445,12 +453,15 @@ void VNController::ApplyDiscoveryDnsXmppServices(std::vector<DSResponse> resp) {

std::vector<DSResponse>::iterator iter;
int8_t count = -1;
agent_->reset_dns_discovery_servers();
for (iter = resp.begin(); iter != resp.end(); iter++) {
DSResponse dr = *iter;
count++;

CONTROLLER_TRACE(DiscoveryConnection, "DNS Discovery Server Response", count,
dr.ep.address().to_string(), integerToString(dr.ep.port()));
agent_->set_dns_discovery_server(dr.ep.address().to_string(), count);
agent_->set_dns_discovery_port(dr.ep.port(), count);

AgentDnsXmppChannel *chnl = FindAgentDnsXmppChannel(dr.ep.address().to_string());
if (chnl) {
Expand Down Expand Up @@ -508,17 +519,21 @@ void VNController::ApplyDiscoveryDnsXmppServices(std::vector<DSResponse> resp) {
}
}

/* Remove stale Servers */
/* Remove stale Servers if DOWN*/
for (uint8_t idx = 0; idx < MAX_XMPP_SERVERS; idx++) {
if (agent_->dns_xmpp_channel(idx) != NULL) {

if (AgentXmppServerExists(
agent_->dns_server(idx), resp)) {
if (!AgentXmppServerExists(
agent_->dns_server(idx), resp)) {

if (agent_->dns_xmpp_channel(idx)->GetXmppChannel()->
GetPeerState() == xmps::NOT_READY) {

CONTROLLER_TRACE(DiscoveryConnection, "Cleanup Older Dns Xmpp",
idx, agent_->dns_server(idx), "");
DisConnectDnsServer(idx);
agent_->reset_dns_server(idx);
CONTROLLER_TRACE(DiscoveryConnection, "Cleanup Older Dns Xmpp",
idx, agent_->dns_server(idx), "");
DisConnectDnsServer(idx);
agent_->reset_dns_server(idx);
}
}
}
}
Expand Down

0 comments on commit 0cba3c1

Please sign in to comment.