Skip to content

Commit

Permalink
SPDI-54500. Backport Fix metrics Worker.ActiveClients counter error A…
Browse files Browse the repository at this point in the history
…lluxio#14088

Fix metrics Worker.ActiveClients counter error

Fix metrics Worker.ActiveClients counter error

When executing end-to-end test: allxuio runTest --readType NO_CACHE
--writeType THROUGH. the counter metric Worker.ActiveClients.xxx will
change to 2 instead of 0.

No

pr-link: Alluxio#14088
change-id: cid-9bfb67ba59896c03827a0bc8c84901f931a41ba6
  • Loading branch information
xichen01 authored and tianbao.ding committed Aug 8, 2022
1 parent 1e07969 commit 354382f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,13 @@ public void closeUfsBlock(long sessionId, long blockId)
// the sessionId.
LOG.debug("Invalid worker state while committing block.", e);
}
} else {
// When getTempBlockMeta() return null, such as a block readType NO_CACHE writeType THROUGH.
// Counter will not be decrement in the commitblock().
// So we should decrement counter here.
if (mUnderFileSystemBlockStore.isNoCache(sessionId, blockId)) {
Metrics.WORKER_ACTIVE_CLIENTS.dec();
}
}
} finally {
mUnderFileSystemBlockStore.releaseAccess(sessionId, blockId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ public BlockReader getBlockReader(final long sessionId, long blockId, long offse
return reader;
}

/**
* @param sessionId the session ID
* @param blockId the block ID
* @return true if mNoCache is set
*/
public boolean isNoCache(long sessionId, long blockId) {
Key key = new Key(sessionId, blockId);
BlockInfo blockInfo = mBlocks.get(key);
UnderFileSystemBlockMeta mMeta = blockInfo.getMeta();
return mMeta.isNoCache();
}

/**
* Gets the {@link UnderFileSystemBlockMeta} for a session ID and block ID pair.
*
Expand Down

0 comments on commit 354382f

Please sign in to comment.