Esempio n. 1
0
 def tearDown(self):
     if self.store._store is not None:
         self.store.clear()
         self.store.close()
     from pycassa.system_manager import SystemManager  # @UnresolvedImport @IgnorePep8
     system_manager = SystemManager('localhost:9160')
     system_manager.drop_column_family('Murk', 'shove')
Esempio n. 2
0
 def tearDown(self):
     if self.store._store is not None:
         self.store.clear()
         self.store.close()
     from pycassa.system_manager import SystemManager  # @UnresolvedImport @IgnorePep8
     system_manager = SystemManager('localhost:9160')
     system_manager.drop_column_family('Murk', 'shove')
Esempio n. 3
0
class CassandraDbSysManager:
    def __init__(self):
        try:
            logger.info("Connection to " + DB_IP + ":" + DB_PORT + " ...")
            self.sysDB = SystemManager(DB_IP + ":" + DB_PORT)
            logger.info("Connection to the systemManager established.")
        except Exception as exep:
            logger.warning("Could not connect to the DB '" + DB_IP + ":" + DB_PORT + "'. | " + str(exep))


    def create_keyspace(self, KeyspaceName, replica_factor):
        try:
            logger.info(
                "Creating the Keyspace '" + KeyspaceName + "' with replica_factor '" + str(replica_factor) + "'")
            self.sysDB.create_keyspace(KeyspaceName, replica_factor)
            logger.info("Keyspace created.")
        except Exception as exep:
            logger.warning("Could not create the keyspace '" + KeyspaceName + "'. | " + str(exep))

    def drop_keyspace(self, KeyspaceName):
        try:
            logger.info("Dropping the Keyspace '" + KeyspaceName + "'")
            self.sysDB.drop_keyspace(KeyspaceName)
            logger.info("Keyspace dropped.")
        except Exception as exep:
            logger.warning("Could not drop the keyspace '" + KeyspaceName + "'. | " + str(exep))

    def create_column_family(self, KeyspaceName, columnFamily):
        try:
            logger.info("Creating the Column family '" + columnFamily + "' into the keyspace '" + KeyspaceName + "'")
            self.sysDB.create_column_family(KeyspaceName, columnFamily, super=False,
                                            comparator_type=pycassa.system_manager.ASCII_TYPE)
            logger.info("Column Family created.")
        except Exception as exep:
            logger.warning(
                "Could not create the Column Family '" + columnFamily + "' into the keyspace '" + KeyspaceName + "'. | " + str(
                    exep))

    def drop_column_family(self, KeyspaceName, columnFamily):
        try:
            logger.info("Dropping the Column Family '" + columnFamily + "' from the Keyspace '" + KeyspaceName + "'")
            self.sysDB.drop_column_family(KeyspaceName, columnFamily)
            logger.info("Column Family dropped.")
        except Exception as exep:
            logger.warning("Could not drop the column family '" + columnFamily + "'. | " + str(exep))
Esempio n. 4
0
class ComedySysManagerConnection(object):
    """
    This is a also a client connection of Cassandra, difference is it is only for System-Manager level
    """
    def __init__(self, server='localhost:9160', credentials=None, framed_transport=True,
                                                                    timeout=_DEFAULT_TIMEOUT):
        self.conn = SystemManager(server,credentials,framed_transport,timeout)
        
    def create_keyspace(self, name, replication_strategy='SimpleStrategy', strategy_options=None, durable_writes=True, **ks_kwargs):
        """Create a database"""
        self.conn.create_keyspace(name, replication_strategy, strategy_options, durable_writes)
    
    create_database = create_keyspace
    
    def drop_keyspace(self, keyspace):
        """Drop a database"""
        self.conn.drop_keyspace(keyspace)
    
    drop_database = drop_keyspace
    
    
    def create_column_family(self, keyspace, name, column_validation_classes=None, **cf_kwargs):
        """Create a table"""
        self.conn.create_column_family(keyspace, name, column_validation_classes=None, **cf_kwargs) 
    
    create_table = create_column_family
    
    def drop_column_family(self, keyspace, column_family):
        """Drop a table"""
        self.conn.drop_column_family(keyspace, column_family)
        
    drop_table = drop_column_family
    

    def close(self):
        pass
Esempio n. 5
0
 def tearDown(self):
     self.store.clear()
     self.store.close()
     from pycassa.system_manager import SystemManager
     system_manager = SystemManager('localhost:9160')
     system_manager.drop_column_family('Foo', 'shove')
 def tearDown(self):
     self.store.clear()
     self.store.close()
     from pycassa.system_manager import SystemManager
     system_manager = SystemManager('localhost:9160')
     system_manager.drop_column_family('Foo', 'shove')
Esempio n. 7
0
 def teardown_class(cls):
     sys = SystemManager()
     sys.drop_column_family(TEST_KS, 'StdInteger')
Esempio n. 8
0
 def teardown_class(cls):
     sys = SystemManager()
     sys.drop_column_family(TEST_KS, 'StaticComposite')
Esempio n. 9
0
 def teardown_class(cls):
     sys = SystemManager()
     sys.drop_column_family(TEST_KS, 'CustomComposite1')
Esempio n. 10
0
 def teardown_class(cls):
     sys = SystemManager()
     sys.drop_column_family(TEST_KS, 'CompositeOverrideCF')
Esempio n. 11
0
 def _drop_cf(self, cf_name):
     sys_mng = SystemManager('localhost:9160')
     sys_mng.drop_column_family('bbs',cf_name)
     sys_mng.close()