381
ctx context.Context,
382
updateRequest *workflowservice.UpdateNamespaceRequest,
384
>
385
>
// must get the metadata (notificationVersion) first
386
>
// this version can be regarded as the lock on the v2 namespace table
387
>
// and since we do not know which table will return the namespace afterwards
388
>
// this call has to be made
389
>
metadata, err := d.metadataMgr.GetMetadata(ctx)
390
>
if err != nil {
391
return nil, err
392
}
394
>
getResponse, err := d.metadataMgr.GetNamespace(ctx, &persistence.GetNamespaceRequest{Name: updateRequest.GetNamespace()})
395
>
if err != nil {
396
return nil, err
397
}
398
400
>
config := getResponse.Namespace.Config
401
>
replicationConfig := getResponse.Namespace.ReplicationConfig
402
>
failoverHistory := getResponse.Namespace.ReplicationConfig.FailoverHistory
403
>
configVersion := getResponse.Namespace.ConfigVersion
404
>
failoverVersion := getResponse.Namespace.FailoverVersion
405
>
failoverNotificationVersion := getResponse.Namespace.FailoverNotificationVersion
406
>
isGlobalNamespace := getResponse.IsGlobalNamespace || updateRequest.PromoteNamespace
407
>
needsNamespacePromotion := !getResponse.IsGlobalNamespace && updateRequest.PromoteNamespace
408
>
409
>
currentHistoryArchivalState := &namespace.ArchivalConfigState{
410
>
State: config.HistoryArchivalState,
411
>
URI: config.HistoryArchivalUri,
412
>
}
413
>
nextHistoryArchivalState := currentHistoryArchivalState
414
>
historyArchivalConfigChanged := false
415
>
clusterHistoryArchivalConfig := d.archivalMetadata.GetHistoryConfig()
416
>
if updateRequest.Config != nil && clusterHistoryArchivalConfig.ClusterConfiguredForArchival() {
417
cfg := updateRequest.GetConfig()
418
archivalEvent, err := d.toArchivalUpdateEvent(cfg.HistoryArchivalState, cfg.GetHistoryArchivalUri(), clusterHistoryArchivalConfig.GetNamespaceDefaultURI())