TaskManager任务管理工具类

TaskManager任务管理工具类

public class TaskManager {

    public static AbstractTask newTask(TaskContext taskInstance)
            throws IllegalArgumentException {
        switch (taskInstance.getSceneType()) {
            case CPU:
                return new CpuTask(taskInstance);
            case NETWORK:
                return new NetworkTask(taskInstance);
            case DISK:
                return new DiskTask(taskInstance);
            case MYSQL:
                return new DBTask(taskInstance);
            case JVM:
                return new JavaTask(taskInstance);
            case MEM:
                return new MemTask(taskInstance);
            case PROCESS:
                return new ProcessTask(taskInstance);
            case DNS:
                return new DnsTask(taskInstance);
            default:
                throw new IllegalArgumentException("not support task type");
        }

    }
}
posted @ 2020-09-02 10:45  SpecialSpeculator  阅读(244)  评论(0编辑  收藏  举报