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 <memory.h>
00020 
00021 #ifdef _WIN32
00022 #include <winsock2.h>
00023 #endif
00024 
00025 /******************************************************************/
00026 /* This is for defining DLLs on windows. Do NOT define CE_DLL_LINK
00027  * in applications that use the CE library.
00028  */
00029 #ifdef _WIN32
00030 #ifdef CE_MAKE_A_DLL
00031 #define LINKDLL __declspec( dllexport)
00032 #else
00033 #define LINKDLL __declspec( dllimport)
00034 #endif
00035 #else
00036 /* This is unused on Unix
00037  */
00038 #define LINKDLL 
00039 #endif
00040 /******************************************************************/
00041 
00042 
00046 typedef double      ce_float_t ;
00047 
00050 typedef int         ce_bool_t ;
00051 
00056 typedef int         ce_rank_t ;
00057 
00060 typedef int         ce_ltime_t ;
00061 
00064 typedef int         ce_len_t ;
00065 
00070 typedef void       *ce_env_t ;
00071 
00074 typedef double      ce_time_t ;
00075 
00079 typedef char*       ce_endpt_t;
00080 
00083 typedef char*       ce_addr_t;
00084 
00087 typedef char       *ce_data_t;
00088 
00092 typedef ce_iovec_t *ce_iovec_array_t;
00093 
00094 /* An array of boolean values. 
00095  */
00096 typedef ce_bool_t  *ce_bool_array_t;
00097 
00101 typedef ce_endpt_t *ce_endpt_array_t ;
00102 
00105 typedef ce_rank_t  *ce_rank_array_t ;
00106 
00110 typedef ce_addr_t  *ce_addr_array_t ;
00111 
00121 typedef struct ce_view_id_t {
00122     ce_ltime_t ltime ;
00123     ce_endpt_t endpt ;
00124 } ce_view_id_t ;
00125 
00128 typedef ce_view_id_t **ce_view_id_array_t;
00129 
00135 typedef struct ce_view_state_t {
00136     char* version ;                
00137     char* group ;                  
00138     char* proto ;                  
00139     ce_rank_t coord ;              
00140     int ltime ;                    
00141     ce_bool_t primary ;            
00142     ce_bool_t groupd ;             
00143     ce_bool_t xfer_view ;          
00144     char* key ;                    
00145     int num_ids ;                  
00146     ce_view_id_array_t prev_ids ;  
00147     char *params;                  
00148     ce_time_t uptime ;             
00149     ce_endpt_array_t view ;        
00150     ce_addr_array_t address ;      
00151 } ce_view_state_t ;
00152 
00157 typedef struct ce_local_state_t {
00158     ce_endpt_t endpt ;             
00159     ce_addr_t addr ;               
00160     ce_rank_t rank ;               
00161     char* name ;                   
00162     int nmembers ;                 
00163     ce_view_id_t *view_id ;        
00164     ce_bool_t am_coord ;           
00165 } ce_local_state_t ;
00166 
00171 typedef struct ce_jops_t {
00172     ce_time_t hrtbt_rate ;         
00173     char *transports ;             
00174     char *protocol ;               
00175     char *group_name ;             
00176     char *properties ;             
00177     ce_bool_t use_properties ;     
00178     ce_bool_t groupd ;             
00179     char *params ;                 
00180     ce_bool_t client;              
00181     ce_bool_t debug ;              
00182     char *endpt ;                  
00183     char *princ ;                  
00184     char *key ;                    
00185     ce_bool_t secure ;             
00186 } ce_jops_t;
00187 
00191 #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"
00192 
00193 
00198 #define CE_DEFAULT_PROPERTIES "Gmp:Sync:Heal:Switch:Frag:Suspect:Flow:Slander"
00199 
00200 /**************************************************************/
00201 /*
00202  * Utilities
00203  */
00204 
00207 #define record_create(type, var) ((type)malloc(sizeof(*var)))
00208 
00211 #define record_free(rec) free(rec)
00212 
00215 #define record_clear(rec) memset(rec, 0, sizeof(*rec))
00216 
00220 LINKDLL char *ce_copy_string(char *str);
00221 
00226 LINKDLL void ce_view_full_free(ce_local_state_t *ls, ce_view_state_t* vs);
00227 
00231 LINKDLL void ce_jops_free(ce_jops_t*) ;
00232 
00233 /**************************************************************/
00242 typedef void (*ce_appl_install_t)(ce_env_t, ce_local_state_t*, ce_view_state_t*);
00243 
00246 typedef void (*ce_appl_exit_t)(ce_env_t) ;
00247 
00253 typedef void (*ce_appl_receive_cast_t)(ce_env_t, ce_rank_t, int, ce_iovec_array_t) ;
00254 
00260 typedef void (*ce_appl_receive_send_t)(ce_env_t, ce_rank_t, int, ce_iovec_array_t) ;
00261 
00266 typedef void (*ce_appl_flow_block_t)(ce_env_t, ce_rank_t, ce_bool_t) ;
00267 
00272 typedef void (*ce_appl_block_t)(ce_env_t) ;
00273 
00277 typedef void (*ce_appl_heartbeat_t)(ce_env_t, ce_time_t) ;
00278 
00285 typedef struct ce_appl_intf_t ce_appl_intf_t ;
00286 
00308 LINKDLL ce_appl_intf_t*
00309 ce_create_intf(ce_env_t env, 
00310                ce_appl_exit_t exit,
00311                ce_appl_install_t install,
00312                ce_appl_flow_block_t flow_block,
00313                ce_appl_block_t block,
00314                ce_appl_receive_cast_t cast,
00315                ce_appl_receive_send_t send,
00316                ce_appl_heartbeat_t heartbeat
00317     );
00318 
00319 /**************************************************************/
00320 
00331 LINKDLL void ce_Init(
00332     int argc,
00333     char **argv
00334     ) ;
00335 
00338 LINKDLL void ce_Main_loop (void);
00339 
00344 LINKDLL void ce_Join(
00345     ce_jops_t *ops,
00346     ce_appl_intf_t *c_appl
00347     ) ;
00348 
00349 /**************************************************************/
00350 /* The set of actions supported on a group. 
00351  */
00352 
00356 LINKDLL void ce_Leave(ce_appl_intf_t *c_appl) ;
00357 
00363 LINKDLL void ce_Cast(
00364     ce_appl_intf_t *c_appl,
00365     int num,
00366     ce_iovec_array_t iovl
00367     ) ;
00368 
00376 LINKDLL void ce_Send(
00377     ce_appl_intf_t *c_appl,
00378     int num_dests,
00379     ce_rank_array_t dests,
00380     int num,
00381     ce_iovec_array_t iovl
00382     ) ;
00383 
00384 
00391 LINKDLL void ce_Send1(
00392     ce_appl_intf_t *c_appl,
00393     ce_rank_t dest,
00394     int num,
00395     ce_iovec_array_t iovl
00396     ) ;
00397 
00401 LINKDLL void ce_Prompt(
00402     ce_appl_intf_t *c_appl
00403     );
00404 
00410 LINKDLL void ce_Suspect(
00411     ce_appl_intf_t *c_appl,
00412     int num,
00413     ce_rank_array_t suspects
00414     );
00415 
00419 LINKDLL void ce_XferDone(
00420     ce_appl_intf_t *c_appl
00421     ) ;
00422 
00426 LINKDLL void ce_Rekey(
00427     ce_appl_intf_t *c_appl
00428     ) ;
00429 
00440 LINKDLL void ce_ChangeProtocol(
00441     ce_appl_intf_t *c_appl,
00442     char *protocol_name
00443     ) ;
00444 
00445 
00452 LINKDLL void ce_ChangeProperties(
00453     ce_appl_intf_t *c_appl,
00454     char *properties
00455     ) ;
00456 
00457 /**************************************************************/
00464 LINKDLL void ce_MLPrintOverride(
00465     void (*handler)(char *msg)
00466     ) ;
00467     
00471 LINKDLL void ce_MLUncaughtException(
00472     void (*handler)(char *info)
00473     ) ;
00474     
00475 /**************************************************************/
00479 #ifdef _WIN32
00480 typedef SOCKET CE_SOCKET ;
00481 #else
00482 typedef int    CE_SOCKET ;
00483 #endif
00484 
00487 typedef void (*ce_handler_t)(void*);
00488 
00496 LINKDLL void ce_AddSockRecv(
00497     CE_SOCKET socket,
00498     ce_handler_t handler,
00499     ce_env_t env
00500     );
00501 
00505 LINKDLL void ce_RmvSockRecv(
00506     CE_SOCKET socket
00507     );
00508 
00509 /**************************************************************/
00510 /* Here is a simpler "flat" inteface.
00511  * No iovec's are used, as above, things are zero-copy.
00512  */
00513 
00514 
00515 
00516 
00517 
00523 typedef void (*ce_appl_flat_receive_cast_t)(ce_env_t, ce_rank_t, ce_len_t, ce_data_t) ;
00524 
00530 typedef void (*ce_appl_flat_receive_send_t)(ce_env_t, ce_rank_t, ce_len_t, ce_data_t) ;
00531 
00534 LINKDLL ce_appl_intf_t*
00535 ce_create_flat_intf(ce_env_t env, 
00536                     ce_appl_exit_t exit,
00537                     ce_appl_install_t install,
00538                     ce_appl_flow_block_t flow_block,
00539                     ce_appl_block_t block,
00540                     ce_appl_flat_receive_cast_t cast,
00541                     ce_appl_flat_receive_send_t send,
00542                     ce_appl_heartbeat_t heartbeat
00543     );
00544 
00545 
00551 LINKDLL void ce_flat_Cast(
00552      ce_appl_intf_t *c_appl,
00553      ce_len_t len, 
00554      ce_data_t buf
00555      ) ;
00556 
00564 LINKDLL void ce_flat_Send(
00565     ce_appl_intf_t *c_appl,
00566     int num_dests,
00567     ce_rank_array_t dests,
00568     ce_len_t len, 
00569     ce_data_t buf
00570     ) ;
00571 
00572 
00579 LINKDLL void ce_flat_Send1(
00580     ce_appl_intf_t *c_appl,
00581     ce_rank_t dest,
00582     ce_len_t len, 
00583     ce_data_t buf
00584     ) ;
00585 
00586 #endif  /* __CE_H__ */
00587 
00588 /**************************************************************/
00589 

Generated at Thu Apr 4 14:13:52 2002 for CE by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001