mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactoring, go fmt
This commit is contained in:
parent
19728fe3f6
commit
7a14cdc90c
|
@ -1,6 +1,7 @@
|
|||
package weed_server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||
"io"
|
||||
|
@ -34,6 +35,19 @@ func (vs *VolumeServer) VolumeFollow(req *volume_server_pb.VolumeFollowRequest,
|
|||
|
||||
}
|
||||
|
||||
func (vs *VolumeServer) VolumeSyncStatus(ctx context.Context, req *volume_server_pb.VolumeSyncStatusRequest) (*volume_server_pb.VolumeSyncStatusResponse, error) {
|
||||
|
||||
v := vs.store.GetVolume(storage.VolumeId(req.VolumeId))
|
||||
if v == nil {
|
||||
return nil, fmt.Errorf("not found volume id %d", req.VolumeId)
|
||||
}
|
||||
|
||||
resp := v.GetVolumeSyncStatus()
|
||||
|
||||
return resp, nil
|
||||
|
||||
}
|
||||
|
||||
func sendFileContent(datFile *os.File, buf []byte, startOffset, stopOffset int64, stream volume_server_pb.VolumeServer_VolumeFollowServer) error {
|
||||
var blockSizeLimit = int64(len(buf))
|
||||
for i := int64(0); i < stopOffset-startOffset; i += blockSizeLimit {
|
||||
|
|
|
@ -113,7 +113,7 @@ func (vs *VolumeServer) ReadVolumeFileStatus(ctx context.Context, req *volume_se
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
func (vs *VolumeServer) CopyFile(req *volume_server_pb.CopyFileRequest, stream volume_server_pb.VolumeServer_CopyFileServer) (error) {
|
||||
func (vs *VolumeServer) CopyFile(req *volume_server_pb.CopyFileRequest, stream volume_server_pb.VolumeServer_CopyFileServer) error {
|
||||
|
||||
v := vs.store.GetVolume(storage.VolumeId(req.VolumeId))
|
||||
if v == nil {
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package weed_server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage"
|
||||
)
|
||||
|
||||
func (vs *VolumeServer) VolumeSyncStatus(ctx context.Context, req *volume_server_pb.VolumeSyncStatusRequest) (*volume_server_pb.VolumeSyncStatusResponse, error) {
|
||||
|
||||
v := vs.store.GetVolume(storage.VolumeId(req.VolumeId))
|
||||
if v == nil {
|
||||
return nil, fmt.Errorf("not found volume id %d", req.VolumeId)
|
||||
}
|
||||
|
||||
resp := v.GetVolumeSyncStatus()
|
||||
|
||||
glog.V(2).Infof("volume sync status %d", req.VolumeId)
|
||||
|
||||
return resp, nil
|
||||
|
||||
}
|
|
@ -11,6 +11,19 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
func (v *Volume) GetVolumeSyncStatus() *volume_server_pb.VolumeSyncStatusResponse {
|
||||
var syncStatus = &volume_server_pb.VolumeSyncStatusResponse{}
|
||||
if stat, err := v.dataFile.Stat(); err == nil {
|
||||
syncStatus.TailOffset = uint64(stat.Size())
|
||||
}
|
||||
syncStatus.Collection = v.Collection
|
||||
syncStatus.IdxFileSize = v.nm.IndexFileSize()
|
||||
syncStatus.CompactRevision = uint32(v.SuperBlock.CompactRevision)
|
||||
syncStatus.Ttl = v.SuperBlock.Ttl.String()
|
||||
syncStatus.Replication = v.SuperBlock.ReplicaPlacement.String()
|
||||
return syncStatus
|
||||
}
|
||||
|
||||
// The volume sync with a master volume via 2 steps:
|
||||
// 1. The slave checks master side to find subscription checkpoint
|
||||
// to setup the replication.
|
||||
|
@ -41,7 +54,7 @@ update needle map when receiving new .dat bytes. But seems not necessary now.)
|
|||
|
||||
*/
|
||||
|
||||
func (v *Volume) Follow(volumeServer string, grpcDialOption grpc.DialOption) (error) {
|
||||
func (v *Volume) Follow(volumeServer string, grpcDialOption grpc.DialOption) error {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
||||
)
|
||||
|
||||
func (v *Volume) GetVolumeSyncStatus() *volume_server_pb.VolumeSyncStatusResponse {
|
||||
var syncStatus = &volume_server_pb.VolumeSyncStatusResponse{}
|
||||
if stat, err := v.dataFile.Stat(); err == nil {
|
||||
syncStatus.TailOffset = uint64(stat.Size())
|
||||
}
|
||||
syncStatus.Collection = v.Collection
|
||||
syncStatus.IdxFileSize = v.nm.IndexFileSize()
|
||||
syncStatus.CompactRevision = uint32(v.SuperBlock.CompactRevision)
|
||||
syncStatus.Ttl = v.SuperBlock.Ttl.String()
|
||||
syncStatus.Replication = v.SuperBlock.ReplicaPlacement.String()
|
||||
return syncStatus
|
||||
}
|
Loading…
Reference in a new issue