Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
pvfs2-osd/src/client/sysint/mgmt-event-mon-list.sm
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
273 lines (234 sloc)
7.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* (C) 2003 Clemson University and The University of Chicago | |
* | |
* See COPYING in top-level directory. | |
*/ | |
/** \file | |
* \ingroup mgmtint | |
* | |
* PVFS2 management interface routines for event monitoring. | |
*/ | |
#include <string.h> | |
#include <assert.h> | |
#include "client-state-machine.h" | |
#include "pvfs2-debug.h" | |
#include "job.h" | |
#include "gossip.h" | |
#include "str-utils.h" | |
#include "pvfs2-mgmt.h" | |
#include "pint-cached-config.h" | |
#include "PINT-reqproto-encode.h" | |
extern job_context_id pint_client_sm_context; | |
/* completion function prototypes */ | |
static int event_mon_list_comp_fn( | |
void* v_p, struct PVFS_server_resp* resp_p, int i); | |
%% | |
machine pvfs2_client_mgmt_event_mon_list_sm | |
{ | |
state setup_msgpair | |
{ | |
run mgmt_event_mon_list_setup_msgpair; | |
success => xfer_msgpair; | |
default => cleanup; | |
} | |
state xfer_msgpair | |
{ | |
jump pvfs2_msgpairarray_sm; | |
default => cleanup; | |
} | |
state cleanup | |
{ | |
run mgmt_event_mon_list_cleanup; | |
default => terminate; | |
} | |
} | |
%% | |
PVFS_error PVFS_imgmt_event_mon_list( | |
PVFS_fs_id fs_id, | |
PVFS_credentials *credentials, | |
struct PVFS_mgmt_event** event_matrix, | |
PVFS_BMI_addr_t *addr_array, | |
int server_count, | |
int event_count, | |
PVFS_error_details *details, | |
PVFS_mgmt_op_id *op_id, | |
PVFS_hint hints, | |
void *user_ptr) | |
{ | |
PINT_smcb *smcb = NULL; | |
PINT_client_sm *sm_p = NULL; | |
int ret; | |
gossip_debug(GOSSIP_CLIENT_DEBUG, | |
"PVFS_imgmt_event_mon_list entered\n"); | |
if ((server_count < 1) || (event_count < 1) || | |
!event_matrix || !addr_array) | |
{ | |
return -PVFS_EINVAL; | |
} | |
PINT_smcb_alloc(&smcb, PVFS_MGMT_EVENT_MON_LIST, | |
sizeof(struct PINT_client_sm), | |
client_op_state_get_machine, | |
client_state_machine_terminate, | |
pint_client_sm_context); | |
if (!smcb) | |
{ | |
return -PVFS_ENOMEM; | |
} | |
sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); | |
PINT_init_msgarray_params(sm_p, fs_id); | |
PINT_init_sysint_credentials(sm_p->cred_p, credentials); | |
sm_p->u.event_mon_list.fs_id = fs_id; | |
sm_p->u.event_mon_list.event_matrix = event_matrix; | |
sm_p->u.event_mon_list.server_count = server_count; | |
sm_p->u.event_mon_list.event_count = event_count; | |
sm_p->u.event_mon_list.addr_array = addr_array; | |
sm_p->u.event_mon_list.details = details; | |
PVFS_hint_copy(hints, &sm_p->hints); | |
ret = PINT_msgpairarray_init(&sm_p->msgarray_op, server_count); | |
if(ret != 0) | |
{ | |
PINT_smcb_free(smcb); | |
return ret; | |
} | |
return PINT_client_state_machine_post( | |
smcb, op_id, user_ptr); | |
} | |
PVFS_error PVFS_mgmt_event_mon_list( | |
PVFS_fs_id fs_id, | |
PVFS_credentials *credentials, | |
struct PVFS_mgmt_event** event_matrix, | |
PVFS_BMI_addr_t *addr_array, | |
int server_count, | |
int event_count, | |
PVFS_error_details *details, | |
PVFS_hint hints) | |
{ | |
PVFS_error ret = -PVFS_EINVAL, error = 0; | |
PVFS_mgmt_op_id op_id; | |
gossip_debug(GOSSIP_CLIENT_DEBUG, | |
"PVFS_mgmt_event_mon_list entered\n"); | |
ret = PVFS_imgmt_event_mon_list( | |
fs_id, credentials, event_matrix, addr_array, server_count, | |
event_count, details, &op_id, hints, NULL); | |
if (ret) | |
{ | |
PVFS_perror_gossip("PVFS_imgmt_event_mon_list call", ret); | |
error = ret; | |
} | |
else | |
{ | |
ret = PVFS_mgmt_wait(op_id, "event_mon_list", &error); | |
if (ret) | |
{ | |
PVFS_perror_gossip("PVFS_mgmt_wait call", ret); | |
error = ret; | |
} | |
} | |
gossip_debug(GOSSIP_CLIENT_DEBUG, | |
"PVFS_mgmt_event_mon_list completed\n"); | |
PINT_mgmt_release(op_id); | |
return error; | |
} | |
static PINT_sm_action mgmt_event_mon_list_setup_msgpair( | |
struct PINT_smcb *smcb, job_status_s *js_p) | |
{ | |
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); | |
int i = 0; | |
PINT_sm_msgpair_state *msg_p = NULL; | |
gossip_debug(GOSSIP_CLIENT_DEBUG, "event_mon_list state: " | |
"mgmt_event_mon_list_setup_msgpair\n"); | |
js_p->error_code = 0; | |
foreach_msgpair(&sm_p->msgarray_op, msg_p, i) | |
{ | |
PINT_SERVREQ_MGMT_EVENT_MON_FILL( | |
msg_p->req, | |
*sm_p->cred_p, | |
sm_p->u.event_mon_list.event_count, | |
sm_p->hints); | |
msg_p->fs_id = sm_p->u.event_mon_list.fs_id; | |
msg_p->handle = PVFS_HANDLE_NULL; | |
msg_p->retry_flag = PVFS_MSGPAIR_RETRY; | |
msg_p->comp_fn = event_mon_list_comp_fn; | |
msg_p->svr_addr = sm_p->u.event_mon_list.addr_array[i]; | |
} | |
PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op); | |
return SM_ACTION_COMPLETE; | |
} | |
static PINT_sm_action mgmt_event_mon_list_cleanup( | |
struct PINT_smcb *smcb, job_status_s *js_p) | |
{ | |
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); | |
int i = 0, errct = 0; | |
PVFS_error error = js_p->error_code; | |
/* store server-specific errors if requested and present */ | |
if ((error != 0) && (sm_p->u.event_mon_list.details != NULL)) | |
{ | |
sm_p->u.event_mon_list.details->count_exceeded = 0; | |
for(i = 0; i < sm_p->u.event_mon_list.server_count; i++) | |
{ | |
if (sm_p->msgarray_op.msgarray[i].op_status != 0) | |
{ | |
if (errct < | |
sm_p->u.event_mon_list.details->count_allocated) | |
{ | |
sm_p->u.event_mon_list.details->error[errct].error = | |
sm_p->msgarray_op.msgarray[i].op_status; | |
sm_p->u.event_mon_list.details->error[errct].addr = | |
sm_p->msgarray_op.msgarray[i].svr_addr; | |
errct++; | |
} | |
else | |
{ | |
sm_p->u.event_mon_list.details->count_exceeded = 1; | |
} | |
} | |
} | |
sm_p->u.event_mon_list.details->count_used = errct; | |
error = -PVFS_EDETAIL; | |
} | |
PINT_msgpairarray_destroy(&sm_p->msgarray_op); | |
sm_p->error_code = error; | |
PINT_SET_OP_COMPLETE; | |
return SM_ACTION_TERMINATE; | |
} | |
static int event_mon_list_comp_fn(void* v_p, | |
struct PVFS_server_resp* resp_p, | |
int i) | |
{ | |
int j = 0; | |
PINT_smcb *smcb = v_p; | |
PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); | |
/* if this particular request was successful, then store the | |
* performance information in an array to be returned to caller | |
*/ | |
if (sm_p->msgarray_op.msgarray[i].op_status == 0) | |
{ | |
memcpy(sm_p->u.event_mon_list.event_matrix[i], | |
resp_p->u.mgmt_event_mon.event_array, | |
resp_p->u.mgmt_event_mon.event_count | |
* sizeof(struct PVFS_mgmt_event)); | |
} | |
/* if this is the last response, check all of the status values and | |
* return error code if any requests failed | |
*/ | |
if (i == (sm_p->msgarray_op.count -1)) | |
{ | |
for(j = 0; j < sm_p->msgarray_op.count; j++) | |
{ | |
if (sm_p->msgarray_op.msgarray[j].op_status != 0) | |
{ | |
return sm_p->msgarray_op.msgarray[j].op_status; | |
} | |
} | |
} | |
return 0; | |
} | |
/* | |
* Local variables: | |
* mode: c | |
* c-indent-level: 4 | |
* c-basic-offset: 4 | |
* End: | |
* | |
* vim: ft=c ts=8 sts=4 sw=4 expandtab | |
*/ |