SpringBatch中的错误处理

5. 错误处理 5.1 错误处理概述 默认情况下,当任务出现异常时,SpringBatch会结束任务。 当使用相同的参数重启任务时,SpringBatch会...

周二 · 2025-02-25 · 6 分钟 · Yuechen

SpringBatch中的I/O(数据输出)

4. 数据输出 4.1 ItemWriter 概述 ItemReader是一个数据一个数据的读 ItemWriter是一批一批的输出 写个MyWriter:MyWriter.ja...

周二 · 2025-02-25 · 10 分钟 · Yuechen

SpringBatch中的I/O(数据输入)

3. 数据输入 3.1 ItemReader 概述 写个MyReader import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.NonTransientResourceException; import org.springframework.batch.item.ParseException; import org.springframework.batch.item.UnexpectedInputException; import java.util.Iterator; import java.util.List; public class MyReader implements ItemReader<String> { private Iterator<String> iterator; public MyReader(List<String> list) { this.iterator = list.iterator(); } @Override public String read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { // 默认一个一个读数据 if (iterator.hasNext())...

周二 · 2025-02-25 · 8 分钟 · Yuechen

SpringBatch中的作业流

2. 作业流 2.1 Job 的创建和使用 Job:批处理中的核心概念,是 Batch操作的基础单元。每个Job有1个或多个Step。 import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; import org.springframework.batch.core.scope.context.ChunkContext;...

周二 · 2025-02-25 · 5 分钟 · Yuechen

SpringBatch简介

1. 简介 Spring Batch是一个基于Spring框架的批处理框架,它提供了一组完整的API和工具,用于处理大量数据操作,例如读取、处理和写入数据。S...

周二 · 2025-02-25 · 4 分钟 · Yuechen

Design a Log Aggregation System

Implement a Log Aggregation System which aggregates logs from various services in a datacenter and provides search APIs. Design the LogAggregator class: LogAggregator(int machines, int services) Initializes the object with machines and services representing the number of machines and services in the datacenter, respectively. void pushLog(int logId, int machineId, int serviceId, String message) Adds a log with id logId notifying that the machine machineId sent a string message while executing...

周日 · 2025-02-23 · 4 分钟 · Yuechen

Design a Rate Limiting System

A Rate Limiting System can allow a maximum of n requests every t seconds, using an implementation similar to the sliding window algorithm. Given two positive integers n and t, and a non-decreasing stream of integers representing the timestamps of requests, implement a data structure that can check if each request is allowed or not. Implement the RateLimiter class: RateLimiter(int n, int t) Initializes the RateLimiter object with an empty...

周六 · 2025-02-22 · 4 分钟 · Yuechen

Design a Todo List

Design a Todo List Where users can add tasks, mark them as complete, or get a list of pending tasks. Users can also add tags to tasks and can filter the tasks by certain tags. Implement the TodoList class: TodoList() Initializes the object. int addTask(int userId, String taskDescription, int dueDate, List<String> tags) Adds a task for the user with the ID userId with a due date equal to dueDate and...

周日 · 2025-02-16 · 4 分钟 · Yuechen