aboutsummaryrefslogtreecommitdiff
path: root/weed
diff options
context:
space:
mode:
Diffstat (limited to 'weed')
-rw-r--r--weed/command/filer_copy.go35
-rw-r--r--weed/filer2/entry.go15
-rw-r--r--weed/filer2/entry_codec.go50
-rw-r--r--weed/pb/filer.proto3
-rw-r--r--weed/pb/filer_pb/filer.pb.go158
-rw-r--r--weed/server/filer_grpc_server.go42
-rw-r--r--weed/server/filer_server_handlers_write.go7
-rw-r--r--weed/server/filer_server_handlers_write_autochunk.go10
8 files changed, 179 insertions, 141 deletions
diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.go
index 6bc3d4119..3d4e5db9f 100644
--- a/weed/command/filer_copy.go
+++ b/weed/command/filer_copy.go
@@ -18,6 +18,7 @@ import (
"time"
"google.golang.org/grpc"
"context"
+ "github.com/chrislusf/seaweedfs/weed/util"
)
var (
@@ -212,13 +213,16 @@ func uploadFileAsOne(filerAddress, filerGrpcAddress string, urlFolder string, f
Entry: &filer_pb.Entry{
Name: fileName,
Attributes: &filer_pb.FuseAttributes{
- Crtime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Gid: uint32(os.Getgid()),
- Uid: uint32(os.Getuid()),
- FileSize: uint64(fi.Size()),
- FileMode: uint32(fi.Mode()),
- Mime: mimeType,
+ Crtime: time.Now().Unix(),
+ Mtime: time.Now().Unix(),
+ Gid: uint32(os.Getgid()),
+ Uid: uint32(os.Getuid()),
+ FileSize: uint64(fi.Size()),
+ FileMode: uint32(fi.Mode()),
+ Mime: mimeType,
+ Replication: *copy.replication,
+ Collection: *copy.collection,
+ TtlSec: int32(util.ParseInt(*copy.ttl, 0)),
},
Chunks: chunks,
},
@@ -285,13 +289,16 @@ func uploadFileInChunks(filerAddress, filerGrpcAddress string, urlFolder string,
Entry: &filer_pb.Entry{
Name: fileName,
Attributes: &filer_pb.FuseAttributes{
- Crtime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Gid: uint32(os.Getgid()),
- Uid: uint32(os.Getuid()),
- FileSize: uint64(fi.Size()),
- FileMode: uint32(fi.Mode()),
- Mime: mimeType,
+ Crtime: time.Now().Unix(),
+ Mtime: time.Now().Unix(),
+ Gid: uint32(os.Getgid()),
+ Uid: uint32(os.Getuid()),
+ FileSize: uint64(fi.Size()),
+ FileMode: uint32(fi.Mode()),
+ Mime: mimeType,
+ Replication: *copy.replication,
+ Collection: *copy.collection,
+ TtlSec: int32(util.ParseInt(*copy.ttl, 0)),
},
Chunks: chunks,
},
diff --git a/weed/filer2/entry.go b/weed/filer2/entry.go
index a2f8b91ef..82bc00b27 100644
--- a/weed/filer2/entry.go
+++ b/weed/filer2/entry.go
@@ -8,12 +8,15 @@ import (
)
type Attr struct {
- Mtime time.Time // time of last modification
- Crtime time.Time // time of creation (OS X only)
- Mode os.FileMode // file mode
- Uid uint32 // owner uid
- Gid uint32 // group gid
- Mime string
+ Mtime time.Time // time of last modification
+ Crtime time.Time // time of creation (OS X only)
+ Mode os.FileMode // file mode
+ Uid uint32 // owner uid
+ Gid uint32 // group gid
+ Mime string // mime type
+ Replication string // replication
+ Collection string // collection name
+ TtlSec int32 // ttl in seconds
}
func (attr Attr) IsDirectory() bool {
diff --git a/weed/filer2/entry_codec.go b/weed/filer2/entry_codec.go
index 7585203e9..671568b75 100644
--- a/weed/filer2/entry_codec.go
+++ b/weed/filer2/entry_codec.go
@@ -11,15 +11,8 @@ import (
func (entry *Entry) EncodeAttributesAndChunks() ([]byte, error) {
message := &filer_pb.Entry{
- Attributes: &filer_pb.FuseAttributes{
- Crtime: entry.Attr.Crtime.Unix(),
- Mtime: entry.Attr.Mtime.Unix(),
- FileMode: uint32(entry.Attr.Mode),
- Uid: entry.Uid,
- Gid: entry.Gid,
- Mime: entry.Mime,
- },
- Chunks: entry.Chunks,
+ Attributes: EntryAttributeToPb(entry),
+ Chunks: entry.Chunks,
}
return proto.Marshal(message)
}
@@ -32,14 +25,41 @@ func (entry *Entry) DecodeAttributesAndChunks(blob []byte) error {
return fmt.Errorf("decoding value blob for %s: %v", entry.FullPath, err)
}
- entry.Attr.Crtime = time.Unix(message.Attributes.Crtime, 0)
- entry.Attr.Mtime = time.Unix(message.Attributes.Mtime, 0)
- entry.Attr.Mode = os.FileMode(message.Attributes.FileMode)
- entry.Attr.Uid = message.Attributes.Uid
- entry.Attr.Gid = message.Attributes.Gid
- entry.Attr.Mime = message.Attributes.Mime
+ entry.Attr = PbToEntryAttribute(message.Attributes)
entry.Chunks = message.Chunks
return nil
}
+
+func EntryAttributeToPb(entry *Entry) *filer_pb.FuseAttributes {
+
+ return &filer_pb.FuseAttributes{
+ Crtime: entry.Attr.Crtime.Unix(),
+ Mtime: entry.Attr.Mtime.Unix(),
+ FileMode: uint32(entry.Attr.Mode),
+ Uid: entry.Uid,
+ Gid: entry.Gid,
+ Mime: entry.Mime,
+ Collection: entry.Attr.Collection,
+ Replication: entry.Attr.Replication,
+ TtlSec: entry.Attr.TtlSec,
+ }
+}
+
+func PbToEntryAttribute(attr *filer_pb.FuseAttributes) Attr {
+
+ t := Attr{}
+
+ t.Crtime = time.Unix(attr.Crtime, 0)
+ t.Mtime = time.Unix(attr.Mtime, 0)
+ t.Mode = os.FileMode(attr.FileMode)
+ t.Uid = attr.Uid
+ t.Gid = attr.Gid
+ t.Mime = attr.Mime
+ t.Collection = attr.Collection
+ t.Replication = attr.Replication
+ t.TtlSec = attr.TtlSec
+
+ return t
+}
diff --git a/weed/pb/filer.proto b/weed/pb/filer.proto
index ce8781178..d4329e5c7 100644
--- a/weed/pb/filer.proto
+++ b/weed/pb/filer.proto
@@ -73,6 +73,9 @@ message FuseAttributes {
uint32 gid = 5;
int64 crtime = 6;
string mime = 7;
+ string replication = 8;
+ string collection = 9;
+ int32 ttl_sec = 10;
}
message GetEntryAttributesRequest {
diff --git a/weed/pb/filer_pb/filer.pb.go b/weed/pb/filer_pb/filer.pb.go
index f2681a731..2eac69c4d 100644
--- a/weed/pb/filer_pb/filer.pb.go
+++ b/weed/pb/filer_pb/filer.pb.go
@@ -208,13 +208,16 @@ func (m *FileChunk) GetMtime() int64 {
}
type FuseAttributes struct {
- FileSize uint64 `protobuf:"varint,1,opt,name=file_size,json=fileSize" json:"file_size,omitempty"`
- Mtime int64 `protobuf:"varint,2,opt,name=mtime" json:"mtime,omitempty"`
- FileMode uint32 `protobuf:"varint,3,opt,name=file_mode,json=fileMode" json:"file_mode,omitempty"`
- Uid uint32 `protobuf:"varint,4,opt,name=uid" json:"uid,omitempty"`
- Gid uint32 `protobuf:"varint,5,opt,name=gid" json:"gid,omitempty"`
- Crtime int64 `protobuf:"varint,6,opt,name=crtime" json:"crtime,omitempty"`
- Mime string `protobuf:"bytes,7,opt,name=mime" json:"mime,omitempty"`
+ FileSize uint64 `protobuf:"varint,1,opt,name=file_size,json=fileSize" json:"file_size,omitempty"`
+ Mtime int64 `protobuf:"varint,2,opt,name=mtime" json:"mtime,omitempty"`
+ FileMode uint32 `protobuf:"varint,3,opt,name=file_mode,json=fileMode" json:"file_mode,omitempty"`
+ Uid uint32 `protobuf:"varint,4,opt,name=uid" json:"uid,omitempty"`
+ Gid uint32 `protobuf:"varint,5,opt,name=gid" json:"gid,omitempty"`
+ Crtime int64 `protobuf:"varint,6,opt,name=crtime" json:"crtime,omitempty"`
+ Mime string `protobuf:"bytes,7,opt,name=mime" json:"mime,omitempty"`
+ Replication string `protobuf:"bytes,8,opt,name=replication" json:"replication,omitempty"`
+ Collection string `protobuf:"bytes,9,opt,name=collection" json:"collection,omitempty"`
+ TtlSec int32 `protobuf:"varint,10,opt,name=ttl_sec,json=ttlSec" json:"ttl_sec,omitempty"`
}
func (m *FuseAttributes) Reset() { *m = FuseAttributes{} }
@@ -271,6 +274,27 @@ func (m *FuseAttributes) GetMime() string {
return ""
}
+func (m *FuseAttributes) GetReplication() string {
+ if m != nil {
+ return m.Replication
+ }
+ return ""
+}
+
+func (m *FuseAttributes) GetCollection() string {
+ if m != nil {
+ return m.Collection
+ }
+ return ""
+}
+
+func (m *FuseAttributes) GetTtlSec() int32 {
+ if m != nil {
+ return m.TtlSec
+ }
+ return 0
+}
+
type GetEntryAttributesRequest struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
ParentDir string `protobuf:"bytes,2,opt,name=parent_dir,json=parentDir" json:"parent_dir,omitempty"`
@@ -947,64 +971,66 @@ var _SeaweedFiler_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("filer.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
- // 931 bytes of a gzipped FileDescriptorProto
+ // 964 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x56, 0xdd, 0x6e, 0xdc, 0x44,
- 0x14, 0x8e, 0xd7, 0xd9, 0x4d, 0x7c, 0x76, 0x53, 0x60, 0x36, 0x2d, 0x66, 0x9b, 0x54, 0x61, 0x68,
- 0x51, 0x2b, 0xa4, 0x28, 0x0a, 0x5c, 0x54, 0x20, 0x24, 0xaa, 0xa6, 0x54, 0x95, 0x52, 0x55, 0x72,
- 0x09, 0x12, 0x57, 0x2b, 0xc7, 0x3e, 0x59, 0x46, 0xf1, 0x1f, 0x9e, 0x71, 0x50, 0xb8, 0xe5, 0x01,
- 0x78, 0x0a, 0xee, 0xb9, 0xe0, 0x0d, 0x78, 0x31, 0x34, 0x3f, 0xb6, 0xc7, 0xb1, 0xb7, 0x3f, 0x17,
- 0xbd, 0x9b, 0x39, 0x3f, 0xdf, 0xf9, 0xce, 0xcc, 0x99, 0xcf, 0x86, 0xe9, 0x05, 0x4b, 0xb0, 0x3c,
- 0x2c, 0xca, 0x5c, 0xe4, 0x64, 0x5b, 0x6d, 0x96, 0xc5, 0x39, 0x7d, 0x05, 0x77, 0x4f, 0xf3, 0xfc,
- 0xb2, 0x2a, 0x4e, 0x58, 0x89, 0x91, 0xc8, 0xcb, 0xeb, 0x67, 0x99, 0x28, 0xaf, 0x03, 0xfc, 0xad,
- 0x42, 0x2e, 0xc8, 0x1e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0x0b, 0xe4, 0xd1,
+ 0x3a, 0xfd, 0xce, 0xbf, 0x93, 0xe9, 0x97, 0x6f, 0x0b, 0x33, 0x63, 0xbd, 0x45, 0xce, 0x60, 0x64,
+ 0xfd, 0x1a, 0x90, 0x7d, 0x2b, 0xb1, 0xf5, 0x97, 0x31, 0x3d, 0xd8, 0xe0, 0xad, 0xd1, 0x42, 0x20,
+ 0x6d, 0x79, 0x26, 0x5f, 0xac, 0xd2, 0x36, 0x7e, 0x26, 0xa6, 0x0f, 0xdf, 0x1c, 0x64, 0x13, 0xb6,
+ 0xb4, 0xcb, 0x26, 0xdc, 0x56, 0x4b, 0x9b, 0x70, 0x97, 0xe0, 0x29, 0x34, 0x4b, 0x97, 0x6c, 0xb4,
+ 0xb6, 0x12, 0xda, 0x68, 0x5d, 0x62, 0xa6, 0xd0, 0x2c, 0xf1, 0xb0, 0xd1, 0xda, 0x22, 0x67, 0xa3,
+ 0x75, 0x29, 0xce, 0x16, 0x79, 0x0d, 0x63, 0x5b, 0x04, 0x88, 0x95, 0xd0, 0xa1, 0x45, 0xd3, 0x07,
+ 0x9b, 0xdc, 0x36, 0xa0, 0x3d, 0xf3, 0x36, 0x60, 0xc7, 0xd6, 0xdb, 0x80, 0x5d, 0xab, 0x42, 0xb7,
+ 0x2e, 0x07, 0xea, 0xa7, 0xf9, 0xeb, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x63, 0x17, 0x06, 0x1b,
+ 0x43, 0x0b, 0x00, 0x00,
}
diff --git a/weed/server/filer_grpc_server.go b/weed/server/filer_grpc_server.go
index 0510713ef..4271d342f 100644
--- a/weed/server/filer_grpc_server.go
+++ b/weed/server/filer_grpc_server.go
@@ -24,14 +24,8 @@ func (fs *FilerServer) LookupDirectoryEntry(ctx context.Context, req *filer_pb.L
Entry: &filer_pb.Entry{
Name: req.Name,
IsDirectory: entry.IsDirectory(),
- Attributes: &filer_pb.FuseAttributes{
- Mtime: entry.Attr.Mtime.Unix(),
- Crtime: entry.Attr.Crtime.Unix(),
- FileMode: uint32(entry.Attr.Mode),
- Uid: entry.Attr.Uid,
- Gid: entry.Attr.Gid,
- },
- Chunks: entry.Chunks,
+ Attributes: filer2.EntryAttributeToPb(entry),
+ Chunks: entry.Chunks,
},
}, nil
}
@@ -50,15 +44,7 @@ func (fs *FilerServer) ListEntries(ctx context.Context, req *filer_pb.ListEntrie
Name: entry.Name(),
IsDirectory: entry.IsDirectory(),
Chunks: entry.Chunks,
- Attributes: &filer_pb.FuseAttributes{
- FileSize: entry.Size(),
- Mtime: entry.Mtime.Unix(),
- Crtime: entry.Crtime.Unix(),
- Gid: entry.Gid,
- Uid: entry.Uid,
- FileMode: uint32(entry.Mode),
- Mime: entry.Mime,
- },
+ Attributes: filer2.EntryAttributeToPb(entry),
})
}
@@ -67,23 +53,14 @@ func (fs *FilerServer) ListEntries(ctx context.Context, req *filer_pb.ListEntrie
func (fs *FilerServer) GetEntryAttributes(ctx context.Context, req *filer_pb.GetEntryAttributesRequest) (*filer_pb.GetEntryAttributesResponse, error) {
- attributes := &filer_pb.FuseAttributes{}
-
fullpath := filer2.NewFullPath(req.ParentDir, req.Name)
entry, err := fs.filer.FindEntry(fullpath)
if err != nil {
- attributes.FileSize = 0
return nil, fmt.Errorf("FindEntry %s: %v", fullpath, err)
}
- attributes.FileSize = entry.Size()
- attributes.FileMode = uint32(entry.Mode)
- attributes.Uid = entry.Uid
- attributes.Gid = entry.Gid
- attributes.Mtime = entry.Mtime.Unix()
- attributes.Crtime = entry.Crtime.Unix()
- attributes.Mime = entry.Mime
+ attributes := filer2.EntryAttributeToPb(entry)
glog.V(3).Infof("GetEntryAttributes %v size %d chunks %d: %+v", fullpath, attributes.FileSize, len(entry.Chunks), attributes)
@@ -123,15 +100,8 @@ func (fs *FilerServer) LookupVolume(ctx context.Context, req *filer_pb.LookupVol
func (fs *FilerServer) CreateEntry(ctx context.Context, req *filer_pb.CreateEntryRequest) (resp *filer_pb.CreateEntryResponse, err error) {
err = fs.filer.CreateEntry(&filer2.Entry{
FullPath: filer2.FullPath(filepath.Join(req.Directory, req.Entry.Name)),
- Attr: filer2.Attr{
- Mtime: time.Unix(req.Entry.Attributes.Mtime, 0),
- Crtime: time.Unix(req.Entry.Attributes.Mtime, 0),
- Mode: os.FileMode(req.Entry.Attributes.FileMode),
- Uid: req.Entry.Attributes.Uid,
- Gid: req.Entry.Attributes.Gid,
- Mime: req.Entry.Attributes.Mime,
- },
- Chunks: req.Entry.Chunks,
+ Attr: filer2.PbToEntryAttribute(req.Entry.Attributes),
+ Chunks: req.Entry.Chunks,
})
if err == nil {
diff --git a/weed/server/filer_server_handlers_write.go b/weed/server/filer_server_handlers_write.go
index 38d5998d7..d46db6b73 100644
--- a/weed/server/filer_server_handlers_write.go
+++ b/weed/server/filer_server_handlers_write.go
@@ -167,7 +167,12 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
entry := &filer2.Entry{
FullPath: filer2.FullPath(path),
Attr: filer2.Attr{
- Mode: 0660,
+ Mtime: time.Now(),
+ Crtime: time.Now(),
+ Mode: 0660,
+ Replication: replication,
+ Collection: collection,
+ TtlSec: int32(util.ParseInt(r.URL.Query().Get("ttl"), 0)),
},
Chunks: []*filer_pb.FileChunk{{
FileId: fileId,
diff --git a/weed/server/filer_server_handlers_write_autochunk.go b/weed/server/filer_server_handlers_write_autochunk.go
index adc50d030..9aac50454 100644
--- a/weed/server/filer_server_handlers_write_autochunk.go
+++ b/weed/server/filer_server_handlers_write_autochunk.go
@@ -13,6 +13,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ "github.com/chrislusf/seaweedfs/weed/util"
)
func (fs *FilerServer) autoChunk(w http.ResponseWriter, r *http.Request, replication string, collection string) bool {
@@ -158,9 +159,12 @@ func (fs *FilerServer) doAutoChunk(w http.ResponseWriter, r *http.Request, conte
entry := &filer2.Entry{
FullPath: filer2.FullPath(path),
Attr: filer2.Attr{
- Mtime: time.Now(),
- Crtime: time.Now(),
- Mode: 0660,
+ Mtime: time.Now(),
+ Crtime: time.Now(),
+ Mode: 0660,
+ Replication: replication,
+ Collection: collection,
+ TtlSec: int32(util.ParseInt(r.URL.Query().Get("ttl"), 0)),
},
Chunks: fileChunks,
}