SequoiaDB
 All Classes Functions
Public Member Functions | List of all members
pysequoiadb.replicagroup.replicagroup Class Reference
Inheritance diagram for pysequoiadb.replicagroup.replicagroup:

Public Member Functions

def __init__
 
def __del__
 
def __repr__
 
def get_nodenum
 
def get_detail
 
def get_master
 
def get_slave
 
def get_nodebyendpoint
 
def get_nodebyname
 
def create_node
 
def remove_node
 
def start
 
def stop
 
def is_catalog
 
def attach_node
 
def detach_node
 
def reelect
 

Detailed Description

Replica group of SequoiaDB

All operation need deal with the error code returned first, if it has.
Every error code is not SDB_OK(or 0), it means something error has appeared,
and user should deal with it according the meaning of error code printed.

@version: execute to get version
          >>> import pysequoiadb
          >>> print pysequoiadb.get_version()

@notice : The dict of built-in Python is hashed and non-ordered. so the
          element in dict may not the order we make it. we make a dict and
          print it like this:
          ...
          >>> a = {"avg_age":24, "major":"computer science"}
          >>> a
          >>> {'major': 'computer science', 'avg_age': 24}
          ...
          the elements order it is not we make it!!
          therefore, we use bson.SON to make the order-sensitive dict if the
          order is important such as operations in "$sort", "$group",
          "split_by_condition", "aggregate","create_collection"...
          In every scene which the order is important, please make it using
          bson.SON and list. It is a subclass of built-in dict
          and order-sensitive

Constructor & Destructor Documentation

def pysequoiadb.replicagroup.replicagroup.__init__ (   self,
  client 
)
constructor of replica group

Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.__del__ (   self)
release replica group object

Exceptions:
   pysequoiadb.error.SDBBaseError

Member Function Documentation

def pysequoiadb.replicagroup.replicagroup.attach_node (   self,
  hostname,
  servicename,
  config 
)
Attach node in a given replica group.

Parameters:
   Name         Type     Info:
   hostname     str      The host name for the node.
   servicename  str      The servicename for the node.
   config       dict     The configurations for the node. Can not be null or empty. Can be the follow options: 
                 KeepData: Whether to keep the original data of the new node. This option has no default value. User should specify its value explicitly. 
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.create_node (   self,
  hostname,
  servicename,
  dbpath,
  config = None 
)
Create node in a given replica group.

Parameters:
   Name         Type     Info:
   hostname     str      The host name for the node.
   servicename  str      The servicename for the node.
   dbpath       str      The database path for the node.
   config       dict     The configurations for the node.
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.detach_node (   self,
  hostname,
  servicename,
  config 
)
Detach node in a given replica group.

Parameters:
   Name         Type     Info:
   hostname     str      The host name for the node.
   servicename  str      The servicename for the node.
   config       dict     The configurations for the node. Can not be null or empty. Can be the follow options:
                 KeepData: Whether to keep the original data of the detached node. This option has no default value. User should specify its value explicitly. 
                 Enforced: Whether to detach the node forcibly, default to be false. 
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.get_detail (   self)
Get the detail of the replica group.

Return values:
   a dict object of query
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.get_master (   self)
Get the master node of the current replica group.

Return values:
   a replica node object of query
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.get_nodebyendpoint (   self,
  hostname,
  servicename 
)
Get specified node from current replica group.

Parameters:
   Name         Type     Info:
   hostname     str      The host name of the node.
   servicename  str      The service name of the node.
Return values:
   a replicanode object of query
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.get_nodebyname (   self,
  node_name 
)
Get specified node from current replica group.

Parameters:
   Name         Type     Info:
   node_name    str      The host name of the node.
Return values:
   a replicanode object of query
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.get_nodenum (   self,
  node_status 
)
Get the count of node with given status in current replica group.

Parameters:
   Name         Type     Info:
   node_status  int      The specified status, see Info as below.
Return values:
   the count of node
Exceptions:
   pysequoiadb.error.SDBBaseError
Info:
   flags : 0 or 1.
       0 : count of all node
       1 : count of actived node
       2 : count of inactived node
       3 : count of unknown node
def pysequoiadb.replicagroup.replicagroup.get_slave (   self,
  positions 
)
Get one of slave node of the current replica group, if no slave exists
   then get master.

Parameters:
   Name         Type                  Info:
   positions    int           The positions of nodes.
Return values:
   a replicanode object of query
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.is_catalog (   self)
Test whether current replica group is catalog replica group.

Return values:
   bool
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.reelect (   self,
  options = None 
)
Reelect in current group.

Parameters:
   Name         Type     Info:
   options      dict     The options of reelection. Please visit this url:
                         "http://doc.sequoiadb.com/cn/sequoiadb-cat_id-1432190873-edition_id-304"
                         for more detail.
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.remove_node (   self,
  hostname,
  servicename,
  config = None 
)
Remove node in a given replica group.

Parameters:
   Name         Type     Info:
   hostname     str      The host name for the node.
   servicename  str      The servicename for the node.
   config       dict     The configurations for the node.
Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.start (   self)
Start up current replica group.

Exceptions:
   pysequoiadb.error.SDBBaseError
def pysequoiadb.replicagroup.replicagroup.stop (   self)
Stop current replica group.

Exceptions:
   pysequoiadb.error.SDBBaseError

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