aboutsummaryrefslogtreecommitdiff
path: root/weed
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-05-30 16:16:23 -0700
committerchrislu <chris.lu@gmail.com>2022-05-30 16:16:23 -0700
commit968ca95b49525fa2be1009163df5a2c1c81fb96c (patch)
treeb630095971beac2019a4723b4602d1d42f263f41 /weed
parentf214dfb1f5ccfecfedd8a5d3b513508e27388467 (diff)
downloadseaweedfs-968ca95b49525fa2be1009163df5a2c1c81fb96c.tar.xz
seaweedfs-968ca95b49525fa2be1009163df5a2c1c81fb96c.zip
filer.meta.tail: support untilTimeAgo for a range
Diffstat (limited to 'weed')
-rw-r--r--weed/command/filer_meta_tail.go8
-rw-r--r--weed/util/log_buffer/log_read.go4
2 files changed, 11 insertions, 1 deletions
diff --git a/weed/command/filer_meta_tail.go b/weed/command/filer_meta_tail.go
index dd6c1df24..c99fdc02a 100644
--- a/weed/command/filer_meta_tail.go
+++ b/weed/command/filer_meta_tail.go
@@ -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
}
diff --git a/weed/util/log_buffer/log_read.go b/weed/util/log_buffer/log_read.go
index 36854cb74..99532b47b 100644
--- a/weed/util/log_buffer/log_read.go
+++ b/weed/util/log_buffer/log_read.go
@@ -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 {