hll1213181368 commented on PR #2835:
URL: https://github.com/apache/kvrocks/pull/2835#issuecomment-2735709257

   This is my test demo
   
------------------------------------------------------------------------------------------
   @PostConstruct
   void init() throws Exception {
        ExecutorService executor = new ThreadPoolExecutor(
                        CORE_POOL_SIZE,
                        MAX_POOL_SIZE,
                        KEEP_ALIVE_TIME,
                        TimeUnit.SECONDS,
                        new LinkedBlockingQueue<>(QUEUE_CAPACITY),
                        new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略
        );
   
        int num = 10000;
        String filterName = "myBloomFilter";
        for (int i = 0; i < num; i++) {
                filterName = filterName + i;
                bloomRedisTemplate.reserve(filterName, 0.01, 1000);
        }
   
        List<Future<Boolean>> futures = new ArrayList<>();
   
        while (true) {
                for (int i = 0; i < num; i++) {
                        final String filterNameFinal = "myBloomFilter" + i;
                        for (int j = 0; j < 20; j++) {
                                final int index = j;
                                futures.add(executor.submit(() -> {
                                        // 实际请求逻辑(示例)
                                        List<String> elements = new 
ArrayList<>();
                                        for (int k = 0; k < 10; k++) {
                                                
elements.add("testElement_thread_" + index + "_test_" + k);
                                        }
                                        
bloomRedisTemplate.multiAdd(filterNameFinal, elements);
                                        return true;
                                }));
                        }
   
                        // 处理结果(带超时控制)
                        for (Future<Boolean> future : futures) {
                                try {
                                        Boolean response = future.get(5, 
TimeUnit.SECONDS); // 超时设置
                                        System.out.println(response);
                                } catch (Exception e) {
                                        e.printStackTrace();
                                }
                        }
                }
        }
   }


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to