job_entrance_ask_chain.cc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright [2021] JD.com, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "job_entrance_ask_chain.h"
  17. #include "timer/timer_list.h"
  18. #include "task/task_request.h"
  19. #include "poll/poller_base.h"
  20. JobEntranceAskChain::JobEntranceAskChain(PollerBase *t, int c)
  21. : ownerThread(t), main_chain(t), check(c)
  22. {
  23. tlist = t->get_timer_list(c);
  24. stat_job_procedure_time[0] = g_stat_mgr.get_sample(REQ_USEC_ALL);
  25. stat_job_procedure_time[1] = g_stat_mgr.get_sample(REQ_USEC_GET);
  26. stat_job_procedure_time[2] = g_stat_mgr.get_sample(REQ_USEC_INS);
  27. stat_job_procedure_time[3] = g_stat_mgr.get_sample(REQ_USEC_UPD);
  28. stat_job_procedure_time[4] = g_stat_mgr.get_sample(REQ_USEC_DEL);
  29. stat_job_procedure_time[5] = g_stat_mgr.get_sample(REQ_USEC_FLUSH);
  30. stat_job_procedure_time[6] = g_stat_mgr.get_sample(REQ_USEC_HIT);
  31. stat_job_procedure_time[7] = g_stat_mgr.get_sample(REQ_USEC_REPLACE);
  32. }
  33. JobEntranceAskChain::~JobEntranceAskChain()
  34. {
  35. }
  36. void JobEntranceAskChain::record_job_procedure_time(int hit, int type,
  37. unsigned int usec)
  38. {
  39. static const unsigned char cmd2type[] = {
  40. /*TYPE_PASS*/ 0,
  41. /*result_code*/ 0,
  42. /*DTCResultSet*/ 0,
  43. /*HelperAdmin*/ 0,
  44. /*Get*/ 1,
  45. /*Purge*/ 5,
  46. /*Insert*/ 2,
  47. /*Update*/ 3,
  48. /*Delete*/ 4,
  49. /*Other*/ 0,
  50. /*Other*/ 0,
  51. /*Other*/ 0,
  52. /*Replace*/ 7,
  53. /*Flush*/ 5,
  54. /*Invalidate*/ 0,
  55. /*Monitor*/ 0,
  56. /*ReloadConfig*/ 0,
  57. /*Replicate*/ 1,
  58. /*Migrate*/ 1,
  59. };
  60. stat_job_procedure_time[0].push(usec);
  61. unsigned int t = hit ? 6 : cmd2type[type];
  62. if (t)
  63. stat_job_procedure_time[t].push(usec);
  64. }
  65. void JobEntranceAskChain::record_job_procedure_time(DTCJobOperation *req)
  66. {
  67. record_job_procedure_time(req->flag_is_hit(), req->request_code(),
  68. req->responseTimer.live());
  69. }