Browse Source

增加获取打分线程池

xueyiming 2 weeks ago
parent
commit
de60f6710e

+ 13 - 0
ad-engine-commons/src/main/java/com/tzld/piaoquan/ad/engine/commons/thread/ThreadPoolFactory.java

@@ -26,6 +26,14 @@ public final class ThreadPoolFactory {
             new ThreadFactoryBuilder().setNameFormat("Feature-%d").build(),
             new ThreadPoolExecutor.AbortPolicy());
 
+    private final static ExecutorService SCORE = new CommonThreadPoolExecutor(
+            512,
+            512,
+            0L, TimeUnit.SECONDS,
+            new LinkedBlockingQueue<>(5000),
+            new ThreadFactoryBuilder().setNameFormat("SCORE-%d").build(),
+            new ThreadPoolExecutor.AbortPolicy());
+
     public static ExecutorService defaultPool() {
         return DEFAULT;
     }
@@ -34,4 +42,9 @@ public final class ThreadPoolFactory {
         return FEATURE;
     }
 
+    public static ExecutorService score() {
+        return SCORE;
+    }
+
+
 }

+ 1 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/scorer/PAIScorer.java

@@ -94,7 +94,7 @@ public class PAIScorer extends AbstractScorer {
             batches.add(new ArrayList<>(items.subList(i, Math.min(i + batchSize, items.size()))));
         }
 
-        ExecutorService executor = ThreadPoolFactory.defaultPool();
+        ExecutorService executor = ThreadPoolFactory.score();
         List<Future<List<AdRankItem>>> futures = new ArrayList<>();
 
         for (List<AdRankItem> batch : batches) {

+ 1 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/scorer/PAIScorerV2.java

@@ -94,7 +94,7 @@ public class PAIScorerV2 extends AbstractScorer {
             batches.add(new ArrayList<>(items.subList(i, Math.min(i + batchSize, items.size()))));
         }
 
-        ExecutorService executor = ThreadPoolFactory.defaultPool();
+        ExecutorService executor = ThreadPoolFactory.score();
         List<Future<List<AdRankItem>>> futures = new ArrayList<>();
 
         for (List<AdRankItem> batch : batches) {