RepApiInterpreter.cpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:2k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #include "RepApiInterpreter.hpp"
  14. #include <signaldata/GrepImpl.hpp>
  15. RepApiInterpreter::RepApiInterpreter(RepComponents * comps, int port)
  16. {
  17.   m_repComponents = comps;
  18.   m_repState = comps->getRepState();
  19.   m_port = port;
  20.   ss = new SocketServer();
  21.   serv = new RepApiService(*this);
  22. }
  23. RepApiInterpreter::~RepApiInterpreter()
  24. {
  25. }
  26. void
  27. RepApiInterpreter::startInterpreter() 
  28. {
  29.   if(!ss->setup(serv, m_port)){
  30.     sleep(1);
  31.     delete ss;
  32.     delete serv;
  33.   }
  34.   ss->startServer();
  35. }
  36. void
  37. RepApiInterpreter::stopInterpreter() 
  38. {
  39.   delete ss;
  40. }
  41. Properties *
  42. RepApiInterpreter::execCommand(const Properties & props)
  43. {
  44.   Properties * result = new Properties();
  45.   Uint32 req = 0;
  46.   Uint32 epoch = 0;
  47.   props.get("request", &req);
  48.   props.get("epoch", &epoch);
  49.   GrepError::Code err = m_repState->protectedRequest((GrepReq::Request)req, 
  50.      epoch);
  51.   result->put("err", err);
  52.   return result;
  53. }
  54. Properties *
  55. RepApiInterpreter::getStatus()
  56. {
  57.   return m_repState->getStatus();
  58. }
  59. Properties * 
  60. RepApiInterpreter::query(Uint32 counter, Uint32 replicationId)
  61. {
  62.   return m_repState->query((QueryCounter)counter, replicationId);
  63. }