Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.io
Class MultiplexingWriteBufferPool

java.lang.Object
  extended by com.tangosol.io.MultiplexingWriteBufferPool

All Implemented Interfaces:
MultiBufferWriteBuffer.WriteBufferPool, Disposable

public final class MultiplexingWriteBufferPool
extends java.lang.Object
implements MultiBufferWriteBuffer.WriteBufferPool, Disposable

The MultiplexingWriteBufferPool acts as a WriteBufferPool from which a MultiBufferWriteBuffer can allocate and release WriteBuffers from/to.

Author:
ch 2010-03-04

Field Summary
static int DEFAULT_BUF_SIZE
          The default size of the smallest WriteBuffer.

 

Constructor Summary
MultiplexingWriteBufferPool()
          Default constructor.
MultiplexingWriteBufferPool(int cSegments, int cbSegment, int cbBufferMin, int nGrowthFactor)
          Creates a MultiplexingWriteBufferPool.

 

Method Summary
 WriteBuffer allocate(int cbPreviousTotal)
          Allocate a WriteBuffer for use by the MultiBufferWriteBuffer.
 void dispose()
          
protected static int encodeGeneration(int cb, int nGenId)
          Return the buffer allocation size for a given generation.
static int getBaseBufferSize(int cbBufferMin)
          Return the base buffer size for the specified minimum buffer size.
 int getMaximumCapacity()
          Determine the largest amount of aggregate WriteBuffer capacity that this factory can provide.
static int getMaximumSegmentBufferSize(int iSeg, int cbMin, int nGrowthFactor)
          Return the maximum buffer size for a buffer in the specified segment.
 void release(WriteBuffer buffer)
          Returns a WriteBuffer to the pool.

 

Field Detail

DEFAULT_BUF_SIZE

public static final int DEFAULT_BUF_SIZE
The default size of the smallest WriteBuffer. Note that the actual size of the WriteBuffer may be larger, since the size includes an implicit generation ID. Also note that the default buffer size cannot use any of the bits 0-9.
See Also:
Constant Field Values

Constructor Detail

MultiplexingWriteBufferPool

public MultiplexingWriteBufferPool()
Default constructor.

MultiplexingWriteBufferPool

public MultiplexingWriteBufferPool(int cSegments,
                                   int cbSegment,
                                   int cbBufferMin,
                                   int nGrowthFactor)
Creates a MultiplexingWriteBufferPool.
Parameters:
cSegments - the number of segments
cbSegment - the maximum number bytes each segment will consume
cbBufferMin - the smallest buffer size
nGrowthFactor - the segment growth factor

Method Detail

getMaximumCapacity

public int getMaximumCapacity()
Determine the largest amount of aggregate WriteBuffer capacity that this factory can provide.
Specified by:
getMaximumCapacity in interface MultiBufferWriteBuffer.WriteBufferPool
Returns:
the number of bytes that can be stored in the WriteBuffer objects that may be returned from this factory

allocate

public WriteBuffer allocate(int cbPreviousTotal)
Allocate a WriteBuffer for use by the MultiBufferWriteBuffer. The MultiBufferWriteBuffer calls this factory method when it exhausts the storage capacity of previously allocated WriteBuffer objects.

Note that the returned WriteBuffer is expected to be empty, and its capacity is expected to be identical to its maximum capacity, i.e. it is not expected to resize itself, since the purpose of the MultiBufferWriteBuffer is to act as a dynamically-sized WriteBuffer.

Specified by:
allocate in interface MultiBufferWriteBuffer.WriteBufferPool
Parameters:
cbPreviousTotal - the total number of bytes of capacity of the WriteBuffer objects that the MultiBufferWriteBuffer has thus far consumed
Returns:
an empty WriteBuffer suitable for writing to

release

public void release(WriteBuffer buffer)
Returns a WriteBuffer to the pool. This can happen when AbstractWriteBuffer.clear(), or AbstractWriteBuffer.retain(int), or MultiBufferWriteBuffer.retain(int, int) is called.
Specified by:
release in interface MultiBufferWriteBuffer.WriteBufferPool
Parameters:
buffer - the WriteBuffer that is no longer being used

dispose

public void dispose()

getMaximumSegmentBufferSize

public static int getMaximumSegmentBufferSize(int iSeg,
                                              int cbMin,
                                              int nGrowthFactor)
Return the maximum buffer size for a buffer in the specified segment.
Parameters:
iSeg - the segment
cbMin - the pool's minimum buffer size
nGrowthFactor - the segment grown factor
Returns:
the maximum buffer size

getBaseBufferSize

public static int getBaseBufferSize(int cbBufferMin)
Return the base buffer size for the specified minimum buffer size.
Parameters:
cbBufferMin - the minimum buffer size
Returns:
the base buffer size

encodeGeneration

protected static int encodeGeneration(int cb,
                                      int nGenId)
Return the buffer allocation size for a given generation.
Parameters:
cb - the segments base buffer size
nGenId - the generation
Returns:
the allocation size

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.