1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-05-30 23:30:18 +02:00

filer.meta.tail: support untilTimeAgo for a range

This commit is contained in:
chrislu 2022-05-30 16:16:23 -07:00
parent f214dfb1f5
commit 968ca95b49
2 changed files with 11 additions and 1 deletions

View file

@ -36,6 +36,7 @@ var (
tailFiler = cmdFilerMetaTail.Flag.String("filer", "localhost:8888", "filer hostname:port")
tailTarget = cmdFilerMetaTail.Flag.String("pathPrefix", "/", "path to a folder or common prefix for the folders or files on filer")
tailStart = cmdFilerMetaTail.Flag.Duration("timeAgo", 0, "start time before now. \"300ms\", \"1.5h\" or \"2h45m\". Valid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\"")
tailStop = cmdFilerMetaTail.Flag.Duration("untilTimeAgo", 0, "read until this time ago. \"300ms\", \"1.5h\" or \"2h45m\". Valid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\"")
tailPattern = cmdFilerMetaTail.Flag.String("pattern", "", "full path or just filename pattern, ex: \"/home/?opher\", \"*.pdf\", see https://golang.org/pkg/path/filepath/#Match ")
esServers = cmdFilerMetaTail.Flag.String("es", "", "comma-separated elastic servers http://<host:port>")
esIndex = cmdFilerMetaTail.Flag.String("es.index", "seaweedfs", "ES index name")
@ -103,8 +104,13 @@ func runFilerMetaTail(cmd *Command, args []string) bool {
}
}
var untilTsNs int64
if *tailStop != 0 {
untilTsNs = time.Now().Add(-*tailStop).UnixNano()
}
tailErr := pb.FollowMetadata(pb.ServerAddress(*tailFiler), grpcDialOption, "tail", clientId, *tailTarget, nil,
time.Now().Add(-*tailStart).UnixNano(), 0, 0, func(resp *filer_pb.SubscribeMetadataResponse) error {
time.Now().Add(-*tailStart).UnixNano(), untilTsNs, 0, func(resp *filer_pb.SubscribeMetadataResponse) error {
if !shouldPrint(resp) {
return nil
}

View file

@ -40,6 +40,10 @@ func (logBuffer *LogBuffer) LoopProcessLogData(readerName string, startReadTime
}
// glog.V(4).Infof("%s ReadFromBuffer by %v", readerName, lastReadTime)
if bytesBuf == nil {
if stopTsNs != 0 {
isDone = true
return
}
if waitForDataFn() {
continue
} else {