Exemple #1
0
        // Token: 0x06001353 RID: 4947 RVA: 0x0004E3D8 File Offset: 0x0004C5D8
        internal static CopyStatusClientCachedEntry[] GetAllCopyStatuses(AmServerName amServer, RpcGetDatabaseCopyStatusFlags2 collectionFlags2, IEnumerable <IADDatabase> expectedDatabases, int timeoutMs, ActiveManager activeManager, bool isGetHealthStates, out RpcHealthStateInfo[] healthStates, out Exception exception)
        {
            CopyStatusClientCachedEntry[] result   = null;
            RpcDatabaseCopyStatus2[]      statuses = null;
            TimeSpan rpcDuration = TimeSpan.Zero;

            new ReplayStopwatch();
            Exception tempEx = null;

            exception    = null;
            healthStates = null;
            RpcHealthStateInfo[] tmpHealthStates = null;
            tempEx = CopyStatusHelper.TimeCopyStatusRpc(delegate
            {
                if (!isGetHealthStates)
                {
                    statuses = Dependencies.ReplayRpcClientWrapper.GetCopyStatus(amServer.Fqdn, collectionFlags2, null, timeoutMs);
                    return;
                }
                RpcCopyStatusContainer copyStatusWithHealthState = Dependencies.ReplayRpcClientWrapper.GetCopyStatusWithHealthState(amServer.Fqdn, collectionFlags2, null, timeoutMs);
                statuses        = copyStatusWithHealthState.CopyStatuses;
                tmpHealthStates = copyStatusWithHealthState.HealthStates;
            }, out rpcDuration);
            healthStates = tmpHealthStates;
            exception    = tempEx;
            if (exception != null)
            {
                result = (from db in expectedDatabases
                          select CopyStatusHelper.ConstructCopyStatusCachedEntry(db.Guid, amServer, null, tempEx, rpcDuration, activeManager)).ToArray <CopyStatusClientCachedEntry>();
            }
            else if (statuses != null)
            {
                Dictionary <Guid, RpcDatabaseCopyStatus2> tempStatusTable = statuses.ToDictionary((RpcDatabaseCopyStatus2 status) => status.DBGuid);
                tempEx = new ReplayServiceRpcUnknownInstanceException();
                result = (from db in expectedDatabases
                          let guid = db.Guid
                                     let statusFound = tempStatusTable.ContainsKey(guid)
                                                       select CopyStatusHelper.ConstructCopyStatusCachedEntry(guid, amServer, statusFound ? tempStatusTable[guid] : null, statusFound ? null : tempEx, rpcDuration, activeManager)).ToArray <CopyStatusClientCachedEntry>();
            }
            else
            {
                DiagCore.RetailAssert(false, "If no exception was thrown by GetCopyStatus RPC, then we should have some status results!", new object[0]);
            }
            return(result);
        }
        public RpcCopyStatusContainer GetCopyStatusWithHealthState(string serverName, RpcGetDatabaseCopyStatusFlags2 collectionFlags2, Guid[] dbGuids, int timeoutMs)
        {
            if (dbGuids == null || dbGuids.Length == 0)
            {
                dbGuids = new Guid[]
                {
                    Guid.Empty
                };
            }
            RpcCopyStatusContainer container = null;

            if (ReplayRpcVersionControl.IsGetCopyStatusWithHealthStateRpcSupported(ReplayRpcClientWrapper.GetServerVersion(serverName)))
            {
                ReplayRpcClientWrapper.RunRpcOperation(serverName, null, timeoutMs, TasksRpcExceptionWrapper.Instance, delegate(ReplayRpcClient rpcClient)
                {
                    RpcErrorExceptionInfo result;
                    try
                    {
                        ExTraceGlobals.ReplayServiceRpcTracer.TraceDebug <string>(0L, "GetCopyStatusWithHealthState(): Now making RpccGetCopyStatusWithHealthState() RPC to server {0}.", serverName);
                        RpcErrorExceptionInfo rpcErrorExceptionInfo = rpcClient.RpccGetCopyStatusWithHealthState(collectionFlags2, dbGuids, ref container);
                        if (!rpcErrorExceptionInfo.IsFailed())
                        {
                            ReplayRpcClientWrapper.DeserializeExtendedErrorInfo(container.CopyStatuses);
                        }
                        result = rpcErrorExceptionInfo;
                    }
                    catch (RpcException ex)
                    {
                        if (ReplayRpcErrorCode.IsRpcTimeoutError(ex.ErrorCode))
                        {
                            throw new ReplayServiceDownException(serverName, ex.Message, ex);
                        }
                        throw;
                    }
                    return(result);
                });
            }
            else
            {
                container = new RpcCopyStatusContainer();
                container.HealthStates = null;
                container.CopyStatuses = this.GetCopyStatus(serverName, collectionFlags2, dbGuids, timeoutMs);
            }
            return(container);
        }