X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c63ff55687f32dfdff01b9827b411b3757d48ee7..20b7c375715bed99ccfe2dd12ed816b545e94324:/services/datamanager/summary/pull_list.go diff --git a/services/datamanager/summary/pull_list.go b/services/datamanager/summary/pull_list.go index e9bd5d1877..b326c9521a 100644 --- a/services/datamanager/summary/pull_list.go +++ b/services/datamanager/summary/pull_list.go @@ -17,7 +17,6 @@ import ( type Locator blockdigest.DigestWithSize func (l Locator) MarshalJSON() ([]byte, error) { - //return []byte("\"" + l.Digest.String() + "\""), nil return []byte("\"" + blockdigest.DigestWithSize(l).String() + "\""), nil } @@ -60,6 +59,10 @@ type PullServers struct { // Creates a map from block locator to PullServers with one entry for // each under-replicated block. +// +// This method ignores zero-replica blocks since there are no servers +// to pull them from, so callers should feel free to omit them, but +// this function will ignore them if they are provided. func ComputePullServers(kc *keepclient.KeepClient, keepServerInfo *keep.ReadServers, blockToDesiredReplication map[blockdigest.DigestWithSize]int, @@ -72,7 +75,7 @@ func ComputePullServers(kc *keepclient.KeepClient, // Servers that are writeable writableServers := map[string]struct{}{} for _, url := range kc.WritableLocalRoots() { - writableServers[cs.Get(RemoveProtocolPrefix(url))] = struct{}{} + writableServers[cs.Get(url)] = struct{}{} } for block, _ := range underReplicated { @@ -82,17 +85,16 @@ func ComputePullServers(kc *keepclient.KeepClient, if numCopiesMissing > 0 { // We expect this to always be true, since the block was listed // in underReplicated. - // TODO(misha): Consider asserting the above conditional. if numCopies > 0 { - // I believe that we should expect this to always be true. + // Not much we can do with blocks with no copies. // A server's host-port string appears as a key in this map // iff it contains the block. serverHasBlock := map[string]struct{}{} for _, info := range serversStoringBlock { sa := keepServerInfo.KeepServerIndexToAddress[info.ServerIndex] - serverHasBlock[cs.Get(sa.HostPort())] = struct{}{} + serverHasBlock[cs.Get(sa.URL())] = struct{}{} } roots := keepclient.NewRootSorter(kc.LocalRoots(), @@ -124,12 +126,13 @@ func CreatePullServers(cs CanonicalString, for _, host := range sortedServers { // Strip the protocol portion of the url. // Use the canonical copy of the string to avoid memory waste. - server := cs.Get(RemoveProtocolPrefix(host)) + server := cs.Get(host) _, hasBlock := serverHasBlock[server] if hasBlock { - ps.From = append(ps.From, server) + // The from field should include the protocol. + ps.From = append(ps.From, cs.Get(host)) } else if len(ps.To) < maxToFields { - _, writable := writableServers[server] + _, writable := writableServers[host] if writable { ps.To = append(ps.To, server) } @@ -172,7 +175,7 @@ func WritePullLists(arvLogger *logger.Logger, pullLists map[string]PullList) { r := strings.NewReplacer(":", ".") for host, list := range pullLists { - filename := fmt.Sprintf("pull_list.%s", r.Replace(host)) + filename := fmt.Sprintf("pull_list.%s", r.Replace(RemoveProtocolPrefix(host))) pullListFile, err := os.Create(filename) if err != nil { loggerutil.FatalWithMessage(arvLogger,