88c2491aaadfe1bf1e907cfb171246b3217cb79c
java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java
| ... | ... | @@ -23,6 +23,8 @@ import com.mongodb.connection.ClusterDescription; |
| 23 | 23 | import com.mongodb.connection.ServerDescription; |
| 24 | 24 | import com.sap.sailing.server.interfaces.RacingEventService; |
| 25 | 25 | import com.sap.sse.ServerInfo; |
| 26 | +import com.sap.sse.common.Duration; |
|
| 27 | +import com.sap.sse.common.Util; |
|
| 26 | 28 | import com.sap.sse.mongodb.MongoDBService; |
| 27 | 29 | import com.sap.sse.replication.ReplicationService; |
| 28 | 30 | import com.sap.sse.replication.ReplicationStatus; |
| ... | ... | @@ -66,11 +68,15 @@ public class StatusServlet extends HttpServlet { |
| 66 | 68 | if (defaultBackgroundTaskThreadPoolExecutor instanceof ThreadPoolExecutor) { |
| 67 | 69 | final long queueLengthDefaultBackgroundThreadPoolExecutor = ((ThreadPoolExecutor) defaultBackgroundTaskThreadPoolExecutor).getQueue().size(); |
| 68 | 70 | result.put("defaultbackgroundthreadpoolexecutorqueuelength", queueLengthDefaultBackgroundThreadPoolExecutor); |
| 71 | + final long nonDelayedQueueLengthDefaultBackgroundThreadPoolExecutor = Util.size(ThreadPoolUtil.INSTANCE.getTasksDelayedByLessThan((ThreadPoolExecutor) defaultBackgroundTaskThreadPoolExecutor, Duration.ONE_SECOND)); |
|
| 72 | + result.put("defaultbackgroundthreadpoolexecutorqueuelengthnondelayed", nonDelayedQueueLengthDefaultBackgroundThreadPoolExecutor); |
|
| 69 | 73 | } |
| 70 | 74 | final ScheduledExecutorService defaultForegroundTaskThreadPoolExecutor = ThreadPoolUtil.INSTANCE.getDefaultForegroundTaskThreadPoolExecutor(); |
| 71 | 75 | if (defaultForegroundTaskThreadPoolExecutor instanceof ThreadPoolExecutor) { |
| 72 | 76 | final long queueLengthDefaultForegroundThreadPoolExecutor = ((ThreadPoolExecutor) defaultForegroundTaskThreadPoolExecutor).getQueue().size(); |
| 73 | 77 | result.put("defaultforegroundthreadpoolexecutorqueuelength", queueLengthDefaultForegroundThreadPoolExecutor); |
| 78 | + final long nonDelayedQueueLengthDefaultForegroundThreadPoolExecutor = Util.size(ThreadPoolUtil.INSTANCE.getTasksDelayedByLessThan((ThreadPoolExecutor) defaultForegroundTaskThreadPoolExecutor, Duration.ONE_SECOND)); |
|
| 79 | + result.put("defaultforegroundthreadpoolexecutorqueuelengthnondelayed", nonDelayedQueueLengthDefaultForegroundThreadPoolExecutor); |
|
| 74 | 80 | } |
| 75 | 81 | final double systemLoadAverageLastMinute = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); |
| 76 | 82 | result.put("systemloadaveragelastminute", systemLoadAverageLastMinute); |
java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/SailingAnalyticsProcess.java
| ... | ... | @@ -10,6 +10,7 @@ import com.sap.sailing.landscape.procedures.SailingProcessConfigurationVariables |
| 10 | 10 | import com.sap.sse.common.Duration; |
| 11 | 11 | import com.sap.sse.landscape.Release; |
| 12 | 12 | import com.sap.sse.landscape.aws.AwsApplicationProcess; |
| 13 | +import com.sap.sse.util.ThreadPoolUtil; |
|
| 13 | 14 | |
| 14 | 15 | public interface SailingAnalyticsProcess<ShardingKey> extends AwsApplicationProcess<ShardingKey, SailingAnalyticsMetrics, SailingAnalyticsProcess<ShardingKey>> { |
| 15 | 16 | static Logger logger = Logger.getLogger(SailingAnalyticsProcess.class.getName()); |
| ... | ... | @@ -40,7 +41,39 @@ public interface SailingAnalyticsProcess<ShardingKey> extends AwsApplicationProc |
| 40 | 41 | |
| 41 | 42 | double getLastMinuteSystemLoadAverage(Optional<Duration> optionalTimeout) throws TimeoutException, Exception; |
| 42 | 43 | |
| 44 | + /** |
|
| 45 | + * The count of <em>all</em> tasks in the default background thread pool executor's queue, including those scheduled |
|
| 46 | + * with a delay, such as rate limiter and cache clean-up tasks or periodic fetching of remote server content. |
|
| 47 | + * |
|
| 48 | + * @see ThreadPoolUtil#getDefaultBackgroundTaskThreadPoolExecutor() |
|
| 49 | + */ |
|
| 43 | 50 | int getDefaultBackgroundThreadPoolExecutorQueueSize(Optional<Duration> optionalTimeout) throws TimeoutException, Exception; |
| 44 | 51 | |
| 52 | + /** |
|
| 53 | + * The count of <em>all</em> tasks in the default foreground thread pool executor's queue, including those scheduled |
|
| 54 | + * with a delay, such as rate limiter and cache clean-up tasks or periodic fetching of remote server content. |
|
| 55 | + * |
|
| 56 | + * @see ThreadPoolUtil#getDefaultForegroundTaskThreadPoolExecutor() |
|
| 57 | + */ |
|
| 45 | 58 | int getDefaultForegroundThreadPoolExecutorQueueSize(Optional<Duration> optionalTimeout) throws TimeoutException, Exception; |
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * The count of only those tasks in the default background thread pool executor's queue that have no scheduling |
|
| 62 | + * delay or a delay below {@link Duration#ONE_SECOND one second}. This helps exclude from the count those rate |
|
| 63 | + * limiter and cache clean-up tasks or periodic fetching of remote server content. It is as such as good approximation |
|
| 64 | + * of the "immediate" tasks that will keep the server busy in the immediate future. |
|
| 65 | + * |
|
| 66 | + * @see ThreadPoolUtil#getDefaultBackgroundTaskThreadPoolExecutor() |
|
| 67 | + */ |
|
| 68 | + int getDefaultBackgroundThreadPoolExecutorQueueSizeNondelayed(Optional<Duration> optionalTimeout) throws TimeoutException, Exception; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * The count of only those tasks in the default foreground thread pool executor's queue that have no scheduling |
|
| 72 | + * delay or a delay below {@link Duration#ONE_SECOND one second}. This helps exclude from the count those rate |
|
| 73 | + * limiter and cache clean-up tasks or periodic fetching of remote server content. It is as such as good approximation |
|
| 74 | + * of the "immediate" tasks that will keep the server busy in the immediate future. |
|
| 75 | + * |
|
| 76 | + * @see ThreadPoolUtil#getDefaultForegroundTaskThreadPoolExecutor() |
|
| 77 | + */ |
|
| 78 | + int getDefaultForegroundThreadPoolExecutorQueueSizeNondelayed(Optional<Duration> optionalTimeout) throws TimeoutException, Exception; |
|
| 46 | 79 | } |
java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/impl/ArchiveCandidateMonitoringBackgroundTask.java
| ... | ... | @@ -237,7 +237,7 @@ public class ArchiveCandidateMonitoringBackgroundTask implements Runnable { |
| 237 | 237 | |
| 238 | 238 | @Override |
| 239 | 239 | public boolean runCheck() throws Exception { |
| 240 | - final int defaultBackgroundThreadPoolExecutorQueueSize = replicaSet.getMaster().getDefaultBackgroundThreadPoolExecutorQueueSize(Landscape.WAIT_FOR_PROCESS_TIMEOUT); |
|
| 240 | + final int defaultBackgroundThreadPoolExecutorQueueSize = replicaSet.getMaster().getDefaultBackgroundThreadPoolExecutorQueueSizeNondelayed(Landscape.WAIT_FOR_PROCESS_TIMEOUT); |
|
| 241 | 241 | final boolean result = defaultBackgroundThreadPoolExecutorQueueSize < MAXIMUM_THREAD_POOL_QUEUE_SIZE; |
| 242 | 242 | if (!result) { |
| 243 | 243 | setLastFailureMessage("Candidate at " + replicaSet.getMaster().getHost().getPrivateAddress() |
| ... | ... | @@ -257,7 +257,7 @@ public class ArchiveCandidateMonitoringBackgroundTask implements Runnable { |
| 257 | 257 | |
| 258 | 258 | @Override |
| 259 | 259 | public boolean runCheck() throws Exception { |
| 260 | - final int defaultForegroundThreadPoolExecutorQueueSize = replicaSet.getMaster().getDefaultForegroundThreadPoolExecutorQueueSize(Landscape.WAIT_FOR_PROCESS_TIMEOUT); |
|
| 260 | + final int defaultForegroundThreadPoolExecutorQueueSize = replicaSet.getMaster().getDefaultForegroundThreadPoolExecutorQueueSizeNondelayed(Landscape.WAIT_FOR_PROCESS_TIMEOUT); |
|
| 261 | 261 | final boolean result = defaultForegroundThreadPoolExecutorQueueSize < MAXIMUM_THREAD_POOL_QUEUE_SIZE; |
| 262 | 262 | if (!result) { |
| 263 | 263 | setLastFailureMessage("Candidate at "+replicaSet.getMaster().getHost().getPrivateAddress() |
java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/impl/SailingAnalyticsProcessImpl.java
| ... | ... | @@ -54,6 +54,8 @@ implements SailingAnalyticsProcess<ShardingKey> { |
| 54 | 54 | private static final String SYSTEM_LOAD_AVERAGE_LAST_MINUTE_NAME = "systemloadaveragelastminute"; |
| 55 | 55 | private static final String DEFAULT_BACKGROUND_THREAD_POOL_EXECUTOR_QUEUE_LENGTH_NAME = "defaultbackgroundthreadpoolexecutorqueuelength"; |
| 56 | 56 | private static final String DEFAULT_FOREGROUND_THREAD_POOL_EXECUTOR_QUEUE_LENGTH_NAME = "defaultforegroundthreadpoolexecutorqueuelength"; |
| 57 | + private static final String DEFAULT_BACKGROUND_THREAD_POOL_EXECUTOR_QUEUE_LENGTH_NONDELAYED_NAME = "defaultbackgroundthreadpoolexecutorqueuelengthnondelayed"; |
|
| 58 | + private static final String DEFAULT_FOREGROUND_THREAD_POOL_EXECUTOR_QUEUE_LENGTH_NONDELAYED_NAME = "defaultforegroundthreadpoolexecutorqueuelengthnondelayed"; |
|
| 57 | 59 | private Integer expeditionUdpPort; |
| 58 | 60 | private Integer igtimiRiotPort; |
| 59 | 61 | private Release release; |
| ... | ... | @@ -148,6 +150,18 @@ implements SailingAnalyticsProcess<ShardingKey> { |
| 148 | 150 | } |
| 149 | 151 | |
| 150 | 152 | @Override |
| 153 | + public int getDefaultBackgroundThreadPoolExecutorQueueSizeNondelayed(Optional<Duration> optionalTimeout) throws TimeoutException, Exception { |
|
| 154 | + final JSONObject status = getStatus(optionalTimeout); |
|
| 155 | + return ((Number) status.get(DEFAULT_BACKGROUND_THREAD_POOL_EXECUTOR_QUEUE_LENGTH_NONDELAYED_NAME)).intValue(); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + @Override |
|
| 159 | + public int getDefaultForegroundThreadPoolExecutorQueueSizeNondelayed(Optional<Duration> optionalTimeout) throws TimeoutException, Exception { |
|
| 160 | + final JSONObject status = getStatus(optionalTimeout); |
|
| 161 | + return ((Number) status.get(DEFAULT_FOREGROUND_THREAD_POOL_EXECUTOR_QUEUE_LENGTH_NONDELAYED_NAME)).intValue(); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + @Override |
|
| 151 | 165 | public Database getDatabaseConfiguration(Region region, Optional<Duration> optionalTimeout, |
| 152 | 166 | Optional<String> optionalKeyName, byte[] privateKeyEncryptionPassphrase) throws Exception { |
| 153 | 167 | final JSONObject mongoDBConfiguration = (JSONObject) getStatus(optionalTimeout).get(MONGODB_CONFIGURATION_PROPERTY_NAME); |