예제 #1
0
파일: Dctl.cs 프로젝트: erxdkh/azos
        public override string Execute()
        {
            var daemon = Manc.GetApplicationComponentBySIDorName(App, m_Args) as IDaemon;

            if (daemon == null)
            {
                return("The specified component is not an IDaemon");
            }

            var action = m_Args.AttrByName(CONFIG_ACTION_ATTR).ValueAsEnum <Action>();

            switch (action)
            {
            case Action.Start:      { daemon.Start();               return("`{0}` started".Args(daemon)); }

            case Action.SignalStop: { daemon.SignalStop();          return("`{0}` signaled to stop".Args(daemon)); }

            case Action.Stop:       { daemon.WaitForCompleteStop(); return("`{0}` stopped".Args(daemon)); }

            case Action.Config:
            {
                var cdaemon = daemon as IConfigurable;
                if (cdaemon == null)
                {
                    return("This daemon is not IConfigurable");
                }

                var croot = m_Args[CONFIG_ROOT_SECT];

                cdaemon.Configure(croot);

                return("`{0}` configured".Args(daemon));;
            }
            }

            return("Requested daemon action `{0}` is unsupported".Args(action));
        }
예제 #2
0
        public override string Execute()
        {
            var cache = Manc.GetApplicationComponentBySIDorName(App, m_Args) as ICache;

            if (cache == null)
            {
                return("The specified component is not of ICache type");
            }

            var tName = m_Args.AttrByName(CONFIG_TABLE_ATTR).ValueAsString();
            var purge = m_Args.AttrByName(CONFIG_PURGE_ATTR).ValueAsBool();

            var sb = new StringBuilder(1024);

            sb.AppendLine(AppRemoteTerminal.MARKUP_PRAGMA);
            sb.Append("<push><f color=gray>");
            sb.AppendLine("Pile Cache");
            sb.AppendLine("----------------------");

            if (purge)
            {
                sb.AppendLine("<f color=red>Purging:");
            }

            foreach (var tbl in cache.Tables.Where(t => tName == null || t.Name.EqualsOrdIgnoreCase(tName)))
            {
                sb.AppendFormatLine("<f color=yellow>{0,-48}|<f color=white> {1,8:n0}(<f color=cyan>{2,8:n0}<f color=white>)| <f color=darkgray>{3,4:n0}%", tbl.Name, tbl.Count, tbl.Capacity, tbl.LoadFactor * 100d);
                if (purge)
                {
                    tbl.Purge();
                }
            }

            sb.AppendLine("<pop>");
            return(sb.ToString());
        }