예제 #1
0
        private static void Main(string[] args)
        {
            if (args.Length != 5)
            {
                Console.Out.WriteLine("Broker - Incorrect number of arguments: " + args.Length);
                Console.ReadLine();
                return;
            }

            string processName = args[0];
            string processUrl = args[1];
            string puppetMasterUrl = args[2];
            string siteName = args[3];
            string parentSite = args[4];

            Broker broker = new Broker(processName, processUrl, puppetMasterUrl, siteName, parentSite);
            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = TypeFilterLevel.Full;

            IDictionary prop = new Hashtable();

            int port;
            string serviceName;
            if (!Utility.DivideUrl(processUrl, out port, out serviceName))
            {
                Console.WriteLine("Invalid process URL");
                Console.ReadLine();
                return;
            }

            prop["port"] = port;
            prop["name"] = serviceName;

            try
            {
                TcpChannel channel = new TcpChannel(prop, null, serverProv);
                ChannelServices.RegisterChannel(channel, false);
                RemotingServices.Marshal(broker, prop["name"].ToString(), typeof (IBroker));
            } catch (Exception ex)
            {
                Console.Out.WriteLine("********************************************");
                Console.Out.WriteLine("*\tERROR: A problem occured while registering this service");
                Console.Out.WriteLine("*\t" + ex.Message);
                Console.Out.WriteLine("*********************************************");
                Console.ReadLine();
            }

            Console.WriteLine(@"Running " + processName + " at " + processUrl + " - " + siteName);
            Console.ReadLine();
        }
        public void ProcessFilteredDelivery(Broker broker)
        {
            //we only send the subscription to the brokers that we have not yet subscribed that topic to
            //if the request comes from a broker we do not subscribe that topic to him becouse thats pointless

            string sourceSite = broker.RemoteNetwork.SiteName;

            foreach (KeyValuePair<string, List<IRemoteBroker>> entry in broker.RemoteNetwork.OutBrokers)
            {
                if (!entry.Key.Equals(this.source) && !broker.ReceiveTable.IsSubscribedTo(this.topic, entry.Key))
                {
                    broker.ReceiveTable.AddTopic(this.topic, entry.Key.ToLower());

                    foreach (IRemoteBroker remoteBroker in entry.Value)
                    {
                        try{ remoteBroker.DifundSubscribeEvent(this.topic, sourceSite); }
                        catch(Exception) { /*ignore*/}
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            if (args.Length < 3) return;

            Broker b = new Broker(args[0], args[1], args[2]);
            b.Start();
        }
예제 #4
0
파일: Broker.cs 프로젝트: AndreRog/DAD
        static void Main(string[] args)
        {
            char[] delimiter = { ':', '/' };
            string[] arg = args[2].Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
            Console.WriteLine("Broker Application " + arg[2]);
            Console.WriteLine("Broker Application URL:" + args[3]);
            Console.WriteLine("Broker Application URL:" + args[2]);

            TcpChannel brokerChannel = new TcpChannel(Int32.Parse(arg[2]));
            ChannelServices.RegisterChannel(brokerChannel, false);

            Broker broker = new Broker(args[0], args[3], args[2], args[4], args[5], args[6]);
            RemotingServices.Marshal(broker, "broker", typeof(Broker));
            if (!args[3].Equals("null"))
            {

                IBroker parent = (IBroker)Activator.GetObject(
                    typeof(IBroker),
                    args[3]);

                parent.addChild(args[0], args[2]);
            }

            Console.ReadLine();
        }
예제 #5
0
 public Form1()
 {
     InitializeComponent();
     b = new Broker.Broker();
 }
        public void ProcessFilteredDelivery(Broker broker)
        {
            List<string> entitiesInterested = broker.ForwardingTable.GetInterestedEntities(this.topic);
            int entitiesInterestedCount = entitiesInterested.Count;
            string sourceSite = broker.RemoteNetwork.SiteName;

            //corner case
            //if the single interested entity is a site and we subscribed that topic to him we have to unsubscribe it
            //because they would forward the event to us and we back to them again

            if (entitiesInterestedCount == 1)
            {
                if(broker.ReceiveTable.IsSubscribedTo(this.topic, entitiesInterested[0]))
                {
                    if(broker.RemoteNetwork.GetAllOutSites().Contains(entitiesInterested[0]))
                    {
                        foreach (IRemoteBroker remoteBroker in broker.RemoteNetwork.OutBrokers[entitiesInterested[0]])
                        {
                            try { remoteBroker.DifundUnSubscribeEvent(this.topic, sourceSite); }
                            catch { /*ignore*/}
                        }

                        broker.ReceiveTable.RemoveEntityFromTopic(this.topic, entitiesInterested[0]);
                    }
                }

            }

            //check if we still have someone interested in that topic
            //if not send unsubscribe event to all sites forwarding that event to us
            if (entitiesInterestedCount == 0)
            {
                foreach (string siteName in broker.ReceiveTable.GetCreateTopicList(this.topic))
                {
                    if(!siteName.Equals(this.source))
                    {
                        foreach (IRemoteBroker remoteBroker in broker.RemoteNetwork.OutBrokers[siteName])
                        {
                            try { remoteBroker.DifundUnSubscribeEvent(this.topic, sourceSite); }
                            catch { /*ignore*/}

                        }
                    }
                }

                broker.ReceiveTable.RemoveTopic(this.topic);
            }
        }
 public TotalOrderPublishEventManager(Broker b)
     : base(b)
 {
 }
 protected PublishEventManager(Broker b)
 {
     this.B = b;
 }
 public FIFOPublishEventManager(Broker b)
     : base(b)
 {
 }
 public NoOrderPublishEventManager(Broker b)
     : base(b)
 {
 }
 public ReplicationStorage(Broker b)
 {
     this.storedEvents = new List<StoredEvent>();
     this.tMonitor = new TimeoutMonitor(this);
     this.broker = b;
     this.tooEarlyList = new List<int>();
 }
        private Dictionary<string, List<Tuple<int, string>>> unprocessedTotalOrderMessages; //for sequencer replica store messages not send

        #endregion Fields

        #region Constructors

        public Sequencer(Broker broker)
        {
            this.broker = broker;
            this.nextSeqNumber = 1;
            this.dispatchedNewEventMessages = new Dictionary<string, List<int>>(); //publisher -> eventNr
            this.processedTotalOrderMessages = new Dictionary<string, List<int>>();
            this.unprocessedTotalOrderMessages = new Dictionary<string, List<Tuple<int, string>>>();
            this.totalOrderMessagesACKs = new Dictionary<string, List<int>>();
        }