本文整理匯總了Golang中github.com/Symantec/Dominator/proto/sub.UpdateRequest.InodesToMake方法的典型用法代碼示例。如果您正苦於以下問題:Golang UpdateRequest.InodesToMake方法的具體用法?Golang UpdateRequest.InodesToMake怎麽用?Golang UpdateRequest.InodesToMake使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Symantec/Dominator/proto/sub.UpdateRequest
的用法示例。
在下文中一共展示了UpdateRequest.InodesToMake方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: addInode
func (sub *Sub) addInode(request *subproto.UpdateRequest,
requiredEntry *filesystem.DirectoryEntry, myPathName string) {
requiredInode := requiredEntry.Inode()
if name, ok := sub.inodesCreated[requiredEntry.InodeNumber]; ok {
makeHardlink(request, myPathName, name)
return
}
// Try to find a sibling inode.
names := sub.requiredFS.InodeToFilenamesTable()[requiredEntry.InodeNumber]
subFS := sub.FileSystem
if len(names) > 1 {
var sameDataInode filesystem.GenericInode
var sameDataName string
for _, name := range names {
if inum, found := subFS.FilenameToInodeTable()[name]; found {
subInode := sub.FileSystem.InodeTable[inum]
_, sameMetadata, sameData := filesystem.CompareInodes(
subInode, requiredInode, nil)
if sameMetadata && sameData {
makeHardlink(request, myPathName, name)
return
}
if sameData {
sameDataInode = subInode
sameDataName = name
}
}
}
if sameDataInode != nil {
sub.updateMetadata(request, requiredEntry, sameDataName)
makeHardlink(request, myPathName, sameDataName)
return
}
}
if inode, ok := requiredEntry.Inode().(*filesystem.RegularInode); ok {
if inode.Size > 0 {
if _, ok := sub.subObjectCacheUsage[inode.Hash]; ok {
sub.subObjectCacheUsage[inode.Hash]++
} else {
// Not in object cache: grab it from file-system.
request.FilesToCopyToCache = append(
request.FilesToCopyToCache,
sub.getFileToCopy(myPathName, inode.Hash))
sub.subObjectCacheUsage[inode.Hash] = 1
}
}
}
var inode subproto.Inode
inode.Name = myPathName
inode.GenericInode = requiredEntry.Inode()
request.InodesToMake = append(request.InodesToMake, inode)
sub.inodesCreated[requiredEntry.InodeNumber] = myPathName
}
示例2: pushFile
func pushFile(getSubClient getSubClientFunc, source, dest string) error {
var sourceStat wsyscall.Stat_t
if err := wsyscall.Stat(source, &sourceStat); err != nil {
return err
}
sourceFile, err := os.Open(source)
if err != nil {
return err
}
defer sourceFile.Close()
srpcClient := getSubClient()
objClient := objclient.AttachObjectClient(srpcClient)
defer objClient.Close()
if err != nil {
return err
}
hashVal, _, err := objClient.AddObject(sourceFile, uint64(sourceStat.Size),
nil)
if err != nil {
return err
}
newRegularInode := &filesystem.RegularInode{
Mode: filesystem.FileMode(sourceStat.Mode),
Uid: sourceStat.Uid,
Gid: sourceStat.Gid,
MtimeNanoSeconds: int32(sourceStat.Mtim.Nsec),
MtimeSeconds: sourceStat.Mtim.Sec,
Size: uint64(sourceStat.Size),
Hash: hashVal}
newInode := sub.Inode{Name: dest, GenericInode: newRegularInode}
var updateRequest sub.UpdateRequest
var updateReply sub.UpdateResponse
updateRequest.Wait = true
updateRequest.InodesToMake = append(updateRequest.InodesToMake, newInode)
if *triggersFile != "" {
updateRequest.Triggers, err = triggers.Load(*triggersFile)
if err != nil {
return err
}
} else if *triggersString != "" {
updateRequest.Triggers, err = triggers.Decode([]byte(*triggersString))
if err != nil {
return err
}
}
startTime := showStart("Subd.Update()")
err = client.CallUpdate(srpcClient, updateRequest, &updateReply)
showTimeTaken(startTime)
return err
}
示例3: addInode
func addInode(request *subproto.UpdateRequest, state *state,
requiredEntry *filesystem.DirectoryEntry, myPathName string) {
requiredInode := requiredEntry.Inode()
if name, ok := state.inodesCreated[requiredEntry.InodeNumber]; ok {
makeHardlink(request, myPathName, name)
return
}
// Try to find a sibling inode.
names := state.requiredFS.InodeToFilenamesTable[requiredEntry.InodeNumber]
if len(names) > 1 {
var sameDataInode filesystem.GenericInode
var sameDataName string
for _, name := range names {
if inum, found := state.getSubInodeFromFilename(name); found {
subInode := state.subFS.InodeTable[inum]
_, sameMetadata, sameData := filesystem.CompareInodes(
subInode, requiredInode, nil)
if sameMetadata && sameData {
makeHardlink(request, myPathName, name)
return
}
if sameData {
sameDataInode = subInode
sameDataName = name
}
}
}
if sameDataInode != nil {
updateMetadata(request, state, requiredEntry, sameDataName)
makeHardlink(request, myPathName, sameDataName)
return
}
}
if inode, ok := requiredEntry.Inode().(*filesystem.RegularInode); ok {
if inode.Size > 0 {
if _, ok := state.subObjectCacheUsage[inode.Hash]; ok {
state.subObjectCacheUsage[inode.Hash]++
} else {
// Not in object cache: grab it from file-system.
if state.subFS.HashToInodesTable == nil {
state.subFS.BuildHashToInodesTable()
}
if ilist, ok := state.subFS.HashToInodesTable[inode.Hash]; ok {
var fileToCopy subproto.FileToCopyToCache
fileToCopy.Name =
state.subFS.InodeToFilenamesTable[ilist[0]][0]
fileToCopy.Hash = inode.Hash
request.FilesToCopyToCache = append(
request.FilesToCopyToCache, fileToCopy)
state.subObjectCacheUsage[inode.Hash] = 1
} else {
panic("No object in cache for: " + myPathName)
}
}
}
}
var inode subproto.Inode
inode.Name = myPathName
inode.GenericInode = requiredEntry.Inode()
request.InodesToMake = append(request.InodesToMake, inode)
state.inodesCreated[requiredEntry.InodeNumber] = myPathName
}