use of com.chinaunicom.rundocker.bean.returnparm.Task in project mesosFramework by zhizuqiu.
the class RestHandler method startTask.
/**
* 启动任务,如url?id=/2048/1
*
* @param mapParam 请求参数
* @param response 请求响应
* @return 返回参数
*/
@HttpMap(path = "/tasks", paramType = HttpMap.ParamType.URL_DATA, method = HttpMap.Method.PUT)
public Task startTask(Map<String, String> mapParam, DefaultFullHttpResponse response) {
Task task = new Task();
if (mapParam == null || mapParam.isEmpty()) {
response.setStatus(BAD_REQUEST);
return task;
}
String id = mapParam.get("id");
if (id == null || id.trim().isEmpty()) {
response.setStatus(BAD_REQUEST);
return task;
}
Task taskTemp = startOneTask(id);
if (taskTemp != null) {
task = taskTemp;
}
// 判断是否还有任务未下发,是则请求offer
if (!SchedulerService.checkAllAppsIsAccept()) {
AppDataStore.getSchedulerDriver().reviveOffers();
logger.info("reviveOffers");
}
return task;
}
use of com.chinaunicom.rundocker.bean.returnparm.Task in project mesosFramework by zhizuqiu.
the class RestHandler method startOneTask.
/**
* 启动一个
*/
private Task startOneTask(String id) {
Task task = new Task();
task.setId(id);
task.setId(id);
String key = Tools.getStringByJsonpathRecursion(id.trim().replaceAll("/", "."));
DockerStatus dockerStatus = AppDataStore.statusGet(key);
if (dockerStatus == null) {
return null;
}
DockerJob dockerJob = AppDataStore.jobsGet(key);
if (dockerJob == null) {
return null;
}
if (dockerStatus.canRunAgain(dockerJob.getRetries())) {
dockerStatus.setSubmitted(false);
dockerStatus.setTryCount(0);
}
return task;
}
use of com.chinaunicom.rundocker.bean.returnparm.Task in project mesosFramework by zhizuqiu.
the class RestHandler method deleteOneJob.
/**
* 删除一个
*/
private Task deleteOneJob(String id) {
Task task = new Task();
task.setId(id);
String key = Tools.getStringByJsonpathRecursion(id.trim().replaceAll("/", "."));
// 停止
Protos.TaskID taskID = Protos.TaskID.newBuilder().setValue(key).build();
AppDataStore.getSchedulerDriver().killTask(taskID);
DockerStatus dockerStatus = AppDataStore.statusGet(key);
if (dockerStatus != null) {
dockerStatus.setStatus(JobState.WAIT_DELETE);
} else {
logger.error("delete app not exists");
return null;
}
return task;
}
use of com.chinaunicom.rundocker.bean.returnparm.Task in project mesosFramework by zhizuqiu.
the class RestHandler method deleteJob.
/**
* 删除单个任务
*/
@HttpMap(path = "/jobs", paramType = HttpMap.ParamType.URL_DATA, method = HttpMap.Method.DELETE)
public Task deleteJob(Map<String, String> mapParam, DefaultFullHttpResponse response) {
Task task = new Task();
if (mapParam == null || mapParam.isEmpty()) {
response.setStatus(BAD_REQUEST);
return task;
}
String id = mapParam.get("id");
if (id == null || id.trim().isEmpty()) {
response.setStatus(BAD_REQUEST);
return task;
}
Task taskTemp = deleteOneJob(id);
if (taskTemp != null) {
task = taskTemp;
}
return task;
}
Aggregations