Skip to content

Commit

Permalink
Improve documentation; Fix default port in curl connection; Add reque…
Browse files Browse the repository at this point in the history
…st api
  • Loading branch information
wdavidw committed Sep 20, 2010
1 parent 5647c0a commit e66ba32
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 16 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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
43 changes: 43 additions & 0 deletions docs/1.start.md
Original file line number Diff line number Diff line change
@@ -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"
41 changes: 41 additions & 0 deletions docs/2.information.md
Original file line number Diff line number Diff line change
@@ -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] } ]
}


File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/PopHbaseConnectionCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <port>
Expand All @@ -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;
Expand Down
40 changes: 30 additions & 10 deletions src/PopHbaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

/**
* Wrap an Hbase request
* Wrap HTTP REST requests
*
* @author David Worms info(at)adaltas.com
*/
Expand All @@ -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);
}

}
2 changes: 1 addition & 1 deletion tests/connection/HbaseCurlExecuteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

}
}
2 changes: 1 addition & 1 deletion tests/connection/HbaseSockConnectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

}
}
2 changes: 1 addition & 1 deletion tests/hbase/HbaseGetVersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

0 comments on commit e66ba32

Please sign in to comment.