public void AddBroker(BrokerCircle bro) { if (!brokers.Exists(n => n.name == bro.name)) { brokers.Add(bro); } }
public void UnsubscribeBroker(string processname, string topic) { new Task(() => { lock (Broker.monitorLock) { while (Broker.frozen) { Monitor.Wait(Broker.monitorLock); } } if (Broker.leader) { foreach (IBroker broker in Broker.replicaBrokers) { try { broker.UnsubscribeBroker(processname, topic); } catch (Exception e) { Console.WriteLine("Error somewhere: " + e.Message); } } } BrokerCircle bro = Broker.neighbourBrokers.Find(n => n.name == processname); if (bro != null) { lock (Broker.subscriptionMutex) { // Console.WriteLine( "BRO " + processname + " just unsubscribed from " + topic ); Broker.subscriptionCircles.RemoveTopicBroker(topic, processname); //if ( Broker.parent != null ) { bool a = !Broker.topicSubscribers.HasTopic(topic); bool b = !Broker.subscriptionCircles.HasTopic(topic); if (a && b) { Broker.EraseRelatedEvents(topic); if (Broker.leader) { foreach (BrokerCircle broker in Broker.neighbourBrokers) { if (broker.name != processname) { broker.UnsubscribeBroker(Broker.groupName, topic); } } //coiso.broker.SendContent( evt ); } } //} } } }).Start(); }
public void RegisterBrokers( List<string> addresses ) { // Subscriber doesn't need to know the broker's name BrokerCircle brokerCircle = new BrokerCircle( "" ); int id = 0; foreach ( string address in addresses ) { brokerCircle.AddBroker( (IBroker)Activator.GetObject( typeof( IBroker ), address ), id ); id++; } Subscriber.brokerCircle = brokerCircle; }
public void AddTopicBroker( string topic, BrokerCircle bro ) { BrokerCircleTopicList entry = FindTopic( topic ); if ( entry != null ) { entry.AddBroker( bro ); return; } entry = new BrokerCircleTopicList(); entry.topic = topic; entry.AddBroker( bro ); table.Add( entry ); }
public void RegisterBrokers(List <string> addresses) { // Subscriber doesn't need to know the broker's name BrokerCircle brokerCircle = new BrokerCircle(""); int id = 0; foreach (string address in addresses) { brokerCircle.AddBroker((IBroker)Activator.GetObject(typeof(IBroker), address), id); id++; } Subscriber.brokerCircle = brokerCircle; }
// Puppet Master public void RegisterChildReplication(List <string> addresses, string name) { BrokerCircle brokerCircle = new BrokerCircle(name); int id = 0; foreach (string address in addresses) { brokerCircle.AddBroker((IBroker)Activator.GetObject(typeof(IBroker), address), id); id++; } // Add circle to a list of neighbour circles Broker.neighbourBrokers.Add(brokerCircle); }
public void AddTopicBroker(string topic, BrokerCircle bro) { BrokerCircleTopicList entry = FindTopic(topic); if (entry != null) { entry.AddBroker(bro); return; } entry = new BrokerCircleTopicList(); entry.topic = topic; entry.AddBroker(bro); table.Add(entry); }
public void SubscribeBroker(string processname, string topic) { new Task(() => { lock (Broker.monitorLock) { while (Broker.frozen) { Monitor.Wait(Broker.monitorLock); } } if (Broker.leader) { foreach (IBroker broker in Broker.replicaBrokers) { try { broker.SubscribeBroker(processname, topic); } catch (Exception e) { Console.WriteLine("Error somewhere: " + e.Message); } } } BrokerCircle bro = Broker.neighbourBrokers.Find(n => n.name == processname); if (bro != null) { lock (Broker.subscriptionMutex) { //Console.WriteLine( "BRO " + processname + " just subscribed to " + topic ); Broker.subscriptionCircles.AddTopicBroker(topic, bro); if (Broker.leader) { foreach (BrokerCircle broker in Broker.neighbourBrokers) { if (broker.name != processname) { broker.SubscribeBroker(Broker.groupName, topic); } } //coiso.broker.SendContent( evt ); } } } }).Start(); }
// Puppet Master public void RegisterChildReplication( List<string> addresses, string name ) { BrokerCircle brokerCircle = new BrokerCircle( name ); int id = 0; foreach ( string address in addresses ) { brokerCircle.AddBroker( (IBroker)Activator.GetObject( typeof( IBroker ), address ), id ); id++; } // Add circle to a list of neighbour circles Broker.neighbourBrokers.Add( brokerCircle ); }
public void AddBroker( BrokerCircle bro ) { if ( !brokers.Exists( n => n.name == bro.name ) ) { brokers.Add( bro ); } }