Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 162 lines (114 sloc) 4.867 kB
4442b63 @ericflo Added a first draft readme file.
ericflo authored
1 # Twissandra
2
3 Twissandra is an example project, created to learn and demonstrate how to use
4 Cassandra. Running the project will present a website that has similar
5 functionality to Twitter.
6
5796eb4 @ericflo Add a note about the running copy
ericflo authored
7 You can see a running copy at [http://twissandra.com/](http://twissandra.com/)
8
3c1342d @ericflo Add a shout out to cass.py
ericflo authored
9 Most of the magic happens in twissandra/cass.py, so check that out.
78a13b0 @ericflo Add a shout out to cass.py
ericflo authored
10
4442b63 @ericflo Added a first draft readme file.
ericflo authored
11 ## Installation
12
13 Installing Twissandra is fairly straightforward. Really it just involves
14 checking out Cassandra and Twissandra, doing a little configuration, and
15 then starting it up. Here's a roadmap of the steps we're going to take to
16 install the project:
17
18 1. Check out the latest Cassandra source code
0183102 Better README.
Jon Hermes authored
19 2. Check out the Twissandra source code
20 3. Install and configure Cassandra
21 4. Install Thrift
22 5. Create a virtual Python environment with Twissandra's dependencies
23 6. Start up the webserver
4442b63 @ericflo Added a first draft readme file.
ericflo authored
24
25 ### Check out the latest Cassandra source code
26
818cead @ericflo Update the README to guide the users through the steps for developmen…
ericflo authored
27 git clone git://git.apache.org/cassandra.git
4442b63 @ericflo Added a first draft readme file.
ericflo authored
28
29 ### Check out the Twissandra source code
30
aba8945 @thobbs Update twissandra repo URL in README
thobbs authored
31 git clone git://github.com/twissandra/twissandra.git
4442b63 @ericflo Added a first draft readme file.
ericflo authored
32
33 ### Install and configure Cassandra
34
818cead @ericflo Update the README to guide the users through the steps for developmen…
ericflo authored
35 Now build Cassandra:
4442b63 @ericflo Added a first draft readme file.
ericflo authored
36
818cead @ericflo Update the README to guide the users through the steps for developmen…
ericflo authored
37 cd cassandra
38 ant
4442b63 @ericflo Added a first draft readme file.
ericflo authored
39
40 Then we need to create our database directories on disk:
41
42 sudo mkdir -p /var/log/cassandra
43 sudo chown -R `whoami` /var/log/cassandra
44 sudo mkdir -p /var/lib/cassandra
45 sudo chown -R `whoami` /var/lib/cassandra
46
47 Finally we can start Cassandra:
48
02f7c3e @ericflo Fix cassandra command
ericflo authored
49 ./bin/cassandra -f
4442b63 @ericflo Added a first draft readme file.
ericflo authored
50
62e5ab7 @ericflo Some tweaks to the readme
ericflo authored
51 ### Install Thrift
52
53 Follow the instructions [provided on the Thrift website itself](http://wiki.apache.org/thrift/ThriftInstallation)
54
4442b63 @ericflo Added a first draft readme file.
ericflo authored
55 ### Create a virtual Python environment with Twissandra's dependencies
56
62e5ab7 @ericflo Some tweaks to the readme
ericflo authored
57 First, make sure to have virtualenv installed. If it isn't installed already,
58 this should do the trick:
4442b63 @ericflo Added a first draft readme file.
ericflo authored
59
60 sudo easy_install -U virtualenv
61
62 Now let's create a new virtual environment, and begin using it:
63
64 virtualenv twiss
65 source twiss/bin/activate
66
67 We should install pip, so that we can more easily install Twissandra's
68 dependencies into our new virtual environment:
69
70 easy_install -U pip
71
72 Now let's install all of the dependencies:
73
74 pip install -U -r twissandra/requirements.txt
75
76 Now that we've got all of our dependencies installed, we're ready to start up
77 the server.
78
f0cfec3 @ericflo Scrap the old cassandra.yaml file in favor of a management command to…
ericflo authored
79 ### Create the schema
4442b63 @ericflo Added a first draft readme file.
ericflo authored
80
f0cfec3 @ericflo Scrap the old cassandra.yaml file in favor of a management command to…
ericflo authored
81 Make sure you're in the Twissandra checkout, and then run the sync_cassandra
82 command to create the proper keyspace in Cassandra:
4442b63 @ericflo Added a first draft readme file.
ericflo authored
83
84 cd twissandra
f0cfec3 @ericflo Scrap the old cassandra.yaml file in favor of a management command to…
ericflo authored
85 python manage.py sync_cassandra
86
87 ### Start up the webserver
88
89 This is the fun part! We're done setting everything up, we just need to run it:
90
4442b63 @ericflo Added a first draft readme file.
ericflo authored
91 python manage.py runserver
92
01f41f4 @ericflo Added some more documentation
ericflo authored
93 Now go to http://127.0.0.1:8000/ and you can play with Twissandra!
94
95 ## Schema Layout
96
97 In Cassandra, the way that your data is structured is very closely tied to how
98 how it will be retrieved. Let's start with the user ColumnFamily. The key is
0183102 Better README.
Jon Hermes authored
99 a username, and the columns are the properties on the user:
01f41f4 @ericflo Added some more documentation
ericflo authored
100
101 User = {
0183102 Better README.
Jon Hermes authored
102 'hermes': {
01f41f4 @ericflo Added some more documentation
ericflo authored
103 'password': '****',
0183102 Better README.
Jon Hermes authored
104 (other properties),
01f41f4 @ericflo Added some more documentation
ericflo authored
105 },
106 }
107
0183102 Better README.
Jon Hermes authored
108 Friends and followers are keyed by the username, and then the columns are the
109 friend names and follower names, and we store a timestamp as the value because
110 it's interesting information to have:
01f41f4 @ericflo Added some more documentation
ericflo authored
111
112 Friends = {
0183102 Better README.
Jon Hermes authored
113 'hermes': {
01f41f4 @ericflo Added some more documentation
ericflo authored
114 # friend id: timestamp of when the friendship was added
0183102 Better README.
Jon Hermes authored
115 'larry': '1267413962580791',
116 'curly': '1267413990076949',
117 'moe' : '1267414008133277',
01f41f4 @ericflo Added some more documentation
ericflo authored
118 },
119 }
120
121 Followers = {
0183102 Better README.
Jon Hermes authored
122 'hermes': {
01f41f4 @ericflo Added some more documentation
ericflo authored
123 # friend id: timestamp of when the followership was added
0183102 Better README.
Jon Hermes authored
124 'larry': '1267413962580791',
125 'curly': '1267413990076949',
126 'moe' : '1267414008133277',
01f41f4 @ericflo Added some more documentation
ericflo authored
127 },
128 }
129
0183102 Better README.
Jon Hermes authored
130 Tweets are stored with a tweet id for the key.
01f41f4 @ericflo Added some more documentation
ericflo authored
131
132 Tweet = {
133 '7561a442-24e2-11df-8924-001ff3591711': {
cf58e6e @ericflo s/uname/username/ because I'm OCD
ericflo authored
134 'username': 'hermes',
01f41f4 @ericflo Added some more documentation
ericflo authored
135 'body': 'Trying out Twissandra. This is awesome!',
136 },
137 }
138
139 The Timeline and Userline column families keep track of which tweets should
0183102 Better README.
Jon Hermes authored
140 appear, and in what order. To that effect, the key is the username, the column
01f41f4 @ericflo Added some more documentation
ericflo authored
141 name is a timestamp, and the column value is the tweet id:
142
143 Timeline = {
0183102 Better README.
Jon Hermes authored
144 'hermes': {
01f41f4 @ericflo Added some more documentation
ericflo authored
145 # timestamp of tweet: tweet id
146 1267414247561777: '7561a442-24e2-11df-8924-001ff3591711',
147 1267414277402340: 'f0c8d718-24e2-11df-8924-001ff3591711',
148 1267414305866969: 'f9e6d804-24e2-11df-8924-001ff3591711',
149 1267414319522925: '02ccb5ec-24e3-11df-8924-001ff3591711',
4b1e51a @ericflo Tweaks to readme.
ericflo authored
150 },
01f41f4 @ericflo Added some more documentation
ericflo authored
151 }
152
153 Userline = {
0183102 Better README.
Jon Hermes authored
154 'hermes': {
01f41f4 @ericflo Added some more documentation
ericflo authored
155 # timestamp of tweet: tweet id
156 1267414247561777: '7561a442-24e2-11df-8924-001ff3591711',
157 1267414277402340: 'f0c8d718-24e2-11df-8924-001ff3591711',
158 1267414305866969: 'f9e6d804-24e2-11df-8924-001ff3591711',
159 1267414319522925: '02ccb5ec-24e3-11df-8924-001ff3591711',
4b1e51a @ericflo Tweaks to readme.
ericflo authored
160 },
5796eb4 @ericflo Add a note about the running copy
ericflo authored
161 }
Something went wrong with that request. Please try again.