class NS3BaseDceApplication(NS3BaseApplication):
_rtype = "abstract::ns3::DceApplication"
- # Lock used to synchronize usage of DceManagerHelper
- _dce_manager_lock = threading.Lock()
- # Lock used to synchronize usage of DceApplicationHelper
- _dce_application_lock = threading.Lock()
-
- _dce_manager_helper_uuid = None
- _dce_application_helper_uuid = None
-
@classmethod
def _register_attributes(cls):
binary = Attribute("binary",
def pid(self):
return self._pid
- @property
- def dce_manager_helper_uuid(self):
- if not NS3BaseDceApplication._dce_manager_helper_uuid:
- NS3BaseDceApplication._dce_manager_helper_uuid = \
- self.simulation.create("DceManagerHelper")
-
- if self.get("useDlmLoader"):
- self.simulation.invoke(
- NS3BaseDceApplication._dce_manager_helper_uuid,
- "SetLoader",
- "ns3::DlmLoaderFactory")
-
- return NS3BaseDceApplication._dce_manager_helper_uuid
-
- @property
- def dce_application_helper_uuid(self):
- if not NS3BaseDceApplication._dce_application_helper_uuid:
- NS3BaseDceApplication._dce_application_helper_uuid = \
- self.simulation.create("DceApplicationHelper")
-
- return NS3BaseDceApplication._dce_application_helper_uuid
-
- @property
- def dce_manager_lock(self):
- return NS3BaseDceApplication._dce_manager_lock
-
- @property
- def dce_application_lock(self):
- return NS3BaseDceApplication._dce_application_lock
-
def _instantiate_object(self):
pass
# Preventing concurrent access to the DceApplicationHelper
# from different DceApplication RMs
- with self.dce_application_lock:
- self.simulation.invoke(
- self.dce_application_helper_uuid,
- "ResetArguments")
+ dce_helper = self.simulation.dce_helper
+
+ with dce_helper.dce_application_lock:
+ dce_app_uuid = dce_helper.dce_application_uuid
+
+ self.simulation.invoke(dce_app_uuid, "ResetArguments")
- self.simulation.invoke(
- self.dce_application_helper_uuid,
- "ResetEnvironment")
+ self.simulation.invoke(dce_app_uuid, "ResetEnvironment")
- self.simulation.invoke(
- self.dce_application_helper_uuid,
+ self.simulation.invoke(dce_app_uuid,
"SetBinary", self.get("binary"))
- self.simulation.invoke(
- self.dce_application_helper_uuid,
+ self.simulation.invoke(dce_app_uuid,
"SetStackSize", self.get("stackSize"))
arguments = self.get("arguments")
if arguments:
for arg in map(str.strip, arguments.split(";")):
- self.simulation.invoke(
- self.dce_application_helper_uuid,
+ self.simulation.invoke(dce_app_uuid,
"AddArgument", arg)
environment = self.get("environment")
if environment:
for env in map(str.strip, environment.split(";")):
key, val = env.split("=")
- self.simulation.invoke(
- self.dce_application_helper_uuid,
+ self.simulation.invoke(dce_app_uuid,
"AddEnvironment", key, val)
- apps_uuid = self.simulation.invoke(
- self.dce_application_helper_uuid,
+ apps_uuid = self.simulation.invoke(dce_app_uuid,
"InstallInNode", self.node.uuid)
-
- """
- container_uuid = self.simulation.create("NodeContainer")
- self.simulation.invoke(container_uuid, "Add", self.node.uuid)
- apps_uuid = self.simulation.invoke(
- self.dce_application_helper_uuid,
- "Install", container_uuid)
- """
-
self._uuid = self.simulation.invoke(apps_uuid, "Get", 0)
if self.has_changed("StartTime"):
# Using lock to prevent concurrent access to the DceApplicationHelper
# from different DceApplication RMs
- with self.dce_application_lock:
- self._pid = self.simulation.invoke(self.dce_application_helper_uuid,
+ dce_helper = self.simulation.dce_helper
+
+ with dce_helper.dce_application_lock:
+ dce_app_uuid = dce_helper.dce_application_uuid
+
+ self._pid = self.simulation.invoke(dce_app_uuid,
"GetPid", self.uuid)
node_id = self.node.node_id
--- /dev/null
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2014 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+
+import os
+import time
+import threading
+
+class NS3DceHelper(object):
+ def __init__(self, simulation):
+ self.simulation = simulation
+
+ # Lock used to synchronize usage of DceManagerHelper
+ self._dce_manager_lock = threading.Lock()
+ # Lock used to synchronize usage of DceApplicationHelper
+ self._dce_application_lock = threading.Lock()
+
+ self._dce_manager_uuid = None
+ self._dce_application_uuid = None
+
+ @property
+ def dce_manager_uuid(self):
+ if not self._dce_manager_uuid:
+ self._dce_manager_uuid = \
+ self.simulation.create("DceManagerHelper")
+
+ return self._dce_manager_uuid
+
+ @property
+ def dce_application_uuid(self):
+ if not self._dce_application_uuid:
+ self._dce_application_uuid = \
+ self.simulation.create("DceApplicationHelper")
+
+ return self._dce_application_uuid
+
+ @property
+ def dce_manager_lock(self):
+ return self._dce_manager_lock
+
+ @property
+ def dce_application_lock(self):
+ return self._dce_application_lock
+