Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=390... Commit: 390e19b31e8783b4c80b6e044ec06978bdb20c1e Parent: 39919bc11779ca18490548199e977c8a93c627be Author: Lon Hohberger lhh@redhat.com AuthorDate: Thu Sep 9 10:58:17 2010 -0400 Committer: Lon Hohberger lhh@redhat.com CommitterDate: Fri Sep 24 16:16:03 2010 -0400
rgmanager: Support convalesce w/ central_processing
Resolves: rhbz#605733
Signed-off-by: Lon Hohberger lhh@redhat.com --- rgmanager/include/event.h | 1 + rgmanager/src/daemons/service_op.c | 84 +++++++++++++++++++++++ rgmanager/src/daemons/slang_event.c | 18 +++++- rgmanager/src/resources/default_event_script.sl | 4 + 4 files changed, 106 insertions(+), 1 deletions(-)
diff --git a/rgmanager/include/event.h b/rgmanager/include/event.h index 378ee4c..7e628d8 100644 --- a/rgmanager/include/event.h +++ b/rgmanager/include/event.h @@ -141,6 +141,7 @@ void set_transition_throttling(int nsecs); int service_op_start(char *svcName, int *target_list, int target_list_len, int *new_owner); int service_op_stop(char *svcName, int do_disable, int event_type); +int service_op_convalesce(char *svcName);
#endif diff --git a/rgmanager/src/daemons/service_op.c b/rgmanager/src/daemons/service_op.c index 8e1cc91..6b0db24 100644 --- a/rgmanager/src/daemons/service_op.c +++ b/rgmanager/src/daemons/service_op.c @@ -206,6 +206,90 @@ service_op_stop(char *svcName, int do_disable, int event_type) }
+int +service_op_convalesce(char *svcName) +{ + SmMessageSt msg; + int msg_ret; + msgctx_t ctx; + rg_state_t svcStatus; + int msgtarget = my_id(); + + /* Build the message header */ + msg.sm_hdr.gh_magic = GENERIC_HDR_MAGIC; + msg.sm_hdr.gh_command = RG_ACTION_REQUEST; + msg.sm_hdr.gh_arg1 = RG_ACTION_MASTER; + msg.sm_hdr.gh_length = sizeof (SmMessageSt); + + msg.sm_data.d_action = RG_CONVALESCE; + + strncpy(msg.sm_data.d_svcName, svcName, + sizeof(msg.sm_data.d_svcName)); + msg.sm_data.d_ret = 0; + msg.sm_data.d_svcOwner = 0; + + /* Open a connection to the local node - it will decide what to + do in this case. XXX inefficient; should queue requests + locally and immediately forward requests otherwise */ + + if (get_service_state_internal(svcName, &svcStatus) < 0) + return RG_EFAIL; + if (svcStatus.rs_owner > 0) { + if (member_online(svcStatus.rs_owner)) { + msgtarget = svcStatus.rs_owner; + } else { + /* If the owner is not online, + mark the service as 'stopped' but + otherwise, do nothing. + */ + return svc_stop(svcName, RG_STOP); + } + } + + if (msg_open(MSG_CLUSTER, msgtarget, RG_PORT, &ctx, 2 * cluster_timeout)< 0) { + clulog(LOG_ERR, + "#58: Failed opening connection to member #%d\n", + my_id()); + return -1; + } + + /* Encode */ + swab_SmMessageSt(&msg); + + /* Send stop message to the other node */ + if (msg_send(&ctx, &msg, sizeof (SmMessageSt)) < + (int)sizeof (SmMessageSt)) { + clulog(LOG_ERR, "Failed to send complete message\n"); + msg_close(&ctx); + return -1; + } + + /* Check the response */ + do { + msg_ret = msg_receive(&ctx, &msg, + sizeof (SmMessageSt), 10); + if ((msg_ret == -1 && errno != ETIMEDOUT) || + (msg_ret > 0)) { + break; + } + } while(1); + + if (msg_ret != sizeof (SmMessageSt)) { + clulog(LOG_WARNING, "Strange response size: %d vs %d\n", + msg_ret, (int)sizeof(SmMessageSt)); + return 0; /* XXX really UNKNOWN */ + } + + /* Got a valid response from other node. */ + msg_close(&ctx); + + /* Decode */ + swab_SmMessageSt(&msg); + + return msg.sm_data.d_ret; +} + + /* TODO service_op_migrate() diff --git a/rgmanager/src/daemons/slang_event.c b/rgmanager/src/daemons/slang_event.c index 086ac6b..08974ad 100644 --- a/rgmanager/src/daemons/slang_event.c +++ b/rgmanager/src/daemons/slang_event.c @@ -102,7 +102,8 @@ static int _user_restart = RG_RESTART, _user_migrate = RG_MIGRATE, _user_freeze = RG_FREEZE, - _user_unfreeze = RG_UNFREEZE; + _user_unfreeze = RG_UNFREEZE, + _user_convalesce = RG_CONVALESCE;
SLang_Intrin_Var_Type rgmanager_vars[] = @@ -155,6 +156,7 @@ SLang_Intrin_Var_Type rgmanager_vars[] = MAKE_VARIABLE("USER_MIGRATE", &_user_migrate, SLANG_INT_TYPE, 1), MAKE_VARIABLE("USER_FREEZE", &_user_freeze, SLANG_INT_TYPE, 1), MAKE_VARIABLE("USER_UNFREEZE", &_user_unfreeze,SLANG_INT_TYPE, 1), + MAKE_VARIABLE("USER_CONVALESCE",&_user_convalesce,SLANG_INT_TYPE, 1),
/* Errors */ MAKE_VARIABLE("rg_error", &_rg_err, SLANG_INT_TYPE, 1), @@ -469,6 +471,18 @@ sl_service_property(char *svcName, char *prop) /** usage:
+ service_convalesce(name); + */ +static int +sl_convalesce_service(const char *svcname) +{ + return service_op_convalesce(svcname); +} + + +/** + usage: + stop_service(name, disable_flag); */ int @@ -999,6 +1013,8 @@ SLang_Intrin_Fun_Type rgmanager_slang[] = SLANG_VOID_TYPE), MAKE_INTRINSIC_S("service_domain_info", sl_domain_info, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("service_stop", sl_stop_service, SLANG_INT_TYPE), + MAKE_INTRINSIC_S((char *)"service_convalesce", sl_convalesce_service, + SLANG_INT_TYPE), MAKE_INTRINSIC_0("service_start", sl_start_service, SLANG_INT_TYPE), MAKE_INTRINSIC_S("service_status", sl_service_status, SLANG_VOID_TYPE), diff --git a/rgmanager/src/resources/default_event_script.sl b/rgmanager/src/resources/default_event_script.sl index 25347eb..da6bc1f 100644 --- a/rgmanager/src/resources/default_event_script.sl +++ b/rgmanager/src/resources/default_event_script.sl @@ -593,6 +593,10 @@ define default_user_event_handler()
ret = service_unfreeze(service_name);
+ } else if (user_request == USER_CONVALESCE) { + + ret = service_convalesce(service_name); + }
%
cluster-commits@lists.fedorahosted.org