Tracer internal realization of Zorka source code interpretation

Source: Internet
Author: User

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:
    1. Zorkaagent The record is submitted to the queue of the corresponding thread object after the pile is inserted submitqueue
    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.