本文整理汇总了Golang中github.com/couchbase/indexing/secondary/common.TsVbuuid.GetSnapType方法的典型用法代码示例。如果您正苦于以下问题:Golang TsVbuuid.GetSnapType方法的具体用法?Golang TsVbuuid.GetSnapType怎么用?Golang TsVbuuid.GetSnapType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbase/indexing/secondary/common.TsVbuuid
的用法示例。
在下文中一共展示了TsVbuuid.GetSnapType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createSnapshotWorker
func (s *storageMgr) createSnapshotWorker(streamId common.StreamId, bucket string,
tsVbuuid *common.TsVbuuid, indexSnapMap IndexSnapMap, numVbuckets int,
indexInstMap common.IndexInstMap, indexPartnMap IndexPartnMap, stats *IndexerStats) {
defer destroyIndexSnapMap(indexSnapMap)
var needsCommit bool
snapType := tsVbuuid.GetSnapType()
if snapType == common.DISK_SNAP {
needsCommit = true
}
var wg sync.WaitGroup
//for every index managed by this indexer
for idxInstId, partnMap := range indexPartnMap {
// Create snapshots for all indexes in parallel
wg.Add(1)
go func(idxInstId common.IndexInstId, partnMap PartitionInstMap) {
defer wg.Done()
idxInst := indexInstMap[idxInstId]
idxStats := stats.indexes[idxInst.InstId]
lastIndexSnap := indexSnapMap[idxInstId]
//if index belongs to the flushed bucket and stream
if idxInst.Defn.Bucket == bucket &&
idxInst.Stream == streamId &&
idxInst.State != common.INDEX_STATE_DELETED {
// List of snapshots for reading current timestamp
var isSnapCreated bool = true
partnSnaps := make(map[common.PartitionId]PartitionSnapshot)
//for all partitions managed by this indexer
for partnId, partnInst := range partnMap {
var lastPartnSnap PartitionSnapshot
if lastIndexSnap != nil {
lastPartnSnap = lastIndexSnap.Partitions()[partnId]
}
sc := partnInst.Sc
sliceSnaps := make(map[SliceId]SliceSnapshot)
//create snapshot for all the slices
for _, slice := range sc.GetAllSlices() {
var latestSnapshot Snapshot
if lastIndexSnap.Partitions() != nil {
lastSliceSnap := lastPartnSnap.Slices()[slice.Id()]
latestSnapshot = lastSliceSnap.Snapshot()
}
//if flush timestamp is greater than last
//snapshot timestamp, create a new snapshot
snapTs := NewTimestamp(numVbuckets)
if latestSnapshot != nil {
snapTsVbuuid := latestSnapshot.Timestamp()
snapTs = getSeqTsFromTsVbuuid(snapTsVbuuid)
}
ts := getSeqTsFromTsVbuuid(tsVbuuid)
//if the flush TS is greater than the last snapshot TS
//and slice has some changes. Skip only in-memory snapshot
//in case of unchanged data.
if latestSnapshot == nil || (ts.GreaterThan(snapTs) &&
(slice.IsDirty() || needsCommit)) {
newTsVbuuid := tsVbuuid.Copy()
var err error
var info SnapshotInfo
var newSnapshot Snapshot
logging.Tracef("StorageMgr::handleCreateSnapshot Creating New Snapshot "+
"Index: %v PartitionId: %v SliceId: %v Commit: %v", idxInstId, partnId, slice.Id(), needsCommit)
snapCreateStart := time.Now()
if info, err = slice.NewSnapshot(newTsVbuuid, needsCommit); err != nil {
logging.Errorf("handleCreateSnapshot::handleCreateSnapshot Error "+
"Creating new snapshot Slice Index: %v Slice: %v. Skipped. Error %v", idxInstId,
slice.Id(), err)
isSnapCreated = false
common.CrashOnError(err)
continue
}
snapCreateDur := time.Since(snapCreateStart)
idxStats := stats.indexes[idxInstId]
idxStats.numSnapshots.Add(1)
if needsCommit {
idxStats.numCommits.Add(1)
}
snapOpenStart := time.Now()
if newSnapshot, err = slice.OpenSnapshot(info); err != nil {
logging.Errorf("StorageMgr::handleCreateSnapshot Error Creating Snapshot "+
"for Index: %v Slice: %v. Skipped. Error %v", idxInstId,
slice.Id(), err)
isSnapCreated = false
common.CrashOnError(err)
continue
}
//.........这里部分代码省略.........