public class ClientWorker implements Closeable{
public ClientWorker(final HttpAgent agent,final ConfigFilterChainManager configFilterChainManager,final Properties properties){
this.executor.scheduleWithFixedDelay(new Runnable(){
@Override
public void run(){
try{checkConfigInfo();}catch(Exception e){
LOGGER.error("...");
}
}
},1L,10L,TimeUnit.MILLISECONDS);
...
}
public void checkConfigInfo(){
int listenerSize = cacheMap.get().size();
int longingTaskCount = (int)Math.ceil(listenerSize/ParamUtil.getPerTaskConfigSize());
if(longingTaskCount > currentLongingTaskCount){
for(int i = currentLongingTaskCount;i<longingTaskCount;i++){
executorService.execute(new LongPollingRunnable(i));
currentLongingTaskCount = longingTaskCount;
}
}
}
|