id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
139,400
control-center/serviced
dfs/backup.go
snapshotSavePipe
func (dfs *DistributedFilesystem) snapshotSavePipe(vol volume.Volume, label string, excludes []string) (*io.PipeReader, <-chan error) { return savePipe(func(w io.Writer) error { return vol.Export(label, "", w, excludes) }) }
go
func (dfs *DistributedFilesystem) snapshotSavePipe(vol volume.Volume, label string, excludes []string) (*io.PipeReader, <-chan error) { return savePipe(func(w io.Writer) error { return vol.Export(label, "", w, excludes) }) }
[ "func", "(", "dfs", "*", "DistributedFilesystem", ")", "snapshotSavePipe", "(", "vol", "volume", ".", "Volume", ",", "label", "string", ",", "excludes", "[", "]", "string", ")", "(", "*", "io", ".", "PipeReader", ",", "<-", "chan", "error", ")", "{", "...
// snapshotSavePipe returns a pipe that exports a given volume to the pipe's stdout
[ "snapshotSavePipe", "returns", "a", "pipe", "that", "exports", "a", "given", "volume", "to", "the", "pipe", "s", "stdout" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/backup.go#L197-L201
139,401
control-center/serviced
dfs/backup.go
rewriteTar
func rewriteTar(prefix string, tarWriter *tar.Writer, r *io.PipeReader) error { defer r.Close() tarReader := tar.NewReader(r) for { header, err := tarReader.Next() if err == io.EOF { break } else if err != nil { return err } // Rewrite the header to include the prefix header.Name = filepath.Join(...
go
func rewriteTar(prefix string, tarWriter *tar.Writer, r *io.PipeReader) error { defer r.Close() tarReader := tar.NewReader(r) for { header, err := tarReader.Next() if err == io.EOF { break } else if err != nil { return err } // Rewrite the header to include the prefix header.Name = filepath.Join(...
[ "func", "rewriteTar", "(", "prefix", "string", ",", "tarWriter", "*", "tar", ".", "Writer", ",", "r", "*", "io", ".", "PipeReader", ")", "error", "{", "defer", "r", ".", "Close", "(", ")", "\n", "tarReader", ":=", "tar", ".", "NewReader", "(", "r", ...
// rewriteTar interprets an pipe reader as a tar reader and rewrites the // headers so they can get written to the outfile.
[ "rewriteTar", "interprets", "an", "pipe", "reader", "as", "a", "tar", "reader", "and", "rewrites", "the", "headers", "so", "they", "can", "get", "written", "to", "the", "outfile", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/backup.go#L205-L228
139,402
control-center/serviced
dfs/backup.go
writeBackupMetadata
func (dfs *DistributedFilesystem) writeBackupMetadata(data BackupInfo, w *tar.Writer) error { var ( jsonData []byte err error ) backupLogger := plog.WithFields(log.Fields{ "backupversion": data.BackupVersion, "timestamp": data.Timestamp, }) backupLogger.Debug("Writing backup metadata") if jsonD...
go
func (dfs *DistributedFilesystem) writeBackupMetadata(data BackupInfo, w *tar.Writer) error { var ( jsonData []byte err error ) backupLogger := plog.WithFields(log.Fields{ "backupversion": data.BackupVersion, "timestamp": data.Timestamp, }) backupLogger.Debug("Writing backup metadata") if jsonD...
[ "func", "(", "dfs", "*", "DistributedFilesystem", ")", "writeBackupMetadata", "(", "data", "BackupInfo", ",", "w", "*", "tar", ".", "Writer", ")", "error", "{", "var", "(", "jsonData", "[", "]", "byte", "\n", "err", "error", "\n", ")", "\n\n", "backupLog...
// writeBackupMetadata writes out a tar stream containing a file containing the // JSON-serialized backup metdata passed in
[ "writeBackupMetadata", "writes", "out", "a", "tar", "stream", "containing", "a", "file", "containing", "the", "JSON", "-", "serialized", "backup", "metdata", "passed", "in" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/backup.go#L232-L257
139,403
control-center/serviced
rpc/rpcutils/client.go
newClient
func newClient(addr string, max int, discardClientTimeout time.Duration, fn connectRPCFn) (Client, error) { rpcClientFactory := func() (interface{}, error) { return fn(addr) } rpcPool, err := pool.NewPool(max, rpcClientFactory) if err != nil { return nil, err } rc := &reconnectingClient{addr: addr, pool: rpc...
go
func newClient(addr string, max int, discardClientTimeout time.Duration, fn connectRPCFn) (Client, error) { rpcClientFactory := func() (interface{}, error) { return fn(addr) } rpcPool, err := pool.NewPool(max, rpcClientFactory) if err != nil { return nil, err } rc := &reconnectingClient{addr: addr, pool: rpc...
[ "func", "newClient", "(", "addr", "string", ",", "max", "int", ",", "discardClientTimeout", "time", ".", "Duration", ",", "fn", "connectRPCFn", ")", "(", "Client", ",", "error", ")", "{", "rpcClientFactory", ":=", "func", "(", ")", "(", "interface", "{", ...
// newClient that will create at most max active rpc connections at any given time. discardClientTimeout timeout for // discarding client from pool if a call takes too long, call will not be cancelled; assures liveliness of pool
[ "newClient", "that", "will", "create", "at", "most", "max", "active", "rpc", "connections", "at", "any", "given", "time", ".", "discardClientTimeout", "timeout", "for", "discarding", "client", "from", "pool", "if", "a", "call", "takes", "too", "long", "call", ...
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/rpcutils/client.go#L77-L88
139,404
control-center/serviced
domain/properties/validation.go
ValidEntity
func (s *StoredProperties) ValidEntity() error { violations := validation.NewValidationError() if s.Props == nil { violations.AddViolation("Props is nil") } if v, ok := s.CCVersion(); !ok || v == "" { violations.AddViolation("CCVersion is not set") } if violations.HasError() { return violations } return ...
go
func (s *StoredProperties) ValidEntity() error { violations := validation.NewValidationError() if s.Props == nil { violations.AddViolation("Props is nil") } if v, ok := s.CCVersion(); !ok || v == "" { violations.AddViolation("CCVersion is not set") } if violations.HasError() { return violations } return ...
[ "func", "(", "s", "*", "StoredProperties", ")", "ValidEntity", "(", ")", "error", "{", "violations", ":=", "validation", ".", "NewValidationError", "(", ")", "\n", "if", "s", ".", "Props", "==", "nil", "{", "violations", ".", "AddViolation", "(", "\"", "...
// ValidEntity validated type
[ "ValidEntity", "validated", "type" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/properties/validation.go#L21-L34
139,405
control-center/serviced
utils/iostat/iostat.go
NewReporter
func NewReporter(interval time.Duration, quit <-chan interface{}) *Reporter { return &Reporter{ interval: interval, quit: quit, } }
go
func NewReporter(interval time.Duration, quit <-chan interface{}) *Reporter { return &Reporter{ interval: interval, quit: quit, } }
[ "func", "NewReporter", "(", "interval", "time", ".", "Duration", ",", "quit", "<-", "chan", "interface", "{", "}", ")", "*", "Reporter", "{", "return", "&", "Reporter", "{", "interval", ":", "interval", ",", "quit", ":", "quit", ",", "}", "\n", "}" ]
// NewIOStatReporter creates a new IOStatReporter with interval and quit
[ "NewIOStatReporter", "creates", "a", "new", "IOStatReporter", "with", "interval", "and", "quit" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/iostat/iostat.go#L31-L36
139,406
control-center/serviced
utils/iostat/iostat.go
ToSimpleIOStat
func (d DeviceUtilizationReport) ToSimpleIOStat() (SimpleIOStat, error) { if d.Device == "" { return SimpleIOStat{}, ErrIOStatNoDevice } return SimpleIOStat{ Device: d.Device, RPS: d.RPS, WPS: d.WPS, Await: d.Await, }, nil }
go
func (d DeviceUtilizationReport) ToSimpleIOStat() (SimpleIOStat, error) { if d.Device == "" { return SimpleIOStat{}, ErrIOStatNoDevice } return SimpleIOStat{ Device: d.Device, RPS: d.RPS, WPS: d.WPS, Await: d.Await, }, nil }
[ "func", "(", "d", "DeviceUtilizationReport", ")", "ToSimpleIOStat", "(", ")", "(", "SimpleIOStat", ",", "error", ")", "{", "if", "d", ".", "Device", "==", "\"", "\"", "{", "return", "SimpleIOStat", "{", "}", ",", "ErrIOStatNoDevice", "\n", "}", "\n", "re...
// ToSimpleIOStat is a simple version of a DeviceUtilizationReport
[ "ToSimpleIOStat", "is", "a", "simple", "version", "of", "a", "DeviceUtilizationReport" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/iostat/iostat.go#L86-L96
139,407
control-center/serviced
utils/iostat/iostat.go
GetIOStatsCh
func (reporter *Reporter) GetIOStatsCh() (<-chan map[string]DeviceUtilizationReport, error) { cmd := exec.Command("iostat", "-dNxy", fmt.Sprintf("%f", reporter.interval.Seconds())) out, err := cmd.StdoutPipe() if err != nil { return nil, err } if err = cmd.Start(); err != nil { return nil, err } c := make(ch...
go
func (reporter *Reporter) GetIOStatsCh() (<-chan map[string]DeviceUtilizationReport, error) { cmd := exec.Command("iostat", "-dNxy", fmt.Sprintf("%f", reporter.interval.Seconds())) out, err := cmd.StdoutPipe() if err != nil { return nil, err } if err = cmd.Start(); err != nil { return nil, err } c := make(ch...
[ "func", "(", "reporter", "*", "Reporter", ")", "GetIOStatsCh", "(", ")", "(", "<-", "chan", "map", "[", "string", "]", "DeviceUtilizationReport", ",", "error", ")", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "fmt...
// GetIOStatsCh calls iostat with -dNxy and an interval defined in reporter. // It parses the output and creates a DeviceUtilizationReport for each device // and sends it to the returned channel.
[ "GetIOStatsCh", "calls", "iostat", "with", "-", "dNxy", "and", "an", "interval", "defined", "in", "reporter", ".", "It", "parses", "the", "output", "and", "creates", "a", "DeviceUtilizationReport", "for", "each", "device", "and", "sends", "it", "to", "the", ...
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/iostat/iostat.go#L196-L215
139,408
control-center/serviced
utils/iostat/iostat.go
parseIOStatWatcher
func parseIOStatWatcher(r io.Reader, c chan<- map[string]DeviceUtilizationReport, qCh <-chan interface{}) { // Custom bufio.Split() function to split tokens by 2 new lines atTwoNewLines := func(data []byte, atEOF bool) (int, []byte, error) { advance := 0 var token []byte var prev byte for _, b := range data ...
go
func parseIOStatWatcher(r io.Reader, c chan<- map[string]DeviceUtilizationReport, qCh <-chan interface{}) { // Custom bufio.Split() function to split tokens by 2 new lines atTwoNewLines := func(data []byte, atEOF bool) (int, []byte, error) { advance := 0 var token []byte var prev byte for _, b := range data ...
[ "func", "parseIOStatWatcher", "(", "r", "io", ".", "Reader", ",", "c", "chan", "<-", "map", "[", "string", "]", "DeviceUtilizationReport", ",", "qCh", "<-", "chan", "interface", "{", "}", ")", "{", "// Custom bufio.Split() function to split tokens by 2 new lines", ...
// parseIOStatWatcher scans the reader for 2 new lines, signifying a new report
[ "parseIOStatWatcher", "scans", "the", "reader", "for", "2", "new", "lines", "signifying", "a", "new", "report" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/iostat/iostat.go#L223-L279
139,409
control-center/serviced
web/api_hosts.go
getHosts
func getHosts(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) { facade := ctx.getFacade() dataCtx := ctx.getDatastoreContext() hosts, err := facade.GetReadHosts(dataCtx) if err != nil { restServerError(w, err) return } w.WriteJson(hosts) }
go
func getHosts(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) { facade := ctx.getFacade() dataCtx := ctx.getDatastoreContext() hosts, err := facade.GetReadHosts(dataCtx) if err != nil { restServerError(w, err) return } w.WriteJson(hosts) }
[ "func", "getHosts", "(", "w", "*", "rest", ".", "ResponseWriter", ",", "r", "*", "rest", ".", "Request", ",", "ctx", "*", "requestContext", ")", "{", "facade", ":=", "ctx", ".", "getFacade", "(", ")", "\n", "dataCtx", ":=", "ctx", ".", "getDatastoreCon...
// getPools returns the list of pools requested.
[ "getPools", "returns", "the", "list", "of", "pools", "requested", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/api_hosts.go#L25-L36
139,410
control-center/serviced
web/api_hosts.go
getHostsForPool
func getHostsForPool(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) { poolID, err := url.QueryUnescape(r.PathParam("poolId")) if err != nil { writeJSON(w, err, http.StatusBadRequest) return } else if len(poolID) == 0 { writeJSON(w, "poolId must be specified", http.StatusBadRequest) return } ...
go
func getHostsForPool(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) { poolID, err := url.QueryUnescape(r.PathParam("poolId")) if err != nil { writeJSON(w, err, http.StatusBadRequest) return } else if len(poolID) == 0 { writeJSON(w, "poolId must be specified", http.StatusBadRequest) return } ...
[ "func", "getHostsForPool", "(", "w", "*", "rest", ".", "ResponseWriter", ",", "r", "*", "rest", ".", "Request", ",", "ctx", "*", "requestContext", ")", "{", "poolID", ",", "err", ":=", "url", ".", "QueryUnescape", "(", "r", ".", "PathParam", "(", "\"",...
// getHostsForPool returns the list of hosts for a pool.
[ "getHostsForPool", "returns", "the", "list", "of", "hosts", "for", "a", "pool", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/api_hosts.go#L39-L59
139,411
control-center/serviced
web/api_hosts.go
getHostStatuses
func getHostStatuses(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) { facade := ctx.getFacade() dataCtx := ctx.getDatastoreContext() values := r.URL.Query() var hostIDs []string if _, ok := values["hostId"]; ok { hostIDs = values["hostId"] } else { hosts, err := facade.GetReadHosts(dataCtx) ...
go
func getHostStatuses(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) { facade := ctx.getFacade() dataCtx := ctx.getDatastoreContext() values := r.URL.Query() var hostIDs []string if _, ok := values["hostId"]; ok { hostIDs = values["hostId"] } else { hosts, err := facade.GetReadHosts(dataCtx) ...
[ "func", "getHostStatuses", "(", "w", "*", "rest", ".", "ResponseWriter", ",", "r", "*", "rest", ".", "Request", ",", "ctx", "*", "requestContext", ")", "{", "facade", ":=", "ctx", ".", "getFacade", "(", ")", "\n", "dataCtx", ":=", "ctx", ".", "getDatas...
// getHostStatus return status information for hosts. This includes the memory usage and // whether or not the host is active.
[ "getHostStatus", "return", "status", "information", "for", "hosts", ".", "This", "includes", "the", "memory", "usage", "and", "whether", "or", "not", "the", "host", "is", "active", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/api_hosts.go#L63-L105
139,412
control-center/serviced
container/stats.go
statReporter
func statReporter(statsUrl string, interval time.Duration) { tick := time.Tick(interval) for { select { case t := <-tick: collect(t, statsUrl) } } }
go
func statReporter(statsUrl string, interval time.Duration) { tick := time.Tick(interval) for { select { case t := <-tick: collect(t, statsUrl) } } }
[ "func", "statReporter", "(", "statsUrl", "string", ",", "interval", "time", ".", "Duration", ")", "{", "tick", ":=", "time", ".", "Tick", "(", "interval", ")", "\n", "for", "{", "select", "{", "case", "t", ":=", "<-", "tick", ":", "collect", "(", "t"...
// statReporter perically collects statistics at the given // interval until the closing channel closes
[ "statReporter", "perically", "collects", "statistics", "at", "the", "given", "interval", "until", "the", "closing", "channel", "closes" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/stats.go#L31-L40
139,413
control-center/serviced
container/stats.go
readInt64Stats
func readInt64Stats(dir string) (results map[string]int64, err error) { finfos, err := ioutil.ReadDir(dir) if err != nil { return nil, err } results = make(map[string]int64) for _, finfo := range finfos { if finfo.IsDir() { continue } fname := path.Join(dir, finfo.Name()) data, err := ioutil.ReadFile...
go
func readInt64Stats(dir string) (results map[string]int64, err error) { finfos, err := ioutil.ReadDir(dir) if err != nil { return nil, err } results = make(map[string]int64) for _, finfo := range finfos { if finfo.IsDir() { continue } fname := path.Join(dir, finfo.Name()) data, err := ioutil.ReadFile...
[ "func", "readInt64Stats", "(", "dir", "string", ")", "(", "results", "map", "[", "string", "]", "int64", ",", "err", "error", ")", "{", "finfos", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "dir", ")", "\n", "if", "err", "!=", "nil", "{", "ret...
// Read all the files in a directory that contain integers and return a // map of those values
[ "Read", "all", "the", "files", "in", "a", "directory", "that", "contain", "integers", "and", "return", "a", "map", "of", "those", "values" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/stats.go#L101-L124
139,414
control-center/serviced
commons/docker/event.go
monitorEvents
func (c *Client) monitorEvents() (EventMonitor, error) { if err := eventMonitor.run(c); err != nil { return nil, err } return eventMonitor, nil }
go
func (c *Client) monitorEvents() (EventMonitor, error) { if err := eventMonitor.run(c); err != nil { return nil, err } return eventMonitor, nil }
[ "func", "(", "c", "*", "Client", ")", "monitorEvents", "(", ")", "(", "EventMonitor", ",", "error", ")", "{", "if", "err", ":=", "eventMonitor", ".", "run", "(", "c", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n"...
// MonitorEvents returns an EventMonitor that can be used to listen for and respond to // the various events in the Docker container and image lifecycles.
[ "MonitorEvents", "returns", "an", "EventMonitor", "that", "can", "be", "used", "to", "listen", "for", "and", "respond", "to", "the", "various", "events", "in", "the", "Docker", "container", "and", "image", "lifecycles", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/docker/event.go#L96-L101
139,415
control-center/serviced
commons/docker/event.go
IsActive
func (em *clientEventMonitor) IsActive() bool { em.Lock() defer em.Unlock() return em.active }
go
func (em *clientEventMonitor) IsActive() bool { em.Lock() defer em.Unlock() return em.active }
[ "func", "(", "em", "*", "clientEventMonitor", ")", "IsActive", "(", ")", "bool", "{", "em", ".", "Lock", "(", ")", "\n", "defer", "em", ".", "Unlock", "(", ")", "\n\n", "return", "em", ".", "active", "\n", "}" ]
// IsActive reports whether or not an EventMonitor is active, i.e., listening for Docker events.
[ "IsActive", "reports", "whether", "or", "not", "an", "EventMonitor", "is", "active", "i", ".", "e", ".", "listening", "for", "Docker", "events", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/docker/event.go#L104-L109
139,416
control-center/serviced
commons/docker/event.go
Close
func (em *clientEventMonitor) Close() error { em.Lock() defer em.Unlock() if !em.active { return nil } crc := make(chan struct{}) em.closeChannel <- crc select { case <-crc: em.active = false em.subscriptions = make(map[string][]*Subscription) em.done = make(chan struct{}) return nil } }
go
func (em *clientEventMonitor) Close() error { em.Lock() defer em.Unlock() if !em.active { return nil } crc := make(chan struct{}) em.closeChannel <- crc select { case <-crc: em.active = false em.subscriptions = make(map[string][]*Subscription) em.done = make(chan struct{}) return nil } }
[ "func", "(", "em", "*", "clientEventMonitor", ")", "Close", "(", ")", "error", "{", "em", ".", "Lock", "(", ")", "\n", "defer", "em", ".", "Unlock", "(", ")", "\n\n", "if", "!", "em", ".", "active", "{", "return", "nil", "\n", "}", "\n\n", "crc",...
// Close causes the EventMonitor to stop listening for Docker events.
[ "Close", "causes", "the", "EventMonitor", "to", "stop", "listening", "for", "Docker", "events", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/docker/event.go#L112-L131
139,417
control-center/serviced
commons/docker/event.go
run
func (em *clientEventMonitor) run(c *Client) error { em.Lock() defer em.Unlock() if em.active { return nil } go func() { r, w := io.Pipe() go listenAndDispatch(c, em, r, w) select { case crc := <-em.closeChannel: w.Close() r.Close() close(em.done) crc <- struct{}{} return } }() em...
go
func (em *clientEventMonitor) run(c *Client) error { em.Lock() defer em.Unlock() if em.active { return nil } go func() { r, w := io.Pipe() go listenAndDispatch(c, em, r, w) select { case crc := <-em.closeChannel: w.Close() r.Close() close(em.done) crc <- struct{}{} return } }() em...
[ "func", "(", "em", "*", "clientEventMonitor", ")", "run", "(", "c", "*", "Client", ")", "error", "{", "em", ".", "Lock", "(", ")", "\n", "defer", "em", ".", "Unlock", "(", ")", "\n\n", "if", "em", ".", "active", "{", "return", "nil", "\n", "}", ...
// run causes the clientEventMonitor to start listening for Docker container // and image lifecycle events
[ "run", "causes", "the", "clientEventMonitor", "to", "start", "listening", "for", "Docker", "container", "and", "image", "lifecycle", "events" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/docker/event.go#L158-L183
139,418
control-center/serviced
commons/docker/event.go
dispatch
func (em *clientEventMonitor) dispatch(evt *dockerclient.APIEvents) error { em.Lock() defer em.Unlock() if !em.active { return nil } // send the event to subscribers interested in everything if subs, ok := em.subscriptions[AllThingsDocker]; ok { for _, sub := range subs { select { case sub.eventChanne...
go
func (em *clientEventMonitor) dispatch(evt *dockerclient.APIEvents) error { em.Lock() defer em.Unlock() if !em.active { return nil } // send the event to subscribers interested in everything if subs, ok := em.subscriptions[AllThingsDocker]; ok { for _, sub := range subs { select { case sub.eventChanne...
[ "func", "(", "em", "*", "clientEventMonitor", ")", "dispatch", "(", "evt", "*", "dockerclient", ".", "APIEvents", ")", "error", "{", "em", ".", "Lock", "(", ")", "\n", "defer", "em", ".", "Unlock", "(", ")", "\n\n", "if", "!", "em", ".", "active", ...
// dispatch sends the incoming event to the event channel of all interested subscribers.
[ "dispatch", "sends", "the", "incoming", "event", "to", "the", "event", "channel", "of", "all", "interested", "subscribers", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/docker/event.go#L186-L218
139,419
control-center/serviced
commons/docker/event.go
unsubscribe
func (em *clientEventMonitor) unsubscribe(s *Subscription) error { em.Lock() defer em.Unlock() ns := []*Subscription{} for _, sub := range em.subscriptions[s.ID] { if sub != s { ns = append(ns, sub) } } em.subscriptions[s.ID] = ns return nil }
go
func (em *clientEventMonitor) unsubscribe(s *Subscription) error { em.Lock() defer em.Unlock() ns := []*Subscription{} for _, sub := range em.subscriptions[s.ID] { if sub != s { ns = append(ns, sub) } } em.subscriptions[s.ID] = ns return nil }
[ "func", "(", "em", "*", "clientEventMonitor", ")", "unsubscribe", "(", "s", "*", "Subscription", ")", "error", "{", "em", ".", "Lock", "(", ")", "\n", "defer", "em", ".", "Unlock", "(", ")", "\n\n", "ns", ":=", "[", "]", "*", "Subscription", "{", "...
// unsubscribe removes the given Subscription from the event monitor's list of subscribers
[ "unsubscribe", "removes", "the", "given", "Subscription", "from", "the", "event", "monitor", "s", "list", "of", "subscribers" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/docker/event.go#L221-L235
139,420
control-center/serviced
commons/docker/event.go
listenAndDispatch
func listenAndDispatch(c *Client, em *clientEventMonitor, r *io.PipeReader, w *io.PipeWriter) { listener := make(chan *dockerclient.APIEvents) c.dc.AddEventListener(listener) for { evt := <-listener if evt != nil { em.dispatch(evt) } } }
go
func listenAndDispatch(c *Client, em *clientEventMonitor, r *io.PipeReader, w *io.PipeWriter) { listener := make(chan *dockerclient.APIEvents) c.dc.AddEventListener(listener) for { evt := <-listener if evt != nil { em.dispatch(evt) } } }
[ "func", "listenAndDispatch", "(", "c", "*", "Client", ",", "em", "*", "clientEventMonitor", ",", "r", "*", "io", ".", "PipeReader", ",", "w", "*", "io", ".", "PipeWriter", ")", "{", "listener", ":=", "make", "(", "chan", "*", "dockerclient", ".", "APIE...
// listenAndDispatch reads the Docker event stream and dispatches the events // it receives.
[ "listenAndDispatch", "reads", "the", "Docker", "event", "stream", "and", "dispatches", "the", "events", "it", "receives", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/docker/event.go#L239-L248
139,421
control-center/serviced
commons/docker/event.go
Handle
func (s *Subscription) Handle(es string, h HandlerFunc) error { if _, ok := validEvents[es]; !ok { return fmt.Errorf("unknown event: %s", es) } s.lock.Lock() s.handlers[es] = h s.lock.Unlock() return nil }
go
func (s *Subscription) Handle(es string, h HandlerFunc) error { if _, ok := validEvents[es]; !ok { return fmt.Errorf("unknown event: %s", es) } s.lock.Lock() s.handlers[es] = h s.lock.Unlock() return nil }
[ "func", "(", "s", "*", "Subscription", ")", "Handle", "(", "es", "string", ",", "h", "HandlerFunc", ")", "error", "{", "if", "_", ",", "ok", ":=", "validEvents", "[", "es", "]", ";", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\""...
// Handle associates a HandlerFunc h with a the Docker container or image lifecycle // event specified by es. Any HandlerFunc previously associated with es is replaced.
[ "Handle", "associates", "a", "HandlerFunc", "h", "with", "a", "the", "Docker", "container", "or", "image", "lifecycle", "event", "specified", "by", "es", ".", "Any", "HandlerFunc", "previously", "associated", "with", "es", "is", "replaced", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/docker/event.go#L252-L261
139,422
control-center/serviced
commons/docker/event.go
Cancel
func (s *Subscription) Cancel() error { if !s.active { return nil } crc := make(chan struct{}) s.cancelChannel <- crc select { case <-crc: if err := s.monitor.unsubscribe(s); err != nil { glog.V(2).Infof("could not unsubscribe %v (%v)", s, err) } s.active = false return nil } }
go
func (s *Subscription) Cancel() error { if !s.active { return nil } crc := make(chan struct{}) s.cancelChannel <- crc select { case <-crc: if err := s.monitor.unsubscribe(s); err != nil { glog.V(2).Infof("could not unsubscribe %v (%v)", s, err) } s.active = false return nil } }
[ "func", "(", "s", "*", "Subscription", ")", "Cancel", "(", ")", "error", "{", "if", "!", "s", ".", "active", "{", "return", "nil", "\n", "}", "\n\n", "crc", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "s", ".", "cancelChannel", "<-"...
// Cancel causes the Subscription to stop receiving and dispatching Docker container and // image lifecycle events.
[ "Cancel", "causes", "the", "Subscription", "to", "stop", "receiving", "and", "dispatching", "Docker", "container", "and", "image", "lifecycle", "events", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/docker/event.go#L265-L282
139,423
control-center/serviced
commons/docker/event.go
run
func (s *Subscription) run() error { if s.active { return nil } go func() { for { select { case e := <-s.eventChannel: if e.Status != "" { s.lock.RLock() h, ok := s.handlers[e.Status] if ok { h(e) } s.lock.RUnlock() } case crc := <-s.cancelChannel: crc <- stru...
go
func (s *Subscription) run() error { if s.active { return nil } go func() { for { select { case e := <-s.eventChannel: if e.Status != "" { s.lock.RLock() h, ok := s.handlers[e.Status] if ok { h(e) } s.lock.RUnlock() } case crc := <-s.cancelChannel: crc <- stru...
[ "func", "(", "s", "*", "Subscription", ")", "run", "(", ")", "error", "{", "if", "s", ".", "active", "{", "return", "nil", "\n", "}", "\n\n", "go", "func", "(", ")", "{", "for", "{", "select", "{", "case", "e", ":=", "<-", "s", ".", "eventChann...
// run causes the Subscription to start receiving and dispatching Docker container and // image lifecycle events.
[ "run", "causes", "the", "Subscription", "to", "start", "receiving", "and", "dispatching", "Docker", "container", "and", "image", "lifecycle", "events", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/docker/event.go#L286-L315
139,424
control-center/serviced
container/controller.go
Close
func (c *Controller) Close() error { errc := make(chan error) c.closing <- errc return <-errc }
go
func (c *Controller) Close() error { errc := make(chan error) c.closing <- errc return <-errc }
[ "func", "(", "c", "*", "Controller", ")", "Close", "(", ")", "error", "{", "errc", ":=", "make", "(", "chan", "error", ")", "\n", "c", ".", "closing", "<-", "errc", "\n", "return", "<-", "errc", "\n", "}" ]
// Close shuts down the controller
[ "Close", "shuts", "down", "the", "controller" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/controller.go#L134-L138
139,425
control-center/serviced
container/controller.go
getService
func getService(lbClientPort string, serviceID string, instanceID int) (*service.Service, string, string, error) { client, err := node.NewLBClient(lbClientPort) if err != nil { glog.Errorf("Could not create a client to endpoint: %s, %s", lbClientPort, err) return nil, "", "", err } defer client.Close() var ev...
go
func getService(lbClientPort string, serviceID string, instanceID int) (*service.Service, string, string, error) { client, err := node.NewLBClient(lbClientPort) if err != nil { glog.Errorf("Could not create a client to endpoint: %s, %s", lbClientPort, err) return nil, "", "", err } defer client.Close() var ev...
[ "func", "getService", "(", "lbClientPort", "string", ",", "serviceID", "string", ",", "instanceID", "int", ")", "(", "*", "service", ".", "Service", ",", "string", ",", "string", ",", "error", ")", "{", "client", ",", "err", ":=", "node", ".", "NewLBClie...
// getService retrieves a service
[ "getService", "retrieves", "a", "service" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/controller.go#L141-L159
139,426
control-center/serviced
container/controller.go
getAgentHostID
func getAgentHostID(lbClientPort string) (string, error) { client, err := node.NewLBClient(lbClientPort) if err != nil { glog.Errorf("Could not create a client to endpoint: %s, %s", lbClientPort, err) return "", err } defer client.Close() var hostID string err = client.GetHostID(&hostID) if err != nil { g...
go
func getAgentHostID(lbClientPort string) (string, error) { client, err := node.NewLBClient(lbClientPort) if err != nil { glog.Errorf("Could not create a client to endpoint: %s, %s", lbClientPort, err) return "", err } defer client.Close() var hostID string err = client.GetHostID(&hostID) if err != nil { g...
[ "func", "getAgentHostID", "(", "lbClientPort", "string", ")", "(", "string", ",", "error", ")", "{", "client", ",", "err", ":=", "node", ".", "NewLBClient", "(", "lbClientPort", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\""...
// getAgentHostID retrieves the agent's host id
[ "getAgentHostID", "retrieves", "the", "agent", "s", "host", "id" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/controller.go#L162-L179
139,427
control-center/serviced
container/controller.go
getAgentZkInfo
func getAgentZkInfo(lbClientPort string) (node.ZkInfo, error) { var zkInfo node.ZkInfo client, err := node.NewLBClient(lbClientPort) if err != nil { glog.Errorf("Could not create a client to endpoint: %s, %s", lbClientPort, err) return zkInfo, err } defer client.Close() err = client.GetZkInfo(&zkInfo) if er...
go
func getAgentZkInfo(lbClientPort string) (node.ZkInfo, error) { var zkInfo node.ZkInfo client, err := node.NewLBClient(lbClientPort) if err != nil { glog.Errorf("Could not create a client to endpoint: %s, %s", lbClientPort, err) return zkInfo, err } defer client.Close() err = client.GetZkInfo(&zkInfo) if er...
[ "func", "getAgentZkInfo", "(", "lbClientPort", "string", ")", "(", "node", ".", "ZkInfo", ",", "error", ")", "{", "var", "zkInfo", "node", ".", "ZkInfo", "\n", "client", ",", "err", ":=", "node", ".", "NewLBClient", "(", "lbClientPort", ")", "\n", "if", ...
// getAgentZkInfo retrieves the agent's zookeeper dsn
[ "getAgentZkInfo", "retrieves", "the", "agent", "s", "zookeeper", "dsn" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/controller.go#L182-L199
139,428
control-center/serviced
container/controller.go
chownConfFile
func chownConfFile(filename, owner, permissions string) error { runCommand := func(exe, arg, filename string) error { command := exec.Command(exe, arg, filename) output, err := command.CombinedOutput() if err != nil { glog.Errorf("Error running command:'%v' output: %s error: %s\n", command, output, err) ...
go
func chownConfFile(filename, owner, permissions string) error { runCommand := func(exe, arg, filename string) error { command := exec.Command(exe, arg, filename) output, err := command.CombinedOutput() if err != nil { glog.Errorf("Error running command:'%v' output: %s error: %s\n", command, output, err) ...
[ "func", "chownConfFile", "(", "filename", ",", "owner", ",", "permissions", "string", ")", "error", "{", "runCommand", ":=", "func", "(", "exe", ",", "arg", ",", "filename", "string", ")", "error", "{", "command", ":=", "exec", ".", "Command", "(", "exe"...
// chownConfFile sets the owner and permissions for a file
[ "chownConfFile", "sets", "the", "owner", "and", "permissions", "for", "a", "file" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/controller.go#L202-L227
139,429
control-center/serviced
container/controller.go
writeConfFile
func writeConfFile(config servicedefinition.ConfigFile) error { // write file with default perms if err := os.MkdirAll(filepath.Dir(config.Filename), 0755); err != nil { glog.Errorf("could not create directories for config file: %s", config.Filename) return err } if err := ioutil.WriteFile(config.Filename, []by...
go
func writeConfFile(config servicedefinition.ConfigFile) error { // write file with default perms if err := os.MkdirAll(filepath.Dir(config.Filename), 0755); err != nil { glog.Errorf("could not create directories for config file: %s", config.Filename) return err } if err := ioutil.WriteFile(config.Filename, []by...
[ "func", "writeConfFile", "(", "config", "servicedefinition", ".", "ConfigFile", ")", "error", "{", "// write file with default perms", "if", "err", ":=", "os", ".", "MkdirAll", "(", "filepath", ".", "Dir", "(", "config", ".", "Filename", ")", ",", "0755", ")",...
// writeConfFile writes a config file
[ "writeConfFile", "writes", "a", "config", "file" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/controller.go#L230-L248
139,430
control-center/serviced
container/controller.go
setupConfigFiles
func setupConfigFiles(svc *service.Service) error { // write out config files for _, config := range svc.ConfigFiles { err := writeConfFile(config) if err != nil { return err } } return nil }
go
func setupConfigFiles(svc *service.Service) error { // write out config files for _, config := range svc.ConfigFiles { err := writeConfFile(config) if err != nil { return err } } return nil }
[ "func", "setupConfigFiles", "(", "svc", "*", "service", ".", "Service", ")", "error", "{", "// write out config files", "for", "_", ",", "config", ":=", "range", "svc", ".", "ConfigFiles", "{", "err", ":=", "writeConfFile", "(", "config", ")", "\n", "if", ...
// setupConfigFiles sets up config files
[ "setupConfigFiles", "sets", "up", "config", "files" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/controller.go#L251-L260
139,431
control-center/serviced
container/controller.go
setupLogstashFiles
func setupLogstashFiles(hostID string, hostIPs string, svcPath string, service *service.Service, instanceID string, logforwarderOptions LogforwarderOptions) error { // write out logstash files if len(service.LogConfigs) != 0 { err := writeLogstashAgentConfig(hostID, hostIPs, svcPath, service, instanceID, logforward...
go
func setupLogstashFiles(hostID string, hostIPs string, svcPath string, service *service.Service, instanceID string, logforwarderOptions LogforwarderOptions) error { // write out logstash files if len(service.LogConfigs) != 0 { err := writeLogstashAgentConfig(hostID, hostIPs, svcPath, service, instanceID, logforward...
[ "func", "setupLogstashFiles", "(", "hostID", "string", ",", "hostIPs", "string", ",", "svcPath", "string", ",", "service", "*", "service", ".", "Service", ",", "instanceID", "string", ",", "logforwarderOptions", "LogforwarderOptions", ")", "error", "{", "// write ...
// setupLogstashFiles sets up logstash files
[ "setupLogstashFiles", "sets", "up", "logstash", "files" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/controller.go#L263-L272
139,432
control-center/serviced
container/controller.go
rpcHealthCheck
func (c *Controller) rpcHealthCheck() (chan struct{}, error) { gone := make(chan struct{}) client, err := node.NewLBClient(c.options.ServicedEndpoint) if err != nil { return nil, err } go func() { var ts time.Time retries := 3 failures := 0 for { err := client.Ping(2*time.Second, &ts) if err != ni...
go
func (c *Controller) rpcHealthCheck() (chan struct{}, error) { gone := make(chan struct{}) client, err := node.NewLBClient(c.options.ServicedEndpoint) if err != nil { return nil, err } go func() { var ts time.Time retries := 3 failures := 0 for { err := client.Ping(2*time.Second, &ts) if err != ni...
[ "func", "(", "c", "*", "Controller", ")", "rpcHealthCheck", "(", ")", "(", "chan", "struct", "{", "}", ",", "error", ")", "{", "gone", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n\n", "client", ",", "err", ":=", "node", ".", "NewLBClient...
// rpcHealthCheck returns a channel that will close when it not longer possible // to ping the RPC server
[ "rpcHealthCheck", "returns", "a", "channel", "that", "will", "close", "when", "it", "not", "longer", "possible", "to", "ping", "the", "RPC", "server" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/controller.go#L503-L535
139,433
control-center/serviced
zzk/service/poollistener.go
NewPoolListener
func NewPoolListener(synchronizer VirtualIPSynchronizer) *PoolListener { return &PoolListener{synchronizer: synchronizer, Timeout: time.Second * 5} }
go
func NewPoolListener(synchronizer VirtualIPSynchronizer) *PoolListener { return &PoolListener{synchronizer: synchronizer, Timeout: time.Second * 5} }
[ "func", "NewPoolListener", "(", "synchronizer", "VirtualIPSynchronizer", ")", "*", "PoolListener", "{", "return", "&", "PoolListener", "{", "synchronizer", ":", "synchronizer", ",", "Timeout", ":", "time", ".", "Second", "*", "5", "}", "\n", "}" ]
// NewPoolListener instantiates a new PoolListener
[ "NewPoolListener", "instantiates", "a", "new", "PoolListener" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/poollistener.go#L34-L36
139,434
control-center/serviced
script/nodes.go
validParents
func validParents(parents []string, parser lineParser) lineParser { f := func(ctx *parseContext, cmd string, args []string) (node, error) { n, err := parser(ctx, cmd, args) if err == nil { parentMap := make(map[string]struct{}) for _, p := range parents { parentMap[p] = struct{}{} } for _, previous...
go
func validParents(parents []string, parser lineParser) lineParser { f := func(ctx *parseContext, cmd string, args []string) (node, error) { n, err := parser(ctx, cmd, args) if err == nil { parentMap := make(map[string]struct{}) for _, p := range parents { parentMap[p] = struct{}{} } for _, previous...
[ "func", "validParents", "(", "parents", "[", "]", "string", ",", "parser", "lineParser", ")", "lineParser", "{", "f", ":=", "func", "(", "ctx", "*", "parseContext", ",", "cmd", "string", ",", "args", "[", "]", "string", ")", "(", "node", ",", "error", ...
//validParents checks that there are no previous command or previous commands are only in parents list
[ "validParents", "checks", "that", "there", "are", "no", "previous", "command", "or", "previous", "commands", "are", "only", "in", "parents", "list" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/script/nodes.go#L260-L277
139,435
control-center/serviced
script/nodes.go
require
func require(required []string, parser lineParser) lineParser { f := func(ctx *parseContext, cmd string, args []string) (node, error) { n, err := parser(ctx, cmd, args) if err == nil { requiredMap := make(map[string]bool) for _, r := range required { requiredMap[r] = false //hasn't been found yet } ...
go
func require(required []string, parser lineParser) lineParser { f := func(ctx *parseContext, cmd string, args []string) (node, error) { n, err := parser(ctx, cmd, args) if err == nil { requiredMap := make(map[string]bool) for _, r := range required { requiredMap[r] = false //hasn't been found yet } ...
[ "func", "require", "(", "required", "[", "]", "string", ",", "parser", "lineParser", ")", "lineParser", "{", "f", ":=", "func", "(", "ctx", "*", "parseContext", ",", "cmd", "string", ",", "args", "[", "]", "string", ")", "(", "node", ",", "error", ")...
//require checks required commands are already present
[ "require", "checks", "required", "commands", "are", "already", "present" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/script/nodes.go#L280-L303
139,436
control-center/serviced
script/nodes.go
atMost
func atMost(n int, parser lineParser) lineParser { f := func(ctx *parseContext, cmd string, args []string) (node, error) { cmdNode, err := parser(ctx, cmd, args) if err == nil { count := 0 for _, previousNode := range ctx.nodes { if previousNode.cmd == cmd { count += 1 if count >= n { ct...
go
func atMost(n int, parser lineParser) lineParser { f := func(ctx *parseContext, cmd string, args []string) (node, error) { cmdNode, err := parser(ctx, cmd, args) if err == nil { count := 0 for _, previousNode := range ctx.nodes { if previousNode.cmd == cmd { count += 1 if count >= n { ct...
[ "func", "atMost", "(", "n", "int", ",", "parser", "lineParser", ")", "lineParser", "{", "f", ":=", "func", "(", "ctx", "*", "parseContext", ",", "cmd", "string", ",", "args", "[", "]", "string", ")", "(", "node", ",", "error", ")", "{", "cmdNode", ...
// atMost checks that the command type appears at most n times
[ "atMost", "checks", "that", "the", "command", "type", "appears", "at", "most", "n", "times" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/script/nodes.go#L306-L324
139,437
control-center/serviced
domain/metric.go
SetTag
func (request *MetricMetricBuilder) SetTag(Name string, Values ...string) *MetricMetricBuilder { request.Tags[Name] = Values return request }
go
func (request *MetricMetricBuilder) SetTag(Name string, Values ...string) *MetricMetricBuilder { request.Tags[Name] = Values return request }
[ "func", "(", "request", "*", "MetricMetricBuilder", ")", "SetTag", "(", "Name", "string", ",", "Values", "...", "string", ")", "*", "MetricMetricBuilder", "{", "request", ".", "Tags", "[", "Name", "]", "=", "Values", "\n", "return", "request", "\n", "}" ]
// SetTag puts a tag into the metric request object
[ "SetTag", "puts", "a", "tag", "into", "the", "metric", "request", "object" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/metric.go#L50-L53
139,438
control-center/serviced
domain/metric.go
SetTags
func (request *MetricMetricBuilder) SetTags(tags map[string][]string) *MetricMetricBuilder { request.Tags = tags return request }
go
func (request *MetricMetricBuilder) SetTags(tags map[string][]string) *MetricMetricBuilder { request.Tags = tags return request }
[ "func", "(", "request", "*", "MetricMetricBuilder", ")", "SetTags", "(", "tags", "map", "[", "string", "]", "[", "]", "string", ")", "*", "MetricMetricBuilder", "{", "request", ".", "Tags", "=", "tags", "\n", "return", "request", "\n", "}" ]
// SetTags sets tags to value
[ "SetTags", "sets", "tags", "to", "value" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/metric.go#L56-L59
139,439
control-center/serviced
domain/metric.go
Equals
func (config *QueryConfig) Equals(that *QueryConfig) bool { return reflect.DeepEqual(config, that) }
go
func (config *QueryConfig) Equals(that *QueryConfig) bool { return reflect.DeepEqual(config, that) }
[ "func", "(", "config", "*", "QueryConfig", ")", "Equals", "(", "that", "*", "QueryConfig", ")", "bool", "{", "return", "reflect", ".", "DeepEqual", "(", "config", ",", "that", ")", "\n", "}" ]
// Equals compares two QueryConfig objects for equality
[ "Equals", "compares", "two", "QueryConfig", "objects", "for", "equality" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/metric.go#L70-L72
139,440
control-center/serviced
domain/metric.go
ValidEntity
func (config MetricConfig) ValidEntity() error { if config.ID == "metrics" { return fmt.Errorf("'metrics' is a reserved word") } violations := validation.NewValidationError() for _, m := range config.Metrics { if m.BuiltIn { violations.AddViolation(fmt.Sprintf("config %s: metric %s cannot have BuiltIn set t...
go
func (config MetricConfig) ValidEntity() error { if config.ID == "metrics" { return fmt.Errorf("'metrics' is a reserved word") } violations := validation.NewValidationError() for _, m := range config.Metrics { if m.BuiltIn { violations.AddViolation(fmt.Sprintf("config %s: metric %s cannot have BuiltIn set t...
[ "func", "(", "config", "MetricConfig", ")", "ValidEntity", "(", ")", "error", "{", "if", "config", ".", "ID", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "violations", ":=", "validation", ".", "NewV...
// ValidEntity ensures the metric config is not named "metrics"
[ "ValidEntity", "ensures", "the", "metric", "config", "is", "not", "named", "metrics" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/metric.go#L84-L99
139,441
control-center/serviced
domain/metric.go
Equals
func (config *MetricConfig) Equals(that *MetricConfig) bool { return reflect.DeepEqual(config, that) }
go
func (config *MetricConfig) Equals(that *MetricConfig) bool { return reflect.DeepEqual(config, that) }
[ "func", "(", "config", "*", "MetricConfig", ")", "Equals", "(", "that", "*", "MetricConfig", ")", "bool", "{", "return", "reflect", ".", "DeepEqual", "(", "config", ",", "that", ")", "\n", "}" ]
// Equals equality test for MetricConfig
[ "Equals", "equality", "test", "for", "MetricConfig" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/metric.go#L102-L104
139,442
control-center/serviced
domain/metric.go
Metric
func (builder *MetricBuilder) Metric(metric Metric) *MetricMetricBuilder { newMetric := MetricMetricBuilder{ Metric{ ID: metric.ID, Name: metric.Name, Description: metric.Description, Counter: metric.Counter, CounterMax: metric.CounterMax, ResetValue: metric.ResetValue, Uni...
go
func (builder *MetricBuilder) Metric(metric Metric) *MetricMetricBuilder { newMetric := MetricMetricBuilder{ Metric{ ID: metric.ID, Name: metric.Name, Description: metric.Description, Counter: metric.Counter, CounterMax: metric.CounterMax, ResetValue: metric.ResetValue, Uni...
[ "func", "(", "builder", "*", "MetricBuilder", ")", "Metric", "(", "metric", "Metric", ")", "*", "MetricMetricBuilder", "{", "newMetric", ":=", "MetricMetricBuilder", "{", "Metric", "{", "ID", ":", "metric", ".", "ID", ",", "Name", ":", "metric", ".", "Name...
// Metric appends a metric configuration to the MetricBuilder
[ "Metric", "appends", "a", "metric", "configuration", "to", "the", "MetricBuilder" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/metric.go#L114-L129
139,443
control-center/serviced
domain/metric.go
Config
func (builder *MetricBuilder) Config(ID, Name, Description, Start string) (*MetricConfig, error) { //config object to build headers := make(http.Header) headers["Content-Type"] = []string{"application/json"} config := &MetricConfig{ ID: ID, Name: Name, Description: Description, Query: QueryC...
go
func (builder *MetricBuilder) Config(ID, Name, Description, Start string) (*MetricConfig, error) { //config object to build headers := make(http.Header) headers["Content-Type"] = []string{"application/json"} config := &MetricConfig{ ID: ID, Name: Name, Description: Description, Query: QueryC...
[ "func", "(", "builder", "*", "MetricBuilder", ")", "Config", "(", "ID", ",", "Name", ",", "Description", ",", "Start", "string", ")", "(", "*", "MetricConfig", ",", "error", ")", "{", "//config object to build", "headers", ":=", "make", "(", "http", ".", ...
// Config builds a MetricConfig using all defined MetricRequests and resets the metrics requets
[ "Config", "builds", "a", "MetricConfig", "using", "all", "defined", "MetricRequests", "and", "resets", "the", "metrics", "requets" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/metric.go#L132-L184
139,444
control-center/serviced
domain/metric.go
NewMetricConfigBuilder
func NewMetricConfigBuilder(RequestURI, Method string) (*MetricBuilder, error) { //strip leading '/' it's added back below requestURI := RequestURI if len(RequestURI) > 0 && RequestURI[0] == '/' { requestURI = RequestURI[1:] } logger := plog.WithFields(log.Fields{ "url": RequestURI, "method": Method, }) ...
go
func NewMetricConfigBuilder(RequestURI, Method string) (*MetricBuilder, error) { //strip leading '/' it's added back below requestURI := RequestURI if len(RequestURI) > 0 && RequestURI[0] == '/' { requestURI = RequestURI[1:] } logger := plog.WithFields(log.Fields{ "url": RequestURI, "method": Method, }) ...
[ "func", "NewMetricConfigBuilder", "(", "RequestURI", ",", "Method", "string", ")", "(", "*", "MetricBuilder", ",", "error", ")", "{", "//strip leading '/' it's added back below", "requestURI", ":=", "RequestURI", "\n", "if", "len", "(", "RequestURI", ")", ">", "0"...
// NewMetricConfigBuilder creates a factory to create MetricConfig instances.
[ "NewMetricConfigBuilder", "creates", "a", "factory", "to", "create", "MetricConfig", "instances", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/metric.go#L187-L221
139,445
control-center/serviced
zzk/service/state.go
ParseStateID
func ParseStateID(stateID string) (string, string, int, error) { parts := strings.SplitN(stateID, "-", 3) if len(parts) != 3 { return "", "", 0, ErrInvalidStateID } instanceID, err := strconv.Atoi(parts[2]) if err != nil { return "", "", 0, ErrInvalidStateID } return parts[0], parts[1], instanceID, nil }
go
func ParseStateID(stateID string) (string, string, int, error) { parts := strings.SplitN(stateID, "-", 3) if len(parts) != 3 { return "", "", 0, ErrInvalidStateID } instanceID, err := strconv.Atoi(parts[2]) if err != nil { return "", "", 0, ErrInvalidStateID } return parts[0], parts[1], instanceID, nil }
[ "func", "ParseStateID", "(", "stateID", "string", ")", "(", "string", ",", "string", ",", "int", ",", "error", ")", "{", "parts", ":=", "strings", ".", "SplitN", "(", "stateID", ",", "\"", "\"", ",", "3", ")", "\n", "if", "len", "(", "parts", ")", ...
// ParseStateID returns the host, service, and instance id from the given state // id
[ "ParseStateID", "returns", "the", "host", "service", "and", "instance", "id", "from", "the", "given", "state", "id" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/state.go#L153-L163
139,446
control-center/serviced
zzk/service/state.go
GetState
func GetState(conn client.Connection, req StateRequest) (*State, error) { logger := plog.WithFields(log.Fields{ "hostid": req.HostID, "serviceid": req.ServiceID, "instanceid": req.InstanceID, }) basepth := "/" if req.PoolID != "" { basepth = path.Join("/pools", req.PoolID) } // Get the current host...
go
func GetState(conn client.Connection, req StateRequest) (*State, error) { logger := plog.WithFields(log.Fields{ "hostid": req.HostID, "serviceid": req.ServiceID, "instanceid": req.InstanceID, }) basepth := "/" if req.PoolID != "" { basepth = path.Join("/pools", req.PoolID) } // Get the current host...
[ "func", "GetState", "(", "conn", "client", ".", "Connection", ",", "req", "StateRequest", ")", "(", "*", "State", ",", "error", ")", "{", "logger", ":=", "plog", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "req", ".", "HostID"...
// GetState returns the service state and host state for a particular instance.
[ "GetState", "returns", "the", "service", "state", "and", "host", "state", "for", "a", "particular", "instance", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/state.go#L166-L228
139,447
control-center/serviced
zzk/service/state.go
GetServiceStateHostID
func GetServiceStateHostID(conn client.Connection, poolID, serviceID string, instanceID int) (string, error) { logger := plog.WithFields(log.Fields{ "serviceid": serviceID, "instanceid": instanceID, }) basepth := "/" if poolID != "" { basepth = path.Join("/pools", poolID) } spth := path.Join(basepth, "/s...
go
func GetServiceStateHostID(conn client.Connection, poolID, serviceID string, instanceID int) (string, error) { logger := plog.WithFields(log.Fields{ "serviceid": serviceID, "instanceid": instanceID, }) basepth := "/" if poolID != "" { basepth = path.Join("/pools", poolID) } spth := path.Join(basepth, "/s...
[ "func", "GetServiceStateHostID", "(", "conn", "client", ".", "Connection", ",", "poolID", ",", "serviceID", "string", ",", "instanceID", "int", ")", "(", "string", ",", "error", ")", "{", "logger", ":=", "plog", ".", "WithFields", "(", "log", ".", "Fields"...
// GetServiceStateHostID returns the hostid of the matching service state
[ "GetServiceStateHostID", "returns", "the", "hostid", "of", "the", "matching", "service", "state" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/state.go#L231-L268
139,448
control-center/serviced
zzk/service/state.go
GetServiceStateIDs
func GetServiceStateIDs(conn client.Connection, poolID, serviceID string) ([]StateRequest, error) { logger := plog.WithField("serviceid", serviceID) basepth := "/" if poolID != "" { basepth = path.Join("/pools", poolID) } spth := path.Join(basepth, "/services", serviceID) ch, err := conn.Children(spth) if er...
go
func GetServiceStateIDs(conn client.Connection, poolID, serviceID string) ([]StateRequest, error) { logger := plog.WithField("serviceid", serviceID) basepth := "/" if poolID != "" { basepth = path.Join("/pools", poolID) } spth := path.Join(basepth, "/services", serviceID) ch, err := conn.Children(spth) if er...
[ "func", "GetServiceStateIDs", "(", "conn", "client", ".", "Connection", ",", "poolID", ",", "serviceID", "string", ")", "(", "[", "]", "StateRequest", ",", "error", ")", "{", "logger", ":=", "plog", ".", "WithField", "(", "\"", "\"", ",", "serviceID", ")...
// GetServiceStateIDs returns the parsed state ids of a running service
[ "GetServiceStateIDs", "returns", "the", "parsed", "state", "ids", "of", "a", "running", "service" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/state.go#L271-L307
139,449
control-center/serviced
zzk/service/state.go
CreateState
func CreateState(conn client.Connection, req StateRequest) error { logger := plog.WithFields(log.Fields{ "hostid": req.HostID, "serviceid": req.ServiceID, "instanceid": req.InstanceID, }) basepth := "/" if req.PoolID != "" { basepth = path.Join("/pools", req.PoolID) } t := conn.NewTransaction() /...
go
func CreateState(conn client.Connection, req StateRequest) error { logger := plog.WithFields(log.Fields{ "hostid": req.HostID, "serviceid": req.ServiceID, "instanceid": req.InstanceID, }) basepth := "/" if req.PoolID != "" { basepth = path.Join("/pools", req.PoolID) } t := conn.NewTransaction() /...
[ "func", "CreateState", "(", "conn", "client", ".", "Connection", ",", "req", "StateRequest", ")", "error", "{", "logger", ":=", "plog", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "req", ".", "HostID", ",", "\"", "\"", ":", "r...
// CreateState creates a new service state and host state
[ "CreateState", "creates", "a", "new", "service", "state", "and", "host", "state" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/state.go#L443-L498
139,450
control-center/serviced
zzk/service/state.go
UpdateState
func UpdateState(conn client.Connection, req StateRequest, mutate func(*State) bool) error { logger := plog.WithFields(log.Fields{ "hostid": req.HostID, "serviceid": req.ServiceID, "instanceid": req.InstanceID, }) basepth := "/" if req.PoolID != "" { basepth = path.Join("/pools", req.PoolID) } // G...
go
func UpdateState(conn client.Connection, req StateRequest, mutate func(*State) bool) error { logger := plog.WithFields(log.Fields{ "hostid": req.HostID, "serviceid": req.ServiceID, "instanceid": req.InstanceID, }) basepth := "/" if req.PoolID != "" { basepth = path.Join("/pools", req.PoolID) } // G...
[ "func", "UpdateState", "(", "conn", "client", ".", "Connection", ",", "req", "StateRequest", ",", "mutate", "func", "(", "*", "State", ")", "bool", ")", "error", "{", "logger", ":=", "plog", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\""...
// UpdateState updates the service state and host state
[ "UpdateState", "updates", "the", "service", "state", "and", "host", "state" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/state.go#L501-L587
139,451
control-center/serviced
zzk/service/state.go
DeleteState
func DeleteState(conn client.Connection, req StateRequest) error { // set up logging logger := plog.WithFields(log.Fields{ "hostid": req.HostID, "serviceid": req.ServiceID, "instanceid": req.InstanceID, }) basepth := "/" if req.PoolID != "" { basepth = path.Join("/pools", req.PoolID) } t := conn.N...
go
func DeleteState(conn client.Connection, req StateRequest) error { // set up logging logger := plog.WithFields(log.Fields{ "hostid": req.HostID, "serviceid": req.ServiceID, "instanceid": req.InstanceID, }) basepth := "/" if req.PoolID != "" { basepth = path.Join("/pools", req.PoolID) } t := conn.N...
[ "func", "DeleteState", "(", "conn", "client", ".", "Connection", ",", "req", "StateRequest", ")", "error", "{", "// set up logging", "logger", ":=", "plog", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "req", ".", "HostID", ",", "\...
// DeleteState removes the service state and host state
[ "DeleteState", "removes", "the", "service", "state", "and", "host", "state" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/state.go#L590-L677
139,452
control-center/serviced
zzk/service/state.go
DeleteServiceStates
func DeleteServiceStates(conn client.Connection, poolID, serviceID string) (count int) { logger := plog.WithField("serviceid", serviceID) basepth := "/" if poolID != "" { basepth = path.Join("/pools", poolID) } spth := path.Join(basepth, "/services", serviceID) ch, err := conn.Children(spth) if err != nil &&...
go
func DeleteServiceStates(conn client.Connection, poolID, serviceID string) (count int) { logger := plog.WithField("serviceid", serviceID) basepth := "/" if poolID != "" { basepth = path.Join("/pools", poolID) } spth := path.Join(basepth, "/services", serviceID) ch, err := conn.Children(spth) if err != nil &&...
[ "func", "DeleteServiceStates", "(", "conn", "client", ".", "Connection", ",", "poolID", ",", "serviceID", "string", ")", "(", "count", "int", ")", "{", "logger", ":=", "plog", ".", "WithField", "(", "\"", "\"", ",", "serviceID", ")", "\n\n", "basepth", "...
// DeleteServiceStates returns the number of states deleted from a service
[ "DeleteServiceStates", "returns", "the", "number", "of", "states", "deleted", "from", "a", "service" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/state.go#L680-L725
139,453
control-center/serviced
zzk/service/state.go
IsValidState
func IsValidState(conn client.Connection, req StateRequest) (bool, error) { logger := plog.WithFields(log.Fields{ "hostid": req.HostID, "serviceid": req.ServiceID, "instanceid": req.InstanceID, }) basepth := "/" if req.PoolID != "" { basepth = path.Join("/pools", req.PoolID) } hspth := path.Join(ba...
go
func IsValidState(conn client.Connection, req StateRequest) (bool, error) { logger := plog.WithFields(log.Fields{ "hostid": req.HostID, "serviceid": req.ServiceID, "instanceid": req.InstanceID, }) basepth := "/" if req.PoolID != "" { basepth = path.Join("/pools", req.PoolID) } hspth := path.Join(ba...
[ "func", "IsValidState", "(", "conn", "client", ".", "Connection", ",", "req", "StateRequest", ")", "(", "bool", ",", "error", ")", "{", "logger", ":=", "plog", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "req", ".", "HostID", ...
// IsValidState returns true if both the service state and host state exists.
[ "IsValidState", "returns", "true", "if", "both", "the", "service", "state", "and", "host", "state", "exists", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/state.go#L832-L889
139,454
control-center/serviced
zzk/service/state.go
CleanServiceStates
func CleanServiceStates(conn client.Connection, poolID, serviceID string) error { logger := plog.WithField("serviceid", serviceID) basepth := "/" if poolID != "" { basepth = path.Join("/pools", poolID) } spth := path.Join(basepth, "/services", serviceID) ch, err := conn.Children(spth) if err != nil && err !=...
go
func CleanServiceStates(conn client.Connection, poolID, serviceID string) error { logger := plog.WithField("serviceid", serviceID) basepth := "/" if poolID != "" { basepth = path.Join("/pools", poolID) } spth := path.Join(basepth, "/services", serviceID) ch, err := conn.Children(spth) if err != nil && err !=...
[ "func", "CleanServiceStates", "(", "conn", "client", ".", "Connection", ",", "poolID", ",", "serviceID", "string", ")", "error", "{", "logger", ":=", "plog", ".", "WithField", "(", "\"", "\"", ",", "serviceID", ")", "\n\n", "basepth", ":=", "\"", "\"", "...
// CleanServiceStates deletes service states with invalid state ids or // incongruent data.
[ "CleanServiceStates", "deletes", "service", "states", "with", "invalid", "state", "ids", "or", "incongruent", "data", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/state.go#L962-L1026
139,455
control-center/serviced
dfs/mocks/DFS.go
DfPath
func (_m *DFS) DfPath(path string, excludes []string) (uint64, error) { ret := _m.Called(path, excludes) var r0 uint64 if rf, ok := ret.Get(0).(func(string, []string) uint64); ok { r0 = rf(path, excludes) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(uint64) } } var r1 error if rf, ok := ret.Get(1)...
go
func (_m *DFS) DfPath(path string, excludes []string) (uint64, error) { ret := _m.Called(path, excludes) var r0 uint64 if rf, ok := ret.Get(0).(func(string, []string) uint64); ok { r0 = rf(path, excludes) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(uint64) } } var r1 error if rf, ok := ret.Get(1)...
[ "func", "(", "_m", "*", "DFS", ")", "DfPath", "(", "path", "string", ",", "excludes", "[", "]", "string", ")", "(", "uint64", ",", "error", ")", "{", "ret", ":=", "_m", ".", "Called", "(", "path", ",", "excludes", ")", "\n\n", "var", "r0", "uint6...
// Get free disk space for a path
[ "Get", "free", "disk", "space", "for", "a", "path" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/mocks/DFS.go#L349-L369
139,456
control-center/serviced
isvcs/utils.go
uuid
func uuid() string { f, _ := os.Open(randomSource) defer f.Close() b := make([]byte, 16) f.Read(b) return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]) }
go
func uuid() string { f, _ := os.Open(randomSource) defer f.Close() b := make([]byte, 16) f.Read(b) return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]) }
[ "func", "uuid", "(", ")", "string", "{", "f", ",", "_", ":=", "os", ".", "Open", "(", "randomSource", ")", "\n", "defer", "f", ".", "Close", "(", ")", "\n", "b", ":=", "make", "(", "[", "]", "byte", ",", "16", ")", "\n", "f", ".", "Read", "...
// generate a uuid
[ "generate", "a", "uuid" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/isvcs/utils.go#L45-L51
139,457
control-center/serviced
domain/addressassignment/addressassignment.go
EqualIP
func (assign AddressAssignment) EqualIP(b AddressAssignment) bool { if assign.PoolID != b.PoolID { return false } else if assign.IPAddr == b.IPAddr { return false } else if assign.Port != b.Port { return false } else if assign.ServiceID != b.ServiceID { return false } else if assign.EndpointName != b.Endpo...
go
func (assign AddressAssignment) EqualIP(b AddressAssignment) bool { if assign.PoolID != b.PoolID { return false } else if assign.IPAddr == b.IPAddr { return false } else if assign.Port != b.Port { return false } else if assign.ServiceID != b.ServiceID { return false } else if assign.EndpointName != b.Endpo...
[ "func", "(", "assign", "AddressAssignment", ")", "EqualIP", "(", "b", "AddressAssignment", ")", "bool", "{", "if", "assign", ".", "PoolID", "!=", "b", ".", "PoolID", "{", "return", "false", "\n", "}", "else", "if", "assign", ".", "IPAddr", "==", "b", "...
// EqualIP verifies the address assignment is the same by IP ONLY
[ "EqualIP", "verifies", "the", "address", "assignment", "is", "the", "same", "by", "IP", "ONLY" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/addressassignment/addressassignment.go#L48-L61
139,458
control-center/serviced
coordinator/client/zookeeper/driver.go
NewDSN
func NewDSN(servers []string, sessionTimeout time.Duration, connectTimeout time.Duration, perHostConnectDelay time.Duration, reconnectStartDelay time.Duration, reconnectMaxDelay time.Duration) DSN { dsn := DSN{ Servers: servers, SessionTimeout: sessionTimeout, ConnectTimeout: connectTimeout, PerHos...
go
func NewDSN(servers []string, sessionTimeout time.Duration, connectTimeout time.Duration, perHostConnectDelay time.Duration, reconnectStartDelay time.Duration, reconnectMaxDelay time.Duration) DSN { dsn := DSN{ Servers: servers, SessionTimeout: sessionTimeout, ConnectTimeout: connectTimeout, PerHos...
[ "func", "NewDSN", "(", "servers", "[", "]", "string", ",", "sessionTimeout", "time", ".", "Duration", ",", "connectTimeout", "time", ".", "Duration", ",", "perHostConnectDelay", "time", ".", "Duration", ",", "reconnectStartDelay", "time", ".", "Duration", ",", ...
// NewDSN returns a new DSN object from servers and timeout.
[ "NewDSN", "returns", "a", "new", "DSN", "object", "from", "servers", "and", "timeout", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/coordinator/client/zookeeper/driver.go#L51-L69
139,459
control-center/serviced
coordinator/client/zookeeper/driver.go
GetConnection
func (driver *Driver) GetConnection(dsn, basePath string) (client.Connection, error) { dsnVal, err := ParseDSN(dsn) if err != nil { return nil, err } conn, event, err := zklib.Connect(dsnVal.Servers, dsnVal.SessionTimeout, zklib.WithConnectTimeout(dsnVal.ConnectTimeout), zklib.WithReconnectDelay(dsnVal.Re...
go
func (driver *Driver) GetConnection(dsn, basePath string) (client.Connection, error) { dsnVal, err := ParseDSN(dsn) if err != nil { return nil, err } conn, event, err := zklib.Connect(dsnVal.Servers, dsnVal.SessionTimeout, zklib.WithConnectTimeout(dsnVal.ConnectTimeout), zklib.WithReconnectDelay(dsnVal.Re...
[ "func", "(", "driver", "*", "Driver", ")", "GetConnection", "(", "dsn", ",", "basePath", "string", ")", "(", "client", ".", "Connection", ",", "error", ")", "{", "dsnVal", ",", "err", ":=", "ParseDSN", "(", "dsn", ")", "\n", "if", "err", "!=", "nil",...
// GetConnection returns a Zookeeper connection given the dsn. The caller is // responsible for closing the returned connection.
[ "GetConnection", "returns", "a", "Zookeeper", "connection", "given", "the", "dsn", ".", "The", "caller", "is", "responsible", "for", "closing", "the", "returned", "connection", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/coordinator/client/zookeeper/driver.go#L88-L138
139,460
control-center/serviced
facade/logfilter.go
BootstrapLogFilters
func (f *Facade) BootstrapLogFilters(ctx datastore.Context) (bool, error) { logFiltersCreated := false templates, err := f.GetServiceTemplates(ctx) if err != nil { plog.WithError(err).Error("Could not retrieve service templates") return false, err } for _, template := range templates { logger := plog.WithFi...
go
func (f *Facade) BootstrapLogFilters(ctx datastore.Context) (bool, error) { logFiltersCreated := false templates, err := f.GetServiceTemplates(ctx) if err != nil { plog.WithError(err).Error("Could not retrieve service templates") return false, err } for _, template := range templates { logger := plog.WithFi...
[ "func", "(", "f", "*", "Facade", ")", "BootstrapLogFilters", "(", "ctx", "datastore", ".", "Context", ")", "(", "bool", ",", "error", ")", "{", "logFiltersCreated", ":=", "false", "\n", "templates", ",", "err", ":=", "f", ".", "GetServiceTemplates", "(", ...
// Bootstraps the LogFilter store in cases where templates were added to the system in some prior CC version which // did not have a separate store for LogFilters. For cases like that, this code creates new records in the // LogFilter store for each logfilter found in an existing service template.
[ "Bootstraps", "the", "LogFilter", "store", "in", "cases", "where", "templates", "were", "added", "to", "the", "system", "in", "some", "prior", "CC", "version", "which", "did", "not", "have", "a", "separate", "store", "for", "LogFilters", ".", "For", "cases",...
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/logfilter.go#L87-L129
139,461
control-center/serviced
coordinator/client/retry/loop.go
NewLoop
func NewLoop(policy Policy, cancelable func(chan chan error) chan error) Loop { loop := Loop{ startTime: time.Now(), retryPolicy: policy, cancelable: cancelable, waiting: make(chan error, 1), closing: make(chan chan error), } go loop.loop() return loop }
go
func NewLoop(policy Policy, cancelable func(chan chan error) chan error) Loop { loop := Loop{ startTime: time.Now(), retryPolicy: policy, cancelable: cancelable, waiting: make(chan error, 1), closing: make(chan chan error), } go loop.loop() return loop }
[ "func", "NewLoop", "(", "policy", "Policy", ",", "cancelable", "func", "(", "chan", "chan", "error", ")", "chan", "error", ")", "Loop", "{", "loop", ":=", "Loop", "{", "startTime", ":", "time", ".", "Now", "(", ")", ",", "retryPolicy", ":", "policy", ...
// NewLoop creates a loop object that executes the cancelable function according to the // given policy
[ "NewLoop", "creates", "a", "loop", "object", "that", "executes", "the", "cancelable", "function", "according", "to", "the", "given", "policy" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/coordinator/client/retry/loop.go#L35-L45
139,462
control-center/serviced
coordinator/client/retry/loop.go
Close
func (loop Loop) Close() error { errc := make(chan error) loop.closing <- errc return <-errc }
go
func (loop Loop) Close() error { errc := make(chan error) loop.closing <- errc return <-errc }
[ "func", "(", "loop", "Loop", ")", "Close", "(", ")", "error", "{", "errc", ":=", "make", "(", "chan", "error", ")", "\n", "loop", ".", "closing", "<-", "errc", "\n", "return", "<-", "errc", "\n", "}" ]
// Close stops the loop construct from attempting retries and notifies the running function to shutdown
[ "Close", "stops", "the", "loop", "construct", "from", "attempting", "retries", "and", "notifies", "the", "running", "function", "to", "shutdown" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/coordinator/client/retry/loop.go#L95-L99
139,463
control-center/serviced
zzk/service/hostunassign.go
UnassignAll
func (h *ZKHostUnassignmentHandler) UnassignAll(poolID, hostID string) error { path := Base().Pools().ID(poolID).Hosts().ID(hostID).IPs().Path() exists, err := h.connection.Exists(path) if err != nil { return err } if !exists { return nil } ipIDs, err := h.connection.Children(path) if err != nil { retur...
go
func (h *ZKHostUnassignmentHandler) UnassignAll(poolID, hostID string) error { path := Base().Pools().ID(poolID).Hosts().ID(hostID).IPs().Path() exists, err := h.connection.Exists(path) if err != nil { return err } if !exists { return nil } ipIDs, err := h.connection.Children(path) if err != nil { retur...
[ "func", "(", "h", "*", "ZKHostUnassignmentHandler", ")", "UnassignAll", "(", "poolID", ",", "hostID", "string", ")", "error", "{", "path", ":=", "Base", "(", ")", ".", "Pools", "(", ")", ".", "ID", "(", "poolID", ")", ".", "Hosts", "(", ")", ".", "...
// UnassignAll will remove all virtual IP nodes for a host in ZooKeeper.
[ "UnassignAll", "will", "remove", "all", "virtual", "IP", "nodes", "for", "a", "host", "in", "ZooKeeper", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/hostunassign.go#L44-L79
139,464
control-center/serviced
facade/health.go
ReportHealthStatus
func (f *Facade) ReportHealthStatus(key health.HealthStatusKey, value health.HealthStatus, expires time.Duration) { f.hcache.Set(key, value, expires) }
go
func (f *Facade) ReportHealthStatus(key health.HealthStatusKey, value health.HealthStatus, expires time.Duration) { f.hcache.Set(key, value, expires) }
[ "func", "(", "f", "*", "Facade", ")", "ReportHealthStatus", "(", "key", "health", ".", "HealthStatusKey", ",", "value", "health", ".", "HealthStatus", ",", "expires", "time", ".", "Duration", ")", "{", "f", ".", "hcache", ".", "Set", "(", "key", ",", "...
// ReportHealthStatus writes the status of a health check to the cache.
[ "ReportHealthStatus", "writes", "the", "status", "of", "a", "health", "check", "to", "the", "cache", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/health.go#L27-L29
139,465
control-center/serviced
facade/health.go
ReportInstanceDead
func (f *Facade) ReportInstanceDead(serviceID string, instanceID int) { f.hcache.DeleteInstance(serviceID, instanceID) }
go
func (f *Facade) ReportInstanceDead(serviceID string, instanceID int) { f.hcache.DeleteInstance(serviceID, instanceID) }
[ "func", "(", "f", "*", "Facade", ")", "ReportInstanceDead", "(", "serviceID", "string", ",", "instanceID", "int", ")", "{", "f", ".", "hcache", ".", "DeleteInstance", "(", "serviceID", ",", "instanceID", ")", "\n", "}" ]
// ReportInstanceDead removes all health checks of a particular instance from // the cache.
[ "ReportInstanceDead", "removes", "all", "health", "checks", "of", "a", "particular", "instance", "from", "the", "cache", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/health.go#L33-L35
139,466
control-center/serviced
facade/health.go
GetServicesHealth
func (f *Facade) GetServicesHealth(ctx datastore.Context) (map[string]map[int]map[string]health.HealthStatus, error) { defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetServicesHealth")) store := f.serviceStore shs, err := store.GetAllServiceHealth(ctx) if err != nil { glog.Errorf("Could not look up service...
go
func (f *Facade) GetServicesHealth(ctx datastore.Context) (map[string]map[int]map[string]health.HealthStatus, error) { defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetServicesHealth")) store := f.serviceStore shs, err := store.GetAllServiceHealth(ctx) if err != nil { glog.Errorf("Could not look up service...
[ "func", "(", "f", "*", "Facade", ")", "GetServicesHealth", "(", "ctx", "datastore", ".", "Context", ")", "(", "map", "[", "string", "]", "map", "[", "int", "]", "map", "[", "string", "]", "health", ".", "HealthStatus", ",", "error", ")", "{", "defer"...
// GetServicesHealth returns the status of all services health instances.
[ "GetServicesHealth", "returns", "the", "status", "of", "all", "services", "health", "instances", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/health.go#L38-L54
139,467
control-center/serviced
facade/health.go
GetServiceHealth
func (f *Facade) GetServiceHealth(ctx datastore.Context, serviceID string) (map[int]map[string]health.HealthStatus, error) { defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetServiceHealth")) store := f.serviceStore sh, err := store.GetServiceHealth(ctx, serviceID) if err != nil { glog.Errorf("Could not loo...
go
func (f *Facade) GetServiceHealth(ctx datastore.Context, serviceID string) (map[int]map[string]health.HealthStatus, error) { defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetServiceHealth")) store := f.serviceStore sh, err := store.GetServiceHealth(ctx, serviceID) if err != nil { glog.Errorf("Could not loo...
[ "func", "(", "f", "*", "Facade", ")", "GetServiceHealth", "(", "ctx", "datastore", ".", "Context", ",", "serviceID", "string", ")", "(", "map", "[", "int", "]", "map", "[", "string", "]", "health", ".", "HealthStatus", ",", "error", ")", "{", "defer", ...
// GetServiceHealth returns the status of all health instances.
[ "GetServiceHealth", "returns", "the", "status", "of", "all", "health", "instances", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/health.go#L57-L66
139,468
control-center/serviced
zzk/service/pool.go
UpdateResourcePool
func UpdateResourcePool(conn client.Connection, p pool.ResourcePool) error { pth := path.Join("/pools", p.ID) logger := plog.WithFields(log.Fields{ "poolid": p.ID, "zkpath": pth, }) // create the resource pool if it doesn't exist if err := conn.Create(pth, &PoolNode{ResourcePool: &p}); err == client.ErrNodeE...
go
func UpdateResourcePool(conn client.Connection, p pool.ResourcePool) error { pth := path.Join("/pools", p.ID) logger := plog.WithFields(log.Fields{ "poolid": p.ID, "zkpath": pth, }) // create the resource pool if it doesn't exist if err := conn.Create(pth, &PoolNode{ResourcePool: &p}); err == client.ErrNodeE...
[ "func", "UpdateResourcePool", "(", "conn", "client", ".", "Connection", ",", "p", "pool", ".", "ResourcePool", ")", "error", "{", "pth", ":=", "path", ".", "Join", "(", "\"", "\"", ",", "p", ".", "ID", ")", "\n\n", "logger", ":=", "plog", ".", "WithF...
// UpdateResourcePool creates the resource pool if it doesn't exist or updates // it if it does exist.
[ "UpdateResourcePool", "creates", "the", "resource", "pool", "if", "it", "doesn", "t", "exist", "or", "updates", "it", "if", "it", "does", "exist", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/pool.go#L42-L78
139,469
control-center/serviced
zzk/service/pool.go
RemoveResourcePool
func RemoveResourcePool(conn client.Connection, poolid string) error { pth := path.Join("/pools", poolid) logger := plog.WithFields(log.Fields{ "poolid": poolid, "zkpath": pth, }) if err := conn.Delete(pth); err != nil { logger.WithError(err).Debug("Could not delete resource pool entry from zookeeper") r...
go
func RemoveResourcePool(conn client.Connection, poolid string) error { pth := path.Join("/pools", poolid) logger := plog.WithFields(log.Fields{ "poolid": poolid, "zkpath": pth, }) if err := conn.Delete(pth); err != nil { logger.WithError(err).Debug("Could not delete resource pool entry from zookeeper") r...
[ "func", "RemoveResourcePool", "(", "conn", "client", ".", "Connection", ",", "poolid", "string", ")", "error", "{", "pth", ":=", "path", ".", "Join", "(", "\"", "\"", ",", "poolid", ")", "\n\n", "logger", ":=", "plog", ".", "WithFields", "(", "log", "....
// RemoveResourcePool removes the resource pool
[ "RemoveResourcePool", "removes", "the", "resource", "pool" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/pool.go#L81-L97
139,470
control-center/serviced
zzk/service/pool.go
SyncResourcePools
func SyncResourcePools(conn client.Connection, pools []pool.ResourcePool) error { pth := path.Join("/pools") logger := plog.WithField("zkpath", pth) // look up the children pool ids ch, err := conn.Children(pth) if err != nil && err != client.ErrNoNode { logger.WithError(err).Debug("Could not look up resource ...
go
func SyncResourcePools(conn client.Connection, pools []pool.ResourcePool) error { pth := path.Join("/pools") logger := plog.WithField("zkpath", pth) // look up the children pool ids ch, err := conn.Children(pth) if err != nil && err != client.ErrNoNode { logger.WithError(err).Debug("Could not look up resource ...
[ "func", "SyncResourcePools", "(", "conn", "client", ".", "Connection", ",", "pools", "[", "]", "pool", ".", "ResourcePool", ")", "error", "{", "pth", ":=", "path", ".", "Join", "(", "\"", "\"", ")", "\n\n", "logger", ":=", "plog", ".", "WithField", "("...
// SyncResourcePools synchronizes the resource pools to the provided list
[ "SyncResourcePools", "synchronizes", "the", "resource", "pools", "to", "the", "provided", "list" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/pool.go#L100-L137
139,471
control-center/serviced
commons/statistics/ols.go
Mean
func Mean(series []float64) float64 { var n, x, sum float64 for _, x = range series { sum += x n++ } return sum / n }
go
func Mean(series []float64) float64 { var n, x, sum float64 for _, x = range series { sum += x n++ } return sum / n }
[ "func", "Mean", "(", "series", "[", "]", "float64", ")", "float64", "{", "var", "n", ",", "x", ",", "sum", "float64", "\n", "for", "_", ",", "x", "=", "range", "series", "{", "sum", "+=", "x", "\n", "n", "++", "\n", "}", "\n", "return", "sum", ...
// Mean calculates the mean of an array of floats
[ "Mean", "calculates", "the", "mean", "of", "an", "array", "of", "floats" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/statistics/ols.go#L24-L31
139,472
control-center/serviced
commons/statistics/ols.go
LeastSquares
func LeastSquares(xs, ys []float64) (m, b float64, err error) { lx, ly := len(xs), len(ys) // If the arrays are not of equal length, we can't do anything if lx != ly { err = ErrUnequalArrays return } // If we don't have at least two points, we can't do anything if lx < 2 { err = ErrInsufficientData ret...
go
func LeastSquares(xs, ys []float64) (m, b float64, err error) { lx, ly := len(xs), len(ys) // If the arrays are not of equal length, we can't do anything if lx != ly { err = ErrUnequalArrays return } // If we don't have at least two points, we can't do anything if lx < 2 { err = ErrInsufficientData ret...
[ "func", "LeastSquares", "(", "xs", ",", "ys", "[", "]", "float64", ")", "(", "m", ",", "b", "float64", ",", "err", "error", ")", "{", "lx", ",", "ly", ":=", "len", "(", "xs", ")", ",", "len", "(", "ys", ")", "\n\n", "// If the arrays are not of equ...
// LeastSquares calculates the slope and y-intercept of the line of best fit // for the series of points represented as arrays of x- and y-coordinates using // the Ordinary Least Squares method.
[ "LeastSquares", "calculates", "the", "slope", "and", "y", "-", "intercept", "of", "the", "line", "of", "best", "fit", "for", "the", "series", "of", "points", "represented", "as", "arrays", "of", "x", "-", "and", "y", "-", "coordinates", "using", "the", "...
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/statistics/ols.go#L36-L81
139,473
control-center/serviced
zzk/service/synchronizer.go
Sync
func (s *ZKVirtualIPSynchronizer) Sync(pool p.ResourcePool, assignments map[string]string) error { virtualIPMap := s.getVirtualIPMap(pool) errorList := SyncError{} for _, ip := range s.virtualIPsWithNoAssignment(virtualIPMap, assignments) { err := s.handler.Assign(ip.PoolID, ip.IP, ip.Netmask, ip.BindInterface) ...
go
func (s *ZKVirtualIPSynchronizer) Sync(pool p.ResourcePool, assignments map[string]string) error { virtualIPMap := s.getVirtualIPMap(pool) errorList := SyncError{} for _, ip := range s.virtualIPsWithNoAssignment(virtualIPMap, assignments) { err := s.handler.Assign(ip.PoolID, ip.IP, ip.Netmask, ip.BindInterface) ...
[ "func", "(", "s", "*", "ZKVirtualIPSynchronizer", ")", "Sync", "(", "pool", "p", ".", "ResourcePool", ",", "assignments", "map", "[", "string", "]", "string", ")", "error", "{", "virtualIPMap", ":=", "s", ".", "getVirtualIPMap", "(", "pool", ")", "\n\n", ...
// Sync will synchronize virtual IP assignments for a pool. It will assign virtual IPs that // are not assigned to a host. It will unassign any active assignments if the virtual IP as been // removed from the pool.
[ "Sync", "will", "synchronize", "virtual", "IP", "assignments", "for", "a", "pool", ".", "It", "will", "assign", "virtual", "IPs", "that", "are", "not", "assigned", "to", "a", "host", ".", "It", "will", "unassign", "any", "active", "assignments", "if", "the...
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/service/synchronizer.go#L44-L67
139,474
control-center/serviced
cli/api/snapshot.go
GetSnapshots
func (a *api) GetSnapshots() ([]dao.SnapshotInfo, error) { services, err := a.GetAllServiceDetails() if err != nil { return nil, err } // Get only unique snapshots as defined by the tenant ID svcmap := NewServiceMap(services) var snapshots []dao.SnapshotInfo for _, s := range svcmap.Tree()[""] { ss, err := ...
go
func (a *api) GetSnapshots() ([]dao.SnapshotInfo, error) { services, err := a.GetAllServiceDetails() if err != nil { return nil, err } // Get only unique snapshots as defined by the tenant ID svcmap := NewServiceMap(services) var snapshots []dao.SnapshotInfo for _, s := range svcmap.Tree()[""] { ss, err := ...
[ "func", "(", "a", "*", "api", ")", "GetSnapshots", "(", ")", "(", "[", "]", "dao", ".", "SnapshotInfo", ",", "error", ")", "{", "services", ",", "err", ":=", "a", ".", "GetAllServiceDetails", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return",...
// Lists all snapshots on the DFS
[ "Lists", "all", "snapshots", "on", "the", "DFS" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/snapshot.go#L31-L49
139,475
control-center/serviced
cli/api/snapshot.go
GetSnapshotsByServiceID
func (a *api) GetSnapshotsByServiceID(serviceID string) ([]dao.SnapshotInfo, error) { client, err := a.connectDAO() if err != nil { return nil, err } var snapshots []dao.SnapshotInfo if err := client.ListSnapshots(serviceID, &snapshots); err != nil { return nil, err } return snapshots, nil }
go
func (a *api) GetSnapshotsByServiceID(serviceID string) ([]dao.SnapshotInfo, error) { client, err := a.connectDAO() if err != nil { return nil, err } var snapshots []dao.SnapshotInfo if err := client.ListSnapshots(serviceID, &snapshots); err != nil { return nil, err } return snapshots, nil }
[ "func", "(", "a", "*", "api", ")", "GetSnapshotsByServiceID", "(", "serviceID", "string", ")", "(", "[", "]", "dao", ".", "SnapshotInfo", ",", "error", ")", "{", "client", ",", "err", ":=", "a", ".", "connectDAO", "(", ")", "\n", "if", "err", "!=", ...
// Lists all snapshots for a given service
[ "Lists", "all", "snapshots", "for", "a", "given", "service" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/snapshot.go#L52-L64
139,476
control-center/serviced
cli/api/snapshot.go
GetSnapshotByServiceIDAndTag
func (a *api) GetSnapshotByServiceIDAndTag(serviceID string, tag string) (string, error) { client, err := a.connectDAO() if err != nil { return "", err } req := dao.SnapshotByTagRequest{ ServiceID: serviceID, TagName: tag, } var snapshot dao.SnapshotInfo if err := client.GetSnapshotByServiceIDAndTag(req...
go
func (a *api) GetSnapshotByServiceIDAndTag(serviceID string, tag string) (string, error) { client, err := a.connectDAO() if err != nil { return "", err } req := dao.SnapshotByTagRequest{ ServiceID: serviceID, TagName: tag, } var snapshot dao.SnapshotInfo if err := client.GetSnapshotByServiceIDAndTag(req...
[ "func", "(", "a", "*", "api", ")", "GetSnapshotByServiceIDAndTag", "(", "serviceID", "string", ",", "tag", "string", ")", "(", "string", ",", "error", ")", "{", "client", ",", "err", ":=", "a", ".", "connectDAO", "(", ")", "\n", "if", "err", "!=", "n...
// Get the ID of the snapshot for serviceID that has the given tag
[ "Get", "the", "ID", "of", "the", "snapshot", "for", "serviceID", "that", "has", "the", "given", "tag" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/snapshot.go#L67-L83
139,477
control-center/serviced
cli/api/snapshot.go
AddSnapshot
func (a *api) AddSnapshot(cfg SnapshotConfig) (string, error) { client, err := a.connectDAO() if err != nil { return "", err } req := dao.SnapshotRequest{ ServiceID: cfg.ServiceID, Message: cfg.Message, Tag: cfg.Tag, ContainerID: cfg.DockerID, SnapshotSp...
go
func (a *api) AddSnapshot(cfg SnapshotConfig) (string, error) { client, err := a.connectDAO() if err != nil { return "", err } req := dao.SnapshotRequest{ ServiceID: cfg.ServiceID, Message: cfg.Message, Tag: cfg.Tag, ContainerID: cfg.DockerID, SnapshotSp...
[ "func", "(", "a", "*", "api", ")", "AddSnapshot", "(", "cfg", "SnapshotConfig", ")", "(", "string", ",", "error", ")", "{", "client", ",", "err", ":=", "a", ".", "connectDAO", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", "...
// Snapshots a service
[ "Snapshots", "a", "service" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/snapshot.go#L86-L104
139,478
control-center/serviced
cli/api/snapshot.go
RemoveSnapshot
func (a *api) RemoveSnapshot(snapshotID string) error { client, err := a.connectDAO() if err != nil { return err } if err := client.DeleteSnapshot(snapshotID, &unusedInt); err != nil { return err } return nil }
go
func (a *api) RemoveSnapshot(snapshotID string) error { client, err := a.connectDAO() if err != nil { return err } if err := client.DeleteSnapshot(snapshotID, &unusedInt); err != nil { return err } return nil }
[ "func", "(", "a", "*", "api", ")", "RemoveSnapshot", "(", "snapshotID", "string", ")", "error", "{", "client", ",", "err", ":=", "a", ".", "connectDAO", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "err",...
// Deletes a snapshot
[ "Deletes", "a", "snapshot" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/snapshot.go#L107-L118
139,479
control-center/serviced
cli/api/snapshot.go
Rollback
func (a *api) Rollback(snapshotID string, forceRestart bool) error { client, err := a.connectDAO() if err != nil { return err } if err := client.Rollback(dao.RollbackRequest{snapshotID, forceRestart}, &unusedInt); err != nil { return err } return nil }
go
func (a *api) Rollback(snapshotID string, forceRestart bool) error { client, err := a.connectDAO() if err != nil { return err } if err := client.Rollback(dao.RollbackRequest{snapshotID, forceRestart}, &unusedInt); err != nil { return err } return nil }
[ "func", "(", "a", "*", "api", ")", "Rollback", "(", "snapshotID", "string", ",", "forceRestart", "bool", ")", "error", "{", "client", ",", "err", ":=", "a", ".", "connectDAO", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}...
// Rollback rolls back the system to the state of the given snapshot
[ "Rollback", "rolls", "back", "the", "system", "to", "the", "state", "of", "the", "given", "snapshot" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/snapshot.go#L121-L132
139,480
control-center/serviced
cli/api/snapshot.go
TagSnapshot
func (a *api) TagSnapshot(snapshotID string, tagName string) error { client, err := a.connectDAO() if err != nil { return err } if err := client.TagSnapshot(dao.TagSnapshotRequest{snapshotID, tagName}, &unusedInt); err != nil { return err } return nil }
go
func (a *api) TagSnapshot(snapshotID string, tagName string) error { client, err := a.connectDAO() if err != nil { return err } if err := client.TagSnapshot(dao.TagSnapshotRequest{snapshotID, tagName}, &unusedInt); err != nil { return err } return nil }
[ "func", "(", "a", "*", "api", ")", "TagSnapshot", "(", "snapshotID", "string", ",", "tagName", "string", ")", "error", "{", "client", ",", "err", ":=", "a", ".", "connectDAO", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}...
// TagSnapshot tags an existing snapshot with 1 or more strings
[ "TagSnapshot", "tags", "an", "existing", "snapshot", "with", "1", "or", "more", "strings" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/snapshot.go#L135-L144
139,481
control-center/serviced
validation/validators.go
NotEmpty
func NotEmpty(fieldName string, value string) error { if strings.TrimSpace(value) == "" { return NewViolation(fmt.Sprintf("empty string for %v", fieldName)) } return nil }
go
func NotEmpty(fieldName string, value string) error { if strings.TrimSpace(value) == "" { return NewViolation(fmt.Sprintf("empty string for %v", fieldName)) } return nil }
[ "func", "NotEmpty", "(", "fieldName", "string", ",", "value", "string", ")", "error", "{", "if", "strings", ".", "TrimSpace", "(", "value", ")", "==", "\"", "\"", "{", "return", "NewViolation", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "fieldNa...
//NotEmpty check to see if the value is not an empty string or a string with just whitespace characters, returns an // error if empty. FieldName is used to create a meaningful error
[ "NotEmpty", "check", "to", "see", "if", "the", "value", "is", "not", "an", "empty", "string", "or", "a", "string", "with", "just", "whitespace", "characters", "returns", "an", "error", "if", "empty", ".", "FieldName", "is", "used", "to", "create", "a", "...
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/validation/validators.go#L25-L30
139,482
control-center/serviced
validation/validators.go
ExcludeChars
func ExcludeChars(fieldName, value, chars string) error { if strings.ContainsAny(value, chars) { return NewViolation(fmt.Sprintf("invalid chars for %s", fieldName)) } return nil }
go
func ExcludeChars(fieldName, value, chars string) error { if strings.ContainsAny(value, chars) { return NewViolation(fmt.Sprintf("invalid chars for %s", fieldName)) } return nil }
[ "func", "ExcludeChars", "(", "fieldName", ",", "value", ",", "chars", "string", ")", "error", "{", "if", "strings", ".", "ContainsAny", "(", "value", ",", "chars", ")", "{", "return", "NewViolation", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "f...
// ExcludeChars makes sure there characters in a field are valid
[ "ExcludeChars", "makes", "sure", "there", "characters", "in", "a", "field", "are", "valid" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/validation/validators.go#L33-L38
139,483
control-center/serviced
validation/validators.go
IsIP
func IsIP(value string) error { if nil == net.ParseIP(value) { return NewViolation(fmt.Sprintf("invalid IP Address %s", value)) } return nil }
go
func IsIP(value string) error { if nil == net.ParseIP(value) { return NewViolation(fmt.Sprintf("invalid IP Address %s", value)) } return nil }
[ "func", "IsIP", "(", "value", "string", ")", "error", "{", "if", "nil", "==", "net", ".", "ParseIP", "(", "value", ")", "{", "return", "NewViolation", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "value", ")", ")", "\n", "}", "\n", "return", ...
//IsIP checks to see if the value is a valid IP address. Returns an error if not valid
[ "IsIP", "checks", "to", "see", "if", "the", "value", "is", "a", "valid", "IP", "address", ".", "Returns", "an", "error", "if", "not", "valid" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/validation/validators.go#L41-L46
139,484
control-center/serviced
validation/validators.go
IsSubnetCIDR
func IsSubnetCIDR(value string) error { _, _, err := net.ParseCIDR(value) if nil != err { return NewViolation(fmt.Sprintf("invalid subnet %s", value)) } return nil }
go
func IsSubnetCIDR(value string) error { _, _, err := net.ParseCIDR(value) if nil != err { return NewViolation(fmt.Sprintf("invalid subnet %s", value)) } return nil }
[ "func", "IsSubnetCIDR", "(", "value", "string", ")", "error", "{", "_", ",", "_", ",", "err", ":=", "net", ".", "ParseCIDR", "(", "value", ")", "\n", "if", "nil", "!=", "err", "{", "return", "NewViolation", "(", "fmt", ".", "Sprintf", "(", "\"", "\...
//IsSubnetCIDR checks to see if the value is a valid cidr subnet. Returns an error if not valid
[ "IsSubnetCIDR", "checks", "to", "see", "if", "the", "value", "is", "a", "valid", "cidr", "subnet", ".", "Returns", "an", "error", "if", "not", "valid" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/validation/validators.go#L63-L69
139,485
control-center/serviced
container/proxy.go
newProxy
func newProxy(name, tenantEndpointID string, tcpMuxPort uint16, useTLS bool, listener net.Listener, allowDirectConn bool) (p *proxy, err error) { if len(name) == 0 { return nil, fmt.Errorf("prxy: name can not be empty") } p = &proxy{ name: name, tenantEndpointID: tenantEndpointID, addresses: ...
go
func newProxy(name, tenantEndpointID string, tcpMuxPort uint16, useTLS bool, listener net.Listener, allowDirectConn bool) (p *proxy, err error) { if len(name) == 0 { return nil, fmt.Errorf("prxy: name can not be empty") } p = &proxy{ name: name, tenantEndpointID: tenantEndpointID, addresses: ...
[ "func", "newProxy", "(", "name", ",", "tenantEndpointID", "string", ",", "tcpMuxPort", "uint16", ",", "useTLS", "bool", ",", "listener", "net", ".", "Listener", ",", "allowDirectConn", "bool", ")", "(", "p", "*", "proxy", ",", "err", "error", ")", "{", "...
// Newproxy create a new proxy object. It starts listening on the prxy port asynchronously.
[ "Newproxy", "create", "a", "new", "proxy", "object", ".", "It", "starts", "listening", "on", "the", "prxy", "port", "asynchronously", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/proxy.go#L92-L108
139,486
control-center/serviced
container/proxy.go
SetNewAddresses
func (p *proxy) SetNewAddresses(addresses []addressTuple) { // Randomize the addresses so not all instances get them in the same order dest := make([]addressTuple, len(addresses)) perm := rand.Perm(len(addresses)) for i, v := range perm { dest[v] = addresses[i] } p.newAddresses <- dest }
go
func (p *proxy) SetNewAddresses(addresses []addressTuple) { // Randomize the addresses so not all instances get them in the same order dest := make([]addressTuple, len(addresses)) perm := rand.Perm(len(addresses)) for i, v := range perm { dest[v] = addresses[i] } p.newAddresses <- dest }
[ "func", "(", "p", "*", "proxy", ")", "SetNewAddresses", "(", "addresses", "[", "]", "addressTuple", ")", "{", "// Randomize the addresses so not all instances get them in the same order", "dest", ":=", "make", "(", "[", "]", "addressTuple", ",", "len", "(", "address...
// Set a new Destination Address set for the prxy
[ "Set", "a", "new", "Destination", "Address", "set", "for", "the", "prxy" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/proxy.go#L131-L139
139,487
control-center/serviced
container/proxy.go
listenAndproxy
func (p *proxy) listenAndproxy() { connections := make(chan net.Conn) go func(lsocket net.Listener, conns chan net.Conn) { for { conn, err := lsocket.Accept() if err != nil { glog.Fatal("Error (net.Accept): ", err) } conns <- conn } }(p.listener, connections) i := 0 for { select { case co...
go
func (p *proxy) listenAndproxy() { connections := make(chan net.Conn) go func(lsocket net.Listener, conns chan net.Conn) { for { conn, err := lsocket.Accept() if err != nil { glog.Fatal("Error (net.Accept): ", err) } conns <- conn } }(p.listener, connections) i := 0 for { select { case co...
[ "func", "(", "p", "*", "proxy", ")", "listenAndproxy", "(", ")", "{", "connections", ":=", "make", "(", "chan", "net", ".", "Conn", ")", "\n", "go", "func", "(", "lsocket", "net", ".", "Listener", ",", "conns", "chan", "net", ".", "Conn", ")", "{",...
// listenAndproxy listens, locally, on the prxy's specified Port. For each // incoming connection a goroutine running the prxy method is created.
[ "listenAndproxy", "listens", "locally", "on", "the", "prxy", "s", "specified", "Port", ".", "For", "each", "incoming", "connection", "a", "goroutine", "running", "the", "prxy", "method", "is", "created", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/container/proxy.go#L151-L184
139,488
control-center/serviced
volume/utils.go
Labels
func (p FileInfoSlice) Labels() []string { // This would probably be very slightly more efficient with a heap, but the // API would be more complicated sort.Sort(p) labels := make([]string, p.Len()) for i, label := range p { labels[i] = label.Name() } return labels }
go
func (p FileInfoSlice) Labels() []string { // This would probably be very slightly more efficient with a heap, but the // API would be more complicated sort.Sort(p) labels := make([]string, p.Len()) for i, label := range p { labels[i] = label.Name() } return labels }
[ "func", "(", "p", "FileInfoSlice", ")", "Labels", "(", ")", "[", "]", "string", "{", "// This would probably be very slightly more efficient with a heap, but the", "// API would be more complicated", "sort", ".", "Sort", "(", "p", ")", "\n", "labels", ":=", "make", "(...
// Labels will return the names of the files in the slice, sorted by modification time
[ "Labels", "will", "return", "the", "names", "of", "the", "files", "in", "the", "slice", "sorted", "by", "modification", "time" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/utils.go#L72-L81
139,489
control-center/serviced
volume/utils.go
RunBtrFSCmd
func RunBtrFSCmd(sudoer bool, args ...string) ([]byte, error) { cmd := append([]string{"btrfs"}, args...) if sudoer { cmd = append([]string{"sudo", "-n"}, cmd...) } glog.V(4).Infof("Executing: %v", cmd) output, err := exec.Command(cmd[0], cmd[1:]...).CombinedOutput() if err != nil { glog.V(1).Infof("unable to...
go
func RunBtrFSCmd(sudoer bool, args ...string) ([]byte, error) { cmd := append([]string{"btrfs"}, args...) if sudoer { cmd = append([]string{"sudo", "-n"}, cmd...) } glog.V(4).Infof("Executing: %v", cmd) output, err := exec.Command(cmd[0], cmd[1:]...).CombinedOutput() if err != nil { glog.V(1).Infof("unable to...
[ "func", "RunBtrFSCmd", "(", "sudoer", "bool", ",", "args", "...", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "cmd", ":=", "append", "(", "[", "]", "string", "{", "\"", "\"", "}", ",", "args", "...", ")", "\n", "if", "sudoer", ...
// RunBtrFSCmd runs a btrfs command, optionally using sudo
[ "RunBtrFSCmd", "runs", "a", "btrfs", "command", "optionally", "using", "sudo" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/utils.go#L101-L113
139,490
control-center/serviced
volume/utils.go
IsBtrfsFilesystem
func IsBtrfsFilesystem(path string) bool { _, err := RunBtrFSCmd(false, "filesystem", "df", path) return err == nil }
go
func IsBtrfsFilesystem(path string) bool { _, err := RunBtrFSCmd(false, "filesystem", "df", path) return err == nil }
[ "func", "IsBtrfsFilesystem", "(", "path", "string", ")", "bool", "{", "_", ",", "err", ":=", "RunBtrFSCmd", "(", "false", ",", "\"", "\"", ",", "\"", "\"", ",", "path", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// IsBtrfsFilesystem determines whether the path is a btrfs filesystem
[ "IsBtrfsFilesystem", "determines", "whether", "the", "path", "is", "a", "btrfs", "filesystem" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/utils.go#L116-L119
139,491
control-center/serviced
volume/devicemapper/metadata.go
load
func (m *SnapshotMetadata) load() error { // This is not safe for concurrent access. // Exported methods will deal with locking. jsonData, err := ioutil.ReadFile(m.path) if jsonData == nil || os.IsNotExist(err) { m.save() } else { if err := json.Unmarshal(jsonData, &m.snapshotMetadata); err != nil { return ...
go
func (m *SnapshotMetadata) load() error { // This is not safe for concurrent access. // Exported methods will deal with locking. jsonData, err := ioutil.ReadFile(m.path) if jsonData == nil || os.IsNotExist(err) { m.save() } else { if err := json.Unmarshal(jsonData, &m.snapshotMetadata); err != nil { return ...
[ "func", "(", "m", "*", "SnapshotMetadata", ")", "load", "(", ")", "error", "{", "// This is not safe for concurrent access.", "// Exported methods will deal with locking.", "jsonData", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "m", ".", "path", ")", "\n", ...
// load the metadata from file.
[ "load", "the", "metadata", "from", "file", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/metadata.go#L74-L86
139,492
control-center/serviced
volume/devicemapper/metadata.go
save
func (m *SnapshotMetadata) save() error { // This is not safe for concurrent access. // Exported methods will deal with locking. jsonData, err := json.Marshal(m.snapshotMetadata) if err != nil { glog.Errorf("Error encoding metadata to json: %s", err) return ErrInvalidMetadata } return ioutil.WriteFile(m.path,...
go
func (m *SnapshotMetadata) save() error { // This is not safe for concurrent access. // Exported methods will deal with locking. jsonData, err := json.Marshal(m.snapshotMetadata) if err != nil { glog.Errorf("Error encoding metadata to json: %s", err) return ErrInvalidMetadata } return ioutil.WriteFile(m.path,...
[ "func", "(", "m", "*", "SnapshotMetadata", ")", "save", "(", ")", "error", "{", "// This is not safe for concurrent access.", "// Exported methods will deal with locking.", "jsonData", ",", "err", ":=", "json", ".", "Marshal", "(", "m", ".", "snapshotMetadata", ")", ...
// save metadata to file
[ "save", "metadata", "to", "file" ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/metadata.go#L89-L98
139,493
control-center/serviced
volume/devicemapper/metadata.go
RemoveSnapshot
func (m *SnapshotMetadata) RemoveSnapshot(snapshot string) error { m.Lock() defer m.Unlock() delete(m.snapshotMetadata.Snapshots, snapshot) return m.save() }
go
func (m *SnapshotMetadata) RemoveSnapshot(snapshot string) error { m.Lock() defer m.Unlock() delete(m.snapshotMetadata.Snapshots, snapshot) return m.save() }
[ "func", "(", "m", "*", "SnapshotMetadata", ")", "RemoveSnapshot", "(", "snapshot", "string", ")", "error", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "delete", "(", "m", ".", "snapshotMetadata", ".", "Snapshots"...
// Remove snapshot info from the metadata. If the snapshot doesn't exist, it's a no-op.
[ "Remove", "snapshot", "info", "from", "the", "metadata", ".", "If", "the", "snapshot", "doesn", "t", "exist", "it", "s", "a", "no", "-", "op", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/metadata.go#L125-L130
139,494
control-center/serviced
rpc/rpcutils/authcodec.go
requiresAuthentication
func requiresAuthentication(callName string) bool { for _, name := range NonAuthenticatingCalls { if name == callName { return false } } return true }
go
func requiresAuthentication(callName string) bool { for _, name := range NonAuthenticatingCalls { if name == callName { return false } } return true }
[ "func", "requiresAuthentication", "(", "callName", "string", ")", "bool", "{", "for", "_", ",", "name", ":=", "range", "NonAuthenticatingCalls", "{", "if", "name", "==", "callName", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n"...
// Checks the RPC method name to see if authentication is required. // If it is, calls on the client side will include a signed header, which will be // Verified on the server side
[ "Checks", "the", "RPC", "method", "name", "to", "see", "if", "authentication", "is", "required", ".", "If", "it", "is", "calls", "on", "the", "client", "side", "will", "include", "a", "signed", "header", "which", "will", "be", "Verified", "on", "the", "s...
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/rpcutils/authcodec.go#L65-L72
139,495
control-center/serviced
rpc/rpcutils/authcodec.go
ReadRequestHeader
func (a *AuthServerCodec) ReadRequestHeader(r *rpc.Request) error { // There is no need for synchronization here, since go's RPC server // ensures that requests are read one-at-a-time // Reset state a.lastError = nil a.buff.ReadBuff.Reset() ident, body, err := a.parser.ReadHeader(a.conn) if err != nil { lo...
go
func (a *AuthServerCodec) ReadRequestHeader(r *rpc.Request) error { // There is no need for synchronization here, since go's RPC server // ensures that requests are read one-at-a-time // Reset state a.lastError = nil a.buff.ReadBuff.Reset() ident, body, err := a.parser.ReadHeader(a.conn) if err != nil { lo...
[ "func", "(", "a", "*", "AuthServerCodec", ")", "ReadRequestHeader", "(", "r", "*", "rpc", ".", "Request", ")", "error", "{", "// There is no need for synchronization here, since go's RPC server", "// ensures that requests are read one-at-a-time", "// Reset state", "a", ".", ...
// Reads the request header and populates the rpc.Request object. // This implementation reads the auth header off the stream first, then // lets the underlying codec read the rest. // Finally, it validates the identity if necessary.
[ "Reads", "the", "request", "header", "and", "populates", "the", "rpc", ".", "Request", "object", ".", "This", "implementation", "reads", "the", "auth", "header", "off", "the", "stream", "first", "then", "lets", "the", "underlying", "codec", "read", "the", "r...
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/rpcutils/authcodec.go#L130-L177
139,496
control-center/serviced
rpc/rpcutils/authcodec.go
ReadRequestBody
func (a *AuthServerCodec) ReadRequestBody(body interface{}) error { if a.lastError != nil { return a.lastError } // TODO: Use reflection and add the identity to the body if necessary return a.wrappedcodec.ReadRequestBody(body) }
go
func (a *AuthServerCodec) ReadRequestBody(body interface{}) error { if a.lastError != nil { return a.lastError } // TODO: Use reflection and add the identity to the body if necessary return a.wrappedcodec.ReadRequestBody(body) }
[ "func", "(", "a", "*", "AuthServerCodec", ")", "ReadRequestBody", "(", "body", "interface", "{", "}", ")", "error", "{", "if", "a", ".", "lastError", "!=", "nil", "{", "return", "a", ".", "lastError", "\n", "}", "\n", "// TODO: Use reflection and add the ide...
// Decodes the request and populates the body object with the body of the request // We don't change anything here, just let the underlying codec handle it. // This always gets called after ReadRequestHeader
[ "Decodes", "the", "request", "and", "populates", "the", "body", "object", "with", "the", "body", "of", "the", "request", "We", "don", "t", "change", "anything", "here", "just", "let", "the", "underlying", "codec", "handle", "it", ".", "This", "always", "ge...
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/rpcutils/authcodec.go#L182-L188
139,497
control-center/serviced
rpc/rpcutils/authcodec.go
WriteResponse
func (a *AuthServerCodec) WriteResponse(r *rpc.Response, body interface{}) error { // We do need a lock here, because the ServerCodec interface specifies // that WriteResponse must be safe for concurrent use by multiple goroutines a.wBuffMutex.Lock() defer a.wBuffMutex.Unlock() a.buff.WriteBuff.Reset() // Let ...
go
func (a *AuthServerCodec) WriteResponse(r *rpc.Response, body interface{}) error { // We do need a lock here, because the ServerCodec interface specifies // that WriteResponse must be safe for concurrent use by multiple goroutines a.wBuffMutex.Lock() defer a.wBuffMutex.Unlock() a.buff.WriteBuff.Reset() // Let ...
[ "func", "(", "a", "*", "AuthServerCodec", ")", "WriteResponse", "(", "r", "*", "rpc", ".", "Response", ",", "body", "interface", "{", "}", ")", "error", "{", "// We do need a lock here, because the ServerCodec interface specifies", "// that WriteResponse must be safe for...
// Encodes the response before sending it back down to the client. // We don't change anything here, just let the underlying codec handle it.
[ "Encodes", "the", "response", "before", "sending", "it", "back", "down", "to", "the", "client", ".", "We", "don", "t", "change", "anything", "here", "just", "let", "the", "underlying", "codec", "handle", "it", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/rpcutils/authcodec.go#L192-L212
139,498
control-center/serviced
rpc/rpcutils/authcodec.go
WriteRequest
func (a *AuthClientCodec) WriteRequest(r *rpc.Request, body interface{}) error { // Lock to ensure we write the header and the rest of the request back-to-back // This method may be called by multiple goroutines concurrently a.wBuffMutex.Lock() defer a.wBuffMutex.Unlock() a.buff.WriteBuff.Reset() // Let the und...
go
func (a *AuthClientCodec) WriteRequest(r *rpc.Request, body interface{}) error { // Lock to ensure we write the header and the rest of the request back-to-back // This method may be called by multiple goroutines concurrently a.wBuffMutex.Lock() defer a.wBuffMutex.Unlock() a.buff.WriteBuff.Reset() // Let the und...
[ "func", "(", "a", "*", "AuthClientCodec", ")", "WriteRequest", "(", "r", "*", "rpc", ".", "Request", ",", "body", "interface", "{", "}", ")", "error", "{", "// Lock to ensure we write the header and the rest of the request back-to-back", "// This method may be called by ...
// Encodes the request and sends it to the server. // This implementation gets an auth header when appropriate, and writes it to the stream // before letting the underlying codec send the rest of the request.
[ "Encodes", "the", "request", "and", "sends", "it", "to", "the", "server", ".", "This", "implementation", "gets", "an", "auth", "header", "when", "appropriate", "and", "writes", "it", "to", "the", "stream", "before", "letting", "the", "underlying", "codec", "...
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/rpcutils/authcodec.go#L256-L279
139,499
control-center/serviced
rpc/rpcutils/authcodec.go
ReadResponseHeader
func (a *AuthClientCodec) ReadResponseHeader(r *rpc.Response) error { // No need for synchronization here, Go's RPC Client makes sure only // One response is read at a time. a.buff.ReadBuff.Reset() // Read the response from the connection response, err := auth.ReadLengthAndBytes(a.conn) if err != nil { // I...
go
func (a *AuthClientCodec) ReadResponseHeader(r *rpc.Response) error { // No need for synchronization here, Go's RPC Client makes sure only // One response is read at a time. a.buff.ReadBuff.Reset() // Read the response from the connection response, err := auth.ReadLengthAndBytes(a.conn) if err != nil { // I...
[ "func", "(", "a", "*", "AuthClientCodec", ")", "ReadResponseHeader", "(", "r", "*", "rpc", ".", "Response", ")", "error", "{", "// No need for synchronization here, Go's RPC Client makes sure only", "// One response is read at a time.", "a", ".", "buff", ".", "ReadBuff",...
// Decodes the response and reads the header, building the rpc.Response object // We don't change anything here, just let the underlying codec handle it.
[ "Decodes", "the", "response", "and", "reads", "the", "header", "building", "the", "rpc", ".", "Response", "object", "We", "don", "t", "change", "anything", "here", "just", "let", "the", "underlying", "codec", "handle", "it", "." ]
7028f598e6a224b4d421e09cb9b582ad7d000304
https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/rpcutils/authcodec.go#L283-L310