changed slicewidth

This commit is contained in:
Todd Gruben 2016-05-13 19:59:14 -05:00
parent d14c4b971d
commit d0abcfc910
3 changed files with 25 additions and 16 deletions

View file

@ -175,12 +175,29 @@ func (c *Client) Import(db, frame string, slice uint64, bits []Bit) error {
return ErrFrameRequired
}
buf, err := ImportPayload(db, frame, slice, bits)
if err != nil {
return fmt.Errorf("Error Creating Payload: %s", err)
}
// Retrieve a list of nodes that own the slice.
nodes, err := c.SliceNodes(slice)
if err != nil {
return fmt.Errorf("slice nodes: %s", err)
}
// Import to each node.
for _, node := range nodes {
if err := c.importNode(node, buf); err != nil {
return fmt.Errorf("import node: host=%s, err=%s", node.Host, err)
}
}
return nil
}
func ImportPayload(db, frame string, slice uint64, bits []Bit) ([]byte, error) {
// Separate bitmap and profile IDs to reduce allocations.
bitmapIDs := Bits(bits).BitmapIDs()
profileIDs := Bits(bits).ProfileIDs()
@ -194,17 +211,9 @@ func (c *Client) Import(db, frame string, slice uint64, bits []Bit) error {
ProfileIDs: profileIDs,
})
if err != nil {
return fmt.Errorf("marshal import request: %s", err)
return nil, fmt.Errorf("marshal import request: %s", err)
}
// Import to each node.
for _, node := range nodes {
if err := c.importNode(node, buf); err != nil {
return fmt.Errorf("import node: host=%s, err=%s", node.Host, err)
}
}
return nil
return buf, nil
}
// importNode sends a pre-marshaled import request to a node.

View file

@ -13,7 +13,6 @@ import (
"net/url"
"os"
"os/signal"
"os/user"
"path/filepath"
"runtime/pprof"
"strconv"
@ -371,13 +370,14 @@ func (m *Main) ParseFlags(args []string) error {
// Expand home directory.
prefix := "~" + string(filepath.Separator)
if strings.HasPrefix(m.Config.DataDir, prefix) {
u, err := user.Current()
if err != nil {
// u, err := user.Current()
HomeDir := os.Getenv("HOME")
/*if err != nil {
return err
} else if u.HomeDir == "" {
} else*/if HomeDir == "" {
return errors.New("data directory not specified and no home dir available")
}
m.Config.DataDir = filepath.Join(u.HomeDir, strings.TrimPrefix(m.Config.DataDir, prefix))
m.Config.DataDir = filepath.Join(HomeDir, strings.TrimPrefix(m.Config.DataDir, prefix))
}
return nil

View file

@ -25,7 +25,7 @@ import (
const (
// SliceWidth is the number of profile IDs in a slice.
SliceWidth = 65536
SliceWidth = 2097152
// SnapshotExt is the file extension used for an in-process snapshot.
SnapshotExt = ".snapshotting"