public function getClusterNameForIndex($index)
 {
     try {
         $sys_manager = new SystemManager($this->getRandomNodeForIndex($index), $this->getCredentialsForIndex($index), 1500, 1500);
         return $sys_manager->describe_cluster_name();
     } catch (NoServerAvailable $e) {
         return null;
     }
 }
Пример #2
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $sys = new SystemManager();
     $cfattrs = array("column_type" => "Standard", "key_validation_class" => DataType::LONG_TYPE);
     $sys->create_column_family(self::$KS, 'LongKeys', $cfattrs);
     $sys->create_index(self::$KS, 'LongKeys', 'subcol', DataType::LONG_TYPE);
     $cfattrs = array("column_type" => "Standard", "key_validation_class" => DataType::UUID_TYPE);
     $sys->create_column_family(self::$KS, 'UUIDKeys', $cfattrs);
     $sys->create_index(self::$KS, 'UUIDKeys', 'subcol', DataType::LONG_TYPE);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $sys = new SystemManager();
     $cfattrs = array("column_type" => "Super", "comparator_type" => "Int32Type");
     if (self::$have64Bit) {
         $cfattrs["subcomparator_type"] = DataType::LONG_TYPE;
         $sys->create_column_family(self::$KS, 'SuperLongSubLong', $cfattrs);
     }
     $cfattrs["subcomparator_type"] = DataType::INTEGER_TYPE;
     $sys->create_column_family(self::$KS, 'SuperLongSubInt', $cfattrs);
     $cfattrs["subcomparator_type"] = DataType::ASCII_TYPE;
     $sys->create_column_family(self::$KS, 'SuperLongSubAscii', $cfattrs);
     $cfattrs["subcomparator_type"] = DataType::UTF8_TYPE;
     $sys->create_column_family(self::$KS, 'SuperLongSubUTF8', $cfattrs);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $sys = new SystemManager();
     $cfattrs = array("column_type" => "Super");
     $cfattrs["comparator_type"] = DataType::FLOAT_TYPE;
     $sys->create_column_family(self::$KS, 'SuperFloat', $cfattrs);
     $cfattrs["comparator_type"] = DataType::DOUBLE_TYPE;
     $sys->create_column_family(self::$KS, 'SuperDouble', $cfattrs);
     $cfattrs["comparator_type"] = DataType::TIME_UUID_TYPE;
     $sys->create_column_family(self::$KS, 'SuperTime', $cfattrs);
     $cfattrs["comparator_type"] = DataType::LEXICAL_UUID_TYPE;
     $sys->create_column_family(self::$KS, 'SuperLex', $cfattrs);
     # NOTE: this is broken in Cassandra 1.2.0 through 1.2.2
     # see: https://issues.apache.org/jira/browse/CASSANDRA-5287
     // $cfattrs["comparator_type"] = "CompositeType(Int32Type, AsciiType)";
     // $sys->create_column_family(self::$KS, 'SuperComposite', $cfattrs);
 }
Пример #5
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $sys = new SystemManager();
     $cfattrs = array("column_type" => "Standard");
     $cfattrs["default_validation_class"] = DataType::LONG_TYPE;
     $sys->create_column_family(self::$KS, 'ValidatorLong', $cfattrs);
     $cfattrs["default_validation_class"] = DataType::TIME_UUID_TYPE;
     $sys->create_column_family(self::$KS, 'ValidatorTime', $cfattrs);
     $cfattrs["default_validation_class"] = DataType::BYTES_TYPE;
     $sys->create_column_family(self::$KS, 'ValidatorBytes', $cfattrs);
     $cfattrs["default_validation_class"] = "CompositeType(LongType, AsciiType)";
     $sys->create_column_family(self::$KS, 'ValidatorComposite', $cfattrs);
     $cfattrs["default_validation_class"] = DataType::LONG_TYPE;
     $sys->create_column_family(self::$KS, 'DefaultValidator', $cfattrs);
     $sys->alter_column(self::$KS, 'DefaultValidator', 'subcol', 'TimeUUIDType');
     $cfattrs = array("comparator_type" => "CompositeType(Int32Type, AsciiType)", "default_validation_class" => "Int32Type");
     $sys->create_column_family(self::$KS, 'CompositeNames', $cfattrs);
     $sys->alter_column(self::$KS, 'CompositeNames', array(0, 'meta'), 'AsciiType');
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $sys = new SystemManager();
     $cfattrs = array("comparator_type" => DataType::FLOAT_TYPE);
     $sys->create_column_family(self::$KS, 'StdFloat', $cfattrs);
     $cfattrs = array("comparator_type" => DataType::DOUBLE_TYPE);
     $sys->create_column_family(self::$KS, 'StdDouble', $cfattrs);
     $cfattrs = array("comparator_type" => DataType::TIME_UUID_TYPE);
     $sys->create_column_family(self::$KS, 'StdTimeUUID', $cfattrs);
     $cfattrs = array("comparator_type" => DataType::LEXICAL_UUID_TYPE);
     $sys->create_column_family(self::$KS, 'StdLexicalUUID', $cfattrs);
     $cfattrs = array("comparator_type" => DataType::DATE_TYPE);
     $sys->create_column_family(self::$KS, 'StdDate', $cfattrs);
     $cfattrs = array("comparator_type" => 'CompositeType(Int32Type, AsciiType)');
     $sys->create_column_family(self::$KS, 'StdComposite', $cfattrs);
     $cfattrs = array("comparator_type" => 'CompositeType(LexicalUUIDType, DateType)');
     $sys->create_column_family(self::$KS, 'StdNonScalarComposite', $cfattrs);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $sys = new SystemManager();
     $cfattrs = array("column_type" => "Super", "comparator_type" => "Int32Type");
     $cfattrs["subcomparator_type"] = DataType::FLOAT_TYPE;
     $sys->create_column_family(self::$KS, 'SuperLongSubFloat', $cfattrs);
     $cfattrs["subcomparator_type"] = DataType::DOUBLE_TYPE;
     $sys->create_column_family(self::$KS, 'SuperLongSubDouble', $cfattrs);
     $cfattrs["subcomparator_type"] = DataType::TIME_UUID_TYPE;
     $sys->create_column_family(self::$KS, 'SuperLongSubTime', $cfattrs);
     $cfattrs["subcomparator_type"] = DataType::LEXICAL_UUID_TYPE;
     $sys->create_column_family(self::$KS, 'SuperLongSubLex', $cfattrs);
     $cfattrs["subcomparator_type"] = "CompositeType(Int32Type, AsciiType)";
     $sys->create_column_family(self::$KS, 'SuperLongSubComposite', $cfattrs);
 }
Пример #8
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $sys = new SystemManager();
     if (self::$have64Bit) {
         $cfattrs = array("comparator_type" => DataType::LONG_TYPE);
         $sys->create_column_family(self::$KS, 'StdLong', $cfattrs);
     }
     $cfattrs = array("comparator_type" => DataType::INTEGER_TYPE);
     $sys->create_column_family(self::$KS, 'StdInteger', $cfattrs);
     $cfattrs = array("comparator_type" => DataType::INT32_TYPE);
     $sys->create_column_family(self::$KS, 'StdInt32', $cfattrs);
     $cfattrs = array("comparator_type" => DataType::ASCII_TYPE);
     $sys->create_column_family(self::$KS, 'StdAscii', $cfattrs);
     $cfattrs = array("comparator_type" => DataType::UTF8_TYPE);
     $sys->create_column_family(self::$KS, 'StdUTF8', $cfattrs);
 }
 public static function tearDownAfterClass()
 {
     $sys = new SystemManager();
     $sys->drop_keyspace(self::$KS);
     $sys->close();
 }
Пример #10
0
 * If the cli version of PHP is installed, it may be run directly:
 *
 *    $ php basic.php'
 *
 * If you're using Linux, verify that 'php5-cli' or a similar package has
 * been installed.
 *
 */
require_once __DIR__ . '/../lib/autoload.php';
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\ColumnSlice;
use phpcassa\SystemManager;
use phpcassa\Schema\StrategyClass;
// Create a new keyspace and column family
$sys = new SystemManager('127.0.0.1');
$sys->create_keyspace('Keyspace1', array("strategy_class" => StrategyClass::SIMPLE_STRATEGY, "strategy_options" => array('replication_factor' => '1')));
$sys->create_column_family('Keyspace1', 'Letters', array("column_type" => "Standard", "comparator_type" => "LongType", "key_validation_class" => "UTF8Type", "default_validation_class" => "UTF8Type"));
// Start a connection pool, create our ColumnFamily instance
$pool = new ConnectionPool('Keyspace1', array('127.0.0.1'));
$letters = new ColumnFamily($pool, 'Letters');
// Insert a few records
$columns = array(1 => "a", 2 => "b", 3 => "c", 4 => "d", 5 => "e");
$letters->insert('key', $columns);
function print_slice($columns)
{
    echo "(";
    foreach ($columns as $number => $letter) {
        echo "{$number} => {$letter}, ";
    }
    echo ")\n";
Пример #11
0
 * If the cli version of PHP is installed, it may be run directly:
 *
 *    $ php basic.php'
 *
 * If you're using Linux, verify that 'php5-cli' or a similar package has
 * been installed.
 *
 */
require_once __DIR__ . '/../lib/autoload.php';
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\ColumnSlice;
use phpcassa\SystemManager;
use phpcassa\Schema\StrategyClass;
// Create a new keyspace and column family
$sys = new SystemManager('127.0.0.1');
$sys->create_keyspace('Keyspace1', array("strategy_class" => StrategyClass::SIMPLE_STRATEGY, "strategy_options" => array('replication_factor' => '1')));
// Use composites for column names and row keys
$sys->create_column_family('Keyspace1', 'Composites', array("comparator_type" => "CompositeType(LongType, AsciiType)", "key_validation_class" => "CompositeType(AsciiType, LongType)"));
// Start a connection pool, create our ColumnFamily instance
$pool = new ConnectionPool('Keyspace1', array('127.0.0.1'));
$cf = new ColumnFamily($pool, 'Composites');
// Make it easier to work with non-scalar types
$cf->insert_format = ColumnFamily::ARRAY_FORMAT;
$cf->return_format = ColumnFamily::ARRAY_FORMAT;
// Insert a few records
$key1 = array("key", 1);
$key2 = array("key", 2);
$columns = array(array(array(0, "a"), "val0a"), array(array(1, "a"), "val1a"), array(array(1, "b"), "val1b"), array(array(1, "c"), "val1c"), array(array(2, "a"), "val2a"), array(array(3, "a"), "val3a"));
$cf->insert($key1, $columns);
$cf->insert($key2, $columns);
Пример #12
0
 *
 * If the cli version of PHP is installed, it may be run directly:
 *
 *    $ php basic.php'
 *
 * If you're using Linux, verify that 'php5-cli' or a similar package has
 * been installed.
 *
 */
require_once __DIR__ . '/../lib/autoload.php';
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\SystemManager;
use phpcassa\Schema\StrategyClass;
// Create a new keyspace and column family
$sys = new SystemManager('127.0.0.1');
$sys->create_keyspace('Keyspace1', array("strategy_class" => StrategyClass::SIMPLE_STRATEGY, "strategy_options" => array('replication_factor' => '1')));
$sys->create_column_family('Keyspace1', 'Users');
// Start a connection pool, create our ColumnFamily instance
$pool = new ConnectionPool('Keyspace1', array('127.0.0.1'));
$users = new ColumnFamily($pool, 'Users');
// Insert a few records
$users->insert('user0', array("name" => "joe", "state" => "TX"));
$users->insert('user1', array("name" => "bob", "state" => "CA"));
// Fetch a user record
$user = $users->get('user0');
$name = $user["name"];
echo "Fetched user {$name}\n";
// Fetch both at once
$both = $users->multiget(array('user0', 'user1'));
foreach ($both as $user_id => $columns) {
Пример #13
0
 *
 * If the cli version of PHP is installed, it may be run directly:
 *
 *    $ php counters.php'
 *
 * If you're using Linux, verify that 'php5-cli' or a similar package has
 * been installed.
 *
 */
require_once __DIR__ . '/../lib/autoload.php';
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\SystemManager;
use phpcassa\Schema\StrategyClass;
// Create a new keyspace and column family
$sys = new SystemManager('127.0.0.1');
$sys->create_keyspace('Keyspace1', array("strategy_class" => StrategyClass::SIMPLE_STRATEGY, "strategy_options" => array('replication_factor' => '1')));
$sys->create_column_family('Keyspace1', 'Counts', array("default_validation_class" => 'CounterColumnType'));
// Start a connection pool, create our ColumnFamily instance
$pool = new ConnectionPool('Keyspace1', array('127.0.0.1'));
$count_cf = new ColumnFamily($pool, 'Counts');
// ColumnFamily::add() is the easiest way to increment a counter
$count_cf->add("key1", "col1");
$results = $count_cf->get("key1");
$current_count = $results["col1"];
echo "After one add(): {$current_count}\n";
// You can specify a value other than 1 to adjust the counter by
$count_cf->add("key1", "col1", 10);
$results = $count_cf->get("key1");
$current_count = $results["col1"];
echo "After add(10): {$current_count}\n";
Пример #14
0
 *
 *    $ php basic.php'
 *
 * If you're using Linux, verify that 'php5-cli' or a similar package has
 * been installed.
 *
 */
require_once __DIR__ . '/../lib/autoload.php';
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\ColumnSlice;
use phpcassa\SystemManager;
use phpcassa\Schema\StrategyClass;
use phpcassa\UUID;
// Create a new keyspace and column family
$sys = new SystemManager('127.0.0.1');
$sys->create_keyspace('Keyspace1', array("strategy_class" => StrategyClass::SIMPLE_STRATEGY, "strategy_options" => array('replication_factor' => '1')));
// We'll use TimeUUIDs for column names and UUIDs for row keys
$sys->create_column_family('Keyspace1', 'UserLogs', array("comparator_type" => "TimeUUIDType", "key_validation_class" => "LexicalUUIDType"));
// Start a connection pool, create our ColumnFamily instance
$pool = new ConnectionPool('Keyspace1', array('127.0.0.1'));
$user_logs = new ColumnFamily($pool, 'UserLogs');
// Don't use dictionary-style arrays for data
$user_logs->insert_format = ColumnFamily::ARRAY_FORMAT;
$user_logs->return_format = ColumnFamily::ARRAY_FORMAT;
// Make a couple of user IDs with non-Time UUIDs
$user1_id = UUID::uuid4();
$user2_id = UUID::uuid4();
// Insert some log messages
$user1_logs = array();
$user2_logs = array();