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

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

Introduction

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

Prototype

@Override
    public boolean equals(Object obj) 

Source Link

Usage

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

/**
 * Uses {@link CountDownLatch} to wait completion status from
 * application master. Status is considered to be complete if either
 * master itself or parent step execution sends complete status.
 *
 * @param masterStepExecution the parent step execution
 *///  w ww .  j a v  a  2 s.  c o m
protected void waitCompleteState(final StepExecution masterStepExecution) {
    final CountDownLatch latch = new CountDownLatch(1);

    // if we get complete for appmaster, bail out
    batchAppmaster.addAppmasterStateListener(new AppmasterStateListener() {
        @Override
        public void state(AppmasterState state) {
            if (log.isDebugEnabled()) {
                log.debug("AppmasterStateListener state: state=" + state);
            }
            if (state == AppmasterState.COMPLETED) {
                latch.countDown();
            }
        }
    });

    batchAppmaster.addPartitionedStepExecutionStateListener(new PartitionedStepExecutionStateListener() {
        @Override
        public void state(PartitionedStepExecutionState state, StepExecution stepExecution) {

            if (log.isDebugEnabled()) {
                log.debug("PartitionedStepExecutionStateListener state: state=" + state + " stepExecution="
                        + stepExecution + " masterStepExecution=" + masterStepExecution);
            }

            if (state == PartitionedStepExecutionState.COMPLETED && masterStepExecution.equals(stepExecution)) {
                if (log.isDebugEnabled()) {
                    log.debug("Got complete state for stepExecution=" + stepExecution);
                }
                latch.countDown();
            }
        }
    });

    try {
        latch.await();
    } catch (Exception e) {
        log.warn("Latch wait interrupted, we may not be finished!");
    }
}

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

/**
 * Uses {@link CountDownLatch} to wait completion status from
 * application master. Status is considered to be complete if either
 * master itself or parent step execution sends complete status.
 *
 * @param masterStepExecution the parent step execution
 */// ww w.j  a  v a  2 s  .  c  o  m
protected void waitCompleteState(final StepExecution masterStepExecution) {
    final CountDownLatch latch = new CountDownLatch(1);

    batchAppmaster.addAppmasterStateListener(new AppmasterStateListener() {
        @Override
        public void state(AppmasterState state) {
            log.info("AppmasterStateListener state=[" + state + "]");
            if (state == AppmasterState.COMPLETED || state == AppmasterState.FAILED) {
                latch.countDown();
            }
        }
    });

    batchAppmaster.addPartitionedStepExecutionStateListener(new PartitionedStepExecutionStateListener() {
        @Override
        public void state(PartitionedStepExecutionState state, StepExecution stepExecution) {
            log.info("PartitionedStepExecutionStateListener state=[" + state + "] stepExecution=["
                    + stepExecution + "] masterStepExecution=[" + masterStepExecution + "]");
            if (state == PartitionedStepExecutionState.COMPLETED && masterStepExecution.equals(stepExecution)) {
                log.info("Got complete state for stepExecution=[" + stepExecution + "]");
                latch.countDown();
            }
        }
    });

    try {
        latch.await();
    } catch (Exception e) {
        log.warn("Latch wait interrupted, we may not be finished!");
    }
    log.info("Waiting latch complete");
}