~unity-2d-team/unity-2d/Shell-MultiMonitor

« back to all changes in this revision

Viewing changes to grackle/model.py

  • Committer: William Grant
  • Date: 2012-01-24 08:47:51 UTC
  • Revision ID: william.grant@canonical.com-20120124084751-rw55g7rvq4bnmi8m
Use a ConnectionPool. pycassa.connect is gone in 1.4.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import logging
24
24
import uuid
25
25
 
26
 
import pycassa
 
26
import pycassa.pool
27
27
from pycassa.system_manager import (
28
28
    LEXICAL_UUID_TYPE,
29
29
    SystemManager,
145
145
 
146
146
class CassandraConnection(object):
147
147
 
148
 
    def __init__(self, keyspace, host):
 
148
    def __init__(self, keyspace, hosts):
149
149
        self._keyspace = keyspace
150
 
        self._host = host
 
150
        self._hosts = hosts
151
151
        self._connection = self._connect()
 
152
        self._pool = self._connect()
152
153
        self.messages = self._column_family('message')
153
154
        self.archive_messages = self._column_family('archive_message')
154
155
 
155
156
    def _connect(self):
156
 
        return pycassa.connect(self._keyspace, self._host)
 
157
        return pycassa.pool.ConnectionPool(self._keyspace, self._hosts)
157
158
 
158
159
    def _column_family(self, name):
159
 
        return pycassa.ColumnFamily(self._connection, name)
 
160
        return pycassa.ColumnFamily(self._pool, name)
160
161
 
161
162
    def add_message(self, archive_uuid, message):
162
163
        message_uuid = uuid.uuid4()