Ejemplo n.º 1
0
        private static void RunCommand(string command, string[] args)
        {
            GrainClient.Initialize();

            systemManagement = ManagementGrainFactory.GetGrain(RuntimeInterfaceConstants.SYSTEM_MANAGEMENT_ID);
            Dictionary <string, string> options = args.Skip(1)
                                                  .Where(s => s.StartsWith("-"))
                                                  .Select(s => s.Substring(1).Split('='))
                                                  .ToDictionary(a => a[0].ToLowerInvariant(), a => a.Length > 1 ? a[1] : "");

            var restWithoutOptions = args.Skip(1).Where(s => !s.StartsWith("-")).ToArray();

            switch (command)
            {
            case "grainstats":
                PrintSimpleGrainStatistics(restWithoutOptions);
                break;

            case "fullgrainstats":
                PrintGrainStatistics(restWithoutOptions);
                break;

            case "collect":
                CollectActivations(options, restWithoutOptions);
                break;

            case "unregister":
                var unregisterArgs = args.Skip(1).ToArray();
                UnregisterGrain(unregisterArgs);
                break;

            case "lookup":
                var lookupArgs = args.Skip(1).ToArray();
                LookupGrain(lookupArgs);
                break;

            case "grainreport":
                var grainReportArgs = args.Skip(1).ToArray();
                GrainReport(grainReportArgs);
                break;

            default:
                PrintUsage();
                break;
            }
        }
Ejemplo n.º 2
0
        static async Task Subscribe()
        {
            var orleans = ManagementGrainFactory.GetGrain(0);
            var hosts   = await orleans.GetHosts(true);

            foreach (var silo in hosts)
            {
                var address = silo.Key;
                var status  = silo.Value;

                if (status != SiloStatus.Active)
                {
                    continue;
                }

                var id  = HubGateway.HubId(address.Endpoint);
                var hub = MvcApplication.System.ActorOf <Hub>(id);

                await hub.Tell(new Subscribe { Observer = observer });
            }
        }