0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Debug.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #include <Common/Compat.h>
28 
29 #include "Debug.h"
30 
32 
33 #include <Common/Error.h>
34 #include <Common/Logger.h>
35 #include <Common/Serialization.h>
36 #include <Common/StaticBuffer.h>
37 
38 using namespace Hypertable;
39 using namespace Hypertable::FsBroker::Lib;
41 
42 
43 void Debug::run() {
45  const uint8_t *ptr = m_event->payload;
46  size_t remain = m_event->payload_len;
47 
48  try {
49  StaticBuffer serialized_params;
51  params.decode(&ptr, &remain);
52  serialized_params.base = (uint8_t *)ptr;
53  serialized_params.size = remain;
54  serialized_params.own = false;
55  m_broker->debug(&cb, params.get_command(), serialized_params);
56  }
57  catch (Exception &e) {
58  HT_ERROR_OUT << e << HT_END;
59  cb.error(e.code(), "Error handling DEBUG message");
60  }
61 }
A memory buffer of static size.
Definition: StaticBuffer.h:45
Request parameters for debug requests.
Definition: Debug.h:46
virtual void debug(ResponseCallback *cb, int32_t command, StaticBuffer &serialized_parameters)=0
Debug command.
Broker * m_broker
Pointer to file system broker object.
Definition: Debug.h:69
virtual void run()
Invokes the debug function.
Definition: Debug.cc:43
Logging routines and macros.
Comm * m_comm
Pointer to comm layer.
Definition: Debug.h:67
Compatibility Macros for C/C++.
#define HT_END
Definition: Logger.h:220
Functions to serialize/deserialize primitives to/from a memory buffer.
A memory buffer of static size.
#define HT_ERROR_OUT
Definition: Logger.h:301
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
Definition: Serializable.cc:70
int32_t get_command()
Gets command code.
Definition: Debug.h:61
This class is used to generate and deliver standard responses back to a client.
Hypertable definitions
virtual int error(int error, const String &msg)
Sends a standard error response back to the client.
Declarations for Debug request handler.
This is a generic exception class for Hypertable.
Definition: Error.h:314
EventPtr m_event
MESSAGE Event from which handler was initialized.
File system broker framework and client library.
Definition: Broker.h:44
Declarations for Debug request parameters.
Error codes, Exception handling, error logging.
int code() const
Returns the error code.
Definition: Error.h:391