0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RequestHandlerAttrExists.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 
29 #include "Common/Compat.h"
30 #include "Common/Error.h"
31 #include "Common/Logger.h"
32 
34 
35 #include "Hyperspace/Master.h"
37 
39 
40 using namespace Hyperspace;
41 using namespace Hypertable;
42 
45  size_t decode_remain = m_event->payload_len;
46  const uint8_t *decode_ptr = m_event->payload;
47 
48  try {
49  bool has_name = decode_bool(&decode_ptr, &decode_remain);
50  uint64_t handle = 0;
51  const char* name = 0;
52  if (has_name)
53  name = decode_vstr(&decode_ptr, &decode_remain);
54  else
55  handle = decode_i64(&decode_ptr, &decode_remain);
56  const char *attr = decode_vstr(&decode_ptr, &decode_remain);
57 
58  m_master->attr_exists(&cb, m_session_id, handle, name, attr);
59  }
60  catch (Exception &e) {
61  HT_ERROR_OUT << e << HT_END;
62  cb.error(e.code(), "Error handling ATTREXISTS message");
63  }
64 }
char * decode_vstr(const uint8_t **bufp, size_t *remainp)
Decode a vstr (vint64, data, null).
Hyperspace definitions
Declarations for RequestHandlerAttrExists.
uint64_t decode_i64(const uint8_t **bufp, size_t *remainp)
Decode a 64-bit integer in little-endian order.
bool decode_bool(const uint8_t **bufp, size_t *remainp)
Decodes a boolean value from the given buffer.
Definition: Serialization.h:96
Sends back result of an attr_exists request.
Logging routines and macros.
Compatibility Macros for C/C++.
#define HT_END
Definition: Logger.h:220
#define HT_ERROR_OUT
Definition: Logger.h:301
Hypertable definitions
void attr_exists(ResponseCallbackAttrExists *cb, uint64_t session_id, uint64_t handle, const char *name, const char *attr)
Definition: Master.cc:956
virtual int error(int error, const String &msg)
Sends a standard error response back to the client.
virtual void run()
Unmarshalls request parameters and calls Master::attr_exists().
This is a generic exception class for Hypertable.
Definition: Error.h:314
EventPtr m_event
MESSAGE Event from which handler was initialized.
Declarations for ResponseCallback.
Error codes, Exception handling, error logging.
int code() const
Returns the error code.
Definition: Error.h:391