T - The type of the bean being converted topublic class LineExecutor<T> extends ThreadPoolExecutor
IntolerantThreadPoolExecutor intended for
submitting lines of input to be converted to beans.ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| Modifier and Type | Field and Description |
|---|---|
protected com.opencsv.bean.concurrent.AccumulateCsvResults<T> |
accumulateThread
A separate thread that accumulates and orders results.
|
protected BlockingQueue<OrderedObject<T>> |
resultQueue
A queue of the beans created.
|
protected BlockingQueue<OrderedObject<CsvException>> |
thrownExceptionsQueue
A queue of exceptions thrown by threads during processing.
|
| Constructor and Description |
|---|
LineExecutor(boolean orderedResults)
The only constructor available for this class.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterExecute(Runnable r,
Throwable t)
Shuts the Executor down if the thread ended in an exception.
|
void |
complete()
Sends a signal to the Executor that it should shut down once all threads
have completed.
|
List<CsvException> |
getCapturedExceptions()
Returns exceptions captured during the conversion process if
the conversion process was set not to propagate these errors
up the call stack.
|
Throwable |
getTerminalException()
If an unrecoverable exception was thrown during processing, it can be
retrieved here.
|
void |
prepare()
Prepares this Executor to receive jobs.
|
Stream<T> |
resultStream()
Returns the results of conversion as a
Stream. |
List<Runnable> |
shutdownNow() |
void |
submitLine(long lineNumber,
MappingStrategy<? extends T> mapper,
CsvToBeanFilter filter,
List<BeanVerifier<T>> verifiers,
String[] line,
boolean throwExceptions)
Submit one record for conversion to a bean.
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, terminated, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitprotected final BlockingQueue<OrderedObject<T>> resultQueue
protected final BlockingQueue<OrderedObject<CsvException>> thrownExceptionsQueue
protected com.opencsv.bean.concurrent.AccumulateCsvResults<T> accumulateThread
public LineExecutor(boolean orderedResults)
orderedResults - Whether order should be preserved in the resultspublic void submitLine(long lineNumber,
MappingStrategy<? extends T> mapper,
CsvToBeanFilter filter,
List<BeanVerifier<T>> verifiers,
String[] line,
boolean throwExceptions)
lineNumber - Which record in the input file is being processedmapper - The mapping strategy to be usedfilter - A filter to remove beans from the running, if necessary.
May be null.verifiers - The list of verifiers to run on beans after creationline - The line of input to be transformed into a beanthrowExceptions - Whether exceptions should be thrown or captured
for later processingpublic void prepare()
public void complete()
throws InterruptedException
InterruptedException - If the current thread is interrupted while
waiting. Shouldn't be thrown, since the Executor
waits indefinitely for all threads to end.RejectedExecutionException - If an exception during processing
forced this Executor to shut down.public Stream<T> resultStream()
Stream.Stream of resultspublic List<CsvException> getCapturedExceptions()
public List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServiceshutdownNow in class ThreadPoolExecutorprotected void afterExecute(Runnable r, Throwable t)
afterExecute in class ThreadPoolExecutorr - t - public Throwable getTerminalException()
Copyright © 2019. All rights reserved.