Search in sources :

Example 1 with StepExecution

use of org.springframework.batch.core.StepExecution in project head by mifos.

the class MifosScheduler method getJobFailDescription.

public String getJobFailDescription(String jobName) {
    String failDescription = null;
    JobExplorer explorer = getBatchJobExplorer();
    List<JobInstance> jobInstances = explorer.getJobInstances(jobName, 0, 1);
    if (jobInstances.size() > 0) {
        List<JobExecution> jobExecutions = explorer.getJobExecutions(jobInstances.get(0));
        if (jobExecutions.size() > 0) {
            Collection<StepExecution> steps = jobExecutions.get(0).getStepExecutions();
            if (steps.size() > 0) {
                StepExecution step = steps.iterator().next();
                if (!step.getExitStatus().getExitDescription().isEmpty()) {
                    failDescription = step.getExitStatus().getExitDescription();
                }
            }
        }
    }
    return failDescription;
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobInstance(org.springframework.batch.core.JobInstance) JobExplorer(org.springframework.batch.core.explore.JobExplorer) StepExecution(org.springframework.batch.core.StepExecution)

Example 2 with StepExecution

use of org.springframework.batch.core.StepExecution in project pinpoint by naver.

the class AlarmReaderTest method readTest3.

@Test
public void readTest3() {
    StepExecution stepExecution = new StepExecution("alarmStep", null);
    ExecutionContext executionContext = new ExecutionContext();
    stepExecution.setExecutionContext(executionContext);
    AlarmServiceImpl alarmService = new AlarmServiceImpl(mock(AlarmDao.class), mock(WebhookSendInfoDao.class)) {

        @Override
        public List<Rule> selectRuleByApplicationId(String applicationId) {
            return new LinkedList<>();
        }
    };
    AlarmReader reader = new AlarmReader(dataCollectorFactory, applicationIndexDao, alarmService);
    reader.beforeStep(stepExecution);
    assertNull(reader.read());
}
Also used : ExecutionContext(org.springframework.batch.item.ExecutionContext) WebhookSendInfoDao(com.navercorp.pinpoint.web.dao.WebhookSendInfoDao) AlarmServiceImpl(com.navercorp.pinpoint.web.service.AlarmServiceImpl) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) StepExecution(org.springframework.batch.core.StepExecution) AlarmDao(com.navercorp.pinpoint.web.dao.AlarmDao) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 3 with StepExecution

use of org.springframework.batch.core.StepExecution in project pinpoint by naver.

the class ReaderTest method readTest2.

@Test
public void readTest2() {
    StepExecution stepExecution = new StepExecution("alarmStep", null);
    ExecutionContext executionContext = new ExecutionContext();
    executionContext.put(AlarmPartitioner.PARTITION_NUMBER, 2);
    stepExecution.setExecutionContext(executionContext);
    AlarmReader reader = new AlarmReader(dataCollectorFactory, applicationIndexDao, alarmService);
    reader.beforeStep(stepExecution);
    for (int i = 0; i < 2; i++) {
        assertNotNull(reader.read());
    }
    assertNull(reader.read());
}
Also used : ExecutionContext(org.springframework.batch.item.ExecutionContext) StepExecution(org.springframework.batch.core.StepExecution) Test(org.junit.Test)

Example 4 with StepExecution

use of org.springframework.batch.core.StepExecution in project pinpoint by naver.

the class ReaderTest method readTest.

@Test
public void readTest() {
    StepExecution stepExecution = new StepExecution("alarmStep", null);
    ExecutionContext executionContext = new ExecutionContext();
    executionContext.put(AlarmPartitioner.PARTITION_NUMBER, 1);
    stepExecution.setExecutionContext(executionContext);
    AlarmReader reader = new AlarmReader(dataCollectorFactory, applicationIndexDao, alarmService);
    reader.beforeStep(stepExecution);
    for (int i = 0; i < 5; i++) {
        assertNotNull(reader.read());
    }
    assertNull(reader.read());
}
Also used : ExecutionContext(org.springframework.batch.item.ExecutionContext) StepExecution(org.springframework.batch.core.StepExecution) Test(org.junit.Test)

Example 5 with StepExecution

use of org.springframework.batch.core.StepExecution in project pinpoint by naver.

the class ReaderTest method readTest3.

@Test
public void readTest3() {
    StepExecution stepExecution = new StepExecution("alarmStep", null);
    ExecutionContext executionContext = new ExecutionContext();
    executionContext.put(AlarmPartitioner.PARTITION_NUMBER, 2);
    stepExecution.setExecutionContext(executionContext);
    AlarmServiceImpl alarmService = new AlarmServiceImpl() {

        @Override
        public java.util.List<Rule> selectRuleByApplicationId(String applicationId) {
            return new LinkedList<Rule>();
        }
    };
    AlarmReader reader = new AlarmReader(dataCollectorFactory, applicationIndexDao, alarmService);
    reader.beforeStep(stepExecution);
    assertNull(reader.read());
}
Also used : ExecutionContext(org.springframework.batch.item.ExecutionContext) AlarmServiceImpl(com.navercorp.pinpoint.web.service.AlarmServiceImpl) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) StepExecution(org.springframework.batch.core.StepExecution) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

StepExecution (org.springframework.batch.core.StepExecution)8 Test (org.junit.Test)7 ExecutionContext (org.springframework.batch.item.ExecutionContext)5 JobExecution (org.springframework.batch.core.JobExecution)3 JobInstance (org.springframework.batch.core.JobInstance)3 JobExplorer (org.springframework.batch.core.explore.JobExplorer)3 Rule (com.navercorp.pinpoint.web.alarm.vo.Rule)2 AlarmServiceImpl (com.navercorp.pinpoint.web.service.AlarmServiceImpl)2 LinkedList (java.util.LinkedList)2 Ignore (org.junit.Ignore)2 AlarmDao (com.navercorp.pinpoint.web.dao.AlarmDao)1 WebhookSendInfoDao (com.navercorp.pinpoint.web.dao.WebhookSendInfoDao)1