Esempio n. 1
0
    def __init__(self, config_desc, keys_auth, client, use_ipv6=False):
        self.client = client
        self.keys_auth = keys_auth
        self.resources_to_send = []
        self.resources_to_get = []
        self.res_send_it = 0
        self.peers_it = 0
        self.dir_manager = DirManager(client.datadir)
        self.resource_manager = DistributedResourceManager(
            self.dir_manager.get_resource_dir())
        self.use_ipv6 = use_ipv6
        network = TCPNetwork(
            ProtocolFactory(FilesProtocol, self,
                            SessionFactory(ResourceSession)), use_ipv6)
        PendingConnectionsServer.__init__(self, config_desc, network)

        self.resource_peers = {}
        self.waiting_tasks = {}
        self.waiting_tasks_to_compute = {}
        self.waiting_resources = {}

        self.last_get_resource_peers_time = time.time()
        self.get_resource_peers_interval = 5.0
        self.sessions = []

        self.last_message_time_threshold = config_desc.resource_session_timeout
Esempio n. 2
0
    def __init__(self,
                 node,
                 config_desc,
                 keys_auth,
                 client,
                 use_ipv6=False,
                 use_docker_machine_manager=True):
        self.client = client
        self.keys_auth = keys_auth
        self.config_desc = config_desc

        self.node = node
        self.task_keeper = TaskHeaderKeeper(client.environments_manager,
                                            min_price=config_desc.min_price)
        self.task_manager = TaskManager(
            config_desc.node_name,
            self.node,
            self.keys_auth,
            root_path=TaskServer.__get_task_manager_root(client.datadir),
            use_distributed_resources=config_desc.
            use_distributed_resource_management,
            tasks_dir=os.path.join(client.datadir, 'tasks'))
        self.task_computer = TaskComputer(
            config_desc.node_name,
            task_server=self,
            use_docker_machine_manager=use_docker_machine_manager)
        self.task_connections_helper = TaskConnectionsHelper()
        self.task_connections_helper.task_server = self
        self.task_sessions = {}
        self.task_sessions_incoming = WeakList()

        self.max_trust = 1.0
        self.min_trust = 0.0

        self.last_messages = []
        self.last_message_time_threshold = config_desc.task_session_timeout

        self.results_to_send = {}
        self.failures_to_send = {}

        self.use_ipv6 = use_ipv6

        self.forwarded_session_request_timeout = config_desc.waiting_for_task_session_timeout
        self.forwarded_session_requests = {}
        self.response_list = {}
        self.deny_set = get_deny_set(datadir=client.datadir)

        network = TCPNetwork(
            ProtocolFactory(MidAndFilesProtocol, self,
                            SessionFactory(TaskSession)), use_ipv6)
        PendingConnectionsServer.__init__(self, config_desc, network)
Esempio n. 3
0
    def __init__(self,
                 node,
                 config_desc: ClientConfigDescriptor,
                 client,
                 use_ipv6=False,
                 use_docker_manager=True,
                 task_archiver=None,
                 apps_manager=AppsManager(),
                 task_finished_cb=None) -> None:
        self.client = client
        self.keys_auth = client.keys_auth
        self.config_desc = config_desc

        self.node = node
        self.task_archiver = task_archiver
        self.task_keeper = TaskHeaderKeeper(
            environments_manager=client.environments_manager,
            node=self.node,
            min_price=config_desc.min_price,
            task_archiver=task_archiver)
        self.task_manager = TaskManager(
            config_desc.node_name,
            self.node,
            self.keys_auth,
            root_path=TaskServer.__get_task_manager_root(client.datadir),
            use_distributed_resources=config_desc.
            use_distributed_resource_management,
            tasks_dir=os.path.join(client.datadir, 'tasks'),
            apps_manager=apps_manager,
            finished_cb=task_finished_cb,
        )
        benchmarks = self.task_manager.apps_manager.get_benchmarks()
        self.benchmark_manager = BenchmarkManager(
            node_name=config_desc.node_name,
            task_server=self,
            root_path=self.get_task_computer_root(),
            benchmarks=benchmarks)
        self.task_computer = TaskComputer(
            task_server=self,
            use_docker_manager=use_docker_manager,
            finished_cb=task_finished_cb)
        self.task_connections_helper = TaskConnectionsHelper()
        self.task_connections_helper.task_server = self
        self.task_sessions = {}
        self.task_sessions_incoming = weakref.WeakSet()

        self.max_trust = 1.0
        self.min_trust = 0.0

        self.last_messages = []
        self.last_message_time_threshold = config_desc.task_session_timeout

        self.results_to_send = {}
        self.failures_to_send = {}

        self.use_ipv6 = use_ipv6

        self.forwarded_session_request_timeout = \
            config_desc.waiting_for_task_session_timeout
        self.forwarded_session_requests = {}
        self.response_list = {}
        self.acl = get_acl(Path(client.datadir))
        self.resource_handshakes = {}

        network = TCPNetwork(
            ProtocolFactory(SafeProtocol, self, SessionFactory(TaskSession)),
            use_ipv6)
        PendingConnectionsServer.__init__(self, config_desc, network)
        # instantiate ReceivedMessageHandler connected to self
        # to register in golem.network.concent.handlers_library
        from golem.network.concent import \
            received_handler as concent_received_handler
        self.concent_handler = \
            concent_received_handler.TaskServerMessageHandler(self)

        dispatcher.connect(self.income_listener, signal='golem.income')

        dispatcher.connect(self.finished_task_listener,
                           signal='golem.taskmanager')