OCT
REM: 1. 增加清洗任务状态码 2. 增加获取备任务状态信息接口 3. 增加浩瀚设备获取任务状态信息响应类
This commit is contained in:
parent
e1eb9e245e
commit
8aa7985824
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue