mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
update remote storage mount mapping
This commit is contained in:
parent
df29281536
commit
99d4594ee8
|
@ -60,7 +60,16 @@ func (option *RemoteSyncOptions) makeBucketedEventProcessor(filerSource *source.
|
||||||
if err := client.CreateBucket(entry.Name); err != nil {
|
if err := client.CreateBucket(entry.Name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
bucketPath := util.FullPath(option.bucketsDir).Child(entry.Name)
|
||||||
|
remoteLocation := &remote_pb.RemoteStorageLocation{
|
||||||
|
Name: *option.createBucketAt,
|
||||||
|
Bucket: entry.Name,
|
||||||
|
Path: "/",
|
||||||
|
}
|
||||||
|
|
||||||
|
return filer.InsertMountMapping(option, string(bucketPath), remoteLocation)
|
||||||
|
|
||||||
}
|
}
|
||||||
handleDeleteBucket := func(entry *filer_pb.Entry) error {
|
handleDeleteBucket := func(entry *filer_pb.Entry) error {
|
||||||
if !entry.IsDirectory {
|
if !entry.IsDirectory {
|
||||||
|
@ -76,14 +85,16 @@ func (option *RemoteSyncOptions) makeBucketedEventProcessor(filerSource *source.
|
||||||
if err := client.DeleteBucket(entry.Name); err != nil {
|
if err := client.DeleteBucket(entry.Name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
bucketPath := util.FullPath(option.bucketsDir).Child(entry.Name)
|
||||||
|
|
||||||
|
return filer.DeleteMountMapping(option, string(bucketPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEtcRemoteChanges := func(resp *filer_pb.SubscribeMetadataResponse) error {
|
handleEtcRemoteChanges := func(resp *filer_pb.SubscribeMetadataResponse) error {
|
||||||
message := resp.EventNotification
|
message := resp.EventNotification
|
||||||
if message.NewEntry == nil {
|
if message.NewEntry != nil {
|
||||||
return nil
|
// update
|
||||||
}
|
|
||||||
if message.NewEntry.Name == filer.REMOTE_STORAGE_MOUNT_FILE {
|
if message.NewEntry.Name == filer.REMOTE_STORAGE_MOUNT_FILE {
|
||||||
newMappings, readErr := filer.UnmarshalRemoteStorageMappings(message.NewEntry.Content)
|
newMappings, readErr := filer.UnmarshalRemoteStorageMappings(message.NewEntry.Content)
|
||||||
if readErr != nil {
|
if readErr != nil {
|
||||||
|
@ -98,6 +109,16 @@ func (option *RemoteSyncOptions) makeBucketedEventProcessor(filerSource *source.
|
||||||
}
|
}
|
||||||
option.remoteConfs[conf.Name] = conf
|
option.remoteConfs[conf.Name] = conf
|
||||||
}
|
}
|
||||||
|
} else if message.OldEntry != nil {
|
||||||
|
// deletion
|
||||||
|
if strings.HasSuffix(message.OldEntry.Name, filer.REMOTE_STORAGE_CONF_SUFFIX) {
|
||||||
|
conf := &remote_pb.RemoteConf{}
|
||||||
|
if err := proto.Unmarshal(message.OldEntry.Content, conf); err != nil {
|
||||||
|
return fmt.Errorf("unmarshal %s/%s: %v", filer.DirectoryEtcRemote, message.OldEntry.Name, err)
|
||||||
|
}
|
||||||
|
delete(option.remoteConfs, conf.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue