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 "mm_so.h"
00020 #include <memory.h>
00021 
00022 #ifdef _WIN32
00023 #include <winsock2.h>
00024 #endif
00025 
00026 #include "mm_basic.h"
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 
00033 /* The maximal number of iovectors that can fit into an iovec array.
00034  */
00035 #define CE_IOVL_MAX_SIZE 20 
00036 
00037 /* The maximal number of destinations in an suspect/send event.
00038  */
00039 #define CE_DESTS_MAX_SIZE 10
00040     
00041 /* Maximal sizes for the various parameters 
00042  */
00043 #define CE_TRANSPORT_MAX_SIZE 32
00044 #define CE_PROTOCOL_MAX_SIZE 256
00045 #define CE_GROUP_NAME_MAX_SIZE 64
00046 #define CE_PROPERTIES_MAX_SIZE 128
00047 #define CE_PARAMS_MAX_SIZE 256
00048 #define CE_ENDPT_MAX_SIZE 48
00049 #define CE_ADDR_MAX_SIZE 48
00050 #define CE_PRINCIPAL_MAX_SIZE 32
00051 #define CE_KEY_SIZE 32
00052 #define CE_NAME_MAX_SIZE CE_ENDPT_MAX_SIZE+24
00053 #define CE_VERSION_MAX_SIZE 8
00054     
00055 
00059 typedef double      ce_float_t ;
00060 
00063 typedef int         ce_bool_t ;
00064     
00069 typedef int         ce_rank_t ;
00070 
00073 typedef int         ce_ltime_t ;
00074 
00077 typedef int         ce_len_t ;
00078 
00083 typedef void       *ce_env_t ;
00084 
00087 typedef double      ce_time_t ;
00088     
00092 typedef struct ce_endpt_t {
00093     char name[CE_ENDPT_MAX_SIZE];
00094 } ce_endpt_t;
00095     
00098 typedef struct ce_addr_t {
00099     char addr[CE_ADDR_MAX_SIZE];
00100 } ce_addr_t;
00101 
00104 typedef char       *ce_data_t;
00105 
00109 typedef ce_iovec_t *ce_iovec_array_t;
00110 
00111 /* An array of boolean values. 
00112  */
00113 typedef ce_bool_t  *ce_bool_array_t;
00114 
00118 typedef ce_endpt_t *ce_endpt_array_t ;
00119 
00122 typedef ce_rank_t  *ce_rank_array_t ;
00123 
00127 typedef ce_addr_t  *ce_addr_array_t ;
00128 
00129 
00130 
00131 
00141 typedef struct ce_view_id_t {
00142     ce_ltime_t ltime ;
00143     ce_endpt_t endpt ;
00144 } ce_view_id_t ;
00145 
00148 typedef ce_view_id_t **ce_view_id_array_t;
00149 
00155 typedef struct ce_view_state_t {
00156     char version[CE_VERSION_MAX_SIZE] ;     
00157     char group[CE_GROUP_NAME_MAX_SIZE] ;    
00158     char proto[CE_PROTOCOL_MAX_SIZE] ;      
00159     ce_rank_t coord ;              
00160     int ltime ;                    
00161     ce_bool_t primary ;            
00162     ce_bool_t groupd ;             
00163     ce_bool_t xfer_view ;          
00164     char key[CE_KEY_SIZE] ;        
00165     int num_ids ;                  
00166     ce_view_id_t *prev_ids ;       
00167     char params[CE_PARAMS_MAX_SIZE];  
00168     ce_time_t uptime ;             
00169     ce_endpt_t *view ;             
00170     ce_addr_t  *address ;          
00171 } ce_view_state_t ;
00172 
00177 typedef struct ce_local_state_t {
00178     ce_endpt_t endpt ;             
00179     ce_addr_t addr ;               
00180     ce_rank_t rank ;               
00181     char name[CE_NAME_MAX_SIZE];   
00182     int nmembers ;                 
00183     ce_view_id_t view_id ;         
00184     ce_bool_t am_coord ;           
00185 } ce_local_state_t ;
00186 
00187 
00196 typedef struct ce_jops_t {
00197     ce_time_t hrtbt_rate ;                     
00198     char transports[CE_TRANSPORT_MAX_SIZE] ;   
00199     char protocol[CE_PROTOCOL_MAX_SIZE] ;      
00200     char group_name[CE_GROUP_NAME_MAX_SIZE] ;  
00201     char properties[CE_PROPERTIES_MAX_SIZE] ;  
00202     ce_bool_t use_properties ;                 
00203     ce_bool_t groupd ;                         
00204     char params[CE_PARAMS_MAX_SIZE] ;          
00205     ce_bool_t client;                          
00206     ce_bool_t debug ;                          
00208     /* Normally, Ensemble generates a unique endpoint name for each
00209      * group an application joins (this is what happens if you leave
00210      * 'endpt' unmodified).  The application can optionally provide
00211      * its own endpoint name.  It can, for instance, reuse an
00212      * endpoint name generated by Ensemble for another group (the
00213      * same endpoint name can be used to join any number of groups).
00214      * The application can even generate an endpoint on its own.
00215      * Such names should be unique.  It is best if they contain only
00216      * printable characters and do not contain spaces because
00217      * Ensemble my print them out in debugging or error messages.
00218      * (The names generated by Ensemble fit these characteristics.)
00219      * See Endpt.extern in ensemble/type/endpt.mli for more
00220      * information.
00221      */
00222     ce_endpt_t endpt;                          
00223     char princ[CE_PRINCIPAL_MAX_SIZE] ;        
00224     char key[CE_KEY_SIZE] ;                    
00226     ce_bool_t secure ;                         
00227 } ce_jops_t ;
00228 
00232 #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"
00233 
00234 
00239 #define CE_DEFAULT_PROPERTIES "Gmp:Sync:Heal:Switch:Frag:Suspect:Flow:Slander"
00240 
00241 /**************************************************************/
00250 typedef void (*ce_appl_install_t)(ce_env_t, ce_local_state_t*, ce_view_state_t*);
00251 
00254 typedef void (*ce_appl_exit_t)(ce_env_t) ;
00255 
00261 typedef void (*ce_appl_receive_cast_t)(ce_env_t, ce_rank_t, int, ce_iovec_array_t) ;
00262 
00268 typedef void (*ce_appl_receive_send_t)(ce_env_t, ce_rank_t, int, ce_iovec_array_t) ;
00269 
00274 typedef void (*ce_appl_flow_block_t)(ce_env_t, ce_rank_t, ce_bool_t) ;
00275 
00280 typedef void (*ce_appl_block_t)(ce_env_t) ;
00281 
00285 typedef void (*ce_appl_heartbeat_t)(ce_env_t, ce_time_t) ;
00286 
00293 typedef struct ce_appl_intf_t ce_appl_intf_t ;
00294 
00316 LINKDLL ce_appl_intf_t*
00317 ce_create_intf(ce_env_t env, 
00318                ce_appl_exit_t exit,
00319                ce_appl_install_t install,
00320                ce_appl_flow_block_t flow_block,
00321                ce_appl_block_t block,
00322                ce_appl_receive_cast_t cast,
00323                ce_appl_receive_send_t send,
00324                ce_appl_heartbeat_t heartbeat
00325     );
00326 
00327 /**************************************************************/
00328 
00339 LINKDLL void ce_Init(
00340     int argc,
00341     char **argv
00342     ) ;
00343 
00346 LINKDLL void ce_Main_loop (void);
00347 
00352 LINKDLL void ce_Join(
00353     ce_jops_t *ops,
00354     ce_appl_intf_t *c_appl
00355     ) ;
00356 
00357 /**************************************************************/
00358 /* The set of actions supported on a group. 
00359  */
00360 
00364 LINKDLL void ce_Leave(ce_appl_intf_t *c_appl) ;
00365 
00371 LINKDLL void ce_Cast(
00372     ce_appl_intf_t *c_appl,
00373     int num,
00374     ce_iovec_array_t iovl
00375     ) ;
00376 
00385 LINKDLL void ce_Send(
00386     ce_appl_intf_t *c_appl,
00387     int num_dests,
00388     ce_rank_array_t dests,
00389     int num,
00390     ce_iovec_array_t iovl
00391     ) ;
00392 
00393 
00400 LINKDLL void ce_Send1(
00401     ce_appl_intf_t *c_appl,
00402     ce_rank_t dest,
00403     int num,
00404     ce_iovec_array_t iovl
00405     ) ;
00406 
00410 LINKDLL void ce_Prompt(
00411     ce_appl_intf_t *c_appl
00412     );
00413 
00419 LINKDLL void ce_Suspect(
00420     ce_appl_intf_t *c_appl,
00421     int num,
00422     ce_rank_array_t suspects
00423     );
00424 
00428 LINKDLL void ce_XferDone(
00429     ce_appl_intf_t *c_appl
00430     ) ;
00431 
00435 LINKDLL void ce_Rekey(
00436     ce_appl_intf_t *c_appl
00437     ) ;
00438 
00449 LINKDLL void ce_ChangeProtocol(
00450     ce_appl_intf_t *c_appl,
00451     char *protocol_name
00452     ) ;
00453 
00454 
00461 LINKDLL void ce_ChangeProperties(
00462     ce_appl_intf_t *c_appl,
00463     char *properties
00464     ) ;
00465 
00466 /**************************************************************/
00473 LINKDLL void ce_MLPrintOverride(
00474     void (*handler)(char *msg)
00475     ) ;
00476     
00480 LINKDLL void ce_MLUncaughtException(
00481     void (*handler)(char *info)
00482     ) ;
00483     
00484 /**************************************************************/
00488 #ifdef _WIN32
00489 typedef SOCKET CE_SOCKET ;
00490 #else
00491 typedef int    CE_SOCKET ;
00492 #endif
00493 
00496 typedef void (*ce_handler_t)(void*);
00497 
00505 LINKDLL void ce_AddSockRecv(
00506     CE_SOCKET socket,
00507     ce_handler_t handler,
00508     ce_env_t env
00509     );
00510 
00514 LINKDLL void ce_RmvSockRecv(
00515     CE_SOCKET socket
00516     );
00517 
00518 /**************************************************************/
00519 /* Here is a simpler "flat" inteface.
00520  * No iovec's are used, as above, things are zero-copy.
00521  */
00522 
00523 
00524 
00530 typedef void (*ce_appl_flat_receive_cast_t)(ce_env_t, ce_rank_t, ce_len_t, ce_data_t) ;
00531 
00537 typedef void (*ce_appl_flat_receive_send_t)(ce_env_t, ce_rank_t, ce_len_t, ce_data_t) ;
00538 
00541 LINKDLL ce_appl_intf_t*
00542 ce_create_flat_intf(ce_env_t env, 
00543                     ce_appl_exit_t exit,
00544                     ce_appl_install_t install,
00545                     ce_appl_flow_block_t flow_block,
00546                     ce_appl_block_t block,
00547                     ce_appl_flat_receive_cast_t cast,
00548                     ce_appl_flat_receive_send_t send,
00549                     ce_appl_heartbeat_t heartbeat
00550     );
00551 
00552 
00558 LINKDLL void ce_flat_Cast(
00559      ce_appl_intf_t *c_appl,
00560      ce_len_t len, 
00561      ce_data_t buf
00562      ) ;
00563 
00571 LINKDLL void ce_flat_Send(
00572     ce_appl_intf_t *c_appl,
00573     int num_dests,
00574     ce_rank_array_t dests,
00575     ce_len_t len, 
00576     ce_data_t buf
00577     ) ;
00578 
00579 
00586 LINKDLL void ce_flat_Send1(
00587     ce_appl_intf_t *c_appl,
00588     ce_rank_t dest,
00589     ce_len_t len, 
00590     ce_data_t buf
00591     ) ;
00592 
00593 #ifdef __cplusplus
00594 }
00595 #endif
00596 
00597 #endif  /* __CE_H__ */
00598 
00599 /**************************************************************/
00600 

Generated at Wed Dec 18 18:38:45 2002 for CE by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001