public class MemoryTierProducerAgent extends Object implements TierProducerAgent, NettyServiceProducer
TierProducerAgent
.Constructor and Description |
---|
MemoryTierProducerAgent(TieredStoragePartitionId partitionId,
int numSubpartitions,
int bufferSizeBytes,
int segmentSizeBytes,
int subpartitionMaxQueuedBuffers,
boolean isBroadcastOnly,
TieredStorageMemoryManager memoryManager,
TieredStorageNettyService nettyService,
TieredStorageResourceRegistry resourceRegistry) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the agent.
|
void |
connectionBroken(NettyConnectionId connectionId)
NettyConnectionWriter related to a connection id will be notified when the netty
connection is broken. |
void |
connectionEstablished(TieredStorageSubpartitionId subpartitionId,
NettyConnectionWriter nettyConnectionWriter)
NettyConnectionWriter will be created when a netty connection is established for a
subpartition. |
boolean |
tryStartNewSegment(TieredStorageSubpartitionId subpartitionId,
int segmentId,
int minNumBuffers)
Try to start a new segment in the Tier.
|
boolean |
tryWrite(TieredStorageSubpartitionId subpartitionId,
Buffer finishedBuffer,
Object bufferOwner,
int numRemainingConsecutiveBuffers)
Writes the finished
Buffer to the consumer. |
public MemoryTierProducerAgent(TieredStoragePartitionId partitionId, int numSubpartitions, int bufferSizeBytes, int segmentSizeBytes, int subpartitionMaxQueuedBuffers, boolean isBroadcastOnly, TieredStorageMemoryManager memoryManager, TieredStorageNettyService nettyService, TieredStorageResourceRegistry resourceRegistry)
public boolean tryStartNewSegment(TieredStorageSubpartitionId subpartitionId, int segmentId, int minNumBuffers)
TierProducerAgent
tryStartNewSegment
in interface TierProducerAgent
subpartitionId
- subpartition id that the new segment belongs tosegmentId
- id of the new segmentminNumBuffers
- the minimum number of buffers that are expected to be written to the
newly created segment.public boolean tryWrite(TieredStorageSubpartitionId subpartitionId, Buffer finishedBuffer, Object bufferOwner, int numRemainingConsecutiveBuffers)
TierProducerAgent
Buffer
to the consumer.
Note that the method is successfully executed (without throwing any exception), the buffer should be released by the caller, otherwise the tier should be responsible to recycle the buffer.
tryWrite
in interface TierProducerAgent
subpartitionId
- the subpartition id that the buffer is writing tofinishedBuffer
- the writing bufferbufferOwner
- the current owner of this writing buffernumRemainingConsecutiveBuffers
- number of buffers that would be passed in the following
invocations and should be written to the same segment as this onepublic void connectionEstablished(TieredStorageSubpartitionId subpartitionId, NettyConnectionWriter nettyConnectionWriter)
NettyServiceProducer
NettyConnectionWriter
will be created when a netty connection is established for a
subpartition.connectionEstablished
in interface NettyServiceProducer
subpartitionId
- subpartition id indicates the id of subpartition.nettyConnectionWriter
- writer is used to write buffers to netty connection.public void connectionBroken(NettyConnectionId connectionId)
NettyServiceProducer
NettyConnectionWriter
related to a connection id will be notified when the netty
connection is broken.connectionBroken
in interface NettyServiceProducer
connectionId
- connection id is the id of connection.public void close()
TierProducerAgent
Note this only releases resources directly hold by the agent, which excludes resources managed by the resource registry.
close
in interface AutoCloseable
close
in interface TierProducerAgent
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.