Ejemplo n.º 1
0
        public void Stop()
        {
            ExchangeMonitorMessage msg = new ExchangeMonitorMessage("STOP", "Stopping Pipelines", "XCHANGEMESSAGE");

            msg.xid = xid;
            mon?.Send(msg.ToString());

            foreach (Pipeline p in pipes)
            {
                try
                {
                    p.StopPipeLine();
                }
                catch (Exception)
                {
                    //
                }
            }
            // Stop each of the PipeLine threads
            foreach (Thread t in pipeThreads)
            {
                try
                {
                    t.Abort();
                }
                catch (Exception)
                {
                    //
                }
            }
            msg     = new ExchangeMonitorMessage("STOP", "Stopped Pipelines", "XCHANGEMESSAGE");
            msg.xid = xid;
            mon?.Send(msg.ToString());
        }
Ejemplo n.º 2
0
        public void Configure()
        {
            // Read the configuration file and create a Pipeline for each of the defined pipes

            NameValueCollection appSettings = ConfigurationManager.AppSettings;

            Exchange.configFileName = string.IsNullOrEmpty(appSettings["ConfigFileName"]) ? "ExchangeConfig.xml" : appSettings["ConfigFileName"];

            XDocument doc         = XDocument.Load(Exchange.configFileName);
            XElement  monitorDefn = doc.Descendants("monitor").FirstOrDefault();

            try
            {
                if (monitorDefn != null)
                {
                    this.mon = Monitor.Instance;
                    mon.setConfig(monitorDefn);

                    ExchangeMonitorMessage msg = new ExchangeMonitorMessage("START", "Monitor Started", "XCHANGEMESSAGE");
                    msg.xid = xid;
                    mon?.Send(msg.ToString());
                }
            }
            catch (Exception)
            {
                Console.WriteLine("---> Monitor could not be contacted <---");
            }

            IEnumerable <XElement> nsDefn = from n in doc.Descendants("namespace") select n;

            foreach (XElement n in nsDefn)
            {
                nsDict.Add(n.Attribute("prefix").Value, n.Attribute("uri").Value);
            }
            IEnumerable <XElement> pipesDefn = from pipe in doc.Descendants("pipe") select pipe;

            foreach (XElement pipeConfig in pipesDefn)
            {
                // Create the pipeline


                int numInstances;
                try
                {
                    numInstances = int.Parse(pipeConfig.Attribute("numInstances").Value);
                }
                catch (Exception)
                {
                    numInstances = 1;
                }

                for (int i = 0; i < numInstances; i++)
                {
                    Pipeline pipe = new Pipeline(pipeConfig, monitorMessageProgress);
                    pipes.Add(pipe);
                }
            }
        }
Ejemplo n.º 3
0
        private void MonitorStatusMessage(object sender, PipelineMonitorMessage e)
        {
            ExchangeMonitorMessage msg = new ExchangeMonitorMessage(e);

            msg.type = "PIPELINEMESSAGE";
            msg.xid  = xid;

            mon?.Send(msg.ToString());
        }
Ejemplo n.º 4
0
 public void Log(ExchangeMonitorMessage monMess)
 {
     if (!monitorEnabled)
     {
         return;
     }
     lock (logLock)
     {
         if (json)
         {
             _ = Task.Run(() => monitorQueue.SendToOutputAsync(new ExchangeMessage(monMess.ToString())));
         }
         else
         {
             _ = Task.Run(() => monitorQueue.SendToOutputAsync(new ExchangeMessage(monMess.ToString())));
         }
     }
 }
Ejemplo n.º 5
0
 public ExchangeMessage(ExchangeMonitorMessage monMessage)
 {
     payload = monMessage.ToString();
 }