dineshchitlangia commented on a change in pull request #178: HDDS-2498. Fix
sonar issues found in StorageContainerManager.
URL: https://github.com/apache/hadoop-ozone/pull/178#discussion_r348299003
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java
##########
@@ -675,31 +671,28 @@ public SCMSecurityProtocolServer
getSecurityProtocolServer() {
/**
* Initialize container reports cache that sent from datanodes.
- *
- * @param conf
*/
- private void initContainerReportCache(OzoneConfiguration conf) {
- containerReportCache =
+ @SuppressWarnings("UnstableApiUsage")
+ private Cache<String, ContainerStat> buildContainerReportCache() {
+ return
CacheBuilder.newBuilder()
.expireAfterAccess(Long.MAX_VALUE, TimeUnit.MILLISECONDS)
.maximumSize(Integer.MAX_VALUE)
- .removalListener(
- new RemovalListener<String, ContainerStat>() {
- @Override
- public void onRemoval(
- RemovalNotification<String, ContainerStat>
- removalNotification) {
- synchronized (containerReportCache) {
- ContainerStat stat = removalNotification.getValue();
- // remove invalid container report
- metrics.decrContainerStat(stat);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Remove expired container stat entry for " +
- "datanode: {}.", removalNotification.getKey());
- }
- }
- }
- })
+ .removalListener((
+ RemovalListener<String, ContainerStat>) removalNotification ->
{
+ synchronized (containerReportCache) {
+ ContainerStat stat = removalNotification.getValue();
+ if (stat != null) {
+ // TODO: Are we doing the right thing here?
+ // remove invalid container report
+ metrics.decrContainerStat(stat);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Remove expired container stat entry for " +
+ "datanode: {}.", removalNotification.getKey());
+ }
+ }
+ })
Review comment:
L682 - L694 : Checkstyle issue regarding incorrect indentation
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]