Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
bf16cef88b3b511dd30b658815ac32403508715d
[simgrid.git] / src / surf / storage.hpp
1 #include "surf.hpp"
2
3 #ifndef STORAGE_HPP_
4 #define STORAGE_HPP_
5
6 /***********
7  * Classes *
8  ***********/
9
10 class StorageModel;
11 typedef StorageModel *StorageModelPtr;
12
13 class Storage;
14 typedef Storage *StoragePtr;
15
16 class StorageLmm;
17 typedef StorageLmm *StorageLmmPtr;
18
19 class StorageAction;
20 typedef StorageAction *StorageActionPtr;
21
22 class StorageActionLmm;
23 typedef StorageActionLmm *StorageActionLmmPtr;
24
25
26 /*********
27  * Model *
28  *********/
29 class StorageModel : public Model {
30 public:
31   StorageModel();
32   ~StorageModel();
33   StoragePtr createResource(const char* id, const char* model, const char* type_id,
34                    const char* content_name, const char* content_type, xbt_dict_t properties);
35   double shareResources(double now);
36   void updateActionsState(double now, double delta);
37
38 };
39
40 /************
41  * Resource *
42  ************/
43
44 class Storage : virtual public Resource {
45 public:
46   Storage(StorageModelPtr model, const char* name, xbt_dict_t properties);
47
48   bool isUsed();
49   void updateState(tmgr_trace_event_t event_type, double value, double date);
50
51   xbt_dict_t p_content;
52   char* p_contentType;
53   sg_storage_size_t m_size;
54   sg_storage_size_t m_usedSize;
55   char * p_typeId;
56
57   virtual StorageActionPtr open(const char* mount, const char* path)=0;
58   virtual StorageActionPtr close(surf_file_t fd)=0;
59   //virtual StorageActionPtr unlink(surf_file_t fd)=0;
60   virtual StorageActionPtr ls(const char *path)=0;
61   virtual StorageActionPtr read(surf_file_t fd, sg_storage_size_t size)=0;
62   virtual StorageActionPtr write(surf_file_t fd, sg_storage_size_t size)=0;
63   virtual void rename(const char *src, const char *dest)=0;
64
65   virtual xbt_dict_t getContent()=0;
66   virtual sg_storage_size_t getSize()=0;
67
68   xbt_dict_t parseContent(char *filename);
69
70   xbt_dynar_t p_writeActions;
71 };
72
73 class StorageLmm : public ResourceLmm, public Storage {
74 public:
75   StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
76                      lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
77                      const char* type_id, char *content_name, char *content_type, size_t size);
78
79   StorageActionPtr open(const char* mount, const char* path);
80   StorageActionPtr close(surf_file_t fd);
81   //StorageActionPtr unlink(surf_file_t fd);
82   StorageActionPtr ls(const char *path);
83   xbt_dict_t getContent();
84   sg_storage_size_t getSize();
85   StorageActionPtr read(surf_file_t fd, sg_storage_size_t size);//FIXME:why we have a useless param ptr ??
86   StorageActionPtr write(surf_file_t fd, sg_storage_size_t size);//FIXME:why we have a useless param ptr ??
87   void rename(const char *src, const char *dest);
88
89   lmm_constraint_t p_constraintWrite;    /* Constraint for maximum write bandwidth*/
90   lmm_constraint_t p_constraintRead;     /* Constraint for maximum write bandwidth*/
91 };
92
93 /**********
94  * Action *
95  **********/
96
97 typedef enum {
98   READ=0, WRITE, STAT, OPEN, CLOSE, LS
99 } e_surf_action_storage_type_t;
100
101
102 class StorageAction : virtual public Action {
103 public:
104   StorageAction(){};
105   StorageAction(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type)
106    : p_storage(storage), m_type(type) {};
107
108
109
110   e_surf_action_storage_type_t m_type;
111   StoragePtr p_storage;
112   surf_file_t p_file;
113   xbt_dict_t p_lsDict;
114 };
115
116 class StorageActionLmm : public ActionLmm, public StorageAction {
117 public:
118   StorageActionLmm(){};
119   StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type);
120   void suspend();
121   int unref();
122   void cancel();
123   //FIXME:??void recycle();
124   void resume();
125   bool isSuspended();
126   void setMaxDuration(double duration);
127   void setPriority(double priority);
128
129 };
130
131
132 typedef struct s_storage_type {
133   char *model;
134   char *content;
135   char *content_type;
136   char *type_id;
137   xbt_dict_t properties;
138   sg_storage_size_t size;
139 } s_storage_type_t, *storage_type_t;
140
141 typedef struct s_mount {
142   void *storage;
143   char *name;
144 } s_mount_t, *mount_t;
145
146 typedef struct surf_file {
147   char *name;
148   char *mount;
149   sg_storage_size_t size;
150 } s_surf_file_t;
151
152
153 #endif /* STORAGE_HPP_ */