Search in sources :

Example 11 with ExecutionContext

use of org.springframework.batch.item.ExecutionContext 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)

Example 12 with ExecutionContext

use of org.springframework.batch.item.ExecutionContext in project pinpoint by naver.

the class AlarmPartitioner method partition.

@Override
public Map<String, ExecutionContext> partition(int gridSize) {
    int partitionCount = calculateGroupCount();
    Map<String, ExecutionContext> mapContext = new HashMap<>();
    for (int i = 1; i <= partitionCount; i++) {
        ExecutionContext executionContext = new ExecutionContext();
        executionContext.put(PARTITION_NUMBER, i);
        mapContext.put(PARTITION_NUMBER + "_" + i, executionContext);
    }
    return mapContext;
}
Also used : ExecutionContext(org.springframework.batch.item.ExecutionContext) HashMap(java.util.HashMap)

Example 13 with ExecutionContext

use of org.springframework.batch.item.ExecutionContext in project RecordManager2 by moravianlibrary.

the class DateIntervalPartitionerTest method test.

@Test
public void test() {
    Date from = OAIGranularity.stringToDate("2010-06-30T01:20:00Z");
    Date to = OAIGranularity.stringToDate("2012-09-30T01:20");
    DateIntervalPartitioner interval = new DateIntervalPartitioner(from, to, Period.months(1), "to", "from");
    Map<String, ExecutionContext> intervals = interval.partition(0);
    Assert.assertEquals(intervals.size(), 28);
}
Also used : ExecutionContext(org.springframework.batch.item.ExecutionContext) Date(java.util.Date) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 14 with ExecutionContext

use of org.springframework.batch.item.ExecutionContext in project tutorials by eugenp.

the class LinesWriter method beforeStep.

@Override
public void beforeStep(StepExecution stepExecution) {
    ExecutionContext executionContext = stepExecution.getJobExecution().getExecutionContext();
    this.lines = (List<Line>) executionContext.get("lines");
    fu = new FileUtils("output.csv");
    logger.debug("Lines Writer initialized.");
}
Also used : Line(org.baeldung.taskletsvschunks.model.Line) ExecutionContext(org.springframework.batch.item.ExecutionContext) FileUtils(org.baeldung.taskletsvschunks.utils.FileUtils)

Example 15 with ExecutionContext

use of org.springframework.batch.item.ExecutionContext in project pinpoint by naver.

the class AlarmReaderTest method readTest.

@Test
public void readTest() {
    StepExecution stepExecution = new StepExecution("alarmStep", null);
    ExecutionContext executionContext = new ExecutionContext();
    stepExecution.setExecutionContext(executionContext);
    AlarmReader reader = new AlarmReader(dataCollectorFactory, applicationIndexDao, alarmService);
    reader.beforeStep(stepExecution);
    for (int i = 0; i < 7; 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)

Aggregations

ExecutionContext (org.springframework.batch.item.ExecutionContext)17 Test (org.junit.Test)6 StepExecution (org.springframework.batch.core.StepExecution)5 HashMap (java.util.HashMap)4 Rule (com.navercorp.pinpoint.web.alarm.vo.Rule)2 AlarmServiceImpl (com.navercorp.pinpoint.web.service.AlarmServiceImpl)2 LinkedList (java.util.LinkedList)2 Line (org.baeldung.taskletsvschunks.model.Line)2 Resource (org.springframework.core.io.Resource)2 DefaultDivider (com.navercorp.pinpoint.batch.common.DefaultDivider)1 AlarmDao (com.navercorp.pinpoint.web.dao.AlarmDao)1 WebhookSendInfoDao (com.navercorp.pinpoint.web.dao.WebhookSendInfoDao)1 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)1 LongValueRowMapper (cz.mzk.recordmanager.server.jdbc.LongValueRowMapper)1 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)1 CloserUtil (htsjdk.samtools.util.CloserUtil)1 IOUtil (htsjdk.samtools.util.IOUtil)1 StringUtil (htsjdk.samtools.util.StringUtil)1 SAMSequenceDictionaryExtractor (htsjdk.variant.utils.SAMSequenceDictionaryExtractor)1 VariantContext (htsjdk.variant.variantcontext.VariantContext)1