diff options
author | Amar Tumballi <amar@gluster.com> | 2010-07-08 08:16:13 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-07-08 23:28:08 -0700 |
commit | 915adb9c1291d140e57765b7fad0c5bb0e7d5ed5 (patch) | |
tree | 0330fa8796e18601ef7ef1441b6d4eb0df8cb9b6 /xlators/mgmt/glusterd/src/glusterd-op-sm.h | |
parent | 7e489f3cc7f3eb738d2698dcf588bad0bdc12a8b (diff) |
gluster-CLI-and-mgmt-glusterd-added-to-codebase
Signed-off-by: Vijay Bellur <vijay@gluster.com>
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 971 (dynamic volume management)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.h')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.h | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h new file mode 100644 index 000000000..61bdc8885 --- /dev/null +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h @@ -0,0 +1,167 @@ +/* + Copyright (c) 2006-2009 Gluster, Inc. <http://www.gluster.com> + This file is part of GlusterFS. + + GlusterFS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + GlusterFS is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see + <http://www.gnu.org/licenses/>. +*/ + +#ifndef _GLUSTERD_OP_SM_H_ +#define _GLUSTERD_OP_SM_H_ + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include <pthread.h> +#include <uuid/uuid.h> + +#include "glusterfs.h" +#include "xlator.h" +#include "logging.h" +#include "call-stub.h" +#include "authenticate.h" +#include "fd.h" +#include "byte-order.h" +#include "glusterd.h" + +#define GD_VOLUME_NAME_MAX 256 + +typedef enum glusterd_op_sm_state_ { + GD_OP_STATE_DEFAULT = 0, + GD_OP_STATE_LOCK_SENT, + GD_OP_STATE_LOCKED, + GD_OP_STATE_STAGE_OP_SENT, + GD_OP_STATE_STAGED, + GD_OP_STATE_COMMIT_OP_SENT, + GD_OP_STATE_COMMITED, + GD_OP_STATE_UNLOCK_SENT, + GD_OP_STATE_MAX, +} glusterd_op_sm_state_t; + +typedef enum glusterd_op_sm_event_type_ { + GD_OP_EVENT_NONE = 0, + GD_OP_EVENT_START_LOCK, + GD_OP_EVENT_LOCK, + GD_OP_EVENT_RCVD_ACC, + GD_OP_EVENT_ALL_ACC, + GD_OP_EVENT_STAGE_ACC, + GD_OP_EVENT_COMMIT_ACC, + GD_OP_EVENT_RCVD_RJT, + GD_OP_EVENT_STAGE_OP, + GD_OP_EVENT_COMMIT_OP, + GD_OP_EVENT_UNLOCK, + GD_OP_EVENT_MAX +} glusterd_op_sm_event_type_t; + + +struct glusterd_op_sm_event_ { + struct list_head list; + void *ctx; + glusterd_op_sm_event_type_t event; +}; + +typedef struct glusterd_op_sm_event_ glusterd_op_sm_event_t; + +typedef int (*glusterd_op_sm_ac_fn) (glusterd_op_sm_event_t *, void *); + +typedef struct glusterd_op_sm_ { + glusterd_op_sm_state_t next_state; + glusterd_op_sm_ac_fn handler; +} glusterd_op_sm_t; + +typedef enum glusterd_op_ { + GD_OP_NONE = 0, + GD_OP_CREATE_VOLUME, + GD_OP_START_BRICK, + GD_OP_STOP_BRICK, + GD_OP_DELETE_VOLUME, + GD_OP_START_VOLUME, + GD_OP_STOP_VOLUME, + GD_OP_RENAME_VOLUME, + GD_OP_DEFRAG_VOLUME, + GD_OP_ADD_BRICK, + GD_OP_REMOVE_BRICK, + GD_OP_REPLACE_BRICK, + GD_OP_SYNC_VOLUME, + GD_OP_MAX, +} glusterd_op_t; + +typedef struct glusterd_op_sm_state_info_ { + glusterd_op_sm_state_t state; + struct timeval time; +} glusterd_op_sm_state_info_t; + +struct glusterd_op_info_ { + glusterd_op_sm_state_info_t state; + int32_t pending_count; + int32_t op_count; + glusterd_op_t op[GD_OP_MAX]; + glusterd_op_t pending_op[GD_OP_MAX]; + glusterd_op_t commit_op[GD_OP_MAX]; + struct list_head op_peers; + void *op_ctx[GD_OP_MAX]; +}; + +typedef struct glusterd_op_info_ glusterd_op_info_t; + +struct glusterd_op_create_volume_ctx_ { + char volume_name[GD_VOLUME_NAME_MAX]; +}; + +typedef struct glusterd_op_create_volume_ctx_ glusterd_op_create_volume_ctx_t; + + +struct glusterd_op_lock_ctx_ { + uuid_t uuid; + rpcsvc_request_t *req; +}; + +typedef struct glusterd_op_lock_ctx_ glusterd_op_lock_ctx_t; + +struct glusterd_op_stage_ctx_ { + rpcsvc_request_t *req; + void *stage_req; +}; + +typedef struct glusterd_op_stage_ctx_ glusterd_op_stage_ctx_t; + +typedef glusterd_op_stage_ctx_t glusterd_op_commit_ctx_t; + +int +glusterd_op_sm_new_event (glusterd_op_sm_event_type_t event_type, + glusterd_op_sm_event_t **new_event); +int +glusterd_op_sm_inject_event (glusterd_op_sm_event_t *event); + +int +glusterd_op_sm_init (); + +int +glusterd_op_sm (); + +int32_t +glusterd_op_set_ctx (glusterd_op_t op, void *ctx); + +int32_t +glusterd_op_set_op (glusterd_op_t op); + +int +glusterd_op_build_payload (glusterd_op_t op, gd1_mgmt_stage_op_req **req); + + +void * +glusterd_op_get_ctx (glusterd_op_t op); +#endif |