Core class:
Zorkaasyncthread.java
protectedBlockingqueue<t>Submitqueue;/*** Processes Single item from the submit queue (if any).*/ Public voidruncycle () {Try{T obj=Submitqueue.take ();if(obj! =NULL) {List<T> LST =NewArraylist<t>(Plen); Lst.add (obj);if(Plen > 1) {Submitqueue.drainto (LST, Plen-1);} Process (LST); flush ();}} Catch(interruptedexception e) {log.error (zorkalogger.zag_errors,"Cannot perform run cycle", E);}}/*** Submits object to a queue.**@paramobj Object to be submitted*/ Public BooleanSubmit (T obj) {Try {returnSubmitqueue.offer (obj, 1, timeunit.milliseconds);} Catch(interruptedexception e) {return false;}}
It is mainly divided into two key processes:
- Zorkaagent The record is submitted to the queue of the corresponding thread object after the pile is inserted submitqueue
- BeanShell creates a thread, and after the thread starts, it continues to fetch records from the submission queue submitqueue to be processed and sent to the target terminal (log or other monitoring platform).
One, zorkaagent submit the record to the queue
The probe in the piling process calls the Traceenter, Tracereturn, TraceError, and submit four methods of Mainsubmitter, which are primarily used to process the trace record and submit it to the appropriate queue.
At the bottom of the Tracereturn, TraceError call the Pop (), Pop () method the underlying call to the Zorkaasyncthread inheritance class implementation of the Submit method, the record is submitted to the queue.
Capture the record from the queue and process it and send it to the target stream.
TRACER.BSH creates an asynchronous thread that, after the thread starts, automatically fetches the Record object from the queue and processes and sends it. Each thread corresponds to a tracer method.
Zorkaasyncthread is an abstract class, there are many inheritance, such as Zabbixtrapper, Snmptrapper, Zicotraceoutput and so on.
The process method implemented within the inheriting class is used to tell the final record to commit to the destination stream. The Submit method is used to submit the record to the pending queue.
Tracer internal realization of Zorka source code interpretation