0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Create.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 "Create.h"
30 
32 
34 
35 #include <Common/Error.h>
36 #include <Common/Logger.h>
37 #include <Common/Serialization.h>
38 
39 using namespace Hypertable::FsBroker;
40 using namespace Hypertable::FsBroker::Lib;
42 
43 void Create::run() {
45  const uint8_t *ptr = m_event->payload;
46  size_t remain = m_event->payload_len;
47 
48  try {
50  params.decode(&ptr, &remain);
51  m_broker->create(&cb, params.get_name(), params.get_flags(),
52  params.get_buffer_size(), params.get_replication(),
53  params.get_block_size());
54  }
55  catch (Exception &e) {
56  HT_ERROR_OUT << e << HT_END;
57  cb.error(e.code(), "Error handling CREATE message");
58  }
59 }
Declarations for Create request handler.
File system broker definitions.
Definition: CephBroker.h:38
int32_t get_buffer_size()
Gets buffer size.
Definition: Create.h:78
Logging routines and macros.
Compatibility Macros for C/C++.
Declarations for Create request parameters.
virtual void create(Response::Callback::Open *cb, const char *fname, uint32_t flags, int32_t bufsz, int16_t replication, int64_t blksz)=0
Open a file, and create it if it doesn't exist, optionally overwriting the contents.
#define HT_END
Definition: Logger.h:220
Functions to serialize/deserialize primitives to/from a memory buffer.
Comm * m_comm
Pointer to comm layer.
Definition: Create.h:67
#define HT_ERROR_OUT
Definition: Logger.h:301
Broker * m_broker
Pointer to file system broker object.
Definition: Create.h:69
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_replication()
Gets replication factor.
Definition: Create.h:82
Application handler for open function.
Definition: Open.h:45
virtual int error(int error, const String &msg)
Sends a standard error response back to the client.
This is a generic exception class for Hypertable.
Definition: Error.h:314
EventPtr m_event
MESSAGE Event from which handler was initialized.
const char * get_name()
Gets file name.
Definition: Create.h:70
virtual void run()
Invokes the create function.
Definition: Create.cc:43
File system broker framework and client library.
Definition: Broker.h:44
Declarations for ResponseCallback.
Error codes, Exception handling, error logging.
uint32_t get_flags()
Gets create flags.
Definition: Create.h:74
Request parameters for create requests.
Definition: Create.h:46
int code() const
Returns the error code.
Definition: Error.h:391