quick cassandra test

This commit is contained in:
Todd Gruben 2014-01-21 16:00:13 -06:00
parent cd7c30177c
commit 9c853959dc
3 changed files with 33 additions and 16 deletions

View file

@ -45,7 +45,7 @@ func NewService() *Service {
service.WebService = NewWebService(service)
service.Index = index.NewFragmentContainer()
service.Hold = hold.NewHolder()
service.version = "0.0.6"
service.version = "0.0.7"
return service
}

View file

@ -168,17 +168,33 @@ type Fragment struct {
}
func getStorage(db string, slice int, frame string) Storage {
choice := 1
switch choice {
case 1:
return NewMemoryStorage()
case 2:
s, _ := NewKVStorage("/tmp/pilosa/", slice, db)
return s
case 3:
return NewCassStorage()
}
return nil
return NewCassStorage("10.87.110.249", "hotbox")
/*
storage_method := config.GetInt("storage")
switch storage_method {
default:
return NewMemoryStorage()
case 1:
storage_path := config.GetString("kv_base_path")
if storage_path == "" {
storage_path = "/tmp/pilosa"
}
s, _ := NewKVStorage(storage_path, slice, db)
return s
case 2:
host := config.GetString("cass_host")
if host == "" {
host = "localhost"
}
keyspace := config.GetString("cass_keyspace")
if keyspace == "" {
keyspace = "hotbox"
}
return NewCassStorage(host, keyspace)
}
return nil
*/
}
func NewFragment(frag_id SUUID, db string, slice int, frame string) *Fragment {

View file

@ -3,6 +3,7 @@ package index
// #cgo CFLAGS:-mpopcnt
import (
"fmt"
"log"
"tux21b.org/v1/gocql"
@ -20,11 +21,11 @@ func BuildSchema() {
*/
}
func NewCassStorage() Storage {
func NewCassStorage(host, keyspace string) Storage {
obj := new(CassandraStorage)
//cluster := gocql.NewCluster("127.0.0.1")
cluster := gocql.NewCluster("10.87.110.249")
cluster.Keyspace = "hotbox"
cluster := gocql.NewCluster(host)
cluster.Keyspace = keyspace
cluster.Consistency = gocql.Quorum
//cluster.ProtoVersion = 1
// cluster.CQLVersion = "3.0.0"
@ -33,7 +34,7 @@ func NewCassStorage() Storage {
log.Fatal(err)
}
err = session.Query("USE hotbox").Exec()
err = session.Query(fmt.Sprintf("USE %s", keyspace)).Exec()
if err != nil {
}
obj.db = session