| Index: appengine/logdog/coordinator/logStream.go
|
| diff --git a/appengine/logdog/coordinator/logStream.go b/appengine/logdog/coordinator/logStream.go
|
| index 4285bd3e4f25dd4708d0e45025d41964cb9ca775..212bb3b55db5dd7de6cf94da54b763fd287330e6 100644
|
| --- a/appengine/logdog/coordinator/logStream.go
|
| +++ b/appengine/logdog/coordinator/logStream.go
|
| @@ -32,6 +32,27 @@ const (
|
| LSArchived
|
| )
|
|
|
| +// ArchiveState is the state of archival. It is valid on log streams whose
|
| +// log stream state is LSArchived.
|
| +type ArchiveState int
|
| +
|
| +const (
|
| + // NotArchived is the default archive state, indicating that the log stream is
|
| + // not archived.
|
| + NotArchived ArchiveState = iota
|
| + // Archived indicates that the log stream was archived completely and
|
| + // successfully.
|
| + Archived
|
| + // ArchivedPartially indicates that the log stream has been archived, but that
|
| + // there are missing log stream entries. This will happen when the stream has
|
| + // exceeded an archival threshold without all of its log entries available
|
| + // in intermediate storage.
|
| + ArchivedPartially
|
| + // ArchivedWithErrors indicates that the log stream is in an archived state,
|
| + // but that there were errors. Archive files may be present in any state.
|
| + ArchivedWithErrors
|
| +)
|
| +
|
| // LogStream is the primary datastore model containing information and state of
|
| // an individual log stream.
|
| //
|
| @@ -65,6 +86,10 @@ const (
|
| // changed through service endpoint methods.
|
| //
|
| // LogStream's QueryBase is authortative.
|
| +//
|
| +// TODO(dnj): Migration schema checklist. Next migration, we will want to...
|
| +// - Add schema version.
|
| +// - Remove State, ArchiveWhole in favor of "_Terminated" and "ArchiveState".
|
| type LogStream struct {
|
| // Prefix is this log stream's prefix value. Log streams with the same prefix
|
| // are logically grouped.
|
| @@ -114,7 +139,12 @@ type LogStream struct {
|
| Source []string
|
|
|
| // TerminalIndex is the log stream index of the last log entry in the stream.
|
| - // If the value is -1, the log is still streaming.
|
| + //
|
| + // When the value is <0:
|
| + // - If the log is not archived, this means that the stream is still
|
| + // streaming without a known terminal index.
|
| + // - If the log is archived, it means that the stream's archival has
|
| + // completed, but had no log entries.
|
| TerminalIndex int64 `gae:",noindex"`
|
|
|
| // ArchiveIndexURL is the Google Storage URL where the log stream's index is
|
| @@ -139,7 +169,17 @@ type LogStream struct {
|
| ArchiveDataSize int64 `gae:",noindex"`
|
| // ArchiveWhole is true if archival is complete and the archived log stream
|
| // was not missing any entries.
|
| + //
|
| + // TODO(dnj): Next migration, deprecate this in favor of ArchiveState. For
|
| + // now, we will parallel it.
|
| ArchiveWhole bool
|
| + // ArchiveState is the state of log stream archival.
|
| + ArchiveState ArchiveState
|
| + // ArchiveErrors is the number of errors encountered during archival. This
|
| + // will be incremented when incomplete archival is permitted, but the archival
|
| + // still failed due to an error (e.g., data corruption). If this exceeds a
|
| + // threshold, the stream may be marked archived even if the archival failed.
|
| + ArchiveErrors int
|
|
|
| // _ causes datastore to ignore unrecognized fields and strip them in future
|
| // writes.
|
| @@ -353,10 +393,15 @@ func (s *LogStream) Terminated() bool {
|
| return s.State >= LSTerminated
|
| }
|
|
|
| -// Archived returns true if this stream has been archived. A stream is archived
|
| -// if it has any of its archival properties set.
|
| +// Streaming returns true if this log stream is still streaming without a known
|
| +// terminal index.
|
| +func (s *LogStream) Streaming() bool {
|
| + return (s.State == LSPending && s.TerminalIndex < 0)
|
| +}
|
| +
|
| +// Archived returns true if this stream has been archived.
|
| func (s *LogStream) Archived() bool {
|
| - return s.State >= LSArchived
|
| + return (s.ArchiveState != NotArchived) || (s.State >= LSArchived)
|
| }
|
|
|
| // ArchiveMatches tests if the supplied Stream, Index, and Data archival URLs
|
|
|