Package azkaban.flow

Examples of azkaban.flow.ExecutableFlow


        return baseManager.iterator();
    }

    public ExecutableFlow createNewExecutableFlow(String name)
    {
        final ExecutableFlow retVal = baseManager.createNewExecutableFlow(name);

        return new WrappingExecutableFlow(retVal){
            @Override
            public void execute(Props parentProperties, FlowCallback callback) {
View Full Code Here


        Page page = newPage(req, resp, "azkaban/web/pages/flow_instance.vm");
        final FlowManager allFlows = this.getApplication().getAllFlows();
    
        if (hasParam(req, "job_id")) {
          String jobID = getParam(req, "job_id");
          ExecutableFlow flow = allFlows.createNewExecutableFlow(jobID);
         
          page.add("id", "0");
          page.add("name", jobID);
         
          if (flow == null) {
            addError(req, "Job " + jobID + " not found.");
            page.render();
            return;
          }
         
          // This will be used the other
          Flow displayFlow = new Flow(flow.getName(), (Props)null);
          fillFlow(displayFlow, flow);
          displayFlow.validateFlow();
         
          String flowJSON = createJsonFlow(displayFlow);
          page.add("jsonflow", flowJSON);
          page.add("action", "run");
          page.add("joblist", createJsonJobList(displayFlow));
        }
        else if (hasParam(req, "id")) {
          long id = Long.parseLong(getParam(req, "id"));
             FlowExecutionHolder holder = allFlows.loadExecutableFlow(id);
          ExecutableFlow executableFlow = holder.getFlow();

          // This will be used the other
          Flow displayFlow = new Flow(executableFlow.getName(), (Props)null);
          fillFlow(displayFlow, executableFlow);
          displayFlow.validateFlow();
         
          String flowJSON = createJsonFlow(displayFlow);
          page.add("jsonflow", flowJSON);
          page.add("id", id);
          if (executableFlow.getStartTime() != null) {
            page.add("startTime", executableFlow.getStartTime());
            if (executableFlow.getEndTime() != null) {
                page.add("endTime", executableFlow.getEndTime());
              page.add("period", new Duration(executableFlow.getStartTime(), executableFlow.getEndTime()).toPeriod());
            }
            else {
              page.add("period", new Duration(executableFlow.getStartTime(), new DateTime()).toPeriod());
            }
          }

          page.add("showTimes", true);
          page.add("name", executableFlow.getName());
          page.add("action", "restart");
          page.add("joblist", createJsonJobList(displayFlow));
        }

        page.render();
View Full Code Here

          long id = Long.parseLong(getParam(req, "id"));
             FlowExecutionHolder holder = allFlows.loadExecutableFlow(id);
          //Flows.resetFailedFlows(holder.getFlow());
         
          // Disable all proper values
          ExecutableFlow executableFlow = holder.getFlow();
          traverseFlow(disabledJobs, executableFlow);
         
        PrintWriter writer = resp.getWriter();
        JSONUtils jsonUtils = new JSONUtils();
        HashMap<String,Object> results = new HashMap<String,Object>();
       
          try {
            this.getApplication().getJobExecutorManager().execute(holder);
            results.put("id", holder.getFlow().getId());
            results.put("success", true);
            results.put("message", String.format("Executing Flow[%s].", id));
          } catch(Exception e) {
            results.put("id", holder.getFlow().getId());
            results.put("error", true);
            results.put("message", String.format("Error running Flow[%s]. " + e.getMessage(), id));
          }
         
          writer.print(jsonUtils.toJSONString(results));
          writer.flush();
        }
        else if (action.equals("run")) {
          String name = getParam(req, "name");
          String value = req.getParameter("disabled");
          String[] disabledValues = value.split(",");
          HashSet<String> disabledJobs = new HashSet<String>();
          for (String disabled : disabledValues) {
            if (!disabled.isEmpty()) {
              disabledJobs.add(disabled);
            }
          }
         
             ExecutableFlow flow = allFlows.createNewExecutableFlow(name);
             if (flow == null) {
            addError(req, "Job " + name + " not found.");
             }
             traverseFlow(disabledJobs, flow);
        PrintWriter writer = resp.getWriter();
        JSONUtils jsonUtils = new JSONUtils();
        HashMap<String,Object> results = new HashMap<String,Object>();
       
          try {
            this.getApplication().getJobExecutorManager().execute(flow);
            results.put("success", true);
            results.put("message", String.format("Executing Flow[%s].", name));
            results.put("id", flow.getId());
             
          } catch(Exception e) {
            results.put("error", true);
            results.put("message", String.format("Error running Flow[%s]. " + e.getMessage(), name));
          }
View Full Code Here

        individualJob.setStatus(Status.IGNORED);
        System.out.println("ignore " + name);
      }
      else {
        if (flow instanceof ComposedExecutableFlow) {
            ExecutableFlow innerFlow = ((ComposedExecutableFlow) flow).getDepender();
            traverseFlow(disabledJobs, innerFlow);
        }
        else if (flow instanceof MultipleDependencyExecutableFlow) {
            traverseFlow(disabledJobs, ((MultipleDependencyExecutableFlow) flow).getActualFlow());
        }
View Full Code Here

        final CountDownLatch countDown = new CountDownLatch(jobNames.size());

        for(String jobName: jobNames) {
            try {
                final ExecutableFlow flowToRun = allFlows.createNewExecutableFlow(jobName);

                if (flowToRun == null) {
                    System.out.printf("Job[%s] is unknown.  Not running.%n", jobName);

                    countDown.countDown();
                    continue;
                }
                else {
                    System.out.println("Running " + jobName);
                }

                if (ignoreDeps) {
                    for (ExecutableFlow flow : flowToRun.getChildren()) {
                        flow.markCompleted();
                    }
                }


                flowToRun.execute(
                        overrideProps,
                        new FlowCallback()
                        {
                            @Override
                            public void progressMade()
                            {
                            }

                            @Override
                            public void completed(Status status)
                            {
                                if (status == Status.FAILED) {
                                    System.out.printf("Job failed.%n");
                                    final Map<String, Throwable> exceptions = flowToRun.getExceptions();

                                    if (exceptions == null || exceptions.isEmpty()) {
                                        System.out.println("flowToRun.getExceptions() was null/empty when it should not have been.  Please notify the Azkaban developers.");
                                    }
View Full Code Here

      logger.error("Error cancelling job " + e1);
    }
       
        Collection<ExecutingJobAndInstance> executing = app.getJobExecutorManager().getExecutingJobs();
        for(ExecutingJobAndInstance curr: executing) {
            ExecutableFlow flow = curr.getExecutableFlow();
            final String flowId = flow.getId();
            if(flowId.equals(jobId)) {
                final String flowName = flow.getName();
                try {
                    if(flow.cancel()) {
                        addMessage(req, "Cancelled " + flowName);
                        logger.info("Job '" + flowName + "' cancelled from gui.");
                    } else {
                        logger.info("Couldn't cancel flow '" + flowName + "' for some reason.");
                        addError(req, "Failed to cancel flow " + flowName + ".");
View Full Code Here

     *
     * @param id
     * @param ignoreDep
     */
    public void execute(String id, boolean ignoreDep) {
      final ExecutableFlow flowToRun = allKnownFlows.createNewExecutableFlow(id);

      if (isExecuting(id)) {
        throw new JobExecutionException("Job " + id + " is already running.");
      }
     
        if(ignoreDep) {
            for(ExecutableFlow subFlow: flowToRun.getChildren()) {
                subFlow.markCompleted();
            }
        }
       
        execute(flowToRun);
View Full Code Here

     * Schedule this flow to run one time at the specified date
     *
     * @param holder The execution of the flow to run
     */
    public void execute(FlowExecutionHolder holder) {
        ExecutableFlow flow = holder.getFlow();
       
      if (isExecuting(flow.getName())) {
        throw new JobExecutionException("Job " + flow.getName() + " is already running.");
      }
       
        logger.info("Executing job '" + flow.getName() + "' now");

        final JobExecution executingJob = new JobExecution(flow.getName(),
                                                       new DateTime(),
                                                       true);
        executor.execute(new ExecutingFlowRunnable(holder, executingJob));
    }
View Full Code Here

            this.holder = holder;
            this.runningJob = runningJob;
        }

        public void run() {
            final ExecutableFlow flow = holder.getFlow();
            logger.info("Starting run of " + flow.getName());

            List<String> emailList = null;
            String senderAddress = null;
            try {
                emailList = jobManager.getJobDescriptor(flow.getName()).getEmailNotificationList();
                final List<String> finalEmailList = emailList;

                senderAddress = jobManager.getJobDescriptor(flow.getName()).getSenderEmail();
                final String senderEmail = senderAddress;

                // mark the job as executing
                runningJob.setStartTime(new DateTime());

                executing.put(flow.getName(), new ExecutingJobAndInstance(flow, runningJob));
                flow.execute(holder.getParentProps(), new FlowCallback() {

                    @Override
                    public void progressMade() {
                        allKnownFlows.saveExecutableFlow(holder);
                    }

                    @Override
                    public void completed(Status status) {
                      runningJob.setEndTime(new DateTime());

                        try {
                            allKnownFlows.saveExecutableFlow(holder);
                            switch(status) {
                                case SUCCEEDED:
                                    sendSuccessEmail(runningJob,
                                             runningJob.getExecutionDuration(),
                                                     senderEmail,
                                                     finalEmailList);
                                    break;
                                case FAILED:
                                    sendErrorEmail(runningJob,
                                                   flow.getExceptions(),
                                                   senderEmail,
                                                   finalEmailList);
                                    break;
                                default:
                                    sendErrorEmail(runningJob,
View Full Code Here

        int size = sizeParam == null? 20 : Integer.parseInt(sizeParam);

        List<ExecutableFlow> execs = new ArrayList<ExecutableFlow>(size);
        for (int i = begin; i < begin + size; i++) {
            final FlowExecutionHolder holder = allFlows.loadExecutableFlow(currMaxId - i);
            ExecutableFlow flow = null;
            if (holder != null)
                flow = holder.getFlow();

            if (flow != null)
                execs.add(flow);
View Full Code Here

TOP

Related Classes of azkaban.flow.ExecutableFlow

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.