Skip to content

Commit

Permalink
Address comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinjia committed Feb 10, 2020
1 parent ab262c9 commit 1a4f762
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,12 @@ private synchronized byte[] readExternalPage(long pos) throws IOException {
private static final class Metrics {
/** Cache hits. */
private static final Counter BYTES_READ_CACHE =
MetricsSystem.counter(MetricKey.CACHE_BYTES_READ_CACHE.getName());
MetricsSystem.counter(MetricKey.CLIENT_CACHE_BYTES_READ_CACHE.getName());
/** Bytes read from external, may be larger than requests due to reading complete pages. */
private static final Counter BYTES_READ_EXTERNAL =
MetricsSystem.counter(MetricKey.CACHE_BYTES_READ_EXTERNAL.getName());
MetricsSystem.counter(MetricKey.CLIENT_CACHE_BYTES_READ_EXTERNAL.getName());
/** Cache misses. */
private static final Counter BYTES_REQUESTED_EXTERNAL =
MetricsSystem.counter(MetricKey.CACHE_BYTES_REQUESTED_EXTERNAL.getName());
MetricsSystem.counter(MetricKey.CLIENT_CACHE_BYTES_REQUESTED_EXTERNAL.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,20 @@ public void readPagesMetrics() throws Exception {
byte[] cacheMiss = new byte[readSize];
stream.read(cacheMiss);
Assert.assertEquals(0,
MetricsSystem.counter(MetricKey.CACHE_BYTES_READ_CACHE.getName()).getCount());
Assert.assertEquals(readSize,
MetricsSystem.counter(MetricKey.CACHE_BYTES_REQUESTED_EXTERNAL.getName()).getCount());
MetricsSystem.counter(MetricKey.CLIENT_CACHE_BYTES_READ_CACHE.getName()).getCount());
Assert.assertEquals(readSize, MetricsSystem.counter(
MetricKey.CLIENT_CACHE_BYTES_REQUESTED_EXTERNAL.getName()).getCount());
Assert.assertEquals(fileSize,
MetricsSystem.counter(MetricKey.CACHE_BYTES_READ_EXTERNAL.getName()).getCount());
MetricsSystem.counter(MetricKey.CLIENT_CACHE_BYTES_READ_EXTERNAL.getName()).getCount());

// cache hit
stream.read();
Assert.assertEquals(1,
MetricsSystem.counter(MetricKey.CACHE_BYTES_READ_CACHE.getName()).getCount());
Assert.assertEquals(readSize,
MetricsSystem.counter(MetricKey.CACHE_BYTES_REQUESTED_EXTERNAL.getName()).getCount());
MetricsSystem.counter(MetricKey.CLIENT_CACHE_BYTES_READ_CACHE.getName()).getCount());
Assert.assertEquals(readSize, MetricsSystem.counter(
MetricKey.CLIENT_CACHE_BYTES_REQUESTED_EXTERNAL.getName()).getCount());
Assert.assertEquals(fileSize,
MetricsSystem.counter(MetricKey.CACHE_BYTES_READ_EXTERNAL.getName()).getCount());
MetricsSystem.counter(MetricKey.CLIENT_CACHE_BYTES_READ_EXTERNAL.getName()).getCount());
}

private LocalCacheFileInStream setupWithSingleFile(byte[] data, CacheManager manager) {
Expand Down Expand Up @@ -483,6 +483,17 @@ public List<SyncPointInfo> getSyncPathList() throws IOException, AlluxioExceptio
}
}

@Override public FileInStream openFile(URIStatus status, OpenFilePOptions options)
throws FileDoesNotExistException, OpenDirectoryException, FileIncompleteException,
IOException, AlluxioException {
AlluxioURI path = new AlluxioURI(status.getPath());
if (mFiles.containsKey(path)) {
return new MockFileInStream(mFiles.get(path));
} else {
throw new FileDoesNotExistException(path);
}
}

@Override
public void persist(AlluxioURI path, ScheduleAsyncPersistencePOptions options)
throws FileDoesNotExistException, IOException, AlluxioException {
Expand Down
18 changes: 9 additions & 9 deletions core/common/src/main/java/alluxio/metrics/MetricKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -774,21 +774,21 @@ public MetricKey build() {
.setIsClusterAggregated(true)
.build();
// Client local cache metrics
public static final MetricKey CACHE_BYTES_READ_CACHE =
new Builder(Name.CACHE_BYTES_READ_CACHE)
public static final MetricKey CLIENT_CACHE_BYTES_READ_CACHE =
new Builder(Name.CLIENT_CACHE_BYTES_READ_CACHE)
.setDescription("Total number of bytes read from the Local Cache.")
.setMetricType(MetricType.COUNTER)
.setIsClusterAggregated(false)
.build();
public static final MetricKey CACHE_BYTES_READ_EXTERNAL =
new Builder(Name.CACHE_BYTES_READ_EXTERNAL)
public static final MetricKey CLIENT_CACHE_BYTES_READ_EXTERNAL =
new Builder(Name.CLIENT_CACHE_BYTES_READ_EXTERNAL)
.setDescription("Total number of bytes read from external storage due to a cache miss "
+ "on the local cache.")
.setMetricType(MetricType.COUNTER)
.setIsClusterAggregated(false)
.build();
public static final MetricKey CACHE_BYTES_REQUESTED_EXTERNAL =
new Builder(Name.CACHE_BYTES_REQUESTED_EXTERNAL)
public static final MetricKey CLIENT_CACHE_BYTES_REQUESTED_EXTERNAL =
new Builder(Name.CLIENT_CACHE_BYTES_REQUESTED_EXTERNAL)
.setDescription("Total number of bytes the user requested to read which resulted in a "
+ "cache miss. This number may be smaller than CacheBytesReadExternal due to chunk "
+ "reads.")
Expand Down Expand Up @@ -989,9 +989,9 @@ public static final class Name {
public static final String CLIENT_BYTES_WRITTEN_UFS = "Client.BytesWrittenUfs";

// Client local cache metrics
public static final String CACHE_BYTES_READ_CACHE = "Client.CacheBytesReadCache";
public static final String CACHE_BYTES_READ_EXTERNAL = "Client.CacheBytesReadExternal";
public static final String CACHE_BYTES_REQUESTED_EXTERNAL
public static final String CLIENT_CACHE_BYTES_READ_CACHE = "Client.CacheBytesReadCache";
public static final String CLIENT_CACHE_BYTES_READ_EXTERNAL = "Client.CacheBytesReadExternal";
public static final String CLIENT_CACHE_BYTES_REQUESTED_EXTERNAL
= "Client.CacheBytesRequestedExternal";

private Name() {} // prevent instantiation
Expand Down

0 comments on commit 1a4f762

Please sign in to comment.