本文整理匯總了Golang中github.com/Symantec/Dominator/proto/sub.UpdateRequest.ImageName方法的典型用法代碼示例。如果您正苦於以下問題:Golang UpdateRequest.ImageName方法的具體用法?Golang UpdateRequest.ImageName怎麽用?Golang UpdateRequest.ImageName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Symantec/Dominator/proto/sub.UpdateRequest
的用法示例。
在下文中一共展示了UpdateRequest.ImageName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: buildUpdateRequest
// Returns (idle, missing), idle=true if no update needs to be performed.
func (sub *Sub) buildUpdateRequest(request *subproto.UpdateRequest) (
bool, bool) {
waitStartTime := time.Now()
sub.herd.computeSemaphore <- struct{}{}
computeSlotWaitTimeDistribution.Add(time.Since(waitStartTime))
defer func() { <-sub.herd.computeSemaphore }()
request.ImageName = sub.requiredImageName
request.Triggers = sub.requiredImage.Triggers
var rusageStart, rusageStop syscall.Rusage
computeStartTime := time.Now()
syscall.Getrusage(syscall.RUSAGE_SELF, &rusageStart)
subObj := lib.Sub{
Hostname: sub.mdb.Hostname,
FileSystem: sub.fileSystem,
ComputedInodes: sub.computedInodes,
ObjectCache: sub.objectCache}
if lib.BuildUpdateRequest(subObj, sub.requiredImage, request, false,
sub.herd.logger) {
return false, true
}
syscall.Getrusage(syscall.RUSAGE_SELF, &rusageStop)
computeTimeDistribution.Add(time.Since(computeStartTime))
sub.lastComputeUpdateCpuDuration = time.Duration(
rusageStop.Utime.Sec)*time.Second +
time.Duration(rusageStop.Utime.Usec)*time.Microsecond -
time.Duration(rusageStart.Utime.Sec)*time.Second -
time.Duration(rusageStart.Utime.Usec)*time.Microsecond
computeCpuTimeDistribution.Add(sub.lastComputeUpdateCpuDuration)
if len(request.FilesToCopyToCache) > 0 ||
len(request.InodesToMake) > 0 ||
len(request.HardlinksToMake) > 0 ||
len(request.PathsToDelete) > 0 ||
len(request.DirectoriesToMake) > 0 ||
len(request.InodesToChange) > 0 ||
sub.lastSuccessfulImageName != sub.requiredImageName {
sub.herd.logger.Printf(
"buildUpdateRequest(%s) took: %s user CPU time\n",
sub, sub.lastComputeUpdateCpuDuration)
return false, false
}
return true, false
}
示例2: pushImage
func pushImage(getSubClient getSubClientFunc, imageName string) error {
logger := log.New(os.Stderr, "", log.LstdFlags)
computedInodes := make(map[string]*filesystem.RegularInode)
// Start querying the imageserver for the image.
imageServerAddress := fmt.Sprintf("%s:%d",
*imageServerHostname, *imageServerPortNum)
imgChannel := getImageChannel(imageServerAddress, imageName, timeoutTime)
startTime := showStart("getSubClient()")
srpcClient := getSubClient()
showTimeTaken(startTime)
subObj := lib.Sub{
Hostname: *subHostname,
Client: srpcClient,
ComputedInodes: computedInodes}
if *computedFilesRoot == "" {
subObj.ObjectGetter = nullObjectGetterType{}
} else {
fs, err := scanner.ScanFileSystem(*computedFilesRoot, nil, nil, nil,
nil, nil)
if err != nil {
return err
}
subObj.ObjectGetter = fs
for filename, inum := range fs.FilenameToInodeTable() {
if inode, ok := fs.InodeTable[inum].(*filesystem.RegularInode); ok {
computedInodes[filename] = inode
}
}
}
startTime = showStart("<-imgChannel")
imageResult := <-imgChannel
showTimeTaken(startTime)
fmt.Fprintf(os.Stderr, "Background image fetch took %s\n",
format.Duration(imageResult.duration))
img := imageResult.image
var err error
if *filterFile != "" {
img.Filter, err = filter.Load(*filterFile)
if err != nil {
return err
}
}
if *triggersFile != "" {
img.Triggers, err = triggers.Load(*triggersFile)
if err != nil {
return err
}
} else if *triggersString != "" {
img.Triggers, err = triggers.Decode([]byte(*triggersString))
if err != nil {
return err
}
}
if err := pollFetchAndPush(&subObj, img, imageServerAddress, timeoutTime,
logger); err != nil {
return err
}
var updateRequest sub.UpdateRequest
var updateReply sub.UpdateResponse
startTime = showStart("lib.BuildUpdateRequest()")
if lib.BuildUpdateRequest(subObj, img, &updateRequest, true, logger) {
showBlankLine()
return errors.New("missing computed file(s)")
}
showTimeTaken(startTime)
updateRequest.ImageName = imageName
updateRequest.Wait = true
startTime = showStart("Subd.Update()")
err = client.CallUpdate(srpcClient, updateRequest, &updateReply)
if err != nil {
showBlankLine()
return err
}
showTimeTaken(startTime)
return nil
}