Skip to content

Commit 0020cfe

Browse files
review improvements
1 parent 6f8471c commit 0020cfe

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/AllocationBalancingRoundSummaryService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class AllocationBalancingRoundSummaryService {
4343
Setting.Property.Dynamic
4444
);
4545

46-
/** Controls how frequently in time balancer round summaries are logged. If less than zero, effectively disables reporting. */
46+
/** Controls how frequently in time balancer round summaries are logged. */
4747
public static final Setting<TimeValue> BALANCER_ROUND_SUMMARIES_LOG_INTERVAL_SETTING = Setting.timeSetting(
4848
"cluster.routing.allocation.desired_balance.balanace_round_summaries_interval",
4949
TimeValue.timeValueSeconds(10),
@@ -61,10 +61,10 @@ public class AllocationBalancingRoundSummaryService {
6161
* A concurrency-safe list of balancing round summaries. Balancer rounds are run and added here serially, so the queue will naturally
6262
* progress from newer to older results.
6363
*/
64-
private ConcurrentLinkedQueue<BalancingRoundSummary> summaries = new ConcurrentLinkedQueue<>();
64+
private final ConcurrentLinkedQueue<BalancingRoundSummary> summaries = new ConcurrentLinkedQueue<>();
6565

6666
/** This reference is set when reporting is scheduled. If it is null, then reporting is inactive. */
67-
private AtomicReference<Scheduler.Cancellable> scheduledReportFuture = new AtomicReference<>();
67+
private final AtomicReference<Scheduler.Cancellable> scheduledReportFuture = new AtomicReference<>();
6868

6969
public AllocationBalancingRoundSummaryService(ThreadPool threadPool, ClusterSettings clusterSettings) {
7070
this.threadPool = threadPool;

server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/AllocationBalancingRoundSummaryServiceTests.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
public class AllocationBalancingRoundSummaryServiceTests extends ESTestCase {
2525
private static final Logger logger = LogManager.getLogger(AllocationBalancingRoundSummaryServiceTests.class);
2626

27+
private static final String BALANCING_SUMMARY_MSG_PREFIX = "Balancing round summaries:*";
28+
2729
final Settings enabledSummariesSettings = Settings.builder()
2830
.put(AllocationBalancingRoundSummaryService.ENABLE_BALANCER_ROUND_SUMMARIES_SETTING.getKey(), true)
2931
.build();
@@ -73,10 +75,13 @@ public void testServiceDisabledByDefault() {
7375
"Running balancer summary logging",
7476
AllocationBalancingRoundSummaryService.class.getName(),
7577
Level.INFO,
76-
"Balancing round summaries:*"
78+
"*"
7779
)
7880
);
7981

82+
if (deterministicTaskQueue.hasDeferredTasks()) {
83+
deterministicTaskQueue.advanceTime();
84+
}
8085
deterministicTaskQueue.runAllRunnableTasks();
8186
mockLog.awaitAllExpectationsMatched();
8287
service.verifyNumberOfSummaries(0);
@@ -98,7 +103,7 @@ public void testEnabledService() {
98103
"Running balancer summary logging",
99104
AllocationBalancingRoundSummaryService.class.getName(),
100105
Level.INFO,
101-
"Balancing round summaries:*"
106+
BALANCING_SUMMARY_MSG_PREFIX
102107
)
103108
);
104109

@@ -118,7 +123,7 @@ public void testEnabledService() {
118123
"Running balancer summary logging a second time",
119124
AllocationBalancingRoundSummaryService.class.getName(),
120125
Level.INFO,
121-
"Balancing round summaries:*"
126+
BALANCING_SUMMARY_MSG_PREFIX
122127
)
123128
);
124129

@@ -173,7 +178,7 @@ public void testNoSummariesToReport() {
173178
"Running balancer summary logging of combined summaries",
174179
AllocationBalancingRoundSummaryService.class.getName(),
175180
Level.INFO,
176-
"Balancing round summaries:*"
181+
BALANCING_SUMMARY_MSG_PREFIX
177182
)
178183
);
179184

@@ -191,7 +196,7 @@ public void testNoSummariesToReport() {
191196
"No balancer round summary to log",
192197
AllocationBalancingRoundSummaryService.class.getName(),
193198
Level.INFO,
194-
"Balancing round summaries:*"
199+
"*"
195200
)
196201
);
197202

@@ -238,7 +243,7 @@ public void testEnableAndThenDisableService() {
238243
"Running balancer summary logging",
239244
AllocationBalancingRoundSummaryService.class.getName(),
240245
Level.INFO,
241-
"Balancing round summaries:*"
246+
"*"
242247
)
243248
);
244249
deterministicTaskQueue.advanceTime();

0 commit comments

Comments
 (0)