X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffilter_frontend_net.cpp;h=3246eec922ac4cdac2609b797bb6995c0ec76b13;hb=73da32be92051bafbbd89cb2d0b0234ec149aa9c;hp=cf28e9b6bd3353c474c2249efd4432c08584b1a2;hpb=24037b116e6c6a46a477e973e60e5fe6030b46c3;p=metaproxy-moved-to-github.git diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index cf28e9b..3246eec 100644 --- a/src/filter_frontend_net.cpp +++ b/src/filter_frontend_net.cpp @@ -61,6 +61,10 @@ namespace metaproxy_1 { ZAssocServer **az; int m_duration_freq[22]; double m_duration_lim[22]; + double m_duration_max; + double m_duration_min; + double m_duration_total; + bool m_stop; public: Rep(); ~Rep(); @@ -90,7 +94,7 @@ namespace metaproxy_1 { yazpp_1::IPDU_Observable *the_PDU_Observable, int fd); void recv_GDU(Z_GDU *apdu, int len); - + void report(Z_HTTP_Request *hreq); void failNotify(); void timeoutNotify(); void connectNotify(); @@ -183,7 +187,15 @@ void yf::FrontendNet::ThreadPoolPackage::result(const char *t_info) while (m_p->m_duration_lim[ent] != 0.0 && duration > m_p->m_duration_lim[ent]) ent++; m_p->m_duration_freq[ent]++; - + + m_p->m_duration_total += duration; + + if (m_p->m_duration_max < duration) + m_p->m_duration_max = duration; + + if (m_p->m_duration_min == 0.0 || m_p->m_duration_min > duration) + m_p->m_duration_min = duration; + if (m_p->m_msg_config.length()) { Z_GDU *z_gdu = gdu->get(); @@ -275,6 +287,71 @@ yf::FrontendNet::ZAssocChild::~ZAssocChild() { } +void yf::FrontendNet::ZAssocChild::report(Z_HTTP_Request *hreq) +{ + mp::odr o; + + Z_GDU *gdu_res = o.create_HTTP_Response(m_session, hreq, 200); + + Z_HTTP_Response *hres = gdu_res->u.HTTP_Response; + + mp::wrbuf w; + size_t i; + int number_total = 0; + + for (i = 0; m_p->m_duration_lim[i] != 0.0; i++) + number_total += m_p->m_duration_freq[i]; + number_total += m_p->m_duration_freq[i]; + + wrbuf_puts(w, "\n"); + wrbuf_puts(w, "\n"); + wrbuf_printf(w, " \n", number_total); + for (i = 0; m_p->m_duration_lim[i] != 0.0; i++) + { + if (m_p->m_duration_freq[i] > 0) + wrbuf_printf( + w, " \n", + i > 0 ? m_p->m_duration_lim[i - 1] : 0.0, + m_p->m_duration_lim[i], m_p->m_duration_freq[i]); + } + + if (m_p->m_duration_freq[i] > 0) + wrbuf_printf( + w, " \n", + m_p->m_duration_lim[i - 1], m_p->m_duration_freq[i]); + + if (m_p->m_duration_max != 0.0) + wrbuf_printf( + w, " \n", + m_p->m_duration_max); + if (m_p->m_duration_min != 0.0) + wrbuf_printf( + w, " \n", + m_p->m_duration_min); + if (m_p->m_duration_total != 0.0) + wrbuf_printf( + w, " \n", + m_p->m_duration_total / number_total); + + wrbuf_puts(w, " \n"); + + int thread_busy; + int thread_total; + m_thread_pool_observer->get_thread_info(thread_busy, thread_total); + + wrbuf_printf(w, " \n", + thread_busy, thread_total); + + wrbuf_puts(w, "\n"); + + hres->content_len = w.len(); + hres->content_buf = (char *) w.buf(); + + int len; + send_GDU(gdu_res, &len); +} + void yf::FrontendNet::ZAssocChild::recv_GDU(Z_GDU *z_pdu, int len) { m_no_requests++; @@ -288,45 +365,7 @@ void yf::FrontendNet::ZAssocChild::recv_GDU(Z_GDU *z_pdu, int len) if (m_p->m_stat_req.length() && !strcmp(hreq->path, m_p->m_stat_req.c_str())) { - mp::odr o; - - Z_GDU *gdu_res = o.create_HTTP_Response(m_session, hreq, 200); - - Z_HTTP_Response *hres = gdu_res->u.HTTP_Response; - - mp::wrbuf w; - size_t i; - int number_total = 0; - - for (i = 0; m_p->m_duration_lim[i] != 0.0; i++) - number_total += m_p->m_duration_freq[i]; - number_total += m_p->m_duration_freq[i]; - - wrbuf_puts(w, "\n"); - wrbuf_puts(w, "\n"); - wrbuf_printf(w, " \n", number_total); - for (i = 0; m_p->m_duration_lim[i] != 0.0; i++) - { - if (m_p->m_duration_freq[i] > 0) - wrbuf_printf( - w, " \n", - i > 0 ? m_p->m_duration_lim[i - 1] : 0.0, - m_p->m_duration_lim[i], m_p->m_duration_freq[i]); - } - - if (m_p->m_duration_freq[i] > 0) - wrbuf_printf( - w, " \n", - m_p->m_duration_lim[i - 1], m_p->m_duration_freq[i]); - wrbuf_puts(w, " \n"); - wrbuf_puts(w, "\n"); - - hres->content_len = w.len(); - hres->content_buf = (char *) w.buf(); - - int len; - send_GDU(gdu_res, &len); + report(hreq); return; } } @@ -477,10 +516,13 @@ yf::FrontendNet::Rep::Rep() m_duration_lim[18] = 15.0; m_duration_lim[19] = 20.0; m_duration_lim[20] = 30.0; - m_duration_lim[21] = 0; + m_duration_lim[21] = 0.0; + m_duration_max = 0.0; + m_duration_min = 0.0; + m_duration_total = 0.0; + m_stop = false; } - yf::FrontendNet::Rep::~Rep() { if (az) @@ -492,19 +534,14 @@ yf::FrontendNet::Rep::~Rep() } az = 0; } - + yf::FrontendNet::~FrontendNet() { } void yf::FrontendNet::stop() const { - if (m_p->az) - { - size_t i; - for (i = 0; i < m_p->m_ports.size(); i++) - m_p->az[i]->server(""); - } + m_p->m_stop = true; } bool yf::FrontendNet::My_Timer_Thread::timeout() @@ -548,6 +585,16 @@ void yf::FrontendNet::process(Package &package) const } while (m_p->mySocketManager.processEvent() > 0) { + if (m_p->m_stop) + { + m_p->m_stop = false; + if (m_p->az) + { + size_t i; + for (i = 0; i < m_p->m_ports.size(); i++) + m_p->az[i]->server(""); + } + } int no = m_p->mySocketManager.getNumberOfObservers(); if (no <= 1) break;