Exemplo n.º 1
0
 public void RemoveBroker(Broker broker) {
 	if (Brokers.Contains(broker)) {
 		Brokers.Remove(broker) ;
 	}
 	
 	broker.Shutdown() ;	
 }
Exemplo n.º 2
0
		public Agent(Broker broker, long agentBank, string label)
		{
			this.Broker = broker ;
			this.BrokerBank = broker.BrokerBank() ;
			this.AgentBank = agentBank ;
			this.label = label ;
		}
Exemplo n.º 3
0
        public void AddBroker(string url) {
				BrokerURL brokerurl = GetBrokerURL(url) ;
                Broker broker = new Broker(this, brokerurl)  ;
                Brokers.Add(broker) ;
                
                Dictionary<string, object> args = new Dictionary<string, object>() ;
                args.Add("_class", "agent") ;
                args.Add("_broker", broker) ;
                this.GetObjects(args) ;
        }
Exemplo n.º 4
0
		public void HandleContentIndicator(Broker broker, IDecoder decoder, long sequence, bool hasProperties, bool hasStatistics) {
		
			ClassKey key = new ClassKey(decoder) ;
			SchemaClass sClass = null ;;
			lock (LockObject) {
				sClass = GetSchema(key, false) ;
			}
			if (sClass != null) {
			    QMFObject obj = this.CreateQMFObject(sClass, decoder, hasProperties, hasStatistics, true) ;
				
				if (key.PackageName.Equals("org.apache.qpid.broker") && key.ClassName.Equals("agent") && hasProperties) {
					broker.UpdateAgent(obj) ;
				}
				
				lock (LockObject) {
					if (SyncSequenceList.Contains(sequence)) {
						if (!obj.IsDeleted() && this.SelectMatch(obj)) {
							GetResult.Add(obj) ;
						}	
					}
				}
				
				if (Console != null) {
					if (hasProperties) {
						Console.ObjectProperties(broker, obj) ;
					}
					if (hasStatistics) {
						Console.ObjectStatistics(broker, obj) ;	
					}
				}
			}
		}
Exemplo n.º 5
0
		public void HandlePackageIndicator(Broker broker, IDecoder decoder, long sequence) {
			string packageName = decoder.ReadStr8() ;
			bool notify = false ;
			if (!Packages.ContainsKey(packageName)) {
				lock (LockObject) {
					Packages[packageName] = new Dictionary<string, SchemaClass>() ;
					notify = true ;
				}
			}
			
			if (notify && Console != null) {
				Console.NewPackage(packageName) ;
			}
			
			broker.IncrementOutstanding() ;
			long seq = SequenceManager.Reserve(Session.CONTEXT_STARTUP) ; 
			IEncoder enc = broker.CreateEncoder('Q', seq) ;			
			enc.WriteStr8(packageName) ;	
			broker.Send(enc) ;
		}		
Exemplo n.º 6
0
		public void HandleEventIndicator(Broker broker, IDecoder decoder, long sequence) {
			if (Console != null) {
				QMFEvent newEvent = new QMFEvent(this, decoder) ;
				Console.EventRecieved(broker, newEvent) ;
			}			
		}		
Exemplo n.º 7
0
		public void HandleSchemaResponse(Broker broker, IDecoder decoder, long sequence) {
			short kind = decoder.ReadUint8() ;	
			ClassKey classKey = new ClassKey(decoder) ;
			SchemaClass sClass = new SchemaClass(kind, classKey, decoder, this) ;				
			lock(LockObject) {
				Dictionary<string, SchemaClass> classMappings = Packages[sClass.PackageName] ;
				classMappings.Remove(sClass.ClassKeyString) ;
				classMappings.Add(sClass.ClassKeyString, sClass) ;
			}
			
			SequenceManager.Release(sequence) ;
			broker.DecrementOutstanding() ;
			if (Console != null) {
				this.Console.NewClass(kind, classKey) ;
			}	
		}	
Exemplo n.º 8
0
		public void HandleMethodResponse(Broker broker, IDecoder decoder, long sequence) {	
			long code = decoder.ReadUint32() ;
			string text = decoder.ReadStr16() ;
			
			Dictionary<string, object> outArgs = new Dictionary<string, object>() ;
			object obj = SequenceManager.Release(sequence) ;
			
			if (obj == null) { 
				return ;
			}
			
			KeyValuePair<SchemaMethod, bool> pair = (KeyValuePair<SchemaMethod, bool>) obj  ;			
			if (code == 0) {
				foreach (SchemaArgument arg in pair.Key.Arguments) {
					if (arg.IsOutput()) {
						outArgs.Add(arg.Name, this.DecodeValue(decoder, arg.Type)) ;	
					}
				}
			}
			
			MethodResult result = new MethodResult(code, text, outArgs) ;
			
			if (pair.Value) {
				this.SyncResult = result;
				broker.SetSyncInFlight(false) ;
			}
			
			if (Console != null) {
				Console.MethodResponse(broker, sequence, result) ;
			}	
		}	
Exemplo n.º 9
0
		public void HandleHeartbeatIndicator(Broker broker, IDecoder decoder, long sequence, IMessage msg) {
			if (Console != null) {
				long brokerBank = 1 ;
				long agentBank = 0 ;
				try {
					string routingKey = msg.DeliveryProperties.GetRoutingKey() ;
					if (routingKey != null) {
						agentBank = Agent.GetBrokerBank(routingKey) ;
						brokerBank = Agent.GetBrokerBank(routingKey) ;				
					}
				}
				catch (Exception e) {
					log.Warn("Internal QPID error", e) ;
				}
				
				string agentKey = Agent.AgentKey(agentBank, brokerBank) ;
				long timestamp = decoder.ReadUint64() ;
				if (broker.Agents.ContainsKey(agentKey)) {
					Agent agent = broker.Agents[agentKey] ;
					Console.HearbeatRecieved(agent, timestamp) ;
				}
			}
			
		}		
Exemplo n.º 10
0
		public virtual void BrokerInformation(Broker broker) {}
Exemplo n.º 11
0
		public void HandleClassIndicator(Broker broker, IDecoder decoder, long sequence) {
			short kind = decoder.ReadUint8() ;	
			ClassKey classKey = new ClassKey(decoder) ;
			bool unknown = false ;
			
			
			lock (LockObject) {
				if (Packages.ContainsKey(classKey.PackageName)) {
					if (!Packages[classKey.PackageName].ContainsKey(classKey.GetKeyString())) {
						unknown = true ;
					}
				}
			}
			
			if (unknown) {
				broker.IncrementOutstanding() ;
				long seq = SequenceManager.Reserve(Session.CONTEXT_STARTUP) ; 
				IEncoder enc = broker.CreateEncoder('S', seq) ;			
				classKey.encode(enc) ;	
				broker.Send(enc) ;				
			}
		}		
Exemplo n.º 12
0
		public void HandleBrokerResponse(Broker broker, IDecoder decoder, long sequence) {
			if (Console != null) {
				Console.BrokerInformation(broker) ;
			}				
		
		    long seq = SequenceManager.Reserve(CONTEXT_STARTUP) ;
			IEncoder endocder = broker.CreateEncoder('P', seq) ;
			broker.Send(endocder) ;
		}
Exemplo n.º 13
0
		public virtual void ObjectProperties(Broker broker, QMFObject obj) {}
Exemplo n.º 14
0
		public void HandleBrokerDisconnect(Broker broker) {
			if (Console != null) {
				Console.BrokerDisconnected(broker) ;
			}		
		}			
Exemplo n.º 15
0
		protected long SendMethodRequest(QMFObject obj, Broker aBroker, string name, List<object> args, bool synchronous, int timeToLive) {
			
			SchemaMethod method = obj.Schema.GetMethod(name) ;
			if (args == null) {
				args = new List<object>() ;
			}
			
			long seq = 0 ;
			if (method != null) {
				KeyValuePair<SchemaMethod, bool> pair = new KeyValuePair<SchemaMethod, bool>(method, synchronous) ;
				seq = SequenceManager.Reserve(pair) ;
				IEncoder enc = aBroker.CreateEncoder('M', seq) ;
				obj.ObjectID.encode(enc) ;
				obj.Schema.Key.encode(enc) ;
				enc.WriteStr8(name) ;
				
				if (args.Count < method.InputArgCount) {
					throw new Exception(String.Format("Incorrect number of arguments: expected {0}, got{1}", method.InputArgCount, args.Count)) ;
				}
				
				int argIndex = 0 ;
				foreach (SchemaArgument arg in method.Arguments) {
					if (arg.IsInput()) {;						
						this.EncodeValue(enc, arg.Type, args[argIndex]) ;
						argIndex += 1 ;
					} 
				}
				
				Message msg = aBroker.CreateMessage(enc,obj.RoutingKey(),timeToLive) ;
				
				if (synchronous) {
					aBroker.SetSyncInFlight(true) ;
				}
				aBroker.Send(msg) ;
			}
			return seq ;
		}
Exemplo n.º 16
0
		public virtual void EventRecieved(Broker broker, QMFEvent anEvent) {} 
Exemplo n.º 17
0
		public virtual void MethodResponse(Broker broker, long seq, MethodResult response) {}
Exemplo n.º 18
0
		public virtual void ObjectStatistics(Broker broker, QMFObject obj) {}
Exemplo n.º 19
0
		public void HandleCommandComplete(Broker broker, IDecoder decoder, long sequence) {
		
			long code = decoder.ReadUint32() ;
			string text = decoder.ReadStr8() ;
			Object context = this.SequenceManager.Release(sequence) ;
			
			if (context.Equals(CONTEXT_STARTUP)) {
				broker.DecrementOutstanding() ;
			} else {
			 	if ((context.Equals(CONTEXT_SYNC)) & broker.GetSyncInFlight()) {
					broker.SetSyncInFlight(false) ;
				} else {
					if (context.Equals(CONTEXT_MULTIGET) && SyncSequenceList.Contains(sequence)) {
						lock(LockObject) {
							SyncSequenceList.Remove(sequence) ;
							if (SyncSequenceList.Count == 0) {
								Monitor.PulseAll(LockObject) ;
							}
						}
					}
				}
			}
		}	
Exemplo n.º 20
0
		public virtual void BrokerDisconnected(Broker broker) {}