Beispiel #1
0
        public void BroadcastMessage( Message msg )
        {
            if (HandleMessage(msg))
            {
                log.Debug(string.Format("Message handled: {0}", msg.ToString()));
                return;
            }

            log.Debug(string.Format("Broadcasting message: {0}", msg.ToString()));

            // put to message queue for each client, including the sender (agents rely on that!)
            lock( clients )
            {
                foreach( var ci in clients.Values )
                {
                    ci.MsgQueue.Add( msg );
                }
            }
        }
Beispiel #2
0
        void processIncomingMessage(Message msg)
        {
            Type t = msg.GetType();

            if( t != typeof(AppsStateMessage)) // do not log frequent messages
            {
                log.DebugFormat("Incoming Message {0}", msg.ToString());
            }

            if (t == typeof(AppsStateMessage))
            {
                var m = msg as AppsStateMessage;
                updateRemoteAppState(m.appsState);
            }
            else
            if (t == typeof(SelectPlanMessage))
            {
                var m = msg as SelectPlanMessage;
                localOps.SelectPlan(m.plan);
            }
            else
            if (t == typeof(LaunchAppMessage))
            {
                var m = msg as LaunchAppMessage;
                if (m.appIdTuple.MachineId == machineId)
                {
                    localOps.LaunchApp(m.appIdTuple);
                }
            }
            else
            if (t == typeof(KillAppMessage))
            {
                var m = msg as KillAppMessage;
                if (m.appIdTuple.MachineId == machineId)
                {
                    localOps.KillApp(m.appIdTuple);
                }
            }
            else
            if (t == typeof(RestartAppMessage))
            {
                var m = msg as RestartAppMessage;
                if (m.appIdTuple.MachineId == machineId)
                {
                    localOps.RestartApp(m.appIdTuple);
                }
            }
            else
            if (t == typeof(StartPlanMessage))
            {
                var m = msg as StartPlanMessage;
                localOps.StartPlan();
            }
            else
            if (t == typeof(StopPlanMessage))
            {
                var m = msg as StopPlanMessage;
                localOps.StopPlan();
            }
            else
            if (t == typeof(KillPlanMessage))
            {
                var m = msg as KillPlanMessage;
                localOps.KillPlan();
            }
            else
            if (t == typeof(RestartPlanMessage))
            {
                var m = msg as RestartPlanMessage;
                localOps.RestartPlan();
            }
            else
            if (t == typeof(CurrentPlanMessage))
            {
                var m = msg as CurrentPlanMessage;

                // if master's plan is same as ours, do not do anything, othewise load master's plan
                var localPlan = localOps.GetCurrentPlan();
                if (m.plan != null && (localPlan == null || !m.plan.Equals(localPlan)))
                {
                    localOps.SelectPlan(m.plan);
                }
            }
            else
            if (t == typeof(PlanRepoMessage))
            {
                var m = msg as PlanRepoMessage;
                localOps.SetPlanRepo(m.repo);
            }
            else
            if (t == typeof(RemoteOperationErrorMessage))
            {
                var m = msg as RemoteOperationErrorMessage;
                throw new RemoteOperationErrorException(m.Requestor, m.Message, m.Attributes);
            }
        }