001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.apache.hadoop.hdfs.protocol; 020 021import org.apache.hadoop.classification.InterfaceAudience; 022import org.apache.hadoop.classification.InterfaceStability; 023 024/** 025 * CachePoolStats describes cache pool statistics. 026 */ 027@InterfaceAudience.Public 028@InterfaceStability.Evolving 029public class CachePoolStats { 030 public static class Builder { 031 private long bytesNeeded; 032 private long bytesCached; 033 private long bytesOverlimit; 034 private long filesNeeded; 035 private long filesCached; 036 037 public Builder() { 038 } 039 040 public Builder setBytesNeeded(long bytesNeeded) { 041 this.bytesNeeded = bytesNeeded; 042 return this; 043 } 044 045 public Builder setBytesCached(long bytesCached) { 046 this.bytesCached = bytesCached; 047 return this; 048 } 049 050 public Builder setBytesOverlimit(long bytesOverlimit) { 051 this.bytesOverlimit = bytesOverlimit; 052 return this; 053 } 054 055 public Builder setFilesNeeded(long filesNeeded) { 056 this.filesNeeded = filesNeeded; 057 return this; 058 } 059 060 public Builder setFilesCached(long filesCached) { 061 this.filesCached = filesCached; 062 return this; 063 } 064 065 public CachePoolStats build() { 066 return new CachePoolStats(bytesNeeded, bytesCached, bytesOverlimit, 067 filesNeeded, filesCached); 068 } 069 }; 070 071 private final long bytesNeeded; 072 private final long bytesCached; 073 private final long bytesOverlimit; 074 private final long filesNeeded; 075 private final long filesCached; 076 077 private CachePoolStats(long bytesNeeded, long bytesCached, 078 long bytesOverlimit, long filesNeeded, long filesCached) { 079 this.bytesNeeded = bytesNeeded; 080 this.bytesCached = bytesCached; 081 this.bytesOverlimit = bytesOverlimit; 082 this.filesNeeded = filesNeeded; 083 this.filesCached = filesCached; 084 } 085 086 public long getBytesNeeded() { 087 return bytesNeeded; 088 } 089 090 public long getBytesCached() { 091 return bytesCached; 092 } 093 094 public long getBytesOverlimit() { 095 return bytesOverlimit; 096 } 097 098 public long getFilesNeeded() { 099 return filesNeeded; 100 } 101 102 public long getFilesCached() { 103 return filesCached; 104 } 105 106 public String toString() { 107 return new StringBuilder().append("{"). 108 append("bytesNeeded:").append(bytesNeeded). 109 append(", bytesCached:").append(bytesCached). 110 append(", bytesOverlimit:").append(bytesOverlimit). 111 append(", filesNeeded:").append(filesNeeded). 112 append(", filesCached:").append(filesCached). 113 append("}").toString(); 114 } 115}