0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Private Attributes | List of all members
Hypertable::ClusterId Class Reference

Provides access to the cluster ID. More...

#include <ClusterId.h>

Public Types

enum  { GENERATE_IF_NOT_FOUND =1 }
 Flag to signal constructor to generate cluster ID if not found. More...
 

Public Member Functions

 ClusterId (Hyperspace::SessionPtr &hyperspace, bool generate_if_not_found=false)
 Constructor. More...
 

Static Public Member Functions

static uint64_t get ()
 Gets the cluster ID. More...
 

Static Private Attributes

static uint64_t id
 Cluster ID. More...
 

Detailed Description

Provides access to the cluster ID.

Each cluster is assigned a unique identifier, which is a 64-bit unsigned integer. This cluster ID is generated once by the Master and is stored in Hyperspace. This class provides access to the cluster ID and can also be used to generate the cluster ID if it does not exist.

Definition at line 45 of file ClusterId.h.

Constructor & Destructor Documentation

ClusterId::ClusterId ( Hyperspace::SessionPtr hyperspace,
bool  generate_if_not_found = false 
)

Constructor.

This method attempts to read the cluster ID from the cluster_id attribute of the /hypertable/master file in Hyperspace. If found, the cluster ID will be stored to a static member variable and can be obtained via a call to the static member function get(). If the cluster_id attribute does not exist and the generate_if_not_found is true, then the method will generate a cluster ID by taking the first 64-bits of the MD5 hash value of the string formed by concatenating the IP address of the primary interface with the master listen port and the current time. The exact format is as follows:

  <primary-ip> + ':' + <master-listen-port> + <current-time>

Once the ID is generated, it will get written to the cluster_id attribute of the /hypertable/master file in Hyperspace and stored to a static member variable that can be returned by get(). If any errors are encountered, or if the cluster_id attrbute is not found and generate_if_not_found is false, then an exception will be thrown.

Parameters
hyperspaceReference to hyperspace session
generate_if_not_foundFlag to control whether or not the ID should be generated if it is not found

Definition at line 48 of file ClusterId.cc.

Member Function Documentation

static uint64_t Hypertable::ClusterId::get ( )
inlinestatic

Gets the cluster ID.

Returns
The cluster ID

Definition at line 85 of file ClusterId.h.

Member Data Documentation

uint64_t ClusterId::id
staticprivate

Cluster ID.

Definition at line 90 of file ClusterId.h.


The documentation for this class was generated from the following files: