示例#1
0
    def subscribed(self, driver):
        """
        Invoked when the scheduler successfully registers with a Mesos master.
        It is called with a SchedulerDriver which has attributes that include
        the frameworkId, and the mesos_url, which indicates the master currently leading.
        """

        self._driver = driver
        self._framework_id = driver.frameworkId
        self._master_host_address = host_address_from_mesos_url(
            driver.mesos_url)

        logger.info(
            'Scale scheduler registered as framework %s with Mesos master at %s:%i',
            self._framework_id, self._master_host_address.hostname,
            self._master_host_address.port)

        scheduler_mgr.update_from_mesos(self._framework_id,
                                        self._master_host_address)

        # Update driver for background threads
        recon_mgr.driver = self._driver
        self._scheduling_thread.client = self._client
        self._sync_thread.driver = self._driver
        self._task_handling_thread.driver = self._driver

        self._reconcile_running_jobs()
示例#2
0
    def reconnected(self, message):
        """
        Invoked when the scheduler re-registers with a newly elected Mesos
        master.  This is only called when the scheduler has previously been
        registered.
        """

        self._framework_id = self._driver.frameworkId
        self._master_host_address = host_address_from_mesos_url(self._driver.mesos_url)

        logger.info('Scale scheduler re-registered with Mesos master at %s:%i',
                    self._master_host_address.hostname, self._master_host_address.port)

        scheduler_mgr.update_from_mesos(mesos_address=self._master_host_address)

        self._reconcile_running_jobs()
示例#3
0
    def test_mesos_sync_error(self, mock_dcos):
        """Tests doing a successful sync with mesos"""
        mock_dcos.return_value.json.return_value = {
            'slaves': [{
                'no_id_key': 'agent_1',
                'resources': {
                    'cpus': 1.0,
                    'mem': 1024.0,
                    'disk': 1024.0
                }
            }]
        }

        host = host_address_from_mesos_url('http://leader.mesos:80/mesos')
        resource_mgr.sync_with_mesos(host)
        self.assertEqual(resource_mgr._mesos_error,
                         'Missing key u\'id\' in mesos response')
示例#4
0
    def test_successful_mesos_sync(self, mock_dcos):
        """Tests doing a successful sync with mesos"""
        mock_dcos.return_value.json.return_value = {
            'slaves': [{
                'id': 'agent_1',
                'resources': {
                    'cpus': 1.0,
                    'mem': 1024.0,
                    'disk': 1024.0
                }
            }]
        }

        host = host_address_from_mesos_url('http://leader.mesos:80/mesos')
        resource_mgr.sync_with_mesos(host)
        self.assertTrue(
            resource_mgr._agent_resources['agent_1']._total_resources.is_equal(
                NodeResources([Cpus(1.0), Mem(1024.0),
                               Disk(1024.0)])))
示例#5
0
 def test_https_no_port(self):
     result = host_address_from_mesos_url('https://leader.mesos/mesos')
     self.assertEquals(result.protocol, 'https')
     self.assertEquals(result.hostname, 'leader.mesos')
     self.assertEquals(result.port, 443)
示例#6
0
 def test_http_url(self):
     result = host_address_from_mesos_url('http://leader.mesos:80/mesos')
     self.assertEquals(result.protocol, 'http')
     self.assertEquals(result.hostname, 'leader.mesos')
     self.assertEquals(result.port, 80)