I'd prefer something like this (and added logging when we enter and leave the
loop) :
+ while(true) {
+ if (immUtil.getObject(su, &attributes) == false) {
+
LOG_NO("SmfUpgradeProcedure::getImmComponentInfo: Could not get object %s",
su.c_str());
+ rc = false;
+ goto done;
+ }
+
+ hostedByNode = (SaNameT *)immutil_getNameAttr((const
SaImmAttrValuesT_2 **)attributes,
+
"saAmfSUHostedByNode",
+ 0);
++ if (hostedByNode != NULL) {
++ break;
++ }
++
+ if(timeout <= 0) { //Timeout
+
LOG_NO("SmfUpgradeProcedure::getImmComponentInfo: No hostedByNode attr is set
for %s", su.c_str());
+ rc = false;
+ goto done;
+ }
+
+ sleep(interval);
+ timeout -= interval;
++ //No hostedByNode was set, read the same
object again
+ } //End while(true)
-----Original Message-----
From: Ingvar Bergström
Sent: den 3 september 2013 12:35
To: Bertil Engelholm
Cc: [email protected]
Subject: [PATCH 1 of 1] smfd: Re-read SaAmfSU attribute saAmfSUHostedByNode
until set (#557)
osaf/services/saf/smfsv/smfd/SmfUpgradeProcedure.cc | 71 ++++++++++++--------
1 files changed, 43 insertions(+), 28 deletions(-)
In some cases the SU instance attribute saAmfSUHostedByNode is yet not set when
read by smfd.
Smfd waits until the attribute is set by AMF. Timeout is configurable. The node
reboot timeout is used.
diff --git a/osaf/services/saf/smfsv/smfd/SmfUpgradeProcedure.cc
b/osaf/services/saf/smfsv/smfd/SmfUpgradeProcedure.cc
--- a/osaf/services/saf/smfsv/smfd/SmfUpgradeProcedure.cc
+++ b/osaf/services/saf/smfsv/smfd/SmfUpgradeProcedure.cc
@@ -2879,34 +2879,49 @@ SmfUpgradeProcedure::getImmComponentInfo
std::string su(comp.substr(comp.find(',') + 1,
std::string::npos));
std::string sg(su.substr(su.find(',') + 1, std::string::npos));
- if (immUtil.getObject(su, &attributes) == false) {
- LOG_NO("SmfUpgradeProcedure::getImmComponentInfo: Could
not get object %s", su.c_str());
- rc = false;
- goto done;
- }
-
- typeRef = immutil_getNameAttr((const SaImmAttrValuesT_2
**)attributes, "saAmfSUType", 0);
- std::string suType((char *)typeRef->value);
-
- const SaNameT *hostedByNode = immutil_getNameAttr((const
SaImmAttrValuesT_2 **)attributes,
-
"saAmfSUHostedByNode",
- 0);
- if (hostedByNode == NULL) {
- LOG_NO("SmfUpgradeProcedure::getImmComponentInfo: No
hostedByNode attr is set for %s", su.c_str());
- rc = false;
- goto done;
- }
-
- std::string node((char *)hostedByNode->value);
-
- //Save result in a multimap
- //Node as key
- i_objects.insert(std::pair<std::string, objectInst>(node,
objectInst(node,
-
sg,
-
su,
-
suType,
-
comp,
-
compType)));
+ //The attribute hostedByNode may not be set by AMF yet
+ //SMFD tries to read the attribute every 5 seconds until set
+ //Times out after time configured as reboot timeout
+ int interval = 5; //seconds
+ int timeout = smfd_cb->rebootTimeout/1000000000; //seconds
+ SaNameT *hostedByNode = 0;
+ while(true) {
+ if (immUtil.getObject(su, &attributes) == false) {
+
LOG_NO("SmfUpgradeProcedure::getImmComponentInfo: Could not get object %s",
su.c_str());
+ rc = false;
+ goto done;
+ }
+
+ hostedByNode = (SaNameT *)immutil_getNameAttr((const
SaImmAttrValuesT_2 **)attributes,
+
"saAmfSUHostedByNode",
+ 0);
+ if (hostedByNode == NULL) {
+ if(timeout <= 0) { //Timeout
+
LOG_NO("SmfUpgradeProcedure::getImmComponentInfo: No hostedByNode attr is set
for %s", su.c_str());
+ rc = false;
+ goto done;
+ }
+
+ sleep(interval);
+ timeout -= interval;
+ continue; //No hostedByNode was set, read the
same object again
+ }
+
+ break; //Exit the while loop
+ } //End while(true)
+
+ std::string node((char *)hostedByNode->value);
+ typeRef = immutil_getNameAttr((const SaImmAttrValuesT_2
**)attributes, "saAmfSUType", 0);
+ std::string suType((char *)typeRef->value);
+
+ //Save result in a multimap
+ //Node as key
+ i_objects.insert(std::pair<std::string, objectInst>(node,
objectInst(node,
+
sg,
+
su,
+
suType,
+
comp,
+
compType)));
}
done:
(void) immutil_saImmOmSearchFinalize(immSearchHandle);
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel