id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c175200 |
if resp, ok := c.lru.Get(key); ok {
return resp.(*pb.RangeResponse), nil
}
return nil, errors.New("not exist")
} | |
c175201 | := range ivs {
keys := iv.Val.(map[string]struct{})
for key := range keys {
c.lru.Remove(key)
}
}
// delete after removing all keys since it is destructive to 'ivs'
c.cachedRanges.Delete(ivl)
} | |
c175202 | revision > c.compactedRev {
c.compactedRev = revision
}
} | |
c175203 | == "" {
return us
}
if err := us.Set(s); err != nil {
plog.Panicf("new UniqueURLs should never fail: %v", err)
}
return us
} | |
c175204 | return (*fs.Lookup(urlsFlagName).Value.(*UniqueURLs)).uss
} | |
c175205 | (*fs.Lookup(urlsFlagName).Value.(*UniqueURLs)).Values
} | |
c175206 | b.key, v3.NoLease)
return err
} | |
c175207 | _, err := b.client.Delete(b.ctx, b.key)
return err
} | |
c175208 | err = WaitEvents(
b.client,
b.key,
resp.Header.Revision,
[]mvccpb.Event_EventType{mvccpb.PUT, mvccpb.DELETE})
return err
} | |
c175209 | Short: "Performs lock race operation",
Run: runRacerFunc,
}
cmd.Flags().IntVar(&totalClientConnections, "total-client-connections", 10, "total number of client connections")
return cmd
} | |
c175210 | {
return time.Duration(m.Etcd.ElectionTimeoutMs) * time.Millisecond
} | |
c175211 | disk
tlsInfo := transport.TLSInfo{
CertFile: m.ClientCertPath,
KeyFile: m.ClientKeyPath,
TrustedCAFile: m.ClientTrustedCAPath,
// TODO: remove this with generated certs
// only need it for auto TLS
InsecureSkipVerify: true,
}
tlsConfig, err := tlsInfo.ClientConfig()
if err != nil {
return nil, err
}
creds := credentials.NewTLS(tlsConfig)
dialOpts = append(dialOpts, grpc.WithTransportCredentials(creds))
} else {
dialOpts = append(dialOpts, grpc.WithInsecure())
}
dialOpts = append(dialOpts, opts...)
return grpc.Dial(m.EtcdClientEndpoint, dialOpts...)
} | |
c175212 | CertFile: m.ClientCertPath,
KeyFile: m.ClientKeyPath,
TrustedCAFile: m.ClientTrustedCAPath,
// TODO: remove this with generated certs
// only need it for auto TLS
InsecureSkipVerify: true,
}
var tlsConfig *tls.Config
tlsConfig, err = tlsInfo.ClientConfig()
if err != nil {
return nil, err
}
cfg.TLS = tlsConfig
}
return cfg, err
} | |
c175213 | {
cfg, err := m.CreateEtcdClientConfig(opts...)
if err != nil {
return nil, err
}
return clientv3.New(*cfg)
} | |
c175214 | {
return fmt.Errorf("watch channel terminated (endpoint %q)", m.EtcdClientEndpoint)
}
if wr.CompactRevision != rev {
return fmt.Errorf("got compact revision %v, wanted %v (endpoint %q)", wr.CompactRevision, rev, m.EtcdClientEndpoint)
}
return nil
} | |
c175215 | := context.WithTimeout(context.Background(), 5*time.Minute)
_, err = cli.Defragment(ctx, m.EtcdClientEndpoint)
cancel()
return err
} | |
c175216 | := mt.Hash(ctx, &pb.HashRequest{}, grpc.FailFast(false))
cancel()
if err != nil {
return 0, 0, err
}
return resp.Header.Revision, int64(resp.Hash), nil
} | |
c175217 |
resp, err := cli.Status(ctx, m.EtcdClientEndpoint)
if err != nil {
return 0, err
}
return resp.Header.Revision, nil
} | |
c175218 |
ctx, cancel := context.WithTimeout(context.Background(), timeout)
_, err = cli.Compact(ctx, rev, clientv3.WithCompactPhysical())
cancel()
return err
} | |
c175219 | err := cli.Status(context.Background(), m.EtcdClientEndpoint)
if err != nil {
return false, err
}
return resp.Header.MemberId == resp.Leader, nil
} | |
c175220 | in case expensive requests (range/delete) are pending
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
_, err = cli.Put(ctx, "health", "good")
cancel()
if err != nil {
return fmt.Errorf("%v (%q)", err, m.EtcdClientEndpoint)
}
return nil
} | |
c175221 | int64(st.Hash),
SnapshotRevision: st.Revision,
Took: fmt.Sprintf("%v", took),
}
lg.Info(
"snapshot save END",
zap.String("member-name", m.SnapshotInfo.MemberName),
zap.Strings("member-client-urls", m.SnapshotInfo.MemberClientURLs),
zap.String("snapshot-path", m.SnapshotPath),
zap.String("snapshot-file-size", m.SnapshotInfo.SnapshotFileSize),
zap.String("snapshot-total-size", m.SnapshotInfo.SnapshotTotalSize),
zap.Int64("snapshot-total-key", m.SnapshotInfo.SnapshotTotalKey),
zap.Int64("snapshot-hash", m.SnapshotInfo.SnapshotHash),
zap.Int64("snapshot-revision", m.SnapshotInfo.SnapshotRevision),
zap.String("took", m.SnapshotInfo.Took),
)
return nil
} | |
c175222 | "snapshot restore END",
zap.String("member-name", m.SnapshotInfo.MemberName),
zap.Strings("member-client-urls", m.SnapshotInfo.MemberClientURLs),
zap.String("snapshot-path", m.SnapshotPath),
zap.String("snapshot-file-size", m.SnapshotInfo.SnapshotFileSize),
zap.String("snapshot-total-size", m.SnapshotInfo.SnapshotTotalSize),
zap.Int64("snapshot-total-key", m.SnapshotInfo.SnapshotTotalKey),
zap.Int64("snapshot-hash", m.SnapshotInfo.SnapshotHash),
zap.Int64("snapshot-revision", m.SnapshotInfo.SnapshotRevision),
zap.String("took", took.String()),
zap.Error(err),
)
return err
} | |
c175223 | w, pfx: prefix, stopc: make(chan struct{})}
} | |
c175224 | = pb.Entry{Type: pb.EntryConfChange, Term: 1, Index: uint64(i + 1), Data: data}
}
r.raftLog.append(ents...)
r.raftLog.committed = uint64(len(ents))
for _, peer := range peers {
r.addNode(peer.ID)
}
}
// Set the initial hard and soft states after performing all initialization.
rn.prevSoftSt = r.softState()
if lastIndex == 0 {
rn.prevHardSt = emptyState
} else {
rn.prevHardSt = r.hardState()
}
return rn, nil
} | |
c175225 | return rn.raft.Step(pb.Message{
Type: pb.MsgHup,
})
} | |
c175226 |
Type: pb.MsgProp,
From: rn.raft.id,
Entries: []pb.Entry{
{Data: data},
}})
} | |
c175227 | {
return err
}
return rn.raft.Step(pb.Message{
Type: pb.MsgProp,
Entries: []pb.Entry{
{Type: pb.EntryConfChange, Data: data},
},
})
} | |
c175228 |
case pb.ConfChangeRemoveNode:
rn.raft.removeNode(cc.NodeID)
case pb.ConfChangeUpdateNode:
default:
panic("unexpected conf type")
}
return &pb.ConfState{Nodes: rn.raft.nodes(), Learners: rn.raft.learnerNodes()}
} | |
c175229 | pr := rn.raft.getProgress(m.From); pr != nil || !IsResponseMsg(m.Type) {
return rn.raft.Step(m)
}
return ErrStepPeerNotFound
} | |
c175230 | rn.raft.reduceUncommittedSize(rd.CommittedEntries)
return rd
} | |
c175231 |
for id, pr := range rn.raft.learnerPrs {
pr := *pr
pr.ins = nil
visitor(id, ProgressTypeLearner, pr)
}
} | |
c175232 | rn.raft.Step(pb.Message{Type: pb.MsgUnreachable, From: id})
} | |
c175233 | := status == SnapshotFailure
_ = rn.raft.Step(pb.Message{Type: pb.MsgSnapStatus, From: id, Reject: rej})
} | |
c175234 | rn.raft.Step(pb.Message{Type: pb.MsgTransferLeader, From: transferee})
} | |
c175235 | pb.MsgReadIndex, Entries: []pb.Entry{{Data: rctx}}})
} | |
c175236 | -d %q", string(b))
}
fmt.Fprintf(os.Stderr, "cURL Command: %s\n", command)
// reset body
body := bytes.NewBuffer(b)
req.Body = ioutil.NopCloser(body)
return nil
} | |
c175237 | all calls to raftLog.append so progress.next is set after these
// bootstrapping entries (it is an error if we try to append these
// entries since they have already been committed).
// We do not set raftLog.applied so the application will be able
// to observe all conf changes via Ready.CommittedEntries.
for _, peer := range peers {
r.addNode(peer.ID)
}
n := newNode()
n.logger = c.Logger
go n.run(r)
return &n
} | |
c175238 |
n := newNode()
n.logger = c.Logger
go n.run(r)
return &n
} | |
c175239 | n.logger.Warningf("A tick missed to fire. Node blocks too long!")
}
} | |
c175240 | storage before responding to RPCs)
// currentTerm
// votedFor
// log entries[]
return entsnum != 0 || st.Vote != prevst.Vote || st.Term != prevst.Term
} | |
c175241 | make(chan struct{}),
updateAddrsC: make(chan NotifyMsg),
hostPort2ep: getHostPort2ep(eps),
}
if timeout < minHealthRetryDuration {
timeout = minHealthRetryDuration
}
hb.healthCheckTimeout = timeout
close(hb.downc)
go hb.updateNotifyLoop()
hb.wg.Add(1)
go func() {
defer hb.wg.Done()
hb.updateUnhealthy()
}()
return hb
} | |
c175242 | if all connections are down
// or addrs does not include pinAddr.
b.mu.RLock()
update := !hasAddr(b.addrs, b.pinAddr)
b.mu.RUnlock()
return update
} | |
c175243 | unsafe.Pointer(&sigactBuf)
syscall.Syscall6(uintptr(syscall.SYS_RT_SIGACTION), uintptr(sig), uintptr(ptr), 0, 8, 0, 0)
} | |
c175244 |
s.clock = clockwork.NewRealClock()
return s
} | |
c175245 | s.worldLock.RUnlock()
return s.CurrentIndex
} | |
c175246 | reportReadFailure(Get)
}
}()
n, err := s.internalGet(nodePath)
if err != nil {
return nil, err
}
e := newEvent(Get, nodePath, n.ModifiedIndex, n.CreatedIndex)
e.EtcdIndex = s.CurrentIndex
e.Node.loadInternalNode(n, recursive, sorted, s.clock)
return e, nil
} | |
c175247 |
reportWriteFailure(Create)
}()
e, err := s.internalCreate(nodePath, dir, value, unique, false, expireOpts.ExpireTime, Create)
if err != nil {
return nil, err
}
e.EtcdIndex = s.CurrentIndex
s.WatcherHub.notify(e)
return e, nil
} | |
c175248 | nil, err
}
e.EtcdIndex = s.CurrentIndex
// Put prevNode into event
if getErr == nil {
prev := newEvent(Get, nodePath, n.ModifiedIndex, n.CreatedIndex)
prev.Node.loadInternalNode(n, false, false, s.clock)
e.PrevNode = prev.Node
}
if !expireOpts.Refresh {
s.WatcherHub.notify(e)
} else {
e.SetRefresh()
s.WatcherHub.add(e)
}
return e, nil
} | |
c175249 | return fmt.Sprintf("[%v != %v]", prevValue, n.Value)
default:
return fmt.Sprintf("[%v != %v] [%v != %v]", prevValue, n.Value, prevIndex, n.ModifiedIndex)
}
} | |
c175250 |
// recursive implies dir
if recursive {
dir = true
}
n, err := s.internalGet(nodePath)
if err != nil { // if the node does not exist, return error
return nil, err
}
nextIndex := s.CurrentIndex + 1
e := newEvent(Delete, nodePath, nextIndex, n.CreatedIndex)
e.EtcdIndex = nextIndex
e.PrevNode = n.Repr(false, false, s.clock)
eNode := e.Node
if n.IsDir() {
eNode.Dir = true
}
callback := func(path string) { // notify function
// notify the watchers with deleted set true
s.WatcherHub.notifyWatchers(e, path, true)
}
err = n.Remove(dir, recursive, callback)
if err != nil {
return nil, err
}
// update etcd index
s.CurrentIndex++
s.WatcherHub.notify(e)
return e, nil
} | |
c175251 |
if len(components[i]) == 0 { // ignore empty string
return curr, nil
}
curr, err = walkFunc(curr, components[i])
if err != nil {
return nil, err
}
}
return curr, nil
} | |
c175252 | nil, v2error.NewError(v2error.EcodeKeyNotFound, path.Join(parent.Path, name), s.CurrentIndex)
}
f, err := s.walk(nodePath, walkFunc)
if err != nil {
return nil, err
}
return f, nil
} | |
c175253 | function
// notify the watchers with deleted set true
s.WatcherHub.notifyWatchers(e, path, true)
}
s.ttlKeyHeap.pop()
node.Remove(true, true, callback)
reportExpiredKey()
s.Stats.Inc(ExpireCount)
s.WatcherHub.notify(e)
}
} | |
c175254 | := newDir(s, path.Join(parent.Path, dirName), s.CurrentIndex+1, parent, Permanent)
parent.Children[dirName] = n
return n, nil
} | |
c175255 | nil {
return nil, err
}
return b, nil
} | |
c175256 |
s.ttlKeyHeap = newTtlKeyHeap()
s.Root.recoverAndclean()
return nil
} | |
c175257 | g.prefix | lowbit(suffix, suffixLen)
return id
} | |
c175258 | TLS key file")
c.Flags().StringVar(&mmcacert, "dest-cacert", "", "Verify certificates of TLS enabled secure servers using this CA bundle")
// TODO: secure by default when etcd enables secure gRPC by default.
c.Flags().BoolVar(&mminsecureTr, "dest-insecure-transport", true, "Disable transport security for client connections")
return c
} | |
c175259 | cr
cfg.loggerWriteSyncer = syncer
grpcLogOnce.Do(func() {
grpclog.SetLoggerV2(logutil.NewGRPCLoggerV2FromZapCore(cr, syncer))
})
return nil
}
} | |
c175260 |
return &syncer{c: c, prefix: prefix, rev: rev}
} | |
c175261 | INPUT -p tcp --destination-port %d -j DROP", port)
_, err := exec.Command("/bin/sh", "-c", cmdStr).Output()
return err
} | |
c175262 | tc qdisc change dev %s root netem delay %dms %dms distribution normal", ifce, ms, rv)
_, err = exec.Command("/bin/sh", "-c", cmdStr).Output()
if err != nil {
return err
}
}
}
return nil
} | |
c175263 | fmt.Sprintf("sudo tc qdisc del dev %s root netem", ifce)).Output()
if err != nil {
return err
}
}
return nil
} | |
c175264 | txnCommandFunc,
}
cmd.Flags().BoolVarP(&txnInteractive, "interactive", "i", false, "Input transaction in interactive mode")
return cmd
} | |
c175265 | del):")
txn.Then(readOps(reader)...)
promptInteractive("failure requests (get, put, del):")
txn.Else(readOps(reader)...)
resp, err := txn.Commit()
if err != nil {
ExitWithError(ExitError, err)
}
display.Txn(*resp)
} | |
c175266 |
return newRevision(lg, clockwork.NewRealClock(), int64(retention), rg, c), nil
default:
return nil, fmt.Errorf("unsupported compaction mode %s", mode)
}
} | |
c175267 | fmt.Println("Modified-Index:", resp.Node.ModifiedIndex)
if resp.PrevNode != nil {
fmt.Println("PrevNode.Value:", resp.PrevNode.Value)
}
fmt.Println("TTL:", resp.Node.TTL)
fmt.Println("Index:", resp.Index)
if resp.Action != "delete" {
fmt.Println("")
fmt.Println(resp.Node.Value)
}
case "json":
b, err := json.Marshal(resp)
if err != nil {
panic(err)
}
fmt.Println(string(b))
default:
fmt.Fprintln(os.Stderr, "Unsupported output format:", format)
}
} | |
c175268 | return RegisterLockHandlerClient(ctx, mux, v3lockpb.NewLockClient(conn))
} | |
c175269 | == 2 && strings.Contains(r.Header.Get("Content-Type"), "application/grpc") {
grpcServer.ServeHTTP(w, r)
} else {
otherHandler.ServeHTTP(w, r)
}
})
} | |
c175270 | OPTIONS, PUT, DELETE")
w.Header().Add("Access-Control-Allow-Origin", origin)
w.Header().Add("Access-Control-Allow-Headers", "accept, content-type, authorization")
} | |
c175271 | txn.lkv.pfx+string(op.KeyBytes()), ""
if len(op.RangeBytes()) > 0 {
lend = txn.lkv.pfx + string(op.RangeBytes())
}
fbOps = append(fbOps, v3.OpGet(lkey, v3.WithRange(lend)))
}
return fbOps
} | |
c175272 | strconv.ParseUint(s, 16, 64)
return ID(i), err
} | |
c175273 | the pid file first.
err = os.Remove(guard.path)
}
if closeErr := guard.f.Close(); err == nil {
err = closeErr
}
guard.path = ""
guard.f = nil
return err
} | |
c175274 | uint16(sz + 1)
}
enc := sizeVarint(v.ExpiresAt)
return uint16(sz + enc)
} | |
c175275 | = binary.Uvarint(b[2:])
v.Value = b[2+sz:]
} | |
c175276 | := &MergeIterator{all: iters, reversed: reversed}
m.h = make(elemHeap, 0, len(iters))
m.initHeap()
return m
} | |
c175277 | {
it := s.h[0].itr
if it == nil || !it.Valid() {
heap.Pop(&s.h)
continue
}
s.storeKey(s.h[0].itr)
break
}
} | |
c175278 | {
return false
}
return s.h[0].itr.Valid()
} | |
c175279 | len(s.h) == 0 {
return nil
}
return s.h[0].itr.Key()
} | |
c175280 | len(s.h) == 0 {
return ValueStruct{}
}
return s.h[0].itr.Value()
} | |
c175281 | heap.Pop(&s.h)
continue
}
heap.Fix(&s.h, 0)
smallest = s.h[0].itr
if smallest.Valid() {
if !bytes.Equal(smallest.Key(), s.curKey) {
break
}
smallest.Next()
}
}
if !smallest.Valid() {
return
}
s.storeKey(smallest)
} | |
c175282 | itr.Seek(key)
}
s.initHeap()
} | |
c175283 | {
return errors.Wrap(err, "MergeIterator")
}
}
return nil
} | |
c175284 |
binary.BigEndian.PutUint32(b[8:12], p.Offset)
return b[:vptrSize]
} | |
c175285 | = binary.BigEndian.Uint64(buf[8:16])
h.meta = buf[16]
h.userMeta = buf[17]
} | |
c175286 |
buf.Write(e.Value)
hash.Write(e.Value)
var crcBuf [crc32.Size]byte
binary.BigEndian.PutUint32(crcBuf[:], hash.Sum32())
buf.Write(crcBuf[:])
return len(headerEnc) + len(e.Key) + len(e.Value) + len(crcBuf), nil
} | |
c175287 |
// This time the error must not be ErrTxnTooBig, otherwise, we make the
// error permanent.
if err := wb.txn.SetEntry(e); err != nil {
wb.err = err
return err
}
return nil
} | |
c175288 | {
e := &Entry{Key: k, Value: v, UserMeta: meta}
return wb.SetEntry(e)
} | |
c175289 | := time.Now().Add(dur).Unix()
e := &Entry{Key: key, Value: val, ExpiresAt: uint64(expire)}
return wb.SetEntry(e)
} | |
c175290 | return err
}
if err := wb.txn.Delete(k); err != nil {
wb.err = err
return err
}
return nil
} | |
c175291 | wait for this one to commit.
wb.wg.Add(1)
wb.txn.CommitWith(wb.callback)
wb.txn = wb.db.newTransaction(true, true)
// See comment about readTs in NewWriteBatch.
wb.txn.readTs = wb.db.orc.readMark.DoneUntil()
return wb.err
} | |
c175292 | access error without any synchronization here.
return wb.err
} | |
c175293 | defer wb.Unlock()
return wb.err
} | |
c175294 | i := range db.imm {
tables[i+1] = db.imm[last-i]
tables[i+1].IncrRef()
}
return tables, func() {
for _, tbl := range tables {
tbl.DecrRef()
}
}
} | |
c175295 | is trying to update s.imm,
// you will get a deadlock.
time.Sleep(10 * time.Millisecond)
}
if err != nil {
done(err)
return errors.Wrap(err, "writeRequests")
}
if err := db.writeToLSM(b); err != nil {
done(err)
return errors.Wrap(err, "writeRequests")
}
db.updateHead(b.Ptrs)
}
done(nil)
db.elog.Printf("%d entries written", count)
return nil
} | |
c175296 | memtable, mt.size=%d size of flushChan: %d\n",
db.mt.MemSize(), len(db.flushChan))
// We manage to push this task. Let's modify imm.
db.imm = append(db.imm, db.mt)
db.mt = skl.NewSkiplist(arenaSize(db.opt))
// New memtable is empty. We certainly have room.
return nil
default:
// We need to do this to unlock and allow the flusher to modify imm.
return errNoRoom
}
} | |
c175297 | }
if err := b.Add(iter.Key(), iter.Value()); err != nil {
return err
}
}
_, err := f.Write(b.Finish())
return err
} | |
c175298 | to level 0: %v", err)
return err
}
if dirSyncErr != nil {
// Do dir sync as best effort. No need to return due to an error there.
db.elog.Errorf("ERROR while syncing level directory: %v", dirSyncErr)
}
tbl, err := table.OpenTable(fd, db.opt.TableLoadingMode, nil)
if err != nil {
db.elog.Printf("ERROR while opening table: %v", err)
return err
}
// We own a ref on tbl.
err = db.lc.addLevel0Table(tbl) // This will incrRef (if we don't error, sure)
tbl.DecrRef() // Releases our ref.
return err
} | |
c175299 | // db.imm list. Once we flush it, we advance db.imm. The next ft.mt
// which would arrive here would match db.imm[0], because we acquire a
// lock over DB when pushing to flushChan.
// TODO: This logic is dirty AF. Any change and this could easily break.
y.AssertTrue(ft.mt == db.imm[0])
db.imm = db.imm[1:]
ft.mt.DecrRef() // Return memory.
db.Unlock()
break
}
// Encountered error. Retry indefinitely.
db.opt.Errorf("Failure while flushing memtable to disk: %v. Retrying...\n", err)
time.Sleep(time.Second)
}
}
return nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.