Skip to content
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 @@ -193,6 +193,9 @@ public final class Messages {
public static final String SPRING_SCHEDULER_TASK_EXECUTOR_THREADS = "Spring scheduler task executor threads: {0}";
public static final String FILES_ASYNC_UPLOAD_EXECUTOR_MAX_THREADS = "Files async executor max threads: {0}";
public static final String DEPLOY_FROM_URL_EXECUTOR_MAX_THREADS = "Deploy from URL executor max threads: {0}";
public static final String CLOUD_LOGGING_EXECUTOR_CORE_THREADS = "Cloud logging executor core threads: {0}";
public static final String CLOUD_LOGGING_EXECUTOR_MAX_THREADS = "Cloud logging executor max threads: {0}";
public static final String CLOUD_LOGGING_EXECUTOR_QUEUE_CAPACITY = "Cloud logging executor queue capacity: {0}";
public static final String DEPLOY_FROM_URL_ADDRESS_DENY_LIST_0 = "Deploy from URL address deny list: {0}";
public static final String DEPLOY_FROM_URL_ADDRESS_VALIDATION_ENABLED_0 = "Deploy from URL address validation enabled: {0}";
public static final String DEPLOY_FROM_URL_TARGET_ADDRESS_0_DENIED_FOR_JOB_WITH_ID_1 = "Download target host \"{0}\" resolves to a denied address. Job id: {1}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void removeClientFromCache(String operationId) {
webClientCache.remove(operationId);
}

@Async("asyncExecutor")
@Async("cloudLoggingAsyncExecutor")
public void sendLogsToCloudLoggingService(LoggingConfiguration loggingConfiguration,
List<ExternalOperationLogEntry> logEntryBatch) {
WebClient webClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public class ApplicationConfiguration {
static final String CFG_SPRING_SCHEDULER_TASK_EXECUTOR_THREADS = "SPRING_SCHEDULER_TASK_EXECUTOR_THREADS";
static final String CFG_FILES_ASYNC_UPLOAD_EXECUTOR_MAX_THREADS = "FILES_ASYNC_UPLOAD_EXECUTOR_THREADS";
static final String CFG_DEPLOY_FROM_URL_EXECUTOR_MAX_THREADS = "DEPLOY_FROM_URL_EXECUTOR_MAX_THREADS";
static final String CFG_CLOUD_LOGGING_EXECUTOR_CORE_THREADS = "CLOUD_LOGGING_EXECUTOR_CORE_THREADS";
static final String CFG_CLOUD_LOGGING_EXECUTOR_MAX_THREADS = "CLOUD_LOGGING_EXECUTOR_MAX_THREADS";
static final String CFG_CLOUD_LOGGING_EXECUTOR_QUEUE_CAPACITY = "CLOUD_LOGGING_EXECUTOR_QUEUE_CAPACITY";
static final String CFG_ENABLE_ON_START_FILES_WITHOUT_CONTENT_CLEANER = "ENABLE_ON_START_FILES_WITHOUT_CONTENT_CLEANER";
static final String CFG_THREADS_FOR_FILE_UPLOAD_TO_CONTROLLER = "THREADS_FOR_FILE_UPLOAD_TO_CONTROLLER";
static final String CFG_THREADS_FOR_FILE_STORAGE_UPLOAD = "THREADS_FOR_FILE_STORAGE_UPLOAD";
Expand Down Expand Up @@ -163,6 +166,9 @@ public class ApplicationConfiguration {
public static final int DEFAULT_SPRING_SCHEDULER_TASK_EXECUTOR_THREADS = 3;
public static final int DEFAULT_FILES_ASYNC_UPLOAD_EXECUTOR_MAX_THREADS = 6;
public static final int DEFAULT_DEPLOY_FROM_URL_EXECUTOR_MAX_THREADS = 26;
public static final Integer DEFAULT_CLOUD_LOGGING_EXECUTOR_CORE_THREADS = 4;
public static final Integer DEFAULT_CLOUD_LOGGING_EXECUTOR_MAX_THREADS = 8;
public static final Integer DEFAULT_CLOUD_LOGGING_EXECUTOR_QUEUE_CAPACITY = 128;
public static final boolean DEFAULT_ENABLE_ON_START_FILES_WITHOUT_CONTENT_CLEANER = false;
public static final int DEFAULT_THREADS_FOR_FILE_UPLOAD_TO_CONTROLLER = 6;
public static final int DEFAULT_THREADS_FOR_FILE_STORAGE_UPLOAD = 7;
Expand Down Expand Up @@ -230,6 +236,9 @@ public class ApplicationConfiguration {
private Integer springSchedulerTaskExecutorThreads;
private Integer filesAsyncUploadExecutorThreads;
private Integer deployFromUrlExecutorMaxThreads;
private Integer cloudLoggingExecutorCoreThreads;
private Integer cloudLoggingExecutorMaxThreads;
private Integer cloudLoggingExecutorQueueCapacity;
private Boolean isOnStartFilesWithoutContentCleanerEnabledThroughEnvironment;
private Integer threadsForFileUploadToController;
private Integer threadsForFileStorageUpload;
Expand Down Expand Up @@ -292,6 +301,9 @@ public void load() {
getAbortedOperationsTtlInSeconds();
getFilesAsyncUploadExecutorMaxThreads();
getDeployFromUrlExecutorMaxThreads();
getCloudLoggingExecutorCoreThreads();
getCloudLoggingExecutorMaxThreads();
getCloudLoggingExecutorQueueCapacity();
getObjectStoreRegions();
}

Expand Down Expand Up @@ -445,6 +457,27 @@ public Integer getDeployFromUrlExecutorMaxThreads() {
return deployFromUrlExecutorMaxThreads;
}

public Integer getCloudLoggingExecutorCoreThreads() {
if (cloudLoggingExecutorCoreThreads == null) {
cloudLoggingExecutorCoreThreads = getCloudLoggingExecutorCoreThreadsFromEnvironment();
}
return cloudLoggingExecutorCoreThreads;
}

public Integer getCloudLoggingExecutorMaxThreads() {
if (cloudLoggingExecutorMaxThreads == null) {
cloudLoggingExecutorMaxThreads = getCloudLoggingExecutorMaxThreadsFromEnvironment();
}
return cloudLoggingExecutorMaxThreads;
}

public Integer getCloudLoggingExecutorQueueCapacity() {
if (cloudLoggingExecutorQueueCapacity == null) {
cloudLoggingExecutorQueueCapacity = getCloudLoggingExecutorQueueCapacityFromEnvironment();
}
return cloudLoggingExecutorQueueCapacity;
}

public String getGlobalAuditorUser() {
if (globalAuditorUser == null) {
globalAuditorUser = getGlobalAuditorUserFromEnvironment();
Expand Down Expand Up @@ -932,6 +965,27 @@ private Integer getDeployFromUrlExecutorMaxThreadsFromEnvironment() {
return value;
}

private Integer getCloudLoggingExecutorCoreThreadsFromEnvironment() {
Integer value = environment.getPositiveInteger(CFG_CLOUD_LOGGING_EXECUTOR_CORE_THREADS,
DEFAULT_CLOUD_LOGGING_EXECUTOR_CORE_THREADS);
logEnvironmentVariable(CFG_CLOUD_LOGGING_EXECUTOR_CORE_THREADS, Messages.CLOUD_LOGGING_EXECUTOR_CORE_THREADS, value);
return value;
}

private Integer getCloudLoggingExecutorMaxThreadsFromEnvironment() {
Integer value = environment.getPositiveInteger(CFG_CLOUD_LOGGING_EXECUTOR_MAX_THREADS,
DEFAULT_CLOUD_LOGGING_EXECUTOR_MAX_THREADS);
logEnvironmentVariable(CFG_CLOUD_LOGGING_EXECUTOR_MAX_THREADS, Messages.CLOUD_LOGGING_EXECUTOR_MAX_THREADS, value);
return value;
}

private Integer getCloudLoggingExecutorQueueCapacityFromEnvironment() {
Integer value = environment.getPositiveInteger(CFG_CLOUD_LOGGING_EXECUTOR_QUEUE_CAPACITY,
DEFAULT_CLOUD_LOGGING_EXECUTOR_QUEUE_CAPACITY);
logEnvironmentVariable(CFG_CLOUD_LOGGING_EXECUTOR_QUEUE_CAPACITY, Messages.CLOUD_LOGGING_EXECUTOR_QUEUE_CAPACITY, value);
return value;
}

private String getGlobalAuditorUserFromEnvironment() {
String value = environment.getString(CFG_GLOBAL_AUDITOR_USER);
return value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.cloudfoundry.multiapps.controller.web.configuration;

import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;

import jakarta.inject.Inject;
import org.cloudfoundry.multiapps.controller.core.util.ApplicationConfiguration;
Expand All @@ -25,4 +26,18 @@ public Executor getAsyncExecutor() {
executor.initialize();
return executor;
}

@Bean("cloudLoggingAsyncExecutor")
public Executor getCloudLoggingAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(configuration.getCloudLoggingExecutorCoreThreads());
executor.setMaxPoolSize(configuration.getCloudLoggingExecutorMaxThreads());
executor.setQueueCapacity(configuration.getCloudLoggingExecutorQueueCapacity());
// Log export is best-effort and must never fail a deployment; when the pool and
// queue are saturated, run the task on the caller thread instead of aborting it.
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.setThreadNamePrefix("cloud-logging-export-");
executor.initialize();
return executor;
}
}
Loading