_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q33700 | readProtobufQueryRequest | train | func (h *Handler) readProtobufQueryRequest(r *http.Request) (*pilosa.QueryRequest, error) {
// Slurp the body.
body, err := ioutil.ReadAll(r.Body)
if err != nil {
return nil, errors.Wrap(err, "reading")
}
qreq := &pilosa.QueryRequest{}
err = h.api.Serializer.Unmarshal(body, qreq)
if err != nil {
return nil,... | go | {
"resource": ""
} |
q33701 | readURLQueryRequest | train | func (h *Handler) readURLQueryRequest(r *http.Request) (*pilosa.QueryRequest, error) {
q := r.URL.Query()
// Parse query string.
buf, err := ioutil.ReadAll(r.Body)
if err != nil {
return nil, errors.Wrap(err, "reading")
}
query := string(buf)
// Parse list of shards.
shards, err := parseUint64Slice(q.Get("s... | go | {
"resource": ""
} |
q33702 | writeQueryResponse | train | func (h *Handler) writeQueryResponse(w http.ResponseWriter, r *http.Request, resp *pilosa.QueryResponse) error {
if !validHeaderAcceptJSON(r.Header) {
w.Header().Set("Content-Type", "application/protobuf")
return h.writeProtobufQueryResponse(w, resp)
}
w.Header().Set("Content-Type", "application/json")
return h... | go | {
"resource": ""
} |
q33703 | writeProtobufQueryResponse | train | func (h *Handler) writeProtobufQueryResponse(w io.Writer, resp *pilosa.QueryResponse) error {
if buf, err := h.api.Serializer.Marshal(resp); err != nil {
return errors.Wrap(err, "marshalling")
} else if _, err := w.Write(buf); err != nil {
return errors.Wrap(err, "writing")
}
return nil
} | go | {
"resource": ""
} |
q33704 | writeJSONQueryResponse | train | func (h *Handler) writeJSONQueryResponse(w io.Writer, resp *pilosa.QueryResponse) error {
return json.NewEncoder(w).Encode(resp)
} | go | {
"resource": ""
} |
q33705 | parseUint64Slice | train | func parseUint64Slice(s string) ([]uint64, error) {
var a []uint64
for _, str := range strings.Split(s, ",") {
// Ignore blanks.
if str == "" {
continue
}
// Parse number.
num, err := strconv.ParseUint(str, 10, 64)
if err != nil {
return nil, errors.Wrap(err, "parsing int")
}
a = append(a, num)... | go | {
"resource": ""
} |
q33706 | TranslateColumnsToUint64 | train | func (s *translateStore) TranslateColumnsToUint64(index string, values []string) ([]uint64, error) {
return nil, pilosa.ErrNotImplemented
} | go | {
"resource": ""
} |
q33707 | TranslateColumnToString | train | func (s *translateStore) TranslateColumnToString(index string, values uint64) (string, error) {
return "", pilosa.ErrNotImplemented
} | go | {
"resource": ""
} |
q33708 | TranslateRowsToUint64 | train | func (s *translateStore) TranslateRowsToUint64(index, frame string, values []string) ([]uint64, error) {
return nil, pilosa.ErrNotImplemented
} | go | {
"resource": ""
} |
q33709 | TranslateRowToString | train | func (s *translateStore) TranslateRowToString(index, frame string, values uint64) (string, error) {
return "", pilosa.ErrNotImplemented
} | go | {
"resource": ""
} |
q33710 | Reader | train | func (s *translateStore) Reader(ctx context.Context, off int64) (io.ReadCloser, error) {
// Generate remote URL.
u, err := url.Parse(s.node.URI.String())
if err != nil {
return nil, err
}
u.Path = "/internal/translate/data"
u.RawQuery = (url.Values{
"offset": {strconv.FormatInt(off, 10)},
}).Encode()
// Co... | go | {
"resource": ""
} |
q33711 | Open | train | func (g *memberSet) Open() (err error) {
g.mu.Lock()
g.memberlist, err = memberlist.Create(g.config.memberlistConfig)
g.mu.Unlock()
if err != nil {
return errors.Wrap(err, "creating memberlist")
}
g.broadcasts = &memberlist.TransmitLimitedQueue{
NumNodes: func() int {
g.mu.RLock()
defer g.mu.RUnlock()
... | go | {
"resource": ""
} |
q33712 | joinWithRetry | train | func (g *memberSet) joinWithRetry(hosts []string) error {
err := retry(60, 2*time.Second, func() error {
_, err := g.memberlist.Join(hosts)
return err
})
return err
} | go | {
"resource": ""
} |
q33713 | retry | train | func retry(attempts int, sleep time.Duration, fn func() error) (err error) { // nolint: unparam
for i := 0; ; i++ {
err = fn()
if err == nil {
return
}
if i >= (attempts - 1) {
break
}
time.Sleep(sleep)
log.Println("retrying after error:", err)
}
return fmt.Errorf("after %d attempts, last error: ... | go | {
"resource": ""
} |
q33714 | WithTransport | train | func WithTransport(transport *Transport) memberSetOption {
return func(g *memberSet) error {
g.transport = transport
return nil
}
} | go | {
"resource": ""
} |
q33715 | WithLogOutput | train | func WithLogOutput(o io.Writer) memberSetOption {
return func(g *memberSet) error {
g.logOutput = o
return nil
}
} | go | {
"resource": ""
} |
q33716 | WithPilosaLogger | train | func WithPilosaLogger(l logger.Logger) memberSetOption {
return func(g *memberSet) error {
g.Logger = l
return nil
}
} | go | {
"resource": ""
} |
q33717 | NodeMeta | train | func (g *memberSet) NodeMeta(limit int) []byte {
buf, err := g.papi.Serializer.Marshal(g.papi.Node())
if err != nil {
g.Logger.Printf("marshal message error: %s", err)
return []byte{}
}
return buf
} | go | {
"resource": ""
} |
q33718 | NotifyMsg | train | func (g *memberSet) NotifyMsg(b []byte) {
err := g.papi.ClusterMessage(context.Background(), bytes.NewBuffer(b))
if err != nil {
g.Logger.Printf("cluster message error: %s", err)
}
} | go | {
"resource": ""
} |
q33719 | GetBroadcasts | train | func (g *memberSet) GetBroadcasts(overhead, limit int) [][]byte {
return g.broadcasts.GetBroadcasts(overhead, limit)
} | go | {
"resource": ""
} |
q33720 | LocalState | train | func (g *memberSet) LocalState(join bool) []byte {
m := &pilosa.NodeStatus{
Node: g.papi.Node(),
Schema: &pilosa.Schema{Indexes: g.papi.Schema(context.Background())},
}
for _, idx := range m.Schema.Indexes {
is := &pilosa.IndexStatus{Name: idx.Name}
for _, f := range idx.Fields {
availableShards := roar... | go | {
"resource": ""
} |
q33721 | MergeRemoteState | train | func (g *memberSet) MergeRemoteState(buf []byte, join bool) {
err := g.papi.ClusterMessage(context.Background(), bytes.NewBuffer(buf))
if err != nil {
g.Logger.Printf("merge state error: %s", err)
}
} | go | {
"resource": ""
} |
q33722 | newEventReceiver | train | func newEventReceiver(logger logger.Logger, papi *pilosa.API) *eventReceiver {
ger := &eventReceiver{
ch: make(chan memberlist.NodeEvent, 1),
logger: logger,
papi: papi,
}
go ger.listen()
return ger
} | go | {
"resource": ""
} |
q33723 | newTransport | train | func newTransport(conf *memberlist.Config) (*memberlist.NetTransport, error) {
nc := &memberlist.NetTransportConfig{
BindAddrs: []string{conf.BindAddr},
BindPort: conf.BindPort,
Logger: conf.Logger,
}
// See comment below for details about the retry in here.
makeNetRetry := func(limit int) (*memberlist.N... | go | {
"resource": ""
} |
q33724 | MarshalJSON | train | func (cas ColumnAttrSet) MarshalJSON() ([]byte, error) {
if cas.Key != "" {
return json.Marshal(struct {
Key string `json:"key,omitempty"`
Attrs map[string]interface{} `json:"attrs,omitempty"`
}{
Key: cas.Key,
Attrs: cas.Attrs,
})
}
return json.Marshal(struct {
ID uint64 ... | go | {
"resource": ""
} |
q33725 | validateName | train | func validateName(name string) error {
if !nameRegexp.Match([]byte(name)) {
return errors.Wrapf(ErrName, "'%s'", name)
}
return nil
} | go | {
"resource": ""
} |
q33726 | AddressWithDefaults | train | func AddressWithDefaults(addr string) (*URI, error) {
if addr == "" {
return defaultURI(), nil
}
return NewURIFromAddress(addr)
} | go | {
"resource": ""
} |
q33727 | clear | train | func (c *Cache) clear() { // nolint: staticcheck,unused
if c.OnEvicted != nil {
for _, e := range c.cache {
kv := e.Value.(*entry)
c.OnEvicted(kv.key, kv.value)
}
}
c.ll = nil
c.cache = nil
} | go | {
"resource": ""
} |
q33728 | SetTLSConfig | train | func SetTLSConfig(flags *pflag.FlagSet, certificatePath *string, certificateKeyPath *string, skipVerify *bool) {
flags.StringVarP(certificatePath, "tls.certificate", "", "", "TLS certificate path (usually has the .crt or .pem extension")
flags.StringVarP(certificateKeyPath, "tls.key", "", "", "TLS certificate key pat... | go | {
"resource": ""
} |
q33729 | commandClient | train | func commandClient(cmd CommandWithTLSSupport) (*http.InternalClient, error) {
tlsConfig := cmd.TLSConfiguration()
var TLSConfig *tls.Config
if tlsConfig.CertificatePath != "" && tlsConfig.CertificateKeyPath != "" {
cert, err := tls.LoadX509KeyPair(tlsConfig.CertificatePath, tlsConfig.CertificateKeyPath)
if err !... | go | {
"resource": ""
} |
q33730 | newLRUCache | train | func newLRUCache(maxEntries uint32) *lruCache {
c := &lruCache{
cache: lru.New(int(maxEntries)),
counts: make(map[uint64]uint64),
stats: stats.NopStatsClient,
}
c.cache.OnEvicted = c.onEvicted
return c
} | go | {
"resource": ""
} |
q33731 | Top | train | func (c *lruCache) Top() []bitmapPair {
a := make([]bitmapPair, 0, len(c.counts))
for id, n := range c.counts {
a = append(a, bitmapPair{
ID: id,
Count: n,
})
}
sort.Sort(bitmapPairs(a))
return a
} | go | {
"resource": ""
} |
q33732 | NewRankCache | train | func NewRankCache(maxEntries uint32) *rankCache {
return &rankCache{
maxEntries: maxEntries,
thresholdBuffer: int(thresholdFactor * float64(maxEntries)),
entries: make(map[uint64]uint64),
stats: stats.NopStatsClient,
}
} | go | {
"resource": ""
} |
q33733 | Invalidate | train | func (c *rankCache) Invalidate() {
c.mu.Lock()
defer c.mu.Unlock()
c.invalidate()
} | go | {
"resource": ""
} |
q33734 | Recalculate | train | func (c *rankCache) Recalculate() {
c.mu.Lock()
defer c.mu.Unlock()
c.stats.Count("cache.recalculate", 1, 1.0)
c.recalculate()
} | go | {
"resource": ""
} |
q33735 | WriteTo | train | func (c *rankCache) WriteTo(w io.Writer) (n int64, err error) {
panic("FIXME: TODO")
} | go | {
"resource": ""
} |
q33736 | ReadFrom | train | func (c *rankCache) ReadFrom(r io.Reader) (n int64, err error) {
panic("FIXME: TODO")
} | go | {
"resource": ""
} |
q33737 | Pop | train | func (p *Pairs) Pop() interface{} {
old := *p
n := len(old)
x := old[n-1]
*p = old[0 : n-1]
return x
} | go | {
"resource": ""
} |
q33738 | Add | train | func (p Pairs) Add(other []Pair) []Pair {
// Create lookup of key/counts.
m := make(map[uint64]uint64, len(p))
for _, pair := range p {
m[pair.ID] = pair.Count
}
// Add/merge from other.
for _, pair := range other {
m[pair.ID] += pair.Count
}
// Convert back to slice.
a := make([]Pair, 0, len(m))
for k,... | go | {
"resource": ""
} |
q33739 | Keys | train | func (p Pairs) Keys() []uint64 {
a := make([]uint64, len(p))
for i := range p {
a[i] = p[i].ID
}
return a
} | go | {
"resource": ""
} |
q33740 | merge | train | func (p uint64Slice) merge(other []uint64) []uint64 {
ret := make([]uint64, 0, len(p))
i, j := 0, 0
for i < len(p) && j < len(other) {
a, b := p[i], other[j]
if a == b {
ret = append(ret, a)
i, j = i+1, j+1
} else if a < b {
ret = append(ret, a)
i++
} else {
ret = append(ret, b)
j++
}
}... | go | {
"resource": ""
} |
q33741 | Fetch | train | func (s *simpleCache) Fetch(id uint64) (*Row, bool) {
m, ok := s.cache[id]
return m, ok
} | go | {
"resource": ""
} |
q33742 | Add | train | func (s *simpleCache) Add(id uint64, b *Row) {
s.cache[id] = b
} | go | {
"resource": ""
} |
q33743 | Contains | train | func (a Nodes) Contains(n *Node) bool {
for i := range a {
if a[i] == n {
return true
}
}
return false
} | go | {
"resource": ""
} |
q33744 | ContainsID | train | func (a Nodes) ContainsID(id string) bool {
for _, n := range a {
if n.ID == id {
return true
}
}
return false
} | go | {
"resource": ""
} |
q33745 | Filter | train | func (a Nodes) Filter(n *Node) []*Node {
other := make([]*Node, 0, len(a))
for i := range a {
if a[i] != n {
other = append(other, a[i])
}
}
return other
} | go | {
"resource": ""
} |
q33746 | FilterID | train | func (a Nodes) FilterID(id string) []*Node {
other := make([]*Node, 0, len(a))
for _, node := range a {
if node.ID != id {
other = append(other, node)
}
}
return other
} | go | {
"resource": ""
} |
q33747 | FilterURI | train | func (a Nodes) FilterURI(uri URI) []*Node {
other := make([]*Node, 0, len(a))
for _, node := range a {
if node.URI != uri {
other = append(other, node)
}
}
return other
} | go | {
"resource": ""
} |
q33748 | IDs | train | func (a Nodes) IDs() []string {
ids := make([]string, len(a))
for i, n := range a {
ids[i] = n.ID
}
return ids
} | go | {
"resource": ""
} |
q33749 | URIs | train | func (a Nodes) URIs() []URI {
uris := make([]URI, len(a))
for i, n := range a {
uris[i] = n.URI
}
return uris
} | go | {
"resource": ""
} |
q33750 | Clone | train | func (a Nodes) Clone() []*Node {
other := make([]*Node, len(a))
copy(other, a)
return other
} | go | {
"resource": ""
} |
q33751 | newCluster | train | func newCluster() *cluster {
return &cluster{
Hasher: &jmphasher{},
partitionN: defaultPartitionN,
ReplicaN: 1,
joiningLeavingNodes: make(chan nodeAction, 10), // buffered channel
jobs: make(map[int64]*resizeJob),
closing: make(chan struct{}),
joining: make(c... | go | {
"resource": ""
} |
q33752 | isCoordinator | train | func (c *cluster) isCoordinator() bool {
c.mu.RLock()
defer c.mu.RUnlock()
return c.unprotectedIsCoordinator()
} | go | {
"resource": ""
} |
q33753 | setCoordinator | train | func (c *cluster) setCoordinator(n *Node) error {
c.mu.Lock()
defer c.mu.Unlock()
// Verify that the new Coordinator value matches
// this node.
if c.Node.ID != n.ID {
return fmt.Errorf("coordinator node does not match this node")
}
// Update IsCoordinator on all nodes (locally).
_ = c.unprotectedUpdateCoord... | go | {
"resource": ""
} |
q33754 | updateCoordinator | train | func (c *cluster) updateCoordinator(n *Node) bool { // nolint: unparam
c.mu.Lock()
defer c.mu.Unlock()
return c.unprotectedUpdateCoordinator(n)
} | go | {
"resource": ""
} |
q33755 | addNode | train | func (c *cluster) addNode(node *Node) error {
// If the node being added is the coordinator, set it for this node.
if node.IsCoordinator {
c.Coordinator = node.ID
}
// add to cluster
if !c.addNodeBasicSorted(node) {
return nil
}
// add to topology
if c.Topology == nil {
return fmt.Errorf("Cluster.Topolo... | go | {
"resource": ""
} |
q33756 | removeNode | train | func (c *cluster) removeNode(nodeID string) error {
// remove from cluster
c.removeNodeBasicSorted(nodeID)
// remove from topology
if c.Topology == nil {
return fmt.Errorf("Cluster.Topology is nil")
}
if !c.Topology.removeID(nodeID) {
return nil
}
// save topology
return c.saveTopology()
} | go | {
"resource": ""
} |
q33757 | receiveNodeState | train | func (c *cluster) receiveNodeState(nodeID string, state string) error {
c.mu.Lock()
defer c.mu.Unlock()
if !c.unprotectedIsCoordinator() {
return nil
}
c.Topology.mu.Lock()
changed := false
if c.Topology.nodeStates[nodeID] != state {
changed = true
c.Topology.nodeStates[nodeID] = state
for i, n := range... | go | {
"resource": ""
} |
q33758 | determineClusterState | train | func (c *cluster) determineClusterState() (clusterState string) {
if c.state == ClusterStateResizing {
return ClusterStateResizing
}
if c.haveTopologyAgreement() && c.allNodesReady() {
return ClusterStateNormal
}
if len(c.Topology.nodeIDs)-len(c.nodeIDs()) < c.ReplicaN && c.allNodesReady() {
return ClusterSt... | go | {
"resource": ""
} |
q33759 | unprotectedStatus | train | func (c *cluster) unprotectedStatus() *ClusterStatus {
return &ClusterStatus{
ClusterID: c.id,
State: c.state,
Nodes: c.nodes,
}
} | go | {
"resource": ""
} |
q33760 | unprotectedNodeByID | train | func (c *cluster) unprotectedNodeByID(id string) *Node {
for _, n := range c.nodes {
if n.ID == id {
return n
}
}
return nil
} | go | {
"resource": ""
} |
q33761 | nodePositionByID | train | func (c *cluster) nodePositionByID(nodeID string) int {
for i, n := range c.nodes {
if n.ID == nodeID {
return i
}
}
return -1
} | go | {
"resource": ""
} |
q33762 | addNodeBasicSorted | train | func (c *cluster) addNodeBasicSorted(node *Node) bool {
n := c.unprotectedNodeByID(node.ID)
if n != nil {
if n.State != node.State || n.IsCoordinator != node.IsCoordinator || n.URI != node.URI {
n.State = node.State
n.IsCoordinator = node.IsCoordinator
n.URI = node.URI
return true
}
return false
}
... | go | {
"resource": ""
} |
q33763 | Nodes | train | func (c *cluster) Nodes() []*Node {
c.mu.RLock()
defer c.mu.RUnlock()
ret := make([]*Node, len(c.nodes))
copy(ret, c.nodes)
return ret
} | go | {
"resource": ""
} |
q33764 | removeNodeBasicSorted | train | func (c *cluster) removeNodeBasicSorted(nodeID string) bool {
i := c.nodePositionByID(nodeID)
if i < 0 {
return false
}
copy(c.nodes[i:], c.nodes[i+1:])
c.nodes[len(c.nodes)-1] = nil
c.nodes = c.nodes[:len(c.nodes)-1]
return true
} | go | {
"resource": ""
} |
q33765 | diff | train | func (c *cluster) diff(other *cluster) (action string, nodeID string, err error) {
lenFrom := len(c.nodes)
lenTo := len(other.nodes)
// Determine if a node is being added or removed.
if lenFrom == lenTo {
return "", "", errors.New("clusters are the same size")
}
if lenFrom < lenTo {
// Adding a node.
if len... | go | {
"resource": ""
} |
q33766 | fragSources | train | func (c *cluster) fragSources(to *cluster, idx *Index) (map[string][]*ResizeSource, error) {
m := make(map[string][]*ResizeSource)
// Determine if a node is being added or removed.
action, diffNodeID, err := c.diff(to)
if err != nil {
return nil, errors.Wrap(err, "diffing")
}
// Initialize the map with all th... | go | {
"resource": ""
} |
q33767 | partition | train | func (c *cluster) partition(index string, shard uint64) int {
var buf [8]byte
binary.BigEndian.PutUint64(buf[:], shard)
// Hash the bytes and mod by partition count.
h := fnv.New64a()
_, _ = h.Write([]byte(index))
_, _ = h.Write(buf[:])
return int(h.Sum64() % uint64(c.partitionN))
} | go | {
"resource": ""
} |
q33768 | ShardNodes | train | func (c *cluster) ShardNodes(index string, shard uint64) []*Node {
c.mu.RLock()
defer c.mu.RUnlock()
return c.shardNodes(index, shard)
} | go | {
"resource": ""
} |
q33769 | shardNodes | train | func (c *cluster) shardNodes(index string, shard uint64) []*Node {
return c.partitionNodes(c.partition(index, shard))
} | go | {
"resource": ""
} |
q33770 | ownsShard | train | func (c *cluster) ownsShard(nodeID string, index string, shard uint64) bool {
c.mu.RLock()
defer c.mu.RUnlock()
return Nodes(c.shardNodes(index, shard)).ContainsID(nodeID)
} | go | {
"resource": ""
} |
q33771 | partitionNodes | train | func (c *cluster) partitionNodes(partitionID int) []*Node {
// Default replica count to between one and the number of nodes.
// The replica count can be zero if there are no nodes.
replicaN := c.ReplicaN
if replicaN > len(c.nodes) {
replicaN = len(c.nodes)
} else if replicaN == 0 {
replicaN = 1
}
// Determi... | go | {
"resource": ""
} |
q33772 | containsShards | train | func (c *cluster) containsShards(index string, availableShards *roaring.Bitmap, node *Node) []uint64 {
var shards []uint64
availableShards.ForEach(func(i uint64) {
p := c.partition(index, i)
// Determine the nodes for partition.
nodes := c.partitionNodes(p)
for _, n := range nodes {
if n.ID == node.ID {
... | go | {
"resource": ""
} |
q33773 | needTopologyAgreement | train | func (c *cluster) needTopologyAgreement() bool {
return (c.state == ClusterStateStarting || c.state == ClusterStateDegraded) && !stringSlicesAreEqual(c.Topology.nodeIDs, c.nodeIDs())
} | go | {
"resource": ""
} |
q33774 | haveTopologyAgreement | train | func (c *cluster) haveTopologyAgreement() bool {
if c.Static {
return true
}
return stringSlicesAreEqual(c.Topology.nodeIDs, c.nodeIDs())
} | go | {
"resource": ""
} |
q33775 | allNodesReady | train | func (c *cluster) allNodesReady() (ret bool) {
if c.Static {
return true
}
for _, id := range c.nodeIDs() {
if c.Topology.nodeStates[id] != nodeStateReady {
return false
}
}
return true
} | go | {
"resource": ""
} |
q33776 | listenForJoins | train | func (c *cluster) listenForJoins() {
c.wg.Add(1)
go func() {
defer c.wg.Done()
// When a cluster starts, the state is STARTING.
// We first want to wait for at least one node to join.
// Then we want to clear out the joiningLeavingNodes queue (buffered channel).
// Then we want to set the cluster state to ... | go | {
"resource": ""
} |
q33777 | completeCurrentJob | train | func (c *cluster) completeCurrentJob(state string) error {
c.mu.Lock()
defer c.mu.Unlock()
return c.unprotectedCompleteCurrentJob(state)
} | go | {
"resource": ""
} |
q33778 | job | train | func (c *cluster) job(id int64) *resizeJob {
c.mu.RLock()
defer c.mu.RUnlock()
return c.jobs[id]
} | go | {
"resource": ""
} |
q33779 | newResizeJob | train | func newResizeJob(existingNodes []*Node, node *Node, action string) *resizeJob {
// Build a map of uris to track their resize status.
// The value for a node will be set to true after that node
// has indicated that it has completed all resize instructions.
ids := make(map[string]bool)
if action == resizeJobActi... | go | {
"resource": ""
} |
q33780 | run | train | func (j *resizeJob) run() error {
j.Logger.Printf("run resizeJob")
// Set job state to RUNNING.
j.setState(resizeJobStateRunning)
// Job can be considered done in the case where it doesn't require any action.
if !j.nodesArePending() {
j.Logger.Printf("resizeJob contains no pending tasks; mark as done")
j.resu... | go | {
"resource": ""
} |
q33781 | isComplete | train | func (j *resizeJob) isComplete() bool {
switch j.state {
case resizeJobStateDone, resizeJobStateAborted:
return true
default:
return false
}
} | go | {
"resource": ""
} |
q33782 | nodesArePending | train | func (j *resizeJob) nodesArePending() bool {
for _, complete := range j.IDs {
if !complete {
return true
}
}
return false
} | go | {
"resource": ""
} |
q33783 | ContainsID | train | func (n nodeIDs) ContainsID(id string) bool {
for _, nid := range n {
if nid == id {
return true
}
}
return false
} | go | {
"resource": ""
} |
q33784 | ContainsID | train | func (t *Topology) ContainsID(id string) bool {
t.mu.RLock()
defer t.mu.RUnlock()
return t.containsID(id)
} | go | {
"resource": ""
} |
q33785 | addID | train | func (t *Topology) addID(nodeID string) bool {
t.mu.Lock()
defer t.mu.Unlock()
if t.containsID(nodeID) {
return false
}
t.nodeIDs = append(t.nodeIDs, nodeID)
sort.Slice(t.nodeIDs,
func(i, j int) bool {
return t.nodeIDs[i] < t.nodeIDs[j]
})
return true
} | go | {
"resource": ""
} |
q33786 | removeID | train | func (t *Topology) removeID(nodeID string) bool {
t.mu.Lock()
defer t.mu.Unlock()
i := t.positionByID(nodeID)
if i < 0 {
return false
}
copy(t.nodeIDs[i:], t.nodeIDs[i+1:])
t.nodeIDs[len(t.nodeIDs)-1] = ""
t.nodeIDs = t.nodeIDs[:len(t.nodeIDs)-1]
return true
} | go | {
"resource": ""
} |
q33787 | loadTopology | train | func (c *cluster) loadTopology() error {
buf, err := ioutil.ReadFile(filepath.Join(c.Path, ".topology"))
if os.IsNotExist(err) {
c.Topology = newTopology()
return nil
} else if err != nil {
return errors.Wrap(err, "reading file")
}
var pb internal.Topology
if err := proto.Unmarshal(buf, &pb); err != nil {
... | go | {
"resource": ""
} |
q33788 | saveTopology | train | func (c *cluster) saveTopology() error {
if err := os.MkdirAll(c.Path, 0777); err != nil {
return errors.Wrap(err, "creating directory")
}
if buf, err := proto.Marshal(encodeTopology(c.Topology)); err != nil {
return errors.Wrap(err, "marshalling")
} else if err := ioutil.WriteFile(filepath.Join(c.Path, ".top... | go | {
"resource": ""
} |
q33789 | ReceiveEvent | train | func (c *cluster) ReceiveEvent(e *NodeEvent) (err error) {
// Ignore events sent from this node.
if e.Node.ID == c.Node.ID {
return nil
}
switch e.Event {
case NodeJoin:
c.logger.Debugf("nodeJoin of %s on %s", e.Node.URI, c.Node.URI)
// Ignore the event if this is not the coordinator.
if !c.isCoordinator(... | go | {
"resource": ""
} |
q33790 | nodeJoin | train | func (c *cluster) nodeJoin(node *Node) error {
c.mu.Lock()
defer c.mu.Unlock()
c.logger.Printf("node join event on coordinator, node: %s, id: %s", node.URI, node.ID)
if c.needTopologyAgreement() {
// A host that is not part of the topology can't be added to the STARTING cluster.
if !c.Topology.ContainsID(node.I... | go | {
"resource": ""
} |
q33791 | nodeLeave | train | func (c *cluster) nodeLeave(nodeID string) error {
c.mu.Lock()
defer c.mu.Unlock()
// Refuse the request if this is not the coordinator.
if !c.unprotectedIsCoordinator() {
return fmt.Errorf("node removal requests are only valid on the coordinator node: %s",
c.unprotectedCoordinatorNode().ID)
}
if c.state !=... | go | {
"resource": ""
} |
q33792 | unprotectedPreviousNode | train | func (c *cluster) unprotectedPreviousNode() *Node {
if len(c.nodes) <= 1 {
return nil
}
pos := c.nodePositionByID(c.Node.ID)
if pos == -1 {
return nil
} else if pos == 0 {
return c.nodes[len(c.nodes)-1]
} else {
return c.nodes[pos-1]
}
} | go | {
"resource": ""
} |
q33793 | OptServerLogger | train | func OptServerLogger(l logger.Logger) ServerOption {
return func(s *Server) error {
s.logger = l
return nil
}
} | go | {
"resource": ""
} |
q33794 | OptServerReplicaN | train | func OptServerReplicaN(n int) ServerOption {
return func(s *Server) error {
s.cluster.ReplicaN = n
return nil
}
} | go | {
"resource": ""
} |
q33795 | OptServerDataDir | train | func OptServerDataDir(dir string) ServerOption {
return func(s *Server) error {
s.dataDir = dir
return nil
}
} | go | {
"resource": ""
} |
q33796 | OptServerAttrStoreFunc | train | func OptServerAttrStoreFunc(af func(string) AttrStore) ServerOption {
return func(s *Server) error {
s.holder.NewAttrStore = af
return nil
}
} | go | {
"resource": ""
} |
q33797 | OptServerAntiEntropyInterval | train | func OptServerAntiEntropyInterval(interval time.Duration) ServerOption {
return func(s *Server) error {
s.antiEntropyInterval = interval
return nil
}
} | go | {
"resource": ""
} |
q33798 | OptServerLongQueryTime | train | func OptServerLongQueryTime(dur time.Duration) ServerOption {
return func(s *Server) error {
s.cluster.longQueryTime = dur
return nil
}
} | go | {
"resource": ""
} |
q33799 | OptServerMaxWritesPerRequest | train | func OptServerMaxWritesPerRequest(n int) ServerOption {
return func(s *Server) error {
s.maxWritesPerRequest = n
return nil
}
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.