This commit is contained in:
2025-03-08 15:46:24 +08:00
parent 50927481d2
commit c2ebbd71e2
35 changed files with 303 additions and 314 deletions

View File

@ -24,6 +24,7 @@ import com.ycwl.basic.storage.adapters.IStorageAdapter;
import com.ycwl.basic.storage.entity.StorageFileObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -37,6 +38,7 @@ import static com.ycwl.basic.constant.FaceConstant.USER_FACE_DB_NAME;
@Component
@EnableScheduling
@Slf4j
@Profile("prod")
public class FaceCleaner {
@Autowired
private ScenicMapper scenicMapper;

View File

@ -10,6 +10,7 @@ import com.ycwl.basic.model.pc.device.req.DeviceReqQuery;
import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -20,6 +21,7 @@ import java.util.List;
@Component
@EnableScheduling
@Slf4j
@Profile("prod")
public class VideoPieceCleaner {
@Autowired
private DeviceMapper deviceMapper;

View File

@ -62,7 +62,7 @@ public class VideoPieceGetter {
@Data
public static class Task {
public List<Long> faceSampleIds;
public List<Long> faceSampleIds = new ArrayList<>();
public Callback callback;
public Long memberId;
public Long faceId;
@ -114,7 +114,7 @@ public class VideoPieceGetter {
// taskStatusBiz.setFaceCutStatus(task.faceId, 0);
// }
AtomicBoolean invoke = new AtomicBoolean(false);
ThreadPoolExecutor executor = new ThreadPoolExecutor(8, 16, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(32));
final ThreadPoolExecutor executor = new ThreadPoolExecutor(16, 512, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(512));
List<String> currentPlaceholder = new ArrayList<>();
List<FaceSampleEntity> list = faceSampleMapper.listByIds(task.getFaceSampleIds());
Collection<List<FaceSampleEntity>> collection = list.stream()
@ -128,7 +128,8 @@ public class VideoPieceGetter {
.values();
collection.forEach(faceSampleList -> {
executor.execute(() -> {
faceSampleList.parallelStream().forEach(faceSample -> {
faceSampleList.parallelStream().forEach(faceSample -> {
executor.execute(() -> {
DeviceEntity device = deviceRepository.getDevice(faceSample.getDeviceId());
DeviceConfigEntity config = deviceRepository.getDeviceConfig(faceSample.getDeviceId());
@ -255,11 +256,15 @@ public class VideoPieceGetter {
}
}
});
});
});
});
try {
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
Thread.sleep(1000L);
log.info("executor等待被结束[A:{}/T:{}/F:{}]", executor.getActiveCount(), executor.getTaskCount(), executor.getCompletedTaskCount());
executor.shutdown();
executor.awaitTermination(5, TimeUnit.MINUTES);
log.info("executor已结束[A:{}/T:{}/F:{}]", executor.getActiveCount(), executor.getTaskCount(), executor.getCompletedTaskCount());
} catch (InterruptedException e) {
return;
} finally {