Beispiel #1
0
    def statusUpdate(self, driver, update):
        """
        Called to tell us about the status of our task by Mesos.
        """
        tmp = update.data.split(':')
        if len(tmp) < 2:
            return
        host = tmp[0]
        ip_addr = tmp[1]

        if host not in self.slaves:
            self.slaves[host] = ip_addr
            util.add_to_hosts(host, ip_addr)
            util.add_to_cluster_conf(host)
            util.add_host_to_cluster(host.strip())
        elif update.state == mesos_pb2.TASK_FINISHED:
            util.rm_host_from_cluster(host.strip())
            util.rm_from_cluster_conf(host)
            util.rm_from_hosts(host)
            self.slaves.pop(host)
        elif update.state == mesos_pb2.TASK_LOST \
                or update.state == mesos_pb2.TASK_KILLED \
                or update.state == mesos_pb2.TASK_FAILED:
            driver.abort()

        util.show_openlava_state()
Beispiel #2
0
    def statusUpdate(self, driver, update):
        """
        Called to tell us about the status of our task by Mesos.
        """
        tmp = update.data.split(':')
        if len(tmp) < 2:
            return
        host = tmp[0]
        ip_addr = tmp[1]

        if host not in self.slaves:
            self.slaves[host] = ip_addr
            util.add_to_hosts(host, ip_addr)
            util.add_to_cluster_conf(host)
            util.add_host_to_cluster(host.strip())
        elif update.state == mesos_pb2.TASK_FINISHED:
            util.rm_host_from_cluster(host.strip())
            util.rm_from_cluster_conf(host)
            util.rm_from_hosts(host)
            self.slaves.pop(host)
        elif update.state == mesos_pb2.TASK_LOST \
                or update.state == mesos_pb2.TASK_KILLED \
                or update.state == mesos_pb2.TASK_FAILED:
            driver.abort()

        util.show_openlava_state()
Beispiel #3
0
        def run_task():
            """
            Run a Apache Mesos Task.
            """
            # start openlava services
            tmp = json.loads(task.data)
            master_hostname = tmp['master_hostname']
            master_ip = tmp['master_ip']
            agent_hostname = tmp['agent_hostname']
            agent_ip = tmp['agent_ip']

            # configure the master.
            util.add_to_hosts(master_hostname, master_ip)
            util.add_to_cluster_conf(master_hostname)

            # tell master we are ready to fire up.
            update = mesos_pb2.TaskStatus()
            update.task_id.value = task.task_id.value
            update.state = mesos_pb2.TASK_RUNNING
            update.data = str(agent_hostname) + ':' + str(agent_ip)
            driver.sendStatusUpdate(update)

            util.start_lava()

            # in case I'm idle for a while done.
            busy = True
            count = 0
            while busy:
                time.sleep(10)

                try:
                    if util.njobs_per_host(agent_hostname.strip()) == 0:
                        count += 1
                except:
                    # lim not ready...
                    pass

                if count >= 12:
                    busy = False
                    # tell master we are done here.
                    update = mesos_pb2.TaskStatus()
                    update.task_id.value = task.task_id.value
                    update.state = mesos_pb2.TASK_FINISHED
                    update.data = str(agent_hostname) + ':' + str(agent_ip)
                    driver.sendStatusUpdate(update)
                    util.stop_lava()
Beispiel #4
0
        def run_task():
            """
            Run a Apache Mesos Task.
            """
            # start openlava services
            tmp = json.loads(task.data)
            master_hostname = tmp['master_hostname']
            master_ip = tmp['master_ip']
            agent_hostname = tmp['agent_hostname']
            agent_ip = tmp['agent_ip']

            # configure the master.
            util.add_to_hosts(master_hostname, master_ip)
            util.add_to_cluster_conf(master_hostname)

            # tell master we are ready to fire up.
            update = mesos_pb2.TaskStatus()
            update.task_id.value = task.task_id.value
            update.state = mesos_pb2.TASK_RUNNING
            update.data = str(agent_hostname) + ':' + str(agent_ip)
            driver.sendStatusUpdate(update)

            util.start_lava()

            # in case I'm idle for a while done.
            busy = True
            count = 0
            while busy:
                time.sleep(10)

                try:
                    if util.njobs_per_host(agent_hostname.strip()) == 0:
                        count += 1
                except:
                    # lim not ready...
                    pass

                if count >= 12:
                    busy = False
                    # tell master we are done here.
                    update = mesos_pb2.TaskStatus()
                    update.task_id.value = task.task_id.value
                    update.state = mesos_pb2.TASK_FINISHED
                    update.data = str(agent_hostname) + ':' + str(agent_ip)
                    driver.sendStatusUpdate(update)
                    util.stop_lava()
Beispiel #5
0
    def statusUpdate(self, driver, update):
        """
        Called to tell us about the status of our task by Mesos.
        """
        tmp = update.data.split(':')
        if len(tmp) < 2:
            return
        host = tmp[0]
        ip_addr = tmp[1]

        if host not in self.running_tasks:
            util.add_to_hosts(host, ip_addr)
            util.add_to_cluster_conf(host)
            # We tell the master to only expose those shares it should
            # expose and not more - currently JOB_SLOTS = CPU offers.
            tmp = self.accepted_tasks[host]
            max_jobs = tmp[0]
            resource_tag = tmp[1]
            util.add_host_to_cluster(host.strip(), max_jobs, resource_tag)
            self.running_tasks[host] = ip_addr
        elif update.state == mesos_pb2.TASK_FINISHED:
            util.rm_host_from_cluster(host.strip())
            util.rm_from_cluster_conf(host)
            util.rm_from_hosts(host)
            self.accepted_tasks.pop(host)
            self.running_tasks.pop(host)
        elif update.state == mesos_pb2.TASK_LOST \
                or update.state == mesos_pb2.TASK_KILLED \
                or update.state == mesos_pb2.TASK_FAILED:
            driver.abort()
            self.accepted_tasks.pop(host)
            self.running_tasks.pop(host)

        # TODO: use proper logging!
        print('Current queue length (normal): {0}'.
              format(util.get_queue_length('normal')))
        print('Current queue length (priority): {0}'.
              format(util.get_queue_length('priority')))
        print('Current number of hosts: {0}'.
              format(str(len(util.get_hosts()) - 2)))

        sys.stdout.flush()
Beispiel #6
0
        def run_task():
            """
            Run a Apache Mesos Task.
            """
            # start openlava services
            tmp = json.loads(task.data)
            host = tmp['master_host']
            ip_addr = tmp['master_ip']
            util.add_to_hosts(host, ip_addr)
            util.add_to_cluster_conf(host)

            slave_host, slave_ip = util.get_ip()

            update = mesos_pb2.TaskStatus()
            update.task_id.value = task.task_id.value
            update.state = mesos_pb2.TASK_RUNNING
            update.data = slave_host + ':' + slave_ip
            driver.sendStatusUpdate(update)

            util.start_lava()

            # in case I'm idle for a while done.
            busy = True
            count = 0
            while busy:
                time.sleep(10)

                try:
                    if util.njobs_per_host(slave_host.strip()) == 0:
                        count += 1
                except:
                    # lim not ready...
                    pass

                if count >= 12:
                    busy = False
                    update = mesos_pb2.TaskStatus()
                    update.task_id.value = task.task_id.value
                    update.state = mesos_pb2.TASK_FINISHED
                    update.data = slave_host + ':' + slave_ip
                    driver.sendStatusUpdate(update)
                    util.stop_lava()
Beispiel #7
0
    def statusUpdate(self, driver, update):
        """
        Called to tell us about the status of our task by Mesos.
        """
        tmp = update.data.split(':')
        if len(tmp) < 2:
            return
        host = tmp[0]
        ip_addr = tmp[1]

        if host not in self.running_tasks:
            util.add_to_hosts(host, ip_addr)
            util.add_to_cluster_conf(host)
            # We tell the master to only expose those shares it should
            # expose and not more - currently JOB_SLOTS = CPU offers.
            tmp = self.accepted_tasks[host]
            max_jobs = tmp[0]
            resource_tag = tmp[1]
            util.add_host_to_cluster(host.strip(), max_jobs, resource_tag)
            self.running_tasks[host] = ip_addr
        elif update.state == mesos_pb2.TASK_FINISHED:
            util.rm_host_from_cluster(host.strip())
            util.rm_from_cluster_conf(host)
            util.rm_from_hosts(host)
            self.accepted_tasks.pop(host)
            self.running_tasks.pop(host)
        elif update.state == mesos_pb2.TASK_LOST \
                or update.state == mesos_pb2.TASK_KILLED \
                or update.state == mesos_pb2.TASK_FAILED:
            driver.abort()
            self.accepted_tasks.pop(host)
            self.running_tasks.pop(host)

        # TODO: use proper logging!
        print('Current queue length (normal): {0}'.format(
            util.get_queue_length('normal')))
        print('Current queue length (priority): {0}'.format(
            util.get_queue_length('priority')))
        print('Current number of hosts: {0}'.format(
            str(len(util.get_hosts()) - 2)))

        sys.stdout.flush()