internal void AddMap(GrainInterfaceMap map) { foreach (var kvp in map.typeToInterfaceData) { if (!typeToInterfaceData.ContainsKey(kvp.Key)) { typeToInterfaceData.Add(kvp.Key, kvp.Value); } } foreach (var kvp in map.table) { if (!table.ContainsKey(kvp.Key)) { table.Add(kvp.Key, kvp.Value); } } foreach (var grainClassTypeCode in map.unordered) { unordered.Add(grainClassTypeCode); } foreach (var kvp in map.implementationIndex) { if (!implementationIndex.ContainsKey(kvp.Key)) { implementationIndex.Add(kvp.Key, kvp.Value); } } }
public GrainTypeManager( ILocalSiloDetails siloDetails, IApplicationPartManager applicationPartManager, DefaultPlacementStrategy defaultPlacementStrategy, SerializationManager serializationManager, MultiClusterRegistrationStrategyManager multiClusterRegistrationStrategyManager, ILogger <GrainTypeManager> logger, IOptions <GrainClassOptions> grainClassOptions) { var localTestMode = siloDetails.SiloAddress.Endpoint.Address.Equals(IPAddress.Loopback); this.logger = logger; this.defaultPlacementStrategy = defaultPlacementStrategy.PlacementStrategy; this.serializationManager = serializationManager; this.multiClusterRegistrationStrategyManager = multiClusterRegistrationStrategyManager; grainInterfaceMap = new GrainInterfaceMap(localTestMode, this.defaultPlacementStrategy); ClusterGrainInterfaceMap = grainInterfaceMap; grainInterfaceMapsBySilo = new Dictionary <SiloAddress, GrainInterfaceMap>(); var grainClassFeature = applicationPartManager.CreateAndPopulateFeature <GrainClassFeature>(); this.grainTypes = CreateGrainTypeMap(grainClassFeature, grainClassOptions.Value); var grainInterfaceFeature = applicationPartManager.CreateAndPopulateFeature <GrainInterfaceFeature>(); this.invokers = CreateInvokerMap(grainInterfaceFeature); this.InitializeInterfaceMap(); }
public GrainTypeManager( ILocalSiloDetails siloDetails, IApplicationPartManager applicationPartManager, PlacementStrategy defaultPlacementStrategy, SerializationManager serializationManager, ILogger <GrainTypeManager> logger, IOptions <GrainClassOptions> grainClassOptions) { this.logger = logger; this.defaultPlacementStrategy = defaultPlacementStrategy; this.serializationManager = serializationManager; grainInterfaceMap = new GrainInterfaceMap(this.defaultPlacementStrategy); ClusterGrainInterfaceMap = grainInterfaceMap; GrainTypeResolver = grainInterfaceMap.GetGrainTypeResolver(); grainInterfaceMapsBySilo = new Dictionary <SiloAddress, GrainInterfaceMap>(); var grainClassFeature = applicationPartManager.CreateAndPopulateFeature <GrainClassFeature>(); this.grainTypes = CreateGrainTypeMap(grainClassFeature, grainClassOptions.Value); var grainInterfaceFeature = applicationPartManager.CreateAndPopulateFeature <GrainInterfaceFeature>(); this.invokers = CreateInvokerMap(grainInterfaceFeature); this.InitializeInterfaceMap(); }
public GrainTypeManager(bool localTestMode, SiloAssemblyLoader loader, DefaultPlacementStrategy defaultPlacementStrategy, SerializationManager serializationManager, MultiClusterRegistrationStrategyManager multiClusterRegistrationStrategyManager) { this.defaultPlacementStrategy = defaultPlacementStrategy.PlacementStrategy; this.loader = loader; this.serializationManager = serializationManager; this.multiClusterRegistrationStrategyManager = multiClusterRegistrationStrategyManager; grainInterfaceMap = new GrainInterfaceMap(localTestMode, this.defaultPlacementStrategy); ClusterGrainInterfaceMap = grainInterfaceMap; grainInterfaceMapsBySilo = new Dictionary <SiloAddress, GrainInterfaceMap>(); }
public GrainTypeManager(bool localTestMode, IGrainFactory grainFactory) { this.grainFactory = grainFactory; grainInterfaceMap = new GrainInterfaceMap(localTestMode); lock (lockable) { if (Instance != null) throw new InvalidOperationException("An attempt to create a second insance of GrainTypeManager."); Instance = this; } }
public GrainTypeManager(bool localTestMode, SiloAssemblyLoader loader, DefaultPlacementStrategy defaultPlacementStrategy) { this.defaultPlacementStrategy = defaultPlacementStrategy.PlacementStrategy; this.loader = loader; grainInterfaceMap = new GrainInterfaceMap(localTestMode, this.defaultPlacementStrategy); lock (lockable) { if (Instance != null) throw new InvalidOperationException("An attempt to create a second insance of GrainTypeManager."); Instance = this; } }
public GrainTypeManager(bool localTestMode) { grainInterfaceMap = new GrainInterfaceMap(localTestMode); lock (lockable) { if (Instance != null) { throw new InvalidOperationException("An attempt to create a second insance of GrainTypeManager."); } Instance = this; } }
public GrainTypeManager(ILocalSiloDetails siloDetails, SiloAssemblyLoader loader, DefaultPlacementStrategy defaultPlacementStrategy, SerializationManager serializationManager, MultiClusterRegistrationStrategyManager multiClusterRegistrationStrategyManager) { var localTestMode = siloDetails.SiloAddress.Endpoint.Address.Equals(IPAddress.Loopback); this.defaultPlacementStrategy = defaultPlacementStrategy.PlacementStrategy; this.loader = loader; this.serializationManager = serializationManager; this.multiClusterRegistrationStrategyManager = multiClusterRegistrationStrategyManager; grainInterfaceMap = new GrainInterfaceMap(localTestMode, this.defaultPlacementStrategy); ClusterGrainInterfaceMap = grainInterfaceMap; grainInterfaceMapsBySilo = new Dictionary <SiloAddress, GrainInterfaceMap>(); }
public GrainTypeManager(bool localTestMode, IGrainFactory grainFactory, SiloAssemblyLoader loader) { this.grainFactory = grainFactory; this.loader = loader; grainInterfaceMap = new GrainInterfaceMap(localTestMode); lock (lockable) { if (Instance != null) { throw new InvalidOperationException("An attempt to create a second insance of GrainTypeManager."); } Instance = this; } }
public GrainTypeManager(bool localTestMode, SiloAssemblyLoader loader, DefaultPlacementStrategy defaultPlacementStrategy) { this.defaultPlacementStrategy = defaultPlacementStrategy.PlacementStrategy; this.loader = loader; grainInterfaceMap = new GrainInterfaceMap(localTestMode, this.defaultPlacementStrategy); lock (lockable) { if (Instance != null) { throw new InvalidOperationException("An attempt to create a second insance of GrainTypeManager."); } Instance = this; } }
public GrainTypeManager(bool localTestMode, SiloAssemblyLoader loader, DefaultPlacementStrategy defaultPlacementStrategy, SerializationManager serializationManager) { this.defaultPlacementStrategy = defaultPlacementStrategy.PlacementStrategy; this.loader = loader; this.serializationManager = serializationManager; grainInterfaceMap = new GrainInterfaceMap(localTestMode, this.defaultPlacementStrategy); ClusterGrainInterfaceMap = grainInterfaceMap; grainInterfaceMapsBySilo = new Dictionary <SiloAddress, GrainInterfaceMap>(); lock (lockable) { if (Instance != null) { throw new InvalidOperationException("An attempt to create a second insance of GrainTypeManager."); } Instance = this; } }
public GrainTypeManager(SiloInitializationParameters silo, SiloAssemblyLoader loader, DefaultPlacementStrategy defaultPlacementStrategy) { var localTestMode = silo.SiloAddress.Endpoint.Address.Equals(IPAddress.Loopback); this.defaultPlacementStrategy = defaultPlacementStrategy.PlacementStrategy; this.loader = loader; grainInterfaceMap = new GrainInterfaceMap(localTestMode, this.defaultPlacementStrategy); ClusterGrainInterfaceMap = grainInterfaceMap; grainInterfaceMapsBySilo = new Dictionary <SiloAddress, GrainInterfaceMap>(); lock (lockable) { if (Instance != null) { throw new InvalidOperationException("An attempt to create a second insance of GrainTypeManager."); } Instance = this; } }
private void RebuildFullGrainInterfaceMap() { var newClusterGrainInterfaceMap = new GrainInterfaceMap(false, this.defaultPlacementStrategy); var newSupportedSilosByTypeCode = new Dictionary <int, List <SiloAddress> >(); var newSupportedSilosByInterface = new Dictionary <int, Dictionary <ushort, List <SiloAddress> > >(); foreach (var kvp in grainInterfaceMapsBySilo) { newClusterGrainInterfaceMap.AddMap(kvp.Value); foreach (var supportedInterface in kvp.Value.SupportedInterfaces) { var ifaceId = supportedInterface.InterfaceId; var version = supportedInterface.InterfaceVersion; var supportedSilosByVersion = newSupportedSilosByInterface.GetValueOrAddNew(ifaceId); var supportedSilosForVersion = supportedSilosByVersion.GetValueOrAddNew(version); supportedSilosForVersion.Add(kvp.Key); } foreach (var grainClassData in kvp.Value.SupportedGrainClassData) { var grainType = grainClassData.GrainTypeCode; var supportedSilos = newSupportedSilosByTypeCode.GetValueOrAddNew(grainType); supportedSilos.Add(kvp.Key); } } foreach (var silos in newSupportedSilosByTypeCode.Values) { // We need to sort this so the list of silos returned will // be the same accross all silos in the cluster silos.Sort(); } ClusterGrainInterfaceMap = newClusterGrainInterfaceMap; GrainTypeResolver = ClusterGrainInterfaceMap.GetGrainTypeResolver(); supportedSilosByTypeCode = newSupportedSilosByTypeCode; supportedSilosByInterface = newSupportedSilosByInterface; }
private void RebuildFullGrainInterfaceMap() { var newClusterGrainInterfaceMap = new GrainInterfaceMap(false, defaultPlacementStrategy); var newSupportedSilosByTypeCode = new Dictionary <int, IList <SiloAddress> >(); newClusterGrainInterfaceMap.AddMap(grainInterfaceMap); foreach (var kvp in grainInterfaceMapsBySilo) { newClusterGrainInterfaceMap.AddMap(kvp.Value); foreach (var grainType in kvp.Value.SupportedGrainTypes) { IList <SiloAddress> supportedSilos; if (!newSupportedSilosByTypeCode.TryGetValue(grainType, out supportedSilos)) { newSupportedSilosByTypeCode[grainType] = supportedSilos = new List <SiloAddress>(); } supportedSilos.Add(kvp.Key); } } ClusterGrainInterfaceMap = newClusterGrainInterfaceMap; supportedSilosByTypeCode = newSupportedSilosByTypeCode; }
public bool TryGetGrainClassData(Type interfaceType, out GrainClassData implementation, string grainClassNamePrefix) { implementation = null; GrainInterfaceData interfaceData; // First, try to find a non-generic grain implementation: if (this.typeToInterfaceData.TryGetValue(GrainInterfaceMap.GetTypeKey(interfaceType, false), out interfaceData) && TryGetGrainClassData(interfaceData, out implementation, grainClassNamePrefix)) { return(true); } // If a concrete implementation was not found and the interface is generic, // try to find a generic grain implementation: if (interfaceType.IsGenericType && this.typeToInterfaceData.TryGetValue(GrainInterfaceMap.GetTypeKey(interfaceType, true), out interfaceData) && TryGetGrainClassData(interfaceData, out implementation, grainClassNamePrefix)) { return(true); } return(false); }
private void RebuildFullGrainInterfaceMap() { var newClusterGrainInterfaceMap = new GrainInterfaceMap(false, this.defaultPlacementStrategy); var newSupportedSilosByTypeCode = new Dictionary <int, List <SiloAddress> >(); var newSupportedSilosByInterface = new Dictionary <int, Dictionary <ushort, List <SiloAddress> > >(); var newInterfaceVersions = new Dictionary <int, HashSet <ushort> >(); foreach (var kvp in grainInterfaceMapsBySilo) { newClusterGrainInterfaceMap.AddMap(kvp.Value); foreach (var supportedInterface in kvp.Value.SupportedInterfaces) { var ifaceId = supportedInterface.InterfaceId; var version = supportedInterface.InterfaceVersion; var ifaceVersions = newInterfaceVersions.GetValueOrAddNew(ifaceId); ifaceVersions.Add(version); var supportedSilosByVersion = newSupportedSilosByInterface.GetValueOrAddNew(ifaceId); var supportedSilosForVersion = supportedSilosByVersion.GetValueOrAddNew(version); supportedSilosForVersion.Add(kvp.Key); } foreach (var grainClassData in kvp.Value.SupportedGrainClassData) { var grainType = grainClassData.GrainTypeCode; var supportedSilos = newSupportedSilosByTypeCode.GetValueOrAddNew(grainType); supportedSilos.Add(kvp.Key); } } ClusterGrainInterfaceMap = newClusterGrainInterfaceMap; supportedSilosByTypeCode = newSupportedSilosByTypeCode; supportedSilosByInterface = newSupportedSilosByInterface; supportedSilosCache = new ConcurrentDictionary <Tuple <int, int, ushort>, List <SiloAddress> >(); }
// used for testing to (carefully!) allow two clients in the same process internal void StartInternal() { transport.Start(); TraceLogger.MyIPEndPoint = transport.MyAddress.Endpoint; // transport.MyAddress is only set after transport is Started. CurrentActivationAddress = ActivationAddress.NewActivationAddress(transport.MyAddress, clientId); ClientStatistics = new ClientStatisticsManager(config); ClientStatistics.Start(config, statisticsProviderManager, transport, clientId) .WaitWithThrow(initTimeout); listeningCts = new CancellationTokenSource(); var ct = listeningCts.Token; listenForMessages = true; // Keeping this thread handling it very simple for now. Just queue task on thread pool. Task.Factory.StartNew(() => { try { RunClientMessagePump(ct); } catch(Exception exc) { logger.Error(ErrorCode.Runtime_Error_100326, "RunClientMessagePump has thrown exception", exc); } } ); grainInterfaceMap = transport.GetTypeCodeMap(grainFactory).Result; StreamingInitialize(); }
internal void Start() { grainInterfaceMap = typeManager.GetTypeCodeMap(); }
internal void Start() { grainInterfaceMap = typeManager.GetTypeCodeMap(); }
internal void AddMap(GrainInterfaceMap map) { foreach (var kvp in map.typeToInterfaceData) { if (!typeToInterfaceData.ContainsKey(kvp.Key)) { typeToInterfaceData.Add(kvp.Key, kvp.Value); } } foreach (var kvp in map.table) { if (!table.ContainsKey(kvp.Key)) { table.Add(kvp.Key, kvp.Value); } } foreach (var grainClassTypeCode in map.unordered) { unordered.Add(grainClassTypeCode); } foreach (var kvp in map.implementationIndex) { if (!implementationIndex.ContainsKey(kvp.Key)) { implementationIndex.Add(kvp.Key, kvp.Value); } } }
internal GrainClassData(int grainTypeCode, string grainClass, bool isGeneric, GrainInterfaceMap.GrainInterfaceData interfaceData, PlacementStrategy placement, MultiClusterRegistrationStrategy registrationStrategy) { GrainTypeCode = grainTypeCode; GrainClass = grainClass; this.isGeneric = isGeneric; this.interfaceData = interfaceData; genericClassNames = new Dictionary<string, string>(); // TODO: initialize only for generic classes placementStrategy = placement ?? PlacementStrategy.GetDefault(); this.registrationStrategy = registrationStrategy ?? MultiClusterRegistrationStrategy.GetDefault(); }