Top Description Inners Fields Constructors Methods
net.sf.ehcache.pool.impl

public Class BalancedAccessEvictor

extends Object
implements PoolEvictor<PoolParticipant>
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.pool.PoolEvictor
Imports
java.util.ArrayList, .Collection, .Collections, .Comparator, .IdentityHashMap, .List, .Map, net.sf.ehcache.pool.PoolAccessor, .PoolEvictor, .PoolParticipant

Abstract implementation of a global 'cache value' maximizing pool eviction algorithm.

Authors
Chris Dennis, Alex Snaps

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
BalancedAccessEvictor.EvictionCostComparator

Comparator used to rank the stores in order of eviction 'cost'.

Field Summary

Modifier and TypeField and Description
private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private float
evictionCost(PoolAccessor<T extends PoolParticipant> accessor, long unloadedSize)

public boolean
freeSpace(Collection<PoolAccessor<PoolParticipant>>
a collection of resources to free from
from
,
long
the number of bytes to free up
bytes
)

Implements net.sf.ehcache.pool.PoolEvictor.freeSpace.

Free at least N bytes from a collection of resources
private long
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SAMPLE_SIZEback to summary
private static final int SAMPLE_SIZE

Constructor Detail

BalancedAccessEvictorback to summary
public BalancedAccessEvictor()

Method Detail

evictionCostback to summary
private float evictionCost(PoolAccessor<T extends PoolParticipant> accessor, long unloadedSize)
freeSpaceback to summary
public boolean freeSpace(Collection<PoolAccessor<PoolParticipant>> from, long bytes)

Implements net.sf.ehcache.pool.PoolEvictor.freeSpace.

Doc from net.sf.ehcache.pool.PoolEvictor.freeSpace.

Free at least N bytes from a collection of resources

Parameters
from:Collection<PoolAccessor<PoolParticipant>>

a collection of resources to free from

bytes:long

the number of bytes to free up

Returns:boolean

true if at least N bytes could be freed

getDesiredUnloadedSizeback to summary
private long getDesiredUnloadedSize(Collection<PoolAccessor<T extends PoolParticipant>> from)
net.sf.ehcache.pool.impl back to summary

private final Class BalancedAccessEvictor.EvictionCostComparator

extends Object
implements Comparator<PoolAccessor<T extends PoolParticipant>>
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.pool.impl.BalancedAccessEvictor.EvictionCostComparator
All Implemented Interfaces
java.util.Comparator

Comparator used to rank the stores in order of eviction 'cost'.

Field Summary

Modifier and TypeField and Description
private final Map<PoolAccessor<T extends PoolParticipant>, Float>
private final long

Constructor Summary

AccessConstructor and Description
public
EvictionCostComparator(long unloadedSize, int collectionSize)

Method Summary

Modifier and TypeMethod and Description
public int
compare(PoolAccessor<T extends PoolParticipant>
the first object to be compared.
s1
,
PoolAccessor<T extends PoolParticipant>
the second object to be compared.
s2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

evictionCostCacheback to summary
private final Map<PoolAccessor<T extends PoolParticipant>, Float> evictionCostCache
unloadedSizeback to summary
private final long unloadedSize

Constructor Detail

EvictionCostComparatorback to summary
public EvictionCostComparator(long unloadedSize, int collectionSize)

Method Detail

compareback to summary
public int compare(PoolAccessor<T extends PoolParticipant> s1, PoolAccessor<T extends PoolParticipant> s2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
s1:PoolAccessor<T extends PoolParticipant>

the first object to be compared.

s2:PoolAccessor<T extends PoolParticipant>

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.