/** * Returns the cached recent messages history. * * @return * @throws IOException */ private History getHistory() throws IOException { synchronized (historyID) { HistoryService historyService = MessageHistoryActivator.getMessageHistoryService().getHistoryService(); if (history == null) { history = historyService.createHistory(historyID, recordStructure); // lets check the version if not our version, re-create // history (delete it) HistoryReader reader = history.getReader(); boolean delete = false; QueryResultSet<HistoryRecord> res = reader.findLast(1); if (res != null && res.hasNext()) { HistoryRecord hr = res.next(); if (hr.getPropertyValues().length >= 4) { if (!hr.getPropertyValues()[3].equals(RECENT_MSGS_VER)) delete = true; } else delete = true; } if (delete) { // delete it try { historyService.purgeLocallyStoredHistory(historyID); history = historyService.createHistory(historyID, recordStructure); } catch (IOException ex) { logger.error("Cannot delete recent_messages history", ex); } } } return history; } }
/** * @param processInstanceId * @return */ @Override public List<HistoricTaskInstance> createHistoricTaskInstanceQuery(String processInstanceId) { return historyService .createHistoricTaskInstanceQuery() .processInstanceId(processInstanceId) .list(); }
/** * 个人任务首页 * * @return */ @RequestMapping("/index.do") public String index(HttpServletRequest request, HttpServletResponse response, Model model) { User user = request.getSession(true).getAttribute("user") == null ? null : (User) request.getSession(true).getAttribute("user"); List<Group> groups = request.getSession(true).getAttribute("groups") == null ? null : (List<Group>) request.getSession(true).getAttribute("groups"); if (null == user) { return "redirect:/simple/login.do"; } else { model.addAttribute("user", user); model.addAttribute("groups", groups); /** */ List<ProcessDefinition> pdList = repositoryService.createProcessDefinitionQuery().list(); model.addAttribute("pdList", pdList); /** 该用户所有可以认领的任务 */ List<Task> groupTasks = taskService.createTaskQuery().taskCandidateUser(user.getId()).list(); List<Task> userTasks = taskService.createTaskQuery().taskAssignee(user.getId()).list(); model.addAttribute("userTasks", userTasks); model.addAttribute("groupTasks", groupTasks); /** 查看任务实例 */ List<Task> taskList = taskService.createTaskQuery().list(); model.addAttribute("taskList", taskList); /** 历史流程 */ List<HistoricProcessInstance> hpiList = historyService.createHistoricProcessInstanceQuery().finished().list(); model.addAttribute("hpiList", hpiList); } return "/simple/index"; }
@Test public void testRedirect() throws Exception { Configuration conf = new YarnConfiguration(); conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME); conf.set(YarnConfiguration.RM_ADDRESS, RMADDRESS); conf.set(JHAdminConfig.MR_HISTORY_ADDRESS, HSHOSTADDRESS); // Start the RM. RMService rmService = new RMService("test"); rmService.init(conf); rmService.start(); // Start the AM. AMService amService = new AMService(); amService.init(conf); amService.start(conf); // Start the HS. HistoryService historyService = new HistoryService(); historyService.init(conf); historyService.start(conf); LOG.info("services started"); Cluster cluster = new Cluster(conf); org.apache.hadoop.mapreduce.JobID jobID = new org.apache.hadoop.mapred.JobID("201103121733", 1); org.apache.hadoop.mapreduce.Counters counters = cluster.getJob(jobID).getCounters(); validateCounters(counters); Assert.assertTrue(amContact); LOG.info( "Sleeping for 5 seconds before stop for" + " the client socket to not get EOF immediately.."); Thread.sleep(5000); // bring down the AM service amService.stop(); LOG.info("Sleeping for 5 seconds after stop for" + " the server to exit cleanly.."); Thread.sleep(5000); amRestarting = true; // Same client // results are returned from fake (not started job) counters = cluster.getJob(jobID).getCounters(); Assert.assertEquals(0, counters.countCounters()); Job job = cluster.getJob(jobID); org.apache.hadoop.mapreduce.TaskID taskId = new org.apache.hadoop.mapreduce.TaskID(jobID, TaskType.MAP, 0); TaskAttemptID tId = new TaskAttemptID(taskId, 0); // invoke all methods to check that no exception is thrown job.killJob(); job.killTask(tId); job.failTask(tId); job.getTaskCompletionEvents(0, 100); job.getStatus(); job.getTaskDiagnostics(tId); job.getTaskReports(TaskType.MAP); job.getTrackingURL(); amRestarting = false; amService = new AMService(); amService.init(conf); amService.start(conf); amContact = false; // reset counters = cluster.getJob(jobID).getCounters(); validateCounters(counters); Assert.assertTrue(amContact); // Stop the AM. It is not even restarting. So it should be treated as // completed. amService.stop(); // Same client counters = cluster.getJob(jobID).getCounters(); validateCounters(counters); Assert.assertTrue(hsContact); rmService.stop(); historyService.stop(); }