Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: modify executors #23

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,44 +38,45 @@ public class TelemetryService {

private final ConcurrentLinkedQueue<Runnable> additionalContentUploadQueue = new ConcurrentLinkedQueue<>();

private final static ScheduledExecutorService executorService = Executors.newScheduledThreadPool(6);
private final static ScheduledExecutorService scheduledExecutorService =
Executors.newScheduledThreadPool(0, Thread.ofVirtual().factory());

/**
* Starts telemetries listener, which handles incoming telemetries to be processed in a sequential way.
*/
@PostConstruct
private void configure() {
executorService.scheduleWithFixedDelay(() -> {
scheduledExecutorService.scheduleWithFixedDelay(() -> {
if (!apiServerHealthCheckQueue.isEmpty()) {
apiServerHealthCheckQueue.poll().run();
}
}, 0, properties.getDiagnosticsScrapeDelay(), TimeUnit.MILLISECONDS);

executorService.scheduleWithFixedDelay(() -> {
scheduledExecutorService.scheduleWithFixedDelay(() -> {
if (!clusterHealthCheckQueue.isEmpty()) {
clusterHealthCheckQueue.poll().run();
}
}, 0, properties.getDiagnosticsScrapeDelay(), TimeUnit.MILLISECONDS);

executorService.scheduleWithFixedDelay(() -> {
scheduledExecutorService.scheduleWithFixedDelay(() -> {
if (!clusterStateQueue.isEmpty()) {
clusterStateQueue.poll().run();
}
}, 0, properties.getDiagnosticsScrapeDelay(), TimeUnit.MILLISECONDS);

executorService.scheduleWithFixedDelay(() -> {
scheduledExecutorService.scheduleWithFixedDelay(() -> {
if (!clusterDownloadQueue.isEmpty()) {
clusterDownloadQueue.poll().run();
}
}, 0, properties.getDiagnosticsScrapeDelay(), TimeUnit.MILLISECONDS);

executorService.scheduleWithFixedDelay(() -> {
scheduledExecutorService.scheduleWithFixedDelay(() -> {
if (!rawContentUploadQueue.isEmpty()) {
rawContentUploadQueue.poll().run();
}
}, 0, properties.getDiagnosticsScrapeDelay(), TimeUnit.MILLISECONDS);

executorService.scheduleWithFixedDelay(() -> {
scheduledExecutorService.scheduleWithFixedDelay(() -> {
if (!additionalContentUploadQueue.isEmpty()) {
additionalContentUploadQueue.poll().run();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public class LoggingStateService {
@Autowired
private PropertiesEntity properties;

private final ScheduledExecutorService scheduledExecutorService =
Executors.newScheduledThreadPool(0, Thread.ofVirtual().factory());
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();

/**
* Performs application exit if the required state has been changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ public class SchedulerConfigService {
@Autowired
private ApiServerCommunicationResource apiServerCommunicationResource;

private final ExecutorService starterExecutorService = Executors.newVirtualThreadPerTaskExecutor();

private final ScheduledExecutorService operationScheduledExecutorService =
Executors.newScheduledThreadPool(0, Thread.ofVirtual().factory());

/**
* Performs configuration of RepoAchiever Cluster workers.
*
* @throws SchedulerPeriodRetrievalFailureException if scheduler period retrieval process failed.
*/
@PostConstruct
private void process() throws SchedulerPeriodRetrievalFailureException {
ExecutorService starterExecutorService =
Executors.newFixedThreadPool(configService.getConfig().getContent().getLocations().size());

ScheduledExecutorService operationScheduledExecutorService =
Executors.newScheduledThreadPool(configService.getConfig().getContent().getLocations().size());

Long period;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class GitGitHubVendorService {

private String document;

private final ScheduledExecutorService scheduledExecutorService =
Executors.newScheduledThreadPool(0, Thread.ofVirtual().factory());
private ScheduledExecutorService scheduledExecutorService;

/**
* Performs initial GraphQL client and HTTP client configuration.
Expand All @@ -67,6 +66,10 @@ public class GitGitHubVendorService {
*/
@PostConstruct
private void configure() throws GitHubGraphQlClientDocumentNotFoundException {
scheduledExecutorService =
Executors.newScheduledThreadPool(
configService.getConfig().getContent().getLocations().size() * 2);

if (configService.getConfig().getService().getProvider() == ConfigEntity.Service.Provider.GIT_GITHUB) {
WebClient client = WebClient.builder()
.baseUrl(properties.getGraphQlClientGitHubUrl())
Expand Down
Loading