コード例 #1
0
    def create_cf(self,
                  session,
                  name,
                  key_type="varchar",
                  speculative_retry=None,
                  read_repair=None,
                  compression=None,
                  gc_grace=None,
                  columns=None,
                  compact_storage=False):

        additional_columns = ""
        if columns is not None:
            for k, v in columns.items():
                additional_columns = "%s, %s %s" % (additional_columns, k, v)

        if additional_columns == "":
            query = ('CREATE COLUMNFAMILY %s (key %s, c varchar, v varchar, '
                     'PRIMARY KEY(key, c)) WITH comment=\'test cf\'' %
                     (name, key_type))
        else:
            query = ('CREATE COLUMNFAMILY %s (key %s PRIMARY KEY%s) '
                     'WITH comment=\'test cf\'' %
                     (name, key_type, additional_columns))

        if compression is not None:
            query = ('%s AND compression = { \'sstable_compression\': '
                     '\'%sCompressor\' }' % (query, compression))
        else:
            # if a compression option is omitted, C*
            # will default to lz4 compression
            query += ' AND compression = {}'

        if read_repair is not None:
            query = '%s AND read_repair_chance=%f' % (query, read_repair)
        if gc_grace is not None:
            query = '%s AND gc_grace_seconds=%d' % (query, gc_grace)
        if speculative_retry is not None:
            query = ('%s AND speculative_retry=\'%s\'' %
                     (query, speculative_retry))

        if compact_storage:
            query += ' AND COMPACT STORAGE'

        session.execute(query)
        time.sleep(0.2)
コード例 #2
0
ファイル: tester.py プロジェクト: slivne/scylla-cluster-tests
    def create_cf(self, session, name, key_type="varchar",
                  speculative_retry=None, read_repair=None, compression=None,
                  gc_grace=None, columns=None,
                  compact_storage=False):

        additional_columns = ""
        if columns is not None:
            for k, v in columns.items():
                additional_columns = "%s, %s %s" % (additional_columns, k, v)

        if additional_columns == "":
            query = ('CREATE COLUMNFAMILY %s (key %s, c varchar, v varchar, '
                     'PRIMARY KEY(key, c)) WITH comment=\'test cf\'' %
                     (name, key_type))
        else:
            query = ('CREATE COLUMNFAMILY %s (key %s PRIMARY KEY%s) '
                     'WITH comment=\'test cf\'' %
                     (name, key_type, additional_columns))

        if compression is not None:
            query = ('%s AND compression = { \'sstable_compression\': '
                     '\'%sCompressor\' }' % (query, compression))
        else:
            # if a compression option is omitted, C*
            # will default to lz4 compression
            query += ' AND compression = {}'

        if read_repair is not None:
            query = '%s AND read_repair_chance=%f' % (query, read_repair)
        if gc_grace is not None:
            query = '%s AND gc_grace_seconds=%d' % (query, gc_grace)
        if speculative_retry is not None:
            query = ('%s AND speculative_retry=\'%s\'' %
                     (query, speculative_retry))

        if compact_storage:
            query += ' AND COMPACT STORAGE'

        session.execute(query)
        time.sleep(0.2)
コード例 #3
0
 def create_ks(self, session, name, rf):
     query = 'CREATE KEYSPACE %s WITH replication={%s}'
     if isinstance(rf, types.IntType):
         # we assume simpleStrategy
         session.execute(query % (name, "'class':'SimpleStrategy', "
                                  "'replication_factor':%d" % rf))
     else:
         assert len(rf) != 0, "At least one datacenter/rf pair is needed"
         # we assume networkTopologyStrategy
         options = ', '.join(
             ['\'%s\':%d' % (d, r) for d, r in rf.iteritems()])
         session.execute(
             query %
             (name, "'class':'NetworkTopologyStrategy', %s" % options))
     session.execute('USE %s' % name)
コード例 #4
0
ファイル: tester.py プロジェクト: slivne/scylla-cluster-tests
 def create_ks(self, session, name, rf):
     query = 'CREATE KEYSPACE %s WITH replication={%s}'
     if isinstance(rf, types.IntType):
         # we assume simpleStrategy
         session.execute(query % (name,
                                  "'class':'SimpleStrategy', "
                                  "'replication_factor':%d" % rf))
     else:
         assert len(rf) != 0, "At least one datacenter/rf pair is needed"
         # we assume networkTopologyStrategy
         options = ', '.join(['\'%s\':%d' % (d, r) for
                              d, r in rf.iteritems()])
         session.execute(query % (name,
                                  "'class':'NetworkTopologyStrategy', %s" %
                                  options))
     session.execute('USE %s' % name)