//handleCreateSnapshot will create the necessary snapshots //after flush has completed func (s *storageMgr) handleCreateSnapshot(cmd Message) { s.supvCmdch <- &MsgSuccess{} logging.Tracef("StorageMgr::handleCreateSnapshot %v", cmd) msgFlushDone := cmd.(*MsgMutMgrFlushDone) bucket := msgFlushDone.GetBucket() tsVbuuid := msgFlushDone.GetTS() streamId := msgFlushDone.GetStreamId() numVbuckets := s.config["numVbuckets"].Int() snapType := tsVbuuid.GetSnapType() tsVbuuid.Crc64 = common.HashVbuuid(tsVbuuid.Vbuuids) if snapType == common.NO_SNAP { logging.Infof("StorageMgr::handleCreateSnapshot Skip Snapshot For %v "+ "%v SnapType %v", streamId, bucket, snapType) s.supvRespch <- &MsgMutMgrFlushDone{mType: STORAGE_SNAP_DONE, streamId: streamId, bucket: bucket, ts: tsVbuuid} return } s.muSnap.Lock() defer s.muSnap.Unlock() //pass copy of maps to worker indexSnapMap := copyIndexSnapMap(s.indexSnapMap) indexInstMap := common.CopyIndexInstMap(s.indexInstMap) indexPartnMap := CopyIndexPartnMap(s.indexPartnMap) stats := s.stats.Get() go s.createSnapshotWorker(streamId, bucket, tsVbuuid, indexSnapMap, numVbuckets, indexInstMap, indexPartnMap, stats) }
func (c *GsiClient) getConsistency( cons common.Consistency, vector *TsConsistency, bucket string) (*TsConsistency, error) { var err error if cons == common.QueryConsistency && vector == nil { return nil, ErrorExpectedTimestamp } else if cons == common.SessionConsistency { if hash64, ok := c.getBucketHash(bucket); ok && hash64 != 0 { begin := time.Now() fmsg := "Time taken by GET_SEQNOS call, %v CRC: %v\n" defer func() { logging.Debugf(fmsg, time.Since(begin), hash64) }() if vector, err = c.BucketSeqnos(bucket, hash64); err != nil { return nil, err } } else { begin := time.Now() fmsg := "Time taken by STATS call, %v\n" defer func() { logging.Debugf(fmsg, time.Since(begin)) }() if vector, err = c.BucketTs(bucket); err != nil { return nil, err } vector.Crc64 = common.HashVbuuid(vector.Vbuuids) vector.Vbuuids = nil c.setBucketHash(bucket, vector.Crc64) logging.Debugf("STATS CRC: %v\n", vector.Crc64) } } else if cons == common.AnyConsistency { vector = nil } else { return nil, ErrorInvalidConsistency } return vector, nil }