Example usage for org.springframework.batch.core StepExecution getJobParameters

List of usage examples for org.springframework.batch.core StepExecution getJobParameters

Introduction

In this page you can find the example usage for org.springframework.batch.core StepExecution getJobParameters.

Prototype

public JobParameters getJobParameters() 

Source Link

Document

Convenience method to get the current job parameters.

Usage

From source file:org.springframework.yarn.batch.partition.AbstractBatchPartitionHandler.java

@Override
public final Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
        throws Exception {

    if (log.isDebugEnabled()) {
        log.debug("partition job parameters:");
        for (Entry<String, JobParameter> entry : stepExecution.getJobParameters().getParameters().entrySet()) {
            log.debug("entry: " + entry.getKey() + " / " + entry.getValue());
        }/*from   w w  w .  j a  v a 2 s.  co m*/
    }

    Collection<StepExecution> result = new ArrayList<StepExecution>();

    Set<StepExecution> split = createStepExecutionSplits(stepSplitter, stepExecution);

    if (log.isDebugEnabled()) {
        log.debug("Created " + split.size() + " splits for stepName=" + stepName + " with parent stepExecution="
                + stepExecution);
        for (StepExecution execution : split) {
            log.debug("Splitted step execution: " + execution + " with executionContext="
                    + execution.getExecutionContext());
        }
    }

    Map<StepExecution, ContainerRequestHint> resourceRequests = createResourceRequestData(split);

    if (log.isDebugEnabled()) {
        log.debug("Resource request map size is " + resourceRequests.size());
        for (Entry<StepExecution, ContainerRequestHint> entry : resourceRequests.entrySet()) {
            log.debug("Entry stepExecution=" + entry.getKey() + " requestData=" + entry.getValue());
        }
    }

    batchAppmaster.addStepSplits(stepExecution, stepName, split, resourceRequests);

    waitCompleteState(stepExecution);

    result.addAll(batchAppmaster.getStepExecutions());
    if (log.isDebugEnabled()) {
        log.debug("Statuses of remote execution ");
        for (StepExecution execution : result) {
            log.debug("Remote step execution: " + execution);
        }
    }

    return result;
}

From source file:org.springframework.yarn.batch.partition.AbstractPartitionHandler.java

@Override
public final Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
        throws Exception {
    log.info("Handling stepExecution=[" + stepExecution + "] with jobParameters=["
            + stepExecution.getJobParameters() + "]");

    Set<StepExecution> split = createSplits(stepSplitter, stepExecution);
    log.info("Created " + split.size() + " splits for stepName=" + stepName);

    Map<StepExecution, ContainerRequestHint> resourceRequests = createRequestData(split);
    log.info("Resource request map size is " + resourceRequests.size());
    if (log.isDebugEnabled()) {
        for (Entry<StepExecution, ContainerRequestHint> entry : resourceRequests.entrySet()) {
            log.debug("Entry stepExecution=[" + entry.getKey() + "] requestData=[" + entry.getValue() + "]");
        }//from  w  ww.j a  v a2 s .c  o m
    }

    batchAppmaster.addStepSplits(stepExecution, stepName, split, resourceRequests);
    waitCompleteState(stepExecution);
    Collection<StepExecution> result = new ArrayList<StepExecution>(batchAppmaster.getStepExecutions());

    result.addAll(batchAppmaster.getStepExecutions());
    log.info("Listing statuses of remote executions");
    for (StepExecution execution : result) {
        log.info("Remote stepExecution=[" + execution + "]");
    }
    return result;
}

From source file:org.springframework.yarn.batch.partition.HdfsSplitBatchPartitionHandler.java

@Override
protected Set<StepExecution> createStepExecutionSplits(StepExecutionSplitter stepSplitter,
        StepExecution stepExecution) throws Exception {

    String input = stepExecution.getJobParameters().getString("input");
    log.info("Input is " + input);

    FileSystem fs = FileSystem.get(configuration);
    Path path = new Path(input);
    FileStatus[] fileStatuses = fs.globStatus(path);

    Set<StepExecution> split = stepSplitter.split(stepExecution, fileStatuses.length);
    return split;
}

From source file:uk.ac.ebi.intact.dataexchange.dbimporter.listener.MailNotifierStepExecutionListener.java

public void beforeStep(StepExecution stepExecution) {

    SimpleMailMessage message = newSimpleMessage();
    message.setSubject("[IntAct_import] Started step: " + stepExecution.getStepName() + "");
    message.setText(stepExecution.getSummary() + "\n" + stepExecution.getJobExecution());
    message.setTo(stepExecution.getJobParameters().getString("email.recipient"));

    //        try{
    //            mailSender.send(message);
    //        }//  w w w.  j  av  a2 s  .  c o  m
    //        catch (MailException e){
    //            log.error("Impossible to send e-mail", e);
    //        }
}

From source file:uk.ac.ebi.intact.dataexchange.dbimporter.listener.MailNotifierStepExecutionListener.java

public ExitStatus afterStep(StepExecution stepExecution) {

    SimpleMailMessage message = newSimpleMessage();
    message.setSubject("[IntAct_import] Finished step: " + stepExecution.getStepName() + " Exit status: "
            + stepExecution.getExitStatus().getExitCode());
    message.setText(stepExecution.toString() + "\n" + stepExecution.getExecutionContext());
    message.setText(stepExecution.toString() + "\n" + stepExecution.getSummary() + "\n"
            + stepExecution.getJobExecution());
    message.setTo(stepExecution.getJobParameters().getString("email.recipient"));

    //        try{
    //            mailSender.send(message);
    //        }/*w  w  w  .  j av  a2 s  . c  o  m*/
    //        catch (MailException e){
    //            log.error("Impossible to send e-mail", e);
    //        }

    return stepExecution.getExitStatus();
}