@@ -0,0 +1,2343 @@
+package org.cache2k.addon;%0A%0A/*%0A * #%25L%0A * cache2k addon%0A * %25%25%0A * Copyright (C) 2000 - 2021 headissue GmbH, Munich%0A * %25%25%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *      http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * #L%25%0A */%0A%0Aimport org.cache2k.Cache;%0Aimport org.cache2k.Cache2kBuilder;%0Aimport org.cache2k.pinpoint.stress.ThreadingStressTester;%0Aimport org.cache2k.testing.category.SlowTests;%0Aimport org.junit.Test;%0Aimport org.junit.experimental.categories.Category;%0A%0Aimport java.util.Random;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport static java.util.Arrays.asList;%0Aimport static org.junit.Assert.assertEquals;%0A%0A/**%0A * @author Jens Wilke%0A */%0A@Category(SlowTests.class)%0Apublic class CoalescingBulkLoaderStressTest %7B%0A%0A  @Test%0A  public void test() %7B%0A    CoalescingBulkLoaderTest.IdentBulkLoader ibl =%0A      new CoalescingBulkLoaderTest.IdentBulkLoader();%0A    Cache%3CInteger, Integer%3E c =%0A      Cache2kBuilder.of(Integer.class, Integer.class)%0A        .bulkLoader((keys, context, callback) -%3E %7B%0A          if (keys.hashCode() %25 2 == 0) %7B%0A            context.getExecutor().execute(() -%3E %7B%0A              ibl.loadAll(keys, context, callback);%0A            %7D);%0A            return;%0A          %7D%0A          ibl.loadAll(keys, context, callback);%0A        %7D)%0A        .enableWith(CoalescingBulkLoaderSupport.class, b -%3E b%0A          .maxBatchSize(100)%0A          .maxDelay(2, TimeUnit.MILLISECONDS)%0A        )%0A        .entryCapacity(10)%0A        .build();%0A    ThreadingStressTester tst = new ThreadingStressTester();%0A    tst.addTask(3, () -%3E %7B%0A      Random r = new Random();%0A      for (int i = 0; i %3C 10; i++) %7B%0A        int k = r.nextInt(20);%0A        int v = c.get(k);%0A        assertEquals(k, v);%0A      %7D%0A    %7D);%0A    tst.addTask(() -%3E %7B%0A      Random r = new Random();%0A      c.loadAll(asList(r.nextInt(20), r.nextInt(20)));%0A    %7D);%0A    tst.setDoNotInterrupt(true);%0A    tst.run();%0A    c.close();%0A  %7D%0A%7D%0A

add stress test