예제 #1
0
    def onNewMasterDetectedMessage(self, data):
        try:
            info = MasterInfo()
            info.ParseFromString(data)
            ip = socket.inet_ntoa(struct.pack('<I', info.ip))
            self.master = UPID('master@%s:%s' % (ip, info.port))
        except:
            self.master = UPID(data)

        self.connected = False
        self.register()
예제 #2
0
    def onRunTaskMessage(self, framework_id, framework_info, pid, task):
        logger.info("Got assigned task %s for framework %s", 
                task.task_id.value, framework_id.value)
        fid = framework_id.value
        if fid not in self.frameworks:
            framework = Framework(framework_id, framework_info, UPID(pid), self.options)
            self.frameworks[fid] = framework
        else:
            framework = self.frameworks[fid]

        executorInfo = framework.get_executor_info(task)
        eid = executorInfo.executor_id
        executor = framework.getExecutor(eid)
        if executor:
            if executor.shutdown:
                logger.warning("WARNING! executor is shuting down")
            elif not executor.pid:
                executor.queuedTasks[task.task_id.value] = task
            else:
                executor.addTask(task)
                #self.isolation.resourcesChanged(framework_id, executor.id, executor.resources)

                msg = RunTaskMessage()
                msg.framework.MergeFrom(framework.info)
                msg.framework_id.MergeFrom(framework_id)
                msg.pid = str(framework.pid)
                msg.task.MergeFrom(task)
                self.send(executor.pid, msg)
        else:
            directory = self.createUniqueWorkDirectory(framework.id, eid)
            executor = framework.createExecutor(executorInfo, directory)
            executor.queuedTasks[task.task_id.value] = task
            self.isolation.launchExecutor(framework.id, framework.info, executor.info,
                    directory, executor.resources)
예제 #3
0
파일: scheduler.py 프로젝트: wtzhuque/dpark
    def onStatusUpdateMessage(self, update, pid=''):
        assert self.framework_id == update.framework_id
        
        if pid and not pid.endswith('0.0.0.0:0'):
            reply = StatusUpdateAcknowledgementMessage()
            reply.framework_id.MergeFrom(self.framework_id)
            reply.slave_id.MergeFrom(update.slave_id)
            reply.task_id.MergeFrom(update.status.task_id)
            reply.uuid = update.uuid
            try: self.send(UPID(pid), reply)
            except IOError: pass

        self.sched.statusUpdate(self, update.status)
예제 #4
0
    def __init__(self, options):
        Process.__init__(self, "slave")
        self.options = options
        self.resources = Resources(options.cpus, options.mem)
        self.attributes = options.attributes

        self.id = None
        self.isolation = IsolationModule()
        self.info = self.getSlaveInfo() 
        self.master = UPID('master', options.master)
        self.frameworks = {}
        self.startTime = time.time()
        self.connected = False
예제 #5
0
파일: executor.py 프로젝트: xzflin/dpark
    def __init__(self, executor):
        Process.__init__(self, 'executor')
        self.executor = executor

        env = os.environ
        self.local = bool(env.get('MESOS_LOCAL'))
        slave_pid = env.get('MESOS_SLAVE_PID')
        assert slave_pid, 'expecting MESOS_SLAVE_PID in environment'
        self.slave = UPID(slave_pid)
        self.framework_id = FrameworkID()
        self.framework_id.value = env.get('MESOS_FRAMEWORK_ID')
        self.executor_id = ExecutorID()
        self.executor_id.value = env.get('MESOS_EXECUTOR_ID')
        self.workDirectory = env.get('MESOS_DIRECTORY')
예제 #6
0
파일: scheduler.py 프로젝트: wtzhuque/dpark
 def onNewMasterDetectedMessage(self, pid):
     self.master = UPID(pid)
     self.connected = False
     self.register()
예제 #7
0
파일: scheduler.py 프로젝트: wtzhuque/dpark
 def onResourceOffersMessage(self, offers, pids):
     for offer, pid in zip(offers, pids):
         self.savedOffers.setdefault(offer.id.value, {})[offer.slave_id.value] = UPID(pid)
     self.sched.resourceOffers(self, list(offers))