1 /***
2 * Copyright 2003-2010 Terracotta, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package net.sf.ehcache.pool.impl;
18
19 import net.sf.ehcache.pool.PoolableStore;
20
21 /***
22 * Balanced access evictor that makes on-heap eviction decisions.
23 *
24 * @author Chris Dennis
25 */
26 public class BalancedAccessOnHeapPoolEvictor extends AbstractBalancedAccessEvictor<PoolableStore> {
27
28 /***
29 * {@inheritDoc}
30 */
31 @Override
32 protected boolean evict(PoolableStore store, int count, long size) {
33 return store.evictFromOnHeap(count, size);
34 }
35
36 /***
37 * {@inheritDoc}
38 */
39 @Override
40 protected long countSize(PoolableStore store) {
41 return store.getApproximateHeapCountSize();
42 }
43
44 /***
45 * {@inheritDoc}
46 */
47 @Override
48 protected long byteSize(PoolableStore store) {
49 return store.getApproximateHeapByteSize();
50 }
51
52 /***
53 * {@inheritDoc}
54 */
55 @Override
56 protected float hitRate(PoolableStore store) {
57 return store.getApproximateHeapHitRate();
58 }
59
60 /***
61 * {@inheritDoc}
62 */
63 @Override
64 protected float missRate(PoolableStore store) {
65 return store.getApproximateHeapMissRate();
66 }
67 }