use of com.zhizuqiu.nettyrestful.annotation.HttpMap 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.zhizuqiu.nettyrestful.annotation.HttpMap 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