|
9 | 9 | package org.elasticsearch.cluster.service; |
10 | 10 |
|
11 | 11 | import org.apache.logging.log4j.Logger; |
| 12 | +import org.elasticsearch.common.Strings; |
12 | 13 | import org.elasticsearch.core.Nullable; |
13 | 14 | import org.elasticsearch.common.Priority; |
14 | 15 | import org.elasticsearch.core.TimeValue; |
@@ -131,14 +132,28 @@ void runIfNotProcessed(BatchedTask updateTask) { |
131 | 132 | } |
132 | 133 |
|
133 | 134 | if (toExecute.isEmpty() == false) { |
134 | | - final String tasksSummary = processTasksBySource.entrySet().stream().map(entry -> { |
| 135 | + run(updateTask.batchingKey, toExecute, buildTasksDescription(updateTask, toExecute, processTasksBySource)); |
| 136 | + } |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + private static final int MAX_TASK_DESCRIPTION_CHARS = 8 * 1024; |
| 141 | + |
| 142 | + private String buildTasksDescription(BatchedTask updateTask, |
| 143 | + List<BatchedTask> toExecute, |
| 144 | + Map<String, List<BatchedTask>> processTasksBySource) { |
| 145 | + final StringBuilder output = new StringBuilder(); |
| 146 | + Strings.collectionToDelimitedStringWithLimit( |
| 147 | + (Iterable<String>) () -> processTasksBySource.entrySet().stream().map(entry -> { |
135 | 148 | String tasks = updateTask.describeTasks(entry.getValue()); |
136 | 149 | return tasks.isEmpty() ? entry.getKey() : entry.getKey() + "[" + tasks + "]"; |
137 | | - }).reduce((s1, s2) -> s1 + ", " + s2).orElse(""); |
138 | | - |
139 | | - run(updateTask.batchingKey, toExecute, tasksSummary); |
140 | | - } |
| 150 | + }).filter(s -> s.isEmpty() == false).iterator(), |
| 151 | + ", ", "", "", MAX_TASK_DESCRIPTION_CHARS, output |
| 152 | + ); |
| 153 | + if (output.length() > MAX_TASK_DESCRIPTION_CHARS) { |
| 154 | + output.append(" (").append(toExecute.size()).append(" tasks in total)"); |
141 | 155 | } |
| 156 | + return output.toString(); |
142 | 157 | } |
143 | 158 |
|
144 | 159 | /** |
|
0 commit comments