Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,20 @@ private class HistoryServerDiskManager(
* being used so that it's not evicted when running out of designated space.
*/
def openStore(appId: String, attemptId: Option[String]): Option[File] = {
var newSize: Long = 0
val storePath = active.synchronized {
val path = appStorePath(appId, attemptId)
if (path.isDirectory()) {
active(appId -> attemptId) = sizeOf(path)
newSize = sizeOf(path)
active(appId -> attemptId) = newSize
Some(path)
} else {
None
}
}

storePath.foreach { path =>
updateAccessTime(appId, attemptId)
updateApplicationStoreInfo(appId, attemptId, newSize)
}

storePath
Expand Down Expand Up @@ -238,10 +240,11 @@ private class HistoryServerDiskManager(
new File(appStoreDir, fileName)
}

private def updateAccessTime(appId: String, attemptId: Option[String]): Unit = {
private def updateApplicationStoreInfo(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function updates both the lastAccess time and the size, so it would be better to rename to updateApplicationStoreInfo.

appId: String, attemptId: Option[String], newSize: Long): Unit = {
val path = appStorePath(appId, attemptId)
val info = ApplicationStoreInfo(path.getAbsolutePath(), clock.getTimeMillis(), appId, attemptId,
sizeOf(path))
val info = ApplicationStoreInfo(path.getAbsolutePath(), clock.getTimeMillis(), appId,
attemptId, newSize)
listing.write(info)
}

Expand Down Expand Up @@ -297,7 +300,7 @@ private class HistoryServerDiskManager(
s"exceeded ($current > $max)")
}

updateAccessTime(appId, attemptId)
updateApplicationStoreInfo(appId, attemptId, newSize)

active.synchronized {
active(appId -> attemptId) = newSize
Expand Down