0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MetaLogEntityTaskAcknowledgeRelinquish.cc
Go to the documentation of this file.
1 /* -*- c++ -*-
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; version 3 of the
9  * 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 
22 #include <Common/Compat.h>
23 
24 #include "Global.h"
26 
28 
29 #include <Common/Serialization.h>
30 
31 using namespace Hypertable;
32 using namespace Hypertable::MetaLog;
33 
35 
37  : EntityTask(EntityType::TASK_ACKNOWLEDGE_RELINQUISH), location(loc), range_id(id), table(t), range_spec(rs) {
38 }
39 
41  String label = format("%lld %s %s[%s..%s]", (Lld)range_id, location.c_str(),
43 
44  try {
45  HT_INFOF("relinquish_acknowledge(%s)", label.c_str());
46  Global::master_client->relinquish_acknowledge(location, range_id, table, range_spec);
48  }
49  catch (Exception &e) {
50  HT_WARN_OUT << "Master::relinquish_acknowledge(" << label << ") error - " << e << HT_END;
51  return false;
52  }
53 
54  HT_INFOF("Successfully relinquished %s", label.c_str());
55 
56  return true;
57 }
58 
61 }
62 
63 void EntityTaskAcknowledgeRelinquish::decode(const uint8_t **bufp,
64  size_t *remainp,
65  uint16_t definition_version) {
66  if (definition_version <= 2) {
67  decode_old(bufp, remainp);
68  return;
69  }
70  Entity::decode(bufp, remainp);
71 }
72 
74  return format("TaskAcknowledgeRelinquish %s[%s..%s]", table.id, range_spec.start_row, range_spec.end_row);
75 }
76 
78  os << " " << location << " " << table << " " << range_spec << " ";
79 }
80 
82  return 1;
83 }
84 
88 }
89 
93  table.encode(bufp);
94  range_spec.encode(bufp);
95 }
96 
97 void EntityTaskAcknowledgeRelinquish::decode_internal(uint8_t version, const uint8_t **bufp,
98  size_t *remainp) {
99  location = Serialization::decode_vstr(bufp, remainp);
100  range_id = Serialization::decode_i64(bufp, remainp);
101  table.decode(bufp, remainp);
102  range_spec.decode(bufp, remainp);
103 }
104 
105 void EntityTaskAcknowledgeRelinquish::decode_old(const uint8_t **bufp, size_t *remainp) {
106  location = Serialization::decode_vstr(bufp, remainp);
107  range_id = 0;
108  legacy_decode(bufp, remainp, &table);
109  legacy_decode(bufp, remainp, &range_spec);
110 }
char * decode_vstr(const uint8_t **bufp, size_t *remainp)
Decode a vstr (vint64, data, null).
void decode(const uint8_t **bufp, size_t *remainp, uint16_t definition_version) override
Decodes serlialized EntityTaskAcknowledgeRelinquish object.
Range specification.
Definition: RangeSpec.h:40
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
Definition: String.cc:37
virtual size_t encoded_length() const
Returns serialized object length.
Definition: Serializable.cc:37
size_t encoded_length_vstr(size_t len)
Computes the encoded length of vstr (vint64, data, null)
uint8_t encoding_version() const override
Returns encoding version.
uint64_t decode_i64(const uint8_t **bufp, size_t *remainp)
Decode a 64-bit integer in little-endian order.
const char * end_row
Definition: RangeSpec.h:60
virtual void encode(uint8_t **bufp) const
Writes serialized representation of object to a buffer.
Definition: Serializable.cc:64
static Hypertable::Lib::Master::ClientPtr master_client
Definition: Global.h:68
Compatibility Macros for C/C++.
size_t encoded_length_internal() const override
Returns internal serialized length.
void encode_i64(uint8_t **bufp, uint64_t val)
Encode a 64-bit integer in little-endian order.
#define HT_END
Definition: Logger.h:220
Functions to serialize/deserialize primitives to/from a memory buffer.
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
Definition: Serializable.cc:70
#define HT_WARN_OUT
Definition: Logger.h:291
void encode_vstr(uint8_t **bufp, const void *buf, size_t len)
Encode a buffer as variable length string (vint64, data, null)
Hypertable definitions
static void immovable_range_set_add(const TableIdentifier &table, const RangeSpec &spec)
Definition: Global.cc:92
virtual void decode(const uint8_t **bufp, size_t *remainp, uint16_t definition_version)
Decodes serialized entity state.
Definition: MetaLogEntity.h:91
const String name() override
Returns the name of the entity.
long long int Lld
Shortcut for printf formats.
Definition: String.h:53
void legacy_decode(const uint8_t **bufp, size_t *remainp, BalancePlan *plan)
const char * start_row
Definition: RangeSpec.h:59
#define HT_INFOF(msg,...)
Definition: Logger.h:272
void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized representation of object from a buffer.
This is a generic exception class for Hypertable.
Definition: Error.h:314
void display(std::ostream &os) override
Prints a textual representation of the entity state to an ostream.
void encode_internal(uint8_t **bufp) const override
Writes serialized representation of object to a buffer.
static void immovable_range_set_remove(const TableIdentifier &table, const RangeSpec &spec)
Definition: Global.cc:99
MetaLog framework.
Definition: MetaLog.h:44