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

Public Member Functions

 isCatalog ()
 
 getName ()
 
 start ()
 
 stop ()
 
 reelect (array|string $options=NULL)
 
 getDetail ()
 
 getMaster ()
 
 getSlave ($positionsArray=void)
 
 getNode (string $name)
 
 createNode (string $hostName, string $serviceName, string $databasePath, array|string $configure=NULL)
 
 removeNode (string $hostName, string $serviceName, array|string $configure=NULL)
 
 attachNode (string $hostName, string $serviceName, array|string $options)
 
 detachNode (string $hostName, string $serviceName, array|string $options)
 
 getNodeNum (integer $status)
 

Detailed Description

SequoiaGroup Class. To get this Class object must be call SequoiaDB::getGroup.

Member Function Documentation

SequoiaGroup::attachNode ( string  $hostName,
string  $serviceName,
array|string  $options 
)

Attach a node to the group.

Parameters
$hostNamethe string argument. The hostname for the catalog replica group.
$serviceNamethe string argument. The servicename for the catalog replica group.
$optionsan array or the string argument. The options of attach. 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.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $groupObj -> attachNode( 'host1', '11900', array( 'KeepData' => true ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to attach node, error code: ".$err['errno'] ;
return ;
}
SequoiaGroup::createNode ( string  $hostName,
string  $serviceName,
string  $databasePath,
array|string  $configure = NULL 
)

Create node.

Parameters
$hostNamethe string argument. The hostname for the catalog replica group.
$serviceNamethe string argument. The servicename for the catalog replica group.
$databasePaththe string argument. The path for the catalog replica group.
$configurethe string argument. The configurations for the catalog replica group.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $groupObj -> createNode( 'host1', '11900', '/opt/sequoiadb/database/catalog/11900' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to create node, error code: ".$err['errno'] ;
return ;
}
SequoiaGroup::detachNode ( string  $hostName,
string  $serviceName,
array|string  $options 
)

Detach a node from the group.

Parameters
$hostNamethe string argument. The hostname for the catalog replica group.
$serviceNamethe string argument. The servicename for the catalog replica group.
$optionsan array or the string argument. The options of detach. 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.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $groupObj -> detachNode( 'host1', '11900', array( 'KeepData' => true ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to detach node, error code: ".$err['errno'] ;
return ;
}
SequoiaGroup::getDetail ( )

Get the group detail.

Returns
Returns the group detail, default return array.
Return values
arraydetail
stringdetail

Example:

$detail = $groupObj -> getDetail() ;
$err = $db -> getLastErrorMsg() ;
if( $err['errno'] != 0 ) {
echo "Failed to call getDetail, error code: ".$err['errno'] ;
return ;
}
var_dump( $detail ) ;
SequoiaGroup::getMaster ( )

Get the master node.

Returns
Returns a new SequoiaNode object.
Return values
SequoiaNodeObject

Example:

$nodeObj = $groupObj -> getMaster() ;
if( empty( $nodeObj ) ) {
$err = $db -> getLastErrorMsg() ;
echo "Failed to get the master node, error code: ".$err['errno'] ;
return ;
}
SequoiaGroup::getName ( )

Get the specified replica group name.

Returns
Returns the group name.
Return values
string<group_name>

Example:

$groupName = $groupObj -> getName() ;
$err = $db -> getLastErrorMsg() ;
if( $err['errno'] != 0 ) {
echo "Failed to get group name, error code: ".$err['errno'] ;
return ;
}
echo "Group name is: ".$groupName ;
SequoiaGroup::getNode ( string  $name)

Get the node.

Parameters
$namethe string argument. The name of the node.
Returns
Returns a new SequoiaNode object.
Return values
SequoiaNodeObject

Example:

$nodeObj = $groupObj -> getNode( 'host1:11910' ) ;
if( empty( $nodeObj ) ) {
$err = $db -> getLastErrorMsg() ;
echo "Failed to get the node, error code: ".$err['errno'] ;
return ;
}
SequoiaGroup::getNodeNum ( integer  $status)

Get the status node number.

Deprecated:
This function is deprecated.
SequoiaGroup::getSlave (   $positionsArray = void)

Get the slave node.

Parameters
$positionsArrayan array argument. The array of node's position, the array elements can be 1-7.
Returns
Returns a new SequoiaNode object.
Return values
SequoiaNodeObject

Example: Get one of slave node

$nodeObj = $groupObj -> getSlave() ;
if( empty( $nodeObj ) ) {
$err = $db -> getLastErrorMsg() ;
echo "Failed to get the slave node, error code: ".$err['errno'] ;
return ;
}

Example: Get a specified slave node

$nodeObj = $groupObj -> getSlave( array( 1, 2, 3 ) ) ;
if( empty( $nodeObj ) ) {
$err = $db -> getLastErrorMsg() ;
echo "Failed to get the slave node, error code: ".$err['errno'] ;
return ;
}
SequoiaGroup::isCatalog ( )

Judge whether the specified replica group is catalog.

Returns
Returns the result.
Return values
booleanisCatalog

Example:

$isCata = $groupObj -> isCatalog() ;
if( $isCata == true ) {
echo "This is the catalog group." ;
} else {
echo "This is not the catalog group" ;
}
SequoiaGroup::reelect ( array|string  $options = NULL)

Re-elected in the replication group.

Parameters
$optionsan array or the string argument. The $options of reelection. Please reference here for more detail.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example: 60 seconds for new elections.

$err = $groupObj -> reelect( array( 'Seconds' => 60 ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call reelect, error code: ".$err['errno'] ;
return ;
}
SequoiaGroup::removeNode ( string  $hostName,
string  $serviceName,
array|string  $configure = NULL 
)

Remove node in a given replica group.

Parameters
$hostNamethe string argument. The hostname for the catalog replica group.
$serviceNamethe string argument. The servicename for the catalog replica group.
$configurethe string argument. The configurations for the catalog replica group.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $groupObj -> removeNode( 'host1', '11900' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to remove node, error code: ".$err['errno'] ;
return ;
}
SequoiaGroup::start ( )

Start and activate the specified replica group.

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

Example:

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

Stop the specified replica group.

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

Example:

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

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