Class DefaultIoEventSizeEstimator
java.lang.Object
org.apache.mina.filter.executor.DefaultIoEventSizeEstimator
- All Implemented Interfaces:
IoEventSizeEstimator
A default
IoEventSizeEstimator implementation.
Martin's Java Notes
was used for estimation. For unknown types, it inspects declaring fields of the
class of the specified event and the parameter of the event. The size of unknown
declaring fields are approximated to the specified averageSizePerField
(default: 64).
All the estimated sizes of classes are cached for performance improvement.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap<Class<?>, Integer> A map containing the estimated size of each Java objects we know for -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance of this class, injecting the known size of basic java types. -
Method Summary
Modifier and TypeMethodDescriptionprivate static intalign(int size) private intestimateSize(Class<?> clazz, Set<Class<?>> visitedClasses) intestimateSize(Object message) Estimate the size of an Object in number of bytesintestimateSize(IoEvent event) Estimate the IoEvent size in number of bytes
-
Field Details
-
class2size
A map containing the estimated size of each Java objects we know for
-
-
Constructor Details
-
DefaultIoEventSizeEstimator
public DefaultIoEventSizeEstimator()Create a new instance of this class, injecting the known size of basic java types.
-
-
Method Details
-
estimateSize
Estimate the IoEvent size in number of bytes- Specified by:
estimateSizein interfaceIoEventSizeEstimator- Parameters:
event- The event we want to estimate the size of- Returns:
- The estimated size of this event
-
estimateSize
Estimate the size of an Object in number of bytes- Parameters:
message- The object to estimate- Returns:
- The estimated size of the object
-
estimateSize
-
align
private static int align(int size)
-