mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
filer.meta.tail: support untilTimeAgo for a range
This commit is contained in:
parent
f214dfb1f5
commit
968ca95b49
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue