Re: [devel] [PATCH 1/1] evtd: handle CLM-API errors during SC absence [#3081]

2019-09-10 Thread Mathi N P
About the patch, I have no clue why the indentation looks strange.
I just have a question below, otherwise ack:
+while (true) {
+/* Say Hello */
+rc = saClmInitialize_4(>clm_hdl, _cbk, _version);
+if (rc == SA_AIS_OK)
+break;
+else if (rc == SA_AIS_ERR_TRY_AGAIN ||
+rc == SA_AIS_ERR_UNAVAILABLE) {
+osaf_nanosleep();
+continue;

IMM utils implement a global retry counter. I haven't thought through the
big picture yet, so leaving it to you to decide whether
such a retry counter makes sense here?

Thanks,
Mathi.

On Thu, Sep 5, 2019 at 9:21 PM Jones, Alex  wrote:

> Handle CLM-API errors during SC absence.
> ---
> src/evt/common/edsv_defs.h | 2 +-
> src/evt/evtd/eds_amf.c | 71 ++
> src/evt/evtd/eds_amf.h | 11 --
> src/evt/evtd/eds_cb.c | 6 +++-
> 4 files changed, 72 insertions(+), 18 deletions(-)
>
> diff --git a/src/evt/common/edsv_defs.h b/src/evt/common/edsv_defs.h
> index 8372ce8a8..24604927c 100644
> --- a/src/evt/common/edsv_defs.h
> +++ b/src/evt/common/edsv_defs.h
> @@ -82,7 +82,7 @@
>
> #define m_EDSV_GET_CLM_VER(amf_ver) \
> amf_ver.releaseCode = 'B'; \
> - amf_ver.majorVersion = 0x01; \
> + amf_ver.majorVersion = 0x04; \
> amf_ver.minorVersion = 0x01;
>
> /* Define our limits */
> diff --git a/src/evt/evtd/eds_amf.c b/src/evt/evtd/eds_amf.c
> index fe90a6c62..97b71a5bd 100644
> --- a/src/evt/evtd/eds_amf.c
> +++ b/src/evt/evtd/eds_amf.c
> @@ -26,6 +26,7 @@ DESCRIPTION:
> This include file contains AMF interaction logic for health-check and other
> stuff.
>
> ***/
> +#include "base/osaf_time.h"
> #include "eds.h"
> #include "eds_dl_api.h"
>
> @@ -622,9 +623,9 @@ uint32_t eds_amf_register(EDS_CB *eds_cb)
> SaAisErrorT eds_clm_init(EDS_CB *cb)
> {
> SaVersionT clm_version;
> -SaClmCallbacksT clm_cbk;
> -SaClmClusterNodeT cluster_node;
> -SaClmClusterNotificationBufferT notify_buff;
> +SaClmCallbacksT_4 clm_cbk;
> +SaClmClusterNodeT_4 cluster_node;
> +SaClmClusterNotificationBufferT_4 notify_buff;
> SaAisErrorT rc = SA_AIS_OK;
> SaTimeT timeout = EDSV_CLM_TIMEOUT;
> TRACE_ENTER();
> @@ -639,13 +640,22 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> clm_cbk.saClmClusterNodeGetCallback = NULL;
> clm_cbk.saClmClusterTrackCallback = eds_clm_cluster_track_cbk;
>
> -/* Say Hello */
> -rc = saClmInitialize(>clm_hdl, _cbk, _version);
> -if (rc != SA_AIS_OK) {
> -LOG_ER("saClmInitialize failed with error: %d", rc);
> -TRACE_LEAVE();
> -return rc;
> +while (true) {
> +/* Say Hello */
> +rc = saClmInitialize_4(>clm_hdl, _cbk, _version);
> +if (rc == SA_AIS_OK)
> +break;
> +else if (rc == SA_AIS_ERR_TRY_AGAIN ||
> +rc == SA_AIS_ERR_UNAVAILABLE) {
> +osaf_nanosleep();
> +continue;
> +} else {
> +LOG_ER("saClmInitialize_4 failed with error: %d", rc);
> +TRACE_LEAVE();
> +return rc;
> +}
> }
> +
> /* Get the FD */
> if (SA_AIS_OK !=
> (rc = saClmSelectionObjectGet(cb->clm_hdl, >clm_sel_obj))) {
> @@ -654,10 +664,10 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> return rc;
> }
> /* Get your own node id */
> -rc = saClmClusterNodeGet(cb->clm_hdl, SA_CLM_LOCAL_NODE_ID, timeout,
> +rc = saClmClusterNodeGet_4(cb->clm_hdl, SA_CLM_LOCAL_NODE_ID, timeout,
> _node);
> if (rc != SA_AIS_OK) {
> -LOG_ER("saClmClusterNodeGet failed with error: %d", rc);
> +LOG_ER("saClmClusterNodeGet_4 failed with error: %d", rc);
> TRACE_LEAVE();
> return rc;
> }
> @@ -665,7 +675,7 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> cb->node_id = cluster_node.nodeId;
>
> notify_buff.notification = NULL;
> -rc = saClmClusterTrack(cb->clm_hdl,
> +rc = saClmClusterTrack_4(cb->clm_hdl,
> (SA_TRACK_CURRENT | SA_TRACK_CHANGES), NULL);
> if (rc != SA_AIS_OK)
> LOG_ER("saClmClusterTrack failed with error: %d", rc);
> @@ -674,6 +684,33 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> return rc;
> }
>
> +static void * eds_clm_init_thread(void *arg) {
> + TRACE_ENTER();
> + EDS_CB *cb = (EDS_CB *)(arg);
> +
> + eds_clm_init(cb);
> +
> + TRACE_LEAVE();
> + return 0;
> +}
> +
> +SaAisErrorT eds_clm_reinit_bg(EDS_CB *cb)
> +{
> +pthread_t thread;
> +pthread_attr_t attr;
> +pthread_attr_init();
> +pthread_attr_setdetachstate(, PTHREAD_CREATE_DETACHED);
> +
> +if (pthread_create(, , eds_clm_init_thread, cb) != 0) {
> +LOG_ER("pthread_create FAILED: %s", strerror(errno));
> +exit(EXIT_FAILURE);
> +}
> +
> +pthread_attr_destroy();
> +
> +return SA_AIS_OK;
> +}
> +
> /**
> * Function: eds_clm_cluster_track_cbk
> *
> @@ -700,8 +737,14 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> **/
>
> void eds_clm_cluster_track_cbk(
> - const SaClmClusterNotificationBufferT *notificationBuffer,
> - SaUint32T numberOfMembers, SaAisErrorT error)
> +const SaClmClusterNotificationBufferT_4 *notificationBuffer,
> +SaUint32T numberOfMembers,
> +SaInvocationT invocation,
> +const SaNameT *rootCauseEntity,
> +const SaNtfCorrelationIdsT *correlationIds,
> 

[devel] [PATCH 1/1] evtd: handle CLM-API errors during SC absence [#3081]

2019-09-05 Thread Jones, Alex
Handle CLM-API errors during SC absence.
---
 src/evt/common/edsv_defs.h |  2 +-
 src/evt/evtd/eds_amf.c | 71 ++
 src/evt/evtd/eds_amf.h | 11 --
 src/evt/evtd/eds_cb.c  |  6 +++-
 4 files changed, 72 insertions(+), 18 deletions(-)

diff --git a/src/evt/common/edsv_defs.h b/src/evt/common/edsv_defs.h
index 8372ce8a8..24604927c 100644
--- a/src/evt/common/edsv_defs.h
+++ b/src/evt/common/edsv_defs.h
@@ -82,7 +82,7 @@

 #define m_EDSV_GET_CLM_VER(amf_ver) \
   amf_ver.releaseCode = 'B';\
-  amf_ver.majorVersion = 0x01;  \
+  amf_ver.majorVersion = 0x04;  \
   amf_ver.minorVersion = 0x01;

 /* Define our limits */
diff --git a/src/evt/evtd/eds_amf.c b/src/evt/evtd/eds_amf.c
index fe90a6c62..97b71a5bd 100644
--- a/src/evt/evtd/eds_amf.c
+++ b/src/evt/evtd/eds_amf.c
@@ -26,6 +26,7 @@ DESCRIPTION:
 This include file contains AMF interaction logic for health-check and other
 stuff.
 
***/
+#include "base/osaf_time.h"
 #include "eds.h"
 #include "eds_dl_api.h"

@@ -622,9 +623,9 @@ uint32_t eds_amf_register(EDS_CB *eds_cb)
 SaAisErrorT eds_clm_init(EDS_CB *cb)
 {
 SaVersionT clm_version;
-SaClmCallbacksT clm_cbk;
-SaClmClusterNodeT cluster_node;
-SaClmClusterNotificationBufferT notify_buff;
+SaClmCallbacksT_4 clm_cbk;
+SaClmClusterNodeT_4 cluster_node;
+SaClmClusterNotificationBufferT_4 notify_buff;
 SaAisErrorT rc = SA_AIS_OK;
 SaTimeT timeout = EDSV_CLM_TIMEOUT;
 TRACE_ENTER();
@@ -639,13 +640,22 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
 clm_cbk.saClmClusterNodeGetCallback = NULL;
 clm_cbk.saClmClusterTrackCallback = eds_clm_cluster_track_cbk;

-/* Say Hello */
-rc = saClmInitialize(>clm_hdl, _cbk, _version);
-if (rc != SA_AIS_OK) {
-LOG_ER("saClmInitialize failed with error: %d", rc);
-TRACE_LEAVE();
-return rc;
+while (true) {
+/* Say Hello */
+rc = saClmInitialize_4(>clm_hdl, _cbk, _version);
+if (rc == SA_AIS_OK)
+break;
+else if (rc == SA_AIS_ERR_TRY_AGAIN ||
+rc == SA_AIS_ERR_UNAVAILABLE) {
+osaf_nanosleep();
+continue;
+} else {
+LOG_ER("saClmInitialize_4 failed with error: %d", rc);
+TRACE_LEAVE();
+return rc;
+}
 }
+
 /* Get the FD */
 if (SA_AIS_OK !=
 (rc = saClmSelectionObjectGet(cb->clm_hdl, >clm_sel_obj))) {
@@ -654,10 +664,10 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
 return rc;
 }
 /* Get your own node id */
-rc = saClmClusterNodeGet(cb->clm_hdl, SA_CLM_LOCAL_NODE_ID, timeout,
+rc = saClmClusterNodeGet_4(cb->clm_hdl, SA_CLM_LOCAL_NODE_ID, timeout,
  _node);
 if (rc != SA_AIS_OK) {
-LOG_ER("saClmClusterNodeGet failed with error: %d", rc);
+LOG_ER("saClmClusterNodeGet_4 failed with error: %d", rc);
 TRACE_LEAVE();
 return rc;
 }
@@ -665,7 +675,7 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
 cb->node_id = cluster_node.nodeId;

 notify_buff.notification = NULL;
-rc = saClmClusterTrack(cb->clm_hdl,
+rc = saClmClusterTrack_4(cb->clm_hdl,
(SA_TRACK_CURRENT | SA_TRACK_CHANGES), NULL);
 if (rc != SA_AIS_OK)
 LOG_ER("saClmClusterTrack failed with error: %d", rc);
@@ -674,6 +684,33 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
 return rc;
 }

+static void * eds_clm_init_thread(void *arg) {
+   TRACE_ENTER();
+   EDS_CB *cb = (EDS_CB *)(arg);
+
+   eds_clm_init(cb);
+
+   TRACE_LEAVE();
+   return 0;
+}
+
+SaAisErrorT eds_clm_reinit_bg(EDS_CB *cb)
+{
+pthread_t thread;
+pthread_attr_t attr;
+pthread_attr_init();
+pthread_attr_setdetachstate(, PTHREAD_CREATE_DETACHED);
+
+if (pthread_create(, , eds_clm_init_thread, cb) != 0) {
+LOG_ER("pthread_create FAILED: %s", strerror(errno));
+exit(EXIT_FAILURE);
+}
+
+pthread_attr_destroy();
+
+return SA_AIS_OK;
+}
+
 /**
  * Function: eds_clm_cluster_track_cbk
  *
@@ -700,8 +737,14 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
  **/

 void eds_clm_cluster_track_cbk(
-const SaClmClusterNotificationBufferT *notificationBuffer,
-SaUint32T numberOfMembers, SaAisErrorT error)
+const SaClmClusterNotificationBufferT_4 *notificationBuffer,
+SaUint32T numberOfMembers,
+SaInvocationT invocation,
+const SaNameT *rootCauseEntity,
+const SaNtfCorrelationIdsT *correlationIds,
+SaClmChangeStepT step,
+SaTimeT timeSupervision,
+SaAisErrorT error)
 {
 EDS_CB *cb = NULL;
 NODE_ID node_id;
diff --git a/src/evt/evtd/eds_amf.h b/src/evt/evtd/eds_amf.h
index 8b0b7b0a0..e9aeaa6c6 100644
--- a/src/evt/evtd/eds_amf.h
+++ b/src/evt/evtd/eds_amf.h
@@ -81,9 +81,16 @@ void eds_amf_csi_rmv_callback(SaInvocationT invocation, 
const SaNameT *compName,
 uint32_t eds_amf_register(EDS_CB *);

 SaAisErrorT eds_clm_init(EDS_CB *cb);
+SaAisErrorT eds_clm_reinit_bg(EDS_CB *cb);
 void eds_clm_cluster_track_cbk(
-const SaClmClusterNotificationBufferT *notificationBuffer,
-SaUint32T numberOfMembers, SaAisErrorT error);
+const SaClmClusterNotificationBufferT_4 *notificationBuffer,
+SaUint32T