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)
 
 getNodeNum (integer $status)
 
 getDetail ()
 
 getMaster ()
 
 getSlave ()
 
 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=NULL)
 
 detachNode (string $hostName, string $serviceName, array|string $options=NULL)
 

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 = NULL 
)

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.
KeepData : Whether the node data is preserved, default false.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $groupObj -> attachNode( 'host1', '11900' ) ;
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 = NULL 
)

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.
KeepData : Whether the node data is preserved, default false.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $groupObj -> detachNode( 'host1', '11900' ) ;
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 -> getError() ;
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 -> getError() ;
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 -> getError() ;
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 -> getError() ;
echo "Failed to get the node, error code: ".$err['errno'] ;
return ;
}
SequoiaGroup::getNodeNum ( integer  $status)

Get the status node number.

Parameters
$statusan integer argument. The node status, can not be null
Returns
Returns the number of node.
Return values
integerNodes number

Example:

$NodeNum = $groupObj -> getNodeNum() ;
if( $NodeNum < 0 ) {
$err = $db -> getError() ;
echo "Failed to call getNodeNum, error code: ".$err['errno'] ;
return ;
}
echo "Node number: ".$NodeNum ;
SequoiaGroup::getSlave ( )

Get the slave node.

Returns
Returns a new SequoiaNode object.
Return values
SequoiaNodeObject

Example:

$nodeObj = $groupObj -> getSlave() ;
if( empty( $nodeObj ) ) {
$err = $db -> getError() ;
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.
Seconds: New elections needed within the number of seconds to complete, default 30 seconds.
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 file: