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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
133,100 | hashicorp/nomad | client/taskenv/env.go | setHookEnvLocked | func (b *Builder) setHookEnvLocked(hook string, envs map[string]string) *Builder {
if _, exists := b.hookEnvs[hook]; !exists {
b.hookNames = append(b.hookNames, hook)
}
b.hookEnvs[hook] = envs
return b
} | go | func (b *Builder) setHookEnvLocked(hook string, envs map[string]string) *Builder {
if _, exists := b.hookEnvs[hook]; !exists {
b.hookNames = append(b.hookNames, hook)
}
b.hookEnvs[hook] = envs
return b
} | [
"func",
"(",
"b",
"*",
"Builder",
")",
"setHookEnvLocked",
"(",
"hook",
"string",
",",
"envs",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"Builder",
"{",
"if",
"_",
",",
"exists",
":=",
"b",
".",
"hookEnvs",
"[",
"hook",
"]",
";",
"!",
"exists"... | // setHookEnvLocked is the implementation of setting hook environment variables
// and should be called with the lock held | [
"setHookEnvLocked",
"is",
"the",
"implementation",
"of",
"setting",
"hook",
"environment",
"variables",
"and",
"should",
"be",
"called",
"with",
"the",
"lock",
"held"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L513-L520 |
133,101 | hashicorp/nomad | client/taskenv/env.go | SetDeviceHookEnv | func (b *Builder) SetDeviceHookEnv(hookName string, envs map[string]string) *Builder {
b.mu.Lock()
defer b.mu.Unlock()
// Store the device hook name
b.deviceHookName = hookName
return b.setHookEnvLocked(hookName, envs)
} | go | func (b *Builder) SetDeviceHookEnv(hookName string, envs map[string]string) *Builder {
b.mu.Lock()
defer b.mu.Unlock()
// Store the device hook name
b.deviceHookName = hookName
return b.setHookEnvLocked(hookName, envs)
} | [
"func",
"(",
"b",
"*",
"Builder",
")",
"SetDeviceHookEnv",
"(",
"hookName",
"string",
",",
"envs",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"Builder",
"{",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"mu",
".",
"Unlock",
... | // SetDeviceHookEnv sets environment variables from a device hook. Variables are
// Last-Write-Wins, so if a hook writes a variable that's also written by a
// later hook, the later hooks value always gets used. | [
"SetDeviceHookEnv",
"sets",
"environment",
"variables",
"from",
"a",
"device",
"hook",
".",
"Variables",
"are",
"Last",
"-",
"Write",
"-",
"Wins",
"so",
"if",
"a",
"hook",
"writes",
"a",
"variable",
"that",
"s",
"also",
"written",
"by",
"a",
"later",
"hook... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L525-L532 |
133,102 | hashicorp/nomad | client/taskenv/env.go | setTask | func (b *Builder) setTask(task *structs.Task) *Builder {
b.taskName = task.Name
b.envvars = make(map[string]string, len(task.Env))
for k, v := range task.Env {
b.envvars[k] = v
}
// COMPAT(0.11): Remove in 0.11
if task.Resources == nil {
b.memLimit = 0
b.cpuLimit = 0
} else {
b.memLimit = int64(task.Res... | go | func (b *Builder) setTask(task *structs.Task) *Builder {
b.taskName = task.Name
b.envvars = make(map[string]string, len(task.Env))
for k, v := range task.Env {
b.envvars[k] = v
}
// COMPAT(0.11): Remove in 0.11
if task.Resources == nil {
b.memLimit = 0
b.cpuLimit = 0
} else {
b.memLimit = int64(task.Res... | [
"func",
"(",
"b",
"*",
"Builder",
")",
"setTask",
"(",
"task",
"*",
"structs",
".",
"Task",
")",
"*",
"Builder",
"{",
"b",
".",
"taskName",
"=",
"task",
".",
"Name",
"\n",
"b",
".",
"envvars",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string"... | // setTask is called from NewBuilder to populate task related environment
// variables. | [
"setTask",
"is",
"called",
"from",
"NewBuilder",
"to",
"populate",
"task",
"related",
"environment",
"variables",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L536-L552 |
133,103 | hashicorp/nomad | client/taskenv/env.go | setNode | func (b *Builder) setNode(n *structs.Node) *Builder {
b.nodeAttrs = make(map[string]string, 4+len(n.Attributes)+len(n.Meta))
b.nodeAttrs[nodeIdKey] = n.ID
b.nodeAttrs[nodeNameKey] = n.Name
b.nodeAttrs[nodeClassKey] = n.NodeClass
b.nodeAttrs[nodeDcKey] = n.Datacenter
b.datacenter = n.Datacenter
// Set up the att... | go | func (b *Builder) setNode(n *structs.Node) *Builder {
b.nodeAttrs = make(map[string]string, 4+len(n.Attributes)+len(n.Meta))
b.nodeAttrs[nodeIdKey] = n.ID
b.nodeAttrs[nodeNameKey] = n.Name
b.nodeAttrs[nodeClassKey] = n.NodeClass
b.nodeAttrs[nodeDcKey] = n.Datacenter
b.datacenter = n.Datacenter
// Set up the att... | [
"func",
"(",
"b",
"*",
"Builder",
")",
"setNode",
"(",
"n",
"*",
"structs",
".",
"Node",
")",
"*",
"Builder",
"{",
"b",
".",
"nodeAttrs",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"4",
"+",
"len",
"(",
"n",
".",
"Attributes",
... | // setNode is called from NewBuilder to populate node attributes. | [
"setNode",
"is",
"called",
"from",
"NewBuilder",
"to",
"populate",
"node",
"attributes",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L647-L665 |
133,104 | hashicorp/nomad | client/taskenv/env.go | SetDriverNetwork | func (b *Builder) SetDriverNetwork(n *drivers.DriverNetwork) *Builder {
ncopy := n.Copy()
b.mu.Lock()
b.driverNetwork = ncopy
b.mu.Unlock()
return b
} | go | func (b *Builder) SetDriverNetwork(n *drivers.DriverNetwork) *Builder {
ncopy := n.Copy()
b.mu.Lock()
b.driverNetwork = ncopy
b.mu.Unlock()
return b
} | [
"func",
"(",
"b",
"*",
"Builder",
")",
"SetDriverNetwork",
"(",
"n",
"*",
"drivers",
".",
"DriverNetwork",
")",
"*",
"Builder",
"{",
"ncopy",
":=",
"n",
".",
"Copy",
"(",
")",
"\n",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"b",
".",
"driverNe... | // SetDriverNetwork defined by the driver. | [
"SetDriverNetwork",
"defined",
"by",
"the",
"driver",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L689-L695 |
133,105 | hashicorp/nomad | client/taskenv/env.go | SetHostEnvvars | func (b *Builder) SetHostEnvvars(filter []string) *Builder {
filterMap := make(map[string]struct{}, len(filter))
for _, f := range filter {
filterMap[f] = struct{}{}
}
fullHostEnv := os.Environ()
filteredHostEnv := make(map[string]string, len(fullHostEnv))
for _, e := range fullHostEnv {
parts := strings.Spl... | go | func (b *Builder) SetHostEnvvars(filter []string) *Builder {
filterMap := make(map[string]struct{}, len(filter))
for _, f := range filter {
filterMap[f] = struct{}{}
}
fullHostEnv := os.Environ()
filteredHostEnv := make(map[string]string, len(fullHostEnv))
for _, e := range fullHostEnv {
parts := strings.Spl... | [
"func",
"(",
"b",
"*",
"Builder",
")",
"SetHostEnvvars",
"(",
"filter",
"[",
"]",
"string",
")",
"*",
"Builder",
"{",
"filterMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
",",
"len",
"(",
"filter",
")",
")",
"\n",
"for",
... | // SetHostEnvvars adds the host environment variables to the tasks. The filter
// parameter can be use to filter host environment from entering the tasks. | [
"SetHostEnvvars",
"adds",
"the",
"host",
"environment",
"variables",
"to",
"the",
"tasks",
".",
"The",
"filter",
"parameter",
"can",
"be",
"use",
"to",
"filter",
"host",
"environment",
"from",
"entering",
"the",
"tasks",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L735-L759 |
133,106 | hashicorp/nomad | client/taskenv/env.go | addPort | func addPort(m map[string]string, taskName, ip, portLabel string, port int) {
key := fmt.Sprintf("%s%s_%s", AddrPrefix, taskName, portLabel)
m[key] = fmt.Sprintf("%s:%d", ip, port)
key = fmt.Sprintf("%s%s_%s", IpPrefix, taskName, portLabel)
m[key] = ip
key = fmt.Sprintf("%s%s_%s", PortPrefix, taskName, portLabel)
... | go | func addPort(m map[string]string, taskName, ip, portLabel string, port int) {
key := fmt.Sprintf("%s%s_%s", AddrPrefix, taskName, portLabel)
m[key] = fmt.Sprintf("%s:%d", ip, port)
key = fmt.Sprintf("%s%s_%s", IpPrefix, taskName, portLabel)
m[key] = ip
key = fmt.Sprintf("%s%s_%s", PortPrefix, taskName, portLabel)
... | [
"func",
"addPort",
"(",
"m",
"map",
"[",
"string",
"]",
"string",
",",
"taskName",
",",
"ip",
",",
"portLabel",
"string",
",",
"port",
"int",
")",
"{",
"key",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"AddrPrefix",
",",
"taskName",
",",
"p... | // addPort keys and values for other tasks to an env var map | [
"addPort",
"keys",
"and",
"values",
"for",
"other",
"tasks",
"to",
"an",
"env",
"var",
"map"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L778-L785 |
133,107 | hashicorp/nomad | client/stats/host.go | NewHostStatsCollector | func NewHostStatsCollector(logger hclog.Logger, allocDir string, deviceStatsCollector DeviceStatsCollector) *HostStatsCollector {
logger = logger.Named("host_stats")
numCores := runtime.NumCPU()
statsCalculator := make(map[string]*HostCpuStatsCalculator)
collector := &HostStatsCollector{
statsCalculator: sta... | go | func NewHostStatsCollector(logger hclog.Logger, allocDir string, deviceStatsCollector DeviceStatsCollector) *HostStatsCollector {
logger = logger.Named("host_stats")
numCores := runtime.NumCPU()
statsCalculator := make(map[string]*HostCpuStatsCalculator)
collector := &HostStatsCollector{
statsCalculator: sta... | [
"func",
"NewHostStatsCollector",
"(",
"logger",
"hclog",
".",
"Logger",
",",
"allocDir",
"string",
",",
"deviceStatsCollector",
"DeviceStatsCollector",
")",
"*",
"HostStatsCollector",
"{",
"logger",
"=",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
"\n",
"numCo... | // NewHostStatsCollector returns a HostStatsCollector. The allocDir is passed in
// so that we can present the disk related statistics for the mountpoint where
// the allocation directory lives | [
"NewHostStatsCollector",
"returns",
"a",
"HostStatsCollector",
".",
"The",
"allocDir",
"is",
"passed",
"in",
"so",
"that",
"we",
"can",
"present",
"the",
"disk",
"related",
"statistics",
"for",
"the",
"mountpoint",
"where",
"the",
"allocation",
"directory",
"lives... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/stats/host.go#L90-L103 |
133,108 | hashicorp/nomad | client/stats/host.go | Collect | func (h *HostStatsCollector) Collect() error {
h.hostStatsLock.Lock()
defer h.hostStatsLock.Unlock()
return h.collectLocked()
} | go | func (h *HostStatsCollector) Collect() error {
h.hostStatsLock.Lock()
defer h.hostStatsLock.Unlock()
return h.collectLocked()
} | [
"func",
"(",
"h",
"*",
"HostStatsCollector",
")",
"Collect",
"(",
")",
"error",
"{",
"h",
".",
"hostStatsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"hostStatsLock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"h",
".",
"collectLocked",
"(",
... | // Collect collects stats related to resource usage of a host | [
"Collect",
"collects",
"stats",
"related",
"to",
"resource",
"usage",
"of",
"a",
"host"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/stats/host.go#L106-L110 |
133,109 | hashicorp/nomad | client/stats/host.go | collectLocked | func (h *HostStatsCollector) collectLocked() error {
hs := &HostStats{Timestamp: time.Now().UTC().UnixNano()}
// Determine up-time
uptime, err := host.Uptime()
if err != nil {
return err
}
hs.Uptime = uptime
// Collect memory stats
mstats, err := h.collectMemoryStats()
if err != nil {
return err
}
hs.M... | go | func (h *HostStatsCollector) collectLocked() error {
hs := &HostStats{Timestamp: time.Now().UTC().UnixNano()}
// Determine up-time
uptime, err := host.Uptime()
if err != nil {
return err
}
hs.Uptime = uptime
// Collect memory stats
mstats, err := h.collectMemoryStats()
if err != nil {
return err
}
hs.M... | [
"func",
"(",
"h",
"*",
"HostStatsCollector",
")",
"collectLocked",
"(",
")",
"error",
"{",
"hs",
":=",
"&",
"HostStats",
"{",
"Timestamp",
":",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
".",
"UnixNano",
"(",
")",
"}",
"\n\n",
"// Determine ... | // collectLocked collects stats related to resource usage of the host but should
// be called with the lock held. | [
"collectLocked",
"collects",
"stats",
"related",
"to",
"resource",
"usage",
"of",
"the",
"host",
"but",
"should",
"be",
"called",
"with",
"the",
"lock",
"held",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/stats/host.go#L114-L161 |
133,110 | hashicorp/nomad | client/stats/host.go | Stats | func (h *HostStatsCollector) Stats() *HostStats {
h.hostStatsLock.RLock()
defer h.hostStatsLock.RUnlock()
if h.hostStats == nil {
if err := h.collectLocked(); err != nil {
h.logger.Warn("error fetching host resource usage stats", "error", err)
}
}
return h.hostStats
} | go | func (h *HostStatsCollector) Stats() *HostStats {
h.hostStatsLock.RLock()
defer h.hostStatsLock.RUnlock()
if h.hostStats == nil {
if err := h.collectLocked(); err != nil {
h.logger.Warn("error fetching host resource usage stats", "error", err)
}
}
return h.hostStats
} | [
"func",
"(",
"h",
"*",
"HostStatsCollector",
")",
"Stats",
"(",
")",
"*",
"HostStats",
"{",
"h",
".",
"hostStatsLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"h",
".",
"hostStatsLock",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"h",
".",
"hostStats",
"=... | // Stats returns the host stats that has been collected | [
"Stats",
"returns",
"the",
"host",
"stats",
"that",
"has",
"been",
"collected"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/stats/host.go#L215-L226 |
133,111 | hashicorp/nomad | client/stats/host.go | toDiskStats | func (h *HostStatsCollector) toDiskStats(usage *disk.UsageStat, partitionStat *disk.PartitionStat) *DiskStats {
ds := DiskStats{
Size: usage.Total,
Used: usage.Used,
Available: usage.Free,
UsedPercent: usage.UsedPercent,
InodesUsedPercent: usage.InodesUsedPercent,
}
... | go | func (h *HostStatsCollector) toDiskStats(usage *disk.UsageStat, partitionStat *disk.PartitionStat) *DiskStats {
ds := DiskStats{
Size: usage.Total,
Used: usage.Used,
Available: usage.Free,
UsedPercent: usage.UsedPercent,
InodesUsedPercent: usage.InodesUsedPercent,
}
... | [
"func",
"(",
"h",
"*",
"HostStatsCollector",
")",
"toDiskStats",
"(",
"usage",
"*",
"disk",
".",
"UsageStat",
",",
"partitionStat",
"*",
"disk",
".",
"PartitionStat",
")",
"*",
"DiskStats",
"{",
"ds",
":=",
"DiskStats",
"{",
"Size",
":",
"usage",
".",
"T... | // toDiskStats merges UsageStat and PartitionStat to create a DiskStat | [
"toDiskStats",
"merges",
"UsageStat",
"and",
"PartitionStat",
"to",
"create",
"a",
"DiskStat"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/stats/host.go#L229-L250 |
133,112 | hashicorp/nomad | client/stats/host.go | Calculate | func (h *HostCpuStatsCalculator) Calculate(times cpu.TimesStat) (idle float64, user float64, system float64, total float64) {
currentIdle := times.Idle
currentUser := times.User
currentSystem := times.System
currentTotal := times.Total()
currentBusy := times.User + times.System + times.Nice + times.Iowait + times.... | go | func (h *HostCpuStatsCalculator) Calculate(times cpu.TimesStat) (idle float64, user float64, system float64, total float64) {
currentIdle := times.Idle
currentUser := times.User
currentSystem := times.System
currentTotal := times.Total()
currentBusy := times.User + times.System + times.Nice + times.Iowait + times.... | [
"func",
"(",
"h",
"*",
"HostCpuStatsCalculator",
")",
"Calculate",
"(",
"times",
"cpu",
".",
"TimesStat",
")",
"(",
"idle",
"float64",
",",
"user",
"float64",
",",
"system",
"float64",
",",
"total",
"float64",
")",
"{",
"currentIdle",
":=",
"times",
".",
... | // Calculate calculates the current cpu usage percentages | [
"Calculate",
"calculates",
"the",
"current",
"cpu",
"usage",
"percentages"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/stats/host.go#L267-L301 |
133,113 | hashicorp/nomad | client/fingerprint/vault.go | NewVaultFingerprint | func NewVaultFingerprint(logger log.Logger) Fingerprint {
return &VaultFingerprint{logger: logger.Named("vault"), lastState: vaultUnavailable}
} | go | func NewVaultFingerprint(logger log.Logger) Fingerprint {
return &VaultFingerprint{logger: logger.Named("vault"), lastState: vaultUnavailable}
} | [
"func",
"NewVaultFingerprint",
"(",
"logger",
"log",
".",
"Logger",
")",
"Fingerprint",
"{",
"return",
"&",
"VaultFingerprint",
"{",
"logger",
":",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
",",
"lastState",
":",
"vaultUnavailable",
"}",
"\n",
"}"
] | // NewVaultFingerprint is used to create a Vault fingerprint | [
"NewVaultFingerprint",
"is",
"used",
"to",
"create",
"a",
"Vault",
"fingerprint"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/vault.go#L26-L28 |
133,114 | hashicorp/nomad | plugins/base/plugin.go | MsgPackEncode | func MsgPackEncode(b *[]byte, in interface{}) error {
return codec.NewEncoderBytes(b, MsgpackHandle).Encode(in)
} | go | func MsgPackEncode(b *[]byte, in interface{}) error {
return codec.NewEncoderBytes(b, MsgpackHandle).Encode(in)
} | [
"func",
"MsgPackEncode",
"(",
"b",
"*",
"[",
"]",
"byte",
",",
"in",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"codec",
".",
"NewEncoderBytes",
"(",
"b",
",",
"MsgpackHandle",
")",
".",
"Encode",
"(",
"in",
")",
"\n",
"}"
] | // MsgPackEncode is used to encode an object to MsgPack | [
"MsgPackEncode",
"is",
"used",
"to",
"encode",
"an",
"object",
"to",
"MsgPack"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/base/plugin.go#L73-L75 |
133,115 | hashicorp/nomad | client/allocrunner/taskrunner/dispatch_hook.go | writeDispatchPayload | func writeDispatchPayload(base, filename string, payload []byte) error {
renderTo := filepath.Join(base, filename)
decoded, err := snappy.Decode(nil, payload)
if err != nil {
return err
}
if err := os.MkdirAll(filepath.Dir(renderTo), 0777); err != nil {
return err
}
return ioutil.WriteFile(renderTo, decode... | go | func writeDispatchPayload(base, filename string, payload []byte) error {
renderTo := filepath.Join(base, filename)
decoded, err := snappy.Decode(nil, payload)
if err != nil {
return err
}
if err := os.MkdirAll(filepath.Dir(renderTo), 0777); err != nil {
return err
}
return ioutil.WriteFile(renderTo, decode... | [
"func",
"writeDispatchPayload",
"(",
"base",
",",
"filename",
"string",
",",
"payload",
"[",
"]",
"byte",
")",
"error",
"{",
"renderTo",
":=",
"filepath",
".",
"Join",
"(",
"base",
",",
"filename",
")",
"\n",
"decoded",
",",
"err",
":=",
"snappy",
".",
... | // writeDispatchPayload writes the payload to the given file or returns an
// error. | [
"writeDispatchPayload",
"writes",
"the",
"payload",
"to",
"the",
"given",
"file",
"or",
"returns",
"an",
"error",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/dispatch_hook.go#L61-L73 |
133,116 | hashicorp/nomad | client/allocrunner/taskrunner/errors.go | NewHookError | func NewHookError(err error, taskEvent *structs.TaskEvent) error {
return &hookError{
err: err,
taskEvent: taskEvent,
}
} | go | func NewHookError(err error, taskEvent *structs.TaskEvent) error {
return &hookError{
err: err,
taskEvent: taskEvent,
}
} | [
"func",
"NewHookError",
"(",
"err",
"error",
",",
"taskEvent",
"*",
"structs",
".",
"TaskEvent",
")",
"error",
"{",
"return",
"&",
"hookError",
"{",
"err",
":",
"err",
",",
"taskEvent",
":",
"taskEvent",
",",
"}",
"\n",
"}"
] | // NewHookError contains an underlying err and a pre-formatted task event. | [
"NewHookError",
"contains",
"an",
"underlying",
"err",
"and",
"a",
"pre",
"-",
"formatted",
"task",
"event",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/errors.go#L18-L23 |
133,117 | hashicorp/nomad | client/servers/manager.go | cycle | func (s Servers) cycle() {
numServers := len(s)
if numServers < 2 {
return // No action required
}
start := s[0]
for i := 1; i < numServers; i++ {
s[i-1] = s[i]
}
s[numServers-1] = start
} | go | func (s Servers) cycle() {
numServers := len(s)
if numServers < 2 {
return // No action required
}
start := s[0]
for i := 1; i < numServers; i++ {
s[i-1] = s[i]
}
s[numServers-1] = start
} | [
"func",
"(",
"s",
"Servers",
")",
"cycle",
"(",
")",
"{",
"numServers",
":=",
"len",
"(",
"s",
")",
"\n",
"if",
"numServers",
"<",
"2",
"{",
"return",
"// No action required",
"\n",
"}",
"\n\n",
"start",
":=",
"s",
"[",
"0",
"]",
"\n",
"for",
"i",
... | // cycle cycles a list of servers in-place | [
"cycle",
"cycles",
"a",
"list",
"of",
"servers",
"in",
"-",
"place"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L99-L110 |
133,118 | hashicorp/nomad | client/servers/manager.go | shuffle | func (s Servers) shuffle() {
for i := len(s) - 1; i > 0; i-- {
j := rand.Int31n(int32(i + 1))
s[i], s[j] = s[j], s[i]
}
} | go | func (s Servers) shuffle() {
for i := len(s) - 1; i > 0; i-- {
j := rand.Int31n(int32(i + 1))
s[i], s[j] = s[j], s[i]
}
} | [
"func",
"(",
"s",
"Servers",
")",
"shuffle",
"(",
")",
"{",
"for",
"i",
":=",
"len",
"(",
"s",
")",
"-",
"1",
";",
"i",
">",
"0",
";",
"i",
"--",
"{",
"j",
":=",
"rand",
".",
"Int31n",
"(",
"int32",
"(",
"i",
"+",
"1",
")",
")",
"\n",
"... | // shuffle shuffles the server list in place | [
"shuffle",
"shuffles",
"the",
"server",
"list",
"in",
"place"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L113-L118 |
133,119 | hashicorp/nomad | client/servers/manager.go | Equal | func (s Servers) Equal(o Servers) bool {
if len(s) != len(o) {
return false
}
for i, v := range s {
if !v.Equal(o[i]) {
return false
}
}
return true
} | go | func (s Servers) Equal(o Servers) bool {
if len(s) != len(o) {
return false
}
for i, v := range s {
if !v.Equal(o[i]) {
return false
}
}
return true
} | [
"func",
"(",
"s",
"Servers",
")",
"Equal",
"(",
"o",
"Servers",
")",
"bool",
"{",
"if",
"len",
"(",
"s",
")",
"!=",
"len",
"(",
"o",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"i",
",",
"v",
":=",
"range",
"s",
"{",
"if",
"!",
"... | // Equal returns if the two server lists are equal, including the ordering. | [
"Equal",
"returns",
"if",
"the",
"two",
"server",
"lists",
"are",
"equal",
"including",
"the",
"ordering",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L132-L144 |
133,120 | hashicorp/nomad | client/servers/manager.go | Start | func (m *Manager) Start() {
for {
select {
case <-m.rebalanceTimer.C:
m.RebalanceServers()
m.refreshServerRebalanceTimer()
case <-m.shutdownCh:
m.logger.Debug("shutting down")
return
}
}
} | go | func (m *Manager) Start() {
for {
select {
case <-m.rebalanceTimer.C:
m.RebalanceServers()
m.refreshServerRebalanceTimer()
case <-m.shutdownCh:
m.logger.Debug("shutting down")
return
}
}
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Start",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"m",
".",
"rebalanceTimer",
".",
"C",
":",
"m",
".",
"RebalanceServers",
"(",
")",
"\n",
"m",
".",
"refreshServerRebalanceTimer",
"(",
")",
"\n\n"... | // Start is used to start and manage the task of automatically shuffling and
// rebalancing the list of Nomad servers in order to distribute load across
// all known and available Nomad servers. | [
"Start",
"is",
"used",
"to",
"start",
"and",
"manage",
"the",
"task",
"of",
"automatically",
"shuffling",
"and",
"rebalancing",
"the",
"list",
"of",
"Nomad",
"servers",
"in",
"order",
"to",
"distribute",
"load",
"across",
"all",
"known",
"and",
"available",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L184-L196 |
133,121 | hashicorp/nomad | client/servers/manager.go | SetServers | func (m *Manager) SetServers(servers Servers) bool {
m.Lock()
defer m.Unlock()
// Sort both the existing and incoming servers
servers.Sort()
m.servers.Sort()
// Determine if they are equal
equal := servers.Equal(m.servers)
// Randomize the incoming servers
servers.shuffle()
m.servers = servers
return !e... | go | func (m *Manager) SetServers(servers Servers) bool {
m.Lock()
defer m.Unlock()
// Sort both the existing and incoming servers
servers.Sort()
m.servers.Sort()
// Determine if they are equal
equal := servers.Equal(m.servers)
// Randomize the incoming servers
servers.shuffle()
m.servers = servers
return !e... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SetServers",
"(",
"servers",
"Servers",
")",
"bool",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"// Sort both the existing and incoming servers",
"servers",
".",
"Sort",
"(... | // SetServers sets the servers and returns if the new server list is different
// than the existing server set | [
"SetServers",
"sets",
"the",
"servers",
"and",
"returns",
"if",
"the",
"new",
"server",
"list",
"is",
"different",
"than",
"the",
"existing",
"server",
"set"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L200-L216 |
133,122 | hashicorp/nomad | client/servers/manager.go | FindServer | func (m *Manager) FindServer() *Server {
m.Lock()
defer m.Unlock()
if len(m.servers) == 0 {
m.logger.Warn("no servers available")
return nil
}
// Return whatever is at the front of the list because it is
// assumed to be the oldest in the server list (unless -
// hypothetically - the server list was rotate... | go | func (m *Manager) FindServer() *Server {
m.Lock()
defer m.Unlock()
if len(m.servers) == 0 {
m.logger.Warn("no servers available")
return nil
}
// Return whatever is at the front of the list because it is
// assumed to be the oldest in the server list (unless -
// hypothetically - the server list was rotate... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"FindServer",
"(",
")",
"*",
"Server",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"len",
"(",
"m",
".",
"servers",
")",
"==",
"0",
"{",
"m",
".",
"logger"... | // FindServer returns a server to send an RPC too. If there are no servers, nil
// is returned. | [
"FindServer",
"returns",
"a",
"server",
"to",
"send",
"an",
"RPC",
"too",
".",
"If",
"there",
"are",
"no",
"servers",
"nil",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L220-L234 |
133,123 | hashicorp/nomad | client/servers/manager.go | NumNodes | func (m *Manager) NumNodes() int32 {
m.Lock()
defer m.Unlock()
return m.numNodes
} | go | func (m *Manager) NumNodes() int32 {
m.Lock()
defer m.Unlock()
return m.numNodes
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"NumNodes",
"(",
")",
"int32",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n",
"return",
"m",
".",
"numNodes",
"\n",
"}"
] | // NumNodes returns the number of approximate nodes in the cluster. | [
"NumNodes",
"returns",
"the",
"number",
"of",
"approximate",
"nodes",
"in",
"the",
"cluster",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L237-L241 |
133,124 | hashicorp/nomad | client/servers/manager.go | SetNumNodes | func (m *Manager) SetNumNodes(n int32) {
m.Lock()
defer m.Unlock()
m.numNodes = n
} | go | func (m *Manager) SetNumNodes(n int32) {
m.Lock()
defer m.Unlock()
m.numNodes = n
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SetNumNodes",
"(",
"n",
"int32",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n",
"m",
".",
"numNodes",
"=",
"n",
"\n",
"}"
] | // SetNumNodes stores the number of approximate nodes in the cluster. | [
"SetNumNodes",
"stores",
"the",
"number",
"of",
"approximate",
"nodes",
"in",
"the",
"cluster",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L244-L248 |
133,125 | hashicorp/nomad | client/servers/manager.go | NumServers | func (m *Manager) NumServers() int {
m.Lock()
defer m.Unlock()
return len(m.servers)
} | go | func (m *Manager) NumServers() int {
m.Lock()
defer m.Unlock()
return len(m.servers)
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"NumServers",
"(",
")",
"int",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n",
"return",
"len",
"(",
"m",
".",
"servers",
")",
"\n",
"}"
] | // NumServers returns the total number of known servers whether healthy or not. | [
"NumServers",
"returns",
"the",
"total",
"number",
"of",
"known",
"servers",
"whether",
"healthy",
"or",
"not",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L265-L269 |
133,126 | hashicorp/nomad | client/servers/manager.go | GetServers | func (m *Manager) GetServers() Servers {
m.Lock()
defer m.Unlock()
copy := make([]*Server, 0, len(m.servers))
for _, s := range m.servers {
copy = append(copy, s.Copy())
}
return copy
} | go | func (m *Manager) GetServers() Servers {
m.Lock()
defer m.Unlock()
copy := make([]*Server, 0, len(m.servers))
for _, s := range m.servers {
copy = append(copy, s.Copy())
}
return copy
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetServers",
"(",
")",
"Servers",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"copy",
":=",
"make",
"(",
"[",
"]",
"*",
"Server",
",",
"0",
",",
"len",
"(",
"m"... | // GetServers returns a copy of the current list of servers. | [
"GetServers",
"returns",
"a",
"copy",
"of",
"the",
"current",
"list",
"of",
"servers",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L272-L282 |
133,127 | hashicorp/nomad | client/servers/manager.go | RebalanceServers | func (m *Manager) RebalanceServers() {
// Shuffle servers so we have a chance of picking a new one.
servers := m.GetServers()
servers.shuffle()
// Iterate through the shuffled server list to find an assumed
// healthy server. NOTE: Do not iterate on the list directly because
// this loop mutates the server list... | go | func (m *Manager) RebalanceServers() {
// Shuffle servers so we have a chance of picking a new one.
servers := m.GetServers()
servers.shuffle()
// Iterate through the shuffled server list to find an assumed
// healthy server. NOTE: Do not iterate on the list directly because
// this loop mutates the server list... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"RebalanceServers",
"(",
")",
"{",
"// Shuffle servers so we have a chance of picking a new one.",
"servers",
":=",
"m",
".",
"GetServers",
"(",
")",
"\n",
"servers",
".",
"shuffle",
"(",
")",
"\n\n",
"// Iterate through the sh... | // RebalanceServers shuffles the order in which Servers will be contacted. The
// function will shuffle the set of potential servers to contact and then attempt
// to contact each server. If a server successfully responds it is used, otherwise
// it is rotated such that it will be the last attempted server. | [
"RebalanceServers",
"shuffles",
"the",
"order",
"in",
"which",
"Servers",
"will",
"be",
"contacted",
".",
"The",
"function",
"will",
"shuffle",
"the",
"set",
"of",
"potential",
"servers",
"to",
"contact",
"and",
"then",
"attempt",
"to",
"contact",
"each",
"ser... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L288-L321 |
133,128 | hashicorp/nomad | client/servers/manager.go | ResetRebalanceTimer | func (m *Manager) ResetRebalanceTimer() {
m.Lock()
defer m.Unlock()
m.rebalanceTimer.Reset(clientRPCMinReuseDuration)
} | go | func (m *Manager) ResetRebalanceTimer() {
m.Lock()
defer m.Unlock()
m.rebalanceTimer.Reset(clientRPCMinReuseDuration)
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"ResetRebalanceTimer",
"(",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n",
"m",
".",
"rebalanceTimer",
".",
"Reset",
"(",
"clientRPCMinReuseDuration",
")",
"\n",
"}"
] | // ResetRebalanceTimer resets the rebalance timer. This method exists for
// testing and should not be used directly. | [
"ResetRebalanceTimer",
"resets",
"the",
"rebalance",
"timer",
".",
"This",
"method",
"exists",
"for",
"testing",
"and",
"should",
"not",
"be",
"used",
"directly",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/servers/manager.go#L344-L348 |
133,129 | hashicorp/nomad | api/status.go | RegionLeader | func (s *Status) RegionLeader(region string) (string, error) {
var resp string
q := QueryOptions{Region: region}
_, err := s.client.query("/v1/status/leader", &resp, &q)
if err != nil {
return "", err
}
return resp, nil
} | go | func (s *Status) RegionLeader(region string) (string, error) {
var resp string
q := QueryOptions{Region: region}
_, err := s.client.query("/v1/status/leader", &resp, &q)
if err != nil {
return "", err
}
return resp, nil
} | [
"func",
"(",
"s",
"*",
"Status",
")",
"RegionLeader",
"(",
"region",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"resp",
"string",
"\n",
"q",
":=",
"QueryOptions",
"{",
"Region",
":",
"region",
"}",
"\n",
"_",
",",
"err",
":=",
"s"... | // RegionLeader is used to query for the leader in the passed region. | [
"RegionLeader",
"is",
"used",
"to",
"query",
"for",
"the",
"leader",
"in",
"the",
"passed",
"region",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/status.go#L24-L32 |
133,130 | hashicorp/nomad | api/status.go | Peers | func (s *Status) Peers() ([]string, error) {
var resp []string
_, err := s.client.query("/v1/status/peers", &resp, nil)
if err != nil {
return nil, err
}
return resp, nil
} | go | func (s *Status) Peers() ([]string, error) {
var resp []string
_, err := s.client.query("/v1/status/peers", &resp, nil)
if err != nil {
return nil, err
}
return resp, nil
} | [
"func",
"(",
"s",
"*",
"Status",
")",
"Peers",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"string",
"\n",
"_",
",",
"err",
":=",
"s",
".",
"client",
".",
"query",
"(",
"\"",
"\"",
",",
"&",
"resp",
"... | // Peers is used to query the addresses of the server peers
// in the cluster. | [
"Peers",
"is",
"used",
"to",
"query",
"the",
"addresses",
"of",
"the",
"server",
"peers",
"in",
"the",
"cluster",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/status.go#L36-L43 |
133,131 | hashicorp/nomad | command/meta.go | FlagSet | func (m *Meta) FlagSet(n string, fs FlagSetFlags) *flag.FlagSet {
f := flag.NewFlagSet(n, flag.ContinueOnError)
// FlagSetClient is used to enable the settings for specifying
// client connectivity options.
if fs&FlagSetClient != 0 {
f.StringVar(&m.flagAddress, "address", "", "")
f.StringVar(&m.region, "region... | go | func (m *Meta) FlagSet(n string, fs FlagSetFlags) *flag.FlagSet {
f := flag.NewFlagSet(n, flag.ContinueOnError)
// FlagSetClient is used to enable the settings for specifying
// client connectivity options.
if fs&FlagSetClient != 0 {
f.StringVar(&m.flagAddress, "address", "", "")
f.StringVar(&m.region, "region... | [
"func",
"(",
"m",
"*",
"Meta",
")",
"FlagSet",
"(",
"n",
"string",
",",
"fs",
"FlagSetFlags",
")",
"*",
"flag",
".",
"FlagSet",
"{",
"f",
":=",
"flag",
".",
"NewFlagSet",
"(",
"n",
",",
"flag",
".",
"ContinueOnError",
")",
"\n\n",
"// FlagSetClient is ... | // FlagSet returns a FlagSet with the common flags that every
// command implements. The exact behavior of FlagSet can be configured
// using the flags as the second parameter, for example to disable
// server settings on the commands that don't talk to a server. | [
"FlagSet",
"returns",
"a",
"FlagSet",
"with",
"the",
"common",
"flags",
"that",
"every",
"command",
"implements",
".",
"The",
"exact",
"behavior",
"of",
"FlagSet",
"can",
"be",
"configured",
"using",
"the",
"flags",
"as",
"the",
"second",
"parameter",
"for",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/meta.go#L64-L98 |
133,132 | hashicorp/nomad | command/meta.go | AutocompleteFlags | func (m *Meta) AutocompleteFlags(fs FlagSetFlags) complete.Flags {
if fs&FlagSetClient == 0 {
return nil
}
return complete.Flags{
"-address": complete.PredictAnything,
"-region": complete.PredictAnything,
"-namespace": NamespacePredictor(m.Client, nil),
"-no-color": complete.... | go | func (m *Meta) AutocompleteFlags(fs FlagSetFlags) complete.Flags {
if fs&FlagSetClient == 0 {
return nil
}
return complete.Flags{
"-address": complete.PredictAnything,
"-region": complete.PredictAnything,
"-namespace": NamespacePredictor(m.Client, nil),
"-no-color": complete.... | [
"func",
"(",
"m",
"*",
"Meta",
")",
"AutocompleteFlags",
"(",
"fs",
"FlagSetFlags",
")",
"complete",
".",
"Flags",
"{",
"if",
"fs",
"&",
"FlagSetClient",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"complete",
".",
"Flags",
"{",
"\"",... | // AutocompleteFlags returns a set of flag completions for the given flag set. | [
"AutocompleteFlags",
"returns",
"a",
"set",
"of",
"flag",
"completions",
"for",
"the",
"given",
"flag",
"set",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/meta.go#L101-L119 |
133,133 | hashicorp/nomad | command/meta.go | Client | func (m *Meta) Client() (*api.Client, error) {
config := api.DefaultConfig()
if m.flagAddress != "" {
config.Address = m.flagAddress
}
if m.region != "" {
config.Region = m.region
}
if m.namespace != "" {
config.Namespace = m.namespace
}
// If we need custom TLS configuration, then set it
if m.caCert !=... | go | func (m *Meta) Client() (*api.Client, error) {
config := api.DefaultConfig()
if m.flagAddress != "" {
config.Address = m.flagAddress
}
if m.region != "" {
config.Region = m.region
}
if m.namespace != "" {
config.Namespace = m.namespace
}
// If we need custom TLS configuration, then set it
if m.caCert !=... | [
"func",
"(",
"m",
"*",
"Meta",
")",
"Client",
"(",
")",
"(",
"*",
"api",
".",
"Client",
",",
"error",
")",
"{",
"config",
":=",
"api",
".",
"DefaultConfig",
"(",
")",
"\n",
"if",
"m",
".",
"flagAddress",
"!=",
"\"",
"\"",
"{",
"config",
".",
"A... | // Client is used to initialize and return a new API client using
// the default command line arguments and env vars. | [
"Client",
"is",
"used",
"to",
"initialize",
"and",
"return",
"a",
"new",
"API",
"client",
"using",
"the",
"default",
"command",
"line",
"arguments",
"and",
"env",
"vars",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/meta.go#L126-L155 |
133,134 | hashicorp/nomad | command/agent/consul/client.go | NumServices | func (a *AllocRegistration) NumServices() int {
if a == nil {
return 0
}
total := 0
for _, treg := range a.Tasks {
for _, sreg := range treg.Services {
if sreg.Service != nil {
total++
}
}
}
return total
} | go | func (a *AllocRegistration) NumServices() int {
if a == nil {
return 0
}
total := 0
for _, treg := range a.Tasks {
for _, sreg := range treg.Services {
if sreg.Service != nil {
total++
}
}
}
return total
} | [
"func",
"(",
"a",
"*",
"AllocRegistration",
")",
"NumServices",
"(",
")",
"int",
"{",
"if",
"a",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"total",
":=",
"0",
"\n",
"for",
"_",
",",
"treg",
":=",
"range",
"a",
".",
"Tasks",
"{",
"for",
... | // NumServices returns the number of registered services | [
"NumServices",
"returns",
"the",
"number",
"of",
"registered",
"services"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L117-L132 |
133,135 | hashicorp/nomad | command/agent/consul/client.go | NumChecks | func (a *AllocRegistration) NumChecks() int {
if a == nil {
return 0
}
total := 0
for _, treg := range a.Tasks {
for _, sreg := range treg.Services {
total += len(sreg.Checks)
}
}
return total
} | go | func (a *AllocRegistration) NumChecks() int {
if a == nil {
return 0
}
total := 0
for _, treg := range a.Tasks {
for _, sreg := range treg.Services {
total += len(sreg.Checks)
}
}
return total
} | [
"func",
"(",
"a",
"*",
"AllocRegistration",
")",
"NumChecks",
"(",
")",
"int",
"{",
"if",
"a",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"total",
":=",
"0",
"\n",
"for",
"_",
",",
"treg",
":=",
"range",
"a",
".",
"Tasks",
"{",
"for",
... | // NumChecks returns the number of registered checks | [
"NumChecks",
"returns",
"the",
"number",
"of",
"registered",
"checks"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L135-L148 |
133,136 | hashicorp/nomad | command/agent/consul/client.go | NewServiceClient | func NewServiceClient(consulClient AgentAPI, logger log.Logger, isNomadClient bool) *ServiceClient {
logger = logger.ResetNamed("consul.sync")
return &ServiceClient{
client: consulClient,
logger: logger,
retryInterval: defaultRetryInterval,
maxRetryInterval: defaultMaxRetryInter... | go | func NewServiceClient(consulClient AgentAPI, logger log.Logger, isNomadClient bool) *ServiceClient {
logger = logger.ResetNamed("consul.sync")
return &ServiceClient{
client: consulClient,
logger: logger,
retryInterval: defaultRetryInterval,
maxRetryInterval: defaultMaxRetryInter... | [
"func",
"NewServiceClient",
"(",
"consulClient",
"AgentAPI",
",",
"logger",
"log",
".",
"Logger",
",",
"isNomadClient",
"bool",
")",
"*",
"ServiceClient",
"{",
"logger",
"=",
"logger",
".",
"ResetNamed",
"(",
"\"",
"\"",
")",
"\n",
"return",
"&",
"ServiceCli... | // NewServiceClient creates a new Consul ServiceClient from an existing Consul API
// Client, logger and takes whether the client is being used by a Nomad Client agent.
// When being used by a Nomad client, this Consul client reconciles all services and
// checks created by Nomad on behalf of running tasks. | [
"NewServiceClient",
"creates",
"a",
"new",
"Consul",
"ServiceClient",
"from",
"an",
"existing",
"Consul",
"API",
"Client",
"logger",
"and",
"takes",
"whether",
"the",
"client",
"is",
"being",
"used",
"by",
"a",
"Nomad",
"Client",
"agent",
".",
"When",
"being",... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L246-L268 |
133,137 | hashicorp/nomad | command/agent/consul/client.go | Run | func (c *ServiceClient) Run() {
defer close(c.exitCh)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// init will be closed when Consul has been contacted
init := make(chan struct{})
go checkConsulTLSSkipVerify(ctx, c.logger, c.client, init)
// Process operations while waiting for init... | go | func (c *ServiceClient) Run() {
defer close(c.exitCh)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// init will be closed when Consul has been contacted
init := make(chan struct{})
go checkConsulTLSSkipVerify(ctx, c.logger, c.client, init)
// Process operations while waiting for init... | [
"func",
"(",
"c",
"*",
"ServiceClient",
")",
"Run",
"(",
")",
"{",
"defer",
"close",
"(",
"c",
".",
"exitCh",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"context",
".",
"Background",
"(",
")",
")",
"\n",
"defer",
"c... | // Run the Consul main loop which retries operations against Consul. It should
// be called exactly once. | [
"Run",
"the",
"Consul",
"main",
"loop",
"which",
"retries",
"operations",
"against",
"Consul",
".",
"It",
"should",
"be",
"called",
"exactly",
"once",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L287-L386 |
133,138 | hashicorp/nomad | command/agent/consul/client.go | commit | func (c *ServiceClient) commit(ops *operations) {
select {
case c.opCh <- ops:
case <-c.shutdownCh:
}
} | go | func (c *ServiceClient) commit(ops *operations) {
select {
case c.opCh <- ops:
case <-c.shutdownCh:
}
} | [
"func",
"(",
"c",
"*",
"ServiceClient",
")",
"commit",
"(",
"ops",
"*",
"operations",
")",
"{",
"select",
"{",
"case",
"c",
".",
"opCh",
"<-",
"ops",
":",
"case",
"<-",
"c",
".",
"shutdownCh",
":",
"}",
"\n",
"}"
] | // commit operations unless already shutting down. | [
"commit",
"operations",
"unless",
"already",
"shutting",
"down",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L389-L394 |
133,139 | hashicorp/nomad | command/agent/consul/client.go | merge | func (c *ServiceClient) merge(ops *operations) {
for _, s := range ops.regServices {
c.services[s.ID] = s
}
for _, check := range ops.regChecks {
c.checks[check.ID] = check
}
for _, s := range ops.scripts {
c.scripts[s.id] = s
}
for _, sid := range ops.deregServices {
delete(c.services, sid)
}
for _, c... | go | func (c *ServiceClient) merge(ops *operations) {
for _, s := range ops.regServices {
c.services[s.ID] = s
}
for _, check := range ops.regChecks {
c.checks[check.ID] = check
}
for _, s := range ops.scripts {
c.scripts[s.id] = s
}
for _, sid := range ops.deregServices {
delete(c.services, sid)
}
for _, c... | [
"func",
"(",
"c",
"*",
"ServiceClient",
")",
"merge",
"(",
"ops",
"*",
"operations",
")",
"{",
"for",
"_",
",",
"s",
":=",
"range",
"ops",
".",
"regServices",
"{",
"c",
".",
"services",
"[",
"s",
".",
"ID",
"]",
"=",
"s",
"\n",
"}",
"\n",
"for"... | // merge registrations into state map prior to sync'ing with Consul | [
"merge",
"registrations",
"into",
"state",
"map",
"prior",
"to",
"sync",
"ing",
"with",
"Consul"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L397-L421 |
133,140 | hashicorp/nomad | command/agent/consul/client.go | serviceRegs | func (c *ServiceClient) serviceRegs(ops *operations, service *structs.Service, task *TaskServices) (
*ServiceRegistration, error) {
// Get the services ID
id := makeTaskServiceID(task.AllocID, task.Name, service, task.Canary)
sreg := &ServiceRegistration{
serviceID: id,
checkIDs: make(map[string]struct{}, len... | go | func (c *ServiceClient) serviceRegs(ops *operations, service *structs.Service, task *TaskServices) (
*ServiceRegistration, error) {
// Get the services ID
id := makeTaskServiceID(task.AllocID, task.Name, service, task.Canary)
sreg := &ServiceRegistration{
serviceID: id,
checkIDs: make(map[string]struct{}, len... | [
"func",
"(",
"c",
"*",
"ServiceClient",
")",
"serviceRegs",
"(",
"ops",
"*",
"operations",
",",
"service",
"*",
"structs",
".",
"Service",
",",
"task",
"*",
"TaskServices",
")",
"(",
"*",
"ServiceRegistration",
",",
"error",
")",
"{",
"// Get the services ID... | // serviceRegs creates service registrations, check registrations, and script
// checks from a service. It returns a service registration object with the
// service and check IDs populated. | [
"serviceRegs",
"creates",
"service",
"registrations",
"check",
"registrations",
"and",
"script",
"checks",
"from",
"a",
"service",
".",
"It",
"returns",
"a",
"service",
"registration",
"object",
"with",
"the",
"service",
"and",
"check",
"IDs",
"populated",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L631-L686 |
133,141 | hashicorp/nomad | command/agent/consul/client.go | checkRegs | func (c *ServiceClient) checkRegs(ops *operations, serviceID string, service *structs.Service,
task *TaskServices) ([]string, error) {
// Fast path
numChecks := len(service.Checks)
if numChecks == 0 {
return nil, nil
}
checkIDs := make([]string, 0, numChecks)
for _, check := range service.Checks {
checkID ... | go | func (c *ServiceClient) checkRegs(ops *operations, serviceID string, service *structs.Service,
task *TaskServices) ([]string, error) {
// Fast path
numChecks := len(service.Checks)
if numChecks == 0 {
return nil, nil
}
checkIDs := make([]string, 0, numChecks)
for _, check := range service.Checks {
checkID ... | [
"func",
"(",
"c",
"*",
"ServiceClient",
")",
"checkRegs",
"(",
"ops",
"*",
"operations",
",",
"serviceID",
"string",
",",
"service",
"*",
"structs",
".",
"Service",
",",
"task",
"*",
"TaskServices",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",... | // checkRegs registers the checks for the given service and returns the
// registered check ids. | [
"checkRegs",
"registers",
"the",
"checks",
"for",
"the",
"given",
"service",
"and",
"returns",
"the",
"registered",
"check",
"ids",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L690-L746 |
133,142 | hashicorp/nomad | command/agent/consul/client.go | AllocRegistrations | func (c *ServiceClient) AllocRegistrations(allocID string) (*AllocRegistration, error) {
// Get the internal struct using the lock
c.allocRegistrationsLock.RLock()
regInternal, ok := c.allocRegistrations[allocID]
if !ok {
c.allocRegistrationsLock.RUnlock()
return nil, nil
}
// Copy so we don't expose interna... | go | func (c *ServiceClient) AllocRegistrations(allocID string) (*AllocRegistration, error) {
// Get the internal struct using the lock
c.allocRegistrationsLock.RLock()
regInternal, ok := c.allocRegistrations[allocID]
if !ok {
c.allocRegistrationsLock.RUnlock()
return nil, nil
}
// Copy so we don't expose interna... | [
"func",
"(",
"c",
"*",
"ServiceClient",
")",
"AllocRegistrations",
"(",
"allocID",
"string",
")",
"(",
"*",
"AllocRegistration",
",",
"error",
")",
"{",
"// Get the internal struct using the lock",
"c",
".",
"allocRegistrationsLock",
".",
"RLock",
"(",
")",
"\n",
... | // AllocRegistrations returns the registrations for the given allocation. If the
// allocation has no reservations, the response is a nil object. | [
"AllocRegistrations",
"returns",
"the",
"registrations",
"for",
"the",
"given",
"allocation",
".",
"If",
"the",
"allocation",
"has",
"no",
"reservations",
"the",
"response",
"is",
"a",
"nil",
"object",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L942-L979 |
133,143 | hashicorp/nomad | command/agent/consul/client.go | Shutdown | func (c *ServiceClient) Shutdown() error {
// Serialize Shutdown calls with RegisterAgent to prevent leaking agent
// entries.
c.agentLock.Lock()
defer c.agentLock.Unlock()
select {
case <-c.shutdownCh:
return nil
default:
close(c.shutdownCh)
}
// Give run loop time to sync, but don't block indefinitely
... | go | func (c *ServiceClient) Shutdown() error {
// Serialize Shutdown calls with RegisterAgent to prevent leaking agent
// entries.
c.agentLock.Lock()
defer c.agentLock.Unlock()
select {
case <-c.shutdownCh:
return nil
default:
close(c.shutdownCh)
}
// Give run loop time to sync, but don't block indefinitely
... | [
"func",
"(",
"c",
"*",
"ServiceClient",
")",
"Shutdown",
"(",
")",
"error",
"{",
"// Serialize Shutdown calls with RegisterAgent to prevent leaking agent",
"// entries.",
"c",
".",
"agentLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"agentLock",
".",
"Unl... | // Shutdown the Consul client. Update running task registrations and deregister
// agent from Consul. On first call blocks up to shutdownWait before giving up
// on syncing operations. | [
"Shutdown",
"the",
"Consul",
"client",
".",
"Update",
"running",
"task",
"registrations",
"and",
"deregister",
"agent",
"from",
"Consul",
".",
"On",
"first",
"call",
"blocks",
"up",
"to",
"shutdownWait",
"before",
"giving",
"up",
"on",
"syncing",
"operations",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L984-L1033 |
133,144 | hashicorp/nomad | command/agent/consul/client.go | addTaskRegistration | func (c *ServiceClient) addTaskRegistration(allocID, taskName string, reg *TaskRegistration) {
c.allocRegistrationsLock.Lock()
defer c.allocRegistrationsLock.Unlock()
alloc, ok := c.allocRegistrations[allocID]
if !ok {
alloc = &AllocRegistration{
Tasks: make(map[string]*TaskRegistration),
}
c.allocRegistr... | go | func (c *ServiceClient) addTaskRegistration(allocID, taskName string, reg *TaskRegistration) {
c.allocRegistrationsLock.Lock()
defer c.allocRegistrationsLock.Unlock()
alloc, ok := c.allocRegistrations[allocID]
if !ok {
alloc = &AllocRegistration{
Tasks: make(map[string]*TaskRegistration),
}
c.allocRegistr... | [
"func",
"(",
"c",
"*",
"ServiceClient",
")",
"addTaskRegistration",
"(",
"allocID",
",",
"taskName",
"string",
",",
"reg",
"*",
"TaskRegistration",
")",
"{",
"c",
".",
"allocRegistrationsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"allocRegistrati... | // addTaskRegistration adds the task registration for the given allocation. | [
"addTaskRegistration",
"adds",
"the",
"task",
"registration",
"for",
"the",
"given",
"allocation",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L1036-L1048 |
133,145 | hashicorp/nomad | command/agent/consul/client.go | removeTaskRegistration | func (c *ServiceClient) removeTaskRegistration(allocID, taskName string) {
c.allocRegistrationsLock.Lock()
defer c.allocRegistrationsLock.Unlock()
alloc, ok := c.allocRegistrations[allocID]
if !ok {
return
}
// Delete the task and if it is the last one also delete the alloc's
// registration
delete(alloc.Ta... | go | func (c *ServiceClient) removeTaskRegistration(allocID, taskName string) {
c.allocRegistrationsLock.Lock()
defer c.allocRegistrationsLock.Unlock()
alloc, ok := c.allocRegistrations[allocID]
if !ok {
return
}
// Delete the task and if it is the last one also delete the alloc's
// registration
delete(alloc.Ta... | [
"func",
"(",
"c",
"*",
"ServiceClient",
")",
"removeTaskRegistration",
"(",
"allocID",
",",
"taskName",
"string",
")",
"{",
"c",
".",
"allocRegistrationsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"allocRegistrationsLock",
".",
"Unlock",
"(",
")",... | // removeTaskRegistration removes the task registration for the given allocation. | [
"removeTaskRegistration",
"removes",
"the",
"task",
"registration",
"for",
"the",
"given",
"allocation",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L1051-L1066 |
133,146 | hashicorp/nomad | command/agent/consul/client.go | makeCheckID | func makeCheckID(serviceID string, check *structs.ServiceCheck) string {
return check.Hash(serviceID)
} | go | func makeCheckID(serviceID string, check *structs.ServiceCheck) string {
return check.Hash(serviceID)
} | [
"func",
"makeCheckID",
"(",
"serviceID",
"string",
",",
"check",
"*",
"structs",
".",
"ServiceCheck",
")",
"string",
"{",
"return",
"check",
".",
"Hash",
"(",
"serviceID",
")",
"\n",
"}"
] | // makeCheckID creates a unique ID for a check. | [
"makeCheckID",
"creates",
"a",
"unique",
"ID",
"for",
"a",
"check",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L1091-L1093 |
133,147 | hashicorp/nomad | command/agent/consul/client.go | createCheckReg | func createCheckReg(serviceID, checkID string, check *structs.ServiceCheck, host string, port int) (*api.AgentCheckRegistration, error) {
chkReg := api.AgentCheckRegistration{
ID: checkID,
Name: check.Name,
ServiceID: serviceID,
}
chkReg.Status = check.InitialStatus
chkReg.Timeout = check.Timeout.... | go | func createCheckReg(serviceID, checkID string, check *structs.ServiceCheck, host string, port int) (*api.AgentCheckRegistration, error) {
chkReg := api.AgentCheckRegistration{
ID: checkID,
Name: check.Name,
ServiceID: serviceID,
}
chkReg.Status = check.InitialStatus
chkReg.Timeout = check.Timeout.... | [
"func",
"createCheckReg",
"(",
"serviceID",
",",
"checkID",
"string",
",",
"check",
"*",
"structs",
".",
"ServiceCheck",
",",
"host",
"string",
",",
"port",
"int",
")",
"(",
"*",
"api",
".",
"AgentCheckRegistration",
",",
"error",
")",
"{",
"chkReg",
":=",... | // createCheckReg creates a Check that can be registered with Consul.
//
// Script checks simply have a TTL set and the caller is responsible for
// running the script and heartbeating. | [
"createCheckReg",
"creates",
"a",
"Check",
"that",
"can",
"be",
"registered",
"with",
"Consul",
".",
"Script",
"checks",
"simply",
"have",
"a",
"TTL",
"set",
"and",
"the",
"caller",
"is",
"responsible",
"for",
"running",
"the",
"script",
"and",
"heartbeating",... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/client.go#L1099-L1155 |
133,148 | hashicorp/nomad | nomad/structs/bitmap.go | NewBitmap | func NewBitmap(size uint) (Bitmap, error) {
if size == 0 {
return nil, fmt.Errorf("bitmap must be positive size")
}
if size&7 != 0 {
return nil, fmt.Errorf("bitmap must be byte aligned")
}
b := make([]byte, size>>3)
return Bitmap(b), nil
} | go | func NewBitmap(size uint) (Bitmap, error) {
if size == 0 {
return nil, fmt.Errorf("bitmap must be positive size")
}
if size&7 != 0 {
return nil, fmt.Errorf("bitmap must be byte aligned")
}
b := make([]byte, size>>3)
return Bitmap(b), nil
} | [
"func",
"NewBitmap",
"(",
"size",
"uint",
")",
"(",
"Bitmap",
",",
"error",
")",
"{",
"if",
"size",
"==",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"size",
"&",
"7",
"!=",
"0",
"{",
"re... | // NewBitmap returns a bitmap with up to size indexes | [
"NewBitmap",
"returns",
"a",
"bitmap",
"with",
"up",
"to",
"size",
"indexes"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/bitmap.go#L9-L18 |
133,149 | hashicorp/nomad | nomad/structs/bitmap.go | Copy | func (b Bitmap) Copy() (Bitmap, error) {
if b == nil {
return nil, fmt.Errorf("can't copy nil Bitmap")
}
raw := make([]byte, len(b))
copy(raw, b)
return Bitmap(raw), nil
} | go | func (b Bitmap) Copy() (Bitmap, error) {
if b == nil {
return nil, fmt.Errorf("can't copy nil Bitmap")
}
raw := make([]byte, len(b))
copy(raw, b)
return Bitmap(raw), nil
} | [
"func",
"(",
"b",
"Bitmap",
")",
"Copy",
"(",
")",
"(",
"Bitmap",
",",
"error",
")",
"{",
"if",
"b",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"raw",
":=",
"make",
"(",
"[",
"]",
... | // Copy returns a copy of the Bitmap | [
"Copy",
"returns",
"a",
"copy",
"of",
"the",
"Bitmap"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/bitmap.go#L21-L29 |
133,150 | hashicorp/nomad | nomad/structs/bitmap.go | Set | func (b Bitmap) Set(idx uint) {
bucket := idx >> 3
mask := byte(1 << (idx & 7))
b[bucket] |= mask
} | go | func (b Bitmap) Set(idx uint) {
bucket := idx >> 3
mask := byte(1 << (idx & 7))
b[bucket] |= mask
} | [
"func",
"(",
"b",
"Bitmap",
")",
"Set",
"(",
"idx",
"uint",
")",
"{",
"bucket",
":=",
"idx",
">>",
"3",
"\n",
"mask",
":=",
"byte",
"(",
"1",
"<<",
"(",
"idx",
"&",
"7",
")",
")",
"\n",
"b",
"[",
"bucket",
"]",
"|=",
"mask",
"\n",
"}"
] | // Set is used to set the given index of the bitmap | [
"Set",
"is",
"used",
"to",
"set",
"the",
"given",
"index",
"of",
"the",
"bitmap"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/bitmap.go#L37-L41 |
133,151 | hashicorp/nomad | nomad/structs/bitmap.go | Unset | func (b Bitmap) Unset(idx uint) {
bucket := idx >> 3
// Mask should be all ones minus the idx position
offset := 1 << (idx & 7)
mask := byte(offset ^ 0xff)
b[bucket] &= mask
} | go | func (b Bitmap) Unset(idx uint) {
bucket := idx >> 3
// Mask should be all ones minus the idx position
offset := 1 << (idx & 7)
mask := byte(offset ^ 0xff)
b[bucket] &= mask
} | [
"func",
"(",
"b",
"Bitmap",
")",
"Unset",
"(",
"idx",
"uint",
")",
"{",
"bucket",
":=",
"idx",
">>",
"3",
"\n",
"// Mask should be all ones minus the idx position",
"offset",
":=",
"1",
"<<",
"(",
"idx",
"&",
"7",
")",
"\n",
"mask",
":=",
"byte",
"(",
... | // Unset is used to unset the given index of the bitmap | [
"Unset",
"is",
"used",
"to",
"unset",
"the",
"given",
"index",
"of",
"the",
"bitmap"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/bitmap.go#L44-L50 |
133,152 | hashicorp/nomad | nomad/structs/bitmap.go | Check | func (b Bitmap) Check(idx uint) bool {
bucket := idx >> 3
mask := byte(1 << (idx & 7))
return (b[bucket] & mask) != 0
} | go | func (b Bitmap) Check(idx uint) bool {
bucket := idx >> 3
mask := byte(1 << (idx & 7))
return (b[bucket] & mask) != 0
} | [
"func",
"(",
"b",
"Bitmap",
")",
"Check",
"(",
"idx",
"uint",
")",
"bool",
"{",
"bucket",
":=",
"idx",
">>",
"3",
"\n",
"mask",
":=",
"byte",
"(",
"1",
"<<",
"(",
"idx",
"&",
"7",
")",
")",
"\n",
"return",
"(",
"b",
"[",
"bucket",
"]",
"&",
... | // Check is used to check the given index of the bitmap | [
"Check",
"is",
"used",
"to",
"check",
"the",
"given",
"index",
"of",
"the",
"bitmap"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/bitmap.go#L53-L57 |
133,153 | hashicorp/nomad | nomad/structs/bitmap.go | IndexesInRange | func (b Bitmap) IndexesInRange(set bool, from, to uint) []int {
var indexes []int
for i := from; i <= to && i < b.Size(); i++ {
c := b.Check(i)
if c && set || !c && !set {
indexes = append(indexes, int(i))
}
}
return indexes
} | go | func (b Bitmap) IndexesInRange(set bool, from, to uint) []int {
var indexes []int
for i := from; i <= to && i < b.Size(); i++ {
c := b.Check(i)
if c && set || !c && !set {
indexes = append(indexes, int(i))
}
}
return indexes
} | [
"func",
"(",
"b",
"Bitmap",
")",
"IndexesInRange",
"(",
"set",
"bool",
",",
"from",
",",
"to",
"uint",
")",
"[",
"]",
"int",
"{",
"var",
"indexes",
"[",
"]",
"int",
"\n",
"for",
"i",
":=",
"from",
";",
"i",
"<=",
"to",
"&&",
"i",
"<",
"b",
".... | // IndexesInRange returns the indexes in which the values are either set or unset based
// on the passed parameter in the passed range | [
"IndexesInRange",
"returns",
"the",
"indexes",
"in",
"which",
"the",
"values",
"are",
"either",
"set",
"or",
"unset",
"based",
"on",
"the",
"passed",
"parameter",
"in",
"the",
"passed",
"range"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/bitmap.go#L68-L78 |
133,154 | hashicorp/nomad | plugins/drivers/client.go | Fingerprint | func (d *driverPluginClient) Fingerprint(ctx context.Context) (<-chan *Fingerprint, error) {
req := &proto.FingerprintRequest{}
// Join the passed context and the shutdown context
joinedCtx, _ := joincontext.Join(ctx, d.doneCtx)
stream, err := d.client.Fingerprint(joinedCtx, req)
if err != nil {
return nil, gr... | go | func (d *driverPluginClient) Fingerprint(ctx context.Context) (<-chan *Fingerprint, error) {
req := &proto.FingerprintRequest{}
// Join the passed context and the shutdown context
joinedCtx, _ := joincontext.Join(ctx, d.doneCtx)
stream, err := d.client.Fingerprint(joinedCtx, req)
if err != nil {
return nil, gr... | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"Fingerprint",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"<-",
"chan",
"*",
"Fingerprint",
",",
"error",
")",
"{",
"req",
":=",
"&",
"proto",
".",
"FingerprintRequest",
"{",
"}",
"\n\n",
"// Join t... | // Fingerprint the driver, return a chan that will be pushed to periodically and on changes to health | [
"Fingerprint",
"the",
"driver",
"return",
"a",
"chan",
"that",
"will",
"be",
"pushed",
"to",
"periodically",
"and",
"on",
"changes",
"to",
"health"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L75-L90 |
133,155 | hashicorp/nomad | plugins/drivers/client.go | RecoverTask | func (d *driverPluginClient) RecoverTask(h *TaskHandle) error {
req := &proto.RecoverTaskRequest{Handle: taskHandleToProto(h)}
_, err := d.client.RecoverTask(d.doneCtx, req)
return grpcutils.HandleGrpcErr(err, d.doneCtx)
} | go | func (d *driverPluginClient) RecoverTask(h *TaskHandle) error {
req := &proto.RecoverTaskRequest{Handle: taskHandleToProto(h)}
_, err := d.client.RecoverTask(d.doneCtx, req)
return grpcutils.HandleGrpcErr(err, d.doneCtx)
} | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"RecoverTask",
"(",
"h",
"*",
"TaskHandle",
")",
"error",
"{",
"req",
":=",
"&",
"proto",
".",
"RecoverTaskRequest",
"{",
"Handle",
":",
"taskHandleToProto",
"(",
"h",
")",
"}",
"\n\n",
"_",
",",
"err",
... | // RecoverTask does internal state recovery to be able to control the task of
// the given TaskHandle | [
"RecoverTask",
"does",
"internal",
"state",
"recovery",
"to",
"be",
"able",
"to",
"control",
"the",
"task",
"of",
"the",
"given",
"TaskHandle"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L123-L128 |
133,156 | hashicorp/nomad | plugins/drivers/client.go | StartTask | func (d *driverPluginClient) StartTask(c *TaskConfig) (*TaskHandle, *DriverNetwork, error) {
req := &proto.StartTaskRequest{
Task: taskConfigToProto(c),
}
resp, err := d.client.StartTask(d.doneCtx, req)
if err != nil {
st := status.Convert(err)
if len(st.Details()) > 0 {
if rec, ok := st.Details()[0].(*sp... | go | func (d *driverPluginClient) StartTask(c *TaskConfig) (*TaskHandle, *DriverNetwork, error) {
req := &proto.StartTaskRequest{
Task: taskConfigToProto(c),
}
resp, err := d.client.StartTask(d.doneCtx, req)
if err != nil {
st := status.Convert(err)
if len(st.Details()) > 0 {
if rec, ok := st.Details()[0].(*sp... | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"StartTask",
"(",
"c",
"*",
"TaskConfig",
")",
"(",
"*",
"TaskHandle",
",",
"*",
"DriverNetwork",
",",
"error",
")",
"{",
"req",
":=",
"&",
"proto",
".",
"StartTaskRequest",
"{",
"Task",
":",
"taskConfigT... | // StartTask starts execution of a task with the given TaskConfig. A TaskHandle
// is returned to the caller that can be used to recover state of the task,
// should the driver crash or exit prematurely. | [
"StartTask",
"starts",
"execution",
"of",
"a",
"task",
"with",
"the",
"given",
"TaskConfig",
".",
"A",
"TaskHandle",
"is",
"returned",
"to",
"the",
"caller",
"that",
"can",
"be",
"used",
"to",
"recover",
"state",
"of",
"the",
"task",
"should",
"the",
"driv... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L133-L162 |
133,157 | hashicorp/nomad | plugins/drivers/client.go | WaitTask | func (d *driverPluginClient) WaitTask(ctx context.Context, id string) (<-chan *ExitResult, error) {
ch := make(chan *ExitResult)
go d.handleWaitTask(ctx, id, ch)
return ch, nil
} | go | func (d *driverPluginClient) WaitTask(ctx context.Context, id string) (<-chan *ExitResult, error) {
ch := make(chan *ExitResult)
go d.handleWaitTask(ctx, id, ch)
return ch, nil
} | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"WaitTask",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"<-",
"chan",
"*",
"ExitResult",
",",
"error",
")",
"{",
"ch",
":=",
"make",
"(",
"chan",
"*",
"ExitResult",
")",
"\n"... | // WaitTask returns a channel that will have an ExitResult pushed to it once when the task
// exits on its own or is killed. If WaitTask is called after the task has exited, the channel
// will immedialy return the ExitResult. WaitTask can be called multiple times for
// the same task without issue. | [
"WaitTask",
"returns",
"a",
"channel",
"that",
"will",
"have",
"an",
"ExitResult",
"pushed",
"to",
"it",
"once",
"when",
"the",
"task",
"exits",
"on",
"its",
"own",
"or",
"is",
"killed",
".",
"If",
"WaitTask",
"is",
"called",
"after",
"the",
"task",
"has... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L168-L172 |
133,158 | hashicorp/nomad | plugins/drivers/client.go | StopTask | func (d *driverPluginClient) StopTask(taskID string, timeout time.Duration, signal string) error {
req := &proto.StopTaskRequest{
TaskId: taskID,
Timeout: ptypes.DurationProto(timeout),
Signal: signal,
}
_, err := d.client.StopTask(d.doneCtx, req)
return grpcutils.HandleGrpcErr(err, d.doneCtx)
} | go | func (d *driverPluginClient) StopTask(taskID string, timeout time.Duration, signal string) error {
req := &proto.StopTaskRequest{
TaskId: taskID,
Timeout: ptypes.DurationProto(timeout),
Signal: signal,
}
_, err := d.client.StopTask(d.doneCtx, req)
return grpcutils.HandleGrpcErr(err, d.doneCtx)
} | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"StopTask",
"(",
"taskID",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"signal",
"string",
")",
"error",
"{",
"req",
":=",
"&",
"proto",
".",
"StopTaskRequest",
"{",
"TaskId",
":",
"taskID",
"... | // StopTask stops the task with the given taskID. A timeout and signal can be
// given to control a graceful termination of the task. The driver will send the
// given signal to the task and wait for the given timeout for it to exit. If the
// task does not exit within the timeout it will be forcefully killed. | [
"StopTask",
"stops",
"the",
"task",
"with",
"the",
"given",
"taskID",
".",
"A",
"timeout",
"and",
"signal",
"can",
"be",
"given",
"to",
"control",
"a",
"graceful",
"termination",
"of",
"the",
"task",
".",
"The",
"driver",
"will",
"send",
"the",
"given",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L202-L211 |
133,159 | hashicorp/nomad | plugins/drivers/client.go | DestroyTask | func (d *driverPluginClient) DestroyTask(taskID string, force bool) error {
req := &proto.DestroyTaskRequest{
TaskId: taskID,
Force: force,
}
_, err := d.client.DestroyTask(d.doneCtx, req)
return grpcutils.HandleGrpcErr(err, d.doneCtx)
} | go | func (d *driverPluginClient) DestroyTask(taskID string, force bool) error {
req := &proto.DestroyTaskRequest{
TaskId: taskID,
Force: force,
}
_, err := d.client.DestroyTask(d.doneCtx, req)
return grpcutils.HandleGrpcErr(err, d.doneCtx)
} | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"DestroyTask",
"(",
"taskID",
"string",
",",
"force",
"bool",
")",
"error",
"{",
"req",
":=",
"&",
"proto",
".",
"DestroyTaskRequest",
"{",
"TaskId",
":",
"taskID",
",",
"Force",
":",
"force",
",",
"}",
... | // DestroyTask removes the task from the driver's in memory state. The task
// cannot be running unless force is set to true. If force is set to true the
// driver will forcefully terminate the task before removing it. | [
"DestroyTask",
"removes",
"the",
"task",
"from",
"the",
"driver",
"s",
"in",
"memory",
"state",
".",
"The",
"task",
"cannot",
"be",
"running",
"unless",
"force",
"is",
"set",
"to",
"true",
".",
"If",
"force",
"is",
"set",
"to",
"true",
"the",
"driver",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L216-L224 |
133,160 | hashicorp/nomad | plugins/drivers/client.go | InspectTask | func (d *driverPluginClient) InspectTask(taskID string) (*TaskStatus, error) {
req := &proto.InspectTaskRequest{TaskId: taskID}
resp, err := d.client.InspectTask(d.doneCtx, req)
if err != nil {
return nil, grpcutils.HandleGrpcErr(err, d.doneCtx)
}
status, err := taskStatusFromProto(resp.Task)
if err != nil {
... | go | func (d *driverPluginClient) InspectTask(taskID string) (*TaskStatus, error) {
req := &proto.InspectTaskRequest{TaskId: taskID}
resp, err := d.client.InspectTask(d.doneCtx, req)
if err != nil {
return nil, grpcutils.HandleGrpcErr(err, d.doneCtx)
}
status, err := taskStatusFromProto(resp.Task)
if err != nil {
... | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"InspectTask",
"(",
"taskID",
"string",
")",
"(",
"*",
"TaskStatus",
",",
"error",
")",
"{",
"req",
":=",
"&",
"proto",
".",
"InspectTaskRequest",
"{",
"TaskId",
":",
"taskID",
"}",
"\n\n",
"resp",
",",
... | // InspectTask returns status information for a task | [
"InspectTask",
"returns",
"status",
"information",
"for",
"a",
"task"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L227-L255 |
133,161 | hashicorp/nomad | plugins/drivers/client.go | TaskStats | func (d *driverPluginClient) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *cstructs.TaskResourceUsage, error) {
req := &proto.TaskStatsRequest{
TaskId: taskID,
CollectionInterval: ptypes.DurationProto(interval),
}
ctx, _ = joincontext.Join(ctx, d.doneCtx)
stream, err... | go | func (d *driverPluginClient) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *cstructs.TaskResourceUsage, error) {
req := &proto.TaskStatsRequest{
TaskId: taskID,
CollectionInterval: ptypes.DurationProto(interval),
}
ctx, _ = joincontext.Join(ctx, d.doneCtx)
stream, err... | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"TaskStats",
"(",
"ctx",
"context",
".",
"Context",
",",
"taskID",
"string",
",",
"interval",
"time",
".",
"Duration",
")",
"(",
"<-",
"chan",
"*",
"cstructs",
".",
"TaskResourceUsage",
",",
"error",
")",
... | // TaskStats returns resource usage statistics for the task | [
"TaskStats",
"returns",
"resource",
"usage",
"statistics",
"for",
"the",
"task"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L258-L279 |
133,162 | hashicorp/nomad | plugins/drivers/client.go | TaskEvents | func (d *driverPluginClient) TaskEvents(ctx context.Context) (<-chan *TaskEvent, error) {
req := &proto.TaskEventsRequest{}
// Join the passed context and the shutdown context
joinedCtx, _ := joincontext.Join(ctx, d.doneCtx)
stream, err := d.client.TaskEvents(joinedCtx, req)
if err != nil {
return nil, grpcuti... | go | func (d *driverPluginClient) TaskEvents(ctx context.Context) (<-chan *TaskEvent, error) {
req := &proto.TaskEventsRequest{}
// Join the passed context and the shutdown context
joinedCtx, _ := joincontext.Join(ctx, d.doneCtx)
stream, err := d.client.TaskEvents(joinedCtx, req)
if err != nil {
return nil, grpcuti... | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"TaskEvents",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"<-",
"chan",
"*",
"TaskEvent",
",",
"error",
")",
"{",
"req",
":=",
"&",
"proto",
".",
"TaskEventsRequest",
"{",
"}",
"\n\n",
"// Join the p... | // TaskEvents returns a channel that will receive events from the driver about all
// tasks such as lifecycle events, terminal errors, etc. | [
"TaskEvents",
"returns",
"a",
"channel",
"that",
"will",
"receive",
"events",
"from",
"the",
"driver",
"about",
"all",
"tasks",
"such",
"as",
"lifecycle",
"events",
"terminal",
"errors",
"etc",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L314-L328 |
133,163 | hashicorp/nomad | plugins/drivers/client.go | SignalTask | func (d *driverPluginClient) SignalTask(taskID string, signal string) error {
req := &proto.SignalTaskRequest{
TaskId: taskID,
Signal: signal,
}
_, err := d.client.SignalTask(d.doneCtx, req)
return grpcutils.HandleGrpcErr(err, d.doneCtx)
} | go | func (d *driverPluginClient) SignalTask(taskID string, signal string) error {
req := &proto.SignalTaskRequest{
TaskId: taskID,
Signal: signal,
}
_, err := d.client.SignalTask(d.doneCtx, req)
return grpcutils.HandleGrpcErr(err, d.doneCtx)
} | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"SignalTask",
"(",
"taskID",
"string",
",",
"signal",
"string",
")",
"error",
"{",
"req",
":=",
"&",
"proto",
".",
"SignalTaskRequest",
"{",
"TaskId",
":",
"taskID",
",",
"Signal",
":",
"signal",
",",
"}"... | // SignalTask will send the given signal to the specified task | [
"SignalTask",
"will",
"send",
"the",
"given",
"signal",
"to",
"the",
"specified",
"task"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L363-L370 |
133,164 | hashicorp/nomad | plugins/drivers/client.go | ExecTask | func (d *driverPluginClient) ExecTask(taskID string, cmd []string, timeout time.Duration) (*ExecTaskResult, error) {
req := &proto.ExecTaskRequest{
TaskId: taskID,
Command: cmd,
Timeout: ptypes.DurationProto(timeout),
}
resp, err := d.client.ExecTask(d.doneCtx, req)
if err != nil {
return nil, grpcutils.H... | go | func (d *driverPluginClient) ExecTask(taskID string, cmd []string, timeout time.Duration) (*ExecTaskResult, error) {
req := &proto.ExecTaskRequest{
TaskId: taskID,
Command: cmd,
Timeout: ptypes.DurationProto(timeout),
}
resp, err := d.client.ExecTask(d.doneCtx, req)
if err != nil {
return nil, grpcutils.H... | [
"func",
"(",
"d",
"*",
"driverPluginClient",
")",
"ExecTask",
"(",
"taskID",
"string",
",",
"cmd",
"[",
"]",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"ExecTaskResult",
",",
"error",
")",
"{",
"req",
":=",
"&",
"proto",
".",
"... | // ExecTask will run the given command within the execution context of the task.
// The driver will wait for the given timeout for the command to complete before
// terminating it. The stdout and stderr of the command will be return to the caller,
// along with other exit information such as exit code. | [
"ExecTask",
"will",
"run",
"the",
"given",
"command",
"within",
"the",
"execution",
"context",
"of",
"the",
"task",
".",
"The",
"driver",
"will",
"wait",
"for",
"the",
"given",
"timeout",
"for",
"the",
"command",
"to",
"complete",
"before",
"terminating",
"i... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/drivers/client.go#L376-L396 |
133,165 | hashicorp/nomad | e2e/e2eutil/utils.go | WaitForNodesReady | func WaitForNodesReady(t *testing.T, nomadClient *api.Client, nodes int) {
nodesAPI := nomadClient.Nodes()
testutil.WaitForResultRetries(retries, func() (bool, error) {
defer time.Sleep(time.Millisecond * 100)
nodesList, _, err := nodesAPI.List(nil)
if err != nil {
return false, fmt.Errorf("error listing no... | go | func WaitForNodesReady(t *testing.T, nomadClient *api.Client, nodes int) {
nodesAPI := nomadClient.Nodes()
testutil.WaitForResultRetries(retries, func() (bool, error) {
defer time.Sleep(time.Millisecond * 100)
nodesList, _, err := nodesAPI.List(nil)
if err != nil {
return false, fmt.Errorf("error listing no... | [
"func",
"WaitForNodesReady",
"(",
"t",
"*",
"testing",
".",
"T",
",",
"nomadClient",
"*",
"api",
".",
"Client",
",",
"nodes",
"int",
")",
"{",
"nodesAPI",
":=",
"nomadClient",
".",
"Nodes",
"(",
")",
"\n\n",
"testutil",
".",
"WaitForResultRetries",
"(",
... | // WaitForNodesReady waits until at least `nodes` number of nodes are ready or
// fails the test. | [
"WaitForNodesReady",
"waits",
"until",
"at",
"least",
"nodes",
"number",
"of",
"nodes",
"are",
"ready",
"or",
"fails",
"the",
"test",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/e2e/e2eutil/utils.go#L34-L55 |
133,166 | hashicorp/nomad | nomad/leader.go | restoreEvals | func (s *Server) restoreEvals() error {
// Get an iterator over every evaluation
ws := memdb.NewWatchSet()
iter, err := s.fsm.State().Evals(ws)
if err != nil {
return fmt.Errorf("failed to get evaluations: %v", err)
}
for {
raw := iter.Next()
if raw == nil {
break
}
eval := raw.(*structs.Evaluation)... | go | func (s *Server) restoreEvals() error {
// Get an iterator over every evaluation
ws := memdb.NewWatchSet()
iter, err := s.fsm.State().Evals(ws)
if err != nil {
return fmt.Errorf("failed to get evaluations: %v", err)
}
for {
raw := iter.Next()
if raw == nil {
break
}
eval := raw.(*structs.Evaluation)... | [
"func",
"(",
"s",
"*",
"Server",
")",
"restoreEvals",
"(",
")",
"error",
"{",
"// Get an iterator over every evaluation",
"ws",
":=",
"memdb",
".",
"NewWatchSet",
"(",
")",
"\n",
"iter",
",",
"err",
":=",
"s",
".",
"fsm",
".",
"State",
"(",
")",
".",
"... | // restoreEvals is used to restore pending evaluations into the eval broker and
// blocked evaluations into the blocked eval tracker. The broker and blocked
// eval tracker is maintained only by the leader, so it must be restored anytime
// a leadership transition takes place. | [
"restoreEvals",
"is",
"used",
"to",
"restore",
"pending",
"evaluations",
"into",
"the",
"eval",
"broker",
"and",
"blocked",
"evaluations",
"into",
"the",
"blocked",
"eval",
"tracker",
".",
"The",
"broker",
"and",
"blocked",
"eval",
"tracker",
"is",
"maintained",... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L297-L319 |
133,167 | hashicorp/nomad | nomad/leader.go | restoreRevokingAccessors | func (s *Server) restoreRevokingAccessors() error {
// An accessor should be revoked if its allocation or node is terminal
ws := memdb.NewWatchSet()
state := s.fsm.State()
iter, err := state.VaultAccessors(ws)
if err != nil {
return fmt.Errorf("failed to get vault accessors: %v", err)
}
var revoke []*structs.... | go | func (s *Server) restoreRevokingAccessors() error {
// An accessor should be revoked if its allocation or node is terminal
ws := memdb.NewWatchSet()
state := s.fsm.State()
iter, err := state.VaultAccessors(ws)
if err != nil {
return fmt.Errorf("failed to get vault accessors: %v", err)
}
var revoke []*structs.... | [
"func",
"(",
"s",
"*",
"Server",
")",
"restoreRevokingAccessors",
"(",
")",
"error",
"{",
"// An accessor should be revoked if its allocation or node is terminal",
"ws",
":=",
"memdb",
".",
"NewWatchSet",
"(",
")",
"\n",
"state",
":=",
"s",
".",
"fsm",
".",
"State... | // restoreRevokingAccessors is used to restore Vault accessors that should be
// revoked. | [
"restoreRevokingAccessors",
"is",
"used",
"to",
"restore",
"Vault",
"accessors",
"that",
"should",
"be",
"revoked",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L323-L371 |
133,168 | hashicorp/nomad | nomad/leader.go | restorePeriodicDispatcher | func (s *Server) restorePeriodicDispatcher() error {
logger := s.logger.Named("periodic")
ws := memdb.NewWatchSet()
iter, err := s.fsm.State().JobsByPeriodic(ws, true)
if err != nil {
return fmt.Errorf("failed to get periodic jobs: %v", err)
}
now := time.Now()
for i := iter.Next(); i != nil; i = iter.Next() ... | go | func (s *Server) restorePeriodicDispatcher() error {
logger := s.logger.Named("periodic")
ws := memdb.NewWatchSet()
iter, err := s.fsm.State().JobsByPeriodic(ws, true)
if err != nil {
return fmt.Errorf("failed to get periodic jobs: %v", err)
}
now := time.Now()
for i := iter.Next(); i != nil; i = iter.Next() ... | [
"func",
"(",
"s",
"*",
"Server",
")",
"restorePeriodicDispatcher",
"(",
")",
"error",
"{",
"logger",
":=",
"s",
".",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
"\n",
"ws",
":=",
"memdb",
".",
"NewWatchSet",
"(",
")",
"\n",
"iter",
",",
"err",
":... | // restorePeriodicDispatcher is used to restore all periodic jobs into the
// periodic dispatcher. It also determines if a periodic job should have been
// created during the leadership transition and force runs them. The periodic
// dispatcher is maintained only by the leader, so it must be restored anytime a
// leade... | [
"restorePeriodicDispatcher",
"is",
"used",
"to",
"restore",
"all",
"periodic",
"jobs",
"into",
"the",
"periodic",
"dispatcher",
".",
"It",
"also",
"determines",
"if",
"a",
"periodic",
"job",
"should",
"have",
"been",
"created",
"during",
"the",
"leadership",
"tr... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L378-L440 |
133,169 | hashicorp/nomad | nomad/leader.go | schedulePeriodic | func (s *Server) schedulePeriodic(stopCh chan struct{}) {
evalGC := time.NewTicker(s.config.EvalGCInterval)
defer evalGC.Stop()
nodeGC := time.NewTicker(s.config.NodeGCInterval)
defer nodeGC.Stop()
jobGC := time.NewTicker(s.config.JobGCInterval)
defer jobGC.Stop()
deploymentGC := time.NewTicker(s.config.Deployme... | go | func (s *Server) schedulePeriodic(stopCh chan struct{}) {
evalGC := time.NewTicker(s.config.EvalGCInterval)
defer evalGC.Stop()
nodeGC := time.NewTicker(s.config.NodeGCInterval)
defer nodeGC.Stop()
jobGC := time.NewTicker(s.config.JobGCInterval)
defer jobGC.Stop()
deploymentGC := time.NewTicker(s.config.Deployme... | [
"func",
"(",
"s",
"*",
"Server",
")",
"schedulePeriodic",
"(",
"stopCh",
"chan",
"struct",
"{",
"}",
")",
"{",
"evalGC",
":=",
"time",
".",
"NewTicker",
"(",
"s",
".",
"config",
".",
"EvalGCInterval",
")",
"\n",
"defer",
"evalGC",
".",
"Stop",
"(",
"... | // schedulePeriodic is used to do periodic job dispatch while we are leader | [
"schedulePeriodic",
"is",
"used",
"to",
"do",
"periodic",
"job",
"dispatch",
"while",
"we",
"are",
"leader"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L443-L488 |
133,170 | hashicorp/nomad | nomad/leader.go | coreJobEval | func (s *Server) coreJobEval(job string, modifyIndex uint64) *structs.Evaluation {
return &structs.Evaluation{
ID: uuid.Generate(),
Namespace: "-",
Priority: structs.CoreJobPriority,
Type: structs.JobTypeCore,
TriggeredBy: structs.EvalTriggerScheduled,
JobID: job,
LeaderACL: ... | go | func (s *Server) coreJobEval(job string, modifyIndex uint64) *structs.Evaluation {
return &structs.Evaluation{
ID: uuid.Generate(),
Namespace: "-",
Priority: structs.CoreJobPriority,
Type: structs.JobTypeCore,
TriggeredBy: structs.EvalTriggerScheduled,
JobID: job,
LeaderACL: ... | [
"func",
"(",
"s",
"*",
"Server",
")",
"coreJobEval",
"(",
"job",
"string",
",",
"modifyIndex",
"uint64",
")",
"*",
"structs",
".",
"Evaluation",
"{",
"return",
"&",
"structs",
".",
"Evaluation",
"{",
"ID",
":",
"uuid",
".",
"Generate",
"(",
")",
",",
... | // coreJobEval returns an evaluation for a core job | [
"coreJobEval",
"returns",
"an",
"evaluation",
"for",
"a",
"core",
"job"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L491-L503 |
133,171 | hashicorp/nomad | nomad/leader.go | reapFailedEvaluations | func (s *Server) reapFailedEvaluations(stopCh chan struct{}) {
for {
select {
case <-stopCh:
return
default:
// Scan for a failed evaluation
eval, token, err := s.evalBroker.Dequeue([]string{failedQueue}, time.Second)
if err != nil {
return
}
if eval == nil {
continue
}
// Update... | go | func (s *Server) reapFailedEvaluations(stopCh chan struct{}) {
for {
select {
case <-stopCh:
return
default:
// Scan for a failed evaluation
eval, token, err := s.evalBroker.Dequeue([]string{failedQueue}, time.Second)
if err != nil {
return
}
if eval == nil {
continue
}
// Update... | [
"func",
"(",
"s",
"*",
"Server",
")",
"reapFailedEvaluations",
"(",
"stopCh",
"chan",
"struct",
"{",
"}",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"stopCh",
":",
"return",
"\n",
"default",
":",
"// Scan for a failed evaluation",
"eval",
",",
"tok... | // reapFailedEvaluations is used to reap evaluations that
// have reached their delivery limit and should be failed | [
"reapFailedEvaluations",
"is",
"used",
"to",
"reap",
"evaluations",
"that",
"have",
"reached",
"their",
"delivery",
"limit",
"and",
"should",
"be",
"failed"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L507-L549 |
133,172 | hashicorp/nomad | nomad/leader.go | reapDupBlockedEvaluations | func (s *Server) reapDupBlockedEvaluations(stopCh chan struct{}) {
for {
select {
case <-stopCh:
return
default:
// Scan for duplicate blocked evals.
dups := s.blockedEvals.GetDuplicates(time.Second)
if dups == nil {
continue
}
cancel := make([]*structs.Evaluation, len(dups))
for i, dup... | go | func (s *Server) reapDupBlockedEvaluations(stopCh chan struct{}) {
for {
select {
case <-stopCh:
return
default:
// Scan for duplicate blocked evals.
dups := s.blockedEvals.GetDuplicates(time.Second)
if dups == nil {
continue
}
cancel := make([]*structs.Evaluation, len(dups))
for i, dup... | [
"func",
"(",
"s",
"*",
"Server",
")",
"reapDupBlockedEvaluations",
"(",
"stopCh",
"chan",
"struct",
"{",
"}",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"stopCh",
":",
"return",
"\n",
"default",
":",
"// Scan for duplicate blocked evals.",
"dups",
":... | // reapDupBlockedEvaluations is used to reap duplicate blocked evaluations and
// should be cancelled. | [
"reapDupBlockedEvaluations",
"is",
"used",
"to",
"reap",
"duplicate",
"blocked",
"evaluations",
"and",
"should",
"be",
"cancelled",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L553-L584 |
133,173 | hashicorp/nomad | nomad/leader.go | periodicUnblockFailedEvals | func (s *Server) periodicUnblockFailedEvals(stopCh chan struct{}) {
ticker := time.NewTicker(failedEvalUnblockInterval)
defer ticker.Stop()
for {
select {
case <-stopCh:
return
case <-ticker.C:
// Unblock the failed allocations
s.blockedEvals.UnblockFailed()
}
}
} | go | func (s *Server) periodicUnblockFailedEvals(stopCh chan struct{}) {
ticker := time.NewTicker(failedEvalUnblockInterval)
defer ticker.Stop()
for {
select {
case <-stopCh:
return
case <-ticker.C:
// Unblock the failed allocations
s.blockedEvals.UnblockFailed()
}
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"periodicUnblockFailedEvals",
"(",
"stopCh",
"chan",
"struct",
"{",
"}",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"failedEvalUnblockInterval",
")",
"\n",
"defer",
"ticker",
".",
"Stop",
"(",
")",
"\n",
... | // periodicUnblockFailedEvals periodically unblocks failed, blocked evaluations. | [
"periodicUnblockFailedEvals",
"periodically",
"unblocks",
"failed",
"blocked",
"evaluations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L587-L599 |
133,174 | hashicorp/nomad | nomad/leader.go | publishJobSummaryMetrics | func (s *Server) publishJobSummaryMetrics(stopCh chan struct{}) {
timer := time.NewTimer(0)
defer timer.Stop()
for {
select {
case <-stopCh:
return
case <-timer.C:
timer.Reset(s.config.StatsCollectionInterval)
state, err := s.State().Snapshot()
if err != nil {
s.logger.Error("failed to get sta... | go | func (s *Server) publishJobSummaryMetrics(stopCh chan struct{}) {
timer := time.NewTimer(0)
defer timer.Stop()
for {
select {
case <-stopCh:
return
case <-timer.C:
timer.Reset(s.config.StatsCollectionInterval)
state, err := s.State().Snapshot()
if err != nil {
s.logger.Error("failed to get sta... | [
"func",
"(",
"s",
"*",
"Server",
")",
"publishJobSummaryMetrics",
"(",
"stopCh",
"chan",
"struct",
"{",
"}",
")",
"{",
"timer",
":=",
"time",
".",
"NewTimer",
"(",
"0",
")",
"\n",
"defer",
"timer",
".",
"Stop",
"(",
")",
"\n\n",
"for",
"{",
"select",... | // publishJobSummaryMetrics publishes the job summaries as metrics | [
"publishJobSummaryMetrics",
"publishes",
"the",
"job",
"summaries",
"as",
"metrics"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L602-L644 |
133,175 | hashicorp/nomad | nomad/leader.go | reconcile | func (s *Server) reconcile() error {
defer metrics.MeasureSince([]string{"nomad", "leader", "reconcile"}, time.Now())
members := s.serf.Members()
for _, member := range members {
if err := s.reconcileMember(member); err != nil {
return err
}
}
return nil
} | go | func (s *Server) reconcile() error {
defer metrics.MeasureSince([]string{"nomad", "leader", "reconcile"}, time.Now())
members := s.serf.Members()
for _, member := range members {
if err := s.reconcileMember(member); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"reconcile",
"(",
")",
"error",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"time",
".",
"Now",
"(",
")",
")",
"\n",
... | // reconcile is used to reconcile the differences between Serf
// membership and what is reflected in our strongly consistent store. | [
"reconcile",
"is",
"used",
"to",
"reconcile",
"the",
"differences",
"between",
"Serf",
"membership",
"and",
"what",
"is",
"reflected",
"in",
"our",
"strongly",
"consistent",
"store",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L761-L770 |
133,176 | hashicorp/nomad | nomad/leader.go | reconcileJobSummaries | func (s *Server) reconcileJobSummaries() error {
index, err := s.fsm.state.LatestIndex()
if err != nil {
return fmt.Errorf("unable to read latest index: %v", err)
}
s.logger.Debug("leader reconciling job summaries", "index", index)
args := &structs.GenericResponse{}
msg := structs.ReconcileJobSummariesRequestT... | go | func (s *Server) reconcileJobSummaries() error {
index, err := s.fsm.state.LatestIndex()
if err != nil {
return fmt.Errorf("unable to read latest index: %v", err)
}
s.logger.Debug("leader reconciling job summaries", "index", index)
args := &structs.GenericResponse{}
msg := structs.ReconcileJobSummariesRequestT... | [
"func",
"(",
"s",
"*",
"Server",
")",
"reconcileJobSummaries",
"(",
")",
"error",
"{",
"index",
",",
"err",
":=",
"s",
".",
"fsm",
".",
"state",
".",
"LatestIndex",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",... | // reconcileJobSummaries reconciles the summaries of all the jobs registered in
// the system
// COMPAT 0.4 -> 0.4.1 | [
"reconcileJobSummaries",
"reconciles",
"the",
"summaries",
"of",
"all",
"the",
"jobs",
"registered",
"in",
"the",
"system",
"COMPAT",
"0",
".",
"4",
"-",
">",
"0",
".",
"4",
".",
"1"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L798-L812 |
133,177 | hashicorp/nomad | nomad/leader.go | removeRaftPeer | func (s *Server) removeRaftPeer(m serf.Member, parts *serverParts) error {
addr := (&net.TCPAddr{IP: m.Addr, Port: parts.Port}).String()
// See if it's already in the configuration. It's harmless to re-remove it
// but we want to avoid doing that if possible to prevent useless Raft
// log entries.
configFuture :=... | go | func (s *Server) removeRaftPeer(m serf.Member, parts *serverParts) error {
addr := (&net.TCPAddr{IP: m.Addr, Port: parts.Port}).String()
// See if it's already in the configuration. It's harmless to re-remove it
// but we want to avoid doing that if possible to prevent useless Raft
// log entries.
configFuture :=... | [
"func",
"(",
"s",
"*",
"Server",
")",
"removeRaftPeer",
"(",
"m",
"serf",
".",
"Member",
",",
"parts",
"*",
"serverParts",
")",
"error",
"{",
"addr",
":=",
"(",
"&",
"net",
".",
"TCPAddr",
"{",
"IP",
":",
"m",
".",
"Addr",
",",
"Port",
":",
"part... | // removeRaftPeer is used to remove a Raft peer when a Nomad server leaves
// or is reaped | [
"removeRaftPeer",
"is",
"used",
"to",
"remove",
"a",
"Raft",
"peer",
"when",
"a",
"Nomad",
"server",
"leaves",
"or",
"is",
"reaped"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L908-L949 |
133,178 | hashicorp/nomad | nomad/leader.go | replicateACLPolicies | func (s *Server) replicateACLPolicies(stopCh chan struct{}) {
req := structs.ACLPolicyListRequest{
QueryOptions: structs.QueryOptions{
Region: s.config.AuthoritativeRegion,
AllowStale: true,
},
}
limiter := rate.NewLimiter(replicationRateLimit, int(replicationRateLimit))
s.logger.Debug("starting ACL p... | go | func (s *Server) replicateACLPolicies(stopCh chan struct{}) {
req := structs.ACLPolicyListRequest{
QueryOptions: structs.QueryOptions{
Region: s.config.AuthoritativeRegion,
AllowStale: true,
},
}
limiter := rate.NewLimiter(replicationRateLimit, int(replicationRateLimit))
s.logger.Debug("starting ACL p... | [
"func",
"(",
"s",
"*",
"Server",
")",
"replicateACLPolicies",
"(",
"stopCh",
"chan",
"struct",
"{",
"}",
")",
"{",
"req",
":=",
"structs",
".",
"ACLPolicyListRequest",
"{",
"QueryOptions",
":",
"structs",
".",
"QueryOptions",
"{",
"Region",
":",
"s",
".",
... | // replicateACLPolicies is used to replicate ACL policies from
// the authoritative region to this region. | [
"replicateACLPolicies",
"is",
"used",
"to",
"replicate",
"ACL",
"policies",
"from",
"the",
"authoritative",
"region",
"to",
"this",
"region",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L953-L1045 |
133,179 | hashicorp/nomad | nomad/leader.go | diffACLPolicies | func diffACLPolicies(state *state.StateStore, minIndex uint64, remoteList []*structs.ACLPolicyListStub) (delete []string, update []string) {
// Construct a set of the local and remote policies
local := make(map[string][]byte)
remote := make(map[string]struct{})
// Add all the local policies
iter, err := state.ACL... | go | func diffACLPolicies(state *state.StateStore, minIndex uint64, remoteList []*structs.ACLPolicyListStub) (delete []string, update []string) {
// Construct a set of the local and remote policies
local := make(map[string][]byte)
remote := make(map[string]struct{})
// Add all the local policies
iter, err := state.ACL... | [
"func",
"diffACLPolicies",
"(",
"state",
"*",
"state",
".",
"StateStore",
",",
"minIndex",
"uint64",
",",
"remoteList",
"[",
"]",
"*",
"structs",
".",
"ACLPolicyListStub",
")",
"(",
"delete",
"[",
"]",
"string",
",",
"update",
"[",
"]",
"string",
")",
"{... | // diffACLPolicies is used to perform a two-way diff between the local
// policies and the remote policies to determine which policies need to
// be deleted or updated. | [
"diffACLPolicies",
"is",
"used",
"to",
"perform",
"a",
"two",
"-",
"way",
"diff",
"between",
"the",
"local",
"policies",
"and",
"the",
"remote",
"policies",
"to",
"determine",
"which",
"policies",
"need",
"to",
"be",
"deleted",
"or",
"updated",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L1050-L1090 |
133,180 | hashicorp/nomad | nomad/leader.go | replicateACLTokens | func (s *Server) replicateACLTokens(stopCh chan struct{}) {
req := structs.ACLTokenListRequest{
GlobalOnly: true,
QueryOptions: structs.QueryOptions{
Region: s.config.AuthoritativeRegion,
AllowStale: true,
},
}
limiter := rate.NewLimiter(replicationRateLimit, int(replicationRateLimit))
s.logger.Debu... | go | func (s *Server) replicateACLTokens(stopCh chan struct{}) {
req := structs.ACLTokenListRequest{
GlobalOnly: true,
QueryOptions: structs.QueryOptions{
Region: s.config.AuthoritativeRegion,
AllowStale: true,
},
}
limiter := rate.NewLimiter(replicationRateLimit, int(replicationRateLimit))
s.logger.Debu... | [
"func",
"(",
"s",
"*",
"Server",
")",
"replicateACLTokens",
"(",
"stopCh",
"chan",
"struct",
"{",
"}",
")",
"{",
"req",
":=",
"structs",
".",
"ACLTokenListRequest",
"{",
"GlobalOnly",
":",
"true",
",",
"QueryOptions",
":",
"structs",
".",
"QueryOptions",
"... | // replicateACLTokens is used to replicate global ACL tokens from
// the authoritative region to this region. | [
"replicateACLTokens",
"is",
"used",
"to",
"replicate",
"global",
"ACL",
"tokens",
"from",
"the",
"authoritative",
"region",
"to",
"this",
"region",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L1094-L1187 |
133,181 | hashicorp/nomad | nomad/leader.go | diffACLTokens | func diffACLTokens(state *state.StateStore, minIndex uint64, remoteList []*structs.ACLTokenListStub) (delete []string, update []string) {
// Construct a set of the local and remote policies
local := make(map[string][]byte)
remote := make(map[string]struct{})
// Add all the local global tokens
iter, err := state.A... | go | func diffACLTokens(state *state.StateStore, minIndex uint64, remoteList []*structs.ACLTokenListStub) (delete []string, update []string) {
// Construct a set of the local and remote policies
local := make(map[string][]byte)
remote := make(map[string]struct{})
// Add all the local global tokens
iter, err := state.A... | [
"func",
"diffACLTokens",
"(",
"state",
"*",
"state",
".",
"StateStore",
",",
"minIndex",
"uint64",
",",
"remoteList",
"[",
"]",
"*",
"structs",
".",
"ACLTokenListStub",
")",
"(",
"delete",
"[",
"]",
"string",
",",
"update",
"[",
"]",
"string",
")",
"{",
... | // diffACLTokens is used to perform a two-way diff between the local
// tokens and the remote tokens to determine which tokens need to
// be deleted or updated. | [
"diffACLTokens",
"is",
"used",
"to",
"perform",
"a",
"two",
"-",
"way",
"diff",
"between",
"the",
"local",
"tokens",
"and",
"the",
"remote",
"tokens",
"to",
"determine",
"which",
"tokens",
"need",
"to",
"be",
"deleted",
"or",
"updated",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L1192-L1232 |
133,182 | hashicorp/nomad | nomad/leader.go | getOrCreateSchedulerConfig | func (s *Server) getOrCreateSchedulerConfig() *structs.SchedulerConfiguration {
state := s.fsm.State()
_, config, err := state.SchedulerConfig()
if err != nil {
s.logger.Named("core").Error("failed to get scheduler config", "error", err)
return nil
}
if config != nil {
return config
}
if !ServersMeetMinimu... | go | func (s *Server) getOrCreateSchedulerConfig() *structs.SchedulerConfiguration {
state := s.fsm.State()
_, config, err := state.SchedulerConfig()
if err != nil {
s.logger.Named("core").Error("failed to get scheduler config", "error", err)
return nil
}
if config != nil {
return config
}
if !ServersMeetMinimu... | [
"func",
"(",
"s",
"*",
"Server",
")",
"getOrCreateSchedulerConfig",
"(",
")",
"*",
"structs",
".",
"SchedulerConfiguration",
"{",
"state",
":=",
"s",
".",
"fsm",
".",
"State",
"(",
")",
"\n",
"_",
",",
"config",
",",
"err",
":=",
"state",
".",
"Schedul... | // getOrCreateSchedulerConfig is used to get the scheduler config. We create a default
// config if it doesn't already exist for bootstrapping an empty cluster | [
"getOrCreateSchedulerConfig",
"is",
"used",
"to",
"get",
"the",
"scheduler",
"config",
".",
"We",
"create",
"a",
"default",
"config",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"for",
"bootstrapping",
"an",
"empty",
"cluster"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/leader.go#L1263-L1285 |
133,183 | hashicorp/nomad | nomad/acl.go | resolveTokenFromSnapshotCache | func resolveTokenFromSnapshotCache(snap *state.StateSnapshot, cache *lru.TwoQueueCache, secretID string) (*acl.ACL, error) {
// Lookup the ACL Token
var token *structs.ACLToken
var err error
// Handle anonymous requests
if secretID == "" {
token = structs.AnonymousACLToken
} else {
token, err = snap.ACLToken... | go | func resolveTokenFromSnapshotCache(snap *state.StateSnapshot, cache *lru.TwoQueueCache, secretID string) (*acl.ACL, error) {
// Lookup the ACL Token
var token *structs.ACLToken
var err error
// Handle anonymous requests
if secretID == "" {
token = structs.AnonymousACLToken
} else {
token, err = snap.ACLToken... | [
"func",
"resolveTokenFromSnapshotCache",
"(",
"snap",
"*",
"state",
".",
"StateSnapshot",
",",
"cache",
"*",
"lru",
".",
"TwoQueueCache",
",",
"secretID",
"string",
")",
"(",
"*",
"acl",
".",
"ACL",
",",
"error",
")",
"{",
"// Lookup the ACL Token",
"var",
"... | // resolveTokenFromSnapshotCache is used to resolve an ACL object from a snapshot of state,
// using a cache to avoid parsing and ACL construction when possible. It is split from resolveToken
// to simplify testing. | [
"resolveTokenFromSnapshotCache",
"is",
"used",
"to",
"resolve",
"an",
"ACL",
"object",
"from",
"a",
"snapshot",
"of",
"state",
"using",
"a",
"cache",
"to",
"avoid",
"parsing",
"and",
"ACL",
"construction",
"when",
"possible",
".",
"It",
"is",
"split",
"from",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/acl.go#L41-L86 |
133,184 | hashicorp/nomad | drivers/mock/utils.go | parseDuration | func parseDuration(s string) (time.Duration, error) {
if s == "" {
return time.Duration(0), nil
}
// try to parse it as duration
return time.ParseDuration(s)
} | go | func parseDuration(s string) (time.Duration, error) {
if s == "" {
return time.Duration(0), nil
}
// try to parse it as duration
return time.ParseDuration(s)
} | [
"func",
"parseDuration",
"(",
"s",
"string",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"if",
"s",
"==",
"\"",
"\"",
"{",
"return",
"time",
".",
"Duration",
"(",
"0",
")",
",",
"nil",
"\n",
"}",
"\n\n",
"// try to parse it as duration",... | // parseDuration parses a duration string, like time.ParseDuration
// but is empty string friendly, returns a zero time duration | [
"parseDuration",
"parses",
"a",
"duration",
"string",
"like",
"time",
".",
"ParseDuration",
"but",
"is",
"empty",
"string",
"friendly",
"returns",
"a",
"zero",
"time",
"duration"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/mock/utils.go#L9-L16 |
133,185 | hashicorp/nomad | api/allocations.go | List | func (a *Allocations) List(q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error) {
var resp []*AllocationListStub
qm, err := a.client.query("/v1/allocations", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(AllocIndexSort(resp))
return resp, qm, nil
} | go | func (a *Allocations) List(q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error) {
var resp []*AllocationListStub
qm, err := a.client.query("/v1/allocations", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(AllocIndexSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"a",
"*",
"Allocations",
")",
"List",
"(",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"AllocationListStub",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"AllocationListStub",
"\n",
"qm",
",",
"err"... | // List returns a list of all of the allocations. | [
"List",
"returns",
"a",
"list",
"of",
"all",
"of",
"the",
"allocations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/allocations.go#L40-L48 |
133,186 | hashicorp/nomad | api/allocations.go | Info | func (a *Allocations) Info(allocID string, q *QueryOptions) (*Allocation, *QueryMeta, error) {
var resp Allocation
qm, err := a.client.query("/v1/allocation/"+allocID, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | go | func (a *Allocations) Info(allocID string, q *QueryOptions) (*Allocation, *QueryMeta, error) {
var resp Allocation
qm, err := a.client.query("/v1/allocation/"+allocID, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | [
"func",
"(",
"a",
"*",
"Allocations",
")",
"Info",
"(",
"allocID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"*",
"Allocation",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"Allocation",
"\n",
"qm",
",",
"err",
":=",
"a",
... | // Info is used to retrieve a single allocation. | [
"Info",
"is",
"used",
"to",
"retrieve",
"a",
"single",
"allocation",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/allocations.go#L55-L62 |
133,187 | hashicorp/nomad | api/allocations.go | RescheduleInfo | func (a Allocation) RescheduleInfo(t time.Time) (int, int) {
var reschedulePolicy *ReschedulePolicy
for _, tg := range a.Job.TaskGroups {
if *tg.Name == a.TaskGroup {
reschedulePolicy = tg.ReschedulePolicy
}
}
if reschedulePolicy == nil {
return 0, 0
}
availableAttempts := *reschedulePolicy.Attempts
int... | go | func (a Allocation) RescheduleInfo(t time.Time) (int, int) {
var reschedulePolicy *ReschedulePolicy
for _, tg := range a.Job.TaskGroups {
if *tg.Name == a.TaskGroup {
reschedulePolicy = tg.ReschedulePolicy
}
}
if reschedulePolicy == nil {
return 0, 0
}
availableAttempts := *reschedulePolicy.Attempts
int... | [
"func",
"(",
"a",
"Allocation",
")",
"RescheduleInfo",
"(",
"t",
"time",
".",
"Time",
")",
"(",
"int",
",",
"int",
")",
"{",
"var",
"reschedulePolicy",
"*",
"ReschedulePolicy",
"\n",
"for",
"_",
",",
"tg",
":=",
"range",
"a",
".",
"Job",
".",
"TaskGr... | // RescheduleInfo is used to calculate remaining reschedule attempts
// according to the given time and the task groups reschedule policy | [
"RescheduleInfo",
"is",
"used",
"to",
"calculate",
"remaining",
"reschedule",
"attempts",
"according",
"to",
"the",
"given",
"time",
"and",
"the",
"task",
"groups",
"reschedule",
"policy"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/allocations.go#L265-L290 |
133,188 | hashicorp/nomad | client/logmon/logging/syslog_parser.go | Parse | func (d *DockerLogParser) Parse(line []byte) *SyslogMessage {
pri, _, _ := d.parsePriority(line)
msgIdx := d.logContentIndex(line)
// Create a copy of the line so that subsequent Scans do not override the
// message
lineCopy := make([]byte, len(line[msgIdx:]))
copy(lineCopy, line[msgIdx:])
return &SyslogMessag... | go | func (d *DockerLogParser) Parse(line []byte) *SyslogMessage {
pri, _, _ := d.parsePriority(line)
msgIdx := d.logContentIndex(line)
// Create a copy of the line so that subsequent Scans do not override the
// message
lineCopy := make([]byte, len(line[msgIdx:]))
copy(lineCopy, line[msgIdx:])
return &SyslogMessag... | [
"func",
"(",
"d",
"*",
"DockerLogParser",
")",
"Parse",
"(",
"line",
"[",
"]",
"byte",
")",
"*",
"SyslogMessage",
"{",
"pri",
",",
"_",
",",
"_",
":=",
"d",
".",
"parsePriority",
"(",
"line",
")",
"\n",
"msgIdx",
":=",
"d",
".",
"logContentIndex",
... | // Parse parses a syslog log line | [
"Parse",
"parses",
"a",
"syslog",
"log",
"line"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/syslog_parser.go#L53-L66 |
133,189 | hashicorp/nomad | client/logmon/logging/syslog_parser.go | logContentIndex | func (d *DockerLogParser) logContentIndex(line []byte) int {
cursor := 0
numSpace := 0
numColons := 0
// first look for at least 2 colons. This matches into the date that has no more spaces in it
// DefaultFormatter log line look: '<30>2016-07-06T15:13:11Z00:00 hostname docker/9648c64f5037[16200]'
// UnixFormatte... | go | func (d *DockerLogParser) logContentIndex(line []byte) int {
cursor := 0
numSpace := 0
numColons := 0
// first look for at least 2 colons. This matches into the date that has no more spaces in it
// DefaultFormatter log line look: '<30>2016-07-06T15:13:11Z00:00 hostname docker/9648c64f5037[16200]'
// UnixFormatte... | [
"func",
"(",
"d",
"*",
"DockerLogParser",
")",
"logContentIndex",
"(",
"line",
"[",
"]",
"byte",
")",
"int",
"{",
"cursor",
":=",
"0",
"\n",
"numSpace",
":=",
"0",
"\n",
"numColons",
":=",
"0",
"\n",
"// first look for at least 2 colons. This matches into the da... | // logContentIndex finds out the index of the start index of the content in a
// syslog line | [
"logContentIndex",
"finds",
"out",
"the",
"index",
"of",
"the",
"start",
"index",
"of",
"the",
"content",
"in",
"a",
"syslog",
"line"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/syslog_parser.go#L70-L105 |
133,190 | hashicorp/nomad | client/logmon/logging/syslog_parser.go | parsePriority | func (d *DockerLogParser) parsePriority(line []byte) (Priority, int, error) {
cursor := 0
pri := d.newPriority(0)
if len(line) <= 0 {
return pri, cursor, ErrPriorityEmpty
}
if line[cursor] != PRI_PART_START {
return pri, cursor, ErrPriorityNoStart
}
i := 1
priDigit := 0
for i < len(line) {
if i >= 5 {
... | go | func (d *DockerLogParser) parsePriority(line []byte) (Priority, int, error) {
cursor := 0
pri := d.newPriority(0)
if len(line) <= 0 {
return pri, cursor, ErrPriorityEmpty
}
if line[cursor] != PRI_PART_START {
return pri, cursor, ErrPriorityNoStart
}
i := 1
priDigit := 0
for i < len(line) {
if i >= 5 {
... | [
"func",
"(",
"d",
"*",
"DockerLogParser",
")",
"parsePriority",
"(",
"line",
"[",
"]",
"byte",
")",
"(",
"Priority",
",",
"int",
",",
"error",
")",
"{",
"cursor",
":=",
"0",
"\n",
"pri",
":=",
"d",
".",
"newPriority",
"(",
"0",
")",
"\n",
"if",
"... | // parsePriority parses the priority in a syslog message | [
"parsePriority",
"parses",
"the",
"priority",
"in",
"a",
"syslog",
"message"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/syslog_parser.go#L108-L143 |
133,191 | hashicorp/nomad | client/logmon/logging/syslog_parser.go | newPriority | func (d *DockerLogParser) newPriority(p int) Priority {
// The Priority value is calculated by first multiplying the Facility
// number by 8 and then adding the numerical value of the Severity.
return Priority{
Pri: p,
Facility: syslog.Priority(p / 8),
Severity: syslog.Priority(p % 8),
}
} | go | func (d *DockerLogParser) newPriority(p int) Priority {
// The Priority value is calculated by first multiplying the Facility
// number by 8 and then adding the numerical value of the Severity.
return Priority{
Pri: p,
Facility: syslog.Priority(p / 8),
Severity: syslog.Priority(p % 8),
}
} | [
"func",
"(",
"d",
"*",
"DockerLogParser",
")",
"newPriority",
"(",
"p",
"int",
")",
"Priority",
"{",
"// The Priority value is calculated by first multiplying the Facility",
"// number by 8 and then adding the numerical value of the Severity.",
"return",
"Priority",
"{",
"Pri",
... | // newPriority creates a new default priority | [
"newPriority",
"creates",
"a",
"new",
"default",
"priority"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/syslog_parser.go#L151-L159 |
133,192 | hashicorp/nomad | command/job_status.go | outputPeriodicInfo | func (c *JobStatusCommand) outputPeriodicInfo(client *api.Client, job *api.Job) error {
// Output the summary
if err := c.outputJobSummary(client, job); err != nil {
return err
}
// Generate the prefix that matches launched jobs from the periodic job.
prefix := fmt.Sprintf("%s%s", *job.ID, structs.PeriodicLaunc... | go | func (c *JobStatusCommand) outputPeriodicInfo(client *api.Client, job *api.Job) error {
// Output the summary
if err := c.outputJobSummary(client, job); err != nil {
return err
}
// Generate the prefix that matches launched jobs from the periodic job.
prefix := fmt.Sprintf("%s%s", *job.ID, structs.PeriodicLaunc... | [
"func",
"(",
"c",
"*",
"JobStatusCommand",
")",
"outputPeriodicInfo",
"(",
"client",
"*",
"api",
".",
"Client",
",",
"job",
"*",
"api",
".",
"Job",
")",
"error",
"{",
"// Output the summary",
"if",
"err",
":=",
"c",
".",
"outputJobSummary",
"(",
"client",
... | // outputPeriodicInfo prints information about the passed periodic job. If a
// request fails, an error is returned. | [
"outputPeriodicInfo",
"prints",
"information",
"about",
"the",
"passed",
"periodic",
"job",
".",
"If",
"a",
"request",
"fails",
"an",
"error",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_status.go#L228-L263 |
133,193 | hashicorp/nomad | command/job_status.go | outputParameterizedInfo | func (c *JobStatusCommand) outputParameterizedInfo(client *api.Client, job *api.Job) error {
// Output parameterized job details
c.Ui.Output(c.Colorize().Color("\n[bold]Parameterized Job[reset]"))
parameterizedJob := make([]string, 3)
parameterizedJob[0] = fmt.Sprintf("Payload|%s", job.ParameterizedJob.Payload)
pa... | go | func (c *JobStatusCommand) outputParameterizedInfo(client *api.Client, job *api.Job) error {
// Output parameterized job details
c.Ui.Output(c.Colorize().Color("\n[bold]Parameterized Job[reset]"))
parameterizedJob := make([]string, 3)
parameterizedJob[0] = fmt.Sprintf("Payload|%s", job.ParameterizedJob.Payload)
pa... | [
"func",
"(",
"c",
"*",
"JobStatusCommand",
")",
"outputParameterizedInfo",
"(",
"client",
"*",
"api",
".",
"Client",
",",
"job",
"*",
"api",
".",
"Job",
")",
"error",
"{",
"// Output parameterized job details",
"c",
".",
"Ui",
".",
"Output",
"(",
"c",
".",... | // outputParameterizedInfo prints information about a parameterized job. If a
// request fails, an error is returned. | [
"outputParameterizedInfo",
"prints",
"information",
"about",
"a",
"parameterized",
"job",
".",
"If",
"a",
"request",
"fails",
"an",
"error",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_status.go#L267-L310 |
133,194 | hashicorp/nomad | command/job_status.go | outputJobInfo | func (c *JobStatusCommand) outputJobInfo(client *api.Client, job *api.Job) error {
// Query the allocations
jobAllocs, _, err := client.Jobs().Allocations(*job.ID, c.allAllocs, nil)
if err != nil {
return fmt.Errorf("Error querying job allocations: %s", err)
}
// Query the evaluations
jobEvals, _, err := clie... | go | func (c *JobStatusCommand) outputJobInfo(client *api.Client, job *api.Job) error {
// Query the allocations
jobAllocs, _, err := client.Jobs().Allocations(*job.ID, c.allAllocs, nil)
if err != nil {
return fmt.Errorf("Error querying job allocations: %s", err)
}
// Query the evaluations
jobEvals, _, err := clie... | [
"func",
"(",
"c",
"*",
"JobStatusCommand",
")",
"outputJobInfo",
"(",
"client",
"*",
"api",
".",
"Client",
",",
"job",
"*",
"api",
".",
"Job",
")",
"error",
"{",
"// Query the allocations",
"jobAllocs",
",",
"_",
",",
"err",
":=",
"client",
".",
"Jobs",
... | // outputJobInfo prints information about the passed non-periodic job. If a
// request fails, an error is returned. | [
"outputJobInfo",
"prints",
"information",
"about",
"the",
"passed",
"non",
"-",
"periodic",
"job",
".",
"If",
"a",
"request",
"fails",
"an",
"error",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_status.go#L314-L390 |
133,195 | hashicorp/nomad | command/job_status.go | outputJobSummary | func (c *JobStatusCommand) outputJobSummary(client *api.Client, job *api.Job) error {
// Query the summary
summary, _, err := client.Jobs().Summary(*job.ID, nil)
if err != nil {
return fmt.Errorf("Error querying job summary: %s", err)
}
if summary == nil {
return nil
}
periodic := job.IsPeriodic()
paramet... | go | func (c *JobStatusCommand) outputJobSummary(client *api.Client, job *api.Job) error {
// Query the summary
summary, _, err := client.Jobs().Summary(*job.ID, nil)
if err != nil {
return fmt.Errorf("Error querying job summary: %s", err)
}
if summary == nil {
return nil
}
periodic := job.IsPeriodic()
paramet... | [
"func",
"(",
"c",
"*",
"JobStatusCommand",
")",
"outputJobSummary",
"(",
"client",
"*",
"api",
".",
"Client",
",",
"job",
"*",
"api",
".",
"Job",
")",
"error",
"{",
"// Query the summary",
"summary",
",",
"_",
",",
"err",
":=",
"client",
".",
"Jobs",
"... | // outputJobSummary displays the given jobs summary and children job summary
// where appropriate | [
"outputJobSummary",
"displays",
"the",
"given",
"jobs",
"summary",
"and",
"children",
"job",
"summary",
"where",
"appropriate"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_status.go#L494-L545 |
133,196 | hashicorp/nomad | command/job_status.go | outputReschedulingEvals | func (c *JobStatusCommand) outputReschedulingEvals(client *api.Client, job *api.Job, allocListStubs []*api.AllocationListStub, uuidLength int) error {
// Get the most recent alloc ID by task group
mostRecentAllocs := make(map[string]*api.AllocationListStub)
for _, alloc := range allocListStubs {
a, ok := mostRece... | go | func (c *JobStatusCommand) outputReschedulingEvals(client *api.Client, job *api.Job, allocListStubs []*api.AllocationListStub, uuidLength int) error {
// Get the most recent alloc ID by task group
mostRecentAllocs := make(map[string]*api.AllocationListStub)
for _, alloc := range allocListStubs {
a, ok := mostRece... | [
"func",
"(",
"c",
"*",
"JobStatusCommand",
")",
"outputReschedulingEvals",
"(",
"client",
"*",
"api",
".",
"Client",
",",
"job",
"*",
"api",
".",
"Job",
",",
"allocListStubs",
"[",
"]",
"*",
"api",
".",
"AllocationListStub",
",",
"uuidLength",
"int",
")",
... | // outputReschedulingEvals displays eval IDs and time for any
// delayed evaluations by task group | [
"outputReschedulingEvals",
"displays",
"eval",
"IDs",
"and",
"time",
"for",
"any",
"delayed",
"evaluations",
"by",
"task",
"group"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_status.go#L549-L611 |
133,197 | hashicorp/nomad | command/job_status.go | createStatusListOutput | func createStatusListOutput(jobs []*api.JobListStub) string {
out := make([]string, len(jobs)+1)
out[0] = "ID|Type|Priority|Status|Submit Date"
for i, job := range jobs {
out[i+1] = fmt.Sprintf("%s|%s|%d|%s|%s",
job.ID,
getTypeString(job),
job.Priority,
getStatusString(job.Status, &job.Stop),
format... | go | func createStatusListOutput(jobs []*api.JobListStub) string {
out := make([]string, len(jobs)+1)
out[0] = "ID|Type|Priority|Status|Submit Date"
for i, job := range jobs {
out[i+1] = fmt.Sprintf("%s|%s|%d|%s|%s",
job.ID,
getTypeString(job),
job.Priority,
getStatusString(job.Status, &job.Stop),
format... | [
"func",
"createStatusListOutput",
"(",
"jobs",
"[",
"]",
"*",
"api",
".",
"JobListStub",
")",
"string",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"jobs",
")",
"+",
"1",
")",
"\n",
"out",
"[",
"0",
"]",
"=",
"\"",
"\"",
... | // list general information about a list of jobs | [
"list",
"general",
"information",
"about",
"a",
"list",
"of",
"jobs"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_status.go#L641-L653 |
133,198 | hashicorp/nomad | drivers/shared/executor/legacy_executor_wrapper.go | init | func init() {
gob.Register([]interface{}{})
gob.Register(map[string]interface{}{})
gob.Register([]map[string]string{})
gob.Register([]map[string]int{})
gob.Register(syscall.Signal(0x1))
} | go | func init() {
gob.Register([]interface{}{})
gob.Register(map[string]interface{}{})
gob.Register([]map[string]string{})
gob.Register([]map[string]int{})
gob.Register(syscall.Signal(0x1))
} | [
"func",
"init",
"(",
")",
"{",
"gob",
".",
"Register",
"(",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"gob",
".",
"Register",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"gob",
".",
"Register",
"(",
... | // Registering these types since we have to serialize and de-serialize the Task
// structs over the wire between drivers and the executor. | [
"Registering",
"these",
"types",
"since",
"we",
"have",
"to",
"serialize",
"and",
"de",
"-",
"serialize",
"the",
"Task",
"structs",
"over",
"the",
"wire",
"between",
"drivers",
"and",
"the",
"executor",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/legacy_executor_wrapper.go#L26-L32 |
133,199 | hashicorp/nomad | nomad/structs/config/plugins.go | PluginConfigSetMerge | func PluginConfigSetMerge(first, second []*PluginConfig) []*PluginConfig {
findex := make(map[string]*PluginConfig, len(first))
for _, p := range first {
findex[p.Name] = p
}
sindex := make(map[string]*PluginConfig, len(second))
for _, p := range second {
sindex[p.Name] = p
}
var out []*PluginConfig
// G... | go | func PluginConfigSetMerge(first, second []*PluginConfig) []*PluginConfig {
findex := make(map[string]*PluginConfig, len(first))
for _, p := range first {
findex[p.Name] = p
}
sindex := make(map[string]*PluginConfig, len(second))
for _, p := range second {
sindex[p.Name] = p
}
var out []*PluginConfig
// G... | [
"func",
"PluginConfigSetMerge",
"(",
"first",
",",
"second",
"[",
"]",
"*",
"PluginConfig",
")",
"[",
"]",
"*",
"PluginConfig",
"{",
"findex",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"PluginConfig",
",",
"len",
"(",
"first",
")",
")",
"\n",
... | // PluginConfigSetMerge merges to sets of plugin configs. For plugins with the
// same name, the configs are merged. | [
"PluginConfigSetMerge",
"merges",
"to",
"sets",
"of",
"plugin",
"configs",
".",
"For",
"plugins",
"with",
"the",
"same",
"name",
"the",
"configs",
"are",
"merged",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/plugins.go#L40-L75 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.