def create_keyspaces(replication): """ Creates keyspace which AppScale uses for storing application and user data Args: replication: Replication factor for Cassandra Raises: AppScaleBadArg: When args are bad """ if int(replication) <= 0: raise dbconstants.AppScaleBadArg( "Replication must be greater than zero") print "Creating Cassandra Key Spaces" # Set this to False to keep data from a previous deployment. Setting it # it to True will remove previous tables. _DROP_TABLES = True # TODO use shared library to get constants host = helper_functions.read_file('/etc/appscale/my_private_ip') sysman = system_manager.SystemManager(host + ":" +\ str(cassandra_interface.CASS_DEFAULT_PORT)) if _DROP_TABLES: try: sysman.drop_keyspace(cassandra_interface.KEYSPACE) except pycassa.cassandra.ttypes.InvalidRequestException, e: pass
def main(): parser = argparse.ArgumentParser() parser.add_argument("file_name", help="Enter input file name", type=str) args = parser.parse_args() yes_exs, no_exs, attributes = read_file(args.file_name) root = Node(yes_exs, no_exs) build_decision_tree(root, yes_exs, no_exs, attributes, yes_exs, no_exs) # expand the decision tree print_tree(root) print("number of nodes is: {}".format(count_nodes(root))) print("training_set_accuracy is: {:.2%}".format( training_set_accuracy(yes_exs, no_exs, root))) run_cross_val = input( "Do you want to run leave-one-out cross-validation (y/n)? ") if run_cross_val == 'y': print("test_set_accuracy is: {:.2%}".format( test_set_accuracy(yes_exs, no_exs, attributes))) elif run_cross_val != 'n': print("Invalid input! Please enter either 'y' or 'n'.")
def create_keyspaces(replication): """ Creates keyspace which AppScale uses for storing application and user data Args: replication: Replication factor for Cassandra Raises: AppScaleBadArg: When args are bad """ if int(replication) <= 0: raise dbconstants.AppScaleBadArg("Replication must be greater than zero") print "Creating Cassandra Key Spaces" # Set this to False to keep data from a previous deployment. Setting it # it to True will remove previous tables. _DROP_TABLES = True # TODO use shared library to get constants host = helper_functions.read_file('/etc/appscale/my_private_ip') sysman = system_manager.SystemManager(host + ":" +\ str(cassandra_interface.CASS_DEFAULT_PORT)) if _DROP_TABLES: try: sysman.drop_keyspace(cassandra_interface.KEYSPACE) except pycassa.cassandra.ttypes.InvalidRequestException, e: pass
def __init__(self, logger = appscale_logger.getLogger("datastore-hypertable")): """ Constructor Args: logger: Object where log messages are sent """ self.logger = logger self.host = helper_functions.read_file( APPSCALE_HOME + '/.appscale/my_private_ip') self.conn = thriftclient.ThriftClient(self.host, THRIFT_PORT) self.ns = self.conn.namespace_open(NS)
def __init__(self, logger=appscale_logger.getLogger("datastore-hypertable")): """ Constructor Args: logger: Object where log messages are sent """ self.logger = logger self.host = helper_functions.read_file(APPSCALE_HOME + '/.appscale/my_private_ip') self.conn = thriftclient.ThriftClient(self.host, THRIFT_PORT) self.ns = self.conn.namespace_open(NS)
def create_connection(self): """ Creates a connection to HBase's Thrift to the local node. Returns: An HBase client object """ host = helper_functions.read_file('/etc/appscale/my_private_ip') t = TSocket.TSocket(host, THRIFT_PORT) t = TTransport.TBufferedTransport(t) p = TBinaryProtocol.TBinaryProtocol(t) c = Hbase.Client(p) t.open() return c
def __init__(self, logger = appscale_logger.getLogger("datastore-cassandra")): """ Constructor Args: logger: An object that logging messages can be sent to """ self.host = helper_functions.read_file(APPSCALE_HOME + \ '/.appscale/my_private_ip') self.port = CASS_DEFAULT_PORT self.pool = pycassa.ConnectionPool(keyspace=KEYSPACE, server_list=[self.host+":"+str(self.port)], prefill=False) self.logger = logger
def __init__(self, logger=appscale_logger.getLogger("datastore-cassandra")): """ Constructor Args: logger: An object that logging messages can be sent to """ self.host = helper_functions.read_file(APPSCALE_HOME + \ '/.appscale/my_private_ip') self.port = CASS_DEFAULT_PORT self.pool = pycassa.ConnectionPool( keyspace=KEYSPACE, server_list=[self.host + ":" + str(self.port)], prefill=False) self.logger = logger