分设备队列
This commit is contained in:
parent
7cea8093c7
commit
cecc7aa181
@ -67,6 +67,7 @@ import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
@ -91,8 +92,16 @@ public class ViidController {
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private TaskFaceService taskFaceService;
|
||||
private final Map<String, ThreadPoolExecutor> executors = new ConcurrentHashMap<>();
|
||||
|
||||
private final ThreadPoolExecutor executor = new ThreadPoolExecutor(8, 4096, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(4096));
|
||||
private ThreadPoolExecutor getExecutor(String deviceId) {
|
||||
ThreadPoolExecutor executor = executors.get(deviceId);
|
||||
if (executor == null) {
|
||||
executor = new ThreadPoolExecutor(4, 4096, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(4096));
|
||||
executors.put(deviceId, executor);
|
||||
}
|
||||
return executor;
|
||||
}
|
||||
|
||||
// region 注册注销基础接口
|
||||
/**
|
||||
@ -311,6 +320,7 @@ public class ViidController {
|
||||
String url = adapter.uploadFile(file, "user-face", UUID.randomUUID() + "." + ext);
|
||||
faceSample.setFaceUrl(url);
|
||||
faceSampleMapper.add(faceSample);
|
||||
ThreadPoolExecutor executor = getExecutor(device.getId().toString());
|
||||
executor.execute(() -> {
|
||||
if (faceBodyAdapter != null) {
|
||||
taskFaceService.assureFaceDb(faceBodyAdapter, scenicId.toString());
|
||||
@ -372,6 +382,7 @@ public class ViidController {
|
||||
faceSample.setFaceUrl(url);
|
||||
faceSampleMapper.add(faceSample);
|
||||
DynamicTaskGenerator.addTask(faceSample.getId());
|
||||
ThreadPoolExecutor executor = getExecutor(device.getId().toString());
|
||||
executor.execute(() -> {
|
||||
if (faceBodyAdapter != null) {
|
||||
taskFaceService.assureFaceDb(faceBodyAdapter, scenicId.toString());
|
||||
|
Loading…
x
Reference in New Issue
Block a user