Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'hypervisor' into surf++
[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 xbt_dict_t getContent()=0;
64   virtual sg_storage_size_t getSize()=0;
65
66   xbt_dict_t parseContent(char *filename);
67
68   xbt_dynar_t p_writeActions;
69 };
70
71 class StorageLmm : public ResourceLmm, public Storage {
72 public:
73   StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
74                      lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
75                      const char* type_id, char *content_name, char *content_type, size_t size);
76
77   StorageActionPtr open(const char* mount, const char* path);
78   StorageActionPtr close(surf_file_t fd);
79   //StorageActionPtr unlink(surf_file_t fd);
80   StorageActionPtr ls(const char *path);
81   xbt_dict_t getContent();
82   sg_storage_size_t getSize();
83   StorageActionPtr read(surf_file_t fd, sg_storage_size_t size);//FIXME:why we have a useless param ptr ??
84   StorageActionPtr write(surf_file_t fd, sg_storage_size_t size);//FIXME:why we have a useless param ptr ??
85
86   lmm_constraint_t p_constraintWrite;    /* Constraint for maximum write bandwidth*/
87   lmm_constraint_t p_constraintRead;     /* Constraint for maximum write bandwidth*/
88 };
89
90 /**********
91  * Action *
92  **********/
93
94 typedef enum {
95   READ=0, WRITE, STAT, OPEN, CLOSE, LS
96 } e_surf_action_storage_type_t;
97
98
99 class StorageAction : virtual public Action {
100 public:
101   StorageAction(){};
102   StorageAction(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type)
103    : p_storage(storage), m_type(type) {};
104
105
106
107   e_surf_action_storage_type_t m_type;
108   StoragePtr p_storage;
109   surf_file_t p_file;
110   xbt_dict_t p_lsDict;
111 };
112
113 class StorageActionLmm : public ActionLmm, public StorageAction {
114 public:
115   StorageActionLmm(){};
116   StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type);
117   void suspend();
118   int unref();
119   void cancel();
120   //FIXME:??void recycle();
121   void resume();
122   bool isSuspended();
123   void setMaxDuration(double duration);
124   void setPriority(double priority);
125
126 };
127
128
129 typedef struct s_storage_type {
130   char *model;
131   char *content;
132   char *content_type;
133   char *type_id;
134   xbt_dict_t properties;
135   sg_storage_size_t size;
136 } s_storage_type_t, *storage_type_t;
137
138 typedef struct s_mount {
139   void *storage;
140   char *name;
141 } s_mount_t, *mount_t;
142
143 typedef struct surf_file {
144   char *name;
145   char *mount;
146   sg_storage_size_t size;
147 } s_surf_file_t;
148
149
150 #endif /* STORAGE_HPP_ */