Top Fields Constructors Methods
stormpot

pack-priv final Class TimingReallocatorAdaptor<T extends Poolable>

extends TimingReallocatingAdaptor<T extends Poolable>
implements Reallocator<T extends Poolable>
Class Inheritance
All Implemented Interfaces
stormpot.Reallocator, stormpot.Allocator
Imports
java.util.concurrent.TimeUnit

Field Summary

Inherited from stormpot.TimingReallocatingAdaptor:
metricsRecorder

Constructor Summary

AccessConstructor and Description
pack-priv
TimingReallocatorAdaptor(Reallocator<T> allocator, MetricsRecorder metricsRecorder)

Method Summary

Modifier and TypeMethod and Description
public T
reallocate(Slot
The slot the pool wish to allocate an object for. Implementers do not need to concern themselves with the details of a pools slot objects. They just have to call release on them as the protocol demands.
slot
,
T
The non-null Poolable instance to be reallocated.
poolable
)

Overrides stormpot.ReallocatingAdaptor.reallocate.

Implements stormpot.Reallocator.reallocate.

Possibly reallocate the given instance of T for the given slot, and return it if the reallocation was successful, or a fresh replacement if the instance could not be reallocated.
Inherited from stormpot.TimingReallocatingAdaptor:
allocatedeallocate

Constructor Detail

TimingReallocatorAdaptorback to summary
pack-priv TimingReallocatorAdaptor(Reallocator<T> allocator, MetricsRecorder metricsRecorder)

Method Detail

reallocateback to summary
public T reallocate(Slot slot, T poolable) throws Exception

Overrides stormpot.ReallocatingAdaptor.reallocate.

Implements stormpot.Reallocator.reallocate.

Doc from stormpot.Reallocator.reallocate.

Possibly reallocate the given instance of T for the given slot, and return it if the reallocation was successful, or a fresh replacement if the instance could not be reallocated. This method is effectively equivalent to the following: [source,java] -- include::src/test/java/examples/Examples.java[tag=reallocatorExample] -- With the only difference that it may, if possible, reuse the given expired Poolable, either wholly or in part. The state stored in the stormpot.SlotInfo for the object is reset upon reallocation, just like it would be in the case of a normal deallocation-allocation cycle. Exceptions thrown by this method may propagate out through the claim method of a pool, in the form of being wrapped inside a PoolException. Pools must be able to handle these exceptions in a sane manner, and are guaranteed to return to a working state if a Reallocator stops throwing exceptions from its reallocate method. Be aware that if the reallocation of an object fails with an exception, then no attempts will be made to explicitly deallocate that object. This way, a failed reallocation is implicitly understood to effectively be a successful deallocation.

Parameters
slot:Slot

The slot the pool wish to allocate an object for. Implementers do not need to concern themselves with the details of a pools slot objects. They just have to call release on them as the protocol demands.

poolable:T

The non-null Poolable instance to be reallocated.

Returns:T

A fresh or rejuvenated instance of T. Never `null`.

Annotations
@Override
Exceptions
Exception:
If the allocation fails.