Пример #1
0
        public static DagNetworkConfiguration GetDagNetworkConfig(DatabaseAvailabilityGroup dag)
        {
            DagNetworkConfiguration dagNetworkConfiguration = null;

            if (dag.Servers.Count == 0)
            {
                return(null);
            }
            Exception ex = null;
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 85, "GetDagNetworkConfig", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Cluster\\DagNetworkClientRpc.cs");

            topologyConfigurationSession.UseConfigNC      = false;
            topologyConfigurationSession.UseGlobalCatalog = true;
            foreach (ADObjectId adobjectId in dag.Servers)
            {
                try
                {
                    ADComputer adcomputer = topologyConfigurationSession.FindComputerByHostName(adobjectId.Name);
                    if (adcomputer != null && !string.IsNullOrEmpty(adcomputer.DnsHostName))
                    {
                        if (dag.DatacenterActivationMode != DatacenterActivationModeOption.DagOnly || !dag.StoppedMailboxServers.Contains(adcomputer.DnsHostName, StringComparer.OrdinalIgnoreCase))
                        {
                            dagNetworkConfiguration = DagNetworkRpc.GetDagNetworkConfig(adcomputer.DnsHostName);
                            if (dagNetworkConfiguration != null)
                            {
                                break;
                            }
                        }
                    }
                }
                catch (TaskServerTransientException ex2)
                {
                    ex = ex2;
                }
                catch (TaskServerException ex3)
                {
                    ex = ex3;
                }
                catch (ADTransientException ex4)
                {
                    ex = ex4;
                }
                catch (ADExternalException ex5)
                {
                    ex = ex5;
                }
                catch (ADOperationException ex6)
                {
                    ex = ex6;
                }
            }
            if (dagNetworkConfiguration == null && ex != null)
            {
                throw ex;
            }
            return(dagNetworkConfiguration);
        }
Пример #2
0
 public static DagNetworkConfiguration GetDagNetworkConfig(string serverName)
 {
     byte[] configAsBytes = null;
     DagNetworkRpc.RunRpcOperation(serverName, delegate(ReplayRpcClient rpcClient)
     {
         ExTraceGlobals.DatabaseAvailabilityGroupTracer.TraceDebug <string>(0L, "GetDagNetworkConfig sending RPC to {0}", serverName);
         return(rpcClient.GetDagNetworkConfig(ref configAsBytes));
     });
     return((DagNetworkConfiguration)Serialization.BytesToObject(configAsBytes));
 }
Пример #3
0
        private static void RunRpcOperation(string serverName, int?timeoutMs, DagNetworkRpc.InternalRpcOperation rpcOperation)
        {
            RpcErrorExceptionInfo errorInfo = null;

            TasksRpcExceptionWrapper.Instance.ClientRetryableOperation(serverName, delegate
            {
                using (ReplayRpcClient replayRpcClient = DagNetworkRpc.RpcClientFactory(serverName, timeoutMs))
                {
                    errorInfo = rpcOperation(replayRpcClient);
                }
            });
            TasksRpcExceptionWrapper.Instance.ClientRethrowIfFailed(serverName, errorInfo);
        }
Пример #4
0
        public static void SetDagNetwork(DatabaseAvailabilityGroup dag, SetDagNetworkRequest change)
        {
            if (dag.Servers.Count == 0)
            {
                return;
            }
            AmPamInfo primaryActiveManager = AmRpcClientHelper.GetPrimaryActiveManager(ADObjectWrapperFactory.CreateWrapper(dag));
            string    targetServerName     = primaryActiveManager.ServerName;

            byte[] changeAsBytes = Serialization.ObjectToBytes(change);
            DagNetworkRpc.RunRpcOperation(targetServerName, delegate(ReplayRpcClient rpcClient)
            {
                ExTraceGlobals.DatabaseAvailabilityGroupTracer.TraceDebug <string>(0L, "SetDagNetwork sending RPC to {0}", targetServerName);
                return(rpcClient.SetDagNetwork(changeAsBytes));
            });
        }
Пример #5
0
 private static ReplayRpcClient RpcClientFactory(string serverName)
 {
     return(DagNetworkRpc.RpcClientFactory(serverName, null));
 }
Пример #6
0
 private static void RunRpcOperation(string serverName, DagNetworkRpc.InternalRpcOperation rpcOperation)
 {
     DagNetworkRpc.RunRpcOperation(serverName, null, rpcOperation);
 }