public abstract class LogWatchBuilder extends Object
LogWatch
that will automatically
LogWatch.start()
. Unless overriden by the user, the instance will
have the following properties:
DEFAULT_DELAY_BETWEEN_READS_IN_MILLISECONDS
.DEFAULT_READ_BUFFER_SIZE_IN_BYTES
.Integer.MAX_VALUE
, the maximum possible.DEFAULT_DELAY_BETWEEN_SWEEPS_IN_MILLISECONDS
.getGateCondition()
and not do so for all others.Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_DELAY_BETWEEN_READS_IN_MILLISECONDS |
static long |
DEFAULT_DELAY_BETWEEN_SWEEPS_IN_MILLISECONDS |
static int |
DEFAULT_READ_BUFFER_SIZE_IN_BYTES |
Constructor and Description |
---|
LogWatchBuilder() |
Modifier and Type | Method and Description |
---|---|
abstract LogWatch |
build()
Build the log watch with previously defined properties, or defaults where
not overriden.
|
abstract Follower |
buildFollowing()
Build the log watch with previously defined properties, or defaults where
not overriden, and immediately start listening for
Message s. |
abstract Follower |
buildFollowingWith(TailSplitter splitter)
Build the log watch with previously defined properties, or defaults where
not overriden, and immediately start listening for
Message s |
abstract LogWatch |
buildWith(TailSplitter splitter)
Build the log watch with previously defined properties, or defaults where
not overriden.
|
LogWatchBuilder |
closingAfterReading()
Change the default behavior of the future log watch to close the watched
file after each reading.
|
LogWatchBuilder |
doNotStart()
Do not run
LogWatch.start() on the new instance. |
int |
getCapacityLimit()
Get the capacity of the future log watch.
|
static LogWatchBuilder |
getDefault()
Used to construct a
LogWatch for a particular log file. |
long |
getDelayBetweenReads()
Get the delay between attempts to read from the watched file.
|
long |
getDelayBetweenSweeps()
Get the delay between attempts to sweep unreachable messages from memory.
|
File |
getFileToWatch()
Get the file that the log watch will be watching.
|
SimpleMessageCondition |
getGateCondition()
|
int |
getReadingBufferSize()
Get the buffer size for the log watch.
|
SimpleMessageCondition |
getStorageCondition()
|
LogWatchBuilder |
ignoringPreexistingContent()
Change the default behavior of the future log watch so that the existing
contents of the file is ignored and only the future additions to the file
are reported.
|
boolean |
isClosingBetweenReads() |
boolean |
isReadingFromBeginning() |
LogWatchBuilder |
limitCapacityTo(int size)
Limit capacity of the log watch to a given amount of messages.
|
String |
toString() |
LogWatchBuilder |
watchedFile(File f)
Set the file that the future
LogWatch will be tailing. |
boolean |
willBeStarted() |
LogWatchBuilder |
withDelayBetweenReads(int length,
TimeUnit unit)
Specify the delay between attempts to read the file.
|
LogWatchBuilder |
withDelayBetweenSweeps(int length,
TimeUnit unit)
Specify the delay between attempts to sweep the log watch from
unreachable messages.
|
LogWatchBuilder |
withGateCondition(SimpleMessageCondition condition)
Only the
Message s for which
SimpleMessageCondition.accept(Message) is true will be passed to
Follower s and other MessageConsumer s. |
LogWatchBuilder |
withReadingBufferSize(int bufferSize)
Specify the buffer size that will be used for reading changes made to the
watched file.
|
LogWatchBuilder |
withStorageCondition(SimpleMessageCondition condition)
Only the messages for which
SimpleMessageCondition.accept(Message) is true will be stored
within the future LogWatch . |
public static final long DEFAULT_DELAY_BETWEEN_READS_IN_MILLISECONDS
public static final long DEFAULT_DELAY_BETWEEN_SWEEPS_IN_MILLISECONDS
public static final int DEFAULT_READ_BUFFER_SIZE_IN_BYTES
public static LogWatchBuilder getDefault()
LogWatch
for a particular log file.public abstract LogWatch build()
getFileToWatch()
until after LogWatch.startFollowing()
or
MessageProducer.startConsuming(com.github.triceo.splitlog.api.MessageListener)
.public abstract Follower buildFollowing()
Message
s.LogWatch
can be retrieved by
Follower.getFollowed()
.public abstract Follower buildFollowingWith(TailSplitter splitter)
Message
ssplitter
- The splitter instance to use for the log watch instead of the
default.LogWatch
can be retrieved by
Follower.getFollowed()
.public abstract LogWatch buildWith(TailSplitter splitter)
getFileToWatch()
until after LogWatch.startFollowing()
or
MessageProducer.startConsuming(com.github.triceo.splitlog.api.MessageListener)
.splitter
- The splitter instance to use for the log watch instead of the
default.LogWatch.startFollowing()
or
MessageProducer.startConsuming(com.github.triceo.splitlog.api.MessageListener)
.public LogWatchBuilder closingAfterReading()
public LogWatchBuilder doNotStart()
LogWatch.start()
on the new instance.public int getCapacityLimit()
public long getDelayBetweenReads()
public long getDelayBetweenSweeps()
public File getFileToWatch()
public SimpleMessageCondition getGateCondition()
public int getReadingBufferSize()
public SimpleMessageCondition getStorageCondition()
public LogWatchBuilder ignoringPreexistingContent()
public boolean isClosingBetweenReads()
public boolean isReadingFromBeginning()
public LogWatchBuilder limitCapacityTo(int size)
size
- Maximum amount of messages to store.public LogWatchBuilder watchedFile(File f)
LogWatch
will be tailing.f
- File to watch.public boolean willBeStarted()
LogWatch.start()
ed.public LogWatchBuilder withDelayBetweenReads(int length, TimeUnit unit)
length
- Length of time.unit
- Unit of that length.public LogWatchBuilder withDelayBetweenSweeps(int length, TimeUnit unit)
length
- Length of time.unit
- Unit of that length.public LogWatchBuilder withGateCondition(SimpleMessageCondition condition)
Message
s for which
SimpleMessageCondition.accept(Message)
is true will be passed to
Follower
s and other MessageConsumer
s. Such
Message
s will also never be stored. For the purposes of Splitlog,
if it fails this condition, it's as if it never existed.condition
- The condition.public LogWatchBuilder withReadingBufferSize(int bufferSize)
bufferSize
- In bytes.public LogWatchBuilder withStorageCondition(SimpleMessageCondition condition)
SimpleMessageCondition.accept(Message)
is true will be stored
within the future LogWatch
. However, MessageConsumer
s
will be notified of them either way.
The condition in question will only ever be called on Message
s
that have already passed the getGateCondition()
.condition
- The condition.Copyright © 2015. All rights reserved.