Main Page   Compound List   File List   Compound Members   File Members  

ce.h

Go to the documentation of this file.
00001 /**************************************************************/
00002 /* CE.H */
00003 /* Author: Ohad Rodeh */
00004 /* Based on code by Mark Hayden and Alexey Vaysburd. */
00005 /**************************************************************/
00013 /**************************************************************/
00014 
00015 #ifndef __CE_H__
00016 #define __CE_H__
00017 
00018 #include "e_iovec.h"
00019 #include "ce_so.h"
00020 #include <memory.h>
00021 
00022 #ifdef _WIN32
00023 #include <winsock2.h>
00024 #endif
00025 
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00034 typedef double      ce_float_t ;
00035 
00038 typedef int         ce_bool_t ;
00039 
00044 typedef int         ce_rank_t ;
00045 
00048 typedef int         ce_ltime_t ;
00049 
00052 typedef int         ce_len_t ;
00053 
00058 typedef void       *ce_env_t ;
00059 
00062 typedef double      ce_time_t ;
00063 
00067 typedef char*       ce_endpt_t;
00068 
00071 typedef char*       ce_addr_t;
00072 
00075 typedef char       *ce_data_t;
00076 
00080 typedef ce_iovec_t *ce_iovec_array_t;
00081 
00082 /* An array of boolean values. 
00083  */
00084 typedef ce_bool_t  *ce_bool_array_t;
00085 
00089 typedef ce_endpt_t *ce_endpt_array_t ;
00090 
00093 typedef ce_rank_t  *ce_rank_array_t ;
00094 
00098 typedef ce_addr_t  *ce_addr_array_t ;
00099 
00109 typedef struct ce_view_id_t {
00110     ce_ltime_t ltime ;
00111     ce_endpt_t endpt ;
00112 } ce_view_id_t ;
00113 
00116 typedef ce_view_id_t **ce_view_id_array_t;
00117 
00123 typedef struct ce_view_state_t {
00124     char* version ;                
00125     char* group ;                  
00126     char* proto ;                  
00127     ce_rank_t coord ;              
00128     int ltime ;                    
00129     ce_bool_t primary ;            
00130     ce_bool_t groupd ;             
00131     ce_bool_t xfer_view ;          
00132     char* key ;                    
00133     int num_ids ;                  
00134     ce_view_id_array_t prev_ids ;  
00135     char *params;                  
00136     ce_time_t uptime ;             
00137     ce_endpt_array_t view ;        
00138     ce_addr_array_t address ;      
00139 } ce_view_state_t ;
00140 
00145 typedef struct ce_local_state_t {
00146     ce_endpt_t endpt ;             
00147     ce_addr_t addr ;               
00148     ce_rank_t rank ;               
00149     char* name ;                   
00150     int nmembers ;                 
00151     ce_view_id_t *view_id ;        
00152     ce_bool_t am_coord ;           
00153 } ce_local_state_t ;
00154 
00159 typedef struct ce_jops_t {
00160     ce_time_t hrtbt_rate ;         
00161     char *transports ;             
00162     char *protocol ;               
00163     char *group_name ;             
00164     char *properties ;             
00165     ce_bool_t use_properties ;     
00166     ce_bool_t groupd ;             
00167     char *params ;                 
00168     ce_bool_t client;              
00169     ce_bool_t debug ;              
00170     char *endpt ;                  
00171     char *princ ;                  
00172     char *key ;                    
00173     ce_bool_t secure ;             
00174 } ce_jops_t;
00175 
00179 #define CE_DEFAULT_PROTOCOL "Top:Heal:Switch:Leave:Inter:Intra:Elect:Merge:Slander:Sync:Suspect:Stable:Vsync:Frag_Abv:Top_appl:Frag:Pt2ptw:Mflow:Pt2pt:Mnak:Bottom"
00180 
00181 
00186 #define CE_DEFAULT_PROPERTIES "Gmp:Sync:Heal:Switch:Frag:Suspect:Flow:Slander"
00187 
00188 /**************************************************************/
00189 /*
00190  * Utilities
00191  */
00192 
00195 #define record_create(type, var) ((type)malloc(sizeof(*var)))
00196  
00199 #define record_free(rec) free(rec)
00200 
00203 #define record_clear(rec) memset(rec, 0, sizeof(*rec))
00204 
00208 LINKDLL char *ce_copy_string(char *str);
00209 
00214 LINKDLL void ce_view_full_free(ce_local_state_t *ls, ce_view_state_t* vs);
00215 
00219 LINKDLL void ce_jops_free(ce_jops_t*) ;
00220 
00221 /**************************************************************/
00225 
00230 typedef void (*ce_appl_install_t)(ce_env_t, ce_local_state_t*, ce_view_state_t*);
00231 
00234 typedef void (*ce_appl_exit_t)(ce_env_t) ;
00235 
00241 typedef void (*ce_appl_receive_cast_t)(ce_env_t, ce_rank_t, int, ce_iovec_array_t) ;
00242 
00248 typedef void (*ce_appl_receive_send_t)(ce_env_t, ce_rank_t, int, ce_iovec_array_t) ;
00249 
00254 typedef void (*ce_appl_flow_block_t)(ce_env_t, ce_rank_t, ce_bool_t) ;
00255 
00260 typedef void (*ce_appl_block_t)(ce_env_t) ;
00261 
00265 typedef void (*ce_appl_heartbeat_t)(ce_env_t, ce_time_t) ;
00266 
00273 typedef struct ce_appl_intf_t ce_appl_intf_t ;
00274 
00296 LINKDLL ce_appl_intf_t*
00297 ce_create_intf(ce_env_t env, 
00298                ce_appl_exit_t exit,
00299                ce_appl_install_t install,
00300                ce_appl_flow_block_t flow_block,
00301                ce_appl_block_t block,
00302                ce_appl_receive_cast_t cast,
00303                ce_appl_receive_send_t send,
00304                ce_appl_heartbeat_t heartbeat
00305     );
00306 
00307 /**************************************************************/
00308 
00319 LINKDLL void ce_Init(
00320     int argc,
00321     char **argv
00322     ) ;
00323 
00326 LINKDLL void ce_Main_loop (void);
00327  
00332 LINKDLL void ce_Join(
00333     ce_jops_t *ops,
00334     ce_appl_intf_t *c_appl
00335     ) ;
00336 
00337 /**************************************************************/
00338 /* The set of actions supported on a group. 
00339  */
00340 
00344 LINKDLL void ce_Leave(ce_appl_intf_t *c_appl) ;
00345 
00351 LINKDLL void ce_Cast(
00352     ce_appl_intf_t *c_appl,
00353     int num,
00354     ce_iovec_array_t iovl
00355     ) ;
00356 
00364 LINKDLL void ce_Send(
00365     ce_appl_intf_t *c_appl,
00366     int num_dests,
00367     ce_rank_array_t dests,
00368     int num,
00369     ce_iovec_array_t iovl
00370     ) ;
00371 
00372 
00379 LINKDLL void ce_Send1(
00380     ce_appl_intf_t *c_appl,
00381     ce_rank_t dest,
00382     int num,
00383     ce_iovec_array_t iovl
00384     ) ;
00385 
00389 LINKDLL void ce_Prompt(
00390     ce_appl_intf_t *c_appl
00391     );
00392 
00398 LINKDLL void ce_Suspect(
00399     ce_appl_intf_t *c_appl,
00400     int num,
00401     ce_rank_array_t suspects
00402     );
00403 
00407 LINKDLL void ce_XferDone(
00408     ce_appl_intf_t *c_appl
00409     ) ;
00410 
00414 LINKDLL void ce_Rekey(
00415     ce_appl_intf_t *c_appl
00416     ) ;
00417 
00428 LINKDLL void ce_ChangeProtocol(
00429     ce_appl_intf_t *c_appl,
00430     char *protocol_name
00431     ) ;
00432 
00433 
00440 LINKDLL void ce_ChangeProperties(
00441     ce_appl_intf_t *c_appl,
00442     char *properties
00443     ) ;
00444 
00445 /**************************************************************/
00448 
00452 LINKDLL void ce_MLPrintOverride(
00453     void (*handler)(char *msg)
00454     ) ;
00455     
00459 LINKDLL void ce_MLUncaughtException(
00460     void (*handler)(char *info)
00461     ) ;
00462     
00463 /**************************************************************/
00467 #ifdef _WIN32
00468 typedef SOCKET CE_SOCKET ;
00469 #else
00470 typedef int    CE_SOCKET ;
00471 #endif
00472 
00475 typedef void (*ce_handler_t)(void*);
00476 
00484 LINKDLL void ce_AddSockRecv(
00485     CE_SOCKET socket,
00486     ce_handler_t handler,
00487     ce_env_t env
00488     );
00489 
00493 LINKDLL void ce_RmvSockRecv(
00494     CE_SOCKET socket
00495     );
00496 
00497 /**************************************************************/
00498 /* Here is a simpler "flat" inteface.
00499  * No iovec's are used, as above, things are zero-copy.
00500  */
00501 
00502 
00503 
00504 
00505 
00511 typedef void (*ce_appl_flat_receive_cast_t)(ce_env_t, ce_rank_t, ce_len_t, ce_data_t) ;
00512 
00518 typedef void (*ce_appl_flat_receive_send_t)(ce_env_t, ce_rank_t, ce_len_t, ce_data_t) ;
00519 
00522 LINKDLL ce_appl_intf_t*
00523 ce_create_flat_intf(ce_env_t env, 
00524                     ce_appl_exit_t exit,
00525                     ce_appl_install_t install,
00526                     ce_appl_flow_block_t flow_block,
00527                     ce_appl_block_t block,
00528                     ce_appl_flat_receive_cast_t cast,
00529                     ce_appl_flat_receive_send_t send,
00530                     ce_appl_heartbeat_t heartbeat
00531     );
00532 
00533 
00539 LINKDLL void ce_flat_Cast(
00540      ce_appl_intf_t *c_appl,
00541      ce_len_t len, 
00542      ce_data_t buf
00543      ) ;
00544 
00552 LINKDLL void ce_flat_Send(
00553     ce_appl_intf_t *c_appl,
00554     int num_dests,
00555     ce_rank_array_t dests,
00556     ce_len_t len, 
00557     ce_data_t buf
00558     ) ;
00559 
00560 
00567 LINKDLL void ce_flat_Send1(
00568     ce_appl_intf_t *c_appl,
00569     ce_rank_t dest,
00570     ce_len_t len, 
00571     ce_data_t buf
00572     ) ;
00573 
00574 #ifdef __cplusplus
00575 }
00576 #endif
00577 
00578 #endif  /* __CE_H__ */
00579 
00580 /**************************************************************/
00581 

Generated at Fri Aug 30 02:15:26 2002 for CE by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001