示例#1
0
 // Token: 0x060005BB RID: 1467 RVA: 0x000158A4 File Offset: 0x00013AA4
 public IDistributedStoreKey OpenKey(string subkeyName, DxStoreKeyAccessMode mode, bool isIgnoreIfNotExist, ReadWriteConstraints constraints)
 {
     return(this.BaseParameters.KeyFactory.RunOperationAndTranslateException <IDistributedStoreKey>(OperationCategory.OpenKey, Path.Combine(this.FullKeyName, subkeyName), delegate()
     {
         ReadOptions readOptions = this.GetReadOptions(constraints);
         WriteOptions writeOptions = this.GetWriteOptions(constraints);
         DxStoreAccessRequest.CheckKey checkKey = this.CreateRequest <DxStoreAccessRequest.CheckKey>();
         checkKey.IsCreateIfNotExist = (mode == DxStoreKeyAccessMode.CreateIfNotExist);
         checkKey.SubkeyName = subkeyName;
         checkKey.ReadOptions = readOptions;
         checkKey.WriteOptions = writeOptions;
         DxStoreAccessReply.CheckKey checkKey2 = this.BaseParameters.Client.CheckKey(checkKey, null);
         this.SetReadResult(constraints, checkKey2.ReadResult);
         this.SetWriteResult(constraints, checkKey2.WriteResult);
         IDistributedStoreKey result = null;
         if (!checkKey2.IsExist)
         {
             if (!isIgnoreIfNotExist)
             {
                 throw new DxStoreKeyNotFoundException(subkeyName);
             }
         }
         else
         {
             result = new DxStoreKey(Path.Combine(this.FullKeyName, subkeyName), mode, this.BaseParameters);
         }
         return result;
     }, false));
 }
        public IDistributedStoreKey GetBaseKey(DxStoreKeyAccessMode mode, DistributedStore.Context context)
        {
            if (this.IsRestartProcessOnDxStoreModeChange)
            {
                this.StartProcessRestartTimer();
            }
            DistributedStoreKey compositeKey = new DistributedStoreKey(string.Empty, string.Empty, mode, context);

            compositeKey.IsBaseKey = true;
            try
            {
                this.ExecuteRequest(compositeKey, OperationCategory.GetBaseKey, OperationType.Read, string.Empty, delegate(IDistributedStoreKey key, bool isPrimary, StoreKind storeKind)
                {
                    this.SetKeyByRole(compositeKey, isPrimary, this.BaseKeyGenerator(mode, context, storeKind));
                });
            }
            finally
            {
                if (compositeKey.PrimaryStoreKey == null)
                {
                    compositeKey.CloseKey();
                    compositeKey = null;
                }
            }
            return(compositeKey);
        }
        // Token: 0x06000536 RID: 1334 RVA: 0x0001393C File Offset: 0x00011B3C
        private IDistributedStoreKey OpenKeyInternal(string subKeyName, DxStoreKeyAccessMode mode, bool isIgnoreIfNotExist)
        {
            AmClusterRegkeyHandle amClusterRegkeyHandle = null;
            AmClusterRegkeyHandle keyHandle             = this.KeyHandle;
            RegSAM regSam = ClusterDbKey.GetRegSam(mode);
            int    num    = ClusapiMethods.ClusterRegOpenKey(keyHandle, subKeyName, regSam, out amClusterRegkeyHandle);

            if (mode == DxStoreKeyAccessMode.CreateIfNotExist && (num == 2 || num == 3))
            {
                uint num2;
                num = ClusapiMethods.ClusterRegCreateKey(keyHandle, subKeyName, 0U, regSam, IntPtr.Zero, out amClusterRegkeyHandle, out num2);
            }
            if (num == 0)
            {
                return(new ClusterDbKey(amClusterRegkeyHandle, this.ClusterHandle));
            }
            if (amClusterRegkeyHandle != null && !amClusterRegkeyHandle.IsInvalid)
            {
                amClusterRegkeyHandle.Dispose();
            }
            amClusterRegkeyHandle = null;
            if (!isIgnoreIfNotExist)
            {
                throw new ClusterApiException("ClusterRegOpenKey", new Win32Exception(num));
            }
            return(null);
        }
        // Token: 0x06000535 RID: 1333 RVA: 0x00013918 File Offset: 0x00011B18
        private static RegSAM GetRegSam(DxStoreKeyAccessMode mode)
        {
            RegSAM result = RegSAM.Read;

            if (mode == DxStoreKeyAccessMode.Write || mode == DxStoreKeyAccessMode.CreateIfNotExist)
            {
                result = RegSAM.AllAccess;
            }
            return(result);
        }
 // Token: 0x060005A4 RID: 1444 RVA: 0x00014FEC File Offset: 0x000131EC
 private IDistributedStoreKey OpenKeyInternal(string subKeyName, DxStoreKeyAccessMode mode, bool isIgnoreIfNotExist, ReadWriteConstraints constraints)
 {
     if (mode == DxStoreKeyAccessMode.CreateIfNotExist)
     {
         IDistributedStoreKey distributedStoreKey = this.OpenKeyFinal(subKeyName, DxStoreKeyAccessMode.Write, true, constraints);
         if (distributedStoreKey != null)
         {
             return(distributedStoreKey);
         }
     }
     return(this.OpenKeyFinal(subKeyName, mode, isIgnoreIfNotExist, constraints));
 }
 // Token: 0x06000583 RID: 1411 RVA: 0x00014DC8 File Offset: 0x00012FC8
 public DistributedStoreKey(string parentKeyName, string subkeyName, DxStoreKeyAccessMode mode, DistributedStore.Context context = null)
 {
     this.InstanceId = Guid.NewGuid();
     if (string.IsNullOrEmpty(parentKeyName))
     {
         parentKeyName = string.Empty;
     }
     if (string.IsNullOrEmpty(subkeyName))
     {
         subkeyName = string.Empty;
     }
     this.FullKeyName = Path.Combine(parentKeyName, subkeyName);
     this.Mode        = mode;
     this.Context     = context;
 }
        // Token: 0x060005A5 RID: 1445 RVA: 0x0001507C File Offset: 0x0001327C
        private IDistributedStoreKey OpenKeyFinal(string subKeyName, DxStoreKeyAccessMode mode, bool isIgnoreIfNotExist, ReadWriteConstraints constraints)
        {
            OperationCategory operationCategory = OperationCategory.OpenKey;
            OperationType     operationType     = OperationType.Read;

            if (mode == DxStoreKeyAccessMode.CreateIfNotExist)
            {
                operationCategory = OperationCategory.OpenOrCreateKey;
                operationType     = OperationType.Write;
            }
            DistributedStoreKey  compositeKey = new DistributedStoreKey(this.FullKeyName, subKeyName, mode, this.Context);
            IDistributedStoreKey result;

            try
            {
                result = (DistributedStore.Instance.ExecuteRequest <bool>(this, operationCategory, operationType, string.Format("SubKey: [{0}] Mode: [{1}] IsBestEffort: [{2}] IsConstrained: [{3}]", new object[]
                {
                    subKeyName,
                    mode,
                    isIgnoreIfNotExist,
                    constraints != null
                }), delegate(IDistributedStoreKey key, bool isPrimary, StoreKind storeKind)
                {
                    this.ThrowIfKeyIsInvalid(key);
                    IDistributedStoreKey distributedStoreKey = key.OpenKey(subKeyName, mode, isIgnoreIfNotExist, ReadWriteConstraints.Copy(constraints));
                    if (distributedStoreKey != null)
                    {
                        DistributedStore.Instance.SetKeyByRole(compositeKey, isPrimary, distributedStoreKey);
                        return(true);
                    }
                    return(false);
                }) ? compositeKey : null);
            }
            finally
            {
                if (compositeKey.PrimaryStoreKey == null)
                {
                    compositeKey.CloseKey();
                }
            }
            return(result);
        }
        public IDistributedStoreKey GetBaseKeyByStoreKind(DxStoreKeyAccessMode mode, DistributedStore.Context context, StoreKind storeKind)
        {
            IDistributedStoreKey result;

            switch (storeKind)
            {
            case StoreKind.Clusdb:
                result = ClusterDbKey.GetBaseKey(context.ClusterHandle, mode);
                break;

            case StoreKind.DxStore:
                result = this.DxStoreKeyFactoryInstance.GetBaseKey(mode, context.ChannelFactory, context.NodeName, false);
                break;

            default:
                result = null;
                break;
            }
            return(result);
        }
 // Token: 0x060005E9 RID: 1513 RVA: 0x00016650 File Offset: 0x00014850
 public IDistributedStoreKey GetBaseKey(DxStoreKeyAccessMode mode, CachedChannelFactory <IDxStoreAccess> channelFactory = null, string nodeName = null, bool isPrivate = false)
 {
     return(this.RunOperationAndTranslateException <DxStoreKey>(OperationCategory.GetBaseKey, string.Empty, delegate()
     {
         channelFactory = (channelFactory ?? this.GetFactory(nodeName, null));
         IDxStoreAccessClient dxStoreAccessClient;
         if (this.GroupConfig.Settings.IsUseHttpTransportForClientCommunication)
         {
             dxStoreAccessClient = new HttpStoreAccessClient(this.GroupConfig.Self, HttpClient.TargetInfo.BuildFromNode(nodeName, this.GroupConfig), this.GroupConfig.Settings.StoreAccessHttpTimeoutInMSec);
         }
         else
         {
             dxStoreAccessClient = new WcfStoreAccessClient(channelFactory, null);
         }
         DxStoreAccessRequest.CheckKey checkKey = new DxStoreAccessRequest.CheckKey();
         checkKey.Initialize(string.Empty, isPrivate, this.ConfigProvider.Self);
         DxStoreAccessReply.CheckKey checkKey2 = dxStoreAccessClient.CheckKey(checkKey, null);
         if (checkKey2.ReadResult.IsStale)
         {
             throw new DxStoreInstanceStaleStoreException();
         }
         if (!checkKey2.IsExist)
         {
             throw new DxStoreKeyNotFoundException(string.Empty);
         }
         DxStoreKey.BaseKeyParameters baseParameters = new DxStoreKey.BaseKeyParameters
         {
             Client = dxStoreAccessClient,
             KeyFactory = this,
             Self = this.ConfigProvider.Self,
             IsPrivate = isPrivate,
             DefaultReadOptions = new ReadOptions(),
             DefaultWriteOptions = new WriteOptions()
         };
         return new DxStoreKey(string.Empty, mode, baseParameters);
     }, false));
 }
示例#10
0
 private IDistributedStoreKey GetClusterCompositeKey(AmClusterHandle clusterHandle, CachedChannelFactory <IDxStoreAccess> channelFactory = null, string nodeName = null, DxStoreKeyAccessMode mode = DxStoreKeyAccessMode.Read)
 {
     DistributedStore.Context context = new DistributedStore.Context
     {
         ClusterHandle  = clusterHandle,
         ChannelFactory = channelFactory,
         NodeName       = nodeName
     };
     return(this.GetBaseKey(mode, context));
 }
示例#11
0
        internal IDistributedStoreKey GetClusterKey(AmClusterHandle clusterHandle, CachedChannelFactory <IDxStoreAccess> channelFactory = null, string nodeName = null, DxStoreKeyAccessMode mode = DxStoreKeyAccessMode.Read, bool isBestEffort = false)
        {
            IDistributedStoreKey result = null;

            try
            {
                if (this.StoreSettings.IsCompositeModeEnabled || RegistryParameters.DistributedStoreIsLogPerformanceForSingleStore)
                {
                    result = this.GetClusterCompositeKey(clusterHandle, channelFactory, nodeName, mode);
                }
                else
                {
                    DistributedStore.Context context = new DistributedStore.Context
                    {
                        ClusterHandle  = clusterHandle,
                        ChannelFactory = channelFactory,
                        NodeName       = nodeName
                    };
                    result = this.GetBaseKeyByStoreKind(mode, context, this.StoreSettings.Primary);
                }
            }
            catch (ClusterException)
            {
                if (!isBestEffort)
                {
                    throw;
                }
            }
            return(result);
        }
 // Token: 0x06000525 RID: 1317 RVA: 0x00013455 File Offset: 0x00011655
 public IDistributedStoreKey OpenKey(string subKeyName, DxStoreKeyAccessMode mode, bool isIgnoreIfNotExist, ReadWriteConstraints constraints)
 {
     return(this.OpenKeyInternal(subKeyName, mode, isIgnoreIfNotExist));
 }
        // Token: 0x06000533 RID: 1331 RVA: 0x000138B8 File Offset: 0x00011AB8
        internal static IDistributedStoreKey GetBaseKey(AmClusterHandle clusterHandle, DxStoreKeyAccessMode mode)
        {
            RegSAM regSam = ClusterDbKey.GetRegSam(mode);
            AmClusterRegkeyHandle clusterKey = ClusapiMethods.GetClusterKey(clusterHandle, regSam);

            if (clusterKey == null || clusterKey.IsInvalid)
            {
                throw AmExceptionHelper.ConstructClusterApiExceptionNoErr("GetClusterKey", new object[0]);
            }
            return(new ClusterDbKey(clusterKey, clusterHandle));
        }
示例#14
0
 // Token: 0x060005B2 RID: 1458 RVA: 0x000156F9 File Offset: 0x000138F9
 public DxStoreKey(string keyFullName, DxStoreKeyAccessMode mode, DxStoreKey.BaseKeyParameters baseParameters)
 {
     this.FullKeyName    = keyFullName;
     this.Mode           = mode;
     this.BaseParameters = baseParameters;
 }
示例#15
0
        public T RunActionWithKey <T>(string keyName, Func <IDistributedStoreKey, T> action, DxStoreKeyAccessMode mode = DxStoreKeyAccessMode.Read)
        {
            IDistributedStoreKey distributedStoreKey = string.IsNullOrEmpty(keyName) ? this.rootKey : this.rootKey.OpenKey(keyName, mode, false, null);
            T result;

            try
            {
                T t = action(distributedStoreKey);
                result = t;
            }
            finally
            {
                if (distributedStoreKey != null && !object.ReferenceEquals(distributedStoreKey, this.rootKey))
                {
                    distributedStoreKey.Dispose();
                }
            }
            return(result);
        }
        public AmClusterNodeStatusAccessor(IAmCluster cluster, AmServerName nodeName, DxStoreKeyAccessMode mode = DxStoreKeyAccessMode.Read)
        {
            this.ServerName = nodeName;
            string keyName = string.Format("{0}\\{1}", "ExchangeActiveManager\\NodeState", nodeName.NetbiosName);

            using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(cluster.Handle, null, null, mode, false))
            {
                this.distributedStoreKey = clusterKey.OpenKey(keyName, mode, false, null);
            }
        }