42 #include <boost/algorithm/string.hpp>
43 #include <boost/progress.hpp>
49 #define BUFFER_SIZE 65536
61 void process_event(
EventPtr &event) {
63 const ::uint8_t *decode_ptr =
event->payload + 4;
64 size_t decode_remain =
event->payload_len - 4;
65 ::uint32_t offset, len;
66 if (decode_remain == 0)
67 cout <<
"success" << endl;
69 while (decode_remain) {
71 error =
decode_i32(&decode_ptr, &decode_remain);
72 offset =
decode_i32(&decode_ptr, &decode_remain);
79 cout <<
"rejected: offset=" << offset <<
" span=" << len <<
" "
87 RangeServerCommandInterpreter::RangeServerCommandInterpreter(
90 : m_hyperspace(hyperspace), m_addr(addr),
91 m_range_server(range_server), m_cur_scanner_id(-1) {
92 HqlHelpText::install_range_server_client_text();
115 ::int32_t scanner_id;
118 info = parse(line.c_str(), parser, space_p);
125 if (table_info == 0) {
126 bool is_namespace =
false;
129 HT_FATALF(
"Hyperspace is required to execute: %s", line.c_str());
151 status.
set(Status::Code::CRITICAL,
156 status.
get(&code, output);
160 cout <<
" - " << output;
163 return static_cast<int>(code);
168 cout <<
"TableName = " << state.
table_name << endl;
180 vector<QualifiedRangeSpec *> range_vec;
181 map<QualifiedRangeSpec, int> response_map;
182 range_vec.push_back(&qrs);
184 map<QualifiedRangeSpec, int>::iterator it = response_map.begin();
186 HT_THROW(it->second,
"Problem acknowledging load range");
191 if (!FileUtils::exists(state.
input_file.c_str()))
197 ::uint8_t *send_buf = 0;
198 size_t send_buf_len = 0;
202 size_t key_len, value_len;
203 ::uint32_t send_count = 0;
204 bool outstanding =
false;
208 while (tsource->
next(key, value)) {
210 value_len = value.
length();
211 buf.
ensure(key_len + value_len);
222 std::vector<SerializedKey> keys;
223 const ::uint8_t *ptr;
228 while (ptr < buf.
ptr) {
235 std::sort(keys.begin(), keys.end());
237 send_buf = new ::uint8_t [buf.
fill()];
238 ::uint8_t *sendp = send_buf;
239 for (
size_t i=0; i<keys.size(); i++) {
243 len = key.
ptr - keys[i].ptr;
244 memcpy(sendp, keys[i].ptr, len);
247 send_buf_len = sendp - send_buf;
249 send_count = keys.size();
258 HT_THROW(Protocol::response_code(event),
259 (Protocol::string_format_message(event)));
260 process_event(event);
265 if (send_buf_len > 0) {
268 mybuf, 0, &sync_handler);
277 HT_THROW(Protocol::response_code(event),
278 (Protocol::string_format_message(event)));
279 process_event(event);
293 while (scanblock.
next(key, value))
305 "No currently open scanner");
319 while (scanblock.
next(key, value))
348 HT_THROW(Protocol::response_code(event),
349 (Protocol::string_format_message(event)));
354 cout <<
"success" << endl;
358 cout <<
"success" << endl;
363 for (
size_t i=0; text[i]; i++)
364 cout << text[i] << endl;
367 cout << endl <<
"no help for '" << state.
str <<
"'" << endl << endl;
409 cout << key.
timestamp <<
" " << key.
row <<
" DELETE" << endl;
430 <<
") for row key " << key.
row;
A memory buffer of static size.
int get_scanner_id()
Returns scanner ID associated with this scanblock.
ScanSpec & get()
Returns the built ScanSpec object.
Holds Nagios-style program status information.
PropertiesPtr properties
This singleton map stores all options.
static const uint32_t FLAG_DELETE_ROW
std::string String
A String is simply a typedef to std::string.
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
Column family specification.
bool eos()
Returns true if this is the final scanblock returned by the scanner.
uint64_t soft_limit
Soft split size limit.
static const uint32_t FLAG_DELETE_CELL
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
uint8_t * ptr
Pointer to the end of the used part of the buffer.
bool wait_for_reply(EventPtr &event)
This method is used by a client to synchronize.
void set(Code code, const std::string &text)
Sets status code and text.
A dynamic, resizable and reference counted memory buffer.
Code
Enumeration for status codes.
static const uint32_t FLAG_DELETE_COLUMN_FAMILY
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
A class managing one or more serializable ByteStrings.
std::string pseudo_table_name
Declarations for RangeServerProtocol.
File system utility functions.
Declarations for RangeState.
std::shared_ptr< Session > SessionPtr
const char * get_text(int error)
Returns a descriptive error message.
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
std::shared_ptr< Client > ClientPtr
Smart pointer to Client.
Compatibility Macros for C/C++.
Initialization helper for applications.
T get(const String &name)
Retrieves a configuration value.
size_t length() const
Retrieves the length of the serialized string.
std::string range_start_row
const uint8_t * ptr
The pointer to the serialized data.
Encapsulates a block of scan results.
#define HT_FATALF(msg,...)
const std::string & get_name() const
Gets column family name.
bool next(SerializedKey &key, ByteString &value)
Returns the next key/value pair in the scanblock.
DispatchHandler class used to synchronize with response messages.
void clear()
Clears the buffer.
Provides access to internal components of opaque key.
uint8_t * base
Pointer to the allocated memory buffer.
void get(Code *code, std::string &text) const
Gets status code and text.
size_t fill() const
Returns the size of the used portion.
This is a generic exception class for Hypertable.
Declarations for ScanBlock.
Qualified (with table identifier) range specification.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
uint8_t column_family_code
Declarations for HqlHelpText.
const char * column_qualifier
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
std::string range_end_row
void ensure(size_t len)
Ensure space for additional data Will grow the space to 1.5 of the needed space with existing data un...
uint8_t * add_unchecked(const void *data, size_t len)
Adds additional data without boundary checks.
Declarations for ClusterId.
Declarations for DispatchHandlerSynchronizer.
const char * code_to_string(int var_code)
Converts variable code to variable string.
uint8_t * next()
Retrieves the next serialized String in the buffer.
int code() const
Returns the error code.
bool next(ByteString &key, ByteString &value)