Moved chunks to a branch (called chunks)
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>A 'chunk' of items, that will be committed together. It is expected that a
|
||||
* chunk may be serialized, especially if using a queue to dispatch chunks to
|
||||
* various {@link ChunkProcessor}s.</p>
|
||||
*
|
||||
* <p>A note on serialization: A chunk is only as serializable as as the items
|
||||
* it contains, and no validation is performed to ensure they are serialiable.
|
||||
* Therefore, it is expected that constructors of this class will ensure this
|
||||
* condition if they intend to use the chunk in such a way that will require
|
||||
* serialization.</p>
|
||||
*
|
||||
* @author Ben Hale
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public class Chunk implements Serializable {
|
||||
|
||||
private final Long id;
|
||||
|
||||
private final List items;
|
||||
|
||||
public Chunk(Long id, List items) {
|
||||
this.items = items;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of items for this chunk.
|
||||
*
|
||||
* @return items.
|
||||
*/
|
||||
public List getItems() {
|
||||
return new ArrayList(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the chunk id.
|
||||
*
|
||||
* @return id of this chunk.
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.io.exception.ReadFailureException;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
|
||||
|
||||
/**
|
||||
* Interface defining the contract for reading a chunk. This is most useful when
|
||||
* implementing a 'chunk-oriented' approach to processing. Implementors of this
|
||||
* class are expected to aggregate the output of an ItemReader into 'chunks'.
|
||||
*
|
||||
* @author Ben Hale
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public interface Chunker extends ItemStream {
|
||||
|
||||
/**
|
||||
* Read in a chunk, given the provided chunk size for the given StepExecution.
|
||||
*
|
||||
* @param chunkSize the number of items that should be read for this chunk.
|
||||
* @param StepExecution the stepExecution the current chunk is being processed within.
|
||||
* @return the {@link Chunk} that has been read.
|
||||
* @throws IllegalArgumentException if chunkSize is less than zero.
|
||||
*/
|
||||
public ChunkingResult chunk(int chunkSize, StepContribution stepContribution) throws ReadFailureException;
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Value object representing the result of chunking.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public class ChunkingResult {
|
||||
|
||||
private final Chunk chunk;
|
||||
|
||||
private final List exceptions;
|
||||
|
||||
public ChunkingResult(Chunk chunk, List exceptions) {
|
||||
this.chunk = chunk;
|
||||
this.exceptions = exceptions;
|
||||
}
|
||||
|
||||
public Chunk getChunk() {
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public List getExceptions() {
|
||||
return exceptions;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
|
||||
/**
|
||||
* Interface defining the contract for dechunking a {@link Chunk}. Similar
|
||||
* to the differences between an {@link ItemReader} and an {@link ItemWriter},
|
||||
* a dechunker is the polar oposite of a {@link Chunker}. A {@link Chunker} creates
|
||||
* a chunk from a stream of items, wheras a Dechunker removes each item from the
|
||||
* {@link Chunk} and adds it to an outgoing stream of items.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public interface Dechunker extends ItemStream{
|
||||
|
||||
/**
|
||||
* Dechunk the provided chunk. In general, this will be done by delegating to an
|
||||
* {@link ItemWriter} for each item in the {@link Chunk}, however, it's purely at the
|
||||
* discretion of various implementations.
|
||||
*
|
||||
* @param chunk to be 'dechunked'
|
||||
* @param stepContribution the chunk belongs to.
|
||||
* @return a Dechunking result detailing whether or not dechunking was successful, and
|
||||
* if any items were skipped.
|
||||
* @throws Exception, specifically throws IllegalArgumentException if either the chunk
|
||||
* or StepExecution is null.
|
||||
*/
|
||||
DechunkingResult dechunk(Chunk chunk, StepContribution stepContribution) throws Exception;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Value object representing the result of dechunking a {@link Chunk}. It contains
|
||||
* the id of the chunk that was processed, a list of exceptions, and whether or not
|
||||
* the chunk was successful.
|
||||
*
|
||||
* @author Ben Hale
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public class DechunkingResult {
|
||||
|
||||
private final Long chunkId;
|
||||
|
||||
private final List exceptions;
|
||||
|
||||
private final boolean successful;
|
||||
|
||||
public DechunkingResult(boolean successful, Long chunkId, List exceptions) {
|
||||
this.chunkId = chunkId;
|
||||
this.exceptions = exceptions;
|
||||
this.successful = successful;
|
||||
}
|
||||
|
||||
public Long getChunkId() {
|
||||
return chunkId;
|
||||
}
|
||||
|
||||
public List getExceptions() {
|
||||
return new ArrayList(exceptions);
|
||||
}
|
||||
|
||||
public boolean isSuccessful() {
|
||||
return successful;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user