Ejemplo n.º 1
0
def create_cassandra_permacache_column_family(config):
    sys = SystemManager(config.get('DEFAULT', 'cassandra_seeds'))
    if 'permacache' in sys.get_keyspace_column_families(config.get('DEFAULT', 'cassandra_keyspace')).keys():
        print "found permacache, not creating"
        return
    print "creating %r / 'permacache'" % (config.get('DEFAULT', 'cassandra_keyspace'),)
    sys.create_column_family(config.get('DEFAULT', 'cassandra_keyspace'), 'permacache', super=False, comparator_type=BYTES_TYPE, row_cache_provider='org.apache.cassandra.cache.ConcurrentLinkedHashCacheProvider')
    print "created permacache"
	def colum_family_create(self,machine_id,keyspace_name,column_family_name):
		"""Create a column family in a given keyspace """
		if (self.keyspace_contains(keyspace_name) == False):
			print "Error : Keyspace with this name dosenot exist."
			return False
		sys = SystemManager(machine_id)
		sys.create_column_family(keyspace_name, column_family_name)
		self.keyspace_columnfamily_list('localhost:9160')
		sys.close()
		return True
Ejemplo n.º 3
0
 def colum_family_create(self, machine_id, keyspace_name,
                         column_family_name):
     """Create a column family in a given keyspace """
     if (self.keyspace_contains(keyspace_name) == False):
         print "Error : Keyspace with this name dosenot exist."
         return False
     sys = SystemManager(machine_id)
     sys.create_column_family(keyspace_name, column_family_name)
     self.keyspace_columnfamily_list('localhost:9160')
     sys.close()
     return True
Ejemplo n.º 4
0
def create_column_families():
    sys = pycassa.system_manager.SystemManager('esb-a-test.sensors.elex.be')
    #sys.create_keyspace('test', pycassa.system_manager.NETWORK_TOPOLOGY_STRATEGY, {'erfurt': '1', 'sensors': '1', 'sofia': '1', 'diegem': '1'})
    sys.create_column_family('test',
                             'INDEXCF',
                             super=False,
                             comparator_type=pycassa.system_manager.UTF8_TYPE)
    sys.create_column_family('test',
                             'DATACF',
                             super=False,
                             comparator_type=pycassa.system_manager.UTF8_TYPE)
    sys.close()
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 __init__(self):
   self.host = file_io.read(constants.APPSCALE_HOME + '/.appscale/my_private_ip')
   self.port = DEFAULT_PORT
   self.pool = pycassa.ConnectionPool(keyspace='Keyspace1', 
                          server_list=[self.host+":"+str(self.port)], 
                          prefill=False)
   sys = SystemManager(self.host + ":" + str(DEFAULT_PORT))
   try: 
     sys.create_column_family('Keyspace1', 
                              SCHEMA_TABLE, 
                              comparator_type=UTF8_TYPE)
   except Exception, e:
     print "Exception creating column family: %s"%str(e)
     pass
 def __init__(self):
     self.host = file_io.read(constants.APPSCALE_HOME +
                              '/.appscale/my_private_ip')
     self.port = DEFAULT_PORT
     self.pool = pycassa.ConnectionPool(
         keyspace='Keyspace1',
         server_list=[self.host + ":" + str(self.port)],
         prefill=False)
     sys = SystemManager(self.host + ":" + str(DEFAULT_PORT))
     try:
         sys.create_column_family('Keyspace1',
                                  SCHEMA_TABLE,
                                  comparator_type=UTF8_TYPE)
     except Exception, e:
         print "Exception creating column family: %s" % str(e)
         pass
Ejemplo n.º 8
0
 def __init__(self, logger = appscale_logger.getLogger("datastore-cassandra")):
   f = open(APPSCALE_HOME + '/.appscale/my_private_ip', 'r')
   self.host = f.read()
   self.port = DEFAULT_PORT
   self.pool = pycassa.ConnectionPool(keyspace='Keyspace1', 
                          server_list=[self.host+":"+str(self.port)], 
                          prefill=False)
   f = open(APPSCALE_HOME + '/.appscale/my_private_ip', 'r')
   host = f.read()
   sys = SystemManager(host + ":" + str(DEFAULT_PORT))
   try: 
     sys.create_column_family('Keyspace1', 
                              SCHEMA_TABLE, 
                              comparator_type=UTF8_TYPE)
   except Exception, e:
     print "Exception creating column family: %s"%str(e)
     pass
Ejemplo n.º 9
0
	def colum_family_create(self,machine_id,keyspace_name,column_family_name):
		"""Create a column family in a given keyspace """
		keyspace.error = "Unknown error occur please check your inputs"
		if (self.keyspace_contains(keyspace.local_system,keyspace_name) == False):
			keyspace.error = "Desired Keyspace does not exist."
			return False
		try:
			sys = SystemManager(machine_id)
		except Exception as e:
			print e
			return False
		try:
			sys.create_column_family(keyspace_name, column_family_name)
		except Exception as e:
			print e
			return False
		sys.close()
		return True
Ejemplo n.º 10
0
 def __init__(self,
              logger=appscale_logger.getLogger("datastore-cassandra")):
     f = open(APPSCALE_HOME + '/.appscale/my_private_ip', 'r')
     self.host = f.read()
     self.port = DEFAULT_PORT
     self.pool = pycassa.ConnectionPool(
         keyspace='Keyspace1',
         server_list=[self.host + ":" + str(self.port)],
         prefill=False)
     f = open(APPSCALE_HOME + '/.appscale/my_private_ip', 'r')
     host = f.read()
     sys = SystemManager(host + ":" + str(DEFAULT_PORT))
     try:
         sys.create_column_family('Keyspace1',
                                  SCHEMA_TABLE,
                                  comparator_type=UTF8_TYPE)
     except Exception, e:
         print "Exception creating column family: %s" % str(e)
         pass
Ejemplo n.º 11
0
	def colum_family_create(self,machine_id,keyspace_name,column_family_name):
		"""Create a column family in a given keyspace """
		print "->>>in column family create function"
		sys = SystemManager(machine_id)
		sys.create_column_family(keyspace_name, column_family_name)
		return 1
Ejemplo n.º 12
0
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,
)
sys.create_column_family(keyspace, 'Timeline',
    comparator_type=UTF8_TYPE,
    default_validation_class=UTF8_TYPE,
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
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,
Ejemplo n.º 15
0
def create_column_families():
    sys = pycassa.system_manager.SystemManager('esb-a-test.sensors.elex.be')
    #sys.create_keyspace('test', pycassa.system_manager.NETWORK_TOPOLOGY_STRATEGY, {'erfurt': '1', 'sensors': '1', 'sofia': '1', 'diegem': '1'})
    sys.create_column_family('test', 'INDEXCF', super=False, comparator_type=pycassa.system_manager.UTF8_TYPE)
    sys.create_column_family('test', 'DATACF', super=False, comparator_type=pycassa.system_manager.UTF8_TYPE)
    sys.close()
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"

def prime_cassandra(replication):
  create_keyspaces(int(replication))