You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CacheEntry.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. package org.apache.archiva.rest.api.model;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import javax.xml.bind.annotation.XmlRootElement;
  21. import java.io.Serializable;
  22. /**
  23. * @author Olivier Lamy
  24. * @since 1.4-M3
  25. */
  26. @XmlRootElement(name = "cacheEntry")
  27. public class CacheEntry
  28. implements Serializable, Comparable
  29. {
  30. private String key;
  31. private long size;
  32. private long cacheHits;
  33. private long cacheMiss;
  34. private String cacheHitRate;
  35. private long inMemorySize;
  36. public CacheEntry()
  37. {
  38. // no op
  39. }
  40. public CacheEntry( String key, long size, long cacheHits, long cacheMiss, String cacheHitRate, long inMemorySize )
  41. {
  42. this.key = key;
  43. this.size = size;
  44. this.cacheHits = cacheHits;
  45. this.cacheMiss = cacheMiss;
  46. this.cacheHitRate = cacheHitRate;
  47. // size is in bytes so use kb
  48. this.inMemorySize = inMemorySize / 1024;
  49. }
  50. public String getKey()
  51. {
  52. return key;
  53. }
  54. public void setKey( String key )
  55. {
  56. this.key = key;
  57. }
  58. public long getSize()
  59. {
  60. return size;
  61. }
  62. public void setSize( long size )
  63. {
  64. this.size = size;
  65. }
  66. public long getCacheHits()
  67. {
  68. return cacheHits;
  69. }
  70. public void setCacheHits( long cacheHits )
  71. {
  72. this.cacheHits = cacheHits;
  73. }
  74. public long getCacheMiss()
  75. {
  76. return cacheMiss;
  77. }
  78. public void setCacheMiss( long cacheMiss )
  79. {
  80. this.cacheMiss = cacheMiss;
  81. }
  82. public String getCacheHitRate()
  83. {
  84. return cacheHitRate;
  85. }
  86. public void setCacheHitRate( String cacheHitRate )
  87. {
  88. this.cacheHitRate = cacheHitRate;
  89. }
  90. /**
  91. * @return cache size in kb
  92. */
  93. public long getInMemorySize()
  94. {
  95. return inMemorySize;
  96. }
  97. public void setInMemorySize( long inMemorySize )
  98. {
  99. this.inMemorySize = inMemorySize;
  100. }
  101. @Override
  102. public int compareTo( Object o )
  103. {
  104. return this.key.compareTo( ( (CacheEntry) o ).key );
  105. }
  106. @Override
  107. public boolean equals( Object o )
  108. {
  109. if ( this == o )
  110. {
  111. return true;
  112. }
  113. if ( o == null || getClass() != o.getClass() )
  114. {
  115. return false;
  116. }
  117. CacheEntry that = (CacheEntry) o;
  118. if ( !key.equals( that.key ) )
  119. {
  120. return false;
  121. }
  122. return true;
  123. }
  124. @Override
  125. public int hashCode()
  126. {
  127. return key.hashCode();
  128. }
  129. @Override
  130. public String toString()
  131. {
  132. final StringBuilder sb = new StringBuilder();
  133. sb.append( "CacheEntry" );
  134. sb.append( "{key='" ).append( key ).append( '\'' );
  135. sb.append( ", size=" ).append( size );
  136. sb.append( ", cacheHits=" ).append( cacheHits );
  137. sb.append( ", cacheMiss=" ).append( cacheMiss );
  138. sb.append( ", cacheHitRate='" ).append( cacheHitRate ).append( '\'' );
  139. sb.append( ", inMemorySize=" ).append( inMemorySize );
  140. sb.append( '}' );
  141. return sb.toString();
  142. }
  143. }