forked from 4399data/php-hiveserver2
-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.php
30 lines (22 loc) · 839 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
$GLOBALS['THRIFT_ROOT'] = dirname(__FILE__) . '/src';
require_once $GLOBALS['THRIFT_ROOT'] . '/packages/hive_service/TCLIService.php';
require_once $GLOBALS['THRIFT_ROOT'] . '/transport/TSocket.php';
require_once $GLOBALS['THRIFT_ROOT'] . '/transport/TSaslClientTransport.php';
require_once $GLOBALS['THRIFT_ROOT'] . '/protocol/TBinaryProtocol.php';
/**
* example
* @author dryoung
* @version 0.1 13-12-2 20:19
*/
//hive2server`host and port
$transport = new TSaslClientTransport(new TSocket('localhost', 10000));
$protocol = new TBinaryProtocol($transport);
$client = new TCLIServiceClient($protocol);
//open session
$openSessionReq = new TOpenSessionReq(array(
'client_protocol' => 0
));
$openSessionResp = $client->OpenSession($openSessionReq);
//print the sessionHandle
var_dump($openSessionResp->sessionHandle);