Ejemplo n.º 1
0
def create_cassandra_keyspace(config):
    sys = SystemManager(config.get('DEFAULT', 'cassandra_seeds'))
    if config.get('DEFAULT', 'cassandra_keyspace') in sys.list_keyspaces():
        print "found keyspace %r, not creating" % (config.get('DEFAULT', 'cassandra_keyspace'),)
        return
    print "creating %r" % (config.get('DEFAULT', 'cassandra_keyspace'),)
    sys.create_keyspace(config.get('DEFAULT', 'cassandra_keyspace'), replication_factor=1)
	def keyspace_create(self,machine_id,name):
		"""Create keyspace with given name on specified machine_id """
		print "->>>in create keyspace function"
		sys = SystemManager(machine_id)
		sys.create_keyspace(name, SIMPLE_STRATEGY, {'replication_factor': '1'})
		sys.close()
		return 1
	def keyspace_create(self,machine_id,keyspace_name):
		"""Create keyspace with given name on specified machine_id """
		if (self.keyspace_contains(keyspace_name) == True):
			print "Error : Keyspace with this name already exist."
			return False
		sys = SystemManager(machine_id)
		print sys.create_keyspace(keyspace_name, SIMPLE_STRATEGY, {'replication_factor': '1'})
		self.keyspace_columnfamily_list('localhost:9160')
		sys.close()
		return True
Ejemplo n.º 4
0
 def keyspace_create(self, machine_id, keyspace_name):
     """Create keyspace with given name on specified machine_id """
     if (self.keyspace_contains(keyspace_name) == True):
         print "Error : Keyspace with this name already exist."
         return False
     sys = SystemManager(machine_id)
     print sys.create_keyspace(keyspace_name, SIMPLE_STRATEGY,
                               {'replication_factor': '1'})
     self.keyspace_columnfamily_list('localhost:9160')
     sys.close()
     return True
Ejemplo n.º 5
0
def cassandra_changed():
    import pycassa

    # relation-get:
    # port: "9160"
    # private-address: 10.0.3.147
    host = hookenv.relation_get('private-address')
    port = hookenv.relation_get('port')
    if host and port:
        casshost = '%s:%d' % (host, int(port))
        log("Connecting to Cassandra host: %s" % casshost)

        sys = pycassa.system_manager.SystemManager(casshost)

        # Create 'reddit' keyspace
        keyspaces = sys.list_keyspaces()
        if CASSANDRA_KEYSPACE not in keyspaces:
            sys.create_keyspace(
                CASSANDRA_KEYSPACE,
                pycassa.system_manager.SIMPLE_STRATEGY,
                {'replication_factor': '1'}
            )
            log("Created '%s' keyspace" % CASSANDRA_KEYSPACE)
        else:
            log("'%s' keyspace already exists." % CASSANDRA_KEYSPACE)

        column_families = sys.get_keyspace_column_families(
            CASSANDRA_KEYSPACE
        ).keys()

        if CASSANDRA_COLUMN not in column_families:
            sys.create_column_family(
                CASSANDRA_KEYSPACE,
                CASSANDRA_COLUMN,
                column_type='Standard',
                default_validation_class=pycassa.BYTES_TYPE
            )
            log("Created '%s' column" % CASSANDRA_COLUMN)
        else:
            log("'%s' column already exists" % CASSANDRA_COLUMN)

        add_to_ini(values={
            'cassandra_seeds': casshost
        })

        make_ini()

    else:
        log("cassandra not ready")

    return
Ejemplo n.º 6
0
	def keyspace_create(self,machine_id,keyspace_name,replication="1"):
		"""Create keyspace with given name on specified machine_id """
		keyspace.error = "Unknown error occur please check your inputs"
		if (self.keyspace_contains(keyspace.local_system,keyspace_name) == True):
			keyspace.error = "Desired Keyspace already exist with this name"
			return False
		try:
			sys = SystemManager(machine_id)
		except Exception as e:
			print e
			return False
		try:
			sys.create_keyspace(keyspace_name, SIMPLE_STRATEGY, {'replication_factor': replication})
		except Exception as e:
			print e	
			return False
		sys.close()
		return True
Ejemplo n.º 7
0
sys = SystemManager()
keyspace = settings.CASSANDRA_KEYSPACE

if keyspace in sys.list_keyspaces():
    msg = 'Looks like you already have a %s keyspace.\nDo you ' % keyspace
    msg += 'want to delete it and recreate it? All current data will '
    msg += 'be deleted! (y/n): '
    resp = raw_input(msg)
    if not resp or resp[0] != 'y':
        print "Ok, then we're done here."
        import sys
        sys.exit(0)
    sys.drop_keyspace(keyspace)

sys.create_keyspace(keyspace, SIMPLE_STRATEGY, {'replication_factor': '1'})
sys.create_column_family(keyspace, 'Counters',
    comparator_type=UTF8_TYPE,
    default_validation_class='CounterColumnType',
    key_validation_class=UTF8_TYPE,
)
sys.create_column_family(keyspace, 'Followers',
    comparator_type=LONG_TYPE,
    default_validation_class=LONG_TYPE,
    key_validation_class=LONG_TYPE,
)
sys.create_column_family(keyspace, 'UserTimeline',
    comparator_type=LONG_TYPE,
    default_validation_class=LONG_TYPE,
    key_validation_class=LONG_TYPE,
)
Ejemplo n.º 8
0
from pycassa.system_manager import *
CASS_PORT = 9160


def create_keyspaces(replication):
    print "Creating Key Spaces"
    f = open(APPSCALE_HOME + '/.appscale/my_private_ip', 'r')
    host = f.read()
    sys = SystemManager(host + ":" + str(CASS_PORT))

    try:
        sys.drop_keyspace('Keyspace1')
    except pycassa.cassandra.ttypes.InvalidRequestException, e:
        pass

    sys.create_keyspace('Keyspace1', pycassa.SIMPLE_STRATEGY,
                        {'replication_factor': str(replication)})
    sys.create_column_family(
        'Keyspace1',
        'Standard1',  #column_type="Standard",
        comparator_type=UTF8_TYPE)
    sys.create_column_family(
        'Keyspace1',
        'Standard2',  #column_type="Standard",
        comparator_type=UTF8_TYPE)
    sys.create_column_family(
        'Keyspace1',
        'StandardByTime1',  #column_type="Standard",
        comparator_type=TIME_UUID_TYPE)
    sys.create_column_family(
        'Keyspace1',
        'StandardByTime2',  #column_type="Standard",
Ejemplo n.º 9
0
sys = SystemManager()
keyspace = settings.CASSANDRA_KEYSPACE

if keyspace in sys.list_keyspaces():
    msg = 'Looks like you already have a %s keyspace.\nDo you ' % keyspace
    msg += 'want to delete it and recreate it? All current data will '
    msg += 'be deleted! (y/n): '
    resp = raw_input(msg)
    if not resp or resp[0] != 'y':
        print "Ok, then we're done here."
        import sys
        sys.exit(0)
    sys.drop_keyspace(keyspace)

sys.create_keyspace(keyspace, SIMPLE_STRATEGY, {'replication_factor': '1'})
sys.create_column_family(
    keyspace,
    'Counters',
    comparator_type=UTF8_TYPE,
    default_validation_class='CounterColumnType',
    key_validation_class=UTF8_TYPE,
)
sys.create_column_family(
    keyspace,
    'Followers',
    comparator_type=LONG_TYPE,
    default_validation_class=LONG_TYPE,
    key_validation_class=LONG_TYPE,
)
sys.create_column_family(
from dbconstants import *
import pycassa
from pycassa.system_manager import *
CASS_PORT = 9160
def create_keyspaces(replication):
  print "Creating Key Spaces" 
  f = open(APPSCALE_HOME + '/.appscale/my_private_ip', 'r')
  host = f.read()
  sys = SystemManager(host + ":" + str(CASS_PORT))

  try:
    sys.drop_keyspace('Keyspace1')
  except pycassa.cassandra.ttypes.InvalidRequestException, e:
    pass

  sys.create_keyspace('Keyspace1', pycassa.SIMPLE_STRATEGY, {'replication_factor':str(replication)})
  sys.create_column_family('Keyspace1', 'Standard1', #column_type="Standard",
                          comparator_type=UTF8_TYPE)
  sys.create_column_family('Keyspace1', 'Standard2', #column_type="Standard",
                          comparator_type=UTF8_TYPE)
  sys.create_column_family('Keyspace1', 'StandardByTime1', #column_type="Standard",
                          comparator_type=TIME_UUID_TYPE)
  sys.create_column_family('Keyspace1', 'StandardByTime2', #column_type="Standard",
                          comparator_type=TIME_UUID_TYPE)
  #sys.create_column_family('Keyspace1', 'Super1',  column_type="Super",
  #                        comparator_type=UTF8_TYPE)
  #sys.create_column_family('Keyspace1', 'Super2', column_type="Super",
  #                        comparator_type=UTF8_TYPE)
  sys.close()
  print "SUCCESS"