public abstract class BaseReqHandler<T> extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected AtomicInteger |
activeRunnableNum
onging runnable number, every subclass implement process method should decrement this value when a job was done.
|
protected ThreadPoolExecutor |
batchProcessSvc |
protected long |
defaultSleepMs |
protected long |
emptySleepMs |
protected TaskMasterPool |
taskMasterPool |
| 构造器和说明 |
|---|
BaseReqHandler(long jobInstanceId,
int coreBatchThreadNum,
int maxBatchThreadNum,
int batchSize,
ReqQueue<T> queue,
String batchProcessThreadName,
String batchRetrieveThreadName) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
clear() |
T |
getLatestRequest() |
boolean |
isActive()
queue has remaining or at least on runnable running, using this method with attention
because batch process may be async so activeRunnableNum should be decrement when job really down,
you can look #{TMStatusReqHandler} for example;
|
void |
process(long jobInstanceId,
List<T> reqs) |
abstract void |
process(long jobInstanceId,
List<T> reqs,
String workerIdAddr)
logic implemented by subclass for processing this batch of reqs
|
void |
setBatchSize(int batchSize) |
void |
setWorkThreadNum(int workThreadNum) |
void |
start() |
void |
stop() |
void |
submitRequest(T request) |
List<T> |
syncHandleReqs(int pageSize,
String workerIdAddr) |
protected TaskMasterPool taskMasterPool
protected ThreadPoolExecutor batchProcessSvc
protected long defaultSleepMs
protected long emptySleepMs
protected AtomicInteger activeRunnableNum
public void start()
public abstract void process(long jobInstanceId,
List<T> reqs,
String workerIdAddr)
jobInstanceId - id of job instance which these reqs belong to.reqs - batch of reqsworkerIdAddr - of PullModelpublic void setWorkThreadNum(int workThreadNum)
public void setBatchSize(int batchSize)
public void stop()
public void clear()
public T getLatestRequest()
public boolean isActive()
Copyright © 2022. All rights reserved.