Overview

Namespaces

  • cassandra
  • None
  • PHP
  • phpcassa
    • Batch
    • Connection
    • Index
    • Iterator
    • Schema
      • DataType
    • Util
    • UUID

Classes

  • AbstractColumnFamily
  • ColumnFamily
  • ColumnSlice
  • SuperColumnFamily
  • SystemManager
  • UUID
  • Overview
  • Namespace
  • Class
  • Tree

Class SystemManager

Helps with getting information about the schema, making schema changes, and getting information about the state and configuration of the cluster.

Namespace: phpcassa
Package: phpcassa
Located at phpcassa/SystemManager.php
Methods summary
public
# __construct( string $server = 'localhost:9160', array $credentials = NULL, integer $send_timeout = 15000, integer $recv_timeout = 15000 )

Parameters

$server
string
$server the host and port to connect to, in the form 'host:port'. Defaults to 'localhost:9160'.
$credentials
array
$credentials if using authentication or authorization with Cassandra, a username and password need to be supplied. This should be in the form array("username" => username, "password" => password)
$send_timeout
integer
$send_timeout the socket send timeout in milliseconds. Defaults to 15000.
$recv_timeout
integer
$recv_timeout the socket receive timeout in milliseconds. Defaults to 15000.
public
# close( )

Closes the underlying Thrift connection.

Closes the underlying Thrift connection.

public
# create_keyspace( string $keyspace, array $attrs )

Creates a new keyspace.

Creates a new keyspace.

Example usage:

use phpcassa\SystemManager;
use phpcassa\Schema\StrategyClass;

$sys = SystemManager();
$attrs = array("strategy_class" => StrategyClass\SIMPLE_STRATEGY,
               "strategy_options" => array("replication_factor" => "1"));
$sys->create_keyspace("Keyspace1", $attrs);

Parameters

$keyspace
string
$keyspace the keyspace name
$attrs
array
$attrs an array that maps attribute names to values. Valid attribute names include "strategy_class", "strategy_options", and "replication_factor". By default, SimpleStrategy will be used with a replication factor of 1 and no strategy options.
public
# alter_keyspace( string $keyspace, array $attrs )

Modifies a keyspace's properties.

Modifies a keyspace's properties.

Example usage:

$sys = SystemManager();
$attrs = array("replication_factor" => 2);
$sys->alter_keyspace("Keyspace1", $attrs);

Parameters

$keyspace
string
$keyspace the keyspace to modify
$attrs
array
$attrs an array that maps attribute names to values. Valid attribute names include "strategy_class", "strategy_options", and "replication_factor".
public
# drop_keyspace( mixed $keyspace )
public
# create_column_family( string $keyspace, string $column_family, array $attrs = null )

Creates a column family.

Creates a column family.

Example usage:

$sys = SystemManager();
$attrs = array("column_type" => "Standard",
               "comparator_type" => "org.apache.cassandra.db.marshal.AsciiType",
               "memtable_throughput_in_mb" => 32);
$sys->create_column_family("Keyspace1", "ColumnFamily1", $attrs);

Parameters

$keyspace
string
$keyspace the keyspace containing the column family
$column_family
string
$column_family the name of the column family
$attrs
array
$attrs an array that maps attribute names to values.
public
# alter_column_family( string $keyspace, string $column_family, array $attrs )

Modifies a column family's attributes.

Modifies a column family's attributes.

Example usage:

$sys = SystemManager();
$attrs = array("max_compaction_threshold" => 10);
$sys->alter_column_family("Keyspace1", "ColumnFamily1", $attrs);

Parameters

$keyspace
string
$keyspace the keyspace containing the column family
$column_family
string
$column_family the name of the column family
$attrs
array
$attrs an array that maps attribute names to values.
public
# drop_column_family( mixed $keyspace, mixed $column_family )
public
# truncate_column_family( string $keyspace, string $column_family )

Mark the entire column family as deleted.

Mark the entire column family as deleted.

From the user's perspective a successful call to truncate will result complete data deletion from cfname. Internally, however, disk space will not be immediatily released, as with all deletes in cassandra, this one only marks the data as deleted.

The operation succeeds only if all hosts in the cluster at available and will throw an UnavailableException if some hosts are down.

Example usage:

$sys = SystemManager();
$sys->truncate_column_family("Keyspace1", "ColumnFamily1");

Parameters

$keyspace
string
$keyspace the keyspace the CF is in
$column_family
string
$column_family the column family name
public
# create_index( string $keyspace, string $column_family, string $column, string $data_type = self::KEEP, string $index_name = NULL, cassandra\IndexType $index_type = phpcassa\IndexType::KEYS )

Adds an index to a column family.

Adds an index to a column family.

Example usage:

$sys = new SystemManager();
$sys->create_index("Keyspace1", "Users", "name", "UTF8Type");

Parameters

$keyspace
string
$keyspace the name of the keyspace containing the column family
$column_family
string
$column_family the name of the column family
$column
string
$column the name of the column to put the index on
$data_type
string
$data_type the data type of the values being indexed
$index_name
string
$index_name an optional name for the index
$index_type
cassandra\IndexType
$index_type the type of index. Defaults to \cassandra\IndexType::KEYS_INDEX, which is currently the only option.
public
# drop_index( string $keyspace, string $column_family, string $column )

Drop an index from a column family.

Drop an index from a column family.

Example usage:

$sys = new SystemManager();
$sys->drop_index("Keyspace1", "Users", "name");

Parameters

$keyspace
string
$keyspace the name of the keyspace containing the column family
$column_family
string
$column_family the name of the column family
$column
string
$column the name of the column to drop the index from
public
# alter_column( string $keyspace, string $column_family, string $column, string $data_type )

Changes or sets the validation class of a single column.

Changes or sets the validation class of a single column.

Example usage:

$sys = new SystemManager();
$sys->alter_column("Keyspace1", "Users", "name", "UTF8Type");

Parameters

$keyspace
string
$keyspace the name of the keyspace containing the column family
$column_family
string
$column_family the name of the column family
$column
string
$column the name of the column to put the index on
$data_type
string
$data_type the data type of the values being indexed
public array
# describe_ring( mixed $keyspace )

Describes the Cassandra cluster.

Describes the Cassandra cluster.

Returns

array
the node to token mapping
public string
# describe_cluster_name( )

Gives the cluster name.

Gives the cluster name.

Returns

string
the cluster name
public string
# describe_version( )

Gives the Thrift API version for the Cassandra instance.

Gives the Thrift API version for the Cassandra instance.

Note that this is different than the Cassandra version.

Returns

string
the API version
public array
# describe_schema_versions( )

Describes what schema version each node currently has. Differences in schema versions indicate a schema conflict.

Describes what schema version each node currently has. Differences in schema versions indicate a schema conflict.

Returns

array
a mapping of schema versions to nodes.
public string
# describe_partitioner( )

Describes the cluster's partitioner.

Describes the cluster's partitioner.

Returns

string
the name of the partitioner in use
public string
# describe_snitch( )

Describes the cluster's snitch.

Describes the cluster's snitch.

Returns

string
the name of the snitch in use
public cassandra\KsDef
# describe_keyspace( string $keyspace )

Returns a description of the keyspace and its column families. This includes all configuration settings for the keyspace and column families.

Returns a description of the keyspace and its column families. This includes all configuration settings for the keyspace and column families.

Parameters

$keyspace
string
$keyspace the keyspace name

Returns

cassandra\KsDef
public array
# describe_keyspaces( )

Like describe_keyspace(), but for all keyspaces.

Like describe_keyspace(), but for all keyspaces.

Returns

array
an array of cassandra\KsDef
phpcassa API documentation generated by ApiGen 2.8.0