REM:
1. 增加清洗任务状态码
2. 增加获取备任务状态信息接口
3. 增加浩瀚设备获取任务状态信息响应类
This commit is contained in:
chenlinghy 2020-07-03 16:18:28 +08:00
parent e1eb9e245e
commit 8aa7985824
6 changed files with 151 additions and 6 deletions

View File

@ -0,0 +1,55 @@
package com.dispose.common;
/**
* The enum Device capacity.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
public enum CleanTaskStatus {
/**
* task is cleaning.
*/
CLEANING(1, "清洗中"),
/**
* task is end of cleaning.
*/
ENDOFCLEANING(2, "清洗结束"),
/**
* task is not existed.
*/
NOTASK(3, "该清洗任务不存在"),
/**
* HaoHan device err.
*/
HAOHANERROR(4, "浩瀚设备返回错误"),
/**
* device not support get task status.
*/
DEVNOTSUPPORT(0, "设备不支持获取任务状态");
private final int code;
private final String readme;
CleanTaskStatus(int code, String readme) {
this.code = code;
this.readme = readme;
}
/**
* Gets code.
*
* @return the code
*/
public int getCode() {
return this.code;
}
/**
* Gets readme.
*
* @return the readme
*/
public String getReadme() {
return this.readme;
}
}

View File

@ -1,6 +1,7 @@
package com.dispose.dispose;
import com.dispose.common.CleanTaskStatus;
import com.dispose.common.DeviceCapacity;
import com.dispose.common.ErrorCode;
import com.dispose.dispose.po.DeviceInfo;
@ -93,4 +94,12 @@ public interface DisposeEntryManager {
* @return the device info
*/
DeviceInfo getDeviceInfo();
/**
* Gets device clean task status.
* @param devTaskId device Task Id.
*
* @return the task status
*/
CleanTaskStatus getCleanTaskStatus(Long devTaskId);
}

View File

@ -1,9 +1,6 @@
package com.dispose.dispose.impl;
import com.dispose.common.DeviceCapacity;
import com.dispose.common.DpTechAttackType;
import com.dispose.common.ErrorCode;
import com.dispose.common.GlobalVar;
import com.dispose.common.*;
import com.dispose.config.DisposeConfigure;
import com.dispose.dispose.DisposeEntryManager;
import com.dispose.dispose.po.DeviceInfo;
@ -332,5 +329,16 @@ public class DpTechImpl implements DisposeEntryManager {
return "";
}
}
/**
* Gets device clean task status.
*
* @param devTaskId device Task Id.
* @return the task status
*/
@Override
public CleanTaskStatus getCleanTaskStatus(Long devTaskId) {
return CleanTaskStatus.DEVNOTSUPPORT;
}
}

View File

@ -1,5 +1,6 @@
package com.dispose.dispose.impl;
import com.dispose.common.CleanTaskStatus;
import com.dispose.common.DeviceCapacity;
import com.dispose.common.ErrorCode;
import com.dispose.common.Http;
@ -12,6 +13,7 @@ import com.dispose.pojo.vo.haohan.CleanReq;
import com.dispose.pojo.vo.haohan.CleanRsp;
import com.dispose.pojo.vo.haohan.CommonRsp;
import com.dispose.pojo.vo.haohan.StopCleanReq;
import com.dispose.pojo.vo.haohan.CleanTaskStatusRsp;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
@ -100,7 +102,7 @@ public class HaoHanImpl implements DisposeEntryManager {
log.info("++++Begging Haohan Stop Cleanup Task: {}", devTaskId);
try{
try {
String ret = Http.postJson(deviceAddress + "/delTow",
null,
objectMapper.writeValueAsString(req));
@ -114,7 +116,7 @@ public class HaoHanImpl implements DisposeEntryManager {
log.info("----Finish Haohan Stop Cleanup Task: {}", devTaskId);
return new MulReturnType<>(ErrorCode.ERR_OK, null);
}catch (JsonProcessingException e) {
} catch (JsonProcessingException e) {
log.error("----Error Haohan Stop Cleanup Task: {}", devTaskId);
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, null);
}
@ -236,4 +238,44 @@ public class HaoHanImpl implements DisposeEntryManager {
public String getDetectionDevices() {
return null;
}
/**
* Gets device clean task status.
*
* @param devTaskId device Task Id.
* @return the task status
*/
@Override
public CleanTaskStatus getCleanTaskStatus(Long devTaskId) {
try {
String jsonRequest = String.valueOf(devTaskId);
//"http://10.88.77.88:18080/DDoSClean/clean/getCleanTaskState"
String ret = Http.postJson(deviceAddress + "getCleanTaskState",
null,
jsonRequest);
CleanTaskStatusRsp rsp = objectMapper.readValue(ret, CleanTaskStatusRsp.class);
if (rsp == null) {
log.error("----Error Haohan get task{} status error", devTaskId);
return CleanTaskStatus.HAOHANERROR;
}
if (rsp.getState() == 0) {
if (rsp.getCleanTaskState() == 1) {
log.error("----Get task {}, status {}", devTaskId, rsp.getCleanTaskState());
return CleanTaskStatus.CLEANING;
}
log.error("----Get task {}, status {}", devTaskId, rsp.getCleanTaskState());
return CleanTaskStatus.ENDOFCLEANING;
} else {
log.error("----Get task {}, status {}", devTaskId, rsp.getCleanTaskState());
return CleanTaskStatus.NOTASK;
}
} catch (Exception ex) {
log.error(ex.getMessage());
return CleanTaskStatus.HAOHANERROR;
}
}
}

View File

@ -1,5 +1,6 @@
package com.dispose.dispose.impl;
import com.dispose.common.CleanTaskStatus;
import com.dispose.common.DeviceCapacity;
import com.dispose.common.ErrorCode;
import com.dispose.common.GlobalVar;
@ -170,4 +171,15 @@ public class VirtualDeviceImpl implements DisposeEntryManager {
public String getProtectDevices() {
return "192.168.10.10";
}
/**
* Gets device clean task status.
*
* @param devTaskId device Task Id.
* @return the task status
*/
@Override
public CleanTaskStatus getCleanTaskStatus(Long devTaskId) {
return CleanTaskStatus.DEVNOTSUPPORT;
}
}

View File

@ -0,0 +1,19 @@
package com.dispose.pojo.vo.haohan;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*;
/**
* The type Clean rsp.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CleanTaskStatusRsp extends CommonRsp {
private Long cleanTaskState;
}