Changeset 7317


Ignore:
Timestamp:
Apr 3, 2017, 1:44:30 PM (6 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2071: Restart a job from the beginning if it has already been restarted in the middle

It is now possible to select if a job should be restarted from the beginning or from the stored breakpoint.

Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/Job.java

    r7270 r7317  
    10141014
    10151015  /**
     1016    The command to send to the plug-in when starting to
     1017    execute it. If null, a default values is used. See
     1018    Request.COMMAND_EXECUTE. This is usually only used when
     1019    automatically restarting a failed job.
     1020    @since 3.11
     1021  */
     1022  public String getExecuteCommand()
     1023  {
     1024    return getData().getExecuteCommand();
     1025  }
     1026 
     1027  /**
     1028    Reset th currently stored execution command to force a
     1029    plug-in to restart from the beginning instead of at the
     1030    stored breakpoint.
     1031    @since 3.11
     1032  */
     1033  public void clearExecuteCommand()
     1034  {
     1035    checkPermission(Permission.WRITE);
     1036    getData().setExecuteCommand(null);
     1037  }
     1038 
     1039  /**
    10161040    Set the job's status to {@link Status#WAITING}. This status is
    10171041    used to signal that a job has been fully configured and is ready
  • trunk/www/common/plugin/finish_job.jsp

    r6200 r7317  
    117117      </tr>
    118118      <%
     119      if (job.getExecuteCommand() != null)
     120      {
     121        %>
     122        <tr>
     123          <th class="subprompt"></th>
     124          <td>
     125            <input type="checkbox" name="resume_from_breakpoint" id="resumeFromBreakPoint" value="1">
     126            <label for="resumeFromBreakPoint">Resume from breakpoint: <%=HTML.encodeTags(job.getExecuteCommand()) %></label>
     127          </td>
     128        </tr>
     129        <%
     130      }
     131      %>
     132      <%
    119133      if (agents != null && agents.size() > 0)
    120134      {
  • trunk/www/common/plugin/index.jsp

    r6319 r7317  
    559559    job.setSendMessage(Values.getBoolean(request.getParameter("send_message")));
    560560    job.setRemoveJobWhenFinished(Values.getBoolean(request.getParameter("remove_job")));
    561    
     561    if (!Values.getBoolean(request.getParameter("resume_from_breakpoint")))
     562    {
     563      job.clearExecuteCommand();
     564    }
    562565    if (!executeImmediately)
    563566    {
  • trunk/www/views/jobs/index.jsp

    r7307 r7317  
    308308    boolean useLatestConfiguration = Values.getBoolean(request.getParameter("useLatestConfiguration"), false);
    309309    boolean clearDryRun = Values.getBoolean(request.getParameter("clearDryRun"), false);
     310    boolean resumeFromBreakPoint = Values.getBoolean(request.getParameter("resumeFromBreakPoint"), false);
    310311    dc = sc.newDbControl();
    311312    Job job = Job.getById(dc, cc.getId());
     313    if (!resumeFromBreakPoint) job.clearExecuteCommand();
    312314    job.retry(useLatestConfiguration, clearDryRun);
    313315    dc.commit();
  • trunk/www/views/jobs/jobs.js

    r7270 r7317  
    122122
    123123 
    124   jobs.restartJob = function(event)
     124  jobs.restartJob = function(event, options)
    125125  {
    126126    var parameterVersion = Data.int('page-data', 'job-parameter-version');
    127127    var latestVersion = Data.int('page-data', 'latest-parameter-version');
    128     var jobId = Data.get('page-data', 'item-id');
    129     var clearDryRun = Data.int(event.currentTarget, 'clear-dry-run', 0);
     128    var breakPoint = Data.get('page-data', 'breakpoint');
     129    var jobId = Data.get('page-data', 'item-id');
     130    var clearDryRun = event ? Data.int(event.currentTarget, 'clear-dry-run', 0) : 0;
    130131   
    131132    var useLatestConfiguration = 0;
    132     if (parameterVersion != latestVersion)
    133     {
    134       var msg = 'The configuration parameters for the plugin has changed since\n';
    135       msg += 'the job was added to the job queue. Do you want to use the new\n';
    136       msg += 'configuration parameters?\n\n';
    137       msg += 'Ok / Yes = Use the new parameters (version = '+latestVersion + ')\n';
    138       msg += 'Cancel / No = Use the current parameters (version = ' + parameterVersion + ')';
    139       if (confirm(msg))
    140       {
    141         useLatestConfiguration = 1;
     133    var resumeFromBreakPoint = 0;
     134    if (parameterVersion != latestVersion || breakPoint)
     135    {
     136      if (!options)
     137      {
     138        var url = 'restart_job_options.jsp?';
     139        Dialogs.openPopup(url, 'RestartJobOptions', 500, 300);
     140        return;
     141      }
     142      else
     143      {
     144        useLatestConfiguration = options.useLatestConfiguration || 0;
     145        resumeFromBreakPoint = options.resumeFromBreakPoint || 0;
    142146      }
    143147    }
     
    145149    url += '&cmd=RestartJob&item_id='+jobId;
    146150    url += '&useLatestConfiguration='+useLatestConfiguration;
     151    url += '&resumeFromBreakPoint='+resumeFromBreakPoint;
    147152    if (clearDryRun) url += '&clearDryRun=' + clearDryRun;
    148153    location.replace(url);
  • trunk/www/views/jobs/view_job.jsp

    r7307 r7317  
    227227      data-job-parameter-version="<%=parameterVersion %>"
    228228      data-latest-parameter-version="<%=latestParameterVersion %>"
     229      data-breakpoint="<%=HTML.encodeTags(job.getExecuteCommand()) %>"
    229230      data-job-status="<%=status.name()%>"
    230231      data-auto-update="<%=autoUpdate ? 1 : 0 %>"
     
    317318          <div class="<%=job.getStatus() == Job.Status.ERROR ? "error messagecontainer" : ""%>" style="margin: 1px 0px;">
    318319          <%=job.getStatus()%><%=job.isDryRun() ? " (dry-run)" : "" %>:
    319           <span id="message" ><%=HTML.niceFormat(job.getStatusMessage())%></span>
     320          <span id="message">
     321            <%=job.getStatus() == Job.Status.WAITING && job.getExecuteCommand() != null ?
     322              "(Resume from " + job.getExecuteCommand() + ")" : ""%>
     323            <%=HTML.niceFormat(job.getStatusMessage())%></span>
    320324          </div>
    321325        </td>
Note: See TracChangeset for help on using the changeset viewer.