diff --git a/.gitignore b/.gitignore index 5fe629f6a..86fa71248 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ default.etcd/ *.test vendor .protoc-gen-gofast + +/datadog/.DS_Store diff --git a/cluster.go b/cluster.go index ac5b2ec6f..4c6dc2b82 100644 --- a/cluster.go +++ b/cluster.go @@ -3,7 +3,6 @@ package pilosa import ( "encoding/binary" "hash/fnv" - "sync" "github.com/pilosa/pilosa/internal" ) diff --git a/cmd/server.go b/cmd/server.go index 4e5d96114..f18ee4e69 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -87,7 +87,7 @@ on the configured port.`, flags.StringVarP(&Server.Config.Cluster.Type, "cluster.type", "", "static", "Determine how the cluster handles membership and state sharing. Choose from [static, http, gossip]") flags.StringVarP(&Server.Config.Cluster.GossipSeed, "cluster.gossip-seed", "", "", "Host with which to seed the gossip membership.") flags.StringVarP(&Server.Config.Cluster.InternalPort, "cluster.internal-port", "", "", "Port to which pilosa should bind for internal state sharing.") - flags.StringVarP(&Server.Config.Metric.Service, "metric.service", "", "noop", "Default URI on which pilosa should listen.") + flags.StringVarP(&Server.Config.Metric.Service, "metric.service", "", "nop", "Default URI on which pilosa should listen.") flags.StringVarP(&Server.Config.Metric.Host, "metric.host", "", "", "Default URI to send metrics.") flags.DurationVarP((*time.Duration)(&Server.Config.Metric.PollingInterval), "metric.poll-interval", "", time.Minute*0, "Polling interval metrics.") return serveCmd diff --git a/config.go b/config.go index a0b51a503..646c77773 100644 --- a/config.go +++ b/config.go @@ -8,7 +8,7 @@ const ( DefaultPort = "10101" DefaultClusterType = "static" DefaultInternalPort = "14000" - DefaultMetrics = "noop" + DefaultMetrics = "nop" ) // Config represents the configuration for the command. diff --git a/executor.go b/executor.go index e467385b0..e828100b8 100644 --- a/executor.go +++ b/executor.go @@ -920,7 +920,7 @@ func (e *Executor) executeSetColumnAttrs(ctx context.Context, index string, c *p if err := idx.ColumnAttrStore().SetAttrs(id, attrs); err != nil { return err } - d.Stats.Count("SetProfileAttrs", 1) + idx.Stats.Count("SetProfileAttrs", 1) // Do not forward call if this is already being forwarded. if opt.Remote { return nil diff --git a/holder.go b/holder.go index 426817410..ad329522f 100644 --- a/holder.go +++ b/holder.go @@ -245,7 +245,7 @@ func (h *Holder) newIndex(path, name string) (*Index, error) { return nil, err } index.LogOutput = h.LogOutput - index.stats = h.Stats.WithTags(fmt.Sprintf("index:%s", index.Name())) + index.Stats = h.Stats.WithTags(fmt.Sprintf("index:%s", index.Name())) index.broadcaster = h.Broadcaster return index, nil } diff --git a/index.go b/index.go index 3fa8ac028..10790a079 100644 --- a/index.go +++ b/index.go @@ -44,7 +44,7 @@ type Index struct { columnAttrStore *AttrStore broadcaster Broadcaster - stats StatsClient + Stats StatsClient LogOutput io.Writer } @@ -68,7 +68,7 @@ func NewIndex(path, name string) (*Index, error) { columnLabel: DefaultColumnLabel, - stats: NopStatsClient, + Stats: NopStatsClient, LogOutput: ioutil.Discard, }, nil } @@ -165,7 +165,7 @@ func (i *Index) openFrames() error { } i.frames[fr.Name()] = fr - i.stats.Count("frameN", 1) + i.Stats.Count("frameN", 1) } return nil } @@ -405,7 +405,7 @@ func (i *Index) createFrame(name string, opt FrameOptions) (*Frame, error) { // Add to index's frame lookup. i.frames[name] = f - i.stats.Count("frameN", 1) + i.Stats.Count("frameN", 1) return f, nil } @@ -416,7 +416,7 @@ func (i *Index) newFrame(path, name string) (*Frame, error) { return nil, err } f.LogOutput = i.LogOutput - f.stats = i.stats.WithTags(fmt.Sprintf("frame:%s", name)) + f.Stats = i.Stats.WithTags(fmt.Sprintf("frame:%s", name)) f.broadcaster = i.broadcaster return f, nil } @@ -445,7 +445,7 @@ func (i *Index) DeleteFrame(name string) error { // Remove reference. delete(i.frames, name) - i.stats.Count("frameN", -1) + i.Stats.Count("frameN", -1) return nil } diff --git a/server.go b/server.go index 6c45dccd5..1180ba98a 100644 --- a/server.go +++ b/server.go @@ -282,18 +282,13 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { // In a gossip implementation, memberlist.Delegate.LocalState() uses this. func (s *Server) LocalStatus() (proto.Message, error) { if s.Holder == nil { - return nil, errors.New("Server.Holder is nil.") + return nil, errors.New("Server.Holder is nil") } return &internal.NodeStatus{ Host: s.Host, State: NodeStateUp, Indexes: encodeIndexes(s.Holder.Indexes()), - - ns := internal.NodeState{ - } - - s.Cluster.SetNodeState(&ns) - return &ns, nil + }, nil } // ClusterStatus returns the NodeState for all nodes in the cluster. diff --git a/stats_test.go b/stats_test.go index cf06f2f06..3875b6a0f 100644 --- a/stats_test.go +++ b/stats_test.go @@ -2,30 +2,31 @@ package pilosa_test import ( "context" - "github.com/pilosa/pilosa" "testing" "time" + + "github.com/pilosa/pilosa" ) func TestStatsCount_TopN(t *testing.T) { - idx := MustOpenIndex() - defer idx.Close() + hldr := MustOpenHolder() + defer hldr.Close() - idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 0) - idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 1) - idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth) - idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth+2) + hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 0) + hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 1) + hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth) + hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth+2) // Execute query. called := false - e := NewExecutor(idx.Index, NewCluster(1)) - e.Index.Stats = &MockStats{ + e := NewExecutor(hldr.Holder, NewCluster(1)) + e.Holder.Stats = &MockStats{ mockCountWithTags: func(name string, value int64, tags []string) { if name != "TopN" { t.Errorf("Expected TopN, Results %s", name) } - if tags[0] != "db:d" { + if tags[0] != "index:d" { t.Errorf("Expected db, Results %s", tags[0]) } @@ -42,20 +43,20 @@ func TestStatsCount_TopN(t *testing.T) { } func TestStatsCount_Bitmap(t *testing.T) { - idx := MustOpenIndex() - defer idx.Close() + hldr := MustOpenHolder() + defer hldr.Close() - idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 0) - idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 1) + hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 0) + hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 1) called := false - e := NewExecutor(idx.Index, NewCluster(1)) - e.Index.Stats = &MockStats{ + e := NewExecutor(hldr.Holder, NewCluster(1)) + e.Holder.Stats = &MockStats{ mockCountWithTags: func(name string, value int64, tags []string) { if name != "Bitmap" { t.Errorf("Expected Bitmap, Results %s", name) } - if tags[0] != "db:d" { + if tags[0] != "index:d" { t.Errorf("Expected db, Results %s", tags[0]) } @@ -72,15 +73,15 @@ func TestStatsCount_Bitmap(t *testing.T) { } func TestStatsCount_SetBitmapAttrs(t *testing.T) { - idx := MustOpenIndex() - defer idx.Close() + hldr := MustOpenHolder() + defer hldr.Close() - idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0) - idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1) + hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0) + hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1) called := false - e := NewExecutor(idx.Index, NewCluster(1)) - frame := e.Index.Frame("d", "f") + e := NewExecutor(hldr.Holder, NewCluster(1)) + frame := e.Holder.Frame("d", "f") if frame == nil { t.Fatal("frame not found") } @@ -94,7 +95,7 @@ func TestStatsCount_SetBitmapAttrs(t *testing.T) { return }, } - if _, err := e.Execute(context.Background(), "d", MustParse(`SetBitmapAttrs(id=10, frame=f, foo="bar")`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "d", MustParse(`SetRowAttrs(id=10, frame=f, foo="bar")`), nil, nil); err != nil { t.Fatal(err) } if !called { @@ -103,20 +104,20 @@ func TestStatsCount_SetBitmapAttrs(t *testing.T) { } func TestStatsCount_SetProfileAttrs(t *testing.T) { - idx := MustOpenIndex() - defer idx.Close() + hldr := MustOpenHolder() + defer hldr.Close() - idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0) - idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1) + hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0) + hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1) called := false - e := NewExecutor(idx.Index, NewCluster(1)) - db := e.Index.DB("d") - if db == nil { - t.Fatal("db not found") + e := NewExecutor(hldr.Holder, NewCluster(1)) + idx := e.Holder.Index("d") + if idx == nil { + t.Fatal("idex not found") } - db.Stats = &MockStats{ + idx.Stats = &MockStats{ mockCount: func(name string, value int64) { if name != "SetProfileAttrs" { t.Errorf("Expected SetProfilepAttrs, Results %s", name) @@ -126,7 +127,7 @@ func TestStatsCount_SetProfileAttrs(t *testing.T) { return }, } - if _, err := e.Execute(context.Background(), "d", MustParse(`SetProfileAttrs(id=10, frame=f, foo="bar")`), nil, nil); err != nil { + if _, err := e.Execute(context.Background(), "d", MustParse(`SetColumnAttrs(id=10, frame=f, foo="bar")`), nil, nil); err != nil { t.Fatal(err) } if !called {