adusted cas batch; removed panics

This commit is contained in:
Todd Gruben 2014-06-24 07:55:43 -05:00
parent 515f6ce181
commit 6b8428f64c
5 changed files with 27 additions and 20 deletions

View file

@ -105,15 +105,13 @@ func getLightestProcess(m map[string]int) (Pair, error) {
}
func (self *TopologyMapper) MakeFragments(db string, slice_int int) error {
/*
frames_to_create := config.GetStringArrayDefault("supported_frames", []string{"b.n", "l.n", "t.t", "d"})
for _, frame := range frames_to_create {
err := self.AllocateFragment(db, frame, slice_int)
if err != nil {
log.Println(err)
}
frames_to_create := config.GetStringArrayDefault("supported_frames", []string{"b.n", "l.n", "t.t", "d"})
for _, frame := range frames_to_create {
err := self.AllocateFragment(db, frame, slice_int)
if err != nil {
log.Println(err)
}
*/
}
return nil
}

View file

@ -437,7 +437,7 @@ func (self *WebService) HandleStats(w http.ResponseWriter, r *http.Request) {
err := encoder.Encode(m)
if err != nil {
panic("Error encoding stats")
log.Fatal("Error encoding stats")
}
}
@ -483,7 +483,7 @@ func (self *WebService) HandleProcesses(w http.ResponseWriter, r *http.Request)
processes := self.service.ProcessMap.GetMetadata()
err := encoder.Encode(processes)
if err != nil {
panic("Error encoding stats")
http.Error(w, "Error Encoding", http.StatusBadRequest)
}
}

View file

@ -123,12 +123,15 @@ func (self *CassandraStorage) FlushBatch() {
func (self *CassandraStorage) EndBatch() {
start := time.Now()
if self.batch != nil {
last := time.Since(self.batch_time)
if last.Seconds() > self.cass_time_window_secs {
self.FlushBatch()
} else if self.batch_counter > self.cass_flush_size {
self.FlushBatch()
}
self.FlushBatch()
/*
last := time.Since(self.batch_time)
if last.Seconds() > self.cass_time_window_secs {
self.FlushBatch()
} else if self.batch_counter > self.cass_flush_size {
self.FlushBatch()
}
*/
} else {
log.Println("NIL BATCH")
}
@ -161,7 +164,7 @@ func (self *CassandraStorage) Store(id int64, db string, frame string, slice int
func (self *CassandraStorage) StoreBlock(id int64, db string, frame string, slice int, filter uint64, chunk int64, block_index int32, block int64) error {
if self.batch == nil {
panic("NIL BATCH")
self.BeginBatch()
}
start := time.Now()
self.batch.Query(self.stmt, id, db, frame, slice, int(filter), chunk, block_index, block)

View file

@ -3,6 +3,7 @@ package query
import (
"errors"
"fmt"
"log"
"pilosa/util"
"strconv"
@ -199,8 +200,9 @@ ArgLoop:
}
}
default:
spew.Dump("unexpected", token)
panic(token)
log.Println(spew.Sdump("unexpected", token))
return nil, errors.New("BAD TOKEN")
}
}

View file

@ -2,11 +2,14 @@ package query
import (
"encoding/gob"
"errors"
"fmt"
"log"
"math/rand"
"pilosa/db"
"pilosa/util"
"github.com/davecgh/go-spew/spew"
)
type PortableQueryStep interface {
@ -390,7 +393,8 @@ func (qp *QueryPlanner) buildTree(query *Query, slice int) (QueryTree, error) {
tree = &IntersectQueryTree{subqueries: subqueries}
} else {
//TODO return error gracefully
panic("invalid operation")
log.Println(spew.Sdump(query))
return nil, errors.New("BuildTree Issues")
}
}
return tree, nil