def prime_hypertable(): """ Primes the hypertable datastore with the tables required by an AppScale deployment. Returns: The int 0 on success, and the int 1 on failure. """ print "prime hypertable database" client = py_hypertable.DatastoreProxy() print "Creating users table" print client.create_table(dbconstants.USERS_TABLE, dbconstants.USERS_SCHEMA) print "Creating apps table" tables = client.create_table(dbconstants.APPS_TABLE, dbconstants.APPS_SCHEMA) create_app_tables() if dbconstants.USERS_TABLE in tables and dbconstants.APPS_TABLE in tables: print "CREATE TABLE SUCCESS FOR USER AND APPS" return 0 else: print "FAILED TO CREATE TABLE FOR USER AND APPS" return 1
def create_app_tables(): db = py_hypertable.DatastoreProxy() db.create_table(ASC_PROPERTY_TABLE, PROPERTY_SCHEMA) db.create_table(DSC_PROPERTY_TABLE, PROPERTY_SCHEMA) db.create_table(APP_INDEX_TABLE, APP_INDEX_SCHEMA) db.create_table(APP_NAMESPACE_TABLE, APP_NAMESPACE_SCHEMA) db.create_table(APP_ID_TABLE, APP_ID_SCHEMA) db.create_table(APP_ENTITY_TABLE, APP_ENTITY_SCHEMA) db.create_table(APP_KIND_TABLE, APP_KIND_SCHEMA)
def prime_hypertable(): print "prime hypertable database" client = py_hypertable.DatastoreProxy() print "Creating users table" print client.create_table(USERS_TABLE, USERS_SCHEMA) print "Creating apps table" tables = client.create_table(APPS_TABLE, APPS_SCHEMA) if USERS_TABLE in tables and APPS_TABLE in tables: print "CREATE TABLE SUCCESS FOR USER AND APPS" return 0 else: print "FAILED TO CREATE TABLE FOR USER AND APPS" return 1
def create_app_tables(): """ Creates required tables for storing application data. Tables include entity data, indexes, and transaction journalling. Tables are created by using the AppScale hypertable interface. """ datastore = py_hypertable.DatastoreProxy() datastore.create_table(dbconstants.ASC_PROPERTY_TABLE, dbconstants.PROPERTY_SCHEMA) datastore.create_table(dbconstants.DSC_PROPERTY_TABLE, dbconstants.PROPERTY_SCHEMA) datastore.create_table(dbconstants.APP_ID_TABLE, dbconstants.APP_ID_SCHEMA) datastore.create_table(dbconstants.APP_ENTITY_TABLE, dbconstants.APP_ENTITY_SCHEMA) datastore.create_table(dbconstants.APP_KIND_TABLE, dbconstants.APP_KIND_SCHEMA) datastore.create_table(dbconstants.JOURNAL_TABLE, dbconstants.JOURNAL_SCHEMA)
import py_hypertable py_hypertable = py_hypertable.DatastoreProxy() columns = ["a", "b", "c"] data = ["1", "2", "3"] table_name = "hello" key = "1" print "key= " + key print "columns= " + str(columns) print "data= " + str(data) print "table= " + table_name print "PUT" print py_hypertable.put_entity(table_name, key, columns, data) print "GET" ret = py_hypertable.get_entity(table_name, key, columns) print "doing a put then get" print ret if ret[1:] != data: print "ERROR doing a put then get. Data does not match" print "returned: " + str(ret) print "expected: " + str(data) exit(1) else: print "Success" ret = py_hypertable.get_schema("hello") print ret print "checking schema:" print ret if ret[1:] != columns: print "ERROR in recieved schema" print "returned: " + str(ret)