Поправил закрытие пулов потоков Executors.
This commit is contained in:
parent
19702fb5e0
commit
ba8dead115
4 changed files with 14 additions and 8 deletions
|
|
@ -47,6 +47,7 @@ public class ClearingService implements DisposableBean {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
|
log.debug("Shutdown {}", getClass().getSimpleName());
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@ import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,16 +83,20 @@ public abstract class AbstractHazelcastLifecycleSupport implements InitializingB
|
||||||
return maxKey;
|
return maxKey;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
long maxKey = 0L;
|
||||||
int threadCount = Runtime.getRuntime().availableProcessors();// todo config * Config.get().getRoot().getSettings().getInitHazelcastThreadMultiplier();
|
int threadCount = Runtime.getRuntime().availableProcessors();// todo config * Config.get().getRoot().getSettings().getInitHazelcastThreadMultiplier();
|
||||||
log.info("Initializing threads count = {}", threadCount);
|
log.info("Initializing threads count = {}", threadCount);
|
||||||
ExecutorService executor = Executors.newWorkStealingPool(threadCount);
|
ExecutorService executor = Executors.newWorkStealingPool(threadCount);
|
||||||
List<Future<Long>> results = executor.invokeAll(tasks);
|
try {
|
||||||
long maxKey = 0L;
|
List<Future<Long>> results = executor.invokeAll(tasks);
|
||||||
for (Future<Long> result : results) {
|
for (Future<Long> result : results) {
|
||||||
Long maxKeyResult = result.get();
|
Long maxKeyResult = result.get();
|
||||||
if (maxKeyResult != null) {
|
if (maxKeyResult != null) {
|
||||||
maxKey = Math.max(maxKey, maxKeyResult);
|
maxKey = Math.max(maxKey, maxKeyResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
executor.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
IdGenerator generator = hazelcastServerInstance.getIdGenerator(IMDGDistributedNames.MAP_SEQUENCE_NAME);
|
IdGenerator generator = hazelcastServerInstance.getIdGenerator(IMDGDistributedNames.MAP_SEQUENCE_NAME);
|
||||||
|
|
|
||||||
|
|
@ -157,8 +157,11 @@ public class QueueConsumer implements AutoCloseable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
log.debug("Closing queue consumer {}", getClass().getSimpleName());
|
||||||
closed.set(true);
|
closed.set(true);
|
||||||
consumer.wakeup();
|
consumer.wakeup();
|
||||||
|
inputExecutor.shutdown();
|
||||||
|
outputExecutor.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue