Esempio n. 1
0
        static void Main(string[] args)
        {
            SharedXmlConfigReader cr = new SharedXmlConfigReader();
            var cfg = cr.Load( File.OpenText("../../../../data/SharedConfig.xml") );

            var cl = new Client("cl1", "localhost", 12345);
            cl.Connect();

            LaunchPlan plan1 = new LaunchPlan(
                "plan1",
                new List<AppDef>()
                {
                    new AppDef() { AppIdTuple = new AppIdTuple("m1", "a"), StartupOrder = -1, Dependencies=new List<string>() {"b"} },
                    new AppDef() { AppIdTuple = new AppIdTuple("m1", "b"), StartupOrder = -1, },
                    new AppDef() { AppIdTuple = new AppIdTuple("m1", "c"), StartupOrder = -1, Dependencies=new List<string>() {"b"} },
                    new AppDef() { AppIdTuple = new AppIdTuple("m1", "d"), StartupOrder = -1, Dependencies=new List<string>() {"a"} },
                }
            );

            cl.BroadcastMessage( new LoadPlanMessage(plan1) );

            var messages = cl.ReadMessages();
            foreach( var msg in messages )
            {
                Console.WriteLine("Received: {0}", msg.ToString());

                if( msg.GetType() == typeof(LoadPlanMessage) )
                {
                    LoadPlanMessage m = msg as LoadPlanMessage;
                    Console.WriteLine("  LoadPlan '{0}' ({1} applications)", m.plan.Name, m.plan.getAppDefs().Count<AppDef>());
                }
            }
        }
Esempio n. 2
0
        public void Read1()
        {
            var r = new SharedXmlConfigReader();
            var cfg = r.Load( new StringReader(xml) );

            Assert.IsNotNull(cfg.Plans[0].getAppDefs());
            Assert.AreEqual( "m1.a", cfg.Plans[0].getAppDefs().First().AppIdTuple.ToString() );
        }
Esempio n. 3
0
        public static SharedConfig loadSharedConfig()
        {
            SharedXmlConfigReader cr = new SharedXmlConfigReader();
            string cfgFileName = Path.GetFullPath("../../../../data/SharedConfig.xml");
            try
            {
                return cr.Load(File.OpenText(cfgFileName));
            }
            catch (Exception ex)
            {
                string errorMsg = string.Format("Failed to read configuration from file '{0}'.", cfgFileName);

                log.Error(errorMsg);

                ExceptionDialog.showException(
                    ex,
                    "Configuration Load Error",
                    errorMsg
                );
            }
            return null;
        }