Skip to content

Commit becdd66

Browse files
committed
move prefetching stat names to StreamStatistics
1 parent 65f5ee7 commit becdd66

File tree

8 files changed

+108
-49
lines changed

8 files changed

+108
-49
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/StreamStatisticNames.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,46 @@ public final class StreamStatisticNames {
387387
public static final String BLOCKS_RELEASED
388388
= "blocks_released";
389389

390+
/**
391+
* Total number of prefetching operations executed.
392+
*/
393+
public static final String STREAM_READ_PREFETCH_OPERATIONS
394+
= "stream_read_prefetch_operations";
395+
396+
/**
397+
* Total number of block in disk cache.
398+
*/
399+
public static final String STREAM_READ_BLOCKS_IN_FILE_CACHE
400+
= "stream_read_blocks_in_cache";
401+
402+
/**
403+
* Total number of active prefetch operations.
404+
*/
405+
public static final String STREAM_READ_ACTIVE_PREFETCH_OPERATIONS
406+
= "stream_read_active_prefetch_operations";
407+
408+
/**
409+
* Total bytes of memory in use by this input stream.
410+
*/
411+
public static final String STREAM_READ_ACTIVE_MEMORY_IN_USE
412+
= "stream_read_active_memory_in_use";
413+
414+
/**
415+
* count/duration of reading a remote block.
416+
* IO.
417+
* Value: {@value}.
418+
*/
419+
public static final String STREAM_READ_REMOTE_BLOCK_READ
420+
= "stream_read_block_read";
421+
422+
/**
423+
* count/duration of acquiring a buffer and reading to it
424+
* IO.
425+
* Value: {@value}.
426+
*/
427+
public static final String STREAM_READ_BLOCK_ACQUIRE_AND_READ
428+
= "stream_read_block_read";
429+
390430
private StreamStatisticNames() {
391431
}
392432

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/Constants.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -674,46 +674,6 @@ private Constants() {
674674
public static final String STREAM_READ_GAUGE_INPUT_POLICY =
675675
"stream_read_gauge_input_policy";
676676

677-
/**
678-
* Total number of prefetching operations executed.
679-
*/
680-
public static final String STREAM_READ_PREFETCH_OPERATIONS
681-
= "stream_read_prefetch_operations";
682-
683-
/**
684-
* Total number of block in disk cache.
685-
*/
686-
public static final String STREAM_READ_BLOCKS_IN_FILE_CACHE
687-
= "stream_read_blocks_in_cache";
688-
689-
/**
690-
* Total number of active prefetch operations.
691-
*/
692-
public static final String STREAM_READ_ACTIVE_PREFETCH_OPERATIONS
693-
= "stream_read_active_prefetch_operations";
694-
695-
/**
696-
* Total bytes of memory in use by this input stream.
697-
*/
698-
public static final String STREAM_READ_ACTIVE_MEMORY_IN_USE
699-
= "stream_read_active_memory_in_use";
700-
701-
/**
702-
* count/duration of reading a remote block.
703-
* IO.
704-
* Value: {@value}.
705-
*/
706-
public static final String STREAM_READ_REMOTE_BLOCK_READ
707-
= "stream_read_block_read";
708-
709-
/**
710-
* count/duration of acquiring a buffer and reading to it
711-
* IO.
712-
* Value: {@value}.
713-
*/
714-
public static final String STREAM_READ_BLOCK_ACQUIRE_AND_READ
715-
= "stream_read_block_read";
716-
717677
@InterfaceAudience.Private
718678
@InterfaceStability.Unstable
719679
public static final String S3_CLIENT_FACTORY_IMPL =

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AInstrumentation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@
7272
import java.util.concurrent.atomic.AtomicInteger;
7373
import java.util.concurrent.atomic.AtomicLong;
7474

75-
import static org.apache.hadoop.fs.s3a.Constants.STREAM_READ_BLOCK_ACQUIRE_AND_READ;
7675
import static org.apache.hadoop.fs.s3a.Constants.STREAM_READ_GAUGE_INPUT_POLICY;
77-
import static org.apache.hadoop.fs.s3a.Constants.STREAM_READ_PREFETCH_OPERATIONS;
78-
import static org.apache.hadoop.fs.s3a.Constants.STREAM_READ_REMOTE_BLOCK_READ;
76+
import static org.apache.hadoop.fs.statistics.StreamStatisticNames.STREAM_READ_BLOCK_ACQUIRE_AND_READ;
77+
import static org.apache.hadoop.fs.statistics.StreamStatisticNames.STREAM_READ_PREFETCH_OPERATIONS;
78+
import static org.apache.hadoop.fs.statistics.StreamStatisticNames.STREAM_READ_REMOTE_BLOCK_READ;
7979
import static org.apache.hadoop.fs.statistics.IOStatisticsLogging.demandStringifyIOStatistics;
8080
import static org.apache.hadoop.fs.statistics.IOStatisticsSupport.snapshotIOStatistics;
8181
import static org.apache.hadoop.fs.statistics.StoreStatisticNames.ACTION_EXECUTOR_ACQUIRED;

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/Statistic.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,15 @@ public enum Statistic {
358358
"Total count of bytes read from an input stream",
359359
TYPE_COUNTER),
360360
STREAM_READ_BLOCKS_IN_FILE_CACHE(
361-
Constants.STREAM_READ_BLOCKS_IN_FILE_CACHE,
361+
StreamStatisticNames.STREAM_READ_BLOCKS_IN_FILE_CACHE,
362362
"Gauge of blocks in disk cache",
363363
TYPE_GAUGE),
364364
STREAM_READ_ACTIVE_PREFETCH_OPERATIONS(
365-
Constants.STREAM_READ_ACTIVE_PREFETCH_OPERATIONS,
365+
StreamStatisticNames.STREAM_READ_ACTIVE_PREFETCH_OPERATIONS,
366366
"Gauge of active prefetches",
367367
TYPE_GAUGE),
368368
STREAM_READ_ACTIVE_MEMORY_IN_USE(
369-
Constants.STREAM_READ_ACTIVE_MEMORY_IN_USE,
369+
StreamStatisticNames.STREAM_READ_ACTIVE_MEMORY_IN_USE,
370370
"Gauge of active memory in use",
371371
TYPE_GAUGE),
372372

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/read/S3CachingInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.apache.hadoop.fs.s3a.S3ObjectAttributes;
3434
import org.apache.hadoop.fs.s3a.statistics.S3AInputStreamStatistics;
3535

36-
import static org.apache.hadoop.fs.s3a.Constants.STREAM_READ_BLOCK_ACQUIRE_AND_READ;
36+
import static org.apache.hadoop.fs.statistics.StreamStatisticNames.STREAM_READ_BLOCK_ACQUIRE_AND_READ;
3737
import static org.apache.hadoop.fs.statistics.impl.IOStatisticsBinding.invokeTrackingDuration;
3838

3939
/**

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/read/S3Reader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.apache.hadoop.fs.s3a.Invoker;
3434
import org.apache.hadoop.fs.s3a.statistics.S3AInputStreamStatistics;
3535

36-
import static org.apache.hadoop.fs.s3a.Constants.STREAM_READ_REMOTE_BLOCK_READ;
36+
import static org.apache.hadoop.fs.statistics.StreamStatisticNames.STREAM_READ_REMOTE_BLOCK_READ;
3737
import static org.apache.hadoop.fs.statistics.impl.IOStatisticsBinding.trackDurationOfOperation;
3838

3939
/**
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.hadoop.fs.common;
21+
22+
import java.time.Duration;
23+
24+
public final class EmptyPrefetchingStatistics implements PrefetchingStatistics {
25+
@Override
26+
public void prefetchOperationStarted() {
27+
28+
}
29+
30+
@Override
31+
public void blockAddedToFileCache() {
32+
33+
}
34+
35+
@Override
36+
public void blockRemovedFromFileCache() {
37+
38+
}
39+
40+
@Override
41+
public void prefetchOperationCompleted() {
42+
43+
}
44+
45+
@Override
46+
public void executorAcquired(Duration timeInQueue) {
47+
48+
}
49+
50+
@Override
51+
public void memoryAllocated(int size) {
52+
53+
}
54+
55+
@Override
56+
public void memoryFreed(int size) {
57+
58+
}
59+
}

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/common/TestBlockCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class TestBlockCache extends AbstractHadoopTestBase {
4040
public void testArgChecks() throws Exception {
4141
// Should not throw.
4242
BlockCache cache =
43-
new SingleFilePerBlockCache(EmptyS3AStatisticsContext.EMPTY_INPUT_STREAM_STATISTICS);
43+
new SingleFilePerBlockCache(new EmptyPrefetchingStatistics());
4444

4545
ByteBuffer buffer = ByteBuffer.allocate(16);
4646

0 commit comments

Comments
 (0)