Пример #1
0
 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;
     }
 }
Пример #2
0
 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;
     }
 }
        /// <summary>
        /// Constructors -- Registers Orleans system performance counters, 
        /// plus any grain-specific activation conters that can be detected when this installer is run.
        /// </summary>
        public OrleansPerformanceCounterInstaller()
        {
            SerializationTestEnvironment.Initialize();
            Trace.Listeners.Clear();
            var cfg = new NodeConfiguration { TraceFilePattern = null, TraceToConsole = false };
            LogManager.Initialize(cfg);

            consumer = new OrleansPerfCounterTelemetryConsumer();

            if (GrainTypeManager.Instance == null)
            {
                var loader = new SiloAssemblyLoader(new Dictionary<string, SearchOption>());
                var typeManager = new GrainTypeManager(false, loader, new RandomPlacementDefaultStrategy());
                GrainTypeManager.Instance.Start(false);
            }
        }
        /// <summary>
        /// Constructors -- Registers Orleans system performance counters, 
        /// plus any grain-specific activation conters that can be detected when this installer is run.
        /// </summary>
        public OrleansPerformanceCounterInstaller()
        {
            SerializationManager.InitializeForTesting();
            Trace.Listeners.Clear();
            var cfg = new NodeConfiguration { TraceFilePattern = null, TraceToConsole = false };
            LogManager.Initialize(cfg);

            consumer = new OrleansPerfCounterTelemetryConsumer();

            if (GrainTypeManager.Instance == null)
            {
                var loader = new SiloAssemblyLoader(new Dictionary<string, SearchOption>());
                var typeManager = new GrainTypeManager(false, null, loader); // We shouldn't need GrainFactory in this case
                GrainTypeManager.Instance.Start(false);
            }
        }
Пример #5
0
        public void Start(bool strict = true)
        {
            // loading application assemblies now occurs in four phases.
            // 1. We scan the file system for assemblies meeting pre-determined criteria, specified in SiloAssemblyLoader.LoadApplicationAssemblies (called by the constructor).
            // 2. We load those assemblies into memory. In the official distribution of Orleans, this is usually 4 assemblies.
            var loader = new SiloAssemblyLoader();

            // (no more assemblies should be loaded into memory, so now is a good time to log all types registered with the serialization manager)
            SerializationManager.LogRegisteredTypes();

            // 3. We scan types in memory for GrainTypeData objects that describe grain classes and their corresponding grain state classes.
            InitializeGrainClassData(loader, strict);

            // 4. We scan types in memory for grain method invoker objects.
            InitializeInvokerMap(loader, strict);

            InitializeInterfaceMap();
            StreamingInitialize();
        }
Пример #6
0
        public void Start(bool strict = true)
        {
            // loading application assemblies now occurs in four phases.
            // 1. We scan the file system for assemblies meeting pre-determined criteria, specified in SiloAssemblyLoader.LoadApplicationAssemblies (called by the constructor).
            // 2. We load those assemblies into memory. In the official distribution of Orleans, this is usually 4 assemblies.
            var loader = new SiloAssemblyLoader();

            // Generate code for newly loaded assemblies.
            CodeGeneratorManager.GenerateAndCacheCodeForAllAssemblies();

            // (no more assemblies should be loaded into memory, so now is a good time to log all types registered with the serialization manager)
            SerializationManager.LogRegisteredTypes();

            // 3. We scan types in memory for GrainTypeData objects that describe grain classes and their corresponding grain state classes.
            InitializeGrainClassData(loader, strict);

            // 4. We scan types in memory for grain method invoker objects.
            InitializeInvokerMap(loader, strict);

            InitializeInterfaceMap();
            StreamingInitialize();
        }
Пример #7
0
 private void InitializeGrainClassData(SiloAssemblyLoader loader, bool strict)
 {
     grainTypes = loader.GetGrainClassTypes(strict);
 }
Пример #8
0
        /// <summary>
        /// Create the set of Orleans counters, if they do not already exist
        /// </summary>
        /// <param name="useBruteForce">Use brute force, if necessary</param>
        /// <remarks>Note: Program needs to be running as Administrator to be able to register Windows perf counters.</remarks>
        private static void RegisterWindowsPerfCounters(bool useBruteForce)
        {
            try
            {
                if (OrleansPerfCounterTelemetryConsumer.AreWindowsPerfCountersAvailable())
                {
                    if (!useBruteForce)
                    {
                        ConsoleText.WriteStatus("Orleans counters are already registered -- Use brute-force mode to re-initialize");
                        return;
                    }

                    // Delete any old perf counters
                    UnregisterWindowsPerfCounters(true);
                }

                if (GrainTypeManager.Instance == null)
                {
                    var loader = new SiloAssemblyLoader(new Dictionary<string, SearchOption>());
                    var typeManager = new GrainTypeManager(false, loader, new RandomPlacementDefaultStrategy()); 
                    GrainTypeManager.Instance.Start(false);
                }
                // Register perf counters
                perfCounterConsumer.InstallCounters();

                if (OrleansPerfCounterTelemetryConsumer.AreWindowsPerfCountersAvailable())
                    ConsoleText.WriteStatus("Orleans counters registered successfully");
                else
                    ConsoleText.WriteError("Orleans counters are NOT registered");
            }
            catch (Exception exc)
            {
                ConsoleText.WriteError("Error registering Orleans counters - {0}" + exc);
                throw;
            }
        }
Пример #9
0
 private void InitializeGrainClassData(SiloAssemblyLoader loader, bool strict)
 {
     grainTypes            = loader.GetGrainClassTypes(strict);
     LogManager.GrainTypes = this.grainTypes.Keys.ToList();
 }
Пример #10
0
 public GrainTypeManager(ILocalSiloDetails siloDetails, SiloAssemblyLoader loader, DefaultPlacementStrategy defaultPlacementStrategy, SerializationManager serializationManager, MultiClusterRegistrationStrategyManager multiClusterRegistrationStrategyManager)
     : this(siloDetails.SiloAddress.Endpoint.Address.Equals(IPAddress.Loopback), loader, defaultPlacementStrategy, serializationManager, multiClusterRegistrationStrategyManager)
 {
 }
Пример #11
0
 private void InitializeInvokerMap(SiloAssemblyLoader loader, bool strict)
 {
     IEnumerable<KeyValuePair<int, Type>> types = loader.GetGrainMethodInvokerTypes(strict);
     foreach (var i in types)
     {
         int ifaceId = i.Key;
         Type type = i.Value;
         AddInvokerClass(ifaceId, type);
     }
 }
Пример #12
0
 private void InitializeGrainClassData(SiloAssemblyLoader loader, bool strict)
 {
     grainTypes = loader.GetGrainClassTypes(strict);
 }
Пример #13
0
 public GrainTypeManager(SiloInitializationParameters silo, SiloAssemblyLoader loader, DefaultPlacementStrategy defaultPlacementStrategy)
     : this(silo.SiloAddress.Endpoint.Address.Equals(IPAddress.Loopback), loader, defaultPlacementStrategy)
 {
 }
Пример #14
0
 public GrainTypeManager(SiloInitializationParameters silo, SiloAssemblyLoader loader, DefaultPlacementStrategy defaultPlacementStrategy)
     : this(silo.SiloAddress.Endpoint.Address.Equals(IPAddress.Loopback), loader, defaultPlacementStrategy)
 {
 }
Пример #15
0
 private void InitializeGrainClassData(SiloAssemblyLoader loader)
 {
     grainTypes = loader.GrainClassTypeData;
 }
Пример #16
0
 private void InitializeGrainClassData(SiloAssemblyLoader loader)
 {
     grainTypes            = loader.GetGrainClassTypes();
     CrashUtils.GrainTypes = this.grainTypes.Keys.ToList();
 }