Exemplo n.º 1
0
class Meetup(tdb_cassandra.Thing):
    _use_db = True
    _timestamp_prop = None
    _defaults = {
        # one of:
        # - "prep": finding meetups and printing badges
        # - "active": badges and connections
        # - "after": just connections
        # - "closed": all done
        "state": "prep",
    }
    _extra_schema_creation_args = dict(
        key_validation_class=types.AsciiType(),
        default_validation_class=types.UTF8Type(),
        column_validation_classes={
            "date": types.DateType(),
        },
    )
    _read_consistency_level = tdb_cassandra.CL.ONE
    _write_consistency_level = tdb_cassandra.CL.ALL
    _date_props = ("date", )

    @classmethod
    def _new(cls, codename, title, meetup_date):
        meetup = cls(
            _id=codename,
            title=title,
            date=meetup_date,
            body="",
        )
        meetup._commit()
        return meetup
Exemplo n.º 2
0
class TestUTF8(object):
    key = types.LexicalUUIDType()
    strcol = types.AsciiType(default='default')
    intcol = types.LongType(default=0)
    floatcol = types.FloatType(default=0.0)
    datetimecol = types.DateType()

    def __str__(self):
        return str(map(str, [self.strcol, self.intcol, self.floatcol, self.datetimecol]))

    def __eq__(self, other):
        return self.__dict__ == other.__dict__

    def __ne__(self, other):
        return self.__dict__ != other.__dict__
Exemplo n.º 3
0
class MeetupConnectionsByAccount(tdb_cassandra.View):
    _use_db = True
    _value_type = "str"
    _read_consistency_level = tdb_cassandra.CL.QUORUM
    _write_consistency_level = tdb_cassandra.CL.QUORUM
    _extra_schema_creation_args = dict(
        key_validation_class=types.AsciiType(),
        default_validation_class=types.AsciiType(),
    )

    @staticmethod
    def _rowkey(meetup, user):
        return ":".join((meetup._id, user._id36))

    @classmethod
    def _connect(cls, meetup, user, other):
        rowkey = cls._rowkey(meetup, user)
        cls._set_values(rowkey, {other._id36: ""})

    @classmethod
    def _connections(cls, meetup, user):
        rowkey = cls._rowkey(meetup, user)
        connections = cls.get_time_sorted_columns(rowkey).keys()
        return Account._byID36(connections, return_dict=False, data=True)
Exemplo n.º 4
0
class MeetupConnections(tdb_cassandra.View):
    _use_db = True
    _value_type = "date"
    _read_consistency_level = tdb_cassandra.CL.QUORUM
    _write_consistency_level = tdb_cassandra.CL.QUORUM
    _extra_schema_creation_args = dict(
        key_validation_class=types.AsciiType(),
        default_validation_class=types.DateType(),
    )

    @classmethod
    def _connect(cls, meetup, user, other):
        now = datetime.datetime.now(g.tz)
        values = {":".join((user._id36, other._id36)): now}
        cls._set_values(meetup._id, values)
Exemplo n.º 5
0
NETWORK_TOPOLOGY_STRATEGY = 'NetworkTopologyStrategy'
""" Replication strategy that puts a number of replicas in each datacenter """

OLD_NETWORK_TOPOLOGY_STRATEGY = 'OldNetworkTopologyStrategy'
"""
Original replication strategy for putting a number of replicas in each datacenter.
This was originally called 'RackAwareStrategy'.
"""

KEYS_INDEX = IndexType.KEYS
""" A secondary index type where each indexed value receives its own row """

BYTES_TYPE = types.BytesType()
LONG_TYPE = types.LongType()
INT_TYPE = types.IntegerType()
ASCII_TYPE = types.AsciiType()
UTF8_TYPE = types.UTF8Type()
TIME_UUID_TYPE = types.TimeUUIDType()
LEXICAL_UUID_TYPE = types.LexicalUUIDType()
COUNTER_COLUMN_TYPE = types.CounterColumnType()
DOUBLE_TYPE = types.DoubleType()
FLOAT_TYPE = types.FloatType()
DECIMAL_TYPE = types.DecimalType()
BOOLEAN_TYPE = types.BooleanType()
DATE_TYPE = types.DateType()

class SystemManager(object):
    """
    Lets you examine and modify schema definitions as well as get basic
    information about the cluster.