Exemplo n.º 1
0
 def _create_session_manager(self):
     session_type = self._cfg_manager.get_value(WEBLAB_PROXY_SERVER_SESSION_TYPE, DEFAULT_WEBLAB_PROXY_SERVER_SESSION_TYPE)
     session_pool_id   = self._cfg_manager.get_value(WEBLAB_PROXY_SERVER_SESSION_POOL_ID, DEFAULT_WEBLAB_PROXY_SERVER_SESSION_POOL_ID)
     if session_type in SessionType.getSessionTypeValues():
         return SessionManager.SessionManager(self._cfg_manager, session_type, session_pool_id)
     else:
         raise ProxyErrors.NotASessionTypeError('Not a session type: %s' % session_type)
Exemplo n.º 2
0
 def _create_session_manager(self):
     session_type = self._cfg_manager.get_value(
         WEBLAB_PROXY_SERVER_SESSION_TYPE,
         DEFAULT_WEBLAB_PROXY_SERVER_SESSION_TYPE)
     session_pool_id = self._cfg_manager.get_value(
         WEBLAB_PROXY_SERVER_SESSION_POOL_ID,
         DEFAULT_WEBLAB_PROXY_SERVER_SESSION_POOL_ID)
     if session_type in SessionType.getSessionTypeValues():
         return SessionManager.SessionManager(self._cfg_manager,
                                              session_type, session_pool_id)
     else:
         raise ProxyErrors.NotASessionTypeError('Not a session type: %s' %
                                                session_type)
Exemplo n.º 3
0
    def __init__(self, cfg_manager, map=None, map_file=None, *args, **kwargs):
        """
        session_type: member of voodoo.sessions.session_type
        map: voodoo.gen.coordinator.CoordinationInformation.CoordinationMap
        map_file: file object

        The parameter session_type must be provided; if "map" parameter is provided, the CoordinatorServer
        uses this map. If map_file is provided, a new CoordinatorMap is created, and loaded from the map_file.
        If no one of these two parameters is provided, a new CoordinatorMap is created, waiting for the method
        "load" to be called. Finally, if both parameters are provided, an exception is raised.
        """
        super(CoordinatorServer, self).__init__(*args, **kwargs)
        session_type = cfg_manager.get_value(
            COORDINATOR_SERVER_SESSION_TYPE,
            DEFAULT_COORDINATOR_SERVER_SESSION_TYPE)
        session_pool_id = cfg_manager.get_value(
            COORDINATOR_SERVER_SESSION_POOL_ID,
            DEFAULT_COORDINATOR_SERVER_SESSION_POOL_ID)
        if session_type in SessionType.getSessionTypeValues():
            self._session_manager = SessionManager.SessionManager(
                cfg_manager, session_type, session_pool_id)
        else:
            raise CoordinatorServerErrors.NotASessionTypeError(
                "Not a session_type: %s" % session_type)
        if map is not None and map_file is None:
            self._coordination_map_controller = CoordinationInformation.CoordinationMapController(
                map)
        elif map is None and map_file is not None:
            self._coordination_map_controller = CoordinationInformation.CoordinationMapController(
            )
            self._coordination_map_controller.load(map_file)
        elif map is not None and map_file is not None:
            raise CoordinatorServerErrors.BothMapAndMapFileProvidedError(
                "Can't provide both map_file and map to CoordinatorServer")
        elif map is None and map_file is None:
            raise CoordinatorServerErrors.NeitherMapNorFileProvidedError(
                "Can't build the Coordination Map if neither map nor map_file fields are provided!"
            )
        else:
            raise RuntimeError(
                "This possibility should never happen -voodoo.gen.coordinator.CoordinatorServer.__init__-"
            )
Exemplo n.º 4
0
    def __init__(self,cfg_manager, session_type, session_pool_id, timeout = "default"):
        """ SessionManager(cfg_manager, session_type, session_pool_id[, timeout])

        * cfg_manager: a ConfigurationManager
        * session_type: a SessionType
        * session_pool_id: a str identifying which session pool are we refering to
        * timeout: the timeout of this session_pool_id. It can be an int or a float (both refering to seconds), or None (to set no timeout)
        """
        object.__init__(self)
        if not session_type in SessionType.getSessionTypeValues():
            raise SessionErrors.SessionInvalidSessionTypeError(
                    "Not a session type: %s " % session_type
                )

        self._cfg_manager = cfg_manager
        if timeout == "default":
            timeout = self._cfg_manager.get_doc_value(configuration_doc.SESSION_MANAGER_DEFAULT_TIMEOUT)

        gateway_class = SessionGateway.get_gateway_class(session_type)
        self.gateway = gateway_class(cfg_manager, session_pool_id, timeout)
        self._session_type = session_type

        SessionManagerCleaner.append_session_manager(self)
Exemplo n.º 5
0
    def __init__(self, cfg_manager, map = None, map_file = None, *args, **kwargs):
        """
        session_type: member of voodoo.sessions.session_type
        map: voodoo.gen.coordinator.CoordinationInformation.CoordinationMap
        map_file: file object

        The parameter session_type must be provided; if "map" parameter is provided, the CoordinatorServer
        uses this map. If map_file is provided, a new CoordinatorMap is created, and loaded from the map_file.
        If no one of these two parameters is provided, a new CoordinatorMap is created, waiting for the method
        "load" to be called. Finally, if both parameters are provided, an exception is raised.
        """
        super(CoordinatorServer, self).__init__(*args, **kwargs)
        session_type = cfg_manager.get_value(COORDINATOR_SERVER_SESSION_TYPE, DEFAULT_COORDINATOR_SERVER_SESSION_TYPE)
        session_pool_id = cfg_manager.get_value(COORDINATOR_SERVER_SESSION_POOL_ID, DEFAULT_COORDINATOR_SERVER_SESSION_POOL_ID)
        if session_type in SessionType.getSessionTypeValues():
            self._session_manager = SessionManager.SessionManager(
                    cfg_manager,
                    session_type,
                    session_pool_id
                )
        else:
            raise CoordinatorServerErrors.NotASessionTypeError(
                    "Not a session_type: %s" % session_type
                )
        if map is not None and map_file is None:
            self._coordination_map_controller = CoordinationInformation.CoordinationMapController(map)
        elif map is None and map_file is not None:
            self._coordination_map_controller = CoordinationInformation.CoordinationMapController()
            self._coordination_map_controller.load(map_file)
        elif map is not None and map_file is not None:
            raise CoordinatorServerErrors.BothMapAndMapFileProvidedError(
                "Can't provide both map_file and map to CoordinatorServer"
            )
        elif map is None and map_file is None:
            raise CoordinatorServerErrors.NeitherMapNorFileProvidedError("Can't build the Coordination Map if neither map nor map_file fields are provided!")
        else:
            raise RuntimeError("This possibility should never happen -voodoo.gen.coordinator.CoordinatorServer.__init__-")