AWS Hbase: Invalid method name: 'getTableNames' - python

I am using Hbase 0.94.18 on AWS EMR. I am planning to use HappyBase as it looks very promising. Unfortunately I faced this issue on the very first attempt:
conn = happybase.Connection(port=9200,compat='0.94')
conn.tables()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.6/site-packages/happybase/connection.py", line 238, in tables
names = self.client.getTableNames()
File "/usr/local/lib/python2.6/site-packages/happybase/hbase/Hbase.py", line 818, in getTableNames
return self.recv_getTableNames()
File "/usr/local/lib/python2.6/site-packages/happybase/hbase/Hbase.py", line 833, in recv_getTableNames
raise x
thrift.Thrift.TApplicationException: Invalid method name: 'getTableNames'
Can you please help me?

Are you sure the interface you're connecting to is a HBase Thrift1 service? It looks like a protocol incompatibility...

When using "hbase thrift2 start -threadpool" I get the same error.
When using "thrift" (i.e. thrift 1) the error disappears.
This is caused by accessing the thrift 2 interface using happybase's thrift 1 implementation.

hbase thrift 2 has delete the function.

Related

cassandra-driver issue on shutdown

Using cassandra-driver version 3.24.0, I'm able to connect to a cluster and run queries (using protocol 4) without any issues.
However when I call cluster.shutdown(), or let the script completes which calls it automatically I think, I get the following exception :
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "cassandra\cluster.py", line 221, in cassandra.cluster._shutdown_clusters
File "cassandra\cluster.py", line 1759, in cassandra.cluster.Cluster.shutdown
File "cassandra\cluster.py", line 3147, in cassandra.cluster.Session.shutdown
File "cassandra\pool.py", line 493, in cassandra.pool.HostConnection.shutdown
File "C:\Users\myuser\AppData\Local\Programs\Python\Python37\lib\site-packages\cassandra\io\asyncorereactor.py", line 386, in close
ConnectionShutdown("Connection to %s was closed" % self.endpoint))
File "cassandra\connection.py", line 207, in cassandra.connection.DefaultEndPoint.__str__
TypeError: %d format: a number is required, not str
I couldn't find anything about this, it looks like an issue in the library itself but I assume I must be passing something it doesn't like somewhere.
Any ideas what could be causing this ? Weather I use execution profiles or the legacy API, same result.
Thanks
Have the same issue.
Found that in cassandra/connection.py in row 207 there is str method, which uses port as %d. All you need is during cluster creation send int, not str
cluster = Cluster(contact_points=[hostname], port=int(port), execution_profiles=profiles, auth_provider=auth)
I faced the same issue. I type cast the port no to int value.
int(port) and issue is resolved.

Connect Python to Bonsai

I am trying to connect to Bonsai using Python and for this I am using the code provided by Bonsai here. However, my code breaks at
bonsai = os.environ['https://username:password#app-testing-3106893156.eu-central-1.bonsaisearch.net:443']
with error
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/python3.7/os.py", line 679, in __getitem__
raise KeyError(key) from None
KeyError: 'https://username:password#app-testing-3106893156.eu-central-1.bonsaisearch.net:443'
I am using the exact same code Bonsai provides and I am only adding the Full Access URL also provided by Bonsai so I have no idea how to proceed with this. Any ideas what is causing the error?
You have to set environment variable first. example
export BONSAI_URL='https://username:password#app-testing-3106893156.eu-central-1.bonsaisearch.net:443'
and then use it in code like
bonsai = os.environ['BONSAI_URL']
Check How to set environment variables in Python

Can't connect to MongoDB after upgrading?

I'm building a website using Flask in which I use MongoDB with the MongoEngine ORM. To go for a fresh start again I now upgraded all apt and pip packages on my ubuntu 14.04 development machine. Unfortunately this broke my connection to MongoDB:
Traceback (most recent call last):
File "./run.py", line 4, in <module>
from app import app, socketio
File "/home/kr65/beta/app/__init__.py", line 21, in <module>
mongoDb = MongoEngine(app)
File "/usr/local/lib/python2.7/dist-packages/flask_mongoengine/__init__.py", line 33, in __init__
self.init_app(app)
File "/usr/local/lib/python2.7/dist-packages/flask_mongoengine/__init__.py", line 66, in init_app
self.connection = mongoengine.connect(**conn_settings)
File "/usr/local/lib/python2.7/dist-packages/mongoengine/connection.py", line 164, in connect
return get_connection(alias)
File "/usr/local/lib/python2.7/dist-packages/mongoengine/connection.py", line 126, in get_connection
raise ConnectionError("Cannot connect to database %s :\n%s" % (alias, e))
mongoengine.connection.ConnectionError: Cannot connect to database default :
False is not a read preference.
I checked if MongoDB is up:
$ sudo service mongodb status
mongodb start/running, process 781
and if I could get into the interactive command line:
$ mongo
MongoDB shell version: 2.4.9
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
Tue Apr 14 09:14:10.267 [initandlisten]
Tue Apr 14 09:14:10.267 [initandlisten] ** WARNING: You are running in OpenVZ. This is known to be broken!!!
Tue Apr 14 09:14:10.267 [initandlisten]
>
I didn't change anything to the code or passwords or anything like that. I did a reboot and restarted mongoDB, but nothing works. My settings are like this:
MONGODB_SETTINGS = {
'db': 'mydatabasename'
}
and I instantiate the connection like this (which worked before):
app = Flask(__name__)
app.config.from_object('config')
mongoDb = MongoEngine(app)
Since I didn't really change anything, I'm kind of unsure where to search for a solution. Does anybody have any tips how I could solve this?
[EDIT]
With the tip of #lapinkoira my MongoDB now starts up correctly, but I now get the error below while querying. Any ideas how to solve this one?
File "/home/kr65/beta/app/views/webviews.py", line 476, in getDoc
userDoc = UserDocument.objects(id=docId).first()
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/base.py", line 309, in first
result = queryset[0]
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/base.py", line 160, in __getitem__
return queryset._document._from_son(queryset._cursor[key],
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/base.py", line 1410, in _cursor
**self._cursor_args)
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 924, in find
return Cursor(self, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'snapshot'
looks like you have pymongo 3.0 installed.
Mongoengine is not yet compatible with it.
You can try fix this by
pip uninstall pymongo
pip install pymongo==2.8
Looks like your default read_preference value is False, try this, add to your imports:
from pymongo import read_preferences
and this to your mongo config dictionary:
'read_preference': read_preferences.ReadPreference.PRIMARY
If using monogengine >= 3 and python >=3 and Ubuntu
Write
from pymongo import read_preferences in /usr/local/lib/python3.5/dist-packages/mongoengine/
and open terminal in the same directory with sudo gedit connection.py
and in def register_connection
replace
'read_preference': read_preferences.ReadPreference.PRIMARY in parameters of the function
And it works like charm

Running Into Issues Access Console On Google Appengine 1.5.4

I'm running into the following issue when trying to activate our console on Google Appengine.
WARNING:root:No ssl package found. urlfetch will not be able to validate SSL certificates.
Traceback (most recent call last):
File "manage.py", line 18, in
InstallAppengineHelperForDjango()
File "/Users/franklinkho/Workspace/mopub/server/appengine_django/init.py", line 550, in InstallAppengineHelperForDjango
LoadAppengineEnvironment()
File "/Users/franklinkho/Workspace/mopub/server/appengine_django/init.py", line 212, in LoadAppengineEnvironment
appconfig, unused_matcher, _ = dev_appserver.LoadAppConfig(PARENT_DIR, {})
ValueError: need more than 2 values to unpack
Does anyone know why this is occurring?
So this is an issue with your version of GAE, its trying to unpack more values than is there. The patch is to set the retun of LoadAppConfig to be two parameters, the first is the appconfig and the other you can disregard.
appconfig, unused_matcher = dev_appserver.LoadAppConfig(PARENT_DIR, {})

Suds + JIRA = SAXException

I'm using Python 2.6 and suds 0.3.7 to interact with JIRA 4.0.
When I connect to the JIRA server, I get information on all the issues just fine.
However, when I want to update an issue, I get a SAXException from suds (presumably):
WebFault: Server raised fault:
org.xml.sax.SAXException: Found character data inside an array element while deserializing
I'm following the steps described here: http://confluence.atlassian.com/display/JIRA/Creating+a+SOAP+Client
only replacing SOAPpy calls with suds.
My attempt to update an issue looks like this, complete with exceptions:
>>> w="http://bugs/rpc/soap/jirasoapservice-v2?wsdl"
>>> from suds.client import Client
>>> client = Client(w)
>>> auth = client.service.login("myname","mypass")
>>> issue = client.service.getIssue(auth,"BUG-30112")
>>> issue.summary
This is the original summary for BUG-30112
>>>
>>> client.service.updateIssue(auth,"BUG-30112",[
... {"id":"summary","values":["My new summary"]}])
Traceback (most recent call last):
File "<interactive input>", line 2, in <module>
File "C:\Python26\lib\suds\client.py", line 535, in __call__
return client.invoke(args, kwargs)
File "C:\Python26\lib\suds\client.py", line 595, in invoke
result = self.send(msg)
File "C:\Python26\lib\suds\client.py", line 630, in send
result = self.failed(binding, e)
File "C:\Python26\lib\suds\client.py", line 681, in failed
r, p = binding.get_fault(reply)
File "C:\Python26\lib\suds\bindings\binding.py", line 235, in get_fault
raise WebFault(p, faultroot)
WebFault: Server raised fault: 'org.xml.sax.SAXException: Found character data inside an array element while deserializing'
>>>
Has anyone seen a problem like this?
This will be solved if you switch to suds 3.0.9 (beta) ... the only one to have the fix.
How about increasing the verbosity to see what is being sent? Or use wireshark. You could also do the same with SOAPpy and compare exactly what is sent. Debugging soap errors is usually like this for me :-/
~Matt
Actually, by just changing the library from suds to SOAPpy, everything started working with no other modifications. Kind of annoying. I skipped SOAPpy because it seemed to have been abandoned and more complex to install, compared to suds. But SOAPpy works!
Thanks, all.

Categories

Resources