Changing reschedule_delay internals
[nepi.git] / src / nepi / resources / linux / ns3 / ccn / ns3ccnrdceapplication.py
1 #
2 #    NEPI, a framework to manage network experiments
3 #    Copyright (C) 2014 INRIA
4 #
5 #    This program is free software: you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License as published by
7 #    the Free Software Foundation, either version 3 of the License, or
8 #    (at your option) any later version.
9 #
10 #    This program is distributed in the hope that it will be useful,
11 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #    GNU General Public License for more details.
14 #
15 #    You should have received a copy of the GNU General Public License
16 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
19
20 from nepi.execution.attribute import Attribute, Flags, Types
21 from nepi.execution.resource import clsinit_copy, ResourceState 
22 from nepi.resources.linux.ns3.ccn.ns3ccndceapplication import LinuxNS3CCNDceApplication
23
24 @clsinit_copy
25 class LinuxNS3DceCCNR(LinuxNS3CCNDceApplication):
26     _rtype = "ns3::LinuxDceCCNR"
27
28     @classmethod
29     def _register_attributes(cls):
30         max_fanout = Attribute("maxFanout",
31             "Sets the CCNR_BTREE_MAX_FANOUT environmental variable. ",
32             flags = Flags.Design)
33
34         max_leaf_entries = Attribute("maxLeafEntries",
35             "Sets the CCNR_BTREE_MAX_LEAF_ENTRIES environmental variable. ",
36             flags = Flags.Design)
37
38         max_node_bytes = Attribute("maxNodeBytes",
39             "Sets the CCNR_BTREE_MAX_NODE_BYTES environmental variable. ",
40             flags = Flags.Design)
41
42         max_node_pool = Attribute("maxNodePool",
43             "Sets the CCNR_BTREE_MAX_NODE_POOL environmental variable. ",
44             flags = Flags.Design)
45
46         content_cache = Attribute("contentCache",
47             "Sets the CCNR_CONTENT_CACHE environmental variable. ",
48             flags = Flags.Design)
49
50         debug = Attribute("debug",
51             "Sets the CCNR_DEBUG environmental variable. "
52             "Logging level for ccnr. Defaults to WARNING.",
53             type = Types.Enumerate,
54             allowed = [
55                     "NONE",
56                     "SEVERE",
57                     "ERROR",
58                     "WARNING",
59                     "INFO",
60                     "FINE, FINER, FINEST"],
61             flags = Flags.Design)
62
63         directory = Attribute("directory",
64             "Sets the CCNR_DIRECTORY environmental variable. ",
65             flags = Flags.Design)
66
67         global_prefix = Attribute("globalPrefix",
68             "Sets the CCNR_GLOBAL_PREFIX environmental variable. ",
69             flags = Flags.Design)
70
71         listen_on = Attribute("listenOn",
72             "Sets the CCNR_LISTEN_ON environmental variable. ",
73             flags = Flags.Design)
74
75         min_send_bufsize = Attribute("minSendBufsize",
76             "Sets the CCNR_MIN_SEND_BUFSIZE environmental variable. ",
77             flags = Flags.Design)
78
79         proto = Attribute("proto",
80             "Sets the CCNR_PROTO environmental variable. ",
81             flags = Flags.Design)
82
83         status_port = Attribute("statusPort",
84             "Sets the CCNR_STATUS_PORT environmental variable. ",
85             flags = Flags.Design)
86
87         start_write_scope_limit = Attribute("startWriteScopeLimit",
88             "Sets the CCNR_START_WRITE_SCOPE_LIMIT environmental variable. ",
89             flags = Flags.Design)
90
91         ccns_debug = Attribute("ccnsDebug",
92             "Sets the CCNS_DEBUG environmental variable. ",
93             flags = Flags.Design)
94
95         ccns_enable = Attribute("ccnsEnable",
96             "Sets the CCNS_ENABLE environmental variable. ",
97             flags = Flags.Design)
98
99         ccns_faux_error = Attribute("ccnsFauxError",
100             "Sets the CCNS_FAUX_ERROR environmental variable. ",
101             flags = Flags.Design)
102
103         ccns_heartbeat_micros = Attribute("ccnsHeartBeatMicros",
104             "Sets the CCNS_HEART_BEAT_MICROS environmental variable. ",
105             flags = Flags.Design)
106
107         ccns_max_compares_busy = Attribute("ccnsMaxComparesBusy",
108             "Sets the CCNS_MAX_COMPARES_BUSY environmental variable. ",
109             flags = Flags.Design)
110
111         ccns_max_fetch_busy = Attribute("ccnsMaxFetchBusy",
112             "Sets the CCNS_MAX_FETCH_BUSY environmental variable. ",
113             flags = Flags.Design)
114
115         ccns_node_fetch_lifetime = Attribute("ccnsNodeFetchLifetime",
116             "Sets the CCNS_NODE_FETCH_LIFETIME environmental variable. ",
117             flags = Flags.Design)
118
119         ccns_note_err = Attribute("ccnsNoteErr",
120             "Sets the CCNS_NOTE_ERR environmental variable. ",
121             flags = Flags.Design)
122
123         ccns_repo_store = Attribute("ccnsRepoStore",
124             "Sets the CCNS_REPO_STORE environmental variable. ",
125             flags = Flags.Design)
126
127         ccns_root_advise_fresh = Attribute("ccnsRootAdviseFresh",
128             "Sets the CCNS_ROOT_ADVISE_FRESH environmental variable. ",
129             flags = Flags.Design)
130
131         ccns_root_advise_lifetime = Attribute("ccnsRootAdviseLifetime",
132             "Sets the CCNS_ROOT_ADVISE_LIFETIME environmental variable. ",
133             flags = Flags.Design)
134
135         ccns_stable_enabled = Attribute("ccnsStableEnabled",
136             "Sets the CCNS_STABLE_ENABLED environmental variable. ",
137             flags = Flags.Design)
138
139         ccns_sync_scope = Attribute("ccnsSyncScope",
140             "Sets the CCNS_SYNC_SCOPE environmental variable. ",
141             flags = Flags.Design)
142
143         repo_file = Attribute("repoFile1",
144             "The Repository uses $CCNR_DIRECTORY/repoFile1 for "
145             "persistent storage of CCN Content Objects",
146             flags = Flags.Design)
147
148         cls._register_attribute(max_fanout)
149         cls._register_attribute(max_leaf_entries)
150         cls._register_attribute(max_node_bytes)
151         cls._register_attribute(max_node_pool)
152         cls._register_attribute(content_cache)
153         cls._register_attribute(debug)
154         cls._register_attribute(directory)
155         cls._register_attribute(global_prefix)
156         cls._register_attribute(listen_on)
157         cls._register_attribute(min_send_bufsize)
158         cls._register_attribute(proto)
159         cls._register_attribute(status_port)
160         cls._register_attribute(start_write_scope_limit)
161         cls._register_attribute(ccns_debug)
162         cls._register_attribute(ccns_enable)
163         cls._register_attribute(ccns_faux_error)
164         cls._register_attribute(ccns_heartbeat_micros)
165         cls._register_attribute(ccns_max_compares_busy)
166         cls._register_attribute(ccns_max_fetch_busy)
167         cls._register_attribute(ccns_node_fetch_lifetime)
168         cls._register_attribute(ccns_note_err)
169         cls._register_attribute(ccns_repo_store)
170         cls._register_attribute(ccns_root_advise_fresh)
171         cls._register_attribute(ccns_root_advise_lifetime)
172         cls._register_attribute(ccns_stable_enabled)
173         cls._register_attribute(ccns_sync_scope)
174         cls._register_attribute(repo_file)
175
176     def _instantiate_object(self):
177         if not self.get("binary"):
178             self.set("binary", "ccnr")
179
180         if not self.get("environment"):
181             self.set("environment", self._environment)
182        
183         repoFile1 = self.get("repoFile1")
184         if repoFile1:
185             env = "CCNR_DIRECTORY=/REPO/" 
186             environment = self.get("environment")
187             if environment:
188                 env += ";" + environment
189             self.set("environment", env)
190             self.set("files", "%s=/REPO/repoFile1" % repoFile1) 
191
192         super(LinuxNS3DceCCNR, self)._instantiate_object()
193
194     @property
195     def _environment(self):
196         envs = dict({
197             "maxFanout": "CCNR_BTREE_MAX_FANOUT",
198             "maxLeafEntries": "CCNR_BTREE_MAX_LEAF_ENTRIES",
199             "maxNodeBytes": "CCNR_BTREE_MAX_NODE_BYTES",
200             "maxNodePool": "CCNR_BTREE_MAX_NODE_POOL",
201             "contentCache": "CCNR_CONTENT_CACHE",
202             "debug": "CCNR_DEBUG",
203             "directory": "CCNR_DIRECTORY",
204             "globalPrefix": "CCNR_GLOBAL_PREFIX",
205             "listenOn": "CCNR_LISTEN_ON",
206             "minSendBufsize": "CCNR_MIN_SEND_BUFSIZE",
207             "proto": "CCNR_PROTO",
208             "statusPort": "CCNR_STATUS_PORT",
209             "startWriteScopeLimit": "CCNR_START_WRITE_SCOPE_LIMIT",
210             "ccnsDebug": "CCNS_DEBUG",
211             "ccnsEnable": "CCNS_ENABLE",
212             "ccnsFauxError": "CCNS_FAUX_ERROR",
213             "ccnsHeartBeatMicros": "CCNS_HEART_BEAT_MICROS",
214             "ccnsMaxComparesBusy": "CCNS_MAX_COMPARES_BUSY",
215             "ccnsMaxFetchBusy": "CCNS_MAX_FETCH_BUSY",
216             "ccnsNodeFetchLifetime": "CCNS_NODE_FETCH_LIFETIME",
217             "ccnsNoteErr": "CCNS_NOTE_ERR",
218             "ccnsRepoStore": "CCNS_REPO_STORE",
219             "ccnsRootAdviseFresh": "CCNS_ROOT_ADVISE_FRESH",
220             "ccnsRootAdviseLifetime": "CCNS_ROOT_ADVISE_LIFETIME",
221             "ccnsStableEnabled": "CCNS_STABLE_ENABLED",
222             "ccnsSyncScope": "CCNS_SYNC_SCOPE",
223             })
224
225         env = ";".join(map(lambda k: "%s=%s" % (envs.get(k), str(self.get(k))), 
226             [k for k in envs.keys() if self.get(k)]))
227
228         return env
229
230