当前位置: 首页>>代码示例>>C#>>正文


C# TestingHost.SiloHandle类代码示例

本文整理汇总了C#中Orleans.TestingHost.SiloHandle的典型用法代码示例。如果您正苦于以下问题:C# SiloHandle类的具体用法?C# SiloHandle怎么用?C# SiloHandle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SiloHandle类属于Orleans.TestingHost命名空间,在下文中一共展示了SiloHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetGrainOnTargetSilo

 private async Task<ILongRunningTaskGrain<bool>> GetGrainOnTargetSilo(SiloHandle siloHandle)
 {
     const int maxRetry = 5;
     for (int i = 0; i < maxRetry; i++)
     {
         var grain = HostedCluster.GrainFactory.GetGrain<ILongRunningTaskGrain<bool>>(Guid.NewGuid());
         var instanceId = await grain.GetRuntimeInstanceId();
         if (instanceId.Contains(siloHandle.SiloAddress.Endpoint.ToString()))
         {
             return grain;
         }
     }
     return null;
 }
开发者ID:jdom,项目名称:orleans,代码行数:14,代码来源:SilosStopTests.cs

示例2: TryGetGeneratedAssemblies

        private Dictionary<string, byte[]> TryGetGeneratedAssemblies(SiloHandle siloHandle)
        {
            var tryToRetrieveGeneratedAssemblies = Task.Run(() =>
            {
                try
                {
                    var silo = siloHandle.Silo;
                    if (silo?.TestHook != null)
                    {
                        var generatedAssemblies = new Silo.TestHooks.GeneratedAssemblies();
                        silo.TestHook.UpdateGeneratedAssemblies(generatedAssemblies);

                        return generatedAssemblies.Assemblies;
                    }
                }
                catch (Exception exc)
                {
                    WriteLog("UpdateGeneratedAssemblies threw an exception. Ignoring it. Exception: {0}", exc);
                }

                return null;
            });

            // best effort to try to import generated assemblies, otherwise move on.
            if (tryToRetrieveGeneratedAssemblies.Wait(TimeSpan.FromSeconds(3)))
            {
                return tryToRetrieveGeneratedAssemblies.Result;
            }

            return null;
        }
开发者ID:MikeHardman,项目名称:orleans,代码行数:31,代码来源:TestCluster.cs

示例3: StartOrleansSilo

        public static SiloHandle StartOrleansSilo(TestCluster cluster, Silo.SiloType type, ClusterConfiguration clusterConfig, NodeConfiguration nodeConfig)
        {
            if (cluster == null) throw new ArgumentNullException(nameof(cluster));
            var siloName = nodeConfig.SiloName;

            cluster.WriteLog("Starting a new silo in app domain {0} with config {1}", siloName, clusterConfig.ToString(siloName));
            AppDomain appDomain;
            Silo silo = cluster.LoadSiloInNewAppDomain(siloName, type, clusterConfig, out appDomain);

            silo.Start();

            SiloHandle retValue = new SiloHandle
            {
                Name = siloName,
                Silo = silo,
                NodeConfiguration = nodeConfig,
                Endpoint = silo.SiloAddress.Endpoint,
                AppDomain = appDomain,
            };
            cluster.ImportGeneratedAssemblies(retValue);
            return retValue;
        }
开发者ID:MikeHardman,项目名称:orleans,代码行数:22,代码来源:TestCluster.cs

示例4: GetDetailedGrainReport

 /// <summary>Gets a detailed grain report from a specified silo</summary>
 /// <param name="grainId">The grain id we are requesting information from</param>
 /// <param name="siloHandle">The target silo that should provide this information from it's cache</param>
 internal static Task<DetailedGrainReport> GetDetailedGrainReport(GrainId grainId, SiloHandle siloHandle)
 {
     var siloControl = GrainClient.InternalGrainFactory.GetSystemTarget<ISiloControl>(Constants.SiloControlId, siloHandle.ProxyAddress);
     return siloControl.GetDetailedGrainReport(grainId);
 }
开发者ID:jdom,项目名称:orleans,代码行数:8,代码来源:TestUtils.cs

示例5: ImportGeneratedAssemblies

 /// <summary>
 /// Imports assemblies generated by runtime code generation from the provided silo.
 /// </summary>
 /// <param name="siloHandle">The silo.</param>
 private void ImportGeneratedAssemblies(SiloHandle siloHandle)
 {
     var generatedAssemblies = TryGetGeneratedAssemblies(siloHandle);
     if (generatedAssemblies != null)
     {
         foreach (var assembly in generatedAssemblies)
         {
             // If we have never seen generated code for this assembly before, or generated code might be
             // newer, store it for later silo creation.
             byte[] existing;
             if (!this.additionalAssemblies.TryGetValue(assembly.Key, out existing) || assembly.Value != null)
             {
                 this.additionalAssemblies[assembly.Key] = assembly.Value;
             }
         }
     }
 }
开发者ID:MikeHardman,项目名称:orleans,代码行数:21,代码来源:TestCluster.cs

示例6: RestartSilo

 /// <summary>
 /// Do a Stop or Kill of the specified silo, followed by a restart.
 /// </summary>
 /// <param name="instance">Silo to be restarted.</param>
 public SiloHandle RestartSilo(SiloHandle instance)
 {
     if (instance != null)
     {
         var options = instance.Options;
         var type = instance.Silo.Type;
         StopOrleansSilo(instance, true);
         instance = StartOrleansSilo(type, options, InstanceCounter++);
         return instance;
     }
     return null;
 }
开发者ID:bestwpw,项目名称:orleans,代码行数:16,代码来源:TestingSiloHost.cs

示例7: StartOrleansSilo

        // This is a static version that can be called without a TestingSiloHost object (host = null)
        public static SiloHandle StartOrleansSilo(TestingSiloHost host, Silo.SiloType type, TestingSiloOptions options, int instanceCount, AppDomain shared = null)
        {
            // Load initial config settings, then apply some overrides below.
            ClusterConfiguration config = new ClusterConfiguration();
            if (options.SiloConfigFile == null)
            {
                config.StandardLoad();
            }
            else
            {
                config.LoadFromFile(options.SiloConfigFile.FullName);
            }

            int basePort = options.BasePort < 0 ? BasePort : options.BasePort;

            if (config.Globals.SeedNodes.Count > 0 && options.BasePort < 0)
            {
                config.PrimaryNode = config.Globals.SeedNodes[0];
            }
            else
            {
                config.PrimaryNode = new IPEndPoint(IPAddress.Loopback, basePort);
            }
            config.Globals.SeedNodes.Clear();
            config.Globals.SeedNodes.Add(config.PrimaryNode);

            if (!String.IsNullOrEmpty(DeploymentId))
            {
                config.Globals.DeploymentId = DeploymentId;
            }
            config.Defaults.PropagateActivityId = options.PropagateActivityId;
            if (options.LargeMessageWarningThreshold > 0)
            {
                config.Defaults.LargeMessageWarningThreshold = options.LargeMessageWarningThreshold;
            }

            config.Globals.LivenessType = options.LivenessType;
            config.Globals.ReminderServiceType = options.ReminderServiceType;
            if (!String.IsNullOrEmpty(options.DataConnectionString))
            {
                config.Globals.DataConnectionString = options.DataConnectionString;
            }

            _livenessStabilizationTime = GetLivenessStabilizationTime(config.Globals);

            if (host != null)
            {
                host.Globals = config.Globals;
            }

            string siloName;
            switch (type)
            {
                case Silo.SiloType.Primary:
                    siloName = "Primary";
                    break;
                default:
                    siloName = "Secondary_" + instanceCount.ToString(CultureInfo.InvariantCulture);
                    break;
            }

            NodeConfiguration nodeConfig = config.GetConfigurationForNode(siloName);
            nodeConfig.HostNameOrIPAddress = "loopback";
            nodeConfig.Port = basePort + instanceCount;
            nodeConfig.DefaultTraceLevel = config.Defaults.DefaultTraceLevel;
            nodeConfig.PropagateActivityId = config.Defaults.PropagateActivityId;
            nodeConfig.BulkMessageLimit = config.Defaults.BulkMessageLimit;

            if (nodeConfig.ProxyGatewayEndpoint != null && nodeConfig.ProxyGatewayEndpoint.Address != null)
            {
                int proxyBasePort = options.ProxyBasePort < 0 ? ProxyBasePort : options.ProxyBasePort;
                nodeConfig.ProxyGatewayEndpoint = new IPEndPoint(nodeConfig.ProxyGatewayEndpoint.Address, proxyBasePort + instanceCount);
            }

            config.Globals.ExpectedClusterSize = 2;

            config.Overrides[siloName] = nodeConfig;

            AdjustForTest(config, options);

            WriteLog("Starting a new silo in app domain {0} with config {1}", siloName, config.ToString(siloName));
            AppDomain appDomain;
            Silo silo = LoadSiloInNewAppDomain(siloName, type, config, out appDomain);

            silo.Start();

            SiloHandle retValue = new SiloHandle
            {
                Name = siloName,
                Silo = silo,
                Options = options,
                Endpoint = silo.SiloAddress.Endpoint,
                AppDomain = appDomain,
            };
            ImportGeneratedAssemblies(retValue);
            return retValue;
        }
开发者ID:bestwpw,项目名称:orleans,代码行数:98,代码来源:TestingSiloHost.cs

示例8: RestartSilo

        /// <summary>
        /// Do a Stop or Kill of the specified silo, followed by a restart.
        /// </summary>
        /// <param name="instance">Silo to be restarted.</param>
        public SiloHandle RestartSilo(SiloHandle instance)
        {
            if (instance != null)
            {
                var options = instance.Options;
                var type = instance.Silo.Type;
                StopOrleansSilo(instance, true);
                var newInstance = StartOrleansSilo(type, options, InstanceCounter++);

                if (Primary == instance)
                {
                    Primary = newInstance;
                }
                else if (Secondary == instance)
                {
                    Secondary = newInstance;
                }
                else
                {
                    additionalSilos.Remove(instance);
                    additionalSilos.Add(newInstance);
                }

                return newInstance;
            }
            return null;
        }
开发者ID:vobradovich,项目名称:orleans,代码行数:31,代码来源:TestingSiloHost.cs

示例9: StartOrleansSilo

        /// <summary>
        /// Start a new silo in the target cluster
        /// </summary>
        /// <param name="host">The target cluster</param>
        /// <param name="type">The type of the silo to deploy</param>
        /// <param name="options">The options to use for the silo</param>
        /// <param name="instanceCount">The instance count of the silo</param>
        /// <param name="shared">The shared AppDomain to use</param>
        /// <returns>A handle to the deployed silo</returns>
        public static SiloHandle StartOrleansSilo(TestingSiloHost host, Silo.SiloType type, TestingSiloOptions options, int instanceCount, AppDomain shared = null)
        {
            if (host == null) throw new ArgumentNullException("host");

            // Load initial config settings, then apply some overrides below.
            ClusterConfiguration config = new ClusterConfiguration();
            try
            {
                if (options.SiloConfigFile == null)
                {
                    config.StandardLoad();
                }
                else
                {
                    config.LoadFromFile(options.SiloConfigFile.FullName);
                }
            }
            catch (FileNotFoundException)
            {
                if (options.SiloConfigFile != null
                    && !string.Equals(options.SiloConfigFile.Name, TestingSiloOptions.DEFAULT_SILO_CONFIG_FILE, StringComparison.InvariantCultureIgnoreCase))
                {
                    // if the user is not using the defaults, then throw because the file was legitimally not found
                    throw;
                }

                config = ClusterConfiguration.LocalhostPrimarySilo();
                config.AddMemoryStorageProvider("Default");
                config.AddMemoryStorageProvider("MemoryStore");
            }

            int basePort = options.BasePort < 0 ? BasePort : options.BasePort;


            if (config.Globals.SeedNodes.Count > 0 && options.BasePort < 0)
            {
                config.PrimaryNode = config.Globals.SeedNodes[0];
            }
            else
            {
                config.PrimaryNode = new IPEndPoint(IPAddress.Loopback, basePort);
            }
            config.Globals.SeedNodes.Clear();
            config.Globals.SeedNodes.Add(config.PrimaryNode);

            if (!String.IsNullOrEmpty(host.DeploymentId))
            {
                config.Globals.DeploymentId = host.DeploymentId;
            }

            config.Defaults.PropagateActivityId = options.PropagateActivityId;
            if (options.LargeMessageWarningThreshold > 0)
            {
                config.Defaults.LargeMessageWarningThreshold = options.LargeMessageWarningThreshold;
            }

            config.Globals.LivenessType = options.LivenessType;
            config.Globals.ReminderServiceType = options.ReminderServiceType;
            if (!String.IsNullOrEmpty(options.DataConnectionString))
            {
                config.Globals.DataConnectionString = options.DataConnectionString;
            }

            host.Globals = config.Globals;

            string siloName;
            switch (type)
            {
                case Silo.SiloType.Primary:
                    siloName = "Primary";
                    break;
                default:
                    siloName = "Secondary_" + instanceCount.ToString(CultureInfo.InvariantCulture);
                    break;
            }

            NodeConfiguration nodeConfig = config.GetOrCreateNodeConfigurationForSilo(siloName);
            nodeConfig.HostNameOrIPAddress = "loopback";
            nodeConfig.Port = basePort + instanceCount;
            nodeConfig.DefaultTraceLevel = config.Defaults.DefaultTraceLevel;
            nodeConfig.PropagateActivityId = config.Defaults.PropagateActivityId;
            nodeConfig.BulkMessageLimit = config.Defaults.BulkMessageLimit;

            int? gatewayport = null;
            if (nodeConfig.ProxyGatewayEndpoint != null && nodeConfig.ProxyGatewayEndpoint.Address != null)
            {
                gatewayport = (options.ProxyBasePort < 0 ? ProxyBasePort : options.ProxyBasePort) + instanceCount;
                nodeConfig.ProxyGatewayEndpoint = new IPEndPoint(nodeConfig.ProxyGatewayEndpoint.Address, gatewayport.Value);
            }

            config.Globals.ExpectedClusterSize = 2;
//.........这里部分代码省略.........
开发者ID:vobradovich,项目名称:orleans,代码行数:101,代码来源:TestingSiloHost.cs

示例10: ImportGeneratedAssemblies

 /// <summary>
 /// Imports assemblies generated by runtime code generation from the provided silo.
 /// </summary>
 /// <param name="siloHandle">The silo.</param>
 private static void ImportGeneratedAssemblies(SiloHandle siloHandle)
 {
     try
     {
         var silo = siloHandle.Silo;
         if (silo != null && silo.TestHook != null)
         {
             var generatedAssemblies = new Silo.TestHooks.GeneratedAssemblies();
             silo.TestHook.UpdateGeneratedAssemblies(generatedAssemblies);
             
             foreach (var assembly in generatedAssemblies.Assemblies)
             {
                 // If we have never seen generated code for this assembly before, or generated code might be
                 // newer, store it for later silo creation.
                 byte[] existing;
                 if (!additionalAssemblies.TryGetValue(assembly.Key, out existing) || assembly.Value != null)
                 {
                     additionalAssemblies[assembly.Key] = assembly.Value;
                 }
             }
         }
     }
     catch (Exception exc)
     {
         Console.WriteLine("UpdateGeneratedAssemblies threw an exception. Ignoring it. Exception: {0}", exc);
         return;
     }
 }
开发者ID:danieldeb,项目名称:orleans,代码行数:32,代码来源:TestingSiloHost.cs

示例11: StopOrleansSilo

 private void StopOrleansSilo(SiloHandle instance, bool stopGracefully)
 {
     instance.StopSilo(stopGracefully);
     instance.Dispose();
 }
开发者ID:osjimenez,项目名称:orleans,代码行数:5,代码来源:TestCluster.cs

示例12: StopSilo

 /// <summary>
 /// Do a semi-graceful Stop of the specified silo.
 /// </summary>
 /// <param name="instance">Silo to be stopped.</param>
 public static void StopSilo(SiloHandle instance)
 {
     if (instance != null)
     {
         StopOrleansSilo(instance, true);
     }
 }
开发者ID:bestwpw,项目名称:orleans,代码行数:11,代码来源:TestingSiloHost.cs

示例13: InitializeAsync

        private async Task InitializeAsync(TestingSiloOptions options, TestingClientOptions clientOptions)
        {
            bool doStartPrimary = false;
            bool doStartSecondary = false;

            if (options.StartFreshOrleans)
            {
                // the previous test was !startFresh, so we need to cleanup after it.
                if (Primary != null || Secondary != null || GrainClient.IsInitialized)
                {
                    StopDefaultSilos();
                }

                StopAdditionalSilos();

                if (options.StartPrimary)
                {
                    doStartPrimary = true;
                }
                if (options.StartSecondary)
                {
                    doStartSecondary = true;
                }
            }
            else
            {
                if (options.StartPrimary && Primary == null)
                {
                    // first time.
                    doStartPrimary = true;
                }
                if (options.StartSecondary && Secondary == null)
                {
                    doStartSecondary = true;
                }
            }
            if (options.PickNewDeploymentId && String.IsNullOrEmpty(DeploymentId))
            {
                DeploymentId = GetDeploymentId();
            }

            if (options.ParallelStart)
            {
                var handles = new List<Task<SiloHandle>>();     
                if (doStartPrimary)
                {
                    int instanceCount = InstanceCounter++;
                    handles.Add(Task.Run(() => StartOrleansSilo(Silo.SiloType.Primary, options, instanceCount)));
                }
                if (doStartSecondary)
                {
                    int instanceCount = InstanceCounter++;
                    handles.Add(Task.Run(() => StartOrleansSilo(Silo.SiloType.Secondary, options, instanceCount)));
                }
                await Task.WhenAll(handles.ToArray());
                if (doStartPrimary)
                {
                    Primary = await handles[0];
                }
                if (doStartSecondary)
                {
                    Secondary = await handles[1];
                }
            }else
            {
                if (doStartPrimary)
                {
                    Primary = StartOrleansSilo(Silo.SiloType.Primary, options, InstanceCounter++);
                }
                if (doStartSecondary)
                {
                    Secondary = StartOrleansSilo(Silo.SiloType.Secondary, options, InstanceCounter++);
                }
            }

            if (!GrainClient.IsInitialized && options.StartClient)
            {
                ClientConfiguration clientConfig;
                if (clientOptions.ClientConfigFile != null)
                {
                    clientConfig = ClientConfiguration.LoadFromFile(clientOptions.ClientConfigFile.FullName);
                }
                else
                {
                    clientConfig = ClientConfiguration.StandardLoad();
                }
                if (clientOptions.ProxiedGateway && clientOptions.Gateways != null)
                {
                    clientConfig.Gateways = clientOptions.Gateways;
                    if (clientOptions.PreferedGatewayIndex >= 0)
                        clientConfig.PreferedGatewayIndex = clientOptions.PreferedGatewayIndex;
                }
                if (clientOptions.PropagateActivityId)
                {
                    clientConfig.PropagateActivityId = clientOptions.PropagateActivityId;
                }
                if (!String.IsNullOrEmpty(DeploymentId))
                {
                    clientConfig.DeploymentId = DeploymentId;
                }
//.........这里部分代码省略.........
开发者ID:nahugrau,项目名称:orleans,代码行数:101,代码来源:TestingSiloHost.cs

示例14: KillSilo

 /// <summary>
 /// Do an immediate Kill of the specified silo.
 /// </summary>
 /// <param name="instance">Silo to be killed.</param>
 public static void KillSilo(SiloHandle instance)
 {
     if (instance != null)
     {
         // do NOT stop, just kill directly, to simulate crash.
         StopOrleansSilo(instance, false);
     }
 }
开发者ID:bestwpw,项目名称:orleans,代码行数:12,代码来源:TestingSiloHost.cs

示例15: StopSilo

 /// <summary>
 /// Do a semi-graceful Stop of the specified silo.
 /// </summary>
 /// <param name="instance">Silo to be stopped.</param>
 public void StopSilo(SiloHandle instance)
 {
     if (instance != null)
     {
         StopOrleansSilo(instance, true);
         if (Primary == instance)
         {
             Primary = null;
         }
         else
         {
             additionalSilos.Remove(instance);
         }
     }
 }
开发者ID:MikeHardman,项目名称:orleans,代码行数:19,代码来源:TestCluster.cs


注:本文中的Orleans.TestingHost.SiloHandle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。