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

Side by Side Diff: appengine/logdog/coordinator/logStream.go

Issue 1853433002: LogDog: Handle archive failures. (Closed) Base URL: https://github.com/luci/luci-go@logdog-gs-update
Patch Set: Created 4 years, 8 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package coordinator 5 package coordinator
6 6
7 import ( 7 import (
8 "crypto/sha256" 8 "crypto/sha256"
9 "encoding/hex" 9 "encoding/hex"
10 "errors" 10 "errors"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // can be queried against. 107 // can be queried against.
108 // 108 //
109 // The serialization/deserialization is handled manually in order to ena ble 109 // The serialization/deserialization is handled manually in order to ena ble
110 // key/value queries. 110 // key/value queries.
111 Tags TagMap `gae:"-"` 111 Tags TagMap `gae:"-"`
112 112
113 // Source is the set of source strings sent by the Butler. 113 // Source is the set of source strings sent by the Butler.
114 Source []string 114 Source []string
115 115
116 // TerminalIndex is the log stream index of the last log entry in the st ream. 116 // TerminalIndex is the log stream index of the last log entry in the st ream.
117 » // If the value is -1, the log is still streaming. 117 » //
118 » // If the value is <0:
Vadim Sh. 2016/03/31 22:29:59 typo: "If" is not needed here
dnj 2016/04/01 22:57:04 Acknowledged.
119 » //» - If the log is in the LSPending state, the stream is still stre aming
120 » //» without a known terminal index.
121 » //» - If the log is in LSArchived state, it means that the stream's archival
122 » //» has completed, but had no log entries.
118 TerminalIndex int64 `gae:",noindex"` 123 TerminalIndex int64 `gae:",noindex"`
119 124
120 // ArchiveIndexURL is the Google Storage URL where the log stream's inde x is 125 // ArchiveIndexURL is the Google Storage URL where the log stream's inde x is
121 // archived. 126 // archived.
122 ArchiveIndexURL string `gae:",noindex"` 127 ArchiveIndexURL string `gae:",noindex"`
123 // ArchiveIndexSize is the size, in bytes, of the archived Index. It wil l be 128 // ArchiveIndexSize is the size, in bytes, of the archived Index. It wil l be
124 // zero if the file is not archived. 129 // zero if the file is not archived.
125 ArchiveIndexSize int64 `gae:",noindex"` 130 ArchiveIndexSize int64 `gae:",noindex"`
126 // ArchiveStreamURL is the Google Storage URL where the log stream's raw 131 // ArchiveStreamURL is the Google Storage URL where the log stream's raw
127 // stream data is archived. If this is not empty, the log stream is cons idered 132 // stream data is archived. If this is not empty, the log stream is cons idered
128 // archived. 133 // archived.
129 ArchiveStreamURL string `gae:",noindex"` 134 ArchiveStreamURL string `gae:",noindex"`
130 // ArchiveStreamSize is the size, in bytes, of the archived stream. It w ill be 135 // ArchiveStreamSize is the size, in bytes, of the archived stream. It w ill be
131 // zero if the file is not archived. 136 // zero if the file is not archived.
132 ArchiveStreamSize int64 `gae:",noindex"` 137 ArchiveStreamSize int64 `gae:",noindex"`
133 // ArchiveDataURL is the Google Storage URL where the log stream's assem bled 138 // ArchiveDataURL is the Google Storage URL where the log stream's assem bled
134 // data is archived. If this is not empty, the log stream is considered 139 // data is archived. If this is not empty, the log stream is considered
135 // archived. 140 // archived.
136 ArchiveDataURL string `gae:",noindex"` 141 ArchiveDataURL string `gae:",noindex"`
137 // ArchiveDataSize is the size, in bytes, of the archived data. It will be 142 // ArchiveDataSize is the size, in bytes, of the archived data. It will be
138 // zero if the file is not archived. 143 // zero if the file is not archived.
139 ArchiveDataSize int64 `gae:",noindex"` 144 ArchiveDataSize int64 `gae:",noindex"`
140 // ArchiveWhole is true if archival is complete and the archived log str eam 145 // ArchiveWhole is true if archival is complete and the archived log str eam
141 // was not missing any entries. 146 // was not missing any entries.
142 ArchiveWhole bool 147 ArchiveWhole bool
148 // ArchiveErrors is the number of errors encountered during archival. Th is
149 // will be incremented when incomplete archival is permitted, but the ar chival
150 // still failed due to an error (e.g., data corruption). If this exceeds a
151 // threshold, the stream may be marked archived even if the archival fai led.
152 ArchiveErrors int
143 153
144 // _ causes datastore to ignore unrecognized fields and strip them in fu ture 154 // _ causes datastore to ignore unrecognized fields and strip them in fu ture
145 // writes. 155 // writes.
146 _ ds.PropertyMap `gae:"-,extra"` 156 _ ds.PropertyMap `gae:"-,extra"`
147 157
148 // hashID is the cached generated ID from the stream's Prefix/Name field s. If 158 // hashID is the cached generated ID from the stream's Prefix/Name field s. If
149 // this is populated, ID metadata will be retrieved from this field inst ead of 159 // this is populated, ID metadata will be retrieved from this field inst ead of
150 // generated. 160 // generated.
151 hashID string 161 hashID string
152 } 162 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 return nil, err 356 return nil, err
347 } 357 }
348 return &pb, nil 358 return &pb, nil
349 } 359 }
350 360
351 // Terminated returns true if this stream has been terminated. 361 // Terminated returns true if this stream has been terminated.
352 func (s *LogStream) Terminated() bool { 362 func (s *LogStream) Terminated() bool {
353 return s.State >= LSTerminated 363 return s.State >= LSTerminated
354 } 364 }
355 365
366 // Streaming returns true if this log stream is still streaming without a known
367 // terminal index.
368 func (s *LogStream) Streaming() bool {
369 return (s.State == LSPending && s.TerminalIndex < 0)
370 }
371
356 // Archived returns true if this stream has been archived. A stream is archived 372 // Archived returns true if this stream has been archived. A stream is archived
357 // if it has any of its archival properties set. 373 // if it has any of its archival properties set.
358 func (s *LogStream) Archived() bool { 374 func (s *LogStream) Archived() bool {
359 return s.State >= LSArchived 375 return s.State >= LSArchived
360 } 376 }
361 377
362 // ArchiveMatches tests if the supplied Stream, Index, and Data archival URLs 378 // ArchiveMatches tests if the supplied Stream, Index, and Data archival URLs
363 // match the current values. 379 // match the current values.
364 func (s *LogStream) ArchiveMatches(sURL, iURL, dURL string) bool { 380 func (s *LogStream) ArchiveMatches(sURL, iURL, dURL string) bool {
365 return (s.ArchiveStreamURL == sURL && s.ArchiveIndexURL == iURL && s.Arc hiveDataURL == dURL) 381 return (s.ArchiveStreamURL == sURL && s.ArchiveIndexURL == iURL && s.Arc hiveDataURL == dURL)
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // were created before the supplied time. 590 // were created before the supplied time.
575 func AddOlderFilter(q *ds.Query, t time.Time) *ds.Query { 591 func AddOlderFilter(q *ds.Query, t time.Time) *ds.Query {
576 return q.Lt("Created", t.UTC()).Order("-Created") 592 return q.Lt("Created", t.UTC()).Order("-Created")
577 } 593 }
578 594
579 // AddNewerFilter adds a filter to queries that restricts them to results that 595 // AddNewerFilter adds a filter to queries that restricts them to results that
580 // were created after the supplied time. 596 // were created after the supplied time.
581 func AddNewerFilter(q *ds.Query, t time.Time) *ds.Query { 597 func AddNewerFilter(q *ds.Query, t time.Time) *ds.Query {
582 return q.Gt("Created", t.UTC()).Order("-Created") 598 return q.Gt("Created", t.UTC()).Order("-Created")
583 } 599 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698