Example #1
0
func (sdriver *SchedulerDriver) SendFrameworkMessage(
	executorId *ExecutorID,
	slaveId *SlaveID,
	data string) error {
	if sdriver.driver != nil {
		executorMessage, executorErr := serialize(executorId)
		if executorErr != nil {
			return executorErr
		}

		slaveMessage, slaveErr := serialize(slaveId)
		if slaveErr != nil {
			return slaveErr
		}

		var cdata *C.char = C.CString(data)

		C.scheduler_sendFrameworkMessage(
			C.SchedulerDriverPtr(sdriver.driver),
			&executorMessage,
			&slaveMessage,
			cdata)
	} else {
		return errors.New(
			"SendFrameworkMessage() failed: scheduler driver not initialized")
	}

	return nil
}
Example #2
0
func (sdriver *SchedulerDriver) DeclineOffer(
	offerId *OfferID,
	filters ...Filters) error {
	if sdriver.driver != nil {
		message, err := serialize(offerId)
		if err != nil {
			return err
		}

		var filters_ *C.ProtobufObj = nil
		if len(filters) > 1 {
			filtersObj, err := serialize(&filters[0])
			if err != nil {
				return err
			}

			filters_ = &filtersObj
		}

		C.scheduler_declineOffer(
			C.SchedulerDriverPtr(sdriver.driver),
			&message,
			filters_)
	} else {
		return errors.New("Start() failed: scheduler driver not initialized")
	}
	return nil
}
Example #3
0
func (sdriver *SchedulerDriver) RequestResources(requests []Request) error {
	if sdriver.driver != nil {
		var requestsData []byte
		for _, request := range requests {
			requestItemData, err := serializeItem(&request)
			if err != nil {
				return err
			}

			requestsData = append(requestsData, requestItemData...)
		}

		requestsObj := C.ProtobufObj{
			data: unsafe.Pointer(&requestsData[0]),
			size: C.size_t(len(requestsData)),
		}

		C.scheduler_requestResources(
			C.SchedulerDriverPtr(sdriver.driver),
			&requestsObj)
	} else {
		return errors.New(
			"RequestResources() failed: scheduler driver not initialized")
	}

	return nil
}
Example #4
0
func (sdriver *SchedulerDriver) ReviveOffers() error {
	if sdriver.driver != nil {
		C.scheduler_reviveOffers(C.SchedulerDriverPtr(sdriver.driver))
	} else {
		return errors.New("ReviveOffers() failed: scheduler driver not initialized")
	}
	return nil
}
Example #5
0
func (sdriver *SchedulerDriver) Join() error {
	if sdriver.driver != nil {
		C.scheduler_join(C.SchedulerDriverPtr(sdriver.driver))
	} else {
		return errors.New("Join() failed: scheduler driver not initialized")
	}
	return nil
}
Example #6
0
func (sdriver *SchedulerDriver) Stop(failover bool) error {
	if sdriver.driver != nil {
		var failoverInt C.int = 0
		if failover {
			failoverInt = 1
		}

		C.scheduler_stop(C.SchedulerDriverPtr(sdriver.driver), failoverInt)
	} else {
		return errors.New("Stop() failed: scheduler driver not initialized")
	}
	return nil
}
Example #7
0
func (sdriver *SchedulerDriver) KillTask(taskId *TaskID) error {
	if sdriver.driver != nil {
		message, err := serialize(taskId)
		if err != nil {
			return err
		}

		C.scheduler_killTask(C.SchedulerDriverPtr(sdriver.driver), &message)
	} else {
		return errors.New("KillTask() failed: scheduler driver not initialized")
	}

	return nil
}
Example #8
0
func (sdriver *SchedulerDriver) LaunchTasks(
	offerId *OfferID,
	tasks []*TaskInfo,
	filters ...Filters) error {

	if sdriver.driver != nil {
		offerObj, err := serialize(offerId)
		if err != nil {
			return err
		}

		var tasksData []byte
		for _, task := range tasks {
			taskItemData, err := serializeItem(task)
			if err != nil {
				return err
			}
			tasksData = append(tasksData, taskItemData...)
		}

		tasksObj := C.ProtobufObj{
			data: unsafe.Pointer(&tasksData[0]),
			size: C.size_t(len(tasksData)),
		}

		var filters_ *C.ProtobufObj = nil
		if len(filters) > 1 {
			filtersObj, err := serialize(&filters[0])
			if err != nil {
				return err
			}

			filters_ = &filtersObj
		}

		C.scheduler_launchTasks(
			C.SchedulerDriverPtr(sdriver.driver),
			&offerObj,
			&tasksObj,
			filters_)
	} else {
		return errors.New("LaunchTasks() failed: scheduler driver not initialized")
	}

	return nil
}