Search in sources :

Example 6 with HttpMap

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;
}
Also used : Task(com.chinaunicom.rundocker.bean.returnparm.Task) HttpMap(com.zhizuqiu.nettyrestful.annotation.HttpMap)

Example 7 with HttpMap

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;
}
Also used : Task(com.chinaunicom.rundocker.bean.returnparm.Task) HttpMap(com.zhizuqiu.nettyrestful.annotation.HttpMap)

Aggregations

HttpMap (com.zhizuqiu.nettyrestful.annotation.HttpMap)7 Task (com.chinaunicom.rundocker.bean.returnparm.Task)6 Gson (com.google.gson.Gson)4 ArrayList (java.util.ArrayList)4 JsonSyntaxException (com.google.gson.JsonSyntaxException)3 DockerJob (com.chinaunicom.rundocker.bean.DockerJob)1 DockerStatus (com.chinaunicom.rundocker.bean.DockerStatus)1 Jobs (com.chinaunicom.rundocker.bean.returnparm.Jobs)1 AppDataStore (com.chinaunicom.rundocker.store.AppDataStore)1