Chris Lu
6 years ago
47 changed files with 337 additions and 225 deletions
-
8unmaintained/repeated_vacuum/repeated_vacuum.go
-
3unmaintained/volume_tailer/volume_tailer.go
-
4weed/command/backup.go
-
8weed/command/benchmark.go
-
7weed/command/filer.go
-
18weed/command/filer_copy.go
-
8weed/command/filer_replication.go
-
14weed/command/master.go
-
3weed/command/mount_std.go
-
9weed/command/s3.go
-
23weed/command/scaffold.go
-
10weed/command/server.go
-
4weed/command/shell.go
-
9weed/command/upload.go
-
7weed/command/volume.go
-
2weed/command/webdav.go
-
41weed/filer2/stream.go
-
33weed/server/filer_server.go
-
34weed/server/filer_server_handlers_read.go
-
2weed/server/master_grpc_server.go
-
67weed/server/master_server.go
-
6weed/shell/command_collection_delete.go
-
8weed/shell/command_collection_list.go
-
16weed/shell/command_ec_balance.go
-
6weed/shell/command_ec_common.go
-
14weed/shell/command_ec_encode.go
-
10weed/shell/command_ec_rebuild.go
-
7weed/shell/command_fs_cat.go
-
4weed/shell/command_fs_cd.go
-
6weed/shell/command_fs_du.go
-
4weed/shell/command_fs_ls.go
-
4weed/shell/command_fs_meta_load.go
-
8weed/shell/command_fs_meta_notify.go
-
4weed/shell/command_fs_meta_save.go
-
4weed/shell/command_fs_pwd.go
-
4weed/shell/command_fs_tree.go
-
12weed/shell/command_volume_balance.go
-
4weed/shell/command_volume_copy.go
-
4weed/shell/command_volume_delete.go
-
6weed/shell/command_volume_fix_replication.go
-
6weed/shell/command_volume_list.go
-
4weed/shell/command_volume_mount.go
-
4weed/shell/command_volume_move.go
-
4weed/shell/command_volume_unmount.go
-
33weed/shell/commands.go
-
32weed/shell/shell_liner.go
-
34weed/util/config.go
@ -0,0 +1,41 @@ |
|||
package filer2 |
|||
|
|||
import ( |
|||
"io" |
|||
|
|||
"github.com/chrislusf/seaweedfs/weed/glog" |
|||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" |
|||
"github.com/chrislusf/seaweedfs/weed/util" |
|||
"github.com/chrislusf/seaweedfs/weed/wdclient" |
|||
) |
|||
|
|||
func StreamContent(masterClient *wdclient.MasterClient, w io.Writer, chunks []*filer_pb.FileChunk, offset int64, size int) error { |
|||
|
|||
chunkViews := ViewFromChunks(chunks, offset, size) |
|||
|
|||
fileId2Url := make(map[string]string) |
|||
|
|||
for _, chunkView := range chunkViews { |
|||
|
|||
urlString, err := masterClient.LookupFileId(chunkView.FileId) |
|||
if err != nil { |
|||
glog.V(1).Infof("operation LookupFileId %s failed, err: %v", chunkView.FileId, err) |
|||
return err |
|||
} |
|||
fileId2Url[chunkView.FileId] = urlString |
|||
} |
|||
|
|||
for _, chunkView := range chunkViews { |
|||
urlString := fileId2Url[chunkView.FileId] |
|||
_, err := util.ReadUrlAsStream(urlString, chunkView.Offset, int(chunkView.Size), func(data []byte) { |
|||
w.Write(data) |
|||
}) |
|||
if err != nil { |
|||
glog.V(1).Infof("read %s failed, err: %v", chunkView.FileId, err) |
|||
return err |
|||
} |
|||
} |
|||
|
|||
return nil |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue