38 # include <dsn/c/api_common.h> 41 namespace dsn {
class service_app; }
99 typedef void* (*dsn_app_create)(
100 const char* app_name,
143 bool is_write_operation,
144 dsn_message_t request
178 dsn_message_t* requests,
243 void* request_buffer,
265 int64_t learn_start_decree,
266 int64_t local_last_decree,
268 int learn_request_size,
286 int64_t local_last_decree,
290 # define DSN_APP_MASK_APP 0x01 291 # define DSN_APP_MASK_FRAMEWORK 0x02 302 # pragma pack(push, 4) 336 char type_name[DSN_MAX_APP_TYPE_NAME_LENGTH];
349 struct layer2_framework_callbacks
360 # pragma pack(push, 4) 376 char role[DSN_MAX_APP_TYPE_NAME_LENGTH];
377 char type[DSN_MAX_APP_TYPE_NAME_LENGTH];
378 char name[DSN_MAX_APP_TYPE_NAME_LENGTH];
379 char data_dir[DSN_MAX_PATH];
436 const char* app_name,
450 bool sleep_after_init DEFAULT(
false)
475 extern DSN_API
void dsn_run(
int argc,
char** argv,
bool sleep_after_init DEFAULT(
false));
485 NORETURN
extern DSN_API
void dsn_exit(
int code);
basic structure for state (e.g., full/delta checkpoint) transfer across nodes for an app...
Definition: app_model.h:148
dsn_error_t(* dsn_app_start)(void *app, int argc, char **argv)
callback to run the app with the app context, similar to main(argc, argv)
Definition: app_model.h:113
developers define the following dsn_app data structure, and passes it to rDSN through dsn_register_ap...
Definition: app_model.h:333
simply a checkpoint from remote machine is given, do not change the local state
Definition: app_model.h:163
struct dsn_app dsn_app
developers define the following dsn_app data structure, and passes it to rDSN through dsn_register_ap...
int64_t(* dsn_app_get_last_checkpoint_decree)(void *app)
get the decree of last done checkpoint, used by frameworks, implemented by apps
Definition: app_model.h:225
rpc address, which is always encoded into a 64-bit integer
Definition: api_layer1.h:471
int app_id
app id, see service_app_spec for more details.
Definition: app_model.h:374
dsn_address_t primary_address
primary address
Definition: app_model.h:380
DSN_API void dsn_app_loader_signal()
signal the application loader that application types are registered.
DSN_API void dsn_run(int argc, char **argv, bool sleep_after_init DEFAULT(false))
start the system with given arguments
int file_state_count
on-disk file count to be transferred
Definition: app_model.h:154
dsn_error_t(* dsn_app_destroy)(void *app, bool cleanup)
callback to stop and destroy the app
Definition: app_model.h:127
application information retrived at runtime
Definition: app_model.h:362
given a checkpoint from remote machine, prepare to change the local state
Definition: app_model.h:164
DSN_API const char * dsn_get_app_data_dir(dsn_gpid gpid DEFAULT(dsn_gpid{0}))
get current application data dir.
dsn_app_callbacks apps
app model (for integration with frameworks)
Definition: app_model.h:355
int64_t to_decree_included
the end decree of the state
Definition: app_model.h:152
struct dsn_app_info dsn_app_info
application information retrived at runtime
callbacks needed by the frameworks, application developers need to implement some of them so that cer...
Definition: app_model.h:309
int(* dsn_app_get_physical_error)(void *app)
get physical error (e.g., disk failure) from the app, used by frameworks, implemented by apps ...
Definition: app_model.h:188
dsn_app_start start
callback to start the app, similar to main
Definition: app_model.h:342
void * app_context_ptr
returned by dsn_app_create
Definition: app_model.h:368
dsn_app_destroy destroy
callback to stop and destroy the app
Definition: app_model.h:343
const char ** files
on-disk file path array, end with nullptr
Definition: app_model.h:156
Definition: api_layer1.h:683
NORETURN DSN_API void dsn_exit(int code)
exit the process with the given exit code
void *(* dsn_app_create)(const char *app_name, dsn_gpid id)
callback to create the app context
Definition: app_model.h:99
DSN_API bool dsn_mimic_app(const char *app_name, int index)
mimic an app as if the following execution in the current thread are executed in the target app's thr...
dsn_app_create create
callback to create the context for the app
Definition: app_model.h:341
int total_learn_state_size
memory used in the given buffer by this learn-state
Definition: app_model.h:150
app definition, mask = DSN_APP_MASK_APP
Definition: app_model.h:339
DSN_API int dsn_get_all_apps(dsn_app_info *info_buffer, int count)
get rDSN application (instance)s information in the current process
dsn_error_t(* dsn_app_apply_checkpoint)(void *app, dsn_chkpt_apply_mode mode, int64_t local_last_decree, const dsn_app_learn_state *learn_state)
apply checkpoint from remote nodes, used by frameworks, implemented by apps
Definition: app_model.h:283
DSN_API bool dsn_register_app(dsn_app *app_type)
register application/framework into rDSN runtime
dsn_error_t(* dsn_app_async_checkpoint)(void *app, int64_t last_decree)
checkpoint the application asynchronously, used by frameworks, implemented by apps ...
Definition: app_model.h:213
Definition: app_model.h:312
Definition: service_app.h:51
int meta_state_size
in-memory state size as stored in meta_state_ptr below
Definition: app_model.h:153
DSN_API bool dsn_get_app_callbacks(const char *name, dsn_app_callbacks *callbacks)
get application callbacks registered into rDSN runtime
dsn_error_t(* dsn_app_sync_checkpoint)(void *app, int64_t last_decree)
checkpoint the application synchronously, used by frameworks, implemented by apps ...
Definition: app_model.h:200
void(* dsn_framework_rpc_request_handler)(void *app, dsn_gpid gpid, bool is_write_operation, dsn_message_t request)
callback for framework to handle incoming rpc request, implemented by frameworks
Definition: app_model.h:140
void(* dsn_app_on_batched_write_requests)(void *app, int64_t decree, dsn_message_t *requests, int request_count)
batched rpc request from frameworks, used by frameworks, implemented by apps
Definition: app_model.h:175
DSN_API bool dsn_run_config(const char *config, bool sleep_after_init DEFAULT(false))
start the system with given configuration
int index
app role index
Definition: app_model.h:375
union dsn_app_callbacks dsn_app_callbacks
callbacks needed by the frameworks, application developers need to implement some of them so that cer...
dsn_error_t(* dsn_app_prepare_get_checkpoint)(void *app, void *request_buffer, int capacity, int *used_size)
learner prepares a get checkpoint request for better fitting the local state (e.g., for delta learning), the request will be used by dsn_app_get_checkpoint below, used by frameworks, implemented by apps
Definition: app_model.h:241
dsn_error_t(* dsn_app_bridge_t)(int, const char **)
when the service cannot automatically register its app types into rdsn through dmoudule's dllmain or ...
Definition: app_model.h:300
DSN_API bool dsn_get_current_app_info(dsn_app_info *app_info)
get current rDSN application information.
int64_t from_decree_excluded
the start decree(sequence number, version) of the state
Definition: app_model.h:151
uint64_t mask
application capability mask
Definition: app_model.h:335
void * meta_state_ptr
in-memory state
Definition: app_model.h:155
dsn_chkpt_apply_mode
checkpoint apply mode, see dsn_app_apply_checkpoint, used by frameworks
Definition: app_model.h:161
DSN_API void dsn_app_loader_wait()
wait signal from dsn_app_loader_signal.
dsn_error_t(* dsn_app_get_checkpoint)(void *app, int64_t learn_start_decree, int64_t local_last_decree, void *learn_request, int learn_request_size, dsn_app_learn_state *learn_state_buffer, int capacity)
get checkpoint information from learnee, used by frameworks, implemented by apps
Definition: app_model.h:263