Nikolay Izhikov created IGNITE-27451:
----------------------------------------
Summary: Service#cancel java.lang.AssertionError: Concurrent map
modification
Key: IGNITE-27451
URL: https://issues.apache.org/jira/browse/IGNITE-27451
Project: Ignite
Issue Type: Bug
Reporter: Nikolay Izhikov
{code:java}
package org.apache.ignite.internal.processors.service;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import
org.apache.ignite.internal.processors.service.inner.LongInitializedTestService;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
/**
* Tests concurrent deploy/undeploy services. */
public class ServiceConcurrentDeployUndeployTest extends GridCommonAbstractTest
{
/** */
private static final int THREAD_CNT = 10;
/** */
private static final int EXECUTION_CNT = 100;
/** */
private final ExecutorService executor =
Executors.newFixedThreadPool(THREAD_CNT);
/** */
@Test
public void test() throws Exception {
CountDownLatch latch = new CountDownLatch(EXECUTION_CNT * THREAD_CNT);
try (IgniteEx ignite = startGrids(4)) {
for (int t = 0; t < THREAD_CNT; t++) {
for (int i = 0; i < EXECUTION_CNT; i++) {
String threadName = String.format("worker-%s-%s", t, i);
executor.submit(getServiceRunnable(threadName, latch));
}
}
latch.await();
}
}
/** */
private Runnable getServiceRunnable(String srvcName, CountDownLatch latch) {
return () -> {
try {
IgniteConfiguration cfg = getConfiguration("client-" +
srvcName);
try (IgniteEx client = startClientGrid(cfg)) {
long delay = ThreadLocalRandom.current().nextLong(1001);
IgniteFuture<Void> fut =
client.services().deployNodeSingletonAsync(srvcName, new
LongInitializedTestService(delay));
fut.get();
client.services().cancelAll();
latch.countDown();
}
}
catch (Exception e) {
log.error("Unexpected error [" + srvcName + "]", e);
}
};
}
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)