-
Notifications
You must be signed in to change notification settings - Fork 277
Code cleanup, updated datastore interface, removed unused files #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
381b5f5
8c08f0b
a250b10
da264b0
f234f5d
fd1f2c1
f59910f
334fd4e
fa01bd5
ad4e76d
1b05560
5614640
6be9ff0
6b19d84
82854dd
a7e98ed
5906800
86a0ca5
02aaab9
c112324
62eeb1f
3b583aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/usr/bin/python | ||
| # Programmer: Navraj Chohan <nlake44@gmail.com> | ||
| # See LICENSE file | ||
|
|
||
| import imp | ||
| import os | ||
| import socket | ||
| import string | ||
| import sys | ||
| import threading | ||
| import types | ||
|
|
||
| import appscale_logger | ||
| import dbconstants | ||
|
|
||
| app_datastore_logger = appscale_logger.getLogger("appscale_datastore_batch") | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this logger be initialized with the name of the class? (appscale_datastore_batch)?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
| DATASTORE_DIR= "%s/AppDB" % dbconstants.APPSCALE_HOME | ||
|
|
||
| class DatastoreFactory: | ||
|
|
||
| @classmethod | ||
| def getDatastore(cls, d_type): | ||
| """ Returns a reference for the datastore. Validates where | ||
| the <datastore>_interface.py is and adds that path to | ||
| the system path. | ||
|
|
||
| Args: | ||
| d_type: The name of the datastore (ex: cassandra) | ||
| """ | ||
|
|
||
| datastore = None | ||
| mod_path = DATASTORE_DIR + "/" + d_type + "/" + d_type + "_interface.py" | ||
|
|
||
| if os.path.exists(mod_path): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need to do this? Can't you just load them all and use something like a Factory to get the right datastore?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The loading method can be changed if needed. If this old method is not sufficient we can create a new issue to do loading of the interface as suggested and do so for the older versions as well. |
||
| sys.path.append(DATASTORE_DIR + "/" + d_type) | ||
| d_mod = imp.load_source(d_type+"_interface.py", mod_path) | ||
| datastore = d_mod.DatastoreProxy(app_datastore_logger) | ||
| else: | ||
| app_datastore_logger.error("Fail to use datastore: %s. Please \ | ||
| check the datastore type." % d_type) | ||
| raise Exception("Fail to use datastore: %s" % d_type) | ||
|
|
||
| return datastore | ||
|
|
||
| @classmethod | ||
| def valid_datastores(cls): | ||
| """ Returns a list of directories where the datastore code is | ||
|
|
||
| Returns: Directory list | ||
| """ | ||
|
|
||
| dblist = os.listdir(DATASTORE_DIR) | ||
| return dblist | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving to be consistent with god interface.