Package azkaban.flow

Examples of azkaban.flow.FlowManager


  @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
            IOException {
        resp.setContentType("application/xhtml+xml");
        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);
View Full Code Here


    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        resp.setContentType("application/json");

        final FlowManager allFlows = this.getApplication().getAllFlows();
        String action = getParam(req, "action");
       
        if (action.equals("restart")) {
          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);
            }
          }
         
          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();
View Full Code Here

        final ExecutableFlowDeserializer flowDeserializer = new DefaultExecutableFlowDeserializer(jobManager, factory);
        FlowExecutionSerializer flowExecutionSerializer = new FlowExecutionSerializer(flowSerializer);
        FlowExecutionDeserializer flowExecutionDeserializer = new FlowExecutionDeserializer(flowDeserializer);


        FlowManager allFlows = new RefreshableFlowManager(jobManager,
                                                          flowExecutionSerializer,
                                                          flowExecutionDeserializer,
                                                          executionsStorageFile,
                                                          lastId);
        jobManager.setFlowManager(allFlows);

        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();
View Full Code Here

    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
            IOException {
        final FlowManager allFlows = this.getApplication().getAllFlows();

        /* set runtime properties from request and response*/
        super.setRuntimeProperties (req, resp);
       
        if (hasParam(req, "action")) {
            if ("restart".equals(getParam(req, "action")) && hasParam(req, "id")) {
                try {
                    long id = Long.parseLong(getParam(req, "id"));

                    final FlowExecutionHolder holder = allFlows.loadExecutableFlow(id);

                    if (holder == null) {
                        addMessage(req, String.format("Unknown flow with id[%s]", id));
                    }
                    else {
                        Flows.resetFailedFlows(holder.getFlow());
                        this.getApplication().getJobExecutorManager().execute(holder);

                        addMessage(req, String.format("Flow[%s] restarted.", id));
                    }
                }
                catch (NumberFormatException e) {
                    addMessage(req, String.format("Apparently [%s] is not a valid long.", getParam(req, "id")));
                }
                catch (JobExecutionException e) {
                  addMessage(req, "Error restarting " + getParam(req, "id") + ". " + e.getMessage());
                }
            }
        }

        long currMaxId = allFlows.getCurrMaxId();

        String beginParam = req.getParameter("begin");
        int begin = beginParam == null? 0 : Integer.parseInt(beginParam);
       
        String sizeParam = req.getParameter("size");
        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)
View Full Code Here

TOP

Related Classes of azkaban.flow.FlowManager

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.