com.hazelcast.ringbuffer.impl
Class RingbufferContainer

java.lang.Object
  extended by com.hazelcast.ringbuffer.impl.RingbufferContainer
All Implemented Interfaces:
DataSerializable

public class RingbufferContainer
extends Object
implements DataSerializable

The RingbufferContainer is responsible for storing the actual content of a ringbuffer. Currently the Ringbuffer is not a partitioned data-structure. So all data of a ringbuffer is stored in a single partition and replicated to the replica's. No thread-safety is needed since a partition can only be accessed by a single thread at any given moment. The ringItems is the ring that contains the actual items. The ringExpiration contains the expiration time of an item. The if a time to live is set, the ringExpiration is created. Otherwise it is null to safe space. The expiration time of an item can be found at the same index as the item itself. So these 2 arrays are always in step with each other. The reason why 2 array are created instead of just wrapping the item in a new object containing the expiration is that we don't want to generate more waste than needed.


Constructor Summary
RingbufferContainer(RingbufferConfig config, SerializationService serializationService)
           
RingbufferContainer(String name)
           
RingbufferContainer(String name, RingbufferConfig config, SerializationService serializationService)
           
 
Method Summary
 long add(Data item)
           
 long addAll(Data[] items)
           
 void checkBlockableReadSequence(long readSequence)
           
 void cleanup()
          Cleans up the ringbuffer by deleting all expired items.
 int getCapacity()
           
 RingbufferConfig getConfig()
           
 RingbufferWaitNotifyKey getRingEmptyWaitNotifyKey()
           
 long headSequence()
           
 void init(NodeEngine nodeEngine)
           
 boolean isEmpty()
           
 Data read(long sequence)
           
 void readData(ObjectDataInput in)
          Reads fields from the input stream
 long readMany(long beginSequence, ReadResultSetImpl result)
           
 long remainingCapacity()
           
 void setHeadSequence(long sequence)
           
 boolean shouldWait(long sequence)
           
 long size()
           
 long tailSequence()
           
 void writeData(ObjectDataOutput out)
          Writes object fields to output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RingbufferContainer

public RingbufferContainer(String name)

RingbufferContainer

public RingbufferContainer(RingbufferConfig config,
                           SerializationService serializationService)

RingbufferContainer

public RingbufferContainer(String name,
                           RingbufferConfig config,
                           SerializationService serializationService)
Method Detail

init

public void init(NodeEngine nodeEngine)

getRingEmptyWaitNotifyKey

public RingbufferWaitNotifyKey getRingEmptyWaitNotifyKey()

getConfig

public RingbufferConfig getConfig()

tailSequence

public long tailSequence()

headSequence

public long headSequence()

setHeadSequence

public void setHeadSequence(long sequence)

getCapacity

public int getCapacity()

size

public long size()

isEmpty

public boolean isEmpty()

shouldWait

public boolean shouldWait(long sequence)

remainingCapacity

public long remainingCapacity()

checkBlockableReadSequence

public void checkBlockableReadSequence(long readSequence)

add

public long add(Data item)

addAll

public long addAll(Data[] items)

read

public Data read(long sequence)

readMany

public long readMany(long beginSequence,
                     ReadResultSetImpl result)
Parameters:
beginSequence - the sequence of the first item to read.
result - the List where the result are stored in.
Returns:
returns the sequenceId of the next item to read. This is needed if not all required items are found.

cleanup

public void cleanup()
Cleans up the ringbuffer by deleting all expired items.


writeData

public void writeData(ObjectDataOutput out)
               throws IOException
Description copied from interface: DataSerializable
Writes object fields to output stream

Specified by:
writeData in interface DataSerializable
Parameters:
out - output
Throws:
IOException

readData

public void readData(ObjectDataInput in)
              throws IOException
Description copied from interface: DataSerializable
Reads fields from the input stream

Specified by:
readData in interface DataSerializable
Parameters:
in - input
Throws:
IOException


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.