SequoiaDB
 All Classes Files Functions Variables Pages
Public Member Functions | List of all members
SequoiaNode Class Reference

Public Member Functions

 getName ()
 
 getHostName ()
 
 getServiceName ()
 
 connect ()
 
 start ()
 
 stop ()
 
 getNodeName ()
 
 getStatus ()
 

Detailed Description

SequoiaNode Class. To get this Class object must be call SequoiaGroup::getMaster or SequoiaGroup::getNode or SequoiaGroup::getSlave.

Class for create an object of the node

Member Function Documentation

SequoiaNode::connect ( )

Connect the node.

Returns
Returns a new SequoiaDB object.
Return values
SequoiaDBObject

Example:

//connect to the coord
$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
//get group object
$groupObj = $db -> getGroup( 'myGroup' ) ;
if( empty( $groupObj ) ) {
$err = $db -> getLastErrorMsg() ;
echo "Failed to call getGroup, error code: ".$err['errno'] ;
return ;
}
//get node object
$nodeObj = $groupObj -> getNode( 'host1:11910' ) ;
if( empty( $nodeObj ) ) {
$err = $db -> getLastErrorMsg() ;
echo "Failed to get the node, error code: ".$err['errno'] ;
return ;
}
//connect to the node
$nodeDB = $nodeObj -> connect() ;
if( empty( $nodeDB ) ) {
echo "Failed to connect node database, error code: ".$err['errno'] ;
return ;
}
//get node contexts
$cursor = $nodeDB -> list( SDB_LIST_CONTEXTS ) ;
if( empty( $cursor ) ) {
$err = $db -> getLastErrorMsg() ;
echo "Failed to call list, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaNode::getHostName ( )

Get the node host name.

Returns
Returns the node host name.
Return values
string<node_hostname>

Example:

$hostName = $nodeObj -> getName() ;
$err = $db -> getLastErrorMsg() ;
if( $err['errno'] != 0 ) {
echo "Failed to get host name, error code: ".$err['errno'] ;
return ;
}
echo "Host name is: ".$hostName ;
SequoiaNode::getName ( )

Get the node name.

Returns
Returns the node name.
Return values
string<node_name>

Example:

$nodeName = $nodeObj -> getName() ;
$err = $db -> getLastErrorMsg() ;
if( $err['errno'] != 0 ) {
echo "Failed to get node name, error code: ".$err['errno'] ;
return ;
}
echo "Node name is: ".$nodeName ;
SequoiaNode::getNodeName ( )

Get the node name.

See Also
getName().
Deprecated:
This function is deprecated, use the function getName() instead.
SequoiaNode::getServiceName ( )

Get the node service name.

Returns
Returns the node service name.
Return values
string<node_servicename>

Example:

$servicename = $nodeObj -> getServiceName() ;
$err = $db -> getLastErrorMsg() ;
if( $err['errno'] != 0 ) {
echo "Failed to get service name, error code: ".$err['errno'] ;
return ;
}
echo "Service name is: ".$servicename ;
SequoiaNode::getStatus ( )

Get node status.

Deprecated:
This function is deprecated.
SequoiaNode::start ( )

Start the node.

Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $nodeObj -> start() ;
if( $err['errno'] != 0 ) {
echo "Failed to start node, error code: ".$err['errno'] ;
return ;
}
SequoiaNode::stop ( )

Stop the node.

Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $nodeObj -> stop() ;
if( $err['errno'] != 0 ) {
echo "Failed to stop node, error code: ".$err['errno'] ;
return ;
}

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