public void UpdateAgent(QMFObject obj) { long agentBank = (long)obj.GetProperty("agentBank"); long brokerBank = (long)obj.GetProperty("brokerBank"); String key = Agent.AgentKey(agentBank, brokerBank); if (obj.IsDeleted()) { if (Agents.ContainsKey(key)) { Agent agent = Agents[key]; Agents.Remove(key); consoleSession.HandleAgentRemoved(agent); } } else { if (!Agents.ContainsKey(key)) { Agent newAgent = new Agent(this, agentBank, (string)obj.GetProperty("label")); Agents.Add(key, newAgent); consoleSession.HandleNewAgent(newAgent); } } }
public MethodResult InvokeMethod(QMFObject obj, string name, List <object> args, bool synchronous, int timeToLive) { Broker aBroker = this.GetBroker(obj.BrokerBank()); long seq = this.SendMethodRequest(obj, aBroker, name, args, synchronous, timeToLive); if (seq != 0) { if (!synchronous) { return(null); } try { aBroker.WaitForSync(timeToLive); } catch (Exception e) { SequenceManager.Release(seq); throw e; } // FIXME missing error logic in the broker return((MethodResult)SyncResult); } return(null); }
public QMFObject(QMFObject source) { this.Session = source.Session ; this.Schema = source.Schema ; this.Managed = source.Managed ; this.CurrentTime = source.CurrentTime ; this.CreateTime = source.CreateTime ; this.DeleteTime = source.DeleteTime ; this.ObjectID = source.ObjectID ; this.Properties = source.Properties ; this.Statistics = source.Statistics ; }
public QMFObject(QMFObject source) { this.Session = source.Session; this.Schema = source.Schema; this.Managed = source.Managed; this.CurrentTime = source.CurrentTime; this.CreateTime = source.CreateTime; this.DeleteTime = source.DeleteTime; this.ObjectID = source.ObjectID; this.Properties = source.Properties; this.Statistics = source.Statistics; }
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); }
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); } } } }
public virtual void ObjectStatistics(Broker broker, QMFObject obj) { }
public virtual void ObjectProperties(Broker broker, QMFObject obj) { }
public BaseClass(QMFObject source) : base(source) { }
public bool SelectMatch(QMFObject obj) { return true ; }
public bool SelectMatch(QMFObject obj) { return(true); }
public virtual void ObjectStatistics(Broker broker, QMFObject obj) {}
public virtual void ObjectProperties(Broker broker, QMFObject obj) {}
public MethodResult InvokeMethod(QMFObject obj, string name, List<object> args, bool synchronous, int timeToLive) { Broker aBroker = this.GetBroker(obj.BrokerBank()) ; long seq = this.SendMethodRequest(obj, aBroker, name, args, synchronous, timeToLive) ; if (seq != 0) { if (!synchronous) { return null ; } try { aBroker.WaitForSync(timeToLive) ; } catch (Exception e) { SequenceManager.Release(seq) ; throw e ; } // FIXME missing error logic in the broker return (MethodResult) SyncResult ; } return null ; }
public void EncodeValue(IEncoder enc, short type, object val) { try { switch ((int)type) { case 1: enc.WriteUint8((short)val); break; // U8 case 2: enc.WriteUint16((int)val); break; // U16 case 3: enc.WriteUint32((long)val); break; // U32 case 4: enc.WriteUint64((long)val); break; // U64 case 6: enc.WriteStr8((string)val); break; // SSTR case 7: enc.WriteStr16((string)val); break; // LSTR case 8: enc.WriteDatetime((long)val); break; // ABSTIME case 9: enc.WriteUint32((long)val); break; // DELTATIME case 10: ((ObjectID)val).encode(enc); break; // ref case 11: if ((bool)val) { enc.WriteUint8(1); } else { enc.WriteUint8(0); } break; case 12: enc.WriteFloat((float)val); break; // FLOAT case 13: enc.WriteDouble((double)val); break; // DOUBLE case 14: enc.WriteUuid((UUID)val); break; // UUID case 15: enc.WriteMap((Dictionary <string, object>)val); break; // Ftable case 16: enc.WriteInt8((short)val); break; // int8 case 17: enc.WriteInt16((int)val); break; // int16 case 18: enc.WriteInt32(long.Parse("" + val)); break; // int32 case 19: enc.WriteInt64(long.Parse("" + val)); break; // int64 case 20: // Object // Check that the object has a session, if not // take ownership of it QMFObject qObj = (QMFObject)val; if (qObj.Session == null) { qObj.Session = this; } qObj.Encode(enc); break; case 21: // List List <object> items = (List <object>)val; MSEncoder lEnc = new MSEncoder(1); lEnc.Init(); lEnc.WriteUint32(items.Count); foreach (object obj in items) { short innerType = Util.QMFType(obj); lEnc.WriteUint8(innerType); this.EncodeValue(lEnc, innerType, obj); } enc.WriteVbin32(lEnc.Segment().ToArray()); break; case 22: // Array List <object> aItems = (List <object>)val; MSEncoder aEnc = new MSEncoder(1); aEnc.Init(); long aCount = aItems.Count; aEnc.WriteUint32(aCount); if (aCount > 0) { Object anObj = aItems[0]; short innerType = Util.QMFType(anObj); aEnc.WriteUint8(innerType); foreach (object obj in aItems) { this.EncodeValue(aEnc, innerType, obj); } } enc.WriteVbin32(aEnc.Segment().ToArray()); break; default: throw new Exception(String.Format("Invalid Type Code: {0}", type)); } } catch (System.InvalidCastException e) { string msg = String.Format("Class cast exception for typecode {0}, type {1} ", type, val.GetType()); log.Error(msg); throw new Exception(msg + type, e); } }
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 ; }
public void UpdateAgent(QMFObject obj) { long agentBank = (long)obj.GetProperty("agentBank") ; long brokerBank = (long)obj.GetProperty("brokerBank") ; String key = Agent.AgentKey(agentBank, brokerBank) ; if (obj.IsDeleted()) { if (Agents.ContainsKey(key)) { Agent agent = Agents[key] ; Agents.Remove(key) ; consoleSession.HandleAgentRemoved(agent) ; } } else { if (! Agents.ContainsKey(key)) { Agent newAgent = new Agent(this, agentBank, (string)obj.GetProperty("label")) ; Agents.Add(key, newAgent) ; consoleSession.HandleNewAgent(newAgent) ; } } }
public DerivedClass(QMFObject source) : base(source) { }
public ExampleService(QMFObject source) : base(source) { }