public class ChronicleLogAppender<M extends Externalizable> extends Object implements CloseableLogAppender<M>
Modifier and Type | Field and Description |
---|---|
protected File |
basePath |
static String |
BLOCK_SIZE_KEY |
protected int |
blockSize |
protected boolean |
closed |
protected Codec<M> |
codec |
static int |
CQ_BLOCK_SIZE |
protected static int |
MAX_PARTITIONS |
protected static String |
METADATA_FILE |
static String |
MSG_KEY |
protected String |
name |
protected int |
nbPartitions |
protected static String |
PARTITION_PREFIX |
protected List<net.openhft.chronicle.queue.ChronicleQueue> |
partitions |
static String |
PARTITIONS_KEY |
protected static int |
POLL_INTERVAL_MS |
protected ChronicleRetentionDuration |
retention |
static String |
RETENTION_KEY |
protected ConcurrentLinkedQueue<ChronicleLogTailer<M>> |
tailers |
Modifier | Constructor and Description |
---|---|
protected |
ChronicleLogAppender(Codec<M> codec,
File basePath,
ChronicleRetentionDuration retention)
Open an existing Log
|
protected |
ChronicleLogAppender(Codec<M> codec,
File basePath,
int size,
ChronicleRetentionDuration retention)
Create a new Log
|
Modifier and Type | Method and Description |
---|---|
protected LogTailer<M> |
addTailer(ChronicleLogTailer<M> tailer) |
LogOffset |
append(int partition,
M message)
Append a message into a partition, returns
LogOffset position of the message. |
void |
close() |
boolean |
closed()
Returns
true if the appender has been closed by the manager. |
long |
countMessages(int partition,
long lowerOffset,
long upperOffset) |
static <M extends Externalizable> |
create(Codec<M> codec,
File basePath,
int size)
Create a new log.
|
static <M extends Externalizable> |
create(Codec<M> codec,
File basePath,
int size,
ChronicleRetentionDuration retention)
Create a new log
|
LogTailer<M> |
createTailer(LogPartition partition,
String group,
Codec<M> codec) |
static int |
discoverPartitions(Path basePath) |
long |
endOffset(int partition) |
protected static boolean |
exists(File basePath) |
long |
firstOffset(int partition) |
String |
getBasePath() |
Codec<M> |
getCodec()
Returns the codec used to write record.
|
protected Path |
getMetadataPath() |
ChronicleRetentionDuration |
getRetention() |
protected Properties |
guessMetadata(ChronicleRetentionDuration retention) |
protected void |
initPartitions(boolean create) |
protected static boolean |
isPartitionDirectory(Path path) |
protected boolean |
isProcessed(ChronicleLogOffsetTracker tracker,
long offset) |
String |
name()
Returns the Log's name.
|
static <M extends Externalizable> |
open(Codec<M> codec,
File basePath)
Open an existing log.
|
static <M extends Externalizable> |
open(Codec<M> codec,
File basePath,
ChronicleRetentionDuration retention)
Open an existing log.
|
static int |
partitions(Path basePath) |
protected static Properties |
readMetadata(Path file) |
protected void |
saveMetadata() |
int |
size()
Returns the number of partitions in the Log.
|
String |
toString() |
boolean |
waitFor(LogOffset offset,
String group,
Duration timeout)
Wait for consumer to process a message up to the offset.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
append
protected static final String PARTITION_PREFIX
protected static final String METADATA_FILE
protected static final int POLL_INTERVAL_MS
protected static final int MAX_PARTITIONS
public static final String MSG_KEY
public static final int CQ_BLOCK_SIZE
public static final String RETENTION_KEY
public static final String PARTITIONS_KEY
public static final String BLOCK_SIZE_KEY
protected final List<net.openhft.chronicle.queue.ChronicleQueue> partitions
protected final int nbPartitions
protected final int blockSize
protected final ConcurrentLinkedQueue<ChronicleLogTailer<M extends Externalizable>> tailers
protected final ChronicleRetentionDuration retention
protected final Codec<M extends Externalizable> codec
protected volatile boolean closed
protected ChronicleLogAppender(Codec<M> codec, File basePath, ChronicleRetentionDuration retention)
protected ChronicleLogAppender(Codec<M> codec, File basePath, int size, ChronicleRetentionDuration retention)
protected void initPartitions(boolean create)
protected void saveMetadata()
protected Path getMetadataPath()
protected static Properties readMetadata(Path file)
protected Properties guessMetadata(ChronicleRetentionDuration retention)
public static <M extends Externalizable> ChronicleLogAppender<M> create(Codec<M> codec, File basePath, int size, ChronicleRetentionDuration retention)
public static <M extends Externalizable> ChronicleLogAppender<M> create(Codec<M> codec, File basePath, int size)
public static <M extends Externalizable> ChronicleLogAppender<M> open(Codec<M> codec, File basePath)
public static <M extends Externalizable> ChronicleLogAppender<M> open(Codec<M> codec, File basePath, ChronicleRetentionDuration retention)
public String getBasePath()
public String name()
LogAppender
name
in interface LogAppender<M extends Externalizable>
public int size()
LogAppender
size
in interface LogAppender<M extends Externalizable>
public LogOffset append(int partition, M message)
LogAppender
LogOffset
position of the message. This method is thread safe,
a queue can be shared by multiple producers.append
in interface LogAppender<M extends Externalizable>
partition
- index lower than LogAppender.size()
public LogTailer<M> createTailer(LogPartition partition, String group, Codec<M> codec)
public long endOffset(int partition)
public long firstOffset(int partition)
public long countMessages(int partition, long lowerOffset, long upperOffset)
protected LogTailer<M> addTailer(ChronicleLogTailer<M> tailer)
public boolean waitFor(LogOffset offset, String group, Duration timeout) throws InterruptedException
LogAppender
true
if the message has been consumed, false
in case
of timeout.waitFor
in interface LogAppender<M extends Externalizable>
InterruptedException
public boolean closed()
LogAppender
true
if the appender has been closed by the manager.closed
in interface LogAppender<M extends Externalizable>
public Codec<M> getCodec()
LogAppender
getCodec
in interface LogAppender<M extends Externalizable>
protected boolean isProcessed(ChronicleLogOffsetTracker tracker, long offset)
public void close()
close
in interface AutoCloseable
close
in interface CloseableLogAppender<M extends Externalizable>
public static int partitions(Path basePath)
public static int discoverPartitions(Path basePath)
protected static boolean isPartitionDirectory(Path path)
public ChronicleRetentionDuration getRetention()
Copyright © 2019 Nuxeo. All rights reserved.