forked from Alluxio/alluxio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What changes are proposed in this pull request? Please outline the changes and how this PR fixes the issue. modify the calculation method for cacheMissPercentage metric, ensuring it comprehensively accounts for the influence of job worker read operations. Alluxio#16945 ### Why are the changes needed? Because of the incorrect calculation results of this metric, it may produce exception value. ### Does this PR introduce any user facing changes? No pr-link: Alluxio#18208 change-id: cid-d24a6f324f7148cab4a30fbbf819510a1a314ebc
- Loading branch information
1 parent
59b1ce6
commit f07e66f
Showing
12 changed files
with
188 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
core/server/worker/src/main/java/alluxio/worker/block/io/MetricAccountingBlockReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 | ||
* (the "License"). You may not use this work except in compliance with the License, which is | ||
* available at www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied, as more fully set forth in the License. | ||
* | ||
* See the NOTICE file distributed with this work for information regarding copyright ownership. | ||
*/ | ||
|
||
package alluxio.worker.block.io; | ||
|
||
import alluxio.metrics.MetricKey; | ||
import alluxio.metrics.MetricsSystem; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
import java.nio.channels.ReadableByteChannel; | ||
|
||
/** | ||
* An reader class with metrics. | ||
*/ | ||
public class MetricAccountingBlockReader extends BlockReader { | ||
private final LocalFileBlockReader mBlockReader; | ||
|
||
/** | ||
* A decorator of BlockReader. | ||
* @param mblockReader block reader | ||
*/ | ||
public MetricAccountingBlockReader(LocalFileBlockReader mblockReader) { | ||
mBlockReader = mblockReader; | ||
} | ||
|
||
@Override | ||
public ByteBuffer read(long offset, long length) throws IOException { | ||
ByteBuffer buffer = mBlockReader.read(offset, length); | ||
int bytesReadFromCache = buffer.limit() - buffer.position(); | ||
MetricsSystem.counter(MetricKey.WORKER_BYTES_READ_CACHE.getName()).inc(bytesReadFromCache); | ||
return buffer; | ||
} | ||
|
||
@Override | ||
public long getLength() { | ||
return mBlockReader.getLength(); | ||
} | ||
|
||
@Override | ||
public ReadableByteChannel getChannel() { | ||
return new ReadableByteChannel() { | ||
private final ReadableByteChannel mDelegate = mBlockReader.getChannel(); | ||
@Override | ||
public int read(ByteBuffer dst) throws IOException { | ||
int bytesRead = mDelegate.read(dst); | ||
if (bytesRead != -1) { | ||
MetricsSystem.counter(MetricKey.WORKER_BYTES_READ_CACHE.getName()).inc(bytesRead); | ||
} | ||
return bytesRead; | ||
} | ||
|
||
@Override | ||
public boolean isOpen() { | ||
return mDelegate.isOpen(); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
mDelegate.close(); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public int transferTo(ByteBuf buf) throws IOException { | ||
int bytesReadFromCache = mBlockReader.transferTo(buf); | ||
if (bytesReadFromCache != -1) { | ||
MetricsSystem.counter(MetricKey.WORKER_BYTES_READ_CACHE.getName()).inc(bytesReadFromCache); | ||
} | ||
return bytesReadFromCache; | ||
} | ||
|
||
@Override | ||
public boolean isClosed() { | ||
return mBlockReader.isClosed(); | ||
} | ||
|
||
@Override | ||
public String getLocation() { | ||
return mBlockReader.getLocation(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return mBlockReader.toString(); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
mBlockReader.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters