Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Save information from routing corresponding to storage.
[simgrid.git] / src / surf / storage.c
1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012. The SimGrid Team.
2  * All rights reserved.                                                                 */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package.             */
6
7 #include "xbt/ex.h"
8 #include "xbt/dict.h"
9 #include "portable.h"
10 #include "surf_private.h"
11 #include "surf/surf_resource.h"
12
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf,
14                                 "Logging specific to the SURF storage module");
15
16 surf_model_t surf_storage_model = NULL;
17
18 typedef struct surf_storage {
19   s_surf_resource_t generic_resource;
20   const char* type;
21   const char* content; /*should be a dict */
22 } s_surf_storage_t, *surf_storage_t;
23
24 static surf_action_t storage_action_open(void *storage, const char* path, const char* mode)
25 {
26   return NULL;
27 }
28
29 static surf_action_t storage_action_close(void *storage, surf_file_t fp)
30 {
31   return NULL;
32 }
33
34 static surf_action_t storage_action_read(void *storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
35 {
36   return NULL;
37 }
38
39 static surf_action_t storage_action_write(void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
40 {
41   return NULL;
42 }
43
44 static surf_action_t storage_action_stat(void *storage, int fd, void* buf)
45 {
46   return NULL;
47 }
48
49 static void* storage_create_resource(const char* id, const char* type,
50                                     const char* content, xbt_dict_t storage_properties)
51 {
52   return NULL;
53 }
54
55 static void storage_finalize(void)
56 {
57   surf_model_exit(surf_storage_model);
58   surf_storage_model = NULL;
59 }
60
61 static void storage_update_actions_state(double now, double delta)
62 {
63
64 }
65
66 static double storage_share_resources(double NOW)
67 {
68   double min_action_duration = -1;
69   return min_action_duration;
70 }
71
72 static int storage_resource_used(void *resource_id)
73 {
74   THROW_UNIMPLEMENTED;
75   return 0;
76 }
77
78 static void storage_resources_state(void *id, tmgr_trace_event_t event_type,
79                                  double value, double time)
80 {
81   THROW_UNIMPLEMENTED;
82 }
83
84 static int storage_action_unref(surf_action_t action)
85 {
86   THROW_UNIMPLEMENTED;
87   return 0;
88 }
89
90 static void storage_action_cancel(surf_action_t action)
91 {
92   THROW_UNIMPLEMENTED;
93 }
94
95 static void storage_action_state_set(surf_action_t action, e_surf_action_state_t state)
96 {
97   THROW_UNIMPLEMENTED;
98 }
99
100 static void storage_action_suspend(surf_action_t action)
101 {
102   THROW_UNIMPLEMENTED;
103 }
104
105 static void storage_action_resume(surf_action_t action)
106 {
107   THROW_UNIMPLEMENTED;
108 }
109
110 static int storage_action_is_suspended(surf_action_t action)
111 {
112   THROW_UNIMPLEMENTED;
113   return 0;
114 }
115
116 static void storage_action_set_max_duration(surf_action_t action, double duration)
117 {
118   THROW_UNIMPLEMENTED;
119 }
120
121 static void storage_action_set_priority(surf_action_t action, double priority)
122 {
123   THROW_UNIMPLEMENTED;
124 }
125
126 static void parse_storage_init(sg_platf_storage_cbarg_t storage)
127 {
128   XBT_DEBUG("parse_storage_init");
129 }
130
131 static void parse_mstorage_init(sg_platf_mstorage_cbarg_t mstorage)
132 {
133   XBT_DEBUG("parse_mstorage_init");
134 }
135
136 static void parse_storage_type_init(sg_platf_storage_type_cbarg_t storagetype_)
137 {
138   XBT_DEBUG("parse_storage_type_init");
139 }
140
141 static void parse_mount_init(sg_platf_mount_cbarg_t mount)
142 {
143   XBT_DEBUG("parse_mount_init");
144 }
145
146 static void storage_define_callbacks()
147 {
148   sg_platf_storage_add_cb(parse_storage_init);
149   sg_platf_storage_type_add_cb(parse_storage_type_init);
150   sg_platf_mstorage_add_cb(parse_mstorage_init);
151   sg_platf_mount_add_cb(parse_mount_init);
152 }
153
154 static void surf_storage_model_init_internal(void)
155 {
156   XBT_DEBUG("surf_storage_model_init_internal");
157   surf_storage_model = surf_model_init();
158
159   surf_storage_model->name = "Storage";
160   surf_storage_model->action_unref = storage_action_unref;
161   surf_storage_model->action_cancel = storage_action_cancel;
162   surf_storage_model->action_state_set = storage_action_state_set;
163
164   surf_storage_model->model_private->finalize = storage_finalize;
165   surf_storage_model->model_private->update_actions_state = storage_update_actions_state;
166   surf_storage_model->model_private->share_resources = storage_share_resources;
167   surf_storage_model->model_private->resource_used = storage_resource_used;
168   surf_storage_model->model_private->update_resource_state = storage_resources_state;
169
170   surf_storage_model->suspend = storage_action_suspend;
171   surf_storage_model->resume = storage_action_resume;
172   surf_storage_model->is_suspended = storage_action_is_suspended;
173   surf_storage_model->set_max_duration = storage_action_set_max_duration;
174   surf_storage_model->set_priority = storage_action_set_priority;
175
176   surf_storage_model->extension.storage.open = storage_action_open;
177   surf_storage_model->extension.storage.close = storage_action_close;
178   surf_storage_model->extension.storage.read = storage_action_read;
179   surf_storage_model->extension.storage.write = storage_action_write;
180   surf_storage_model->extension.storage.stat = storage_action_stat;
181   surf_storage_model->extension.storage.create_resource = storage_create_resource;
182 }
183
184 void surf_storage_model_init_default(void)
185 {
186   surf_storage_model_init_internal();
187   storage_define_callbacks();
188
189   xbt_dynar_push(model_list, &surf_storage_model);
190 }