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: 0x060005E8 RID: 1512 RVA: 0x00016464 File Offset: 0x00014664 public CachedChannelFactory <IDxStoreAccess> GetFactory(string nodeName = null, WcfTimeout wcfTimeout = null) { if (this.GroupConfig.Settings.IsUseHttpTransportForClientCommunication) { return(null); } CachedChannelFactory <IDxStoreAccess> cachedChannelFactory = null; bool flag = false; if (this.IsSelf(nodeName)) { cachedChannelFactory = this.localChannelFactory; flag = true; } if (cachedChannelFactory == null) { ServiceEndpoint storeAccessEndpoint = EndpointBuilder.GetStoreAccessEndpoint(this.GroupConfig, nodeName, this.IsDefaultGroupIdentifier(this.GroupConfig.Name), false, wcfTimeout); cachedChannelFactory = this.GetFactoryByEndPoint(storeAccessEndpoint); } if (flag && this.localChannelFactory == null) { this.localChannelFactory = cachedChannelFactory; } return(cachedChannelFactory); }
public void TestGetChannelIsCached() { Channel channel1 = CachedChannelFactory.GetChannel(config); Channel channel2 = CachedChannelFactory.GetChannel(config); Assert.AreEqual(channel1, channel2); }
public void TestGetChannelRemovesClosedChannels() { Channel channel1 = CachedChannelFactory.GetChannel(config); channel1.ShutdownAsync().Wait(); Channel channel2 = CachedChannelFactory.GetChannel(config); Assert.AreNotEqual(channel1, channel2); }
// 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)); }
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)); }