-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from normal-cock/develop
0.1.4
- Loading branch information
Showing
8 changed files
with
399 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.pyc | ||
*.egg-info | ||
.eggs | ||
/.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
language: python | ||
env: | ||
- TESTING_ON_TRAVIS=1 | ||
matrix: | ||
include: | ||
- python: 2.7 | ||
- python: 3.5 | ||
- python: 3.6 | ||
- python: 3.7 | ||
install: | ||
- pip install -r requirements-test.txt | ||
script: make test | ||
after_success: | ||
- coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test: | ||
coverage run --source happybase_kerberos_patch setup.py test | ||
coverage report --include happybase_kerberos_patch.py -m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,68 @@ | ||
# happybase-kerberos-patch | ||
[](https://travis-ci.org/normal-cock/happybase-kerberos-patch) | ||
[](https://coveralls.io/github/normal-cock/happybase-kerberos-patch?branch=master) | ||
<!-- TOC --> | ||
|
||
## Introduction | ||
This is a patch for happybase to support kerberos when connect to hbase thrift server. | ||
- [Introduction](#introduction) | ||
- [requirements](#requirements) | ||
- [Installment](#installment) | ||
- [Usage:](#usage) | ||
- [Important points to remember](#important-points-to-remember) | ||
|
||
<!-- /TOC --> | ||
|
||
# Introduction | ||
|
||
This is a patch for happybase to support kerberos when connect to hbase thrift server with the following extra features: | ||
|
||
1. `KerberosConnectionPool` support multiple specify multiple hosts as destination to connection as a support to high avaliable | ||
2. `KerberosConnectionPool` will auto connect to the next host if current is unavailable even in the outermost with statement | ||
3. Using `pykerberos` instead of `kerberos` which has memory leaking issue | ||
|
||
The patch now support `python 2.7`, `python 3.5`, `python 3.6`, `python 3.7`. | ||
|
||
# requirements | ||
|
||
In order to use kerberos, the following packages is required: | ||
|
||
1. python3-dev | ||
2. libkrb5-dev | ||
|
||
For example, in ubuntu install by the follow commands: | ||
|
||
```shell | ||
sudo apt-get install python-dev | ||
sudo apt-get install python3-dev | ||
sudo apt-get install libkrb5-dev | ||
``` | ||
|
||
# Installment | ||
pip install -U git+https://github.com/normal-cock/happybase-kerberos-patch.git | ||
|
||
## Usage: | ||
from happybase_kerberos_patch import KerberosConnection, KerberosConnectionPool | ||
connection = KerberosConnection('HOST_TO_THRIFT_SERVER', protocol='compact', use_kerberos=True) | ||
test_table = connection.table('test') | ||
# insert | ||
test_table.put('row_key_1', {'f1:q1':'v1'}) | ||
# get data | ||
|
||
`pip install -U git+https://github.com/normal-cock/happybase-kerberos-patch.git` | ||
|
||
# Usage | ||
|
||
```python | ||
from happybase_kerberos_patch import KerberosConnection, KerberosConnectionPool | ||
connection = KerberosConnection('HOST_TO_THRIFT_SERVER', protocol='compact', use_kerberos=True) | ||
test_table = connection.table('test') | ||
# insert | ||
test_table.put('row_key_1', {'f1:q1':'v1'}) | ||
# get data | ||
print test_table.row('row_key_1') | ||
|
||
pool = KerberosConnectionPool(size=3, host='...', protocol='compact', use_kerberos=True) | ||
with pool.connection() as connection: | ||
test = connection.table('test') | ||
print test_table.row('row_key_1') | ||
|
||
pool = KerberosConnectionPool(size=3, host='...', protocol='compact', use_kerberos=True) | ||
with pool.connection() as connection: | ||
test = connection.table('test') | ||
print test_table.row('row_key_1') | ||
# multiple thrift servers high avaliable | ||
pool = KerberosConnectionPool(size=3, hosts=['thrift1', 'thrift2'], protocol='compact', use_kerberos=True) | ||
with pool.connection() as connection: | ||
test = connection.table('test') | ||
print test_table.row('row_key_1') | ||
|
||
## Important points to remember: | ||
* Only support "compact" protocol and "buffered" transport | ||
* Only support happybase>=1.0.0 | ||
# multiple thrift servers high avaliable | ||
pool = KerberosConnectionPool(size=3, hosts=['thrift1', 'thrift2'], protocol='compact', use_kerberos=True) | ||
with pool.connection() as connection: | ||
test = connection.table('test') | ||
print test_table.row('row_key_1') | ||
``` | ||
|
||
# Important points to remember | ||
|
||
* Only support "compact" protocol and "buffered" transport | ||
* Only support happybase>=1.2.0 |
Oops, something went wrong.