0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Pread.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 "Pread.h"
30 
33 
35 
36 #include <Common/Error.h>
37 #include <Common/Logger.h>
38 #include <Common/Serialization.h>
39 
40 using namespace Hypertable;
41 using namespace Hypertable::FsBroker::Lib;
43 
44 void Pread::run() {
46  const uint8_t *ptr = m_event->payload;
47  size_t remain = m_event->payload_len;
48 
49  try {
51  params.decode(&ptr, &remain);
52  m_broker->pread(&cb, params.get_fd(), params.get_offset(),
53  params.get_amount(), params.get_verify_checksum());
54  }
55  catch (Exception &e) {
56  HT_ERROR_OUT << e << HT_END;
57  cb.error(e.code(), "Error handling PREAD message");
58  }
59 }
int32_t get_fd()
Gets file descriptor.
Definition: Pread.h:68
Broker * m_broker
Pointer to file system broker object.
Definition: Pread.h:68
Declarations for Read response callback.
uint64_t get_offset()
Gets file offset.
Definition: Pread.h:72
uint32_t get_amount()
Gets amount of data to read.
Definition: Pread.h:76
Declarations for Pread request handler.
Logging routines and macros.
Compatibility Macros for C/C++.
Declarations for Pread request parameters.
#define HT_END
Definition: Logger.h:220
Functions to serialize/deserialize primitives to/from a memory buffer.
#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
virtual void pread(Response::Callback::Read *cb, uint32_t fd, uint64_t offset, uint32_t amount, bool verify_checksum)=0
Read from file at position.
bool get_verify_checksum()
Gets verify checksum flag.
Definition: Pread.h:80
Hypertable definitions
Application handler for read function.
Definition: Read.h:47
virtual int error(int error, const String &msg)
Sends a standard error response back to the client.
Comm * m_comm
Pointer to comm layer.
Definition: Pread.h:66
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 ResponseCallback.
Request parameters for pread requests.
Definition: Pread.h:46
virtual void run()
Invokes the pread function.
Definition: Pread.cc:44
Error codes, Exception handling, error logging.
int code() const
Returns the error code.
Definition: Error.h:391