class MachineExamTask extends BaseTask {

    private List<String> machineIpList;
    private Integer useType;
    private List<MachineStats> machineStatsList = Lists.newArrayList();
    private Map<String, Integer> machineInstanceCountMap = Maps.newHashMap();
    private List<Map> examResult = Lists.newArrayList();


    @Override
    public List<String> getTaskSteps() {<FILL_FUNCTION_BODY>}

    @Override
    public TaskStepFlowEnum.TaskFlowStatusEnum init() {
        super.init();
        useType = MapUtils.getInteger(paramMap, TaskConstants.USE_TYPE_KEY, null);
        machineIpList = (List) MapUtils.getObject(paramMap, TaskConstants.MACHINE_IP_LIST_KEY);
        return TaskStepFlowEnum.TaskFlowStatusEnum.SUCCESS;
    }

    /**
     * 1. 准备任务参数
     *
     * @return
     */
    public TaskFlowStatusEnum prepareAppParam() {
        for (String ip : machineIpList) {
            List<MachineStats> list = machineCenter.getMachineStats(ip, useType, null,null, null, -1, null);
            machineStatsList.addAll(list);
        }
        machineInstanceCountMap = machineCenter.getMachineInstanceCountMap();
        if (machineStatsList.isEmpty() || machineInstanceCountMap.isEmpty()) {
            return TaskFlowStatusEnum.ABORT;
        }
        return TaskFlowStatusEnum.SUCCESS;
    }

    /**
     * 2. 执行机器故障检查
     *
     * @return
     */
    public TaskFlowStatusEnum executeMachineExam() {
        for (MachineStats machineStats : machineStatsList) {
            String ip = machineStats.getIp();
            double mem = (double) machineStats.getInfo().getMem();//G
            double usedMem = machineStats.getMachineMemInfo().getUsedMemRss() / 1024 / 1024 / 1024;//byte
            double applyMem = (double) machineStats.getMachineMemInfo().getApplyMem() / 1024 / 1024 / 1024;//byte
            double usedMemRatio = usedMem / mem;
            double applyMemRatio = applyMem / mem;

            int cpu = machineStats.getInfo().getCpu();
            int usedCpu = machineInstanceCountMap.get(ip);
            double usedCpuRatio = (double) usedCpu / cpu;

            if (judgeMemUsed(usedMemRatio, mem) || judgeMemUsed(applyMemRatio, mem) || judgeCpuUsed(usedCpuRatio)) {
                examResult.add(
                        new HashMap<String, String>() {{
                            put(MachineExamContants.MACHINE_IP, ip);
                            put(MachineExamContants.MEM, String.valueOf(mem));
                            put(MachineExamContants.APPLY_MEM, String.valueOf(applyMem));
                            put(MachineExamContants.APPLY_MEM_RATIO, String.valueOf(applyMemRatio));
                            put(MachineExamContants.USED_MEM, String.valueOf(usedMem));
                            put(MachineExamContants.USED_MEM_RATIO, String.valueOf(usedMemRatio));
                            put(MachineExamContants.CPU, String.valueOf(cpu));
                            put(MachineExamContants.USED_CPU, String.valueOf(usedCpu));
                            put(MachineExamContants.USED_CPU_RATIO, String.valueOf(usedCpuRatio));
                        }}
                );
            }
        }
        return TaskFlowStatusEnum.SUCCESS;
    }


    /**
     * 3. 检查结果展示
     *
     * @return
     */
    public TaskFlowStatusEnum showMachineExamResult() {
        return TaskFlowStatusEnum.SUCCESS;
    }

    private boolean judgeMemUsed(double ratio, double mem) {
        if (mem > 20 && ratio > MachineExamContants.defult_memUseThreshold) {
            return true;
        } else if (mem > 10 && mem <= 20 && ratio > MachineExamContants.middle_memUseThreshold) {
            return true;
        } else if (mem <= 10 && ratio > MachineExamContants.small_memUseThreshold) {
            return true;
        }
        return false;
    }

    private boolean judgeCpuUsed(double ratio) {
        if (ratio >= MachineExamContants.BASE_RATIO) {
            return true;
        }
        return false;
    }
}

        List<String> taskStepList = new ArrayList<String>();
        taskStepList.add(TaskConstants.INIT_METHOD_KEY);
        // 1. 准备任务参数
        taskStepList.add("prepareAppParam");
        // 2. 执行机器故障检查
        taskStepList.add("executeMachineExam");
        // 3. 检查结果展示
        taskStepList.add("showMachineExamResult");
        return taskStepList;
    
<methods>public non-sealed void <init>() ,public static java.lang.String generateMasterName(java.lang.String, int) ,public Map<java.lang.String,java.lang.Object> getParamMap() ,public abstract List<java.lang.String> getTaskSteps() ,public com.sohu.cache.task.constant.TaskStepFlowEnum.TaskFlowStatusEnum init() ,public void setParamMap(Map<java.lang.String,java.lang.Object>) <variables>public static final java.lang.String MARKER_NAME,private static final java.lang.String NUT_CRACKER_TEMPLATE_FILE,private static final java.lang.String NUT_CRACKER_TEMPLATE_NO_CPUIDX_FILE,private static final java.lang.String PIKA_TEMPLATE_FILE,private static final java.lang.String REDIS_COMMON_TEMPLATE_FILE,private static final java.lang.String REDIS_COMMON_TEMPLATE_NO_CPUIDX_FILE,private static final java.lang.String REDIS_MIGRATE_TOOL_TEMPLATE_FILE,private static final java.lang.String REDIS_PORT_TEMPLATE_FILE,protected com.sohu.cache.dao.AppAuditDao appAuditDao,protected com.sohu.cache.dao.AppDao appDao,protected com.sohu.cache.web.util.AppEmailUtil appEmailUtil,protected java.lang.String appEnvName,protected com.sohu.cache.web.service.AppService appService,protected com.sohu.cache.stats.app.AppStatsCenter appStatsCenter,protected com.sohu.cache.task.util.AppWechatUtil appWechatUtil,protected com.sohu.cache.redis.AssistRedisService assistRedisService,protected com.sohu.cache.dao.DiagnosticTaskRecordDao diagnosticTaskRecordDao,protected org.springframework.core.env.Environment environment,protected com.sohu.cache.dao.InstanceBigKeyDao instanceBigKeyDao,protected com.sohu.cache.dao.InstanceDao instanceDao,protected com.sohu.cache.stats.instance.InstanceDeployCenter instanceDeployCenter,protected com.sohu.cache.web.service.InstancePortService instancePortService,protected com.sohu.cache.dao.InstanceStatsDao instanceStatsDao,protected org.slf4j.Logger logger,protected com.sohu.cache.machine.MachineCenter machineCenter,protected com.sohu.cache.dao.MachineDao machineDao,protected com.sohu.cache.dao.MachineRelationDao machineRelationDao,protected com.sohu.cache.dao.MachineRoomDao machineRoomDao,protected com.sohu.cache.dao.MachineStatsDao machineStatsDao,public static final org.slf4j.Marker marker,protected com.sohu.cache.web.service.ModuleService moduleService,protected Map<java.lang.String,java.lang.Object> paramMap,protected com.sohu.cache.redis.RedisCenter redisCenter,protected com.sohu.cache.redis.RedisConfigTemplateService redisConfigTemplateService,protected com.sohu.cache.redis.RedisDeployCenter redisDeployCenter,protected com.sohu.cache.dao.ResourceDao resourceDao,protected com.sohu.cache.web.service.ResourceService resourceService,protected com.sohu.cache.ssh.SSHService sshService,protected long taskId,protected com.sohu.cache.task.TaskService taskService