MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CpcClient.hpp
1 /*
2  Copyright (C) 2003-2007 MySQL AB, 2009 Sun Microsystems, Inc.
3 
4  All rights reserved. Use is subject to license terms.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; version 2 of the License.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 #ifndef __CPCCLIENT_HPP_INCLUDED__
21 #define __CPCCLIENT_HPP_INCLUDED__
22 
23 #include <Parser.hpp>
24 #include <SocketServer.hpp>
25 #include <util/InputStream.hpp>
26 #include <util/OutputStream.hpp>
27 
28 /*
29  Simple CPC client class.
30 */
32 public:
33  SimpleCpcClient(const char *host, int port);
34  ~SimpleCpcClient();
35 
36  int getPort() const { return port;}
37  const char * getHost() const { return host;}
38 
39  struct Process {
40  int m_id;
41  BaseString m_name;
42 
43  BaseString m_owner;
44  BaseString m_group;
45  BaseString m_runas;
46 
47  BaseString m_cwd;
48  BaseString m_env;
49  BaseString m_path;
50  BaseString m_args;
51 
52  BaseString m_type;
53  BaseString m_status;
54 
55  BaseString m_stdin;
56  BaseString m_stdout;
57  BaseString m_stderr;
58  BaseString m_ulimit;
59  BaseString m_shutdown_options;
60  };
61 
62 private:
63  class ParserDummy : SocketServer::Session {
64  public:
65  ParserDummy(NDB_SOCKET_TYPE sock);
66  };
67 
69  typedef ParserRow<ParserDummy> ParserRow_t;
70 
71  char *host;
72  int port;
73  NDB_SOCKET_TYPE cpc_sock;
74 
75 public:
76  int connect();
77  int list_processes(Vector<Process>&, Properties &reply);
78  int start_process(Uint32 id, Properties& reply);
79  int stop_process(Uint32 id, Properties& reply);
80  int undefine_process(Uint32 id, Properties& reply);
81  int define_process(Process & p, Properties& reply);
82 
83 private:
84  int cpc_send(const char *cmd,
85  const Properties &args);
86 
87 
88  Parser_t::ParserStatus cpc_recv(const ParserRow_t *syntax,
89  const Properties **reply,
90  void **user_data = NULL);
91 
92  const Properties *cpc_call(const char *cmd,
93  const Properties &args,
94  const ParserRow_t *reply_syntax);
95 };
96 
97 #endif /* !__CPCCLIENT_HPP_INCLUDED__ */