From 568132c0c9d91b3611d658ca4f8f0361c7d52ebe Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 20 Jul 2018 00:10:01 -0700 Subject: [PATCH] delete bucket also removes collection data --- weed/pb/filer.proto | 10 ++ weed/pb/filer_pb/filer.pb.go | 192 ++++++++++++++++++---------- weed/s3api/s3api_bucket_handlers.go | 19 ++- weed/server/filer_grpc_server.go | 10 ++ 4 files changed, 163 insertions(+), 68 deletions(-) diff --git a/weed/pb/filer.proto b/weed/pb/filer.proto index 50afcd03a..a01ee7a2e 100644 --- a/weed/pb/filer.proto +++ b/weed/pb/filer.proto @@ -30,6 +30,9 @@ service SeaweedFiler { rpc LookupVolume (LookupVolumeRequest) returns (LookupVolumeResponse) { } + rpc DeleteCollection (DeleteCollectionRequest) returns (DeleteCollectionResponse) { + } + } ////////////////////////////////////////////////// @@ -153,3 +156,10 @@ message Location { message LookupVolumeResponse { map locations_map = 1; } + +message DeleteCollectionRequest { + string collection = 1; +} + +message DeleteCollectionResponse { +} diff --git a/weed/pb/filer_pb/filer.pb.go b/weed/pb/filer_pb/filer.pb.go index 0a451a9ec..d7f279a17 100644 --- a/weed/pb/filer_pb/filer.pb.go +++ b/weed/pb/filer_pb/filer.pb.go @@ -32,6 +32,8 @@ It has these top-level messages: Locations Location LookupVolumeResponse + DeleteCollectionRequest + DeleteCollectionResponse */ package filer_pb @@ -663,6 +665,30 @@ func (m *LookupVolumeResponse) GetLocationsMap() map[string]*Locations { return nil } +type DeleteCollectionRequest struct { + Collection string `protobuf:"bytes,1,opt,name=collection" json:"collection,omitempty"` +} + +func (m *DeleteCollectionRequest) Reset() { *m = DeleteCollectionRequest{} } +func (m *DeleteCollectionRequest) String() string { return proto.CompactTextString(m) } +func (*DeleteCollectionRequest) ProtoMessage() {} +func (*DeleteCollectionRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{23} } + +func (m *DeleteCollectionRequest) GetCollection() string { + if m != nil { + return m.Collection + } + return "" +} + +type DeleteCollectionResponse struct { +} + +func (m *DeleteCollectionResponse) Reset() { *m = DeleteCollectionResponse{} } +func (m *DeleteCollectionResponse) String() string { return proto.CompactTextString(m) } +func (*DeleteCollectionResponse) ProtoMessage() {} +func (*DeleteCollectionResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{24} } + func init() { proto.RegisterType((*LookupDirectoryEntryRequest)(nil), "filer_pb.LookupDirectoryEntryRequest") proto.RegisterType((*LookupDirectoryEntryResponse)(nil), "filer_pb.LookupDirectoryEntryResponse") @@ -687,6 +713,8 @@ func init() { proto.RegisterType((*Locations)(nil), "filer_pb.Locations") proto.RegisterType((*Location)(nil), "filer_pb.Location") proto.RegisterType((*LookupVolumeResponse)(nil), "filer_pb.LookupVolumeResponse") + proto.RegisterType((*DeleteCollectionRequest)(nil), "filer_pb.DeleteCollectionRequest") + proto.RegisterType((*DeleteCollectionResponse)(nil), "filer_pb.DeleteCollectionResponse") } // Reference imports to suppress errors if they are not otherwise used. @@ -708,6 +736,7 @@ type SeaweedFilerClient interface { DeleteEntry(ctx context.Context, in *DeleteEntryRequest, opts ...grpc.CallOption) (*DeleteEntryResponse, error) AssignVolume(ctx context.Context, in *AssignVolumeRequest, opts ...grpc.CallOption) (*AssignVolumeResponse, error) LookupVolume(ctx context.Context, in *LookupVolumeRequest, opts ...grpc.CallOption) (*LookupVolumeResponse, error) + DeleteCollection(ctx context.Context, in *DeleteCollectionRequest, opts ...grpc.CallOption) (*DeleteCollectionResponse, error) } type seaweedFilerClient struct { @@ -790,6 +819,15 @@ func (c *seaweedFilerClient) LookupVolume(ctx context.Context, in *LookupVolumeR return out, nil } +func (c *seaweedFilerClient) DeleteCollection(ctx context.Context, in *DeleteCollectionRequest, opts ...grpc.CallOption) (*DeleteCollectionResponse, error) { + out := new(DeleteCollectionResponse) + err := grpc.Invoke(ctx, "/filer_pb.SeaweedFiler/DeleteCollection", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // Server API for SeaweedFiler service type SeaweedFilerServer interface { @@ -801,6 +839,7 @@ type SeaweedFilerServer interface { DeleteEntry(context.Context, *DeleteEntryRequest) (*DeleteEntryResponse, error) AssignVolume(context.Context, *AssignVolumeRequest) (*AssignVolumeResponse, error) LookupVolume(context.Context, *LookupVolumeRequest) (*LookupVolumeResponse, error) + DeleteCollection(context.Context, *DeleteCollectionRequest) (*DeleteCollectionResponse, error) } func RegisterSeaweedFilerServer(s *grpc.Server, srv SeaweedFilerServer) { @@ -951,6 +990,24 @@ func _SeaweedFiler_LookupVolume_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _SeaweedFiler_DeleteCollection_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteCollectionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SeaweedFilerServer).DeleteCollection(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/filer_pb.SeaweedFiler/DeleteCollection", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SeaweedFilerServer).DeleteCollection(ctx, req.(*DeleteCollectionRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _SeaweedFiler_serviceDesc = grpc.ServiceDesc{ ServiceName: "filer_pb.SeaweedFiler", HandlerType: (*SeaweedFilerServer)(nil), @@ -987,6 +1044,10 @@ var _SeaweedFiler_serviceDesc = grpc.ServiceDesc{ MethodName: "LookupVolume", Handler: _SeaweedFiler_LookupVolume_Handler, }, + { + MethodName: "DeleteCollection", + Handler: _SeaweedFiler_DeleteCollection_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "filer.proto", @@ -995,68 +1056,71 @@ var _SeaweedFiler_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("filer.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 1004 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x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43, 0x3a, 0xaf, 0xf5, 0x90, 0xbb, 0x30, 0xae, - 0x41, 0x6b, 0x2e, 0xb2, 0xe2, 0xc5, 0x32, 0x7e, 0x5f, 0x15, 0x6b, 0xd0, 0xa6, 0xe2, 0x3f, 0x0e, - 0x90, 0x53, 0x4c, 0xf0, 0x9d, 0x4a, 0xb6, 0x98, 0x6b, 0xc3, 0x81, 0xdc, 0xa6, 0x03, 0x3d, 0x84, - 0x3b, 0x32, 0x45, 0x55, 0x9b, 0xc5, 0xa1, 0x08, 0xd5, 0x68, 0x0d, 0xe8, 0x88, 0x71, 0x4d, 0xe1, - 0x34, 0x14, 0xa1, 0x01, 0xca, 0x31, 0x2a, 0x72, 0xce, 0x6e, 0x50, 0x0d, 0x9b, 0x02, 0xa2, 0x65, - 0x48, 0x6a, 0xa9, 0x71, 0x36, 0x5a, 0xfe, 0x76, 0x60, 0xfc, 0x94, 0x73, 0x36, 0x4f, 0x7f, 0xca, - 0x92, 0x62, 0x81, 0xa5, 0x98, 0x5d, 0xe8, 0x45, 0x59, 0x61, 0xde, 0x6f, 0x8f, 0xea, 0xcd, 0xda, - 0xac, 0x75, 0x1a, 0xb3, 0xb6, 0x36, 0xad, 0x6e, 0x73, 0x5a, 0xad, 0x69, 0xec, 0xda, 0xd3, 0x48, - 0x3e, 0x85, 0xa1, 0x94, 0x37, 0x8b, 0x30, 0x15, 0x98, 0x2b, 0x05, 0x1e, 0x05, 0x19, 0x3a, 0x51, - 0x91, 0xe0, 0x06, 0x76, 0xeb, 0x44, 0x4d, 0x2f, 0x6e, 0xf4, 0x4b, 0x69, 0x45, 0x79, 0x62, 0x58, - 0xca, 0xa5, 0x1a, 0xe0, 0xe2, 0x32, 0x61, 0xd1, 0x4c, 0x1e, 0xb8, 0x66, 0x80, 0x55, 0xe4, 0x22, - 0x4f, 0x56, 0x9a, 0xbb, 0x96, 0xe6, 0xe0, 0x6b, 0x18, 0xeb, 0x2f, 0x60, 0xfd, 0x01, 0xed, 0x03, - 0x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0x93, 0x6c, 0xc2, 0x96, 0x33, 0xda, 0x84, 0x9b, 0x5e, 0x6c, 0x13, 0x6e, - 0xb3, 0x53, 0x85, 0x66, 0xb9, 0x9e, 0x8d, 0xd6, 0xf4, 0x59, 0x1b, 0xad, 0xcd, 0x2a, 0x15, 0x9a, - 0xe5, 0x3b, 0x36, 0x5a, 0xd3, 0x42, 0x6d, 0xb4, 0x36, 0xb3, 0xda, 0x22, 0xaf, 0x60, 0x64, 0x9b, - 0x00, 0xb1, 0x2e, 0xb4, 0xb8, 0xd8, 0xe4, 0xc1, 0xa6, 0x63, 0x1b, 0xd0, 0xee, 0x79, 0x1b, 0xb0, - 0x65, 0xea, 0x6d, 0xc0, 0xb6, 0x51, 0x09, 0xb6, 0x2e, 0xfb, 0xea, 0x97, 0xfc, 0xab, 0xff, 0x03, - 0x00, 0x00, 0xff, 0xff, 0x27, 0x89, 0x58, 0x67, 0xa1, 0x0b, 0x00, 0x00, + // 1049 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x57, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x0e, 0x45, 0x4b, 0x16, 0x47, 0x72, 0x9a, 0xae, 0x9c, 0x84, 0x55, 0xec, 0x54, 0xd9, 0x26, + 0x85, 0x83, 0x02, 0x86, 0xe1, 0xf6, 0x90, 0xb6, 0x28, 0xd0, 0xc0, 0x4e, 0x83, 0x00, 0x0e, 0x02, + 0xd0, 0x75, 0x81, 0xa2, 0x07, 0x81, 0x26, 0xc7, 0xea, 0xc2, 0x14, 0xa9, 0x72, 0x97, 0x2e, 0xdc, + 0x6b, 0x8f, 0x3d, 0xf5, 0x21, 0x8a, 0xde, 0xfb, 0x0a, 0x7d, 0xb1, 0x62, 0x7f, 0x48, 0x2d, 0x45, + 0xca, 0x49, 0x0e, 0xbd, 0xed, 0xce, 0xce, 0x7c, 0x33, 0xdf, 0x72, 0xe6, 0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, 0x16, 0x31, 0xb1, 0x01, 0xdb, + 0x26, 0x90, 0xde, 0x22, 0x3f, 0xc1, 0x9d, 0xd5, 0x96, 0x26, 0x8f, 0x56, 0x69, 0x35, 0x26, 0x65, + 0x4c, 0x6f, 0x72, 0x29, 0xc1, 0xcf, 0x7b, 0xea, 0x6f, 0xc4, 0xe7, 0xff, 0x05, 0x00, 0x00, 0xff, + 0xff, 0x45, 0xa6, 0x48, 0x98, 0x55, 0x0c, 0x00, 0x00, } diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go index ef62d08d9..1fcbde9b7 100644 --- a/weed/s3api/s3api_bucket_handlers.go +++ b/weed/s3api/s3api_bucket_handlers.go @@ -91,7 +91,7 @@ func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request) return fmt.Errorf("mkdir %s/%s: %v", s3a.option.BucketsPath, bucket, err) } - // TODO create collection + // lazily create collection return nil }) @@ -109,10 +109,21 @@ func (s3a *S3ApiServer) DeleteBucketHandler(w http.ResponseWriter, r *http.Reque vars := mux.Vars(r) bucket := vars["bucket"] - // TODO delete collection - err := s3a.withFilerClient(func(client filer_pb.SeaweedFilerClient) error { + ctx := context.Background() + + // delete collection + deleteCollectionRequest := &filer_pb.DeleteCollectionRequest{ + Collection: bucket, + } + + glog.V(1).Infof("delete collection: %v", deleteCollectionRequest) + if _, err := client.DeleteCollection(ctx, deleteCollectionRequest); err != nil { + return fmt.Errorf("delete collection %%s: %v", bucket, err) + } + + // delete bucket metadata request := &filer_pb.DeleteEntryRequest{ Directory: s3a.option.BucketsPath, Name: bucket, @@ -122,7 +133,7 @@ func (s3a *S3ApiServer) DeleteBucketHandler(w http.ResponseWriter, r *http.Reque } glog.V(1).Infof("delete bucket: %v", request) - if _, err := client.DeleteEntry(context.Background(), request); err != nil { + if _, err := client.DeleteEntry(ctx, request); err != nil { return fmt.Errorf("delete bucket %s/%s: %v", s3a.option.BucketsPath, bucket, err) } diff --git a/weed/server/filer_grpc_server.go b/weed/server/filer_grpc_server.go index 49748af23..1d6743651 100644 --- a/weed/server/filer_grpc_server.go +++ b/weed/server/filer_grpc_server.go @@ -12,6 +12,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "strconv" + "github.com/chrislusf/seaweedfs/weed/util" ) func (fs *FilerServer) LookupDirectoryEntry(ctx context.Context, req *filer_pb.LookupDirectoryEntryRequest) (*filer_pb.LookupDirectoryEntryResponse, error) { @@ -211,3 +212,12 @@ func (fs *FilerServer) AssignVolume(ctx context.Context, req *filer_pb.AssignVol PublicUrl: assignResult.PublicUrl, }, err } + +func (fs *FilerServer) DeleteCollection(ctx context.Context, req *filer_pb.DeleteCollectionRequest) (resp *filer_pb.DeleteCollectionResponse, err error) { + + for _, master := range fs.masters { + _, err = util.Get(fmt.Sprintf("http://%s/col/delete?collection=%s", master, req.Collection)) + } + + return &filer_pb.DeleteCollectionResponse{}, err +}