public class MsgDispatcher extends MsgDispatcherCore
Modifier and Type | Class and Description |
---|---|
class |
MsgDispatcher.DispatcherThread
Class to organize a dispatcher thread.
|
MsgDispatcherCore.Entry, MsgDispatcherCore.Output, MsgDispatcherCore.TestCnt
Modifier and Type | Field and Description |
---|---|
private int |
maxDst |
LogMessage |
outputConsole
A console output is standard everytime..
|
static int |
version
Version, history and license.
|
actNrofListIdents, ctLostMessages, entryMsgBufferOverflow, freeOrders, idThreadForDispatching, listBitDst, listIdents, listOrders, mAdd, mConsole, mConsoleQueued, mDispatchBits, mDispatchInCallingThread, mDispatchInDispatcherThread, mDstMixedOutputs, mDstOneOutput, mRemove, mSet, msgText, nrofMixedOutputs, outputs, runNoEntryMessage, testCnt
nLogLevel
dateFormat, debug, error, fineDebug, fineInfo, info, minSecondsFormat, mNeverOutputToDisplay, mReportLevel, sVersion, warning
Constructor and Description |
---|
MsgDispatcher(int maxDispatchEntries,
int maxQueue,
int maxOutputs,
int nrofMixedOutputs,
int msgIdentQueueOverflow,
java.lang.Runnable runNoEntryMessage)
Initializes the instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
close and flush forces the dispatching of the messages in the queue.
|
private int |
completeDispatchInThreadBits(int dstBits)
Completes a destination bit mask with the information, whether any destinations are used
in the calling thread or in the dispatcher thread.
|
void |
flush()
flush forces the dispatching of the messages in the queue.
|
ConcurrentLinkedQueue<MsgDispatcherCore.Entry> |
getSharedFreeEntries()
Gets the internal free entries for sharing with an other log output,
at example LogMessageFile.
|
private int |
insertIdent(int idx,
int fromIdent,
int toIdent)
inserts an ident range after given position:
1 means any stored ident number, 7 means a number behind,
i,j means the inserted idents.
|
boolean |
reportOutput(FileAppend file)
Writes the msg dispatching outputs in file.
|
void |
setDefaults(java.lang.String fileOut) |
java.lang.String |
setOutputFromString(java.lang.String ctrl,
java.lang.StringBuilder errorBuffer)
Sets the output from a String content.
|
int |
setOutputRange(int fromIdent,
int toIdent,
int dst,
int mode,
int level)
Sets the output dispatch bits for the given message number range.
|
void |
setOutputRoutine(int dstIdx,
java.lang.String name,
boolean bQueued,
boolean bText,
LogMessage dst)
Sets a destination interface to a index for dispatching.
|
(package private) void |
stop()
It's a debug helper.
|
append, append, append, dispatchMsg, dispatchQueuedMsg, isOnline, searchDispatchBits, sendMsg, sendMsgTime, sendMsgVaList, setIdThreadForMsgDispatching, setMsgTextConverter, tickAndFlushOrClose
flushReport, getReportLevel, getReportLevelFromIdent, report, report, reportln, reportln, setReportLevel, setReportLevelToIdent, writeError, writeError, writeInfo, writeInfoln, writeWarning
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
msgSec, timeCurr, timeMsg
public static final int version
MsgDispatcherCore
now.
MsgDispatcher(int, int, int, int, int, Runnable)
has gotten a new argument
'msgIdentQueueOverflow'. This is the number for a message which is created automatically if a overflowed msg queue
was found on the next invocation of MsgDispatcherCore.dispatchQueuedMsg()
. That is the best method to show that there was a
buffer overflow. The user found this message in its message log on configurable output with a configurable text
as hint that a overflow has occurred. An overflow is a result of either to less queue size or to much messages.
setOutputRoutine(int, String, boolean, boolean, LogMessage)
has gotten a new argument
'bText'. It is a substantial property whether an output channel uses the text or not. The preparation of text
is not done especially if a short calculation cycle does not need that.
MsgDispatcherCore.searchDispatchBits(int)
.
It make it possible to use the dispatch data without calling #sendMsg(int, String, Object...)
.
public final LogMessage outputConsole
private int maxDst
public MsgDispatcher(int maxDispatchEntries, int maxQueue, int maxOutputs, int nrofMixedOutputs, int msgIdentQueueOverflow, java.lang.Runnable runNoEntryMessage)
maxDispatchEntries
- The max number of message-ident-number ranges which are dispatched
to different outputs. It is a static limited data amount.
If you have about 1000 different message-ident-numbers, 1000 is okay.
If you have some more different message-ident-numbers, but with determined ranges,
which are always dispatched to the same destinations, that number of ranges is okay.
In other words, it is the maximal number of lines in a message dispatched file,
if all message ranges are set new.maxQueue
- The static limited maximal size of the queue to store messages from user threads
to dispatch in the dispatcher thread. If you call the dispatching in dispatcher thread
cyclicly in 100-ms-steps, and you have worst case no more as 200 messages in this time,
200 is okay.maxOutputs
- The static limited maximal number of outputs.nrofMixedOutputs
- msgIdentQueueOverflow
- Ident of that message that inform about lost messages. New since 2013-02-24runNoEntryMessage
- null or a routine which is called on lost messages. New since 2013-02-24public final ConcurrentLinkedQueue<MsgDispatcherCore.Entry> getSharedFreeEntries()
public final void setDefaults(java.lang.String fileOut)
private final int insertIdent(int idx, int fromIdent, int toIdent)
1 means any stored ident number, 7 means a number behind, i,j means the inserted idents. The idx selects the 1.-ident. before: ....1.7...... after: ....1.i.j.7..If fromIdent == toIdent, only one position is inserted:
before: ....1.7.... after: ....1.j.7..
idx
- Index, after them the ident is inserted.fromIdent
- first value of the ident.toIdent
- second value of the ident.mask
- bit to orpublic final void setOutputRoutine(int dstIdx, java.lang.String name, boolean bQueued, boolean bText, LogMessage dst)
dstIdx
- The index 0..28 or greater, which is associated to the destination.name
- Name of the output channel to use for dispatch configurationbQueued
- true than the message is queued if this destination is used.bText
- true than the output uses the message text. false if the text is unused. new since 2013-02-24
A text is unused if the output channel stores or transmits the message without text. The message text
may be complement later determined by the message ident maybe in another language from any configuration setting.dst
- The destination for message or log output.public final int setOutputRange(int fromIdent, int toIdent, int dst, int mode, int level)
fromIdent
- The first ident number for which the dispatch bit is valid.toIdent
- The last ident number for which the dispatch bit is valid.dst
- Bit or index for the destination for the given output range.
An or-value #mDispatchWithIndex
can be added. If this Bit is set,
the rest of bits are the index of the output, greater as MsgDispatcherCore.nrofMixedOutputs
.
In this case mode should be MsgDispatcherCore.mSet
.
#mDispatchWithIndex
isn't set, the bits 0..23 describe one or more outputs.
mode
- Ones of MsgDispatcherCore.mAdd
, MsgDispatcherCore.mSet
, MsgDispatcherCore.mRemove
to presribe,
what to do with dst.level
- public final java.lang.String setOutputFromString(java.lang.String ctrl, java.lang.StringBuilder errorBuffer)
123..512:0x27 //It is a bit mask, all messages from 123 to inclusive 521 are set to channels 0,1,2 and 5 1001:+CON. //Message 1001 is sent additional to CON
ctrl
- The control String.errorBuffer
- A Buffer to assign an error String:
This method doesn't allocate any memory, therefore no String concatenation is done.
Instead an error String is assembled in the buffer using append.
This argument may be null, than only a short hint of error is returned as constant string
or as substring from ctrl.public final boolean reportOutput(FileAppend file)
setOutputFromString(String, StringBuilder)
.file
- The file should be opened already.
Hint: A simple writer isn't used because Java2C don't able to translate it yet. (Version 0.84)private final int completeDispatchInThreadBits(int dstBits)
dstBits
- The input maskmDispatchInDispatcherThread
and/or mDispatchInCallingThread
final void stop()
public final void close()
close
in interface LogMessage
close
in class MsgDispatcherCore
org.vishia.util.LogMessage#close()
public final void flush()
flush
in interface LogMessage
flush
in class MsgDispatcherCore
org.vishia.util.LogMessage#close()