Ejemplo n.º 1
0
def makeConnection():
    try:
        global bCluster, bSpace, keyspace_name, replication_factor, connection_established
        bCluster, bSpace = cassandraHelper.makeConnection()
        keyspace_name,replication_factor = cassandraHelper.findKeyAndRep()
        bSpace.set_keyspace(keyspace_name)
        if bSpace is not None:
            connection_established = True #if some error occurs this would be skipped
            return True
    except InvalidRequest as er:
        try:
            bSpace.execute("create keyspace %s with replication={'class':'SimpleStrategy','replication_factor':%s}" % (keyspace_name, replication_factor))
            bSpace.set_keyspace(keyspace_name)
            return True
        except Exception as er:
            print 'bemossspace couldnt be created/switched to'
            print er
            raise er

    except Exception as er:
        print 'Cannot establish connection'
        raise er
Ejemplo n.º 2
0
def makeConnection():
    try:
        global bCluster, bSpace, keyspace_name, replication_factor, connection_established
        bCluster, bSpace = cassandraHelper.makeConnection()
        keyspace_name, replication_factor = cassandraHelper.findKeyAndRep()
        bSpace.set_keyspace(keyspace_name)
        if bSpace is not None:
            connection_established = True  #if some error occurs this would be skipped
            return True
    except InvalidRequest as er:
        try:
            bSpace.execute(
                "create keyspace %s with replication={'class':'SimpleStrategy','replication_factor':%s}"
                % (keyspace_name, replication_factor))
            bSpace.set_keyspace(keyspace_name)
            return True
        except Exception as er:
            print 'bemossspace couldnt be created/switched to'
            print er
            raise er

    except Exception as er:
        print 'Cannot establish connection'
        raise er