|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.vishia.msgDispatch.MsgDispatcher
public class MsgDispatcher
| Nested Class Summary | |
|---|---|
class |
MsgDispatcher.DispatcherThread
Class to organize a dispachter thread. |
static class |
MsgDispatcher.Entry
Stores all data of a message if the message is queued here. |
private static class |
MsgDispatcher.Output
This class contains all infomations for a output. |
private static class |
MsgDispatcher.TestCnt
This class contains some test-counts for debugging. |
| Field Summary | |
|---|---|
private int |
actNrofListIdents
List of idents, its current length. |
(package private) ConcurrentLinkedQueue<MsgDispatcher.Entry> |
freeOrders
List of entries for messages to use. |
private int[] |
listBitDst
List of destination bits for the idents. |
private int[] |
listIdents
List of idents, a array with lengthListIdents elements. |
(package private) ConcurrentLinkedQueue<MsgDispatcher.Entry> |
listOrders
List of messages to process in the dispatcher thread. |
static int |
mAdd
Used for argument mode from setOutputRange(int, int, int, int, int) to add an output. |
private int |
maxDst
|
static int |
mConsole
Mask for dispatch the message to console directly in the calling thread. |
static int |
mConsoleQueued
queued Console output, it is a fix part of the Message dispatcher. |
static int |
mDispatchBits
Only this bits are used to indicate the destination via some Bits |
static int |
mDispatchInCallingThread
If this bit is set in the bitmask for dispatching, the dispatching should only be done in the calling thread. |
static int |
mDispatchInDispatcherThread
If this bit is set in the bitmask for dispatching, the dispatching should be done in the dispatcher Thread. |
private int |
mDstMixedOutputs
Calculated mask of bits which are able to mix. |
private int |
mDstOneOutput
Calculated mask of bits which are one index. |
static int |
mRemove
Used for argument mode from setOutputRange(int, int, int, int, int) to remove an output. |
static int |
mSet
Used for argument mode from setOutputRange(int, int, int, int, int) to set an output. |
private int |
nrofMixedOutputs
Number of Bits in mDispatchWithBits, it is the number of destinations dispached via bit mask. |
LogMessage |
outputConsole
A console output is standard everytime.. |
private MsgDispatcher.Output[] |
outputs
up to 30 destinations for output. |
(package private) MsgDispatcher.TestCnt |
testCnt
|
| Constructor Summary | |
|---|---|
MsgDispatcher(int maxDispatchEntries,
int maxQueue,
int maxOutputs,
int nrofMixedOutputs)
Initializes the instance. |
|
| Method Summary | |
|---|---|
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. |
private int |
dispatchMsg(int dstBits,
boolean bDispatchInDispatcherThread,
int identNumber,
OS_TimeStamp creationTime,
java.lang.String text,
Va_list args)
Dispatches a message. |
int |
dispatchQueuedMsg()
Dispatches all messages, which are stored in the queue. |
void |
flush()
flush forces the dispatching of the messages in the queue. |
ConcurrentLinkedQueue<MsgDispatcher.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 |
isOnline()
Checks whether the message output is available. |
boolean |
reportOutput(FileWriter file)
Writes the msg dispatching outputs in file. |
private int |
searchDispatchBits(int ident)
|
boolean |
sendMsg(int identNumber,
java.lang.String text,
java.lang.Object... args)
Sends a message. |
boolean |
sendMsgTime(int identNumber,
OS_TimeStamp creationTime,
java.lang.String text,
java.lang.Object... args)
Sends a message. |
boolean |
sendMsgVaList(int identNumber,
OS_TimeStamp creationTime,
java.lang.String text,
Va_list args)
Sends a message. |
void |
setDefaults(java.lang.String fileOut)
|
java.lang.String |
setOutputFromString(java.lang.String ctrl,
java.lang.StringBuffer 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,
LogMessage dst)
Sets a destination interface to a index for dispatching. |
(package private) void |
stop()
It's a debug helper. |
void |
tickAndFlushOrClose()
Outputs the queued messages calling LogMessage.flush() for all queued outputs. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int mDispatchInDispatcherThread
public static final int mDispatchInCallingThread
mDispatchInDispatcherThread
is set, if there is more as one destination.
public static final int mDispatchBits
private final int nrofMixedOutputs
mDispatchWithBits, it is the number of destinations dispached via bit mask.
private final int mDstMixedOutputs
private final int mDstOneOutput
public static final int mConsole
public static final int mConsoleQueued
public static final int mAdd
setOutputRange(int, int, int, int, int) to add an output.
The other set outputs aren't change.
public static final int mSet
setOutputRange(int, int, int, int, int) to set an output.
Outputs before are removed.
public static final int mRemove
setOutputRange(int, int, int, int, int) to remove an output.
All other outputs aren't change.
final MsgDispatcher.TestCnt testCnt
final ConcurrentLinkedQueue<MsgDispatcher.Entry> listOrders
final ConcurrentLinkedQueue<MsgDispatcher.Entry> freeOrders
private int actNrofListIdents
private int[] listIdents
private int[] listBitDst
private MsgDispatcher.Output[] outputs
public final LogMessage outputConsole
private int maxDst
| Constructor Detail |
|---|
public MsgDispatcher(int maxDispatchEntries,
int maxQueue,
int maxOutputs,
int nrofMixedOutputs)
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 - | Method Detail |
|---|
public final ConcurrentLinkedQueue<MsgDispatcher.Entry> getSharedFreeEntries()
public final void setDefaults(java.lang.String fileOut)
private final int searchDispatchBits(int ident)
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 or
public final void setOutputRoutine(int dstIdx,
java.lang.String name,
boolean bQueued,
LogMessage dst)
dstIdx - The index 0..28 or greater, which is associated to the destination.bQueued - true than the message is queued if this destination is used.outputs - 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 nrofMixedOutputs.
In this case mode should be mSet.
#mDispatchWithIndex isn't set, the bits 0..23 describe one or more outputs.
mode - Ones of mAdd, mSet, mRemove to presribe,
what to do with dst.level -
public final java.lang.String setOutputFromString(java.lang.String ctrl,
java.lang.StringBuffer 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(FileWriter file)
setOutputFromString(String, StringBuffer).
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 mask
mDispatchInDispatcherThread and/or mDispatchInCallingThread
private final int dispatchMsg(int dstBits,
boolean bDispatchInDispatcherThread,
int identNumber,
OS_TimeStamp creationTime,
java.lang.String text,
Va_list args)
dstBits - Destination identificator. If the bit mDispatchInDispatcherThread is set,
the dispatching should be done only for a destination if the destination is valid
for the dispatcher thread.
Elsewhere if the bit is 0, the dispatching should be done only for a destination
if the destination is valid for the calling thread.bDispatchInDispatcherThread - true if this method is called in dispatcher thread,
false if called in calling thread. This param is compared with MsgDispatcher.Output.dstInDispatcherThread,
only if it is equal with them, the message is outputted.identNumber - identification of the message.creationTime - text - The identifier text @pjava2c=zeroTermString.args - @pjava2c=nonPersistent.
public final boolean sendMsg(int identNumber,
java.lang.String text,
java.lang.Object... args)
sendMsg in interface LogMessageidentNumber - text - The text representation of the message, format string, see java.lang.String.format(..).args - see interface
public final boolean sendMsgTime(int identNumber,
OS_TimeStamp creationTime,
java.lang.String text,
java.lang.Object... args)
sendMsgTime in interface LogMessageidentNumber - text - The text representation of the message, format string, see java.lang.String.format(..).args - see interfacecreationTime - absolute time stamp. @Java2C=perValue.
public final boolean sendMsgVaList(int identNumber,
OS_TimeStamp creationTime,
java.lang.String text,
Va_list args)
sendMsgVaList in interface LogMessageidentNumber - creationTime - text - The identifier text @pjava2c=zeroTermString.typeArgs - Type chars, ZCBSIJFD for boolean, char, byte, short, int, long, float double.args - see interface
public final int dispatchQueuedMsg()
final void stop()
public void close()
close in interface LogMessageorg.vishia.util.LogMessage#close()public void flush()
flush in interface LogMessageorg.vishia.util.LogMessage#close()public boolean isOnline()
LogMessage
isOnline in interface LogMessagepublic final void tickAndFlushOrClose()
LogMessage.flush() for all queued outputs.
This method can be called in the dispatcher thread cyclically, as opposite to the
Thread.start(), where this routine is called too.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||