diff --git a/README.md b/README.md index 587553a..64e8b45 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,9 @@ Its features include: The source code has been tested agains PHP 5.2.x and PHP 5.3.x versions, however, it should also run on PHP 5.1.x versions. -By default, the connection is handled by the Curl base implementation ("PopHbaseConnectionCurl") and it requires PHP to be compiled with Curl support. A socket based implementation is also provided but less stable at the time. \ No newline at end of file +By default, the connection is handled by the Curl base implementation ("PopHbaseConnectionCurl") and it requires PHP to be compiled with Curl support. A socket based implementation is also provided but less stable at the time. + +Getting the source +------------------ + + git clone http://github.com/pop/pop_hbase.git \ No newline at end of file diff --git a/docs/1.start.md b/docs/1.start.md new file mode 100644 index 0000000..bdfb205 --- /dev/null +++ b/docs/1.start.md @@ -0,0 +1,43 @@ +Getting started +=============== + +Installing HBase +---------------- + +We found the cloudera distribution to be the easiest way to get started. If you run Ubuntu, Debian or RedHat, the package are integrated with apt-get and yum. However, desptite respecting the Unix conventions, we found the installation quite inconvient, having constantly to search for config, bin, data files all dispatched over the filesystem. For this reason, we usually download the package from `http://archive.cloudera.com/cdh/3/` and install each of them manually. + +Starting HBase +-------------- + +It seems like Stargate took the place of the old REST namespace. However, i need confirmation on this one. So if i'm right, assuming `${HBASE_HOME}/bin` is in your classpath, starting Hbase with REST connector is as follow: + + start-hbase.sh + hbase-daemon.sh start rest + +And stoping: + + hbase-daemon.sh stop rest + stop-hbase.sh + +Requiring Pop HBase +------------------- + +The source code organisation comply with [PEAR naming conventions][pear] and the [PHP Framework Interop Group PSR-0][psr] for autoloader interoperability. + +If you do not use a autoloader, simply download and unpack the source code and finally require `pop_hbase.inc.php` present in the `src` folder. The script will require the classes for you. + + require(dirname(__FILE__).'/pop_hbase/src/pop_hbase.inc.php'); + +Creating a connection +--------------------- + +See the documentation relative to the connection for more details. + + $hbase = new PopHbase(array( + "host" => "127.0.0.1", + "port" => "8080", + )); + + +[pear]: http://pear.php.net/ "PEAR projects" +[psr]: http://groups.google.com/group/php-standards/web/psr-0-final-proposal "PHP Framework Interop Group" \ No newline at end of file diff --git a/docs/2.information.md b/docs/2.information.md new file mode 100644 index 0000000..e8f75e4 --- /dev/null +++ b/docs/2.information.md @@ -0,0 +1,41 @@ +Server information: Command relative to version and server status +================================================================= + +Query Software Version +---------------------- + + $hbase->getVersion(); + +Will return something similar to: + + { Server: 'jetty/6.1.24' + , REST: '0.0.2' + , OS: 'Mac OS X 10.6.4 x86_64' + , Jersey: '1.1.5.1' + , JVM: 'Apple Inc. 1.6.0_20-16.3-b01-279' + } + +Query Storage Cluster Version +----------------------------- + + $hbase->getVersionCluster(); + +Will return something similar to: + + '0.89.20100726' + +Query Storage Cluster Status +---------------------------- + + $hbase->getStatusCluster(); + +Will return something similar to: + + { requests: 0 + , regions: 3 + , averageLoad: 3 + , DeadNodes: [ null ] + , LiveNodes: [ { Node: [Object] } ] + } + + diff --git a/docs/connection.md b/docs/3.connection.md similarity index 100% rename from docs/connection.md rename to docs/3.connection.md diff --git a/docs/table.md b/docs/4.table.md similarity index 100% rename from docs/table.md rename to docs/4.table.md diff --git a/docs/row.md b/docs/5.row.md similarity index 100% rename from docs/row.md rename to docs/5.row.md diff --git a/src/PopHbaseConnectionCurl.php b/src/PopHbaseConnectionCurl.php index f395e4e..5a66399 100755 --- a/src/PopHbaseConnectionCurl.php +++ b/src/PopHbaseConnectionCurl.php @@ -22,7 +22,7 @@ class PopHbaseConnectionCurl implements PopHbaseConnection{ * - *host* * Hbase server host, default to "localhost" * - *port* - * Hbase server port, default to "5984" + * Hbase server port, default to "8080" * * Accorging to Stargate API: * ./bin/hbase org.apache.hadoop.hbase.stargate.Main -p @@ -37,7 +37,7 @@ public function __construct(array $options = array()){ $options['host'] = 'localhost'; } if(!isset($options['port'])){ - $options['port'] = 5984; + $options['port'] = 8080; } if(!isset($options['alive'])){ $options['alive'] = 1; diff --git a/src/PopHbaseRequest.php b/src/PopHbaseRequest.php index 59d82c5..340f343 100755 --- a/src/PopHbaseRequest.php +++ b/src/PopHbaseRequest.php @@ -7,7 +7,7 @@ */ /** - * Wrap an Hbase request + * Wrap HTTP REST requests * * @author David Worms info(at)adaltas.com */ @@ -18,26 +18,46 @@ class PopHbaseRequest{ /** * Request constructor. * - * @param PopHbaseConnection required $connection + * @param PopHbase required $hbase instance */ function __construct(PopHbase $hbase){ $this->hbase = $hbase; } - public function delete($url){ - return $this->hbase->connection->execute('DELETE',$url); + /** + * Create a DELETE HTTP request. + * + * @return PopHbaseResponse Response object + */ + public function delete($command){ + return $this->hbase->connection->execute('DELETE',$command); } - public function get($url){ - return $this->hbase->connection->execute('GET',$url); + /** + * Create a GET HTTP request. + * + * @return PopHbaseResponse Response object + */ + public function get($command){ + return $this->hbase->connection->execute('GET',$command); } - public function post($url,$data){ - return $this->hbase->connection->execute('POST',$url,$data); + /** + * Create a POST HTTP request. + * + * @return PopHbaseResponse Response object + */ + public function post($command,$data){ + return $this->hbase->connection->execute('POST',$command,$data); } - public function put($url,$data=null){ - return $this->hbase->connection->execute('PUT',$url,$data); + /** + * Create a PUT HTTP request. + * + * @return PopHbaseResponse Response object + */ + public function put($command,$data=null){ + return $this->hbase->connection->execute('PUT',$command,$data); } } diff --git a/tests/connection/HbaseCurlExecuteTest.php b/tests/connection/HbaseCurlExecuteTest.php index ce02a1a..a6feaeb 100644 --- a/tests/connection/HbaseCurlExecuteTest.php +++ b/tests/connection/HbaseCurlExecuteTest.php @@ -19,7 +19,7 @@ public function testReturn(){ $connection = new PopHbaseConnectionCurl($this->config); $version = $connection->execute('get','version')->getBody(); $this->assertTrue(is_array($version)); - $this->assertSame(array('Stargate','Server','OS','JVM','Jersey'),array_keys($version)); + $this->assertSame(array('Server','REST','OS','Jersey','JVM'),array_keys($version)); } } diff --git a/tests/connection/HbaseSockConnectTest.php b/tests/connection/HbaseSockConnectTest.php index 23e5691..bece17a 100644 --- a/tests/connection/HbaseSockConnectTest.php +++ b/tests/connection/HbaseSockConnectTest.php @@ -20,7 +20,7 @@ public function testReturn(){ $this->assertSame($connection,$connection->connect()); $version = $connection->execute('get','version')->getBody(); $this->assertTrue(is_array($version)); - $this->assertSame(array('Stargate','Server','OS','JVM','Jersey'),array_keys($version)); + $this->assertSame(array('Server','REST','OS','Jersey','JVM'),array_keys($version)); } } diff --git a/tests/hbase/HbaseGetVersionTest.php b/tests/hbase/HbaseGetVersionTest.php index 1507e87..bb28396 100644 --- a/tests/hbase/HbaseGetVersionTest.php +++ b/tests/hbase/HbaseGetVersionTest.php @@ -18,6 +18,6 @@ class HbaseGetVersionTest extends PopHbaseTestCase{ public function testReturn(){ $hbase = new PopHbase($this->config); $version = $hbase->getVersion(); - $this->assertSame(array('Stargate','Server','OS','JVM','Jersey'),array_keys($version)); + $this->assertSame(array('Server','REST','OS','Jersey','JVM'),array_keys($version)); } }