Package com.skymobi.monitor.model

Examples of com.skymobi.monitor.model.Task


    @Before
    public void setUp() throws Exception {

        project=new Project();
        task=new Task();
        task.setScript(SCRIPT);

    }
View Full Code Here


    @Test
    public void test_render_task_template() throws Exception {
        project.setLogCollection("flash_dog_log");
        project.setMetricCollection("flash_dog_metrics");
        Task task1 = creator.renderTask(task, project);
        assertEquals(task.getCron(), task1.getCron());
        assertEquals(task.getName(), task1.getName());
        assertEquals(task.getTimeout(), task1.getTimeout());
        assertEquals("   //统计错误日志占比\n" +
                "                            err=db.flash_dog_log.find({'level':'ERROR',timestamp:{$gt:new Date(new Date - 300000)}}).count()\n" +
                "                            total=db.flash_dog_log.find({timestamp:{$gt:new Date(new Date - 300000)}}).count();\n" +
                "                            if(total==0)total=1;\n" +
                "                            value=err*100/total;\n" +
                "                            db.flash_dog_metrics.save({name:'错误日志百分比',value:value,timeStamp:new Date().getTime()});\n" +
                "                            return value;", task1.getScript());

    }
View Full Code Here

     */
    @RequestMapping(value = "/projects/{projectName}/tasks/new", method = RequestMethod.POST)
    public String create(ModelMap map, @PathVariable String projectName, String taskName) {

        Project project = projectService.findProject(projectName);
        Task projectTask = project.findTask(taskName);
        if (projectTask == null) {
            Task task = new Task();
            task.setName(taskName);
            project.saveTask(task);
            projectService.saveProject(project);
        }
        return String.format("redirect:/projects/%s/tasks/%s", projectName, taskName);

View Full Code Here

     * @return
     */
    @RequestMapping(value = "/projects/{projectName}/tasks/{taskName}", method = RequestMethod.GET)
    public String edit(ModelMap map, @PathVariable String projectName, @PathVariable String taskName) throws IOException {
        Project project = projectService.findProject(projectName);
        Task task = project.findTask(taskName);
        map.put("project", project);
        map.put("task", task);
        return "task/edit";
    }
View Full Code Here

    }

    @RequestMapping(value = "/projects/{projectName}/tasks/update", method = RequestMethod.POST)
    public @ResponseBody
    WebResult updateTask(ModelMap map, @PathVariable String projectName, HttpEntity<Task> entity) {
        Task task=entity.getBody();
        logger.debug("update task {}", new Gson().toJson(task));
        projectService.saveTask(projectName, task);

        return new WebResult();
    }
View Full Code Here

        return project;
    }

    public void removeTask(String projectName, String taskName) {
        Project project = findProject(projectName);
        Task task = project.removeTask(taskName);
        saveProject(project);
        taskService.removeScheduled(projectName, task);
    }
View Full Code Here

    public void setInitTasks(List<Task> initTasks) {
        this.initTasks = initTasks;
    }

    public Task renderTask(Task task, Project project) {
        Task task1 = new Task();
        task1.setCron(task.getCron());
        task1.setName(task.getName());
        task1.setTimeout(task.getTimeout());
        String script = task.getScript();
        script = StringUtils.replace(script, "$project.logCollection", project.getLogCollection());
        script = StringUtils.replace(script, "$project.metricCollection", project.getMetricCollection());
        task1.setScript(script);
        return task1;
    }
View Full Code Here

TOP

Related Classes of com.skymobi.monitor.model.Task

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.