public void Udp() { this.closeCount = 0; var anyEndPoint = new IPEndPoint(IPAddress.Any, Port); Udp udp = this.loop .CreateUdp() .ReceiveStart(anyEndPoint, this.OnReceive); this.server = udp; IPEndPoint localEndPoint = udp.GetLocalEndPoint(); Assert.NotNull(localEndPoint); Assert.Equal(anyEndPoint.Address, localEndPoint.Address); Assert.Equal(Port, localEndPoint.Port); Udp client = this.loop.CreateUdp(); var remoteEndPoint = new IPEndPoint(IPAddress.Loopback, Port); byte[] data = Encoding.UTF8.GetBytes("PING"); client.QueueSend(data, remoteEndPoint, this.OnSendCompleted); this.loop.RunDefault(); Assert.Equal(1, this.connectedCount); Assert.Equal(1, this.connectionCount); Assert.Equal(2, this.closeCount); }
public void Add( long afterTime, ScheduleHandle handle, long slot) { lock (this) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QScheduleAdd(_currentTime, afterTime, handle, slot); } if (_handleSetMap.ContainsKey(handle)) { Remove(handle, slot); } var triggerOnTime = _currentTime + afterTime; AddTrigger(slot, handle, triggerOnTime); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AScheduleAdd(); } } }
public void Remove(ScheduleHandle handle, long slot) { lock (this) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QScheduleRemove(handle, slot); } var handleSet = _handleSetMap.Get(handle); if (handleSet == null) { // If it already has been removed then that's fine; // Such could be the case when 2 timers fireStatementStopped at the same time, and one stops the other return; } handleSet.Remove(slot); _handleSetMap.Remove(handle); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AScheduleRemove(); } } }
public void ScheduleRemove( AgentInstanceContext agentInstanceContext, ScheduleHandle scheduleHandle, ScheduleObjectType type, string name) { }
public void QScheduleAdd( long currentTime, long afterMSec, ScheduleHandle handle, long slot) { }
public EchoServer(HandleType handleType) { this.Loop = new Loop(); switch (handleType) { case HandleType.Udp: this.server = this.Loop .CreateUdp() .Bind(TestHelper.AnyEndPoint) .ReceiveStart(OnReceive); break; case HandleType.Tcp: this.server = this.Loop .CreateTcp() .SimultaneousAccepts(true) .Listen(TestHelper.LoopbackEndPoint, this.OnConnection, MaximumBacklogSize); break; case HandleType.Pipe: this.server = this.Loop .CreatePipe() .Listen(TestHelper.LocalPipeName, this.OnConnection, MaximumBacklogSize); break; default: throw new InvalidOperationException($"{handleType} not supported."); } }
/// <summary>Ctor. </summary> /// <param name="time">of schedule</param> /// <param name="slot">slot</param> /// <param name="handle">handle to use</param> public ScheduleSetEntry(long time, ScheduleSlot slot, ScheduleHandle handle) { Time = time; Slot = slot; Handle = handle; }
public void ScheduleAdd( long nextScheduledTime, AgentInstanceContext agentInstanceContext, ScheduleHandle scheduleHandle, ScheduleObjectType type, string name) { }
void OnClose(ScheduleHandle handle) { handle.Dispose(); this.closeCount++; if (!this.resetEvent.IsSet) { this.resetEvent.Set(); } }
void OnCallback(ScheduleHandle handle) { if (this.IsShuttingDown) { this.ShuttingDown(); } else { this.RunAllTasks(this.preciseBreakoutInterval); } }
private void ModifyCreateProxy(ScheduleHandle handle) { if (!(handle is EPStatementHandleCallback)) { return; } var callback = (EPStatementHandleCallback)handle; var sc = (ScheduleHandleCallback)ScheduleHandleCallbackProxy.NewInstance(_engineUri, _statementName, callback.ScheduleCallback); callback.ScheduleCallback = sc; }
private void AddTrigger(long slot, ScheduleHandle handle, long triggerTime) { var handleSet = _timeHandleMap.Get(triggerTime); if (handleSet == null) { handleSet = new SortedDictionary<long, ScheduleHandle>(); _timeHandleMap.Put(triggerTime, handleSet); } handleSet.Put(slot, handle); _handleSetMap.Put(handle, handleSet); }
public void Remove(ScheduleHandle handle, long scheduleSlot) { if (AuditPath.IsInfoEnabled) { StringWriter message = new StringWriter(); message.Write("remove handle "); PrintHandle(message, handle); AuditPath.AuditLog(_engineUri, _statementName, AuditEnum.SCHEDULE, message.ToString()); } _spi.Remove(handle, scheduleSlot); }
private void PrintHandle(StringWriter message, ScheduleHandle handle) { if (handle is EPStatementHandleCallback) { var callback = (EPStatementHandleCallback)handle; TypeHelper.WriteInstance(message, callback.ScheduleCallback, true); } else { TypeHelper.WriteInstance(message, handle, true); } }
public void ScheduleRemove( AgentInstanceContext agentInstanceContext, ScheduleHandle scheduleHandle, ScheduleObjectType objectType, string name) { ProcScheduleRemove?.Invoke( agentInstanceContext, scheduleHandle, objectType, name); }
public void ScheduleAdd( long nextScheduledTime, AgentInstanceContext agentInstanceContext, ScheduleHandle scheduleHandle, ScheduleObjectType objectType, string name) { ProcScheduleAdd?.Invoke( nextScheduledTime, agentInstanceContext, scheduleHandle, objectType, name); }
private void AddTrigger(ScheduleSlot slot, ScheduleHandle handle, long triggerTime) { var handleSet = _timeHandleMap.Get(triggerTime); if (handleSet == null) { handleSet = new NullableDictionary <ScheduleSlot, ScheduleHandle>( new OrderedDictionary <ScheduleSlot, ScheduleHandle>()); _timeHandleMap.Put(triggerTime, handleSet); } handleSet.Put(slot, handle); _handleSetMap.Put(handle, handleSet); }
public void Add(long afterMSec, ScheduleHandle handle, long slot) { if (AuditPath.IsInfoEnabled) { StringWriter message = new StringWriter(); message.Write("after "); message.Write(afterMSec); message.Write(" handle "); PrintHandle(message, handle); AuditPath.AuditLog(_engineUri, _statementName, AuditEnum.SCHEDULE, message.ToString()); ModifyCreateProxy(handle); } _spi.Add(afterMSec, handle, slot); }
public void Add(long afterTime, ScheduleHandle handle, long slot) { using (Instrument.With( i => i.QScheduleAdd(_currentTime, afterTime, handle, slot), i => i.AScheduleAdd())) { using (_uLock.Acquire()) { if (_handleSetMap.ContainsKey(handle)) { Remove(handle, slot); } long triggerOnTime = _currentTime + afterTime; AddTrigger(slot, handle, triggerOnTime); } } }
void OnConnectionClosed(ScheduleHandle handle) { var context = (ConnectionContext)handle.UserToken; context.OpenHandles--; if (context.OpenHandles > 0) { return; } if (this.deplux || context.IsServerConnection) { if (context.Receive == TransferBytes) { this.closedConnections++; } } else { if (context.Receive == 0) { this.closedConnections++; } } if (this.deplux || !context.IsServerConnection) { if (context.Sent == TransferBytes) { this.closedConnections++; } else { if (context.Sent == 0) { this.closedConnections++; } } } }
public void Remove(ScheduleHandle handle, long scheduleSlot) { using (Instrument.With( i => i.QScheduleRemove(handle, scheduleSlot), i => i.AScheduleRemove())) { using (_uLock.Acquire()) { var handleSet = _handleSetMap.Get(handle); if (handleSet == null) { // If it already has been removed then that's fine; // Such could be the case when 2 timers fireStatementStopped at the same time, and one stops the other return; } handleSet.Remove(scheduleSlot); _handleSetMap.Remove(handle); } } }
public void Tcp() { this.closeCount = 0; this.connectedCount = 0; this.connectionCount = 0; var anyEndPoint = new IPEndPoint(IPAddress.Loopback, Port); Tcp tcpServer = this.loop.CreateTcp(); tcpServer.Listen(anyEndPoint, this.OnConnection); this.server = tcpServer; IPEndPoint localEndPoint = tcpServer.GetLocalEndPoint(); Assert.NotNull(localEndPoint); Assert.Equal(anyEndPoint.Address, localEndPoint.Address); Assert.Equal(Port, localEndPoint.Port); var error = Assert.Throws <OperationException>(() => tcpServer.GetPeerEndPoint()); Assert.Equal(ErrorCode.ENOTCONN, error.ErrorCode); var remoteEndPoint = new IPEndPoint(IPAddress.Loopback, Port); Tcp client = this.loop.CreateTcp().ConnectTo(remoteEndPoint, this.OnConnected); IPEndPoint endPoint = client.GetLocalEndPoint(); Assert.NotNull(endPoint); Assert.Equal(anyEndPoint.AddressFamily, endPoint.AddressFamily); Assert.True(endPoint.Port > 0); this.loop.RunDefault(); Assert.Equal(1, this.connectedCount); Assert.Equal(1, this.connectionCount); Assert.Equal(3, this.closeCount); }
static void OnClose(ScheduleHandle handle) => handle.Dispose();
public bool IsScheduled(ScheduleHandle handle) { return(_handleSetMap.ContainsKey(handle)); }
void OnClose(ScheduleHandle handle) { handle.Dispose(); this.closeCount++; }
public void QScheduleRemove(ScheduleHandle handle, long slot) { }
public void Remove(ScheduleHandle callback, ScheduleSlot slot) { Log.Debug(".remove Not implemented, callback=" + callback.GetType().Name); }
public void Add(long afterMSec, ScheduleHandle callback, ScheduleSlot slot) { Log.Debug(".add Not implemented, afterMSec=" + afterMSec + " callback=" + callback.GetType().Name); _added.Put(afterMSec, callback); }
public bool IsScheduled(ScheduleHandle scheduleHandle) { return(false); //To change body of implemented methods use File | Settings | File Templates. }
public void QScheduleRemove(ScheduleHandle handle, ScheduleSlot slot) { }