Skip to content

Commit 4cffbd3

Browse files
committed
Remove line length violations in o.e.indices package (#35647)
Relates to #34884
1 parent 971f354 commit 4cffbd3

36 files changed

+604
-309
lines changed

buildSrc/src/main/resources/checkstyle_suppressions.xml

-36
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,6 @@
129129
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]translog[/\\]TranslogReader.java" checks="LineLength" />
130130
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]translog[/\\]TranslogSnapshot.java" checks="LineLength" />
131131
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]translog[/\\]TranslogWriter.java" checks="LineLength" />
132-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]IndexingMemoryController.java" checks="LineLength" />
133-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]IndicesService.java" checks="LineLength" />
134-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]analysis[/\\]PreBuiltCacheFactory.java" checks="LineLength" />
135-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]breaker[/\\]HierarchyCircuitBreakerService.java" checks="LineLength" />
136-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]flush[/\\]ShardsSyncedFlushResult.java" checks="LineLength" />
137-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]flush[/\\]SyncedFlushService.java" checks="LineLength" />
138-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]recovery[/\\]PeerRecoverySourceService.java" checks="LineLength" />
139-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]recovery[/\\]RecoveryFailedException.java" checks="LineLength" />
140-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]recovery[/\\]RecoverySettings.java" checks="LineLength" />
141-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]recovery[/\\]RecoveryState.java" checks="LineLength" />
142-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]store[/\\]IndicesStore.java" checks="LineLength" />
143-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]store[/\\]TransportNodesListShardStoreMetaData.java" checks="LineLength" />
144132
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]monitor[/\\]jvm[/\\]GcNames.java" checks="LineLength" />
145133
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]monitor[/\\]jvm[/\\]HotThreads.java" checks="LineLength" />
146134
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]node[/\\]Node.java" checks="LineLength" />
@@ -256,30 +244,6 @@
256244
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]translog[/\\]TranslogTests.java" checks="LineLength" />
257245
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indexing[/\\]IndexActionIT.java" checks="LineLength" />
258246
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indexlifecycle[/\\]IndexLifecycleActionIT.java" checks="LineLength" />
259-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]IndexingMemoryControllerTests.java" checks="LineLength" />
260-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]IndicesLifecycleListenerIT.java" checks="LineLength" />
261-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]IndicesOptionsIntegrationIT.java" checks="LineLength" />
262-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]analyze[/\\]AnalyzeActionIT.java" checks="LineLength" />
263-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]exists[/\\]types[/\\]TypesExistsIT.java" checks="LineLength" />
264-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]flush[/\\]FlushIT.java" checks="LineLength" />
265-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]flush[/\\]SyncedFlushSingleNodeTests.java" checks="LineLength" />
266-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]flush[/\\]SyncedFlushUtil.java" checks="LineLength" />
267-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]mapping[/\\]ConcurrentDynamicTemplateIT.java" checks="LineLength" />
268-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]mapping[/\\]SimpleGetFieldMappingsIT.java" checks="LineLength" />
269-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]mapping[/\\]SimpleGetMappingsIT.java" checks="LineLength" />
270-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]mapping[/\\]UpdateMappingIntegrationIT.java" checks="LineLength" />
271-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]memory[/\\]breaker[/\\]CircuitBreakerUnitTests.java" checks="LineLength" />
272-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]memory[/\\]breaker[/\\]RandomExceptionCircuitBreakerIT.java" checks="LineLength" />
273-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]recovery[/\\]IndexPrimaryRelocationIT.java" checks="LineLength" />
274-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]recovery[/\\]IndexRecoveryIT.java" checks="LineLength" />
275-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]recovery[/\\]RecoverySourceHandlerTests.java" checks="LineLength" />
276-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]recovery[/\\]RecoveryStatusTests.java" checks="LineLength" />
277-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]settings[/\\]UpdateNumberOfReplicasIT.java" checks="LineLength" />
278-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]state[/\\]OpenCloseIndexIT.java" checks="LineLength" />
279-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]state[/\\]RareClusterStateIT.java" checks="LineLength" />
280-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]stats[/\\]IndexStatsIT.java" checks="LineLength" />
281-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]store[/\\]IndicesStoreIntegrationIT.java" checks="LineLength" />
282-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indices[/\\]store[/\\]IndicesStoreTests.java" checks="LineLength" />
283247
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]monitor[/\\]jvm[/\\]JvmGcMonitorServiceSettingsTests.java" checks="LineLength" />
284248
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]plugins[/\\]PluginsServiceTests.java" checks="LineLength" />
285249
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]recovery[/\\]FullRollingRestartIT.java" checks="LineLength" />

server/src/main/java/org/elasticsearch/indices/IndexingMemoryController.java

+43-26
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,37 @@ public class IndexingMemoryController extends AbstractComponent implements Index
5454
public static final Setting<ByteSizeValue> INDEX_BUFFER_SIZE_SETTING =
5555
Setting.memorySizeSetting("indices.memory.index_buffer_size", "10%", Property.NodeScope);
5656

57-
/** Only applies when <code>indices.memory.index_buffer_size</code> is a %, to set a floor on the actual size in bytes (default: 48 MB). */
58-
public static final Setting<ByteSizeValue> MIN_INDEX_BUFFER_SIZE_SETTING = Setting.byteSizeSetting("indices.memory.min_index_buffer_size",
59-
new ByteSizeValue(48, ByteSizeUnit.MB),
60-
new ByteSizeValue(0, ByteSizeUnit.BYTES),
61-
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
62-
Property.NodeScope);
63-
64-
/** Only applies when <code>indices.memory.index_buffer_size</code> is a %, to set a ceiling on the actual size in bytes (default: not set). */
65-
public static final Setting<ByteSizeValue> MAX_INDEX_BUFFER_SIZE_SETTING = Setting.byteSizeSetting("indices.memory.max_index_buffer_size",
66-
new ByteSizeValue(-1),
67-
new ByteSizeValue(-1),
68-
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
69-
Property.NodeScope);
70-
71-
/** If we see no indexing operations after this much time for a given shard, we consider that shard inactive (default: 5 minutes). */
72-
public static final Setting<TimeValue> SHARD_INACTIVE_TIME_SETTING = Setting.positiveTimeSetting("indices.memory.shard_inactive_time", TimeValue.timeValueMinutes(5), Property.NodeScope);
57+
/** Only applies when <code>indices.memory.index_buffer_size</code> is a %,
58+
* to set a floor on the actual size in bytes (default: 48 MB). */
59+
public static final Setting<ByteSizeValue> MIN_INDEX_BUFFER_SIZE_SETTING = Setting.byteSizeSetting(
60+
"indices.memory.min_index_buffer_size",
61+
new ByteSizeValue(48, ByteSizeUnit.MB),
62+
new ByteSizeValue(0, ByteSizeUnit.BYTES),
63+
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
64+
Property.NodeScope);
65+
66+
/** Only applies when <code>indices.memory.index_buffer_size</code> is a %,
67+
* to set a ceiling on the actual size in bytes (default: not set). */
68+
public static final Setting<ByteSizeValue> MAX_INDEX_BUFFER_SIZE_SETTING = Setting.byteSizeSetting(
69+
"indices.memory.max_index_buffer_size",
70+
new ByteSizeValue(-1),
71+
new ByteSizeValue(-1),
72+
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
73+
Property.NodeScope);
74+
75+
/** If we see no indexing operations after this much time for a given shard,
76+
* we consider that shard inactive (default: 5 minutes). */
77+
public static final Setting<TimeValue> SHARD_INACTIVE_TIME_SETTING = Setting.positiveTimeSetting(
78+
"indices.memory.shard_inactive_time",
79+
TimeValue.timeValueMinutes(5),
80+
Property.NodeScope
81+
);
7382

7483
/** How frequently we check indexing memory usage (default: 5 seconds). */
75-
public static final Setting<TimeValue> SHARD_MEMORY_INTERVAL_TIME_SETTING = Setting.positiveTimeSetting("indices.memory.interval", TimeValue.timeValueSeconds(5), Property.NodeScope);
84+
public static final Setting<TimeValue> SHARD_MEMORY_INTERVAL_TIME_SETTING = Setting.positiveTimeSetting(
85+
"indices.memory.interval",
86+
TimeValue.timeValueSeconds(5),
87+
Property.NodeScope);
7688

7789
private final ThreadPool threadPool;
7890

@@ -248,10 +260,11 @@ public void bytesWritten(int bytes) {
248260
totalBytes = bytesWrittenSinceCheck.get();
249261
if (totalBytes > indexingBuffer.getBytes()/30) {
250262
bytesWrittenSinceCheck.addAndGet(-totalBytes);
251-
// NOTE: this is only an approximate check, because bytes written is to the translog, vs indexing memory buffer which is
252-
// typically smaller but can be larger in extreme cases (many unique terms). This logic is here only as a safety against
253-
// thread starvation or too infrequent checking, to ensure we are still checking periodically, in proportion to bytes
254-
// processed by indexing:
263+
// NOTE: this is only an approximate check, because bytes written is to the translog,
264+
// vs indexing memory buffer which is typically smaller but can be larger in extreme
265+
// cases (many unique terms). This logic is here only as a safety against thread
266+
// starvation or too infrequent checking, to ensure we are still checking periodically,
267+
// in proportion to bytes processed by indexing:
255268
runUnlocked();
256269
}
257270
} finally {
@@ -310,7 +323,8 @@ private void runUnlocked() {
310323

311324
if (logger.isTraceEnabled()) {
312325
logger.trace("total indexing heap bytes used [{}] vs {} [{}], currently writing bytes [{}]",
313-
new ByteSizeValue(totalBytesUsed), INDEX_BUFFER_SIZE_SETTING.getKey(), indexingBuffer, new ByteSizeValue(totalBytesWriting));
326+
new ByteSizeValue(totalBytesUsed), INDEX_BUFFER_SIZE_SETTING.getKey(), indexingBuffer,
327+
new ByteSizeValue(totalBytesWriting));
314328
}
315329

316330
// If we are using more than 50% of our budget across both indexing buffer and bytes we are still moving to disk, then we now
@@ -340,7 +354,8 @@ private void runUnlocked() {
340354
if (shardBytesUsed > 0) {
341355
if (logger.isTraceEnabled()) {
342356
if (shardWritingBytes != 0) {
343-
logger.trace("shard [{}] is using [{}] heap, writing [{}] heap", shard.shardId(), shardBytesUsed, shardWritingBytes);
357+
logger.trace("shard [{}] is using [{}] heap, writing [{}] heap", shard.shardId(), shardBytesUsed,
358+
shardWritingBytes);
344359
} else {
345360
logger.trace("shard [{}] is using [{}] heap, not writing any bytes", shard.shardId(), shardBytesUsed);
346361
}
@@ -349,12 +364,14 @@ private void runUnlocked() {
349364
}
350365
}
351366

352-
logger.debug("now write some indexing buffers: total indexing heap bytes used [{}] vs {} [{}], currently writing bytes [{}], [{}] shards with non-zero indexing buffer",
353-
new ByteSizeValue(totalBytesUsed), INDEX_BUFFER_SIZE_SETTING.getKey(), indexingBuffer, new ByteSizeValue(totalBytesWriting), queue.size());
367+
logger.debug("now write some indexing buffers: total indexing heap bytes used [{}] vs {} [{}], " +
368+
"currently writing bytes [{}], [{}] shards with non-zero indexing buffer", new ByteSizeValue(totalBytesUsed),
369+
INDEX_BUFFER_SIZE_SETTING.getKey(), indexingBuffer, new ByteSizeValue(totalBytesWriting), queue.size());
354370

355371
while (totalBytesUsed > indexingBuffer.getBytes() && queue.isEmpty() == false) {
356372
ShardAndBytesUsed largest = queue.poll();
357-
logger.debug("write indexing buffer to disk for shard [{}] to free up its [{}] indexing buffer", largest.shard.shardId(), new ByteSizeValue(largest.bytesUsed));
373+
logger.debug("write indexing buffer to disk for shard [{}] to free up its [{}] indexing buffer",
374+
largest.shard.shardId(), new ByteSizeValue(largest.bytesUsed));
358375
writeIndexingBufferAsync(largest.shard);
359376
totalBytesUsed -= largest.bytesUsed;
360377
if (doThrottle && throttled.contains(largest.shard) == false) {

0 commit comments

Comments
 (0)