Skip to content

Commit

Permalink
Merge "Add the clients FQN in the ifmap-xmpp logs" into R2.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Aug 27, 2015
2 parents a0aee2b + 9ee02c5 commit 1c0d9ae
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 21 deletions.
30 changes: 22 additions & 8 deletions src/ifmap/ifmap_log.sandesh
Expand Up @@ -108,21 +108,25 @@ systemlog sandesh IFMapSmTransitionMessage {
systemlog sandesh IFMapNoVrSub {
1: string op
2: string client_name (key="ObjectVRouter")
3: string vm_uuid
3: string client_fqn
4: string vm_uuid
}

systemlog sandesh IFMapNoVmSub {
1: string client_name (key="ObjectVRouter")
2: string vm_uuid
2: string client_fqn
3: string vm_uuid
}

systemlog sandesh IFMapDuplicateVrSub {
1: string client_name (key="ObjectVRouter")
2: string client_fqn
}

systemlog sandesh IFMapDuplicateVmSub {
1: string client_name (key="ObjectVRouter")
2: string vm_uuid
2: string client_fqn
3: string vm_uuid
}

systemlog sandesh IFMapPeerConnError {
Expand Down Expand Up @@ -155,17 +159,20 @@ systemlog sandesh IFMapChannelProcResp {
systemlog sandesh IFMapXmppChannelEvent {
1: string event
2: string client_name (key="ObjectVRouter")
3: string client_fqn
}

systemlog sandesh IFMapXmppVrSubUnsub {
1: string op
2: string client_name (key="ObjectVRouter")
3: string client_fqn
}

systemlog sandesh IFMapXmppVmSubUnsub {
1: string op
2: string client_name (key="ObjectVRouter")
3: string vm_name
3: string client_fqn
4: string vm_name
}

systemlog sandesh IFMapClientSendInfo {
Expand Down Expand Up @@ -299,21 +306,25 @@ trace sandesh IFMapSmTransitionMessageTrace {
trace sandesh IFMapNoVrSubTrace {
1: string op
2: string client_name (key="ObjectVRouter")
3: string vm_uuid
3: string client_fqn
4: string vm_uuid
}

trace sandesh IFMapNoVmSubTrace {
1: string client_name (key="ObjectVRouter")
2: string vm_uuid
2: string client_fqn
3: string vm_uuid
}

trace sandesh IFMapDuplicateVrSubTrace {
1: string client_name (key="ObjectVRouter")
2: string client_fqn
}

trace sandesh IFMapDuplicateVmSubTrace {
1: string client_name (key="ObjectVRouter")
2: string vm_uuid
2: string client_fqn
3: string vm_uuid
}

trace sandesh IFMapPeerConnErrorTrace {
Expand Down Expand Up @@ -346,17 +357,20 @@ trace sandesh IFMapChannelProcRespTrace {
trace sandesh IFMapXmppChannelEventTrace {
1: string event
2: string client_name (key="ObjectVRouter")
3: string client_fqn
}

trace sandesh IFMapXmppVrSubUnsubTrace {
1: string op
2: string client_name (key="ObjectVRouter")
3: string client_fqn
}

trace sandesh IFMapXmppVmSubUnsubTrace {
1: string op
2: string client_name (key="ObjectVRouter")
3: string vm_name
3: string client_fqn
4: string vm_name
}

trace sandesh IFMapNodeOperationTrace {
Expand Down
35 changes: 23 additions & 12 deletions src/ifmap/ifmap_xmpp.cc
Expand Up @@ -29,6 +29,8 @@
#include "xmpp/xmpp_channel.h"
#include "xmpp/xmpp_server.h"

const std::string IFMapXmppChannel::NoFqnSet = "NoFqnSet";

// There are 3 task interactions:
// "xmpp::StateMachine" gives all the channel triggers.
// "db::DBTable" does all the work related to those triggers - except Ready
Expand Down Expand Up @@ -185,29 +187,35 @@ bool IFMapXmppChannel::MustProcessChannelNotReady() {
}

const std::string& IFMapXmppChannel::FQName() const {
return ifmap_client_->identifier();
if (ifmap_client_) {
return ifmap_client_->identifier();
} else {
return IFMapXmppChannel::NoFqnSet;
}
}

void IFMapXmppChannel::ProcessVrSubscribe(const std::string &identifier) {
// If we have already received a vr-subscribe on this channel...
if (client_added_) {
ifmap_channel_manager_->incr_dupicate_vrsub_messages();
IFMAP_XMPP_WARN(IFMapDuplicateVrSub, channel_name());
IFMAP_XMPP_WARN(IFMapDuplicateVrSub, channel_name(), FQName());
return;
}

ifmap_client_->SetIdentifier(identifier);
bool add_client = true;
ifmap_server_->ProcessClientWork(add_client, ifmap_client_);
client_added_ = true;
IFMAP_XMPP_DEBUG(IFMapXmppVrSubUnsub, "VrSubscribe", channel_name());
IFMAP_XMPP_DEBUG(IFMapXmppVrSubUnsub, "VrSubscribe", channel_name(),
FQName());
}

void IFMapXmppChannel::ProcessVmSubscribe(const std::string &vm_uuid) {
if (!client_added_) {
// If we didnt receive the vr-subscribe for this vm...
ifmap_channel_manager_->incr_vmsub_novrsub_messages();
IFMAP_XMPP_WARN(IFMapNoVrSub, "VmSubscribe", channel_name(), vm_uuid);
IFMAP_XMPP_WARN(IFMapNoVrSub, "VmSubscribe", channel_name(), FQName(),
vm_uuid);
return;
}

Expand All @@ -217,19 +225,20 @@ void IFMapXmppChannel::ProcessVmSubscribe(const std::string &vm_uuid) {
ifmap_server_->ProcessVmSubscribe(ifmap_client_->identifier(), vm_uuid,
subscribe, ifmap_client_->HasVms());
IFMAP_XMPP_DEBUG(IFMapXmppVmSubUnsub, "VmSubscribe", channel_name(),
vm_uuid);
FQName(), vm_uuid);
} else {
// If we have already received a subscribe for this vm
ifmap_channel_manager_->incr_dupicate_vmsub_messages();
IFMAP_XMPP_WARN(IFMapDuplicateVmSub, channel_name(), vm_uuid);
IFMAP_XMPP_WARN(IFMapDuplicateVmSub, channel_name(), FQName(), vm_uuid);
}
}

void IFMapXmppChannel::ProcessVmUnsubscribe(const std::string &vm_uuid) {
// If we didnt receive the vr-sub for this vm, ignore the request
if (!client_added_) {
ifmap_channel_manager_->incr_vmunsub_novrsub_messages();
IFMAP_XMPP_WARN(IFMapNoVrSub, "VmUnsubscribe", channel_name(), vm_uuid);
IFMAP_XMPP_WARN(IFMapNoVrSub, "VmUnsubscribe", channel_name(), FQName(),
vm_uuid);
return;
}

Expand All @@ -239,11 +248,11 @@ void IFMapXmppChannel::ProcessVmUnsubscribe(const std::string &vm_uuid) {
ifmap_server_->ProcessVmSubscribe(ifmap_client_->identifier(), vm_uuid,
subscribe, ifmap_client_->HasVms());
IFMAP_XMPP_DEBUG(IFMapXmppVmSubUnsub, "VmUnsubscribe", channel_name(),
vm_uuid);
FQName(), vm_uuid);
} else {
// If we didnt receive the subscribe for this vm, ignore the unsubscribe
ifmap_channel_manager_->incr_vmunsub_novmsub_messages();
IFMAP_XMPP_WARN(IFMapNoVmSub, channel_name(), vm_uuid);
IFMAP_XMPP_WARN(IFMapNoVmSub, channel_name(), FQName(), vm_uuid);
}
}

Expand Down Expand Up @@ -391,12 +400,13 @@ void IFMapChannelManager::ProcessChannelReady(XmppChannel *channel) {
IFMapXmppChannel *ifmap_chnl = FindChannel(channel);
if (ifmap_chnl == NULL) {
IFMAP_XMPP_DEBUG(IFMapXmppChannelEvent, "Create",
channel->connection()->ToUVEKey());
channel->connection()->ToUVEKey(), IFMapXmppChannel::NoFqnSet);
CreateIFMapXmppChannel(channel);
IFMapManager *ifmap_manager = ifmap_server_->get_ifmap_manager();
if (ifmap_manager && !ifmap_manager->GetEndOfRibComputed()) {
IFMAP_XMPP_DEBUG(IFMapXmppChannelEvent, "Close",
channel->connection()->ToUVEKey());
channel->connection()->ToUVEKey(),
IFMapXmppChannel::NoFqnSet);
channel->Close();
}
} else {
Expand All @@ -409,12 +419,13 @@ void IFMapChannelManager::ProcessChannelNotReady(XmppChannel *channel) {
if (ifmap_chnl) {
// If we have received subscriptions and ifmap_server knows about the
// client for this channel, ask ifmap_server to cleanup.
std::string fq_name = ifmap_chnl->FQName();
if (ifmap_chnl->MustProcessChannelNotReady()) {
bool add_client = false;
ifmap_server_->ProcessClientWork(add_client, ifmap_chnl->Sender());
}
IFMAP_XMPP_DEBUG(IFMapXmppChannelEvent, "Destroy",
channel->connection()->ToUVEKey());
channel->connection()->ToUVEKey(), fq_name);
DeleteIFMapXmppChannel(ifmap_chnl);
} else {
incr_invalid_channel_not_ready_messages();
Expand Down
3 changes: 2 additions & 1 deletion src/ifmap/ifmap_xmpp.h
Expand Up @@ -34,8 +34,9 @@ struct ChannelEventInfo {
std::string name;
};

class IFMapXmppChannel {
class IFMapXmppChannel {
public:
static const std::string NoFqnSet;
class IFMapSender;
IFMapXmppChannel(XmppChannel *, IFMapServer *, IFMapChannelManager *);
virtual ~IFMapXmppChannel();
Expand Down

0 comments on commit 1c0d9ae

Please sign in to comment.