Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Side by Side Diff: client/cmd/isolate/checker.go

Issue 2561543002: Log hit and miss file and byte counts from exparchive. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | client/cmd/isolate/checker_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "log" 8 "log"
9 "time" 9 "time"
10 10
(...skipping 23 matching lines...) Expand all
34 callback CheckerCallback 34 callback CheckerCallback
35 } 35 }
36 36
37 // Checker uses the isolatedclient.Client to check whether items are available 37 // Checker uses the isolatedclient.Client to check whether items are available
38 // on the server. 38 // on the server.
39 // Checker methods are safe to call concurrently. 39 // Checker methods are safe to call concurrently.
40 type Checker struct { 40 type Checker struct {
41 svc isolateService 41 svc isolateService
42 bundler *bundler.Bundler 42 bundler *bundler.Bundler
43 err error 43 err error
44
45 Hit, Miss CountBytes
46 }
47
48 // CountBytes aggregates a count of files and the number of bytes in them.
49 type CountBytes struct {
50 Count int
51 Bytes int64
52 }
53
54 func (cb *CountBytes) addFile(size int64) {
55 cb.Count++
56 cb.Bytes += size
44 } 57 }
45 58
46 // NewChecker creates a NewChecker with the given isolated client. 59 // NewChecker creates a NewChecker with the given isolated client.
47 func NewChecker(client *isolatedclient.Client) *Checker { 60 func NewChecker(client *isolatedclient.Client) *Checker {
48 return newChecker(client) 61 return newChecker(client)
49 } 62 }
50 63
51 func newChecker(svc isolateService) *Checker { 64 func newChecker(svc isolateService) *Checker {
52 c := &Checker{ 65 c := &Checker{
53 svc: svc, 66 svc: svc,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 Digest: string(item.item.Digest), 114 Digest: string(item.item.Digest),
102 Size: item.item.Size, 115 Size: item.item.Size,
103 IsIsolated: item.isolated, 116 IsIsolated: item.isolated,
104 }) 117 })
105 } 118 }
106 out, err := c.svc.Contains(context.Background(), digests) 119 out, err := c.svc.Contains(context.Background(), digests)
107 if err != nil { 120 if err != nil {
108 return err 121 return err
109 } 122 }
110 for i, item := range items { 123 for i, item := range items {
124 if size := item.item.Size; out[i] == nil {
125 c.Hit.addFile(size)
126 } else {
127 c.Miss.addFile(size)
128 }
129
111 item.callback(item.item, out[i]) 130 item.callback(item.item, out[i])
112 } 131 }
113 return nil 132 return nil
114 } 133 }
OLDNEW
« no previous file with comments | « no previous file | client/cmd/isolate/checker_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698