private void ajaxExpireTrigger(final HttpServletRequest req, final Map<String, Object> ret, final User user) throws ServletException, TriggerManagerException { final int triggerId = getIntParam(req, "triggerId"); final Trigger t = this.triggerManager.getTrigger(triggerId); if (t == null) { ret.put("message", "Trigger with ID " + triggerId + " does not exist"); ret.put("status", "error"); return; } this.triggerManager.expireTrigger(triggerId); logger.info("User '" + user.getUserId() + " has removed trigger " + t.getDescription()); ret.put("status", "success"); ret.put("message", "trigger " + triggerId + " removed from Schedules."); return; }
@Override public void insertTrigger(final Trigger t, final String user) throws TriggerManagerException { insertTrigger(t); }
@Override public void removeTrigger(final int id, final String user) throws TriggerManagerException { removeTrigger(id); }
private void loadBuiltinCheckersAndActions() { logger.info("Loading built-in checker and action types"); ExecuteFlowAction.setExecutorManager(this.executorManagerAdapter); ExecuteFlowAction.setProjectManager(this.projectManager); ExecuteFlowAction.setTriggerManager(this.triggerManager); KillExecutionAction.setExecutorManager(this.executorManagerAdapter); CreateTriggerAction.setTriggerManager(this.triggerManager); ExecutionChecker.setExecutorManager(this.executorManagerAdapter); this.triggerManager.registerCheckerType(BasicTimeChecker.type, BasicTimeChecker.class); this.triggerManager.registerCheckerType(SlaChecker.type, SlaChecker.class); this.triggerManager.registerCheckerType(ExecutionChecker.type, ExecutionChecker.class); this.triggerManager.registerActionType(ExecuteFlowAction.type, ExecuteFlowAction.class); this.triggerManager.registerActionType(KillExecutionAction.type, KillExecutionAction.class); this.triggerManager.registerActionType(SlaAlertAction.type, SlaAlertAction.class); this.triggerManager.registerActionType(CreateTriggerAction.type, CreateTriggerAction.class); }
@Before public void setup() throws Exception { final Project project = new Project(1, "test-project"); project.setFlows(ImmutableMap.of("test-flow", new Flow("test-flow"))); when(projectManager.getProject(1)).thenReturn(project); when(executorManagerAdapter.submitExecutableFlow(any(), any())) .thenThrow(new ExecutorManagerException("Flow is already running. Skipping execution.", ExecutorManagerException.Reason.SkippedExecution)); ExecuteFlowAction.setExecutorManager(this.executorManagerAdapter); ExecuteFlowAction.setProjectManager(this.projectManager); ExecuteFlowAction.setTriggerManager(this.triggerManager); final Props props = new Props(); props.put("trigger.scan.interval", 300); this.triggerManager = new TriggerManager(props, triggerLoader, executorManagerAdapter); this.triggerManager.registerCheckerType(ThresholdChecker.type, ThresholdChecker.class); this.triggerManager.registerActionType(DummyTriggerAction.type, DummyTriggerAction.class); this.triggerManager.start(); }
@Ignore @Test public void deadlockTest() throws TriggerLoaderException, TriggerManagerException { // this should well saturate it for (int i = 0; i < 1000; i++) { final Trigger t = createSelfRegenTrigger(); this.loader.addTrigger(t); } // keep going and add more for (int i = 0; i < 10000; i++) { final Trigger d = createDummyTrigger(); this.triggerManager.insertTrigger(d); this.triggerManager.removeTrigger(d); } System.out.println("No dead lock."); }
public void expireTrigger(final int triggerId) { final Trigger t = getTrigger(triggerId); t.setStatus(TriggerStatus.EXPIRED); }
@Override public void updateTrigger(final Trigger t, final String user) throws TriggerManagerException { updateTrigger(t); }
getTriggerManager().start();
@Before public void setup() throws ExecutorManagerException, TriggerManagerException { this.loader = new MockTriggerLoader(); final Props props = new Props(); props.put("trigger.scan.interval", 1000); props.put(ConfigurationKeys.EXECUTOR_PORT, 12321); this.execLoader = new MockExecutorLoader(); this.apiGateway = mock(ExecutorApiGateway.class); this.runningExecutions = new RunningExecutions(); this.updaterStage = new ExecutorManagerUpdaterStage(); this.alertHolder = mock(AlerterHolder.class); this.executionFinalizer = new ExecutionFinalizer(this.execLoader, this.updaterStage, this.alertHolder, this.runningExecutions); this.commonMetrics = new CommonMetrics(new MetricsManager(new MetricRegistry())); final ExecutorManager executorManager = getExecutorManager(props); this.triggerManager = new TriggerManager(props, this.loader, executorManager); }
private void handleJMXPage(final HttpServletRequest req, final HttpServletResponse resp, final Session session) throws IOException { final Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/jmxpage.vm"); page.add("mbeans", this.server.getMbeanNames()); final Map<String, Object> executorMBeans = new HashMap<>(); for (final String hostPort : this.executorManagerAdapter.getAllActiveExecutorServerHosts()) { try { final Map<String, Object> mbeans = this.executorManagerAdapter.callExecutorJMX(hostPort, JMX_GET_MBEANS, null); executorMBeans.put(hostPort, mbeans.get("mbeans")); } catch (final IOException e) { logger.error("Cannot contact executor " + hostPort, e); } } page.add("executorRemoteMBeans", executorMBeans); final Map<String, Object> triggerserverMBeans = new HashMap<>(); triggerserverMBeans.put(this.triggerManager.getJMX().getPrimaryServerHost(), this.triggerManager.getJMX().getAllJMXMbeans()); page.add("triggerserverRemoteMBeans", triggerserverMBeans); page.render(); }
private void loadBuiltinCheckersAndActions() { logger.info("Loading built-in checker and action types"); if(triggerManager instanceof TriggerManager) { SlaChecker.setExecutorManager(executorManager); ExecuteFlowAction.setExecutorManager(executorManager); ExecuteFlowAction.setProjectManager(projectManager); ExecuteFlowAction.setTriggerManager(triggerManager); KillExecutionAction.setExecutorManager(executorManager); SlaAlertAction.setExecutorManager(executorManager); //Map<String, azkaban.alert.Alerter> alerters = loadAlerters(props); SlaAlertAction.setAlerters(alerters); SlaAlertAction.setExecutorManager(executorManager); CreateTriggerAction.setTriggerManager(triggerManager); ExecutionChecker.setExecutorManager(executorManager); } triggerManager.registerCheckerType(BasicTimeChecker.type, BasicTimeChecker.class); triggerManager.registerCheckerType(SlaChecker.type, SlaChecker.class); triggerManager.registerCheckerType(ExecutionChecker.type, ExecutionChecker.class); triggerManager.registerActionType(ExecuteFlowAction.type, ExecuteFlowAction.class); triggerManager.registerActionType(KillExecutionAction.type, KillExecutionAction.class); triggerManager.registerActionType(SlaAlertAction.type, SlaAlertAction.class); triggerManager.registerActionType(CreateTriggerAction.type, CreateTriggerAction.class); }
public void expireTrigger(int triggerId) { Trigger t = getTrigger(triggerId); t.setStatus(TriggerStatus.EXPIRED); // updateAgent(t); }
@Override public void updateTrigger(final Trigger t, final String user) throws TriggerManagerException { updateTrigger(t); }
app.getTriggerManager().start();
private TriggerManager loadTriggerManager(Props props) throws TriggerManagerException { TriggerLoader loader = new JdbcTriggerLoader(props); return new TriggerManager(props, loader, executorManager); }
public void removeTrigger(final int id) throws TriggerManagerException { logger.info("Removing trigger with id: " + id + " from TriggerManager"); synchronized (this.syncObj) { final Trigger t = triggerIdMap.get(id); if (t != null) { removeTrigger(triggerIdMap.get(id)); } } }
@Override public void doAction() throws Exception { triggerManager.insertTrigger(this.trigger); }
private void ajaxExpireTrigger(HttpServletRequest req, Map<String, Object> ret, User user) throws ServletException, TriggerManagerException{ int triggerId = getIntParam(req, "triggerId"); Trigger t = triggerManager.getTrigger(triggerId); if(t == null) { ret.put("message", "Trigger with ID " + triggerId + " does not exist"); ret.put("status", "error"); return; } // if(!hasPermission(project, user, Type.SCHEDULE)) { // ret.put("status", "error"); // ret.put("message", "Permission denied. Cannot remove trigger with id " + triggerId); // return; // } triggerManager.expireTrigger(triggerId); logger.info("User '" + user.getUserId() + " has removed trigger " + t.getDescription()); // projectManager.postProjectEvent(project, EventType.SCHEDULE, user.getUserId(), "Schedule " + sched.toString() + " has been removed."); ret.put("status", "success"); ret.put("message", "trigger " + triggerId + " removed from Schedules."); return; }