Exemplo n.º 1
0
    def _get_ready_for_service(self):
        """Perform further initialization.

        Here are initialized those components that need any information
        available at runtime and thus couldn't be initialized by the
        constructor.
        """
        # TODO: do we need this at all?

        self.logger.debug(u"Initializing Warebox...")
        self._warebox = Warebox(self.cfg)

        self.logger.debug(u"Initializing Warebox Cache...")

        session_queue = MultiQueue([
            'servermessage',  # Messages sent by the server
            'operation',  # PathnameOperation objects to handle
            'usercommand',  # Commands sent by the user
            'sessioncommand',  # ServerSession internal use commands
            'systemcommand'  # Commands sent by other client components
        ])

        self.logger.debug(u"Initializing Event Queue...")
        self.queue = EventsQueue(self._internal_facade, session_queue)

        self.logger.debug(u"Initializing Storage Connector...")
        self.connector = StorageConnector(self._warebox, self.cfg)

        self.logger.debug(u"Initializing FileSystem Watcher...")
        self.FSWatcher = filesystemwatcher.watcher_class(self._warebox,
                                                         self.queue,
                                                         start_suspended=True)

        self.logger.debug(u"Initializing Startup Synchronization...")
        self.startup_synchronization = StartupSynchronization(
            self._warebox, self.storage_cache, self.queue)

        self.logger.debug(u"Initializing Server Session...")
        self._server_session = ServerSession(self.cfg,
                                             self._warebox,
                                             self.storage_cache,
                                             self.startup_synchronization,
                                             self.FSWatcher,
                                             self.linker,
                                             self._metadata_db,
                                             self.hashesDB,
                                             self._internal_facade,
                                             self._ui_controller,
                                             self.lockfile_fd,
                                             auto_start=self.auto_start,
                                             input_queue=session_queue,
                                             scheduler=self._scheduler)

        self.logger.debug(u"Initialization completed successfully")