add optional delay

This commit is contained in:
Chris Lu 2021-09-11 02:21:55 -07:00
parent a243d7e047
commit 67949e25e9

View File

@ -12,10 +12,11 @@ import (
)
var (
dir = flag.String("dir", "/tmp", "directory to create files")
n = flag.Int("n", 100, "the number of metadata")
tailFiler = flag.String("filer", "localhost:8888", "the filer address")
isWrite = flag.Bool("write", false, "only write")
dir = flag.String("dir", "/tmp", "directory to create files")
n = flag.Int("n", 100, "the number of metadata")
tailFiler = flag.String("filer", "localhost:8888", "the filer address")
isWrite = flag.Bool("write", false, "only write")
writeInterval = flag.Duration("writeInterval", 0, "write interval, e.g., 1s")
)
func main() {
@ -54,6 +55,7 @@ func startGenerateMetadata() {
for i := 0; i < *n; i++ {
name := fmt.Sprintf("file%d", i)
glog.V(0).Infof("write %s/%s", *dir, name)
if err := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{
Directory: *dir,
Entry: &filer_pb.Entry{
@ -63,6 +65,9 @@ func startGenerateMetadata() {
fmt.Printf("create entry %s: %v\n", name, err)
return err
}
if *writeInterval > 0 {
time.Sleep(*writeInterval)
}
}
return nil