|
|
@ -68,28 +68,21 @@ type NotificationPeerErr struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// DeleteBucket - calls DeleteBucket RPC call on all peers.
|
|
|
|
// DeleteBucket - calls DeleteBucket RPC call on all peers.
|
|
|
|
func (sys *NotificationSys) DeleteBucket(bucketName string) <-chan NotificationPeerErr { |
|
|
|
func (sys *NotificationSys) DeleteBucket(ctx context.Context, bucketName string) { |
|
|
|
errCh := make(chan NotificationPeerErr) |
|
|
|
|
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
defer close(errCh) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var wg sync.WaitGroup |
|
|
|
var wg sync.WaitGroup |
|
|
|
for addr, client := range sys.peerRPCClientMap { |
|
|
|
for addr, client := range sys.peerRPCClientMap { |
|
|
|
wg.Add(1) |
|
|
|
wg.Add(1) |
|
|
|
go func(addr xnet.Host, client *PeerRPCClient) { |
|
|
|
go func(addr xnet.Host, client *PeerRPCClient) { |
|
|
|
defer wg.Done() |
|
|
|
defer wg.Done() |
|
|
|
if err := client.DeleteBucket(bucketName); err != nil { |
|
|
|
if err := client.DeleteBucket(bucketName); err != nil { |
|
|
|
errCh <- NotificationPeerErr{ |
|
|
|
logger.GetReqInfo(ctx).AppendTags("remotePeer", addr.Name) |
|
|
|
Host: addr, |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
Err: err, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}(addr, client) |
|
|
|
}(addr, client) |
|
|
|
} |
|
|
|
} |
|
|
|
wg.Wait() |
|
|
|
wg.Wait() |
|
|
|
}() |
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
return errCh |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SetCredentials - calls SetCredentials RPC call on all peers.
|
|
|
|
// SetCredentials - calls SetCredentials RPC call on all peers.
|
|
|
@ -120,104 +113,76 @@ func (sys *NotificationSys) SetCredentials(credentials auth.Credentials) map[xne |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SetBucketPolicy - calls SetBucketPolicy RPC call on all peers.
|
|
|
|
// SetBucketPolicy - calls SetBucketPolicy RPC call on all peers.
|
|
|
|
func (sys *NotificationSys) SetBucketPolicy(bucketName string, bucketPolicy *policy.Policy) <-chan NotificationPeerErr { |
|
|
|
func (sys *NotificationSys) SetBucketPolicy(ctx context.Context, bucketName string, bucketPolicy *policy.Policy) { |
|
|
|
errCh := make(chan NotificationPeerErr) |
|
|
|
|
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
defer close(errCh) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var wg sync.WaitGroup |
|
|
|
var wg sync.WaitGroup |
|
|
|
for addr, client := range sys.peerRPCClientMap { |
|
|
|
for addr, client := range sys.peerRPCClientMap { |
|
|
|
wg.Add(1) |
|
|
|
wg.Add(1) |
|
|
|
go func(addr xnet.Host, client *PeerRPCClient) { |
|
|
|
go func(addr xnet.Host, client *PeerRPCClient) { |
|
|
|
defer wg.Done() |
|
|
|
defer wg.Done() |
|
|
|
if err := client.SetBucketPolicy(bucketName, bucketPolicy); err != nil { |
|
|
|
if err := client.SetBucketPolicy(bucketName, bucketPolicy); err != nil { |
|
|
|
errCh <- NotificationPeerErr{ |
|
|
|
logger.GetReqInfo(ctx).AppendTags("remotePeer", addr.Name) |
|
|
|
Host: addr, |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
Err: err, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}(addr, client) |
|
|
|
}(addr, client) |
|
|
|
} |
|
|
|
} |
|
|
|
wg.Wait() |
|
|
|
wg.Wait() |
|
|
|
}() |
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
return errCh |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RemoveBucketPolicy - calls RemoveBucketPolicy RPC call on all peers.
|
|
|
|
// RemoveBucketPolicy - calls RemoveBucketPolicy RPC call on all peers.
|
|
|
|
func (sys *NotificationSys) RemoveBucketPolicy(bucketName string) <-chan NotificationPeerErr { |
|
|
|
func (sys *NotificationSys) RemoveBucketPolicy(ctx context.Context, bucketName string) { |
|
|
|
errCh := make(chan NotificationPeerErr) |
|
|
|
|
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
defer close(errCh) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var wg sync.WaitGroup |
|
|
|
var wg sync.WaitGroup |
|
|
|
for addr, client := range sys.peerRPCClientMap { |
|
|
|
for addr, client := range sys.peerRPCClientMap { |
|
|
|
wg.Add(1) |
|
|
|
wg.Add(1) |
|
|
|
go func(addr xnet.Host, client *PeerRPCClient) { |
|
|
|
go func(addr xnet.Host, client *PeerRPCClient) { |
|
|
|
defer wg.Done() |
|
|
|
defer wg.Done() |
|
|
|
if err := client.RemoveBucketPolicy(bucketName); err != nil { |
|
|
|
if err := client.RemoveBucketPolicy(bucketName); err != nil { |
|
|
|
errCh <- NotificationPeerErr{ |
|
|
|
logger.GetReqInfo(ctx).AppendTags("remotePeer", addr.Name) |
|
|
|
Host: addr, |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
Err: err, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}(addr, client) |
|
|
|
}(addr, client) |
|
|
|
} |
|
|
|
} |
|
|
|
wg.Wait() |
|
|
|
wg.Wait() |
|
|
|
}() |
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
return errCh |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// PutBucketNotification - calls PutBucketNotification RPC call on all peers.
|
|
|
|
// PutBucketNotification - calls PutBucketNotification RPC call on all peers.
|
|
|
|
func (sys *NotificationSys) PutBucketNotification(bucketName string, rulesMap event.RulesMap) <-chan NotificationPeerErr { |
|
|
|
func (sys *NotificationSys) PutBucketNotification(ctx context.Context, bucketName string, rulesMap event.RulesMap) { |
|
|
|
errCh := make(chan NotificationPeerErr) |
|
|
|
|
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
defer close(errCh) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var wg sync.WaitGroup |
|
|
|
var wg sync.WaitGroup |
|
|
|
for addr, client := range sys.peerRPCClientMap { |
|
|
|
for addr, client := range sys.peerRPCClientMap { |
|
|
|
wg.Add(1) |
|
|
|
wg.Add(1) |
|
|
|
go func(addr xnet.Host, client *PeerRPCClient, rulesMap event.RulesMap) { |
|
|
|
go func(addr xnet.Host, client *PeerRPCClient, rulesMap event.RulesMap) { |
|
|
|
defer wg.Done() |
|
|
|
defer wg.Done() |
|
|
|
if err := client.PutBucketNotification(bucketName, rulesMap); err != nil { |
|
|
|
if err := client.PutBucketNotification(bucketName, rulesMap); err != nil { |
|
|
|
errCh <- NotificationPeerErr{ |
|
|
|
logger.GetReqInfo(ctx).AppendTags("remotePeer", addr.Name) |
|
|
|
Host: addr, |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
Err: err, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}(addr, client, rulesMap.Clone()) |
|
|
|
}(addr, client, rulesMap.Clone()) |
|
|
|
} |
|
|
|
} |
|
|
|
wg.Wait() |
|
|
|
wg.Wait() |
|
|
|
}() |
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
return errCh |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ListenBucketNotification - calls ListenBucketNotification RPC call on all peers.
|
|
|
|
// ListenBucketNotification - calls ListenBucketNotification RPC call on all peers.
|
|
|
|
func (sys *NotificationSys) ListenBucketNotification(bucketName string, eventNames []event.Name, pattern string, |
|
|
|
func (sys *NotificationSys) ListenBucketNotification(ctx context.Context, bucketName string, eventNames []event.Name, pattern string, |
|
|
|
targetID event.TargetID, localPeer xnet.Host) <-chan NotificationPeerErr { |
|
|
|
targetID event.TargetID, localPeer xnet.Host) { |
|
|
|
errCh := make(chan NotificationPeerErr) |
|
|
|
|
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
defer close(errCh) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var wg sync.WaitGroup |
|
|
|
var wg sync.WaitGroup |
|
|
|
for addr, client := range sys.peerRPCClientMap { |
|
|
|
for addr, client := range sys.peerRPCClientMap { |
|
|
|
wg.Add(1) |
|
|
|
wg.Add(1) |
|
|
|
go func(addr xnet.Host, client *PeerRPCClient) { |
|
|
|
go func(addr xnet.Host, client *PeerRPCClient) { |
|
|
|
defer wg.Done() |
|
|
|
defer wg.Done() |
|
|
|
if err := client.ListenBucketNotification(bucketName, eventNames, pattern, targetID, localPeer); err != nil { |
|
|
|
if err := client.ListenBucketNotification(bucketName, eventNames, pattern, targetID, localPeer); err != nil { |
|
|
|
errCh <- NotificationPeerErr{ |
|
|
|
logger.GetReqInfo(ctx).AppendTags("remotePeer", addr.Name) |
|
|
|
Host: addr, |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
Err: err, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}(addr, client) |
|
|
|
}(addr, client) |
|
|
|
} |
|
|
|
} |
|
|
|
wg.Wait() |
|
|
|
wg.Wait() |
|
|
|
}() |
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
return errCh |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// AddRemoteTarget - adds event rules map, HTTP/PeerRPC client target to bucket name.
|
|
|
|
// AddRemoteTarget - adds event rules map, HTTP/PeerRPC client target to bucket name.
|
|
|
@ -556,13 +521,16 @@ func sendEvent(args eventArgs) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for _, err := range globalNotificationSys.Send(args) { |
|
|
|
notifyCh := globalNotificationSys.Send(args) |
|
|
|
reqInfo := &logger.ReqInfo{BucketName: args.BucketName, ObjectName: args.Object.Name} |
|
|
|
go func() { |
|
|
|
reqInfo.AppendTags("EventName", args.EventName.String()) |
|
|
|
for _, err := range notifyCh { |
|
|
|
reqInfo.AppendTags("targetID", err.ID.Name) |
|
|
|
reqInfo := &logger.ReqInfo{BucketName: args.BucketName, ObjectName: args.Object.Name} |
|
|
|
ctx := logger.SetReqInfo(context.Background(), reqInfo) |
|
|
|
reqInfo.AppendTags("EventName", args.EventName.String()) |
|
|
|
logger.LogOnceIf(ctx, err.Err, err.ID) |
|
|
|
reqInfo.AppendTags("targetID", err.ID.Name) |
|
|
|
} |
|
|
|
ctx := logger.SetReqInfo(context.Background(), reqInfo) |
|
|
|
|
|
|
|
logger.LogOnceIf(ctx, err.Err, err.ID) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func saveConfig(objAPI ObjectLayer, configFile string, data []byte) error { |
|
|
|
func saveConfig(objAPI ObjectLayer, configFile string, data []byte) error { |
|
|
|