0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RangeServerConnection.h
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 #ifndef HYPERTABLE_RANGESERVERCONNECTION_H
23 #define HYPERTABLE_RANGESERVERCONNECTION_H
24 
25 #include "AsyncComm/CommAddress.h"
26 
27 #include "Common/InetAddr.h"
28 
30 
31 namespace Hypertable {
32 
33  namespace RangeServerConnectionFlags {
34  enum {
35  INIT = 0x00,
36  BALANCED = 0x01,
37  REMOVED = 0x02
38  };
39  }
40 
41  class RangeServerHyperspaceCallback;
42 
44  public:
48  virtual ~RangeServerConnection() { }
49 
50  bool connect(const String &hostname, InetAddr local_addr,
51  InetAddr public_addr);
52  bool disconnect();
53  bool connected();
54  void set_removed();
55  bool get_removed();
56  bool set_balanced();
57  bool get_balanced();
58 
59  void set_disk_fill_percentage(double percentage) {
60  m_disk_fill_percentage = percentage;
61  }
63 
64  void set_recovering(bool b);
65  bool is_recovering();
66 
67  void set_hyperspace_handle(uint64_t handle, RangeServerHyperspaceCallback *cb);
68  bool get_hyperspace_handle(uint64_t *handle, RangeServerHyperspaceCallback **cb);
69 
71 
72  const String& location() const { return m_location; }
73  const String& hostname() const { return m_hostname; }
74  InetAddr local_addr() const { return m_local_addr; }
75  InetAddr public_addr() const { return m_public_addr; }
76 
77  const std::string to_str();
78 
79  const String name() override { return "RangeServerConnection"; }
80  void display(std::ostream &os) override;
81 
88  void decode(const uint8_t **bufp, size_t *remainp,
89  uint16_t definition_version) override;
90 
91  private:
92 
93  uint8_t encoding_version() const override;
94 
95  size_t encoded_length_internal() const override;
96 
97  void encode_internal(uint8_t **bufp) const override;
98 
99  void decode_internal(uint8_t version, const uint8_t **bufp,
100  size_t *remainp) override;
101 
102  void decode_old(const uint8_t **bufp, size_t *remainp);
103 
104  uint64_t m_handle {};
108  int32_t m_state {};
113  bool m_connected {};
114  bool m_recovering {};
115  };
116  typedef std::shared_ptr<RangeServerConnection> RangeServerConnectionPtr;
117 
118 } // namespace Hypertable
119 
120 #endif // HYPERTABLE_RANGESERVERCONNECTION_H
void decode(const uint8_t **bufp, size_t *remainp, uint16_t definition_version) override
Decodes serialized RangeServerConnection object.
std::shared_ptr< RangeServerConnection > RangeServerConnectionPtr
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
size_t encoded_length_internal() const override
Returns internal serialized length.
Declarations for CommAddress.
void decode_old(const uint8_t **bufp, size_t *remainp)
Base class for MetaLog entities.
Definition: MetaLogEntity.h:62
Callback class for range server lock files.
RangeServerHyperspaceCallback * m_hyperspace_callback
Encapsulate an internet address.
Definition: InetAddr.h:66
void set_hyperspace_handle(uint64_t handle, RangeServerHyperspaceCallback *cb)
void set_disk_fill_percentage(double percentage)
void display(std::ostream &os) override
Prints a textual representation of the entity state to an ostream.
void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized representation of object from a buffer.
void encode_internal(uint8_t **bufp) const override
Writes serialized representation of object to a buffer.
Hypertable definitions
Declarations for MetaLog::Writer.
uint8_t encoding_version() const override
Returns encoding version.
Internet address wrapper classes and utility functions.
bool connect(const String &hostname, InetAddr local_addr, InetAddr public_addr)
const String name() override
Returns the name of the entity.
bool get_hyperspace_handle(uint64_t *handle, RangeServerHyperspaceCallback **cb)
RangeServerConnection(const String &location, const String &hostname, InetAddr public_addr)
Address abstraction to hold either proxy name or IPv4:port address.
Definition: CommAddress.h:52