public void TestLatencyAlert() { String[] services = { "s0", "s1", "s2" }; String[] customers = { "c0", "c1", "c2" }; OperationMeasurement measurement; for (var i = 0; i < 100; i++) { for (var index = 0; index < services.Length; index++) { measurement = new OperationMeasurement(services[index], customers[index], 9950 + i, true); _sender.SendEvent(measurement); } } // This should generate an alert measurement = new OperationMeasurement(services[0], customers[0], 10000, true); _sender.SendEvent(measurement); // This should generate an alert measurement = new OperationMeasurement(services[1], customers[1], 10001, true); _sender.SendEvent(measurement); // This should not generate an alert measurement = new OperationMeasurement(services[2], customers[2], 9999, true); _sender.SendEvent(measurement); }
public void TestSenderPONO() { Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType("SupportBean", typeof(SupportBean)); configuration.AddEventType("Marker", typeof(SupportMarkerInterface)); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } // type resolved for each by the first event representation picking both up, i.e. the one with "r2" since that is the most specific URI EPStatement stmt = _epService.EPAdministrator.CreateEPL("select * from SupportBean"); stmt.Events += _listener.Update; // send right event EventSender sender = _epService.EPRuntime.GetEventSender("SupportBean"); Object supportBean = new SupportBean(); sender.SendEvent(supportBean); Assert.AreSame(supportBean, _listener.AssertOneGetNewAndReset().Underlying); // send wrong event try { sender.SendEvent(new SupportBean_G("G1")); Assert.Fail(); } catch (EPException ex) { Assert.AreEqual( "Event object of type com.espertech.esper.support.bean.SupportBean_G does not equal, extend or implement the type com.espertech.esper.support.bean.SupportBean of event type 'SupportBean'", ex.Message); } // test an interface sender = _epService.EPRuntime.GetEventSender("Marker"); stmt.Dispose(); stmt = _epService.EPAdministrator.CreateEPL("select * from Marker"); stmt.Events += _listener.Update; var implA = new SupportMarkerImplA("Q2"); sender.SendEvent(implA); Assert.AreSame(implA, _listener.AssertOneGetNewAndReset().Underlying); var implB = new SupportBean_G("Q3"); sender.SendEvent(implB); Assert.AreSame(implB, _listener.AssertOneGetNewAndReset().Underlying); sender.SendEvent(implB); Assert.AreSame(implB, _listener.AssertOneGetNewAndReset().Underlying); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestLatencyAlert() { var services = new[] { "s0", "s1", "s2" }; var customers = new[] { "c0", "c1", "c2" }; var limitSpike = new[] { 15000L, 10000L, 10040L }; // Set up limits for 3 services/customer combinations for (var i = 0; i < services.Length; i++) { var limit = new LatencyLimit(services[i], customers[i], limitSpike[i]); _senderLatencyLimit.SendEvent(limit); } // Send events for (var i = 0; i < 100; i++) { for (var index = 0; index < services.Length; index++) { var measurement = new OperationMeasurement(services[index], customers[index], 9950 + i, true); _senderOperationalMeasurement.SendEvent(measurement); } } // Send a new limit var nlimit = new LatencyLimit(services[1], customers[1], 8000); _senderLatencyLimit.SendEvent(nlimit); // Send a new spike var nmeasurement = new OperationMeasurement(services[1], customers[1], 8001, true); _senderOperationalMeasurement.SendEvent(nmeasurement); }
// Update is called once per frame void Update() { //wait to realise what's happened if (stalled_) { if (car_.GetState() == CarState.CS_STALLED) { if (stallTime_ > 0) { stallTime_ -= Time.deltaTime; } else { car_.SetState(CarState.CS_STARTING); } } //try and start up the car again if (car_.GetState() == CarState.CS_STARTING) { ignition_ += Time.deltaTime; if (ignition_ >= ignitionTime_) { car_.SetState(CarState.CS_MOVING, true); ignition_ = 0; stalled_ = false; } } } if (vision_.enabled) { if (!distracted_) { frameCounter_++; if (frameCounter_ >= distractionCheckFrames_) { frameCounter_ = 0; if (Random.Range(0.0f, 100.0f) < distractionChance_) { distracted_ = true; distractedTime_ = distractionTime_; float maxAngle = vision_.GetLookAngle() * 2.0f; vision_.SetLookStartAngle(Random.Range(-maxAngle, maxAngle)); eventSender_.SendEvent(TrafficEvent.TE_DISTRACTED); } } } else { distractedTime_ -= Time.deltaTime; if (distractedTime_ <= 0) { distracted_ = false; vision_.SetLookStartAngle(0); } } } }
private void RunAssertionCaseStatic(EPServiceProvider epService) { EPStatement stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeOne"); stmt.Events += _listeners[0].Update; stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeTwo"); stmt.Events += _listeners[1].Update; stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeThree"); stmt.Events += _listeners[2].Update; stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeFour"); stmt.Events += _listeners[3].Update; // static senders EventSender sender = epService.EPRuntime.GetEventSender("TestTypeOne"); sender.SendEvent(MakeProperties(new String[][] { new String[] { "r1", "A" }, new String[] { "t1", "B" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[0].AssertOneGetNewAndReset(), new Object[] { "A", "B" }); Assert.IsFalse(_listeners[3].IsInvoked || _listeners[1].IsInvoked || _listeners[2].IsInvoked); sender = epService.EPRuntime.GetEventSender("TestTypeTwo"); sender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "C" }, new String[] { "t2", "D" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[1].AssertOneGetNewAndReset(), new Object[] { "C", "D" }); Assert.IsFalse(_listeners[3].IsInvoked || _listeners[0].IsInvoked || _listeners[2].IsInvoked); sender = epService.EPRuntime.GetEventSender("TestTypeThree"); sender.SendEvent(MakeProperties(new String[][] { new String[] { "r3", "E" }, new String[] { "t3", "F" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[2].AssertOneGetNewAndReset(), new Object[] { "E", "F" }); Assert.IsFalse(_listeners[3].IsInvoked || _listeners[1].IsInvoked || _listeners[0].IsInvoked); sender = epService.EPRuntime.GetEventSender("TestTypeFour"); sender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "G" }, new String[] { "t4", "H" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[3].AssertOneGetNewAndReset(), new Object[] { "G", "H" }); Assert.IsFalse(_listeners[0].IsInvoked || _listeners[1].IsInvoked || _listeners[2].IsInvoked); // dynamic sender - decides on event type thus a particular Update listener should see the event Uri[] uriList = new Uri[] { new Uri("type://properties/test1"), new Uri("type://properties/test2") }; EventSender dynamicSender = epService.EPRuntime.GetEventSender(uriList); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r3", "I" }, new String[] { "t3", "J" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[2].AssertOneGetNewAndReset(), new Object[] { "I", "J" }); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r1", "K" }, new String[] { "t1", "L" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[0].AssertOneGetNewAndReset(), new Object[] { "K", "L" }); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "M" }, new String[] { "t2", "Count" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[1].AssertOneGetNewAndReset(), new Object[] { "M", "Count" }); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "O" }, new String[] { "t4", "P" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[3].AssertOneGetNewAndReset(), new Object[] { "O", "P" }); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "O" }, new String[] { "t3", "P" } })); AssertNoneReceived(); uriList = new Uri[] { new Uri("type://properties/test2") }; dynamicSender = epService.EPRuntime.GetEventSender(uriList); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r1", "I" }, new String[] { "t1", "J" } })); AssertNoneReceived(); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "Q" }, new String[] { "t2", "R" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[1].AssertOneGetNewAndReset(), new Object[] { "Q", "R" }); }
public override void Run(EPServiceProvider epService) { var listener = new SupportUpdateListener(); string stmtText = "select b.c as type, element1 from AEvent"; EPStatement stmt = epService.EPAdministrator.CreateEPL(stmtText); stmt.Events += listener.Update; XmlDocument doc = GetDocument("<a><b><c>text</c></b></a>"); EventSender sender = epService.EPRuntime.GetEventSender("AEvent"); sender.SendEvent(doc); EventBean theEvent = listener.AssertOneGetNewAndReset(); Assert.AreEqual("text", theEvent.Get("type")); Assert.AreEqual("text", theEvent.Get("element1")); // send wrong event try { sender.SendEvent(GetDocument("<xxxx><b><c>text</c></b></xxxx>")); Assert.Fail(); } catch (EPException ex) { Assert.AreEqual("Unexpected root element name 'xxxx' encountered, expected a root element name of 'a'", ex.Message); } try { sender.SendEvent(new SupportBean()); Assert.Fail(); } catch (EPException ex) { Assert.AreEqual("Unexpected event object type '" + typeof(SupportBean).FullName + "' encountered, please supply a XmlDocument or XmlElement node", ex.Message); } // test adding a second type for the same root element var typeMeta = new ConfigurationEventTypeXMLDOM(); typeMeta.RootElementName = "a"; typeMeta.AddXPathProperty("element2", "//c", XPathResultType.String); typeMeta.IsEventSenderValidatesRoot = false; epService.EPAdministrator.Configuration.AddEventType("BEvent", typeMeta); stmtText = "select element2 from BEvent#lastevent"; EPStatement stmtTwo = epService.EPAdministrator.CreateEPL(stmtText); // test sender that doesn't care about the root element EventSender senderTwo = epService.EPRuntime.GetEventSender("BEvent"); senderTwo.SendEvent(GetDocument("<xxxx><b><c>text</c></b></xxxx>")); // allowed, not checking theEvent = stmtTwo.First(); Assert.AreEqual("text", theEvent.Get("element2")); }
private void OnSendTemperatureUpdate(object sender, RoutedEventArgs e) { int value = (int)DateTime.Now.Ticks % 50; byte[] intBytes = BitConverter.GetBytes(value); if (BitConverter.IsLittleEndian) { Array.Reverse(intBytes); } byte[] result = intBytes; eventSender.SendEvent("temperature", value.ToString()); PostStatus("Temperature event sent"); }
void AnyAreaClick(GameObject btn) { if (!Core.Data.guideManger.CanClickGuideUI) { return; } //Debug.LogError("AnyAreaClick"); if (curClickType == ClickType.AnyArea) { GuideData task = Core.Data.guideManger.CurTask; if (task != null && task.ID > 0) { //GuideTouchEnable = false; EventSender.SendEvent((EventTypeDefine)task.TaskID, task); Core.Data.guideManger.AutoSendMsgAtLastTask(); } if (task.AutoNext == 0) { Core.Data.guideManger.AutoRUN(); } else { //如果是缘引导触发 if (task != null && task.ID == -1) { //GuideTouchEnable = false; EventSender.SendEvent((EventTypeDefine)task.TaskID, task); DestoryGuide(); } } } }
public void ChangeSystemMode(IEventMetadata eventMetadata, IEventStore eventStore, SystemModeChangeCommand cmd, long orginalEventNumber) { ValidateSystemMode(cmd.NewSystemMode); ValidateEventNumber(orginalEventNumber); ValidateCategory(eventMetadata.Category); var changeSystemModeCommand = new ChangeSystemMode(eventStore, cmd.ThermostatId, cmd.ThermostatGuid, cmd.TenantId, cmd.NewSystemMode); var commandBus = CommandBus.Instance; commandBus.Execute(changeSystemModeCommand); ApplyEvent(new SystemModeChanged(cmd.ThermostatGuid, DateTimeOffset.UtcNow, eventMetadata, cmd.NewSystemMode), -4); // Send Event to Event Store var events = this.GetUncommittedEvents(); try { EventSender.SendEvent(eventStore, new CompositeAggregateId(eventMetadata.TenantId, AggregateGuid, eventMetadata.Category), events); } catch (ConnectionFailure conn) { Trace.TraceError($"There was a connection error: {conn}"); } }
void SpecifiedAreaClick(GameObject btn) { if (!Core.Data.guideManger.CanClickGuideUI) { return; } //Debug.LogError("SpecifiedAreaClick"); if (curClickType == ClickType.SpecifiedArea) { GuideData task = Core.Data.guideManger.CurTask; if (task != null && task.ID > 0) { task.MultiIndex = btn.name == "GuideMask" ? 0:System.Convert.ToInt32(btn.name); //GuideTouchEnable = false; EventSender.SendEvent((EventTypeDefine)task.TaskID, task); Core.Data.guideManger.AutoSendMsgAtLastTask(); } if (task != null && task.AutoNext == 0) { // if(Core.Data.guideManger.LastTaskID == 300017) // Invoke("AfterAutoRun",0.5f); // else Core.Data.guideManger.AutoRUN(); } } else { AnyAreaClick(btn); } }
private void RunAssertionStatementNameExists(EPServiceProvider epService, string typeName, object[] events) { epService.EPAdministrator.CreateEPL("@Name('MyStatement') select * from " + typeName); epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " + "create schema AllObject System.Object," + "EPStatementSource -> thedata<AllObject> {" + " statementName : 'MyStatement'," + "} " + "DefaultSupportCaptureOp(thedata) {}"); var captureOp = new DefaultSupportCaptureOp(2, SupportContainer.Instance.LockManager()); var options = new EPDataFlowInstantiationOptions() .OperatorProvider(new DefaultSupportGraphOpProvider(captureOp)); EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options); df.Start(); EventSender sender = epService.EPRuntime.GetEventSender(typeName); foreach (Object @event in events) { sender.SendEvent(@event); } captureOp.GetValue(1, TimeUnit.SECONDS); EPAssertionUtil.AssertEqualsExactOrder(events, captureOp.Current); df.Cancel(); epService.EPAdministrator.DestroyAllStatements(); }
public void TestObservationExamplePropertyExpression() { ConfigurationEventTypeXMLDOM typecfg = new ConfigurationEventTypeXMLDOM(); typecfg.RootElementName = "Sensor"; String schemaUri = ResourceManager.ResolveResourceURL(CLASSLOADER_SCHEMA_URI).ToString(); typecfg.SchemaResource = schemaUri; Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.EngineDefaults.ViewResourcesConfig.IsIterableUnbound = true; configuration.AddEventType("SensorEvent", typecfg); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } String stmtExampleOneText = "select ID, Observation.Command, Observation.ID,\n" + "Observation.Tag[0].ID, Observation.Tag[1].ID\n" + "from SensorEvent"; EPStatement stmtExampleOne = _epService.EPAdministrator.CreateEPL(stmtExampleOneText); EPStatement stmtExampleTwo_0 = _epService.EPAdministrator.CreateEPL("insert into ObservationStream\n" + "select ID, Observation from SensorEvent"); EPStatement stmtExampleTwo_1 = _epService.EPAdministrator.CreateEPL("select Observation.Command, Observation.Tag[0].ID from ObservationStream"); EPStatement stmtExampleThree_0 = _epService.EPAdministrator.CreateEPL("insert into TagListStream\n" + "select ID as sensorId, Observation.* from SensorEvent"); EPStatement stmtExampleThree_1 = _epService.EPAdministrator.CreateEPL("select sensorId, Command, Tag[0].ID from TagListStream"); XmlDocument doc = SupportXML.GetDocument(XML); EventSender sender = _epService.EPRuntime.GetEventSender("SensorEvent"); sender.SendEvent(doc); EventTypeAssertionUtil.AssertConsistency(stmtExampleOne.First()); EventTypeAssertionUtil.AssertConsistency(stmtExampleTwo_0.First()); EventTypeAssertionUtil.AssertConsistency(stmtExampleTwo_1.First()); EventTypeAssertionUtil.AssertConsistency(stmtExampleThree_0.First()); EventTypeAssertionUtil.AssertConsistency(stmtExampleThree_1.First()); EPAssertionUtil.AssertProps(stmtExampleTwo_1.First(), "Observation.Command,Observation.Tag[0].ID".Split(','), new Object[] { "READ_PALLET_TAGS_ONLY", "urn:epc:1:2.24.400" }); EPAssertionUtil.AssertProps(stmtExampleThree_1.First(), "sensorId,Command,Tag[0].ID".Split(','), new Object[] { "urn:epc:1:4.16.36", "READ_PALLET_TAGS_ONLY", "urn:epc:1:2.24.400" }); try { _epService.EPAdministrator.CreateEPL("select Observation.Tag.ID from SensorEvent"); Assert.Fail(); } catch (EPStatementException ex) { Assert.AreEqual("Error starting statement: Failed to validate select-clause expression 'Observation.Tag.ID': Failed to resolve property 'Observation.Tag.ID' to a stream or nested property in a stream [select Observation.Tag.ID from SensorEvent]", ex.Message); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
static int SendEvent(IntPtr L) { int count = LuaDLL.lua_gettop(L); Type[] types1 = { typeof(string) }; if (count == 1) { string arg0 = LuaScriptMgr.GetLuaString(L, 1); EventSender.SendEvent(arg0); return(0); } else if (LuaScriptMgr.CheckTypes(L, types1, 1) && LuaScriptMgr.CheckParamsType(L, typeof(object), 2, count - 1)) { string arg0 = LuaScriptMgr.GetString(L, 1); object[] objs1 = LuaScriptMgr.GetParamsObject(L, 2, count - 1); EventSender.SendEvent(arg0, objs1); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: EventSender.SendEvent"); } return(0); }
public static XmlDocument SendEvent(EventSender sender, String xml) { XmlDocument simpleDoc = GetDocument(xml); sender.SendEvent(simpleDoc); return(simpleDoc); }
public static XmlDocument SendEvent( EventSender sender, string xml) { var simpleDoc = GetDocument(xml); sender.SendEvent(simpleDoc); return simpleDoc; }
public void SendBidEvent() { var bidEvent = new BidData( SymbolList[Rand.Next(SymbolList.Length)], 0L, Rand.NextDouble()); _sender.SendEvent(bidEvent); }
public void TestEventSender() { EPServiceProviderIsolated unit = _epService.GetEPServiceIsolated("i1"); EventSender sender = unit.EPRuntime.GetEventSender("SupportBean"); _epService.EPAdministrator.CreateEPL("select * from SupportBean").Events += _listener.Update; sender.SendEvent(new SupportBean()); var testProp = _listener.IsInvoked; }
public void TestSenderMap() { Configuration configuration = SupportConfigFactory.GetConfiguration(); IDictionary <String, Object> myMapType = MakeMap(new[] { new Object[] { "f1", typeof(int) } }); configuration.AddEventType("MyMap", myMapType); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } // type resolved for each by the first event representation picking both up, i.e. the one with "r2" since that is the most specific URI EPStatement stmt = _epService.EPAdministrator.CreateEPL("select * from MyMap"); stmt.Events += _listener.Update; // send right event EventSender sender = _epService.EPRuntime.GetEventSender("MyMap"); IDictionary <String, Object> myMap = MakeMap(new[] { new Object[] { "f1", 10 } }); sender.SendEvent(myMap); Assert.AreEqual(10, _listener.AssertOneGetNewAndReset().Get("f1")); // send wrong event try { sender.SendEvent(new SupportBean()); Assert.Fail(); } catch (EPException ex) { Assert.AreEqual( "Unexpected event object of type com.espertech.esper.support.bean.SupportBean, expected " + typeof(IDictionary <string, object>).FullName, ex.Message); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
private void RunAssertionCaseDynamic(EPServiceProvider epService) { // type resolved for each by the first event representation picking both up, i.e. the one with "r2" since that is the most specific Uri EPStatement stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeOne"); stmt.Events += _listeners[0].Update; stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeTwo"); stmt.Events += _listeners[1].Update; // static senders EventSender sender = epService.EPRuntime.GetEventSender("TestTypeOne"); sender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "A" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[0].AssertOneGetNewAndReset(), new Object[] { "A" }); Assert.IsFalse(_listeners[0].IsInvoked); sender = epService.EPRuntime.GetEventSender("TestTypeTwo"); sender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "B" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[1].AssertOneGetNewAndReset(), new Object[] { "B" }); }
public void TestExpressionPrimitiveArray() { ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "simpleEvent"; eventTypeMeta.SchemaResource = schemaURI; epService.EPAdministrator.Configuration.AddEventType("ABCType", eventTypeMeta); eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "//nested2"; eventTypeMeta.SchemaResource = schemaURI; eventTypeMeta.IsEventSenderValidatesRoot = false; epService.EPAdministrator.Configuration.AddEventType("TestNested2", eventTypeMeta); // try array property in select EPStatement stmtInsert = epService.EPAdministrator.CreateEPL("select * from TestNested2.std:lastevent()"); stmtInsert.Events += listener.Update; EPAssertionUtil.AssertEqualsAnyOrder(new [] { new EventPropertyDescriptor("prop3", typeof(int?[]), typeof(int?), false, false, true, false, false), }, stmtInsert.EventType.PropertyDescriptors); EventTypeAssertionUtil.AssertConsistency(stmtInsert.EventType); SupportXML.SendDefaultEvent(epService.EPRuntime, "test"); Assert.IsFalse(listener.IsInvoked); EventSender sender = epService.EPRuntime.GetEventSender("TestNested2"); sender.SendEvent(SupportXML.GetDocument("<nested2><prop3>2</prop3><prop3></prop3><prop3>4</prop3></nested2>")); EventBean theEvent = stmtInsert.First(); EPAssertionUtil.AssertEqualsExactOrder((int?[])theEvent.Get("prop3"), new int?[] { 2, null, 4 }); EventTypeAssertionUtil.AssertConsistency(theEvent); // try array property nested EPStatement stmtSelect = epService.EPAdministrator.CreateEPL("select nested3.* from ABCType.std:lastevent()"); SupportXML.SendDefaultEvent(epService.EPRuntime, "test"); EventBean stmtSelectResult = stmtSelect.First(); EventTypeAssertionUtil.AssertConsistency(stmtSelectResult); Assert.AreEqual(typeof(String[]), stmtSelectResult.EventType.GetPropertyType("nested4[2].prop5")); Assert.AreEqual("SAMPLE_V8", stmtSelectResult.Get("nested4[0].prop5[1]")); EPAssertionUtil.AssertEqualsExactOrder((String[])stmtSelectResult.Get("nested4[2].prop5"), new Object[] { "SAMPLE_V10", "SAMPLE_V11" }); EventBean fragmentNested4 = (EventBean)stmtSelectResult.GetFragment("nested4[2]"); EPAssertionUtil.AssertEqualsExactOrder((String[])fragmentNested4.Get("prop5"), new Object[] { "SAMPLE_V10", "SAMPLE_V11" }); Assert.AreEqual("SAMPLE_V11", fragmentNested4.Get("prop5[1]")); EventTypeAssertionUtil.AssertConsistency(fragmentNested4); }
void OnCollisionEnter(Collision collision) { GameObject other = collision.collider.gameObject; if (other.tag != "Ground") { GetComponent <AudioSource>().PlayOneShot(crashNoise_); } if (purpose_ && purpose_.enabled) { purpose_.SoundHorn(); } if (tag == "Player") { return; } if (collision.relativeVelocity.magnitude > car_.GetMaxSpeed() * 0.25f) { car_.SetState(CarState.CS_CRASHED); } else { if (purpose_.enabled) { car_.MoveAwayFrom(other); purpose_.SetParkingChance(101.0f); } } if (other.tag == "Car" || other.tag == "Player") { //make sure only one car registers the event if (car_.DistanceToTarget() > other.GetComponent <Car>().DistanceToTarget()) { eventSender_.SendEvent(TrafficEvent.TE_COLLISION); } if (error_) { car_.SetState(CarState.CS_MOVING, true); } } //prevent the car from locking up if (tag == "Player") { car_.Brake(0); car_.Accelerate(0); body_.velocity *= 0.1f; } }
private void RunAssertionInvalid(EPServiceProvider epService, string typename, Object incorrectUnderlying, string message) { EventSender sender = epService.EPRuntime.GetEventSender(typename); try { sender.SendEvent(incorrectUnderlying); Assert.Fail(); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessage(ex, message); } }
private void RunAssertionEventsProcessed(EPServiceProvider epService) { var listenerOne = new SupportListenerTimerHRes(); var listenerTwo = new SupportListenerTimerHRes(); var listenerThree = new SupportListenerTimerHRes(); EPStatement stmtOne = epService.EPAdministrator.CreateEPL("select SupportStaticMethodLib.Sleep(100) from MyMap"); stmtOne.Events += listenerOne.Update; EPStatement stmtTwo = epService.EPAdministrator.CreateEPL("select SupportStaticMethodLib.Sleep(100) from SupportBean"); stmtTwo.Events += listenerTwo.Update; EPStatement stmtThree = epService.EPAdministrator.CreateEPL("select SupportStaticMethodLib.Sleep(100) from XMLType"); stmtThree.Events += listenerThree.Update; EventSender senderOne = epService.EPRuntime.GetEventSender("MyMap"); EventSender senderTwo = epService.EPRuntime.GetEventSender("SupportBean"); EventSender senderThree = epService.EPRuntime.GetEventSender("XMLType"); long start = PerformanceObserver.NanoTime; for (int i = 0; i < 2; i++) { epService.EPRuntime.SendEvent(new Dictionary <string, Object>(), "MyMap"); senderOne.SendEvent(new Dictionary <string, Object>()); epService.EPRuntime.SendEvent(new SupportBean()); senderTwo.SendEvent(new SupportBean()); epService.EPRuntime.SendEvent(SupportXML.GetDocument("<myevent/>")); senderThree.SendEvent(SupportXML.GetDocument("<myevent/>")); } long end = PerformanceObserver.NanoTime; long delta = (end - start) / 1000000; Assert.IsTrue(delta < 500); Thread.Sleep(1000); Assert.AreEqual(4, listenerOne.NewEvents.Count); Assert.AreEqual(4, listenerTwo.NewEvents.Count); Assert.AreEqual(4, listenerThree.NewEvents.Count); EPServiceProviderSPI spi = (EPServiceProviderSPI)epService; Assert.AreEqual(0, spi.ThreadingService.InboundQueue.Count); Assert.IsNotNull(spi.ThreadingService.InboundThreadPool); stmtOne.Dispose(); stmtTwo.Dispose(); stmtThree.Dispose(); }
private static void RunAssertion( RegressionEnvironment env, String eventTypeNameNested, String eventTypeNameABC, RegressionPath path) { // try array property in select env.CompileDeploy("@Name('s0') select * from " + eventTypeNameNested + "#lastevent", path).AddListener("s0"); CollectionAssert.AreEquivalent( new EventPropertyDescriptor[] { new EventPropertyDescriptor("prop3", typeof(int?[]), typeof(int?), false, false, true, false, false) }, env.Statement("s0").EventType.PropertyDescriptors); SupportEventTypeAssertionUtil.AssertConsistency(env.Statement("s0").EventType); EventSender sender = env.EventService.GetEventSender(eventTypeNameNested); sender.SendEvent( SupportXML.GetDocument( "<nested2><prop3>2</prop3><prop3></prop3><prop3>4</prop3></nested2>")); var theEvent = env.GetEnumerator("s0").Advance(); var theValues = theEvent.Get("prop3").Unwrap<object>(true); EPAssertionUtil.AssertEqualsExactOrder( theValues, new object[] {2, null, 4}); SupportEventTypeAssertionUtil.AssertConsistency(theEvent); env.UndeployModuleContaining("s0"); // try array property nested env.CompileDeploy("@Name('s0') select nested3.* from " + eventTypeNameABC + "#lastevent", path); SupportXML.SendDefaultEvent(env.EventService, "test", eventTypeNameABC); var stmtSelectResult = env.GetEnumerator("s0").Advance(); SupportEventTypeAssertionUtil.AssertConsistency(stmtSelectResult); Assert.AreEqual(typeof(string[]), stmtSelectResult.EventType.GetPropertyType("nested4[2].prop5")); Assert.AreEqual("SAMPLE_V8", stmtSelectResult.Get("nested4[0].prop5[1]")); EPAssertionUtil.AssertEqualsExactOrder( (string[]) stmtSelectResult.Get("nested4[2].prop5"), new object[] {"SAMPLE_V10", "SAMPLE_V11"}); var fragmentNested4 = (EventBean) stmtSelectResult.GetFragment("nested4[2]"); EPAssertionUtil.AssertEqualsExactOrder( (string[]) fragmentNested4.Get("prop5"), new object[] {"SAMPLE_V10", "SAMPLE_V11"}); Assert.AreEqual("SAMPLE_V11", fragmentNested4.Get("prop5[1]")); SupportEventTypeAssertionUtil.AssertConsistency(fragmentNested4); env.UndeployAll(); }
private Controller(Guid id, IEventMetadata eventMetadata, IEventStore eventStore) { AggregateGuid = id; ApplyEvent(new Connected(id, DateTimeOffset.UtcNow, eventMetadata)); // Send Event to Event Store var events = this.GetUncommittedEvents(); try { EventSender.SendEvent(eventStore, new CompositeAggregateId(eventMetadata.TenantId, AggregateGuid, eventMetadata.Category), events); } catch (ConnectionFailure conn) { Trace.TraceError($"There was a connection error: {conn}"); } }
public void Update(Object sender, UpdateEventArgs e) { var newEvents = e.NewEvents; var eventBean = newEvents[0]["tick"]; var newTick = (StockTick)eventBean; Log.Info(".update for stock=" + newTick.StockSymbol + " Price=" + newTick.Price); if (_oldEvents != null) { eventBean = _oldEvents[0]["tick"]; var oldTick = (StockTick)eventBean; Compute(newTick, oldTick); _sender.SendEvent(new RSIEvent(newTick, _avgLoss, _avgGain, _rs, _rsi)); } _oldEvents = newEvents; }
private void RunAssertionEventSender(EPServiceProvider epService) { if (SupportConfigFactory.SkipTest(typeof(ExecClientIsolationUnit))) { return; } EPServiceProviderIsolated unit = epService.GetEPServiceIsolated("other1"); EventSender sender = unit.EPRuntime.GetEventSender("SupportBean"); var listener = new SupportUpdateListener(); unit.EPAdministrator.CreateEPL("select * from SupportBean", null, null).Events += listener.Update; sender.SendEvent(new SupportBean()); Assert.IsTrue(listener.IsInvoked); unit.Dispose(); epService.EPAdministrator.DestroyAllStatements(); }
private Thermostat(Guid id, IEventMetadata eventMetadata, IEventStore eventStore, double temperature, double heatSetpoint, double coolSetpoint, string mode, string systemStatus, double?humidity = null) { AggregateGuid = id; ApplyEvent(new Connected(id, DateTimeOffset.UtcNow, eventMetadata, temperature, heatSetpoint, coolSetpoint, mode, systemStatus, humidity)); // Send Event to Event Store var events = this.GetUncommittedEvents(); try { EventSender.SendEvent(eventStore, new CompositeAggregateId(eventMetadata.TenantId, AggregateGuid, eventMetadata.Category), events); } catch (ConnectionFailure conn) { Trace.TraceError($"There was a connection error: {conn}"); } }
private static void RunAssertion( RegressionEnvironment env, RegressionPath path, EPStage stage, string typename, object underlying, Consumer <EPEventService> sender) { string epl = "@public @buseventtype create schema TriggerEvent();\n" + "@public @buseventtype @name('schema') create json schema " + JSON_TYPENAME + "();\n" + "@Name('trigger') select * from TriggerEvent;\n" + "@Name('s0') select * from " + typename + ";\n"; env.CompileDeploy(epl, path).AddListener("s0"); string deploymentId = env.DeploymentId("s0"); StageIt(env, "ST", deploymentId); // test normal send sender.Invoke(stage.EventService); AssertUnderlying(env, typename, underlying); // test EventSender#send EventSender eventSender = stage.EventService.GetEventSender(typename); eventSender.SendEvent(underlying); AssertUnderlying(env, typename, underlying); // test EventSender#route GetStatement("trigger", "ST", env.Runtime).Events += (_, args) => { eventSender.RouteEvent(underlying); }; stage.EventService.SendEventMap(new Dictionary <string, object>(), "TriggerEvent"); AssertUnderlying(env, typename, underlying); UnstageIt(env, "ST", deploymentId); path.Clear(); env.UndeployModuleContaining("s0"); }
private void RunAssertionSuccess(EPServiceProvider epService, string typename, params object[] correctUnderlyings) { string stmtText = "select * from " + typename; EPStatement stmt = epService.EPAdministrator.CreateEPL(stmtText); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; EventSender sender = epService.EPRuntime.GetEventSender(typename); foreach (Object underlying in correctUnderlyings) { sender.SendEvent(underlying); Assert.AreSame(underlying, listener.AssertOneGetNewAndReset().Underlying); } stmt.Dispose(); }