GitHub user akash3456 opened a pull request:
https://github.com/apache/thrift/pull/583
0.9.x
I seem to be having an issue when trying to connect to cassandra to php via
thrift and this is the issue when running this code:
?php
$GLOBALS['THRIFT_ROOT'] = '/usr/share/php/Thrift';
require_once $GLOBALS['THRIFT_ROOT'].'/packages/cassandra/Cassandra.php';
require_once
$GLOBALS['THRIFT_ROOT'].'/packages/cassandra/cassandra_types.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php';
require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php';
try {
// Make a connection to the Thrift interface to Cassandra
$socket = new TSocket('127.0.0.1', 9160);
$transport = new TBufferedTransport($socket, 1024, 1024);
$protocol = new TBinaryProtocolAccelerated($transport);
$client = new CassandraClient($protocol);
$transport->open();
/* Insert some data into the Standard1 column family from the default
config */
// Keyspace specified in storage=conf.xml
$keyspace = 'Keyspace1';
// reference to specific User id
$keyUserId = "1";
// Constructing the column path that we are adding information into.
$columnPath = new cassandra_ColumnPath();
$columnPath->column_family = 'Standard1';
$columnPath->super_column = null;
$columnPath->column = 'email';
// Timestamp for update
$timestamp = time();
// We want the consistency level to be ZERO which means async operations
on 1 node
$consistency_level = cassandra_ConsistencyLevel::ZERO;
// Add the value to be written to the table, User Key, and path.
$value = "[email protected]";
$client->insert($keyspace, $keyUserId, $columnPath, $value, $timestamp,
$consistency_level);
// Add a new column path to be altered.
$columnPath->column = 'age';
//Get a current timestamp
$timestamp = time();
// Update the value to be inserted for the updated column Path
$value = "24";
$client->insert($keyspace, $keyUserId, $columnPath, $value, $timestamp,
$consistency_level);
/*
* use batch_insert to insert a supercolumn and its children using the
standard config
* builds the structure
*
* Super1 : {
* KeyName : {
* SuperColumnName : {
* foo : fooey value
* bar : bar like thing
* }
* }
* }
*/
// build columns to insert
$column1 = new cassandra_Column();
$column1->name = 'foo';
$column1->value = 'fooey value';
$column1->timestamp = time();
$column2 = new cassandra_Column();
$column2->name = 'bar';
$column2->value = 'bar like thing';
$column2->timestamp = time();
// build super column containing the columns
$super_column = new cassandra_SuperColumn();
$super_column->name = 'SuperColumnName';
$super_column->columns = array($column1, $column2);
// create columnorsupercolumn holder class that batch_insert uses
$c_or_sc = new cassandra_ColumnOrSuperColumn();
$c_or_sc->super_column = $super_column;
// create the mutation (a map of ColumnFamily names to lists
ColumnsOrSuperColumns objects
$mutation['Super1'] = array($c_or_sc);
$client->batch_insert($keyspace, 'KeyName', $mutation,
$consistency_level);
/* Query for data */
// Specify what Column Family to query against.
$columnParent = new cassandra_ColumnParent();
$columnParent->column_family = "Standard1";
$columnParent->super_column = NULL;
$sliceRange = new cassandra_SliceRange();
$sliceRange->start = "";
$sliceRange->finish = "";
$predicate = new cassandra_SlicePredicate();
list() = $predicate->column_names;
$predicate->slice_range = $sliceRange;
// We want the consistency level to be ONE which means to only wait for 1
node
$consistency_level = cassandra_ConsistencyLevel::ONE;
// Issue the Query
$keyUserId = 1;
$result = $client->get_slice($keyspace, $keyUserId, $columnParent,
$predicate, $consistency_level);
print_r($result);
$transport->close();
} catch (TException $tx) {
print 'TException: '.$tx->why. ' Error: '.$tx->getMessage() . "\n";
}
?>
TTransport class was not loaded and not found in TSocket.php line 37.
Any ideas?
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/thrift 0.9.x
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/583.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #583
----
commit dddc5df81f3bb7fa41bc40f78dff969e858db90c
Author: Jake Farrell <[email protected]>
Date: 2012-10-11T00:39:23Z
Initial branch for the 0.9.x release
git-svn-id: https://svn.apache.org/repos/asf/thrift/branches/0.9.x@1396885
13f79535-47bb-0310-9956-ffa450edef68
commit c6c01f26dbf8c8fdb218d67354ac68b1703e2e08
Author: Jake Farrell <[email protected]>
Date: 2012-10-11T20:22:24Z
Updating CHANGES and versioning for 0.9.0 release.
git-svn-id: https://svn.apache.org/repos/asf/thrift/branches/0.9.x@1397283
13f79535-47bb-0310-9956-ffa450edef68
commit 1a15f7ceda9e0ed137a1a9808ed2a1b997ee78aa
Author: Jake Farrell <[email protected]>
Date: 2012-10-12T00:45:34Z
Thrift-1643:Denial of Service attack in TBinaryProtocol.readString
Client: java
Patch: Niraj Tolia
In readString, if the string field's size is greater than the number of
bytes remaining in the byte array to deserialize, libthrift will happily
allocate a byte array of that size in readStringBody, filling the heap.
git-svn-id: https://svn.apache.org/repos/asf/thrift/branches/0.9.x@1397398
13f79535-47bb-0310-9956-ffa450edef68
commit 352a50eb36b851bfb3f69469db580e6edfd6250f
Author: jfarrell <[email protected]>
Date: 2013-03-29T15:51:58Z
Thrift-1743: Add Composer.json for Thrift 0.9.x release
Client: PHP
Patch: Xavier HAUSHERR
Adds the composer.json file for the specific release for publishing the php
client.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---